/* ============================================================
   小伟通讯出入库系统 — 样式表
   ============================================================ */
:root {
  --brand: #2f6bff;
  --brand-soft: #eaf0ff;
  --brand-ink: #1b4ed8;
  --green: #10b981;
  --green-soft: #e7f9f1;
  --amber: #f59e0b;
  --amber-soft: #fff5e2;
  --red: #ef4444;
  --red-soft: #feeceb;
  --violet: #7c5cff;

  --bg: #f3f6fc;
  --bg-grad: radial-gradient(1200px 600px at 12% -10%, #e7efff 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #e9fbf5 0%, transparent 55%);
  --card: #ffffff;
  --card-2: #f8faff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #6b7c99;
  --line: #e6ecf7;
  --line-2: #eef2fa;
  --shadow: 0 1px 2px rgba(18, 38, 79, .04), 0 8px 24px -12px rgba(18, 38, 79, .16);
  --shadow-lg: 0 24px 60px -24px rgba(18, 38, 79, .35);
  --radius: 16px;
  --radius-sm: 11px;
  --side-w: 232px;
  --tab-h: 62px;
}

html[data-theme="dark"] {
  --brand: #5b8cff;
  --brand-soft: #16233d;
  --brand-ink: #9dbbff;
  --green: #34d399;
  --green-soft: #10291f;
  --amber: #fbbf24;
  --amber-soft: #2c2210;
  --red: #f87171;
  --red-soft: #2b1418;
  --bg: #080d17;
  --bg-grad: radial-gradient(1000px 500px at 10% -10%, #12203c 0%, transparent 60%),
             radial-gradient(800px 400px at 100% 0%, #0d2a24 0%, transparent 55%);
  --card: #111a2b;
  --card-2: #0d1524;
  --ink: #e8eefb;
  --ink-2: #c2cfe6;
  --muted: #8595b0;
  --line: #1e2a41;
  --line-2: #172234;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -16px rgba(0, 0, 0, .8);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, p { margin: 0; }
b, strong { font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#ic-home, #ic-in, #ic-out, #ic-box, #ic-list, #ic-cloud, #ic-gear, #ic-more { }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 32%, transparent); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

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

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  padding: 18px 14px 16px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}
.brand { display: flex; align-items: center; padding: 4px 2px 0; }
.brand-logo-wide {
  width: 100%;
  max-width: 198px;
  height: auto;
  display: block;
  border-radius: 11px;
  box-shadow: 0 6px 18px -12px rgba(15, 23, 42, .5);
}
html[data-theme="dark"] .brand-logo-wide { box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .9); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 13px; flex: 0 0 40px;
  background: linear-gradient(145deg, var(--brand), #6f4bff 90%);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 8px 20px -8px var(--brand);
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 13px; flex: 0 0 40px;
  object-fit: cover; display: block;
  box-shadow: 0 8px 20px -10px rgba(47, 107, 255, .85);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: 1.2px; }

.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background .16s, color .16s, transform .16s;
  position: relative;
}
.side-nav a svg { width: 18px; height: 18px; opacity: .8; }
.side-nav a:hover { background: var(--line-2); color: var(--ink); }
.side-nav a.active { background: var(--brand); color: #fff; box-shadow: 0 10px 22px -14px var(--brand); }
.side-nav a.active svg { opacity: 1; }
.side-nav a .badge-dot {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--amber-soft); color: var(--amber);
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.side-nav a.active .badge-dot { background: rgba(255,255,255,.22); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.pill-online {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line);
  padding: 7px 10px; border-radius: 999px; width: fit-content;
}
.pill-online i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.pill-online.offline i { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.side-ver { font-size: 11px; color: var(--muted); opacity: .75; padding-left: 4px; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar-title { min-width: 0; }
.topbar-logo { display: none; width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px; object-fit: cover; }
.topbar-title h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.topbar-title p { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.today-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px 6px 10px; font-size: 12px; color: var(--muted);
  box-shadow: var(--shadow);
}
.today-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.today-chip b { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.today-chip em { font-style: normal; }
.t-short { display: none; }
[hidden] { display: none !important; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; color: var(--ink-2);
  transition: transform .16s, background .16s, color .16s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand-ink); }
.icon-btn:active { transform: scale(.94); }

.view {
  padding: 18px 22px 40px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  outline: none;
  animation: viewIn .22s ease;
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabs { display: none; }
.only-mobile { display: none !important; }

/* ---------------- 通用组件 ---------------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }
.gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap14 { gap: 14px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: .2px; }
.card-head .sub { font-size: 11.5px; color: var(--muted); }
.card-head .right-slot { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: auto -30px -50px auto; width: 120px; height: 120px;
  border-radius: 50%; background: var(--brand-soft); opacity: .75;
}
.kpi.g::after { background: var(--green-soft); }
.kpi.a::after { background: var(--amber-soft); }
.kpi.v::after { background: color-mix(in srgb, var(--violet) 12%, transparent); }
.kpi .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.6px; margin-top: 6px; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi .value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; }
.trend-up { color: var(--green); font-weight: 650; }
.trend-down { color: var(--red); font-weight: 650; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: transform .14s, box-shadow .16s, background .16s, border-color .16s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); color: var(--brand-ink); }
.btn:active { transform: scale(.975); }
.btn.primary { background: linear-gradient(140deg, var(--brand), #4f46e5); border-color: transparent; color: #fff; box-shadow: 0 12px 24px -14px var(--brand); }
.btn.primary:hover { color: #fff; filter: brightness(1.05); }
.btn.green { background: linear-gradient(140deg, #0ea472, var(--green)); border-color: transparent; color: #fff; box-shadow: 0 12px 24px -14px var(--green); }
.btn.green:hover { color: #fff; }
.btn.danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn.lg { height: 48px; font-size: 15px; border-radius: 13px; width: 100%; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.field > label .req { color: var(--red); }
.input, .select, .textarea {
  height: 42px; padding: 0 12px; width: 100%;
  border-radius: 11px; border: 1px solid var(--line); background: var(--card-2);
  color: var(--ink); font-size: 14px; outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 64px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); background: var(--card);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand) 14%, transparent);
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group .input { flex: 1 1 auto; }
.hint { font-size: 11.5px; color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--brand); border-color: transparent; color: #fff; }
.chip.sm { height: 27px; padding: 0 10px; font-size: 11.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 7px;
  font-size: 11.5px; font-weight: 650; background: var(--line-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge.blue { background: var(--brand-soft); color: var(--brand-ink); }
.badge.green { background: var(--green-soft); color: #067a55; }
.badge.amber { background: var(--amber-soft); color: #a86200; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.gray { background: var(--line-2); color: var(--muted); }
html[data-theme="dark"] .badge.green { color: #6ee7b7; }
html[data-theme="dark"] .badge.amber { color: #fcd34d; }
html[data-theme="dark"] .badge.red { color: #fca5a5; }

.table-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.tb th {
  text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted);
  padding: 10px 12px; background: var(--card-2); border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0;
}
table.tb td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tb tr:last-child td { border-bottom: 0; }
table.tb tbody tr { transition: background .14s; }
table.tb tbody tr:hover { background: var(--card-2); }
table.tb tr.voided td { opacity: .5; text-decoration: line-through; }
table.tb .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.cell-actions { display: flex; gap: 5px; justify-content: flex-end; }
.mini-btn {
  height: 27px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px;
}
.mini-btn:hover { border-color: var(--brand); color: var(--brand-ink); }
.mini-btn.d { color: var(--red); }
.mini-btn.d:hover { border-color: var(--red); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 30px; opacity: .55; margin-bottom: 8px; }
.empty p { font-size: 13px; }
.empty .sub { font-size: 11.5px; margin-top: 3px; opacity: .8; }

.list { display: flex; flex-direction: column; gap: 1px; }
.row-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 6px;
  border-radius: 10px; transition: background .14s;
}
.row-item:hover { background: var(--card-2); }
.row-item + .row-item { border-top: 1px solid var(--line-2); }
.row-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  display: grid; place-items: center; font-size: 13px; font-weight: 750;
  background: var(--brand-soft); color: var(--brand-ink);
}
.row-icon.in { background: var(--green-soft); color: #0a8f66; }
.row-icon.out { background: var(--brand-soft); color: var(--brand-ink); }
.row-main { min-width: 0; flex: 1 1 auto; }
.row-main .t { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main .s { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tail { text-align: right; flex: 0 0 auto; }
.row-tail .v { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-tail .d { font-size: 11px; color: var(--muted); }

/* 图表 */
.chart-box { position: relative; width: 100%; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12.5px; color: var(--muted); pointer-events: none; text-align: center; padding: 0 20px;
}
.chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
svg.chart { width: 100%; display: block; overflow: visible; }
svg.chart .gl { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
svg.chart .lbl { font-size: 9.5px; fill: var(--muted); }
svg.chart .bar-in { fill: color-mix(in srgb, var(--green) 78%, transparent); }
svg.chart .bar-out { fill: color-mix(in srgb, var(--brand) 82%, transparent); }
svg.chart .line { fill: none; stroke: var(--amber); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .pt { fill: var(--card); stroke: var(--amber); stroke-width: 2; }

.catbar { display: flex; align-items: center; gap: 9px; padding: 7px 0; }
.catbar .nm { width: 62px; font-size: 12.5px; font-weight: 600; flex: 0 0 62px; }
.catbar .track { display: block; flex: 1 1 auto; height: 9px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.catbar .fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #7c5cff); transition: width .4s ease; }
.catbar .vl { font-size: 11.5px; color: var(--muted); width: 74px; text-align: right; font-variant-numeric: tabular-nums; }

/* 扫码区 */
.scan-hero {
  border: 1.5px dashed color-mix(in srgb, var(--brand) 36%, var(--line));
  border-radius: var(--radius); background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 5%, var(--card)), var(--card));
  padding: 16px;
}
.scan-hero > .flex > div:first-child { flex: 1 1 auto; min-width: 0; }
.scan-hero > .flex > .badge { flex: 0 0 auto; }
.scan-input-wrap { position: relative; }
.scan-input {
  height: 54px; font-size: 17px; font-weight: 650; letter-spacing: .6px;
  padding-right: 112px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border-radius: 13px; border: 1.5px solid color-mix(in srgb, var(--brand) 30%, var(--line));
}
.scan-input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.scan-actions { position: absolute; right: 6px; top: 6px; display: flex; gap: 5px; }
.scan-actions .icon-btn { width: 42px; height: 42px; border-radius: 10px; }

.result-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card-2); padding: 13px 14px; margin-top: 12px;
  animation: viewIn .2s ease;
}
.result-card.ok { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); background: color-mix(in srgb, var(--green) 6%, var(--card)); }
.result-card.warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); background: color-mix(in srgb, var(--amber) 7%, var(--card)); }
.result-top { display: flex; align-items: flex-start; gap: 10px; }
.result-title { font-size: 15px; font-weight: 700; }
.result-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.money-row { display: flex; gap: 18px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.money-row .m .k { font-size: 11px; color: var(--muted); }
.money-row .m .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--card-2); }
.qty-stepper button { width: 40px; height: 42px; border: 0; background: transparent; font-size: 19px; color: var(--ink-2); }
.qty-stepper button:hover { background: var(--brand-soft); color: var(--brand-ink); }
.qty-stepper input { width: 62px; height: 42px; border: 0; text-align: center; background: transparent; font-size: 16px; font-weight: 700; outline: none; font-variant-numeric: tabular-nums; }

/* 表格卡片 */
.item-cards { display: grid; gap: 10px; }
.item-card {
  border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; background: var(--card);
  display: flex; gap: 12px; align-items: flex-start;
}
.item-card .thumb {
  width: 42px; height: 42px; border-radius: 11px; flex: 0 0 42px;
  display: grid; place-items: center; font-weight: 750; font-size: 14px;
  background: var(--brand-soft); color: var(--brand-ink);
}
.item-card .body { flex: 1 1 auto; min-width: 0; }
.item-card .nm { font-size: 14px; font-weight: 650; }
.item-card .sb { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.item-card .price { font-size: 13px; margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }
.item-card .price b { font-variant-numeric: tabular-nums; }

/* 弹窗 */
.modal-root:empty { display: none; }
.modal-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(9, 16, 32, .5);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  border: 1px solid var(--line); animation: popIn .2s cubic-bezier(.2,.9,.3,1.2);
  overflow: hidden;
}
.modal.wide { width: min(880px, 100%); }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.modal-head h3 { font-size: 15.5px; font-weight: 700; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 4px 18px 18px; overflow: auto; }
.modal-foot { display: flex; gap: 9px; padding: 0 18px 18px; }
.modal-foot .btn { flex: 1 1 auto; }

/* 扫码摄像头 */
#scannerRegion { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 220px; }
#scannerRegion video { border-radius: 14px; }
.scan-frame { position: relative; }
.scan-frame::after {
  content: ""; position: absolute; inset: 22% 12%; border: 2px solid rgba(255,255,255,.85);
  border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.28); pointer-events: none;
}
.scan-laser {
  position: absolute; left: 12%; right: 12%; height: 2px; top: 30%;
  background: linear-gradient(90deg, transparent, #ff4d4f, transparent);
  animation: laser 2s ease-in-out infinite; pointer-events: none;
}
@keyframes laser { 0%,100% { top: 26%; } 50% { top: 66%; } }

/* Toast */
.toast-wrap { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); bottom: 26px; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: #101a2c; color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 600; box-shadow: 0 16px 40px -18px #000;
  display: flex; align-items: center; gap: 8px; animation: toastIn .22s ease;
  max-width: 100%;
}
.toast.ok { background: linear-gradient(140deg, #0d9668, #10b981); }
.toast.err { background: linear-gradient(140deg, #dc2626, #ef4444); }
.toast.warn { background: linear-gradient(140deg, #d97706, #f59e0b); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.toast.out { animation: toastOut .18s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 14px 0 2px; }
.pager .info { font-size: 12px; color: var(--muted); margin-right: 6px; }

/* 备份列表 */
.backup-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line-2); }
.backup-row:last-child { border-bottom: 0; }
.backup-row .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; flex: 0 0 34px; }
.backup-row .meta { flex: 1 1 auto; min-width: 0; }
.backup-row .meta .t { font-size: 13px; font-weight: 600; }
.backup-row .meta .s { font-size: 11.5px; color: var(--muted); }

/* 打印标签 */
.label-sheet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.label-item { border: 1px dashed #cbd5e1; border-radius: 6px; padding: 6px 8px; text-align: center; page-break-inside: avoid; }
.label-item .ln1 { font-size: 10px; color: #475569; }
.label-item .ln2 { font-size: 12px; font-weight: 700; margin: 1px 0; }
.label-item svg { max-width: 100%; height: 34px; }

/* 导出字段选择 */
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.check {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; font-weight: 500;
  background: var(--card-2); cursor: pointer; user-select: none;
}
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
.check.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

/* 栅格布局 */
.cols { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); align-items: start; }
.cols-2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.hide-sm { display: block; }
.show-sm { display: none; }
@media (max-width: 940px) {
  .cols, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none !important; }
  .show-sm { display: block !important; }
}
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; letter-spacing: .2px; }
a.mini-btn { text-decoration: none; color: inherit; }
.item-card.voided { opacity: .55; }
.row-item[data-go] { cursor: pointer; }
.tag-del:hover { opacity: 1 !important; color: var(--red) !important; }
html[data-theme="dark"] .kpi .value, html[data-theme="dark"] .num { color: inherit; }

/* 登录页 */
.auth-wrap {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px;
  background: var(--bg); background-image: var(--bg-grad); overflow: auto;
}
.auth-card {
  width: min(430px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px 26px 22px; box-shadow: var(--shadow-lg);
  animation: viewIn .3s ease;
}
.auth-logo { width: 100%; max-width: 232px; height: auto; display: block; margin: 0 auto 18px; border-radius: 12px; }
.auth-title { font-size: 21px; font-weight: 750; text-align: center; letter-spacing: .5px; }
.auth-sub { text-align: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 20px; }
.auth-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 10px; font-weight: 600; }
.auth-foot { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-tip { margin-top: 10px; text-align: center; font-size: 11.5px; color: var(--muted); opacity: .85; }
.link-btn {
  border: 0; background: transparent; color: var(--brand); font-weight: 700;
  font-size: 13px; padding: 0 2px; text-decoration: underline; text-underline-offset: 3px;
}

/* 侧栏用户 */
.side-user {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  border-radius: 12px; background: var(--card-2); border: 1px solid var(--line);
}
.side-user .avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
  display: grid; place-items: center; font-size: 13px; font-weight: 750;
  background: linear-gradient(140deg, var(--brand), #6f4bff); color: #fff;
}
.side-user .uinfo { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.25; }
.side-user .uinfo strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .uinfo span { font-size: 10.5px; color: var(--muted); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* 控制台 */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-box { border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; background: var(--card-2); }
.stat-box .k { font-size: 11.5px; color: var(--muted); }
.stat-box .v { font-size: 22px; font-weight: 750; margin-top: 3px; font-variant-numeric: tabular-nums; }

.role-badge { height: 20px; padding: 0 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; }
.role-badge.admin { background: var(--brand-soft); color: var(--brand-ink); }
.role-badge.staff { background: var(--line-2); color: var(--muted); }
.status-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; }
.status-dot i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-dot.active { color: var(--green); } .status-dot.active i { background: var(--green); }
.status-dot.pending { color: var(--amber); } .status-dot.pending i { background: var(--amber); }
.status-dot.disabled { color: var(--muted); } .status-dot.disabled i { background: var(--muted); }

/* 折叠区（已结账目） */
.acc { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--card); }
.acc + .acc { margin-top: 10px; }
.acc-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 13px; cursor: pointer;
  background: var(--card-2); user-select: none;
}
.acc-head:hover { background: var(--line-2); }
.acc-head .ttl { font-size: 13px; font-weight: 700; }
.acc-head .cnt { font-size: 11.5px; color: var(--muted); }
.acc-head .amt { margin-left: auto; font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; }
.acc-head .arrow { transition: transform .2s; color: var(--muted); }
.acc.open .acc-head .arrow { transform: rotate(180deg); }
.acc-body { display: none; padding: 4px 6px 8px; }
.acc.open .acc-body { display: block; }
.order-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 8px;
  border-bottom: 1px solid var(--line-2);
}
.order-row:last-child { border-bottom: 0; }
.order-row .chk { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; }
.order-row .oinfo { flex: 1 1 auto; min-width: 0; }
.order-row .oname { font-size: 13px; font-weight: 650; }
.order-row .osub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.order-row .oval { text-align: right; flex: 0 0 auto; }
.order-row .oval b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.order-row .oval span { display: block; font-size: 11px; color: var(--muted); }

/* 库存分类表 */
.stock-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
.stock-tabs::-webkit-scrollbar { height: 0; }
.stab {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 12.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; flex: 0 0 auto;
  transition: .16s;
}
.stab em {
  font-style: normal; font-size: 10.5px; background: var(--line-2); color: var(--muted);
  padding: 1px 6px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.stab:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.stab.active { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 8px 18px -12px var(--brand); }
.stab.active em { background: rgba(255, 255, 255, .25); color: #fff; }
.stab-x { margin-left: 1px; font-style: normal; opacity: .45; font-weight: 800; font-size: 13px; line-height: 1; }
.stab-x:hover { opacity: 1; color: var(--red); }
.stab.active .stab-x:hover { color: #fff; }
.stab-add { border-style: dashed; color: var(--brand); background: transparent; }
.tabs-label { font-size: 11.5px; color: var(--muted); font-weight: 650; align-self: center; flex: 0 0 auto; margin-right: 2px; }

/* 骨架 */
.skeleton { background: linear-gradient(90deg, var(--line-2) 25%, var(--line) 37%, var(--line-2) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; height: 14px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- 移动端 ---------------- */
@media (max-width: 940px) {
  .side { display: none; }
  .only-mobile { display: grid !important; }
  .topbar { padding: 10px 14px; }
  .topbar-logo { display: block; margin-right: -2px; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-title p { display: none; }
  .today-chip { padding: 5px 10px; font-size: 11px; }
  .t-full { display: none; }
  .t-short { display: inline; }
  .view { padding: 12px 14px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 22px; }
  .card { padding: 13px; border-radius: 14px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: blur(16px) saturate(160%);
    border-top: 1px solid var(--line);
  }
  .tabs button {
    border: 0; background: transparent; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    font-size: 10.5px; color: var(--muted); font-weight: 600; position: relative;
  }
  .tabs button svg { width: 21px; height: 21px; }
  .tabs button.active { color: var(--brand); }
  .tabs button.active svg { filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--brand) 45%, transparent)); }
  .tabs button.active::before {
    content: ""; position: absolute; top: 0; width: 22px; height: 3px;
    border-radius: 0 0 4px 4px; background: var(--brand);
  }
  .toast-wrap { bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; animation: sheetUp .24s cubic-bezier(.2,.9,.3,1); }
  @keyframes sheetUp { from { transform: translateY(30px); opacity: .6; } }
  .modal-foot { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  table.tb { min-width: 560px; }
  .row-item { padding: 10px 2px; }
  .input, .select, .textarea { font-size: 16px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .scan-input { height: 50px; }
  .scan-hero > .flex.between { flex-direction: column; align-items: flex-start; gap: 7px; }
  .scan-hero > .flex.between > .badge { align-self: flex-start; }
}

@media (max-width: 380px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 20px; }
  .scan-input { font-size: 15px; padding-right: 100px; }
}

@media (min-width: 941px) {
  .view { min-height: calc(100vh - 62px); }
}

/* 打印 */
@media print {
  .side, .tabs, .topbar, .toast-wrap, .modal-foot, .no-print { display: none !important; }
  body { background: #fff; }
  .modal-mask { position: static; background: #fff; padding: 0; }
  .modal { box-shadow: none; border: 0; width: 100%; max-height: none; }
  .label-sheet { grid-template-columns: repeat(2, 1fr); }
}

/* 云端更新提示条 */
.sync-bar {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(-12px);
  top: 16px; z-index: 150; display: none; align-items: center; gap: 12px;
  padding: 9px 10px 9px 16px; border-radius: 14px;
  background: linear-gradient(140deg, #101a2c, #1c2b46);
  color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .65);
  border: 1px solid rgba(255, 255, 255, .12);
  opacity: 0; transition: opacity .2s, transform .2s;
  max-width: 92vw;
}
.sync-bar.show { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }
.sync-bar .dotlive { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .25); flex: 0 0 7px; }
.sync-bar button {
  border: 0; border-radius: 9px; padding: 6px 12px; font-size: 12.5px; font-weight: 700;
  background: #2f6bff; color: #fff; cursor: pointer; white-space: nowrap;
}
.sync-bar button:hover { filter: brightness(1.1); }
