/* ==========================================================================
   InvenFlow · 库存管理系统
   Design System: Data-Dense Dashboard  |  Navy #1E40AF + Amber #F59E0B
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;

  /* Brand */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --accent: #f59e0b;
  --accent-soft: #fffbeb;

  /* Text */
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;

  /* Lines */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Semantic */
  --in: #2563eb;         /* 入库 */
  --in-soft: #eff6ff;
  --out: #ea580c;        /* 出库 */
  --out-soft: #fff7ed;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* Metrics */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 4px 12px -4px rgba(15, 23, 42, .08);
  --sidebar-w: 232px;
  --ease: cubic-bezier(.16, 1, .3, 1);

  --font: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================ Layout ============================ */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0f1f4b;
  background: linear-gradient(178deg, #142a5e 0%, #0f1f4b 60%, #0d1a3f 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  transition: width .28s var(--ease), flex-basis .28s var(--ease);
  z-index: 40;
}
.app.collapsed .sidebar { width: 60px; flex-basis: 60px; }
.app.collapsed .brand-text,
.app.collapsed .nav-group-label,
.app.collapsed .nav-item span,
.app.collapsed .sidebar-foot { display: none; }
.app.collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app.collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.app.collapsed .brand { justify-content: center; padding-inline: 10px; }
.app.collapsed .sidebar-toggle { position: absolute; right: -11px; top: 20px; background: var(--primary); border-color: var(--primary); color: #fff; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08);
  position: relative;
}
.brand-mark {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px -2px rgba(59, 130, 246, .5);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { color: #fff; font-size: 14px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle {
  margin-left: auto; width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
  color: #cbd5e1; display: grid; place-items: center; transition: background .18s, color .18s;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); background-clip: content-box; }
.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: #64748b; padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  color: #cbd5e1; font-size: 13px; margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .16s, color .16s;
  position: relative;
}
.nav-item svg { flex: 0 0 17px; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(59, 130, 246, .22); color: #fff; font-weight: 550; }
.nav-item.active svg { opacity: 1; color: #93c5fd; }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: #60a5fa;
}
.nav-badge {
  margin-left: auto; background: var(--accent); color: #422006;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 11px; }
.sf-row { display: flex; justify-content: space-between; color: #64748b; padding: 2px 0; }
.sf-row b { color: #cbd5e1; font-weight: 600; font-variant-numeric: tabular-nums; }

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

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30; min-height: 60px;
}
.page-title h1 { font-size: 17px; }
.page-title p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 20px 22px 48px; flex: 1; outline: none; }
.only-mobile { display: none; }

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 13px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 12.5px;
  font-weight: 550; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .16s, border-color .16s, color .16s, box-shadow .16s;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted-2); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn svg { flex: 0 0 auto; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #422006; }
.btn.accent:hover { filter: brightness(.96); }
.btn.danger { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }
.btn.danger:hover { background: #fee2e2; border-color: #fca5a5; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; border-radius: 5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--muted);
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ============================ Cards ============================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.card-head h3 { font-size: 13.5px; }
.card-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================ KPI ============================ */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--tone, var(--primary));
}
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.kpi-ico {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--tone-soft, var(--primary-soft)); color: var(--tone, var(--primary));
}
.kpi-val { font-size: 23px; font-weight: 680; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

/* card inner padding helper */
.card-pad { padding: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }

/* kv list */
.kv-k { color: var(--muted); font-size: 11.5px; }
.kv-v { font-weight: 550; min-width: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 22px; }

/* number emphasis contexts */
.num.in { color: var(--in); }
.num.out { color: var(--out); }
.num.danger { color: var(--danger); }
.num.muted { color: var(--muted); }

/* range picker */
.range-pick { display: inline-flex; align-items: center; gap: 6px; }
.rng-sep { color: var(--muted); }

/* alert sub-parts */
.alert-body { flex: 1; min-width: 0; }
.alert-sub { font-size: 11.5px; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.alert-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.55); border: 1px solid #fde68a; border-radius: 6px; padding: 1px 7px; font-size: 11px; }
.alert-more { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 11.5px; margin-left: 4px; white-space: nowrap; }
.alert-more:hover { text-decoration: underline; }

/* todo / list rows */
.todo-list { display: flex; flex-direction: column; }
.todo { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--surface-3); cursor: pointer; transition: background .14s; }
.todo:last-child { border-bottom: none; }
.todo:hover { background: var(--primary-soft); }
.todo-ico { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.todo-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.todo-act { color: var(--muted-2); flex: 0 0 auto; }

/* table footnote */
.table-foot-note { padding: 10px 14px; font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); }
.table-foot-note b { color: var(--text-2); font-weight: 650; }
.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--in); }
.delta.down { color: var(--out); }

/* ============================ Table ============================ */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.dt th {
  text-align: left; font-weight: 600; color: var(--muted); background: var(--surface-2);
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2; font-size: 11.5px; letter-spacing: .02em;
}
table.dt th.sortable { cursor: pointer; user-select: none; }
table.dt th.sortable:hover { color: var(--text); }
table.dt th .sort-ind { opacity: .45; margin-left: 3px; font-size: 9px; }
table.dt th.sorted .sort-ind { opacity: 1; color: var(--primary); }
table.dt td { padding: 8px 12px; border-bottom: 1px solid var(--surface-3); vertical-align: middle; }
table.dt tbody tr { transition: background .12s; }
table.dt tbody tr:hover { background: var(--primary-soft); }
table.dt tbody tr.clickable { cursor: pointer; }
table.dt tfoot td { padding: 9px 12px; background: var(--surface-2); font-weight: 650; border-top: 1px solid var(--border); }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
td.ta-r, th.ta-r { text-align: right; }
td.ta-c, th.ta-c { text-align: center; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11px; color: var(--muted); }
.cell-code { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { color: var(--muted-2); margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-size: 13px; color: var(--text-2); font-weight: 550; }
.empty span { font-size: 12px; }

.pager {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--muted);
}
.pager .spacer { margin-left: auto; }
.pager button {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background .15s, border-color .15s;
}
.pager button:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary-border); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ============================ Forms ============================ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 11px; color: var(--muted); }
.field .err { font-size: 11px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 7px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; transition: border-color .16s, box-shadow .16s; outline: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 64, 175, .12);
}
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input.invalid, .select.invalid { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 62px; }
.select { appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 13px; cursor: pointer; }
.input.num-input { text-align: right; font-variant-numeric: tabular-nums; }
.form-grid .num-input { text-align: left; }

.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.search-box .input { padding-left: 30px; min-width: 210px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .c3 { grid-column: span 1; }
.form-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 34px; height: 19px; border-radius: 20px; background: var(--border-strong);
  position: relative; transition: background .2s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(15px); }

/* ============================ Badges / tags ============================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.6;
}
.badge.b-in { background: var(--in-soft); color: var(--in); border-color: #bfdbfe; }
.badge.b-out { background: var(--out-soft); color: var(--out); border-color: #fed7aa; }
.badge.b-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.badge.b-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.b-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.b-mute { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge.b-primary { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.tab {
  padding: 8px 14px; cursor: pointer; border: none; background: none; font-size: 12.5px;
  color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .16s, border-color .16s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button {
  border: none; background: none; padding: 5px 11px; border-radius: 5px; cursor: pointer;
  font-size: 12px; color: var(--muted); font-weight: 550; transition: background .16s, color .16s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.toolbar .spacer { margin-left: auto; }
.toolbar label.inline { font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ============================ Modal ============================ */
.modal-root {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(15, 23, 42, .42); backdrop-filter: blur(3px);
  animation: fade .18s var(--ease); padding: 24px;
}
.modal-root[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; animation: pop .22s var(--ease); overflow: hidden;
}
.modal.wide { width: 1000px; }
.modal.mid { width: 760px; }
.modal.narrow { width: 420px; }
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 14.5px; }
.modal-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.modal-foot .spacer { margin-right: auto; }

/* ============================ Toast ============================ */
.toast-root {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px; padding: 10px 14px; min-width: 250px; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: 12.5px;
  animation: slideIn .26s var(--ease); pointer-events: auto;
}
.toast.out { animation: slideOut .2s var(--ease) forwards; }
.toast.ok { border-left-color: var(--ok); }
.toast.ok .t-ico { color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.err .t-ico { color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn .t-ico { color: var(--warn); }
.t-ico { flex: 0 0 auto; margin-top: 1px; color: var(--primary); }
.t-body strong { display: block; font-weight: 600; }
.t-body span { color: var(--muted); font-size: 11.5px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px) } to { opacity: 1; transform: none } }
@keyframes slideOut { to { opacity: 0; transform: translateX(24px) } }

/* ============================ Doc editor ============================ */
.doc-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.line-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.line-table th {
  background: var(--surface-2); padding: 8px 10px; text-align: left; font-size: 11.5px;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); border-top: 1px solid var(--border);
}
.line-table th:first-child { border-left: 1px solid var(--border); border-radius: var(--r-sm) 0 0 0; }
.line-table th:last-child { border-right: 1px solid var(--border); border-radius: 0 var(--r-sm) 0 0; }
.line-table td { padding: 5px 6px; border-bottom: 1px solid var(--surface-3); }
.line-table td:first-child { border-left: 1px solid var(--border); padding-left: 10px; }
.line-table td:last-child { border-right: 1px solid var(--border); }
.line-table tbody tr:hover { background: var(--surface-2); }
.line-table .input, .line-table .select { padding: 5px 8px; font-size: 12px; }
.line-table tfoot td { background: var(--surface-2); font-weight: 650; padding: 9px 10px; border: 1px solid var(--border); border-top: none; }
.line-idx { color: var(--muted-2); font-size: 11px; width: 26px; text-align: center; font-variant-numeric: tabular-nums; }
.line-del { color: var(--muted-2); cursor: pointer; border: none; background: none; padding: 4px; border-radius: 4px; display: grid; place-items: center; }
.line-del:hover { color: var(--danger); background: var(--danger-soft); }

.summary-bar {
  display: flex; gap: 26px; padding: 12px 16px; background: var(--primary-soft);
  border: 1px solid var(--primary-border); border-radius: var(--r); margin-top: 14px; flex-wrap: wrap;
}
.summary-bar div { display: flex; flex-direction: column; gap: 1px; }
.summary-bar span { font-size: 11px; color: var(--muted); }
.summary-bar b { font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--primary); }

/* ============================ Misc ============================ */
.progress { height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--tone, var(--primary)); transition: width .5s var(--ease); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--surface-3); }
.tl-item:last-child { border-bottom: none; }
.tl-ico { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; display: grid; place-items: center; }
.tl-main { flex: 1; min-width: 0; }
.tl-main strong { font-size: 12.5px; font-weight: 600; }
.tl-main p { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 12.5px; }
.tl-amt small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }

.alert {
  display: flex; gap: 9px; padding: 10px 13px; border-radius: var(--r-sm); font-size: 12.5px;
  background: var(--warn-soft); border: 1px solid #fde68a; color: #92400e; align-items: flex-start;
}
.alert.info { background: var(--primary-soft); border-color: var(--primary-border); color: #1e3a8a; }
.alert.danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert svg { flex: 0 0 auto; margin-top: 1px; }

.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-host .grid-line { stroke: var(--border); stroke-width: 1; }
.chart-host .axis-txt { font-size: 10px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.bar-rect { transition: opacity .16s; cursor: pointer; }
.bar-rect:hover { opacity: .78; }

.hbar-row { display: grid; grid-template-columns: 1fr 74px; gap: 10px; align-items: center; padding: 6px 0; }
.hbar-label { font-size: 12px; display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.hbar-label span { color: var(--muted); font-size: 11px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; }

.pill-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 4px 11px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 11.5px; color: var(--muted); font-weight: 550; transition: all .16s;
}
.pill:hover { border-color: var(--muted-2); color: var(--text); }
.pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.mini-stat { display: flex; align-items: baseline; gap: 6px; }
.mini-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-stat span { font-size: 11px; color: var(--muted); }

.print-only { display: none; }

/* ============================ Responsive ============================ */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-lg);
  }
  .app.mobile-open .sidebar { transform: none; }
  .only-mobile { display: grid; }
  .sidebar-toggle { display: none; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols3 { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: 1fr; }
  .modal-root { padding: 10px; }
  .page-title h1 { font-size: 15px; }
  .page-title p { display: none; }
}

@media print {
  @page {
    size: A4;
    margin: 14mm 12mm 22mm 12mm;
    @bottom-center {
      content: counter(page);
      font-size: 8px; color: #999;
      font-family: 'Microsoft YaHei', sans-serif;
    }
  }

  html, body {
    background: #fff; margin: 0; padding: 0;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'SimSun', sans-serif;
    width: 100%; min-height: 0;
  }
  .sidebar, .topbar, .toolbar, .pager, .no-print, .print-hide,
  .modal-root, .toast-root, .app .main, .app .sidebar,
  #view { display: none !important; }
  .app { display: block !important; min-height: auto !important; height: auto !important; overflow: visible !important; }

  body { background: #fff; }
  * { color: #000 !important; }
  #print-root { display: block !important; position: static; width: 100%; padding: 0; }
  #print-root, .print-doc, .print-doc * { color: #000 !important; }
  .print-doc { max-width: 100%; margin: 0; padding: 0; font-size: 10.5px; background: #fff; line-height: 1.55; overflow: visible; }

  /* ===== 头区 —— 不跨页 ===== */
  .pd-head { padding-bottom: 6px; margin-bottom: 8px; border-bottom: 2px solid #000; text-align: center; page-break-after: avoid; page-break-inside: avoid; }
  .pd-company { font-size: 16px; font-weight: 700; }
  .pd-title { font-size: 13px; font-weight: 600; margin-top: 2px; }

  /* ===== 信息区 —— 不跨页 ===== */
  .pd-info { display: grid; grid-template-columns: 68px 1fr 68px 1fr; gap: 2px 14px; margin-bottom: 10px; font-size: 10px; line-height: 1.7; page-break-inside: avoid; page-break-after: avoid; }
  .pd-info-th { font-weight: 600; }
  .pd-info-td { font-weight: 500; }

  /* ===== 明细表 —— 自动分页，每页重复表头 ===== */
  .pd-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 10px; page-break-inside: auto; }
  .pd-table thead { display: table-header-group; }
  .pd-table tbody { page-break-inside: auto; }
  .pd-table tr { page-break-inside: avoid; page-break-after: auto; }
  .pd-table th { background: #fff; text-align: left; padding: 5px 6px; border: 1px solid #000; font-weight: 600; font-size: 9.5px; }
  .pd-table td { padding: 4px 6px; border: 1px solid #000; vertical-align: top; word-break: break-all; overflow: visible; }
  .pd-table tfoot td { font-weight: 650; border-top: 2px solid #000; text-align: center; }
  .pd-table .c { text-align: center; }
  .pd-table .r { text-align: right; white-space: nowrap; }

  /* ===== 底栏 ===== */
  .pd-foot { display: flex; gap: 20px; font-size: 10px; padding-top: 8px; border-top: 1px solid #000; page-break-inside: avoid; }
  .pd-foot b { font-weight: 650; }
  .pd-remark { font-size: 9.5px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed #000; page-break-inside: avoid; }
  .pd-sign { display: flex; gap: 40px; margin-top: 14px; font-size: 10px; page-break-inside: avoid; }
  .pd-sign span { min-width: 100px; }
  .pd-sign span::after { content: '____________'; letter-spacing: 2px; margin-left: 6px; }

  /* ===== 页码标签 ===== */
  .pd-page { text-align: right; font-size: 9px; color: #999; padding-top: 6px; }
}

/* 打印模板（屏幕隐藏） */
#print-root { display: none; }

/* ===== 登录页 ===== */
.login-box {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; width: 100%;
  background: var(--bg);
}
.login-card {
  width: 380px; max-width: 100%; padding: 36px 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-l); box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo { margin-bottom: 24px; }
.login-logo svg { margin-bottom: 10px; }
.login-logo h2 { font-size: 18px; font-weight: 700; margin: 0; }
.login-logo p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.login-form { margin-bottom: 18px; }
.login-input { width: 100%; padding: 10px 14px; font-size: 14px; text-align: center; letter-spacing: 0.15em; }
.login-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }
.login-btn { width: 100%; padding: 10px; font-size: 14px; }
.login-error { font-size: 12px; color: var(--danger); margin-top: 8px; min-height: 18px; }

/* 退出登录项 */
.nav-item.logout-item { color: var(--muted); }
.nav-item.logout-item:hover { color: var(--danger); background: var(--danger-soft); }

/* ===== 商品选择器 ===== */
.picker-trigger {
  width: 100%; text-align: left; padding: 5px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-height: 30px;
}
.picker-trigger:hover { border-color: var(--primary); }
.picker-trigger .ph { color: var(--muted); }
.picker-search { margin-bottom: 10px; }
.picker-search .input { width: 100%; padding: 8px 12px; font-size: 13px; }
.picker-cats {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 0 10px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.picker-cat {
  padding: 4px 12px; font-size: 11.5px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  cursor: pointer; color: var(--text); transition: all .14s;
}
.picker-cat:hover { border-color: var(--muted-2); }
.picker-cat.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.picker-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); }
.picker-empty { padding: 30px; text-align: center; color: var(--muted); }
.picker-item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--bg-soft); }
.picker-item.on { background: var(--in-soft); }
.picker-item-main { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.picker-item-main .cell-code { font-size: 11.5px; }
.picker-item-main .name { font-weight: 600; }
.picker-item-sub { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.picker-item-sub .price { color: var(--primary); font-weight: 600; }

/* ===== 打印预览（屏幕） ===== */
.print-preview {
  background: #e5e7eb; padding: 24px; border-radius: 8px;
  display: flex; justify-content: center; max-height: 70vh; overflow-y: auto;
}
.print-preview .print-doc {
  box-shadow: 0 8px 32px rgba(0,0,0,.14); border-radius: 6px;
  background: #fff; padding: 28px 32px; max-width: 200mm; min-width: 160mm;
  font-family: 'Microsoft YaHei', 'PingFang SC', 'SimSun', sans-serif;
  font-size: 10.5px; color: #000; line-height: 1.55;
}
.print-preview .pd-head { padding-bottom: 6px; margin-bottom: 8px; border-bottom: 2px solid #000; text-align: center; }
.print-preview .pd-company { font-size: 16px; font-weight: 700; color: #000; }
.print-preview .pd-title { font-size: 13px; font-weight: 600; color: #000; margin-top: 2px; }
.print-preview .pd-info { display: grid; grid-template-columns: 68px 1fr 68px 1fr; gap: 2px 14px; margin-bottom: 10px; font-size: 10px; line-height: 1.7; }
.print-preview .pd-info-th { font-weight: 600; color: #000; }
.print-preview .pd-info-td { font-weight: 500; color: #000; }
.print-preview .pd-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 10px; }
.print-preview .pd-table th { background: #fff; color: #000; text-align: left; padding: 5px 6px; border: 1px solid #000; font-weight: 600; font-size: 9.5px; }
.print-preview .pd-table td { padding: 4px 6px; border: 1px solid #000; vertical-align: top; word-break: break-all; color: #000; }
.print-preview .pd-table tfoot td { font-weight: 650; border-top: 2px solid #000; text-align: center; }
.print-preview .pd-table .c { text-align: center; }
.print-preview .pd-table .r { text-align: right; white-space: nowrap; }
.print-preview .pd-foot { display: flex; gap: 20px; font-size: 10px; padding-top: 8px; border-top: 1px solid #000; color: #000; }
.print-preview .pd-remark { font-size: 9.5px; color: #000; margin-top: 6px; padding-top: 6px; border-top: 1px dashed #000; }
.print-preview .pd-sign { display: flex; gap: 40px; margin-top: 14px; font-size: 10px; color: #000; }
.print-preview .pd-sign span { min-width: 100px; color: #000; }
.print-preview .pd-sign span::after { content: '____________'; letter-spacing: 2px; margin-left: 6px; color: #000; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
