/* ================= 率客 WMS · 界面样式（工业管理风 / 浅色） ================= */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --accent: #1d4ed8;
  --accent-2: #2563eb;
  --accent-soft: #eaf0ff;
  --blue: #1d4ed8;
  --green: #15803d;
  --orange: #c2410c;
  --red: #b42318;
  --gray: #64748b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); letter-spacing: -.2px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 212px; flex: 0 0 212px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; border-bottom: 1px solid var(--line-2); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 7px; flex: 0 0 32px;
  background: linear-gradient(140deg, #1d4ed8, #0f2f9e);
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; letter-spacing: .5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-name { font-size: 13.5px; font-weight: 650; letter-spacing: .2px; line-height: 1.25; }
.brand-sub { font-size: 10.5px; color: var(--faint); letter-spacing: .8px; text-transform: uppercase; }

.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: 1px; color: var(--faint); padding: 12px 10px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 6px; color: var(--ink-2); cursor: pointer;
  position: relative; font-size: 12.8px; user-select: none;
  border: 1px solid transparent;
}
.nav-item:hover { background: #f6f8fc; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-color: #dbe6ff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; opacity: .85; }
.nav-badge { margin-left: auto; font-size: 10.5px; font-family: var(--mono); background: #fde8e4; color: var(--red); border-radius: 9px; padding: 0 5px; line-height: 16px; }

/* 侧边栏自定义排序 */
.nav-tools { padding: 0 8px 8px; }
.nav-tool {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px dashed var(--line); background: #fbfcfe; color: var(--muted);
  font-size: 11.5px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-family: inherit; line-height: 1.3;
}
.nav-tool:hover { color: var(--accent); border-color: #c7d7fb; background: var(--accent-soft); }
.nav-tool svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.nav-tools.sorting { border-top: 1px dashed var(--line-2); margin-top: 2px; padding-top: 8px; }
.nav-tip { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 5px 8px; margin-bottom: 6px; line-height: 1.4; }
.nav-tool-row { display: flex; gap: 6px; }
.nav-tool-row .nav-tool { flex: 1; width: auto; }
.nav-tool.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.nav-tool.primary:hover { background: #1a45c0; color: #fff; }
.nav-grip { display: none; font-size: 11px; color: var(--faint); letter-spacing: -1px; margin-right: -2px; }
.nav.sorting .nav-grip { display: inline-block; }
.nav.sorting .nav-item { cursor: grab; }
.nav.sorting .nav-item.active { background: #fff; color: var(--ink-2); font-weight: 500; border-color: var(--line); }
.nav.sorting .nav-item.active::before { display: none; }
.nav-item.dragging {
  pointer-events: none; opacity: .92; background: #fff;
  border-color: var(--accent); box-shadow: 0 6px 18px rgba(29,78,216,.22); cursor: grabbing;
}
body.nav-sorting { user-select: none; -webkit-user-select: none; }

.side-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line-2); font-size: 11px; color: var(--faint); line-height: 1.6; }
.side-foot b { color: var(--ink-2); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex: 0 0 56px;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; position: sticky; top: 0; z-index: 25;
}
.page-title { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.page-sub { font-size: 11.5px; color: var(--muted); margin-top: -1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.role-select {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 20px; padding: 6px 10px 6px 12px; font-size: 12px; cursor: pointer;
  font-family: inherit; outline: none;
}
.role-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.clock { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
/* 多端同步状态：绿=已同步，青=实时推送在线，蓝=同步中，红=冲突，橙=离线 */
.sync-chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px; background: transparent;
}
.sync-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; flex: 0 0 auto; }
.sync-chip[data-state="saved"]::before { background: #16a34a; }
.sync-chip[data-state="live"]::before { background: #0d9488; animation: syncPulse 2.4s ease-in-out infinite; }
.sync-chip[data-state="pulling"]::before,
.sync-chip[data-state="saving"]::before { background: #2563eb; animation: syncPulse 1s ease-in-out infinite; }
.sync-chip[data-state="error"]::before { background: #dc2626; }
.sync-chip[data-state="offline"]::before { background: #f59e0b; }
@keyframes syncPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.view { padding: 18px 20px 48px; max-width: 1680px; width: 100%; }

/* ---------------- 卡片 / KPI ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #cbd5e1; }
.kpi.k-blue::after { background: var(--blue); }
.kpi.k-green::after { background: var(--green); }
.kpi.k-orange::after { background: var(--orange); }
.kpi.k-red::after { background: var(--red); }
.kpi.k-gray::after { background: #94a3b8; }
.kpi-label { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 23px; font-weight: 650; font-family: var(--mono); letter-spacing: -.6px; margin-top: 4px; line-height: 1.15; }
.kpi-value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; font-family: inherit; letter-spacing: 0; }
.kpi-sub { font-size: 11px; color: var(--faint); margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.panel-hd { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.panel-title { font-size: 12.8px; font-weight: 650; }
.panel-title .muted { font-weight: 400; margin-left: 6px; font-size: 11.5px; }
.panel-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.panel-bd { padding: 0; }
.panel-bd.pad { padding: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; align-items: start; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.wh-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 1100px) { .wh-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .wh-grid { grid-template-columns: 1fr; } }

/* ---------------- 表格 ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
/* 操作列吸附在右侧：窄屏横向滚动时编辑/停用/删除始终可见 */
table.grid th.col-act, table.grid td.col-act {
  position: sticky; right: 0; background: var(--panel); z-index: 1;
  box-shadow: -9px 0 10px -9px rgba(20, 35, 60, .22);
}
table.grid thead th.col-act { background: #f8fafc; top: 0; z-index: 3; }
table.grid tbody tr:hover td.col-act { background: #fafcff; }
table.grid tbody tr.row-off td.col-act { background: #fbfcfe; }
table.grid.tbl-wh { min-width: 1080px; }
/* 仓库档案：散裁仓作为所属仓库的子行展示 */
table.grid.tbl-wh tr.wh-child td { background: #fafcff; }
table.grid.tbl-wh tr.wh-child td.cell-main { padding-left: 30px; }
table.grid.tbl-wh tr.wh-child:hover td { background: #f4f8ff; }
.wh-tree { color: var(--faint); margin-right: 5px; font-family: var(--mono); }
table.grid.tbl-user { min-width: 980px; }
@media (max-width: 920px) {
  table.grid.tbl-wh, table.grid.tbl-user { min-width: 0; }
  table.grid.tbl-wh th, table.grid.tbl-wh td { padding-left: 7px; padding-right: 7px; }
  table.grid.tbl-wh .btn.xs, table.grid.tbl-user .btn.xs { padding: 0 6px; }
  /* 窄屏重排列宽，保证「在库 / 账号 / 状态 / 操作」都进得去 */
  table.tbl-wh th:nth-child(2) { width: 150px !important; }
  table.tbl-wh th:nth-child(3) { width: 56px !important; }
  table.tbl-wh th:nth-child(4) { width: 112px !important; }
  table.tbl-wh th:nth-child(6) { width: 62px !important; }
  table.tbl-wh th:nth-child(8) { width: 48px !important; }
  table.tbl-wh th:nth-child(9) { width: 62px !important; }
  table.tbl-wh th:nth-child(10) { width: 148px !important; }
  table.tbl-user th:nth-child(1) { width: 104px !important; }
  table.tbl-user th:nth-child(3) { width: 84px !important; }
  table.tbl-user th:nth-child(4) { width: 92px !important; }
  table.tbl-user th:nth-child(5) { width: 74px !important; }
  table.tbl-user th:nth-child(6) { width: 60px !important; }
  table.tbl-user th:nth-child(8) { width: 140px !important; }
}
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  background: #f8fafc; white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid tbody tr:hover { background: #fafcff; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tfoot td { padding: 8px 10px; font-weight: 600; background: #f8fafc; border-top: 1px solid var(--line); }
table.grid.compact td { padding: 5px 8px; }
table.grid.compact th { padding: 6px 8px; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 11px; color: var(--faint); }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.qty { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.qty u { text-decoration: none; color: var(--faint); font-size: 10.5px; margin-left: 2px; }

/* ---------------- 状态 / 标签 ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: 10px;
  border: 1px solid transparent; white-space: nowrap; font-weight: 500;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.blue { color: #1e40af; background: #e8efff; border-color: #cfdcfb; }
.pill.green { color: #15803d; background: #e8f6ec; border-color: #cbe9d4; }
.pill.orange { color: #b4530a; background: #fdf0e3; border-color: #f7dcbf; }
.pill.gray { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.pill.red { color: #b42318; background: #fdecea; border-color: #f7cdc7; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: #f1f5f9; color: var(--ink-2); border: 1px solid var(--line); }
.tag.batch { font-family: var(--mono); font-size: 11px; background: #f8fafc; white-space: nowrap; }
.batchcell { display: flex; flex-wrap: wrap; gap: 4px 5px; align-items: center; max-width: 210px; }
.tag.cat { background: #f5f3ff; color: #6d28d9; border-color: #e9e3fd; }
.tag.scat { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }

/* ---------------- 按钮 / 表单 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font: inherit; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: .12s ease;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1a45c4; border-color: #1a45c4; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { border-color: #f0c4c0; color: var(--red); background: #fff; }
.btn.danger:hover { background: #fdf3f2; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 5px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 11px; border-radius: 4px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; font-size: 12.5px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; height: 32px; outline: none; width: 100%;
}
textarea { height: auto; min-height: 64px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
input:disabled, select:disabled { background: #f8fafc; color: var(--muted); }
input[type=number] { font-family: var(--mono); text-align: right; }
label.fl { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); background: #fcfdff; }
.toolbar .spacer { flex: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input:not([type="checkbox"]), .filters select { height: 30px; width: auto; min-width: 130px; font-size: 12px; }
.filters > label { flex: 0 0 auto; white-space: nowrap; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 14px; background: #fff; }
.tab {
  padding: 9px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
  white-space: nowrap; flex: 0 0 auto;
}
.tab .count { display: inline-block; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ---------------- 空状态 ---------------- */
.empty { padding: 34px 16px; text-align: center; color: var(--faint); font-size: 12.5px; }
.empty svg { width: 30px; height: 30px; stroke: #cbd5e1; fill: none; stroke-width: 1.4; margin-bottom: 6px; }

/* ---------------- 提示条 ---------------- */
.notice { display: block; padding: 9px 12px; border-radius: 6px; font-size: 12px; line-height: 1.6; }
.notice > div { min-width: 0; }
.notice .ic { display: inline-flex; vertical-align: -2px; margin-right: 4px; }
.notice.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.notice.err { background: #fef2f2; border: 1px solid #fecaca; color: #b42318; }
.notice.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.notice.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.notice b { font-weight: 650; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 16px; z-index: 100; overflow-y: auto;
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: #fff; border-radius: 10px; width: 560px; max-width: 100%;
  box-shadow: 0 20px 60px -12px rgba(15,23,42,.4);
  animation: pop .14s ease;
}
@keyframes pop { from { transform: translateY(-6px) scale(.99); opacity: .6 } to { transform: none; opacity: 1 } }
.modal.wide { width: 860px; }
.modal.xwide { width: 1080px; }
.modal-hd { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.modal-title { font-size: 14px; font-weight: 650; }
.modal-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.modal-x { margin-left: auto; cursor: pointer; color: var(--faint); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 5px; font-size: 16px; }
.modal-x:hover { background: #f1f5f9; color: var(--ink); }
.modal-bd { padding: 16px 18px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-ft { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-2); background: #fcfdff; border-radius: 0 0 10px 10px; }
.modal-ft .left { margin-right: auto; }

/* ---------------- Toast ---------------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: #0f172a; color: #fff; padding: 9px 14px; border-radius: 7px;
  font-size: 12.5px; box-shadow: var(--shadow); max-width: 380px;
  animation: slideIn .16s ease; display: flex; gap: 8px; align-items: flex-start; line-height: 1.5;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
.toast.warn { background: #7c2d12; }
@keyframes slideIn { from { transform: translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------------- 图表 ---------------- */
.chart-wrap { padding: 12px 14px 6px; }
.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); padding: 0 14px 10px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* ---------------- 配货 / 入库 行编辑 ---------------- */
.lines-head, .line-row {
  display: grid; grid-template-columns: minmax(200px, 2.2fr) 96px 168px 96px 30px;
  gap: 8px; align-items: center;
}
.lines-head.scatter, .line-row.scatter {
  grid-template-columns: minmax(200px, 2.4fr) 168px 96px 30px;
}
/* 退货明细：产品 / 数量 / 批次号 / 库存参考，四列都要能看清 */
.lines-head.ret, .line-row.ret {
  grid-template-columns: minmax(220px, 1.7fr) 110px 210px 190px 30px;
}
.lines-head { font-size: 11px; color: var(--muted); padding: 6px 12px; background: #f8fafc; border-bottom: 1px solid var(--line-2); }
.line-row { padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.line-row:last-child { border-bottom: none; }
.line-row .rm { color: var(--faint); cursor: pointer; text-align: center; font-size: 15px; line-height: 1; }
.line-row .rm:hover { color: var(--red); }
.line-avail { font-size: 10.5px; color: var(--faint); margin-top: 3px; font-family: var(--mono); }
.line-avail.bad { color: var(--red); }

/* ---------------- 产品选择器 ---------------- */
.picker { position: relative; }
.picker-list {
  position: absolute; z-index: 50; left: 0; right: 0; top: 34px;
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 12px 32px -8px rgba(15,23,42,.22); max-height: 268px; overflow-y: auto; padding: 4px;
}
.picker-item { padding: 6px 9px; border-radius: 5px; cursor: pointer; font-size: 12.2px; display: flex; gap: 8px; align-items: center; }
.picker-item:hover, .picker-item.on { background: var(--accent-soft); }
.picker-item .code { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.picker-empty { padding: 10px; color: var(--faint); font-size: 12px; text-align: center; }

/* ---------------- 批次选择 ---------------- */
.batch-select { font-family: var(--mono); font-size: 11.5px; }

/* ---------------- 详情键值表 ---------------- */
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); font-size: 11.5px; }
.kv dd { margin: 0; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 920px) {
  .app { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; width: 100%; flex: none; height: auto;
    border-right: none; border-bottom: 1px solid var(--line);
    flex-direction: column;
  }
  .brand { padding: 10px 14px 8px; }
  .brand-mark { width: 26px; height: 26px; flex-basis: 26px; font-size: 13px; }
  .nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 10px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
  .nav::-webkit-scrollbar { height: 0; display: none; }
  .nav-group, .side-foot { display: none; }
  .nav-tools { padding: 0 10px 8px; display: flex; justify-content: flex-end; }
  .nav-tool { width: auto; padding: 4px 9px; font-size: 11px; }
  .nav-tools.sorting { flex-direction: column; align-items: stretch; gap: 6px; border-top: none; margin-top: 0; padding-top: 0; }
  .nav-tools.sorting .nav-tip { margin: 0; text-align: center; }
  .nav-grip { display: none !important; }
  .nav-item { white-space: nowrap; padding: 6px 10px; font-size: 12px; border: 1px solid var(--line); }
  .nav-item.active::before { display: none; }
  .nav-item svg { width: 13px; height: 13px; }
  .topbar { height: 48px; flex-basis: 48px; padding: 0 12px; gap: 8px; position: sticky; top: 0; }
  .page-title { font-size: 13.5px; }
  .page-sub, .clock { display: none; }
  .sync-chip { padding: 3px 6px; font-size: 10px; }
  .role-select { max-width: 128px; font-size: 11px; padding: 5px 8px; }
  .view { padding: 10px 10px 60px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 10px 11px; }
  .kpi-value { font-size: 19px; }
  .grid-2, .grid-2b { grid-template-columns: 1fr; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.xwide {
    width: 100%; border-radius: 12px 12px 0 0; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
  }
  .modal-bd { max-height: calc(92vh - 132px); flex: 1 1 auto; overflow-y: auto; padding: 14px; }
  .modal-hd { flex: 0 0 auto; }
  .modal-ft { flex: 0 0 auto; }
  .modal-hd, .modal-ft { padding: 12px 14px; }
  .modal-ft .btn { height: 40px; flex: 1; font-size: 13px; }
  .lines-head { display: none; }
  .line-row { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; }
  .line-row .pick-cell { grid-column: 1 / -1; }
  .toolbar { padding: 8px 10px; }
  .filters input:not([type="checkbox"]), .filters select { min-width: 0; flex: 1 1 40%; }
  table.grid { font-size: 12px; }
  table.grid th, table.grid td { padding: 6px 8px; }
  .tabs { padding: 0 8px; overflow-x: auto; }
  .chart-wrap { padding: 8px; }
}

/* ---------------- 分布条 ---------------- */
.dist-row { display: grid; grid-template-columns: 104px 1fr 78px; gap: 10px; align-items: center; margin-bottom: 9px; }
.dist-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dist-bar { height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; border-radius: 4px; min-width: 2px; transition: width .3s ease; }
.dist-val { text-align: right; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.dist-val u { text-decoration: none; color: var(--faint); font-size: 10px; margin-left: 2px; }
.dual-bar { display: flex; gap: 2px; height: 9px; align-items: center; }
.dual-bar i, .dual-bar em { display: block; height: 9px; border-radius: 2px; min-width: 1px; }
.dual-bar em { opacity: .9; }

/* 出库颜色排行 */
.rank-sel { height: 26px; font-size: 11.5px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink-2); }
.crank { display: flex; flex-direction: column; gap: 7px; }
.crank-row { display: grid; grid-template-columns: 20px 124px 1fr 68px 54px; gap: 10px; align-items: center; }
.crank-no { font-size: 11px; font-weight: 600; color: var(--faint); text-align: center; font-variant-numeric: tabular-nums; }
.crank-no.t1, .crank-no.t2, .crank-no.t3 { color: #fff; border-radius: 50%; width: 20px; height: 20px; line-height: 20px; }
.crank-no.t1 { background: #c99a15; }
.crank-no.t2 { background: #93a1ae; }
.crank-no.t3 { background: #b57b41; }
.crank-name { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crank-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .18); }
.crank-bar { height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.crank-bar i { display: block; height: 100%; border-radius: 5px; transition: width .3s ease; }
.crank-val { text-align: right; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.crank-val u { text-decoration: none; color: var(--faint); font-size: 10px; margin-left: 2px; }
.crank-pct { text-align: right; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 920px) {
  .crank-row { grid-template-columns: 18px 96px 1fr 60px; gap: 8px; }
  .crank-pct { display: none; }
}
@media (max-width: 920px) {
  .dist-row { grid-template-columns: 84px 1fr 64px; gap: 8px; }
}

/* 移动端可隐藏的次要列 */
@media (max-width: 920px) { .col-opt { display: none !important; } }

/* 产品名列宽约束：避免长名称把数量列挤出视野 */
table.grid td.prodcell { max-width: 250px; }
table.grid td.prodcell .cell-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 920px) { table.grid td.prodcell { max-width: 150px; } }

/* 固定列表格：给出最小宽度，窄屏改为横向滚动。
   否则 table-layout:fixed 下未设置宽度的列（如「产品名称」）会被压成 0 宽度而整列消失。 */
table.grid.fixed { table-layout: fixed; min-width: 660px; }
table.grid.fixed td { overflow: hidden; }
@media (max-width: 920px) { table.grid.fixed { min-width: 620px; } }
/* 库存查询：带「单价 / 金额」列时整体更宽，窄屏横向滚动查看 */
table.grid.tbl-stock { min-width: 800px; }
@media (max-width: 920px) { table.grid.tbl-stock { min-width: 760px; } }
/* 退货单台账 */
table.grid.tbl-returns { min-width: 980px; }
@media (max-width: 920px) { table.grid.tbl-returns { min-width: 860px; } }

/* 表单栅格：允许子项收缩，避免窄屏溢出 */
.field-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.field-row > *, .line-row > * { min-width: 0; }
@media (max-width: 920px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .line-row .pick-cell { grid-column: 1 / -1; }
}

/* 选择器 / 标签页使用真实按钮 */
button.picker-item { width: 100%; text-align: left; background: transparent; border: 0; font: inherit; font-size: 12.2px; color: var(--ink); }
button.picker-item:hover, button.picker-item.on { background: var(--accent-soft); }
button.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; font: inherit; font-size: 12.5px; color: var(--muted); }
button.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

@media (max-width: 920px) {
  .line-row [data-cur]::before { content: '现有 '; color: var(--faint); font-size: 10.5px; }
}

/* ---------------- 在途订单卡片（移动端） ---------------- */
.oc-list { display: none; }
.oc { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; }
.oc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.oc-top .mono { font-size: 12px; }
.oc-line { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12.5px; }
.oc-line .cell-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.oc-act { display: flex; gap: 8px; margin-top: 10px; }
.oc-act .btn { flex: 1; height: 38px; font-size: 13px; }
@media (max-width: 920px) {
  .transit-table { display: none; }
  .oc-list { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
}

td.reasoncell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
@media (max-width: 920px) { td.reasoncell { max-width: 140px; } }

/* ================= v1.1 登录 / 权限 / 设置 ================= */
input[type=checkbox], input[type=radio] { width: auto; height: auto; accent-color: var(--accent); cursor: pointer; }
input.bad, select.bad { border-color: #f0a9a2; background: #fff8f7; }
.field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.field > span i { color: var(--red); font-style: normal; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .span2 { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; margin-top: 6px; line-height: 1.6; }

/* ---------- 登录 ---------- */
body.guest .app { display: none; }
body.guest { background: #0b1220; }
#login-root:empty { display: none; }
.login { min-height: 100vh; display: grid; grid-template-columns: 1.06fr 1fr; }
.login-aside {
  position: relative; overflow: hidden;
  background: radial-gradient(900px 420px at 10% -10%, rgba(59,130,246,.38), transparent 60%),
              radial-gradient(700px 380px at 90% 110%, rgba(37,99,235,.30), transparent 62%),
              linear-gradient(155deg, #0b1b45 0%, #0f172a 58%, #0a1122 100%);
  color: #dbe6ff; padding: 52px 46px 40px; display: flex; flex-direction: column;
}
.login-aside::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 46px 46px; pointer-events: none;
}
.login-brand { display: flex; gap: 12px; align-items: center; position: relative; z-index: 1; }
.brand-mark.lg { width: 44px; height: 44px; flex-basis: 44px; font-size: 20px; border-radius: 10px; }
.login-name { font-size: 21px; font-weight: 700; letter-spacing: .5px; color: #fff; }
.login-sub { font-size: 12px; color: #93a7d4; margin-top: 2px; }
.login-points { list-style: none; margin: 40px 0 0; padding: 0; position: relative; z-index: 1; display: grid; gap: 16px; max-width: 380px; }
.login-points li { border-left: 2px solid rgba(96,165,250,.5); padding: 2px 0 2px 12px; }
.login-points b { display: block; font-size: 13px; color: #eaf1ff; font-weight: 600; }
.login-points span { font-size: 11.5px; color: #8ea3cc; }
.login-copy { margin-top: auto; font-size: 11px; color: #64789f; position: relative; z-index: 1; }
.login-main { display: grid; place-items: center; background: #fff; padding: 34px 24px; }
.login-card { width: 100%; max-width: 392px; margin: 0; }
.login-hd { font-size: 19px; font-weight: 700; color: var(--ink); }
.login-desc { font-size: 11.5px; color: var(--muted); margin: 4px 0 20px; }
.login-field { display: block; margin-bottom: 13px; }
.login-field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.login-field input { width: 100%; height: 38px; font-size: 13px; }
.login-err { min-height: 18px; font-size: 11.5px; color: var(--red); margin-bottom: 4px; }
.login-btn { width: 100%; height: 38px; font-size: 13.5px; letter-spacing: 2px; }
.login-demo-hd { margin: 22px 0 8px; font-size: 11.5px; color: var(--ink-2); font-weight: 600; display: flex; align-items: baseline; justify-content: space-between; }
.login-demo-hd span { font-weight: 400; color: var(--faint); font-size: 10.5px; }
.login-demo { display: grid; gap: 5px; }
.login-acc {
  display: grid; grid-template-columns: 88px 1fr auto; gap: 8px; align-items: center;
  text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; cursor: pointer; font: inherit; transition: .12s ease;
}
.login-acc:hover { border-color: var(--accent-2); background: #f7f9ff; }
.la-user { font: 11.5px var(--mono); color: var(--accent); }
.la-role { font-size: 11.5px; color: var(--ink-2); }
.la-scope { font-size: 10.5px; color: var(--faint); }
.login-foot { margin-top: 18px; font-size: 10.5px; color: var(--faint); text-align: center; line-height: 1.7; }

/* ---------- 顶栏账号 ---------- */
.user-chip { display: flex; align-items: center; gap: 7px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.uc-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }
.uc-txt { display: flex; flex-direction: column; line-height: 1.2; }
.uc-txt b { font-size: 11.5px; font-weight: 650; color: var(--ink); }
.uc-txt u { text-decoration: none; font-size: 10px; color: var(--muted); }

/* ---------- 权限矩阵 ---------- */
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 9px; padding-top: 13px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.perm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.pg-hd { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; background: #f8fafc; border-bottom: 1px solid var(--line-2); }
.pg-all { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.pg-count { font: 10.5px var(--mono); color: var(--faint); }
.pg-bd { padding: 6px 10px 8px; display: grid; gap: 1px; }
.pg-bd.dim { opacity: .58; }
.perm-item { display: flex; gap: 7px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.perm-item input { margin: 3px 0 0; flex: 0 0 auto; }
.pi-body { display: flex; flex-direction: column; min-width: 0; }
.pi-t { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.pi-d { font-size: 10.5px; color: var(--faint); line-height: 1.45; }
.pi-flag { font-style: normal; font-size: 9.5px; color: #b4530a; background: #fdf0e3; border: 1px solid #f7dcbf; border-radius: 3px; padding: 0 3px; margin-left: 5px; white-space: nowrap; }
.perm-item.off { opacity: .42; cursor: default; }
.perm-item.off input { cursor: not-allowed; }
.perm-readonly .perm-item { cursor: default; padding: 3px 0; }
.pi-mark { font: 11px var(--mono); width: 14px; flex: 0 0 14px; color: var(--green); }
.perm-item.off .pi-mark { color: var(--faint); }
.perm-item.off .pi-t { color: var(--faint); }
.perms-legend { padding: 10px 14px; font-size: 11.5px; color: var(--muted); background: #fcfdff; border-top: 1px solid var(--line-2); line-height: 1.7; }

/* ---------- 分仓实时看板 ---------- */
.bw-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 10px; }
.bw-card { border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: #fff; }
.bw-card.off { opacity: .66; background: #fbfcfe; }
.bw-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.bw-sub { font-size: 10.5px; color: var(--faint); margin: 3px 0 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.bw-grid > div { display: flex; flex-direction: column; min-width: 0; }
.bw-grid span { font-size: 10.5px; color: var(--muted); }
.bw-grid b { font: 600 14px var(--mono); color: var(--ink); }
.bw-grid b u { text-decoration: none; font-size: 10px; color: var(--faint); margin-left: 2px; font-weight: 400; }
.bw-grid b.small { font-size: 11.5px; }
.bw-act { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.c-blue { color: #1e40af !important; }
.c-red { color: var(--red) !important; }
.c-green { color: var(--green) !important; }

/* ---------- 设置页其他 ---------- */
.wh-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.wh-card.off { background: #fbfcfe; opacity: .72; }
tr.row-off td { color: var(--faint); background: #fbfcfe; }
tr.row-off .cell-main { color: var(--muted); }
.forbidden { text-align: center; padding: 44px 16px; }
.forbidden-ico { font: 700 26px var(--mono); color: #cbd5e1; letter-spacing: 2px; }
.forbidden-t { font-size: 15px; font-weight: 650; margin: 8px 0; }

/* ---------------- 设置 · 产品名称 / 一键导入 ---------------- */
.prod-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line-2); }
.prod-actions .spacer { flex: 1; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 14px; }
.pager .small { min-width: 130px; text-align: right; }
.import-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.import-bar .small { flex: 1 1 auto; }
table.grid tr.row-warn td { background: #fffbf4; }
table.grid tr.row-warn td.col-act { background: #fffbf4; }
.bind-sel { height: 28px; font-size: 12px; padding: 2px 6px; }
textarea[data-if="raw"] { font-family: var(--mono); font-size: 12px; line-height: 1.7; min-height: 118px; }
.tbl-prod { min-width: 720px; }
/* 手机宽度：产品列较多，保持最小宽度横向滚动，避免列被压成竖排文字 */
@media (max-width: 560px) {
  .tbl-prod { min-width: 660px; }
  .tbl-prod th, .tbl-prod td { padding-left: 6px; padding-right: 6px; }
  .prod-actions .small { display: none; }
  .prod-actions { padding: 8px 10px; }
  .pager { padding: 8px 10px; }
}

@media (max-width: 920px) {
  .login { grid-template-columns: 1fr; min-height: 100vh; }
  .login-aside { padding: 20px 18px 18px; }
  .login-points, .login-copy { display: none; }
  .login-main { padding: 22px 16px 48px; align-items: start; }
  .login-card { max-width: none; }
  .perm-matrix { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .bw-list { grid-template-columns: 1fr 1fr; }
  .uc-txt { display: none; }
  .user-chip { padding: 3px; }
}
@media (max-width: 560px) {
  .bw-list { grid-template-columns: 1fr; }
  .login-name { font-size: 18px; }
}

/* 未声明 type 的输入框同样铺满（浏览器默认按 size=20 渲染） */
input:not([type]) { font: inherit; font-size: 12.5px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; height: 32px; outline: none; width: 100%; }

/* 表头点击排序 */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
.sort-ico { display: inline-block; font-style: normal; font-size: 9px; margin-left: 5px; color: var(--muted); vertical-align: 1px; }
.sort-ico.asc, .sort-ico.desc { color: var(--accent); }

/* =============================================================
 * 可安装 App（PWA）：安装提示条 / 更新提示条
 * ============================================================= */
.pwa-bar,
.pwa-install {
  position: fixed;
  z-index: 9999;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  background: #0f172a;
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .3);
  max-width: min(560px, calc(100% - 20px));
  font-size: 12.5px;
  line-height: 1.35;
}
.pwa-bar { top: 10px; padding: 9px 10px 9px 14px; }
.pwa-bar b { color: #93c5fd; }
.pwa-install { bottom: 14px; padding: 10px 12px 10px 14px; gap: 12px; }
.pwa-install .pi-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-install .pi-txt b { font-size: 12.5px; }
.pwa-install .pi-txt span { font-size: 11px; color: rgba(255, 255, 255, .66); }
.pwa-bar .pwa-x,
.pwa-install .pwa-x {
  flex: none;
  background: transparent;
  border: 0;
  padding: 0 4px;
  color: rgba(255, 255, 255, .58);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.pwa-bar .pwa-x:hover,
.pwa-install .pwa-x:hover { color: #fff; }
@media (max-width: 560px) {
  .pwa-bar { left: 10px; right: 10px; top: 8px; transform: none; max-width: none; }
  .pwa-install { left: 10px; right: 10px; bottom: 10px; transform: none; max-width: none; }
}

/* ---------------- 批次号扫码 ---------------- */
.input-scan { display: flex; gap: 6px; align-items: stretch; }
.input-scan input { flex: 1 1 auto; width: auto; min-width: 0; }
.scan-btn {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  padding: 0 10px; border: 1px solid #c7d7fb; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.scan-btn:hover { background: #e3ecff; border-color: var(--accent); }
.scan-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.scan-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 16, 30, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(2px);
}
.scan-box {
  width: min(430px, 100%); background: #0f172a; border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45); color: #fff;
}
.scan-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 10px; }
.scan-hd b { display: block; font-size: 14px; }
.scan-hd span { display: block; font-size: 11.5px; color: rgba(255, 255, 255, .6); margin-top: 3px; line-height: 1.4; }
.scan-x {
  flex: none; border: 0; background: transparent; color: rgba(255, 255, 255, .65);
  font-size: 20px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.scan-x:hover { color: #fff; }
.scan-stage { position: relative; background: #000; aspect-ratio: 4 / 3; overflow: hidden; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 16%; bottom: 16%; pointer-events: none; }
.scan-frame i { position: absolute; width: 26px; height: 26px; border: 3px solid #60a5fa; }
.scan-frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.scan-frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.scan-frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.scan-frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }
.scan-line {
  position: absolute; left: 12%; right: 12%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0), #60a5fa, rgba(96, 165, 250, 0));
  box-shadow: 0 0 12px rgba(96, 165, 250, .8);
  animation: scanmove 2.2s ease-in-out infinite;
}
@keyframes scanmove {
  0%, 100% { top: 18%; }
  50% { top: 80%; }
}
.scan-state {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 12px; font-size: 11.5px; color: #dbeafe;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, .85));
  text-align: center;
}
.scan-state.err { color: #fecaca; }
.scan-ft { display: flex; gap: 8px; padding: 12px 14px 14px; }
.scan-ft .btn { flex: 1; justify-content: center; }
.scan-ft input[type=file] { display: none; }
body.scan-on { overscroll-behavior: none; }
@media (max-width: 920px) {
  /* 批次号 + 扫码按钮在窄屏占满整行，避免输入框被压窄 */
  .field-row .field-scan { grid-column: 1 / -1; }
}

/* =============================================================
 * 背景风格：科技风暴黑（深色主题）
 * 通过 <html data-theme="dark"> 切换，浅色为默认，不改动既有浅色规则
 * ============================================================= */
html[data-theme="dark"] {
  --ink: #e9eff9;
  --ink-2: #c2cfe2;
  --muted: #8c9cb5;
  --faint: #62718a;
  --line: #1e2837;
  --line-2: #172030;
  --bg: #070b12;
  --panel: #0e141f;
  --accent: #4f8dff;
  --accent-2: #60a5fa;
  --accent-soft: rgba(79, 141, 255, .16);
  --blue: #5b93ff;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
  --gray: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 12px 30px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background:
    radial-gradient(900px 520px at 8% -12%, rgba(37, 99, 235, .16), transparent 62%),
    radial-gradient(760px 500px at 94% 108%, rgba(14, 165, 233, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #22303f; border-radius: 6px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }

/* 侧边栏 / 顶栏 */
html[data-theme="dark"] .sidebar { background: #0a1017; border-right-color: var(--line); }
html[data-theme="dark"] .brand { border-bottom-color: var(--line-2); }
html[data-theme="dark"] .nav-item:hover { background: rgba(255, 255, 255, .045); color: var(--ink); }
html[data-theme="dark"] .nav-item.active {
  background: rgba(79, 141, 255, .14); color: #8ab4ff; border-color: rgba(79, 141, 255, .34);
  box-shadow: inset 0 0 12px rgba(79, 141, 255, .12);
}
html[data-theme="dark"] .nav-badge { background: rgba(248, 113, 113, .18); color: #fca5a5; }
html[data-theme="dark"] .nav-tool { background: rgba(255, 255, 255, .03); }
html[data-theme="dark"] .nav-tool:hover { border-color: rgba(79, 141, 255, .45); }
html[data-theme="dark"] .nav.sorting .nav-item.active { background: rgba(255, 255, 255, .03); color: var(--ink-2); border-color: var(--line); }
html[data-theme="dark"] .nav-item.dragging { background: #16202e; border-color: var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .6); }
html[data-theme="dark"] .topbar { background: rgba(9, 14, 21, .86); border-bottom-color: rgba(79, 141, 255, .16); box-shadow: 0 1px 0 rgba(79, 141, 255, .05); }
html[data-theme="dark"] .role-select { background: #0e141f; }

/* 卡片 / 表格 */
html[data-theme="dark"] .kpi::after { background: #2a3646; }
html[data-theme="dark"] .kpi.k-gray::after { background: #64748b; }
html[data-theme="dark"] table.grid th,
html[data-theme="dark"] table.grid tfoot td { background: #111a26; }
html[data-theme="dark"] table.grid thead th.col-act { background: #111a26; }
html[data-theme="dark"] table.grid tbody tr:hover,
html[data-theme="dark"] table.grid tbody tr:hover td.col-act { background: rgba(255, 255, 255, .035); }
html[data-theme="dark"] table.grid tbody tr.row-off td,
html[data-theme="dark"] table.grid tbody tr.row-off td.col-act,
html[data-theme="dark"] table.grid.tbl-wh tr.wh-child td { background: #0b1119; }
html[data-theme="dark"] table.grid.tbl-wh tr.wh-child:hover td { background: #101a26; }
html[data-theme="dark"] table.grid tr.row-warn td,
html[data-theme="dark"] table.grid tr.row-warn td.col-act { background: rgba(251, 146, 60, .10); }
html[data-theme="dark"] table.grid th.col-act,
html[data-theme="dark"] table.grid td.col-act { box-shadow: -9px 0 12px -9px rgba(0, 0, 0, .8); }

/* 标签 / 状态 */
html[data-theme="dark"] .pill.blue { color: #93c5fd; background: rgba(59, 130, 246, .16); border-color: rgba(59, 130, 246, .34); }
html[data-theme="dark"] .pill.green { color: #6ee7b7; background: rgba(16, 185, 129, .14); border-color: rgba(16, 185, 129, .32); }
html[data-theme="dark"] .pill.orange { color: #fdba74; background: rgba(249, 115, 22, .14); border-color: rgba(249, 115, 22, .32); }
html[data-theme="dark"] .pill.gray { color: #b3c1d4; background: rgba(148, 163, 184, .12); border-color: rgba(148, 163, 184, .24); }
html[data-theme="dark"] .pill.red { color: #fca5a5; background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .32); }
html[data-theme="dark"] .tag { background: #17202d; border-color: var(--line); color: var(--ink-2); }
html[data-theme="dark"] .tag.batch { background: #131c28; }
html[data-theme="dark"] .tag.cat { background: rgba(139, 92, 246, .16); color: #c4b5fd; border-color: rgba(139, 92, 246, .32); }
html[data-theme="dark"] .tag.scat { background: rgba(59, 130, 246, .16); color: #93c5fd; border-color: rgba(59, 130, 246, .32); }
html[data-theme="dark"] .c-blue { color: #93c5fd !important; }
html[data-theme="dark"] .c-green { color: #6ee7b7 !important; }

/* 按钮 / 表单 */
html[data-theme="dark"] .btn { background: #131c29; border-color: var(--line); color: var(--ink-2); }
html[data-theme="dark"] .btn:hover { background: #1a2537; border-color: #2b3a4e; color: var(--ink); }
html[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .btn.primary:hover { background: #3f7df5; border-color: #3f7df5; }
html[data-theme="dark"] .btn.ghost { background: transparent; border-color: transparent; }
html[data-theme="dark"] .btn.danger { background: rgba(239, 68, 68, .10); border-color: rgba(239, 68, 68, .34); color: #fca5a5; }
html[data-theme="dark"] .btn.danger:hover { background: rgba(239, 68, 68, .18); }
html[data-theme="dark"] input[type=text],
html[data-theme="dark"] input[type=password],
html[data-theme="dark"] input[type=number],
html[data-theme="dark"] input[type=date],
html[data-theme="dark"] input[type=search],
html[data-theme="dark"] input:not([type]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: #0b1220; border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled { background: #0d141f; color: var(--faint); }
html[data-theme="dark"] select option { background: #0e141f; color: var(--ink); }
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); }
html[data-theme="dark"] input.bad,
html[data-theme="dark"] select.bad { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .5); }
html[data-theme="dark"] .hint { background: #0b1220; }
html[data-theme="dark"] .toolbar { background: #0b111a; }
html[data-theme="dark"] .tabs { background: #0e141f; }
html[data-theme="dark"] .lines-head { background: #111a26; }

/* 弹窗 / 选择器 */
html[data-theme="dark"] .modal-mask { background: rgba(3, 6, 12, .66); }
html[data-theme="dark"] .modal { background: #0e141f; box-shadow: 0 24px 70px -18px rgba(0, 0, 0, .9); }
html[data-theme="dark"] .modal-x:hover { background: #17202d; }
html[data-theme="dark"] .modal-ft { background: #0b111a; }
html[data-theme="dark"] .picker-list { background: #0f1723; box-shadow: 0 16px 36px -10px rgba(0, 0, 0, .8); }
html[data-theme="dark"] .empty svg { stroke: #33414f; }
html[data-theme="dark"] .forbidden-ico { color: #33414f; }

/* 提示条 */
html[data-theme="dark"] .notice.warn { background: rgba(251, 146, 60, .10); border-color: rgba(251, 146, 60, .32); color: #fdba74; }
html[data-theme="dark"] .notice.err { background: rgba(239, 68, 68, .10); border-color: rgba(239, 68, 68, .32); color: #fca5a5; }
html[data-theme="dark"] .notice.ok { background: rgba(16, 185, 129, .10); border-color: rgba(16, 185, 129, .30); color: #6ee7b7; }
html[data-theme="dark"] .notice.info { background: rgba(59, 130, 246, .10); border-color: rgba(59, 130, 246, .30); color: #93c5fd; }

/* 排行 / 分布条 */
html[data-theme="dark"] .dist-bar,
html[data-theme="dark"] .crank-bar { background: #16202e; }
html[data-theme="dark"] .crank-dot { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .5); }
html[data-theme="dark"] .rank-sel { background: #0e141f; }

/* 工作台 / 设置 / 在途卡片 */
html[data-theme="dark"] .bw-card { background: #0e141f; }
html[data-theme="dark"] .bw-card.off,
html[data-theme="dark"] .wh-card.off { background: #0b1119; }
html[data-theme="dark"] .perm-group { background: #0e141f; }
html[data-theme="dark"] .pg-hd { background: #111a26; }
html[data-theme="dark"] .perms-legend { background: #0b111a; }
html[data-theme="dark"] .pi-flag { background: rgba(251, 146, 60, .14); border-color: rgba(251, 146, 60, .3); color: #fdba74; }
html[data-theme="dark"] .oc { background: #0e141f; }
html[data-theme="dark"] .user-chip { background: #0e141f; }

/* 登录页：右侧表单区跟随主题 */
html[data-theme="dark"] .login-main { background: #070b12; }
html[data-theme="dark"] .login-acc { background: #0e141f; }
html[data-theme="dark"] .login-acc:hover { background: #131d2b; border-color: rgba(79, 141, 255, .45); }
html[data-theme="dark"] .login-foot { color: #5b6b83; }

/* 趋势图（SVG 用 class 控制，跟随主题） */
.chart-wrap .tl-grid { stroke: #eef2f7; }
.chart-wrap .tl-axis { fill: #94a3b8; }
.chart-wrap .tl-bar { fill: #93b0f2; }
.chart-wrap .tl-bar.empty { fill: #f1f5f9; }
.chart-wrap .tl-val { fill: #475569; }
html[data-theme="dark"] .chart-wrap .tl-grid { stroke: #1b2534; }
html[data-theme="dark"] .chart-wrap .tl-axis { fill: #62718a; }
html[data-theme="dark"] .chart-wrap .tl-bar { fill: #3b82f6; }
html[data-theme="dark"] .chart-wrap .tl-bar.empty { fill: #16202e; }
html[data-theme="dark"] .chart-wrap .tl-val { fill: #cbd5e1; }

/* 主题切换按钮 */
.theme-btn b { font-weight: 500; }
.theme-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }
@media (max-width: 920px) { .theme-btn b { display: none; } .theme-btn { width: 32px; padding: 0; } }

/* 登录页右上角主题切换 */
.login-main { position: relative; }
.login-theme {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; transition: .12s ease;
}
.login-theme:hover { color: var(--accent); border-color: var(--accent-2); }
.login-theme svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* 只读输入框 / 收货核对行（深浅色都要可读） */
input.ro-field, select.ro-field { background: #f8fafc; color: var(--muted); }
html[data-theme="dark"] input.ro-field,
html[data-theme="dark"] select.ro-field { background: #0b1220; color: var(--faint); }
.recv-line { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
html[data-theme="dark"] .recv-line { background: #0b111a; }
.recv-line.recv-bad { border-color: #f7c9b6; background: #fffaf6; }
.recv-line.recv-ok { border-color: #d6e9dc; background: #fbfefc; }
html[data-theme="dark"] .recv-line.recv-bad { border-color: rgba(251, 146, 60, .45); background: rgba(251, 146, 60, .08); }
html[data-theme="dark"] .recv-line.recv-ok { border-color: rgba(16, 185, 129, .40); background: rgba(16, 185, 129, .07); }
/* 窄屏仓库档案：类型标签不换行（散裁仓被挤成两行） */
@media (max-width: 920px) {
  table.tbl-wh .tag { white-space: nowrap; padding: 0 4px; font-size: 10.5px; }
}

/* =============================================================
 * 库存导入导出 / 产品批量修改 / 备份还原
 * ============================================================= */
.stock-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) {
  .stock-actions { width: 100%; margin-top: 6px; }
  .stock-actions .btn { flex: 1 1 auto; justify-content: center; font-size: 11.5px; padding: 0 6px; }
}

.batch-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 14px; background: var(--accent-soft);
  border-bottom: 1px solid var(--line-2);
}
.batch-bar .bb-info { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.batch-bar .bb-info b { color: var(--accent); font-size: 13px; }
.batch-bar select, .batch-bar input { height: 30px; font-size: 12px; padding: 0 8px; }
.batch-bar select { max-width: 156px; }
.batch-bar input { max-width: 124px; }
.batch-bar.on { box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 920px) {
  .batch-bar { padding: 8px 10px; gap: 6px; }
  .batch-bar select, .batch-bar input { max-width: 47%; flex: 1 1 47%; }
  .batch-bar .btn { flex: 1 1 auto; justify-content: center; }
}

table.tbl-bk { min-width: 780px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; font-size: 12.5px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.detail-grid b { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.detail-grid span { color: var(--ink); word-break: break-all; }
html[data-theme="dark"] .batch-bar { background: rgba(79, 141, 255, .10); }

/* ---------------- 库存导入：表头分析与列对应 ---------------- */
.imp-stage {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 10px 12px 6px; margin-bottom: 10px;
}
.imp-hd { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.imp-file { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; }
.imp-file svg { width: 15px; height: 15px; stroke: var(--accent); fill: none; stroke-width: 1.7; flex: 0 0 15px; }
.imp-file b { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.imp-inline { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.imp-inline select { height: 28px; font-size: 11.5px; padding: 0 6px; max-width: 210px; }
.imp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.imp-chips .pill { font-size: 11px; }
table.tbl-map { margin-top: 4px; }
table.tbl-map td { padding: 6px 10px; vertical-align: middle; }
table.tbl-map select { width: 100%; height: 30px; font-size: 12px; }
.req { color: var(--red); font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; margin-left: 2px; }
@media (max-width: 640px) {
  .imp-file b { max-width: 150px; }
  .imp-inline select { max-width: 130px; }
}

/* 长文案的提示框：整体作为单个 flex 项，避免逐词被挤成窄列 */
.notice > div { min-width: 0; flex: 1 1 auto; }

/* ---------------- 工厂在途订单：新建表单行 ---------------- */
.fo-head, .fo-row { display: grid; grid-template-columns: 1fr 96px 30px; gap: 8px; align-items: center; }
.fo-head { padding: 6px 2px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.fo-row { padding: 8px 2px; border-bottom: 1px solid var(--line-2); }
.fo-row:last-child { border-bottom: none; }
.fo-row .rm { color: var(--faint); cursor: pointer; text-align: center; font-size: 15px; line-height: 1; }
.fo-row .rm:hover { color: var(--red); }
.opt { color: var(--muted); font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; margin-left: 2px; }

/* 工厂在途订单详情：整单统一批次号一行 */
.fo-uni { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fo-uni > span { flex: 0 0 150px; }
.fo-uni .input-scan { flex: 1 1 260px; max-width: 420px; }
@media (max-width: 640px) {
  .fo-uni > span { flex: 1 1 100%; }
}

/* ---------------- 系统设置 · 操作报文 ---------------- */
.pager.audit-pager { justify-content: space-between; flex-wrap: wrap; }
.pager.audit-pager .small { min-width: 0; text-align: left; }
.tbl-audit td { vertical-align: top; }
.tbl-audit .cell-main { font-weight: 600; }
.tbl-audit tr.row-warn .cell-main { color: var(--red); }
@media (max-width: 640px) {
  .tbl-audit th, .tbl-audit td { padding: 7px 8px; font-size: 11.5px; }
}

/* 产品档案：编辑 / 删除按钮并排 */
.tbl-prod td.col-act .btn + .btn { margin-left: 5px; }
.tbl-prod td.col-act { white-space: nowrap; }

/* ---------------- 库存查询：批次过期预警角标 ---------------- */
.prodcell { position: relative; }
.prodcell.has-warn .cell-main,
.prodcell.has-warn .cell-sub { padding-right: 62px; }
.warn-badge {
  position: absolute; top: 6px; right: 8px;
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  border: 1px solid currentColor; font-size: 10px; line-height: 15px;
  font-weight: 600; white-space: nowrap; cursor: help;
}
.warn-badge.m3 { color: #b45309; background: #fffbeb; border-color: #fcd34d; }
.warn-badge.m6 { color: #c2410c; background: #fff7ed; border-color: #fdba74; }
.warn-badge.m9 { color: #7e22ce; background: #faf5ff; border-color: #d8b4fe; }
.warn-badge.expired { color: #b91c1c; background: #fee2e2; border-color: #f87171; box-shadow: 0 0 0 2px rgba(239,68,68,.12); }
html[data-theme="dark"] .warn-badge.m3 { color: #fcd34d; background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.5); }
html[data-theme="dark"] .warn-badge.m6 { color: #fdba74; background: rgba(249,115,22,.14); border-color: rgba(249,115,22,.5); }
html[data-theme="dark"] .warn-badge.m9 { color: #d8b4fe; background: rgba(168,85,247,.16); border-color: rgba(168,85,247,.5); }
html[data-theme="dark"] .warn-badge.expired { color: #fca5a5; background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.6); }

/* 产品详情弹窗：档案信息条 */
.pd-info { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:8px; }
.pd-info > div { background:var(--bg-soft,#f7f8fa); border:1px solid var(--line,#e5e7eb); border-radius:6px; padding:8px 10px; }
.pd-info span { display:block; font-size:11px; color:var(--muted,#6b7280); margin-bottom:3px; }
.pd-info b { font-size:13px; color:var(--text,#111827); }
html[data-theme="dark"] .pd-info > div { background:rgba(255,255,255,.04); border-color:rgba(255,255,255,.1); }
html[data-theme="dark"] .pd-info b { color:#e5e7eb; }
