/* ============================================================
 * 仓管家 · 仓库管理系统 — 样式表
 * 现代卡片式布局 / 浅色为主 + 深色可切换 / 全响应式
 * ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, .12);
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f2f7;
  --border: #e6e8ef;
  --border-strong: #d6d9e3;
  --text: #1c2030;
  --text-2: #5b6377;
  --text-3: #8b93a7;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --ok-soft: rgba(16, 185, 129, .12);
  --warn-soft: rgba(245, 158, 11, .14);
  --danger-soft: rgba(239, 68, 68, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .28);
  --sidebar-w: 236px;
}

[data-theme="dark"] {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1c2029;
  --surface-3: #232833;
  --border: #2a2f3b;
  --border-strong: #39404f;
  --text: #eef1f7;
  --text-2: #a9b1c3;
  --text-3: #79839a;
  --ok-soft: rgba(16, 185, 129, .18);
  --warn-soft: rgba(245, 158, 11, .18);
  --danger-soft: rgba(239, 68, 68, .18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -24px rgba(0, 0, 0, .75);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }
b, strong { font-weight: 700; }
sup { font-size: 10px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

.muted { color: var(--text-3); }
.danger { color: var(--danger); }
.up { color: var(--info); }
.down { color: var(--warn); }

/* ---------- 总体布局 ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee));
  font-size: 20px;
  box-shadow: 0 8px 18px -8px var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.brand-text strong { font-size: 15.5px; letter-spacing: .3px; }
.brand-text span { font-size: 11.5px; color: var(--text-3); }
.sidebar-close { display: none; margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 0; background: transparent; cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  transition: background .16s, color .16s, transform .16s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active .nav-ico { transform: scale(1.05); }
.nav-ico { font-size: 16px; width: 20px; text-align: center; transition: transform .16s; }
.nav-label { flex: 1; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--danger); color: #fff;
  font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center;
}

.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.storage-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-3);
  font-size: 12.5px; color: var(--text-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.dot-local { background: var(--text-3); }
.dot-cloud { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sidebar-meta {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 11.5px; color: var(--text-3);
}

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.topbar-title p { font-size: 12.5px; color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.search-mini {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 11px;
  height: 36px;
  width: 230px;
  transition: border-color .16s, box-shadow .16s;
}
.search-mini:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-mini span { font-size: 13px; opacity: .65; }
.search-mini input {
  border: 0; outline: 0; background: transparent;
  width: 100%; font-size: 13px;
}

.content { padding: 20px 24px 40px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .16s, border-color .16s, opacity .16s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 20px -12px var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-warn { background: var(--warn); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; font-weight: 600; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  transition: background .16s, color .16s, border-color .16s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 12.5px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.only-mobile { display: none; }

.link-btn {
  border: 0; background: none; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .head-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head .muted { font-size: 12.5px; margin-left: auto; font-variant-numeric: tabular-nums; }
.card-head > .link-btn { margin-left: auto; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  display: flex; align-items: flex-start; gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute; inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone, var(--accent));
}
.kpi-ico {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 20px;
  background: color-mix(in srgb, var(--tone, var(--accent)) 12%, transparent);
}
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 12.5px; color: var(--text-3); }
.kpi-value {
  font-size: 25px; font-weight: 750; letter-spacing: -.5px;
  line-height: 1.25;
  color: var(--tone, var(--text));
  word-break: break-all;
}
.kpi-value em { font-size: 12.5px; font-style: normal; font-weight: 600; color: var(--text-3); margin-left: 3px; }
.kpi-sub { font-size: 11.5px; color: var(--text-3); }
.kpi-indigo { --tone: #6366f1; }
.kpi-sky { --tone: #0ea5e9; }
.kpi-teal { --tone: #14b8a6; }
.kpi-rose { --tone: #ef4444; }
.kpi-amber { --tone: #f59e0b; }
.kpi-slate { --tone: #64748b; }
.kpi-grid.small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.small .kpi-value { font-size: 22px; }

/* ---------- 栅格 ---------- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-side { display: grid; grid-template-columns: 372px minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 > .card, .grid-side > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }

/* ---------- 分段控件 ---------- */
.seg {
  margin-left: auto;
  display: inline-flex;
  background: var(--surface-3);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.seg.wide { margin: 0 0 14px; width: 100%; }
.seg.wide .seg-btn { flex: 1; }
.seg-btn {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  transition: background .16s, color .16s;
}
.seg-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.legend-inline { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.lg { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.lg-in { background: var(--accent); }
.lg-out { background: var(--warn); margin-left: 8px; }

/* ---------- 环形图 ---------- */
.donut-wrap { min-height: 220px; display: grid; place-items: center; }
.donut { display: flex; align-items: center; gap: 22px; width: 100%; flex-wrap: wrap; justify-content: center; }
.donut-ring {
  width: 158px; height: 158px; flex: 0 0 158px;
  border-radius: 50%;
  display: grid; place-items: center;
  position: relative;
}
.donut-hole {
  width: 106px; height: 106px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center; align-content: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
.donut-total-label { font-size: 11.5px; color: var(--text-3); }
.donut-total { font-size: 16px; font-weight: 750; letter-spacing: -.3px; }
.legend { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 7px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.lg-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.legend-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.legend-pct { width: 46px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- 柱状图 ---------- */
.bars-wrap { min-height: 220px; }
.bars { position: relative; height: 216px; padding: 8px 0 0; }
.bars-grid { position: absolute; inset: 8px 0 30px 34px; display: flex; flex-direction: column; justify-content: space-between; }
.bar-grid-line { border-top: 1px dashed var(--border); position: relative; }
.bar-grid-line span { position: absolute; left: -34px; top: -9px; font-size: 10.5px; color: var(--text-3); }
.bars-cols { position: absolute; inset: 8px 0 0 34px; display: flex; align-items: flex-end; gap: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar {
  width: 40%; max-width: 16px;
  border-radius: 5px 5px 2px 2px;
  position: relative;
  transition: filter .16s;
  min-height: 2px;
}
.bar:hover { filter: brightness(1.1); }
.bar-in { background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 62%, transparent)); }
.bar-out { background: linear-gradient(180deg, var(--warn), color-mix(in srgb, var(--warn) 58%, transparent)); }
.bar em {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-style: normal; color: var(--text-3);
  opacity: 0; transition: opacity .16s; white-space: nowrap;
}
.bar-col:hover .bar em { opacity: 1; }
.bar-label { font-size: 11px; color: var(--text-3); margin-top: 7px; }

/* ---------- 排名条 ---------- */
.rank { display: flex; flex-direction: column; gap: 14px; }
.rank-item { display: flex; gap: 11px; align-items: flex-start; }
.rank-no {
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 7px;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  background: var(--surface-3); color: var(--text-3);
}
.rank-no-1 { background: rgba(245, 158, 11, .16); color: #d97706; }
.rank-no-2 { background: rgba(148, 163, 184, .2); color: #64748b; }
.rank-no-3 { background: rgba(180, 83, 9, .14); color: #b45309; }
.rank-mid { flex: 1; min-width: 0; }
.rank-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.rank-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-val { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--accent); }
.rank-track { height: 6px; border-radius: 4px; background: var(--surface-3); margin: 5px 0 3px; overflow: hidden; }
.rank-track i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #22d3ee)); }
.rank-sub { font-size: 11.5px; color: var(--text-3); }

/* ---------- 表格 ---------- */
.table-scroll { width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
.table-scroll.tall { max-height: 560px; overflow-y: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-weight: 650; font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .act { text-align: right; white-space: nowrap; }
.table .act .btn + .btn, .table .act .icon-btn + .icon-btn { margin-left: 4px; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.row-warn { background: color-mix(in srgb, var(--warn-soft) 55%, transparent); }
.row-danger { background: color-mix(in srgb, var(--danger-soft) 55%, transparent); }
.table tbody tr.row-muted { background: var(--surface-2); }
.table tbody tr.row-muted .cell-main { color: var(--text-2); }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-3);
  padding: 2px 7px; border-radius: 6px;
  color: var(--text-2);
  white-space: nowrap;
}
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--text-3); }

.chip {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650;
  white-space: nowrap;
}
.chip-plain { background: var(--surface-3); color: var(--text-2); font-weight: 550; }
.chip-ok { background: var(--ok-soft); color: #047857; }
.chip-warn { background: var(--warn-soft); color: #b45309; }
.chip-danger { background: var(--danger-soft); color: #b91c1c; }
.chip-in { background: var(--accent-soft); color: var(--accent); }
.chip-out { background: var(--warn-soft); color: #b45309; }
[data-theme="dark"] .chip-ok { color: #34d399; }
[data-theme="dark"] .chip-warn { color: #fbbf24; }
[data-theme="dark"] .chip-danger { color: #f87171; }
[data-theme="dark"] .chip-out { color: #fbbf24; }

.table-foot {
  display: flex; align-items: center; gap: 12px;
  padding-top: 12px; font-size: 12.5px;
}
.pager { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.pg {
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-size: 12.5px; color: var(--text-2);
}
.pg:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pg.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pg:disabled { opacity: .4; cursor: not-allowed; }
.pg-dots { color: var(--text-3); padding: 0 3px; }

/* ---------- 工具栏 / 表单控件 ---------- */
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
  min-width: 240px; flex: 1 1 240px;
  transition: border-color .16s, box-shadow .16s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.search-box span { opacity: .6; font-size: 13px; }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; }

.select, .input {
  height: 36px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 13px; outline: 0;
  transition: border-color .16s, box-shadow .16s;
  max-width: 100%;
}
.select { padding-right: 26px; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.sm, .input.sm { height: 32px; font-size: 12.5px; border-radius: 8px; }
.input::placeholder { color: var(--text-3); }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field > span b { color: var(--danger); font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; font-weight: 500; }
.field.inline .input { width: 96px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form .span-2 { grid-column: span 2; }

.hint { font-size: 12px; color: var(--text-3); }
.hint b { color: var(--text); }
.hint-warn { color: #b45309; }
.hint-danger { color: #b91c1c; }
[data-theme="dark"] .hint-warn { color: #fbbf24; }
[data-theme="dark"] .hint-danger { color: #f87171; }
.small-note { font-size: 12px; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }
.btn-row.wrap { flex-wrap: wrap; }

/* ---------- 开关 / 单选卡 ---------- */
.switch-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 40px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0;
  background: var(--border-strong); border-radius: 999px;
  transition: background .2s;
}
.switch i::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.rule-bar {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.radio-card {
  position: relative; cursor: pointer;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  background: var(--surface-2);
  transition: border-color .16s, background .16s;
  display: block;
}
.radio-card input { position: absolute; opacity: 0; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rc-body { display: flex; flex-direction: column; gap: 3px; }
.rc-body b { font-size: 13.5px; }
.rc-body em { font-size: 11.5px; font-style: normal; color: var(--text-3); line-height: 1.5; }

.swatches { display: flex; gap: 9px; }
.swatch {
  width: 28px; height: 28px; border-radius: 9px;
  border: 2px solid transparent; cursor: pointer;
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .25);
  transition: transform .14s, border-color .14s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--text); transform: scale(1.08); }

/* ---------- 统计列表 / 关于 ---------- */
.stat-list { margin-top: 16px; display: flex; flex-direction: column; }
.stat-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: 0; }
.stat-row span { color: var(--text-3); }
.about p { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

/* ---------- 空状态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 34px 10px; color: var(--text-3); font-size: 13px;
}
.empty span { font-size: 26px; opacity: .8; }

/* ---------- 弹窗 ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 20, 35, .45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  width: min(460px, 100%);
  max-height: 88vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateY(8px) scale(.98);
  transition: transform .2s;
  overflow: hidden;
}
.modal.wide { width: min(760px, 100%); }
.modal-wrap.in .modal { transform: none; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 18px; border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.confirm-text { font-size: 14px; color: var(--text-2); }

/* ---------- 提示条 ---------- */
.toast-root {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  min-width: 240px; max-width: 380px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toastIn .22s ease-out;
}
.toast.out { animation: toastOut .3s forwards; }
.toast p { flex: 1; color: var(--text); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------- 视图切换 ---------- */
.view { display: none; animation: fadeUp .24s ease-out; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 遮罩 ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(15, 20, 35, .4);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- 领取人 ---------- */
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn .select { flex: 1; min-width: 0; }

.person { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: #fff;
  letter-spacing: 0;
}
.avatar.frozen { filter: grayscale(1); opacity: .6; }

.chip-frozen { background: var(--surface-3); color: var(--text-3); }
.chip-active { background: var(--ok-soft); color: #047857; }
[data-theme="dark"] .chip-active { color: #34d399; }

.detail-sum {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.detail-sum > div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.detail-sum span { display: block; font-size: 11.5px; color: var(--text-3); }
.detail-sum b { font-size: 16px; font-weight: 700; }
.section-title {
  font-size: 13px; font-weight: 700; color: var(--text-2);
  margin: 4px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ''; width: 3px; height: 13px; border-radius: 2px;
  background: var(--accent);
}
.modal-body .table-scroll { max-height: 300px; overflow-y: auto; }

/* ---------- 库存数量构成条 ---------- */
.qty-split {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 18px;
  margin-bottom: 18px;
}
.qs-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-3); font-weight: 600;
  margin-bottom: 9px;
}
.qs-legend {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-weight: 500; font-variant-numeric: tabular-nums;
}
.lg-avail { background: var(--info); }
.lg-frozen { background: var(--warn); margin-left: 10px; }
.qs-track {
  display: flex; height: 10px; border-radius: 6px;
  background: var(--surface-3); overflow: hidden;
}
.qs-track i { display: block; height: 100%; transition: width .4s ease; }
.qs-avail { background: linear-gradient(90deg, var(--info), color-mix(in srgb, var(--info) 60%, transparent)); }
.qs-frozen { background: linear-gradient(90deg, var(--warn), color-mix(in srgb, var(--warn) 60%, transparent)); }
.qs-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 8px; font-size: 11.5px; color: var(--text-3);
}

/* ============================================================
 * 入库登记 / 出库登记
 * ============================================================ */
.search-box.slim { min-width: 0; flex: none; height: 34px; border-radius: 9px; }

/* 快捷加量 */
.qty-quick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; height: 36px; }
.qty-quick button {
  height: 28px; padding: 0 10px; min-width: 38px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 650; cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: all .16s;
}
.qty-quick button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.qty-quick button:active { transform: translateY(1px); }

/* 折叠的更多字段 */
.more-fields {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--surface-2);
}
.more-fields[open] { padding-bottom: 12px; }
.more-fields > summary {
  list-style: none; cursor: pointer;
  padding: 9px 0;
  font-size: 12.5px; font-weight: 650; color: var(--text-2);
  display: flex; align-items: center; gap: 7px;
  user-select: none;
}
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields > summary::before {
  content: '▸'; font-size: 11px; color: var(--text-3);
  transition: transform .18s;
}
.more-fields[open] > summary::before { transform: rotate(90deg); }
.more-fields > summary:hover { color: var(--accent); }
.more-body { display: flex; flex-direction: column; gap: 12px; }

/* 手动新建仓库（入库登记：商品只选物料，仓库单独选） */
.wh-new {
  display: flex; flex-direction: column; gap: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}
.wh-new[hidden] { display: none; }
.wh-new .field > span { font-size: 11.5px; }

/* 库存联动预览 */
.stock-live {
  display: flex; flex-direction: column; gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  font-size: 12.5px;
}
.sl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sl-where {
  font-size: 12px; color: var(--text-2); font-weight: 600;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sl-top .chip { margin-left: auto; }
.sl-line {
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.sl-label { font-size: 12px; color: var(--text-3); }
.sl-before { font-size: 19px; font-weight: 700; color: var(--text-3); }
.sl-arrow { font-style: normal; color: var(--text-3); font-size: 13px; }
.sl-after { font-size: 23px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.sl-after.up { color: var(--ok); }
.sl-after.down { color: var(--info); }
.sl-after.danger { color: var(--danger); }
.sl-unit { font-size: 12px; color: var(--text-2); }
.sl-delta {
  font-style: normal; font-size: 12px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
}
.sl-delta.up { background: var(--ok-soft); color: #047857; }
.sl-delta.down { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.sl-delta.danger { background: var(--danger-soft); color: #b91c1c; }
.sl-delta.muted { font-weight: 550; }
.sl-sub { font-size: 11.5px; color: var(--text-3); }
.sl-sub b { color: var(--text-2); }
.sl-alert {
  font-size: 12px; font-weight: 600; color: #b91c1c;
  background: var(--danger-soft); border-radius: 8px; padding: 7px 10px;
}
.sl-note {
  font-size: 11.5px; color: #b45309;
  background: var(--warn-soft); border-radius: 8px; padding: 7px 10px;
}
.sl-empty { font-size: 12.5px; color: var(--text-3); }
.sl-done {
  font-size: 12.5px; font-weight: 600; color: #047857;
  background: var(--ok-soft); border-radius: 8px; padding: 8px 11px;
}
.sl-done b { font-weight: 800; }
[data-theme="dark"] .sl-after.up, [data-theme="dark"] .sl-delta.up { color: #34d399; }
[data-theme="dark"] .sl-delta.up { background: rgba(52, 211, 153, .16); }
[data-theme="dark"] .sl-alert { color: #f87171; }
[data-theme="dark"] .sl-note { color: #fbbf24; }
[data-theme="dark"] .sl-done { color: #34d399; }

/* ---------- 库存流水 ---------- */
.nav-badge.soft { background: var(--accent-soft); color: var(--accent); }
.lg-unit { font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.lg-reason { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.lg-kv { width: 120px; }
.lg-custom {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 11px 13px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.lg-custom .field { gap: 4px; }
.lg-custom-sep { color: var(--text-3); font-size: 12.5px; padding-bottom: 9px; }
.lg-foot-sum { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-3); }
.lg-foot-sum b { font-variant-numeric: tabular-nums; }
#btnLgMore { margin-left: auto; }

/* 按天分组的日期分隔行 */
.table tbody tr.lg-day,
.table tbody tr.lg-day:hover { background: var(--surface-2); }
.table tbody tr.lg-day td {
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-2);
  position: sticky; top: 38px; z-index: 1;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.lg-day-date { font-weight: 700; font-variant-numeric: tabular-nums; }
.lg-day-week { margin-left: 7px; color: var(--text-3); }
.lg-day-sum { float: right; color: var(--text-3); }
.lg-day-sum b { font-variant-numeric: tabular-nums; }

/* ---------- 商品数量列 ---------- */
.avail-num { color: var(--info); font-weight: 650; }
.frozen-num { color: #b45309; font-weight: 650; }
[data-theme="dark"] .frozen-num { color: #fbbf24; }
.input.readonly {
  background: var(--surface-3);
  color: var(--text-2);
  cursor: not-allowed;
  font-weight: 650;
}

/* ============================================================
 * 响应式
 * ============================================================ */
@media (max-width: 1180px) {
  .kpi-grid, .kpi-grid.small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-side { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-102%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-lg);
    width: 250px; flex-basis: 250px;
  }
  .sidebar.open { transform: none; }
  .sidebar-close { display: inline-grid; }
  .search-mini { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
  .radio-cards { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .kpi-grid, .kpi-grid.small { grid-template-columns: 1fr; }
  .detail-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-title p { display: none; }
  .topbar-actions .btn-ghost { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .donut-ring { width: 140px; height: 140px; flex-basis: 140px; }
  .donut-hole { width: 94px; height: 94px; }
  .toast-root { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
  .card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .qty-quick { height: auto; }
  .sl-before { font-size: 16px; }
  .sl-after { font-size: 20px; }
}

@media print {
  .sidebar, .topbar-actions, .backdrop, .toast-root { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
