/* ============================================================
   蝶妙思丝 ERP · 共享组件（全站共用）
   三页共用这一套，不许每页各写一套样式。
   色值只许用 tokens.css 里的变量。
   第 01 批修订（2026-11-21）：可读次文字、状态浅底、左分组导航、
   宽工作区、窄屏容器内横滚、开单底部吸底。
   ============================================================ */

/* ---- 顶栏 ---- */
.topbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo { font-size: 18px; font-weight: 700; color: var(--brand); white-space: nowrap; line-height: 1.3; }
.logo small { display: block; font-size: var(--fs-sub); color: var(--muted-strong); font-weight: 400; }
.topbar .search {
  flex: 1; max-width: 340px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 8px 12px;
  font-size: 13px; color: var(--ink);
}
.topbar .search::placeholder { color: var(--muted); }
.bell {
  margin-left: auto; position: relative;
  background: none; border: 0; font-size: 13px; color: var(--muted-strong);
  padding: 6px 2px;
}
.bell .badge {
  position: absolute; top: -4px; right: -10px;
  background: var(--danger); color: var(--card);
  font-size: 11px; font-weight: 700; line-height: 16px;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: var(--card);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex: none;
}

/* ---- 页签行（快捷入口） ---- */
.tabs { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.tab {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 7px 14px; font-size: 13px; color: var(--muted-strong);
  display: inline-flex; align-items: center; gap: 6px;
}
a.tab:hover { color: var(--brand); border-color: var(--brand); }
.tab.on { background: var(--brand); border-color: var(--brand); color: var(--card); font-weight: 700; }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); display: inline-block; }
.tab--soon { cursor: default; }

/* ---- 左分组导航（完整导航；顶栏 + 页签只作快捷入口） ---- */
.shell { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 12px; align-items: start; } /* 第 01 批修订2：侧栏由 200px 收至 184px，给销售表多让 16px，客户名少换行 */
.shell > *, .qo > * { min-width: 0; } /* 窄屏时栅格子项可收缩，表格在容器内横滚而不是撑破外壳 */
.sidenav { position: sticky; top: 20px; padding: 10px 12px; }
.nav-group { margin-bottom: 10px; }
.nav-group:last-child { margin-bottom: 0; }
.nav-group-t { font-size: var(--fs-sub); font-weight: 700; color: var(--muted-strong); padding: 6px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--radius-btn);
  font-size: 13px; color: var(--ink);
  border-left: 3px solid transparent;
}
a.nav-item:hover { background: var(--hover-bg); color: var(--brand); }
.nav-item.on { background: var(--sel-bg); border-left-color: var(--brand); color: var(--brand); font-weight: 700; }
.nav-cur {
  margin-left: auto; font-size: 11px; font-weight: 700; color: var(--brand);
  border: 1px solid var(--brand); border-radius: var(--radius-tag);
  padding: 1px 5px; line-height: 1.4; white-space: nowrap;
}
.nav-soon { color: var(--muted-strong); cursor: default; }
.nav-soon .soon {
  margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted-strong);
  border: 1px solid var(--line); border-radius: var(--radius-tag);
  padding: 1px 5px; line-height: 1.4; white-space: nowrap; background: var(--muted-bg);
}

/* ---- 卡片 ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px;
}
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card h1 { font-size: var(--fs-title); font-weight: 700; }

/* ---- 按钮（一页只有一个 .btn-primary） ---- */
[hidden] { display: none !important; } /* hidden 属性优先于组件的 display（.actions 是 flex，[hidden] 会被覆盖） */
.btn {
  height: var(--btn-h);
  border-radius: var(--radius-btn);
  padding: 0 18px;
  font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: var(--card); }
.btn-primary:hover { filter: brightness(0.92); }
.btn-secondary { background: var(--card); color: var(--brand); border-color: var(--brand); }
.btn-secondary:hover { background: var(--pink); }
.btn-danger { background: var(--danger); color: var(--card); }
.btn-danger:hover { filter: brightness(0.92); }
.btn-text { background: none; border-color: transparent; color: var(--link); font-weight: 400; }
.btn-text:hover { color: var(--brand); }
.btn:disabled { background: var(--disabled-bg); color: var(--muted-strong); border-color: var(--line); cursor: not-allowed; filter: none; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ---- 状态徽标 ---- */
.tag {
  font-size: 11px; font-weight: 700; line-height: 1.4;
  border-radius: var(--radius-tag);
  padding: 2px 7px; white-space: nowrap;
  border: 1px solid transparent;
  display: inline-block;
}
.tag-ok { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.tag-warn { color: var(--warn); border-color: var(--warn); background: var(--amber-bg); }
.tag-danger { color: var(--danger); border-color: var(--danger); background: var(--pink); }
.tag-muted { color: var(--muted-strong); border-color: var(--line); background: var(--muted-bg); }
.tag-ref { color: var(--danger); border-color: var(--danger); background: var(--card); }

/* ---- 表格 ---- */
.tbl-wrap { overflow-x: auto; } /* 窄屏时表格在容器内横滚，页面外壳不横溢；不藏列 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl-wrap > .tbl { min-width: 720px; }
.tbl th {
  text-align: left; color: var(--muted-strong); font-weight: 700; font-size: var(--fs-sub);
  padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:not(.sel):hover td { background: var(--hover-bg); }
.tbl tr.sel td { background: var(--sel-bg); }
.tbl tr.sel td:first-child { border-left: 3px solid var(--brand); }

/* 金额：右对齐、等宽数字 */
.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-recv { font-weight: 700; color: var(--ink); }
.money-got { color: var(--ok); }
.money-left { color: var(--warn); font-weight: 700; }
.money-ref { color: var(--danger); }
.money-zero { color: var(--muted-strong); } /* 确认是零：灰色横线 — */
.money-unknown { color: var(--muted-strong); font-weight: 700; } /* 金额未知：写「待确认」，不用 0 或横线 */

/* 逐单操作：灰色文字链接（样板占位，未接通；实际可用性按角色与状态在接入时定） */
.row-act { color: var(--link); font-size: 13px; white-space: nowrap; }
.row-act:hover { color: var(--brand); }
.row-act + .row-act::before { content: "·"; color: var(--muted); margin: 0 4px; }

/* ---- 销售表：短字段给最小宽度、不换行；客户名可换行；操作区固定宽度 ----
   第 01 批修订2（2026-11-21）：1366×768 下订单号、时间、件数、操作反复换行把行高撑大，
   首屏只剩 7 行。短字段 nowrap + 最小宽度，表格不够宽时在 .tbl-wrap 内横滚，不撑页面；
   不缩小字号；查看 / 改单 / 收款三项全留，不折叠进「更多」。 */
.tbl-sales { min-width: 1010px; }
.tbl-sales td, .tbl-sales th { padding: 8px 6px; } /* 密度：行内边距收窄，单行行高约 44px → 36px；字号不动 */
.tbl-sales th:nth-child(1), .tbl-sales td:nth-child(1) { white-space: nowrap; min-width: 118px; } /* 订单号 SO-20261121-01，不在连字符处断行 */
.tbl-sales td:nth-child(2) { min-width: 150px; max-width: 250px; } /* 客户名：允许换行 */
.tbl-sales th:nth-child(3), .tbl-sales td:nth-child(3) { white-space: nowrap; min-width: 92px; } /* 下单时间 11-21 09:12，不在空格处断行 */
.tbl-sales th:nth-child(4), .tbl-sales td:nth-child(4) { white-space: nowrap; min-width: 88px; } /* 商品 3 款 · 46 件 */
.tbl-sales th:nth-child(5), .tbl-sales td:nth-child(5),
.tbl-sales th:nth-child(6), .tbl-sales td:nth-child(6),
.tbl-sales th:nth-child(7), .tbl-sales td:nth-child(7),
.tbl-sales th:nth-child(8), .tbl-sales td:nth-child(8) { min-width: 86px; } /* 金额列已 nowrap，再给最小宽 */
.tbl-sales th:nth-child(9), .tbl-sales td:nth-child(9) { white-space: nowrap; min-width: 76px; } /* 状态 */
.tbl-sales th:nth-child(10), .tbl-sales td:nth-child(10) { white-space: nowrap; min-width: 122px; } /* 操作：查看 / 改单 / 收款 */

/* 合计旁的待确认说明：不用滚到页脚就知道合计范围 */
.pending-note { font-size: var(--fs-sub); color: var(--muted-strong); font-weight: 400; white-space: nowrap; }

/* ---- 采购分析表：短字段给最小宽度、不换行；供应商名可换行 ----
   第 02 批（2026-11-21）：与销售表同一做法，不缩小字号；表格不够宽时在 .tbl-wrap 内横滚，不撑页面。 */
.tbl-purchase { min-width: 980px; }
.tbl-purchase td, .tbl-purchase th { padding: 8px 6px; }
.tbl-purchase th:nth-child(1), .tbl-purchase td:nth-child(1) { white-space: nowrap; min-width: 118px; } /* 采购单号 PO-20261120-03 */
.tbl-purchase th:nth-child(2), .tbl-purchase td:nth-child(2) { white-space: nowrap; min-width: 92px; } /* 日期 2026-11-20 */
.tbl-purchase td:nth-child(3) { min-width: 150px; max-width: 250px; } /* 供应商名：允许换行 */
.tbl-purchase th:nth-child(4), .tbl-purchase td:nth-child(4) { white-space: nowrap; min-width: 70px; } /* 货号 */
.tbl-purchase th:nth-child(5), .tbl-purchase td:nth-child(5) { white-space: nowrap; min-width: 84px; } /* 规格 黑 / M */
.tbl-purchase th:nth-child(6), .tbl-purchase td:nth-child(6) { white-space: nowrap; min-width: 64px; text-align: right; } /* 数量 */
.tbl-purchase th:nth-child(7), .tbl-purchase td:nth-child(7),
.tbl-purchase th:nth-child(8), .tbl-purchase td:nth-child(8) { min-width: 86px; } /* 单价、金额已 nowrap */
.tbl-purchase th:nth-child(9), .tbl-purchase td:nth-child(9) { white-space: nowrap; min-width: 76px; } /* 状态 */
/* 被排除在实际采购之外的行：状态徽标后加灰色「不计入」 */
.excluded { font-size: var(--fs-sub); color: var(--muted-strong); white-space: nowrap; }

/* ---- 仓库盘点表：货号/颜色/尺码不换行；账面、实盘、差额右对齐 ----
   第 02 批修订（2026-11-21）：1366×768 下差额列被截断。左栏搜索区 380px → 320px，
   表格列宽收紧（货号 64px、颜色 56px、尺码 56px、账面/实盘/差额各 76px），
   表格最小宽 760px → 640px；不缩字号；表头与关键单元格须在 1366 下全部水平可见。 */
.tbl-count { min-width: 640px; }
.tbl-count td, .tbl-count th { padding: 8px 4px; }
.tbl-count th:nth-child(1), .tbl-count td:nth-child(1) { white-space: nowrap; min-width: 64px; } /* 货号 */
.tbl-count th:nth-child(2), .tbl-count td:nth-child(2) { white-space: nowrap; min-width: 56px; } /* 颜色 */
.tbl-count th:nth-child(3), .tbl-count td:nth-child(3) { white-space: nowrap; min-width: 56px; } /* 尺码 */
.tbl-count th:nth-child(4), .tbl-count td:nth-child(4),
.tbl-count th:nth-child(5), .tbl-count td:nth-child(5),
.tbl-count th:nth-child(6), .tbl-count td:nth-child(6) { text-align: right; white-space: nowrap; min-width: 76px; } /* 账面、实盘、差额 */

/* ---- 盘点实盘输入：右对齐数字框，留空 = 未盘，填 0 = 实盘零；框内 ↑ / ↓ 键加减（第 02 批修订补行为，见 stocktake.js） ---- */
.num-input {
  width: 84px; height: 32px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  background: var(--card); font-size: 13px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.num-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(176, 58, 91, 0.12); }
.num-input:disabled { background: var(--page); color: var(--muted-strong); }

/* ---- 筛选区 / 表单 ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input, .filters select {
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  padding: 8px 10px; font-size: 13px; background: var(--card); height: var(--btn-h);
}
.filters input::placeholder { color: var(--muted); }

/* ---- KPI ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 16px; }
.kpi .l { font-size: var(--fs-sub); color: var(--muted-strong); }
.kpi .n { font-size: 30px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .n .u { font-size: 14px; font-weight: 400; }
.kpi .n.rose { color: var(--brand); }
.kpi .n.red { color: var(--danger); }
.kpi .n.amber { color: var(--warn); }
.kpi .s { font-size: var(--fs-sub); color: var(--muted-strong); }

/* ---- 待办行 ---- */
.todo { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; }
.todo .t { flex: 1; min-width: 0; }
.todo .t b { font-size: 13px; display: block; }
.todo .t p { font-size: var(--fs-sub); color: var(--muted-strong); }

/* ---- 键值行 ---- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.kv:first-of-type { border-top: 0; }
.kv span { color: var(--muted-strong); font-size: var(--fs-sub); white-space: nowrap; }

/* ---- 提醒条 ---- */
.alert {
  border: 1px solid var(--line);
  background: var(--pink);
  border-radius: 10px;
  padding: 10px 12px; font-size: 13px;
}
.alert b { color: var(--danger); }

/* ---- 搜索框（带放大镜图标） ---- */
.search-box { position: relative; margin-bottom: 10px; }
.search-box .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input {
  width: 100%; height: 40px; padding: 0 12px 0 36px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  background: var(--card); font-size: 14px; color: var(--ink);
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(176, 58, 91, 0.12); }

/* ---- 商品选择：款式卡 + 规格行 ---- */
.prod-grid { display: flex; flex-direction: column; gap: 10px; }
.prod { border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.prod-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.prod-head .thumb { width: 44px; height: 44px; border-radius: 8px; flex: none; }
.prod-head .info { flex: 1; min-width: 0; }
.prod-head .info b { font-size: 13px; display: block; }
.prod-head .info span { font-size: var(--fs-sub); color: var(--muted-strong); display: block; }
.prod-head .price { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.var-list { border-top: 1px solid var(--line); }
.var-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; }
.var-row + .var-row { border-top: 1px solid var(--line); }
.var-row .var-spec { flex: 1; min-width: 0; }
.var-row .var-price { font-weight: 700; white-space: nowrap; }
.var-row .var-stock { font-size: var(--fs-sub); color: var(--muted-strong); white-space: nowrap; }
.var-row .var-stock.stock-out { color: var(--warn); }
.var-row .add { border: 0; background: none; color: var(--brand); font-weight: 700; font-size: 13px; padding: 2px 4px; cursor: pointer; white-space: nowrap; }

/* ---- 明细商品缩略图 ---- */
.mini-thumb {
  width: 44px; height: 44px; border-radius: 8px; flex: none;
  display: block;
}
.line-prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.line-prod .nm { min-width: 0; }
.line-prod .nm b { font-size: 13px; display: block; }
.line-prod .nm span { font-size: var(--fs-sub); color: var(--muted-strong); display: block; }
.line-prod .nm .stock-out { color: var(--warn); }

/* ---- 数量步进器 ---- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-btn); overflow: hidden; }
.stepper button {
  width: 30px; height: 30px; border: 0; background: var(--card);
  font-size: 15px; color: var(--ink); line-height: 1;
}
.stepper button:hover { background: var(--pink); color: var(--brand); }
.stepper input {
  width: 44px; height: 30px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: center; font-size: 13px; background: var(--card);
}
.stepper button:disabled { color: var(--muted); background: var(--page); cursor: not-allowed; }

/* ---- 页脚 / 合计 ---- */
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: var(--fs-sub); color: var(--muted-strong); flex-wrap: wrap; }
.foot b { color: var(--ink); font-variant-numeric: tabular-nums; }
.page-note { margin-top: 10px; font-size: var(--fs-sub); color: var(--muted-strong); }

/* ---- 开单底部吸底（长单时合计与主操作始终可见，不遮最后一行） ---- */
.order-foot {
  position: sticky; bottom: 0; z-index: 1;
  background: var(--card);
  border-top: 1px solid var(--line);
  margin: 12px -16px -14px; padding: 10px 16px 12px;
}
.order-foot .foot { margin-top: 0; }
.form-error { color: var(--danger); font-size: 13px; font-weight: 700; margin: 8px 0 0; }

/* ---- 窄屏 ---- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { position: static; }
  .sidenav nav { display: flex; gap: 16px; overflow-x: auto; }
  .nav-group { flex: none; margin-bottom: 0; }
}
@media (max-width: 700px) {
  body { padding: 12px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   第 04 批新增（2026-11-21）：只追加新类，不改已有类样式。
   销售详情 / 仓库配货 / 打印预览共用。
   ============================================================ */

/* 缺货行：浅粉底，与急单浅粉同色，另加「缺货 N 件」文字标签，不只靠颜色区分 */
.tbl tr.row-shortage td { background: var(--pink); }

/* 演示用文字链接（与盘点页 .demo-link 同款） */
.demo-link { background: none; border: 0; color: var(--link); font-size: 12px; text-decoration: underline; padding: 0; cursor: pointer; }
.demo-link:hover { color: var(--brand); }
