/* 看板样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* 兜底：hidden 属性必须始终生效（否则任何作者 display 规则都会把它盖掉） */
[hidden] { display: none !important; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", Consolas, monospace;
  background: #f0f2f5; color: #222; font-size: 14px;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #1f3a6d; color: #fff; padding: 10px 18px;
  position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.topbar h1 { font-size: 18px; }
.meta { display: flex; gap: 8px; align-items: center; }
.badge {
  background: #33486e; padding: 3px 10px; border-radius: 12px; font-size: 12px; color: #cfd8e6;
}
select, button {
  background: #33486e; color: #fff; border: 1px solid #4a5f8f; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 12px;
}
button:hover { background: #45619c; }

.board {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px;
  align-items: start;
}
.card {
  background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.12);
  overflow: hidden;
}
.card.full { grid-column: 1 / -1; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 13px; background: #eef2f8; border-bottom: 1px solid #e0e5ee;
  font-weight: 600; cursor: grab; user-select: none;
}
.card-head:active { cursor: grabbing; }
.card-head .drag-hint { font-size: 11px; color: #98a3b5; font-weight: normal; }
.card-body { padding: 10px; max-height: 420px; overflow: auto; }
.card.dragging { opacity: .55; border: 2px dashed #1f3a6d; }
/* 联动反馈：卡片闪一下边框（替代原来的自动滚动，避免页面突然跳动） */
.card.linked-flash {
  animation: linkedFlash 1.4s ease-out 1;
}
@keyframes linkedFlash {
  0%   { box-shadow: 0 0 0 0 rgba(43,108,214,.55); }
  35%  { box-shadow: 0 0 0 3px rgba(43,108,214,.55); }
  100% { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
}
/* 导出按钮：跟在搜索框下面一行，低调一点 */
button.export-btn {
  margin: -2px 0 8px 0; padding: 4px 12px; font-size: 12px;
  background: #1d7f3f; border-color: #2a9b52;
}
button.export-btn:hover { background: #229549; }
button.export-btn:disabled { background: #7d9c88; cursor: default; }
/* 双击标题最大化：卡片铺满视口（再次双击标题 / 按 Esc 还原） */
.card.maximized {
  position: fixed; inset: 0; z-index: 200; border-radius: 0;
  display: flex; flex-direction: column; box-shadow: none;
}
.card.maximized .card-body { max-height: none; flex: 1 1 auto; }
.card.maximized .card-head { cursor: default; }
body.has-maximized { overflow: hidden; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
th, td { border: 1px solid #e3e8f0; padding: 5px 8px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 名称/品名列：列宽由 colgroup 指定，长文本省略显示（悬停 title 看全名） */
th.name, td.name { max-width: 170px; }
th { background: #f4f6fb; position: sticky; top: 0; }
/* 可排序列：点击切换升序/降序，箭头指示当前方向 */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #e6edf9; }
th.sortable::after { content: "⇅"; opacity: .35; margin-left: 4px; font-size: 10px; }
th.sortable.sorted-asc::after { content: "▲"; opacity: 1; color: #1f3a6d; }
th.sortable.sorted-desc::after { content: "▼"; opacity: 1; color: #1f3a6d; }
/* 列头 ⧉ 一键复制本列 */
th .colcopy { opacity: .3; margin-left: 3px; cursor: pointer; font-size: 10px; }
th .colcopy:hover { opacity: 1; color: #1f3a6d; }

/* 表格块选高亮（Alt+拖动 或 点列头复制时的选中范围） */
td.blk { background: #cfe3ff !important; box-shadow: inset 0 0 0 1px #6f9fe0; }
/* 块选浮动条 + 复制结果提示 */
#selBar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 400; display: flex; gap: 8px;
}
#selBar button {
  background: #1f3a6d; color: #fff; border: none; border-radius: 6px;
  padding: 7px 14px; font-size: 12.5px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}
#selBar button.ghost { background: #5a6b8c; }
#toast {
  position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%);
  z-index: 500; background: rgba(20,32,58,.93); color: #fff;
  padding: 7px 15px; border-radius: 6px; font-size: 12.5px;
}
tr.alert-red td { background: #ffe5e5; color: #a30000; font-weight: 600; }
tr.alert-yellow td { background: #fff4d6; }
tr.selected td { outline: 2px solid #1f3a6d; outline-offset: -2px; }
tbody tr[data-sku]:hover td { filter: brightness(0.95); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 预警行「上下架」按钮（等同双击该行） */
td.op-cell { text-align: center; padding: 3px 6px; }
button.sku-btn {
  background: #1f3a6d; color: #fff; border: none; border-radius: 5px;
  padding: 3px 10px; font-size: 11.5px; line-height: 1.5; cursor: pointer;
  white-space: nowrap;
}
button.sku-btn:hover { background: #2c4d8f; }
button.sku-btn:active { background: #16294d; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; color: #fff; }
.pill.red { background: #d64545; }
.pill.yellow { background: #d9a028; }
.pill.ok { background: #3da25e; }

.kpi-row { display: flex; gap: 12px; margin-bottom: 10px; }
.kpi {
  flex: 1; background: #f7f9fc; border: 1px solid #e3e8f0; border-radius: 8px;
  padding: 8px 12px; text-align: center;
}
.kpi .n { font-size: 22px; font-weight: 700; }
.kpi .l { font-size: 11px; color: #75809a; }
.kpi.n-red .n { color: #d64545; }
.kpi.n-yellow .n { color: #d9a028; }
.kpi.n-green .n { color: #3da25e; }

.sub-list { margin-top: 4px; border-top: 1px dashed #e3e8f0; padding-top: 4px; font-size: 11.5px; color: #455; }
.po-line { display: flex; justify-content: space-between; gap: 6px; }
.search { width: 100%; padding: 6px 8px; border: 1px solid #d4dbe8; border-radius: 6px; margin-bottom: 8px; font-size: 12.5px; }
/* 预警模块：搜索框 + 「隐藏饼底/水果」勾选框同一行 */
.filter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.filter-row .search { flex: 1; width: auto; margin-bottom: 0; }
.filter-row .chk {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
  font-size: 12.5px; color: #455; white-space: nowrap; cursor: pointer; user-select: none;
}
.filter-row .chk input { margin: 0; cursor: pointer; }
.filter-row .hidden-hint { color: #9aa4b8; font-size: 11.5px; }
/* 单位（库存单位）列：窄列、弱化显示，别抢数量的视觉 */
td.uom { color: #5b6b7f; font-size: 11.5px; text-align: center; white-space: nowrap; }
/* 需求模块「按订单号联动」视图 */
.link-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #fff8e6; border: 1px solid #f0dfae; border-radius: 6px;
  padding: 5px 9px; margin-bottom: 8px; font-size: 12.5px; color: #6b5a2a;
}
.link-bar .uom-inline { color: #8a7a4a; font-size: 11.5px; }
.link-bar .link-clear {
  margin-left: auto; background: #e8d9a8; color: #5a4a1a; border-color: #d9c68c;
  padding: 3px 9px; font-size: 11.5px;
}
.link-bar .link-clear:hover { background: #ddc98e; }
.link-total {
  margin-top: 8px; padding: 6px 9px; background: #f6f8fc; border-radius: 6px;
  font-size: 12.5px; color: #41506b;
}
.link-total b { color: #1f3a6d; font-size: 14px; }
td.src { color: #6b7a90; font-size: 11.5px; text-align: center; white-space: nowrap; }
tr.total-row td {
  background: #f2f5fb; font-weight: 600; color: #24365c;
  border-top: 2px solid #dbe3f0;
}
.empty { color: #9aa4b8; text-align: center; padding: 18px 0; }
.foot { text-align: center; color: #9aa4b8; font-size: 11px; padding: 8px; }

/* 上下架平台模态框（双击预警物料打开） */
.sku-modal {
  position: fixed; inset: 0; z-index: 300; background: rgba(15, 28, 55, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
/* 必须显式声明：作者样式的 display:flex 会盖过 UA 的 [hidden]{display:none}，
   否则带 hidden 属性时模态框照样显示 */
.sku-modal[hidden] { display: none; }
.sku-modal-box {
  background: #fff; border-radius: 10px; width: 96vw; height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}
.sku-modal-head {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  background: #1f3a6d; color: #fff; font-size: 13.5px;
}
.sku-modal-head .sku-modal-status { font-size: 12px; color: #b9c6de; }
.sku-modal-head .sku-modal-actions { margin-left: auto; display: flex; gap: 8px; }
.sku-modal-head button {
  background: #33486e; color: #fff; border: 1px solid #4a5f8f;
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 12px;
}
.sku-modal-head button:hover { background: #45619c; }
.sku-modal-body { position: relative; flex: 1 1 auto; }
.sku-modal-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.sku-modal-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #5b6b86; font-size: 13.5px; text-align: center; padding: 20px;
  background: #f7f9fc; z-index: 1;
}
.sku-modal-msg[hidden] { display: none; }
.sku-modal-msg.err { color: #b42318; }

/* 金蝶登录界面 */
.login-overlay {
  position: fixed; inset: 0; background: rgba(15, 28, 55, .86);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-box {
  background: #fff; border-radius: 14px; padding: 32px 38px; width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.login-box h2 { font-size: 20px; margin-bottom: 6px; }
.login-tip { color: #75809a; font-size: 12.5px; margin-bottom: 18px; }
.login-box label { display: block; font-size: 12.5px; color: #445; margin: 12px 0 4px; }
.login-box input[type=text], .login-box input[type=password] {
  width: 100%; padding: 9px 10px; border: 1px solid #c9d3e4; border-radius: 8px;
  font-size: 14px; outline: none;
}
.login-box input:focus { border-color: #1f3a6d; }
.login-box input.acct-fixed {
  background: #eef1f6; color: #55627a; cursor: not-allowed;
}
.remember-row { display: flex !important; align-items: center; gap: 6px; font-size: 12.5px !important; }
.remember-row input { width: auto !important; }
.login-error {
  background: #ffecec; color: #b42318; border: 1px solid #f5c6c0;
  border-radius: 8px; padding: 8px 10px; margin-top: 12px; font-size: 12.5px;
}
.login-btn {
  width: 100%; background: #1f3a6d; color: #fff; border: none; border-radius: 8px;
  padding: 11px; font-size: 15px; margin-top: 18px; cursor: pointer;
}
.login-btn:hover { background: #2c4d8f; }
.login-btn:disabled { background: #9aa8c2; cursor: wait; }
.watch-only {
  width: 100%; background: none; color: #7d8aa5; border: 1px solid #d4dbe8;
  border-radius: 8px; padding: 8px; font-size: 12.5px; margin-top: 8px; cursor: pointer;
}
.badge.erp-ok { background: #1d7f3f; }

/* ===== 预警表底部：昨日物料行（昨天有单、今天没单；仅用于搜索/上下架，不参与预警计算）===== */
.pill.grey { background: #8a93a6; }
tr.alert-yesterday td { background: #f1f3f7; color: #5b6478; }
tr.alert-yesterday td.num.dim { color: #b3bac8; }
tr.alert-yesterday td.name { color: #4a5364; }
.kpi.n-yesterday .n { color: #8a93a6; }

/* ===== 卡片「关联条」（点预警物料 → 库存卡单独显示该物料）===== */
.link-bar { margin: 6px 0 8px; padding: 6px 10px; background: #eef3ff; border: 1px solid #c9d8f7;
  border-radius: 6px; font-size: 12px; color: #1f3a6d; display: flex; align-items: center; gap: 6px; }
.link-bar b { font-family: Consolas, monospace; }
.link-bar .link-info { color: #5b6478; }
.unlink-btn { margin-left: auto; cursor: pointer; border: 1px solid #c9d8f7; background: #fff;
  color: #1f3a6d; border-radius: 4px; padding: 2px 8px; font-size: 12px; }
.unlink-btn:hover { background: #e2eaff; }

/* ===== 顶部标题旁的「上下架平台」入口（大号、可点击）===== */
.topbar h1 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar h1 .title-link {
  font-size: 17px; font-weight: 700; cursor: pointer;
  padding: 6px 16px; border-radius: 8px;
  border: 1px solid #2f6fd0; background: #2f6fd0; color: #fff;
  box-shadow: 0 1px 3px rgba(47,111,208,.35);
  transition: background .15s, transform .05s;
}
.topbar h1 .title-link:hover { background: #2559a8; }
.topbar h1 .title-link:active { transform: translateY(1px); }

/* ===== WMS 库存卡：有分配数量=浅红底，有冻结数量=浅黄底（只在该值 > 0 时上色）===== */
table tbody td.cell-alloc { background: #ffe1e1 !important; color: #b03030; font-weight: 600; }
table tbody td.cell-hold  { background: #fff3c4 !important; color: #8a6d00; font-weight: 600; }