/* ==========================================================================
   微信小店库存管理 — 设计系统
   主色：天蓝 (sky)｜功能色：青绿(入库) / 琥珀(预警) / 玫红(缺货·驳回) / 紫(待办)
   ========================================================================== */

:root {
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  --sky-800: #075985;
  --sky-900: #0c4a6e;

  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --rose: #f43f5e;
  --rose-soft: #ffe4e6;
  --violet: #8b5cf6;
  --violet-soft: #ede9fe;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5edf5;
  --line-2: #cfe3f2;
  --bg: #f4fafe;
  --card: #ffffff;

  --grad: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 55%, #0284c7 100%);
  --grad-soft: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 24px rgba(2, 132, 199, 0.08);
  --shadow-lg: 0 22px 48px rgba(2, 132, 199, 0.18);

  --sidebar-w: 226px;
  --topbar-h: 62px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }

/* 装到安卓手机桌面后（独立窗口、无地址栏）用整屏，避开刘海/挖孔与底部手势条 */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
/* 独立窗口里不要因为下拉手势把页面刷掉，更像原生 App */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: contain; }
}

/* 始终为滚动条预留槽位：打开/关闭弹窗时页面宽度不会左右跳动 */
html { scrollbar-gutter: stable; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }
a { color: var(--sky-600); text-decoration: none; }
a:hover { color: var(--sky-700); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd9e6; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #a9c3d8; background-clip: content-box; }

/* --------------------------------- 图标 --------------------------------- */
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  display: inline-block;
  vertical-align: -3px;
}
.icon.sm { width: 15px; height: 15px; stroke-width: 1.9; }
.icon.lg { width: 22px; height: 22px; }
.icon.xl { width: 26px; height: 26px; }

/* --------------------------------- 布局 --------------------------------- */
#app { min-height: 100%; }
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 8px 18px rgba(2, 132, 199, 0.32);
  flex: none;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--muted-2); letter-spacing: 0.6px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav-group-label { font-size: 11px; color: var(--muted-2); padding: 14px 12px 6px; letter-spacing: 0.8px; font-weight: 600; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
  user-select: none;
}
.nav-item:hover { background: var(--sky-50); color: var(--sky-700); }
.nav-item.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px rgba(2, 132, 199, 0.26); }
.nav-item.active .icon { stroke-width: 2; }
.nav-item .count {
  margin-left: auto;
  background: var(--sky-100);
  color: var(--sky-700);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .count { background: rgba(255, 255, 255, 0.24); color: #fff; }
.nav-item .count.alert { background: var(--rose-soft); color: #be123c; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--grad-soft);
  color: var(--sky-700);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex: none;
  border: 1px solid var(--sky-200);
}
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }

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

.topbar {
  min-height: calc(var(--topbar-h) + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--safe-top) calc(22px + var(--safe-right)) 0 calc(22px + var(--safe-left));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: 0.2px; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.page-head { min-width: 0; }
.topbar-spacer { flex: 1; }
.content { padding: 22px calc(22px + var(--safe-right)) calc(22px + var(--safe-bottom)) calc(22px + var(--safe-left)); max-width: 1560px; width: 100%; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 11px 4px 9px;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--muted-2); flex: none; }
.dot.on { background: var(--emerald); animation: pulse 2s infinite; }
.dot.off { background: var(--muted-2); }
.dot.err { background: var(--rose); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --------------------------------- 卡片 --------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 10px 12px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); opacity: 0.9; }
.stat.tone-teal::after { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.stat.tone-amber::after { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat.tone-rose::after { background: linear-gradient(135deg, #fb7185, #e11d48); }
.stat.tone-violet::after { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 720; letter-spacing: -0.6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat-foot { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat-icon {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--sky-50);
  color: var(--sky-600);
}
.stat.tone-teal .stat-icon { background: var(--teal-soft); color: var(--teal); }
.stat.tone-amber .stat-icon { background: var(--amber-soft); color: #b45309; }
.stat.tone-rose .stat-icon { background: var(--rose-soft); color: #be123c; }
.stat.tone-violet .stat-icon { background: var(--violet-soft); color: #6d28d9; }

.delta { font-weight: 650; font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--emerald); }
.delta.down { color: var(--rose); }
.delta.flat { color: var(--muted); }

/* --------------------------------- 按钮 --------------------------------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.16s var(--ease);
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover { border-color: var(--sky-300); color: var(--sky-700); background: var(--sky-50); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(2, 132, 199, 0.28); }
.btn.primary:hover { filter: brightness(1.05); color: #fff; box-shadow: 0 10px 22px rgba(2, 132, 199, 0.34); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sky-50); color: var(--sky-700); }
.btn.danger { color: #be123c; border-color: #fecdd3; background: #fff5f6; }
.btn.danger:hover { background: var(--rose-soft); border-color: #fda4af; color: #9f1239; }
.btn.success { color: #047857; border-color: #a7f3d0; background: #f0fdf9; }
.btn.success:hover { background: var(--emerald-soft); border-color: #6ee7b7; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 9px; gap: 5px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 8px; }
.btn.icon-only { padding: 7px; }
.btn.block { width: 100%; }
.btn.lg { padding: 11px 18px; font-size: 14.5px; border-radius: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }

/* --------------------------------- 表单 --------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field .hint { font-size: 11.5px; color: var(--muted-2); }

.input, .select, .textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 11px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  outline: none;
}
.textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--sky-300); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--sky-400); box-shadow: 0 0 0 3.5px rgba(56, 189, 248, 0.16); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input.sm, .select.sm { padding: 6px 9px; font-size: 13px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 30px;
}

.search-box { position: relative; display: inline-flex; align-items: center; min-width: 190px; }
.search-box .icon { position: absolute; left: 10px; color: var(--muted-2); pointer-events: none; }
.search-box .input { padding-left: 33px; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { display: none; }
.switch .track { width: 38px; height: 21px; background: #cbd5e1; border-radius: 99px; position: relative; transition: background 0.18s var(--ease); flex: none; }
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  background: #fff;
  border-radius: 99px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s var(--ease);
}
.switch input:checked + .track { background: var(--sky-500); }
.switch input:checked + .track::after { transform: translateX(17px); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--sky-500); cursor: pointer; }

.seg { display: inline-flex; background: var(--sky-50); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.seg button:hover { color: var(--sky-700); background: #fff; }
.seg button.active { background: #fff; color: var(--sky-700); box-shadow: var(--shadow-xs); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 4px; overflow-x: auto; }
.tabs button {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 13px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button.active { color: var(--sky-700); border-bottom-color: var(--sky-500); }

/* --------------------------------- 表格 --------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.3px; }
table.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 12.2px;
  color: var(--muted);
  background: #f7fbfe;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 10px 14px; border-bottom: 1px solid #f1f6fa; vertical-align: middle; }
table.tbl tbody tr:hover td { background: #fafdff; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.center, table.tbl th.center { text-align: center; }
table.tbl .strong { font-weight: 600; }
table.tbl .muted { color: var(--muted); font-size: 12.5px; }
table.tbl tfoot td { border-top: 1px solid var(--line-2); background: #f7fbfe; font-weight: 650; padding: 10px 14px; }

.num-big { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.num-big.low { color: #dc2626; }
.num-big.zero { color: #be123c; }
.num-big.ok { color: var(--sky-700); }
.alert-flag { font-size: 10.8px; font-weight: 600; color: #dc2626; margin-top: 1px; }

/* --------------------------------- 徽章 --------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.8px;
  font-weight: 620;
  padding: 2.5px 9px;
  border-radius: 99px;
  background: var(--sky-50);
  color: var(--sky-700);
  border: 1px solid var(--sky-100);
  white-space: nowrap;
}
.badge.green { background: var(--emerald-soft); color: #047857; border-color: #a7f3d0; }
.badge.teal { background: var(--teal-soft); color: #0f766e; border-color: #99f6e4; }
.badge.amber { background: var(--amber-soft); color: #b45309; border-color: #fde68a; }
.badge.rose { background: var(--rose-soft); color: #be123c; border-color: #fecdd3; }
.badge.violet { background: var(--violet-soft); color: #6d28d9; border-color: #ddd6fe; }
.badge.gray { background: #f1f5f9; color: var(--muted); border-color: #e2e8f0; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: 0.85; }

/* ------------------------------ 空状态 / 提示 --------------------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .icn { width: 54px; height: 54px; border-radius: 16px; background: var(--grad-soft); color: var(--sky-500); display: grid; place-items: center; margin: 0 auto 12px; }
.empty h4 { margin: 0 0 4px; font-size: 14.5px; color: var(--ink-2); }
.empty p { margin: 0; font-size: 12.8px; }

.alert-box { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius); font-size: 13px; align-items: flex-start; background: var(--sky-50); border: 1px solid var(--sky-100); color: var(--sky-800); }
.alert-box.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-box.err { background: #fff5f6; border-color: #fecdd3; color: #9f1239; }
.alert-box.ok { background: #f0fdf9; border-color: #a7f3d0; color: #065f46; }

.skeleton { background: linear-gradient(90deg, #eef5fa 25%, #e2eef8 37%, #eef5fa 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; border-radius: 99px; animation: spin 0.7s linear infinite; flex: none; }
.spinner.dark { border-color: rgba(2, 132, 199, 0.22); border-top-color: var(--sky-600); }
@keyframes spin { to { transform: rotate(360deg); } }

.bar { height: 7px; border-radius: 99px; background: #eaf3fa; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grad); transition: width 0.4s var(--ease); }
.bar > i.teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.bar > i.amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.bar > i.rose { background: linear-gradient(135deg, #fb7185, #e11d48); }

/* --------------------------------- 模态框 ------------------------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px 4vh;
  overflow-y: auto;
  animation: fade 0.16s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; animation: pop 0.2s var(--ease); overflow: hidden; }
.modal.wide { max-width: 820px; }
.modal.xwide { max-width: 1080px; }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; flex: 1; }
.modal-head .x { cursor: pointer; color: var(--muted); padding: 4px; border-radius: 8px; display: grid; place-items: center; }
.modal-head .x:hover { background: #f1f5f9; color: var(--ink); }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; background: #fafcfe; }

/* --------------------------------- Toast -------------------------------- */
/* 提示框容器：默认（手机）是屏幕底部浮层；桌面端会被挪进顶栏空档，见 .docked */
.toast-root {
  position: fixed;
  top: auto;
  bottom: 10px;
  left: 10px;
  right: 10px;
  transform: none;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: stretch;
  pointer-events: none;
  max-width: min(460px, calc(100vw - 32px));
}

/* 顶栏空档：提示框作为普通元素排在这一行里，不会盖住任何按钮或内容 */
.topbar-toast-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 8px;
}
.toast-root.docked {
  position: static;
  transform: none;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  width: 100%;
  max-width: 620px;
  align-items: center;
  gap: 6px;
}
.toast-root.docked .toast {
  max-width: 100%;
  min-width: 0;
  padding: 7px 12px;
  box-shadow: var(--shadow-sm);
}
.toast-root.docked .toast .t-title,
.toast-root.docked .toast .t-msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast {
  /* 提示框只做展示：不拦截点击，即使浮在某个按钮上，点下去仍然作用到下面的按钮 */
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--sky-500);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 11px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.2px;
  animation: slidein 0.24s var(--ease);
  min-width: 240px;
}
@keyframes slidein { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast.out { animation: slideout 0.2s var(--ease) forwards; }
@keyframes slideout { to { opacity: 0; transform: translateY(-10px); } }
.toast.ok { border-left-color: var(--emerald); }
.toast.err { border-left-color: var(--rose); }
.toast.warn { border-left-color: var(--amber); }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 650; margin-bottom: 1px; }
.toast .t-msg { color: var(--muted); font-size: 12.6px; word-break: break-word; }

/* --------------------------------- 登录页 ------------------------------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.08fr 0.92fr; background: #fff; }
.login-hero {
  background: var(--grad);
  color: #fff;
  padding: 56px 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.13); }
.login-hero::before { width: 460px; height: 460px; right: -150px; top: -140px; }
.login-hero::after { width: 320px; height: 320px; left: -110px; bottom: -120px; background: rgba(255, 255, 255, 0.1); }
.login-hero .lh-top { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; }
.login-hero .lh-mark { width: 44px; height: 44px; border-radius: 13px; background: rgba(255, 255, 255, 0.2); display: grid; place-items: center; }
.login-hero h2 { font-size: 32px; line-height: 1.25; margin: 0 0 14px; letter-spacing: -0.5px; position: relative; z-index: 1; }
.login-hero p.lead { position: relative; z-index: 1; opacity: 0.94; font-size: 14.5px; max-width: 420px; line-height: 1.75; margin: 0; }
.login-feats { position: relative; z-index: 1; display: grid; gap: 12px; margin-top: 30px; }
.login-feat { display: flex; gap: 11px; align-items: flex-start; font-size: 13.6px; opacity: 0.96; }
.login-feat .fi { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, 0.18); display: grid; place-items: center; flex: none; }
.login-hero .lh-foot { position: relative; z-index: 1; font-size: 12.4px; opacity: 0.85; }
.login-panel { display: grid; place-items: center; padding: 40px 28px; background: linear-gradient(160deg, #fff 0%, #f7fcff 100%); }
.login-box { width: 100%; max-width: 372px; }
.login-box h3 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.3px; }
.login-box .tip { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.login-form { display: grid; gap: 14px; }
.login-form .input { padding: 10px 12px; font-size: 14px; }
.login-note { margin-top: 20px; font-size: 12.4px; color: var(--muted); text-align: center; line-height: 1.7; }

/* --------------------------------- 其他 --------------------------------- */
.kbd { font-family: var(--mono); font-size: 11.5px; background: #f1f5f9; border: 1px solid #e2e8f0; border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: 12.2px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.wrap { flex-wrap: wrap; }
.flex.between { justify-content: space-between; }
.flex.end { justify-content: flex-end; }
.flex.col { flex-direction: column; align-items: stretch; }
.flex.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-note { font-size: 12.4px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 9px; justify-content: flex-end; padding: 12px 16px; }
.pager .info { font-size: 12.4px; color: var(--muted); margin-right: auto; }

.list-flush { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 11px; padding: 10px 18px; border-bottom: 1px solid #f1f6fa; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #fafdff; }
.avatar-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--sky-50); color: var(--sky-600); flex: none; }
.avatar-ico.tone-in { background: var(--teal-soft); color: var(--teal); }
.avatar-ico.tone-out { background: var(--rose-soft); color: #be123c; }
.avatar-ico.tone-move { background: var(--violet-soft); color: #6d28d9; }

.mini-chart { display: flex; align-items: flex-end; gap: 5px; height: 88px; }
.mini-chart .col { flex: 1; background: var(--grad); border-radius: 6px 6px 3px 3px; min-height: 3px; position: relative; transition: filter 0.15s; }
.mini-chart .col.zero { background: #e8f3fb; }
.mini-chart .col:hover { filter: brightness(1.08); }
.mini-chart .col:hover::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 7px;
  white-space: nowrap;
  z-index: 5;
}

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

.matrix-table th, .matrix-table td { text-align: center; }
.matrix-table th.sticky-col, .matrix-table td.sticky-col { text-align: left; position: sticky; left: 0; background: #fff; z-index: 2; box-shadow: 1px 0 0 var(--line); }
.matrix-table th.sticky-col { background: #f7fbfe; z-index: 3; }
.matrix-input { width: 76px; text-align: center; padding: 5px 6px; font-variant-numeric: tabular-nums; border: 1px solid var(--line-2); border-radius: 8px; font-family: inherit; font-size: 13px; }
.matrix-input:focus { border-color: var(--sky-400); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16); outline: none; }
.matrix-input.changed { border-color: var(--sky-400); background: var(--sky-50); font-weight: 650; }
.stock-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.stock-cell.low { color: #dc2626; }
.stock-cell.zero { color: #be123c; }

/* ---------------------------- 商品预览图 ------------------------------ */
.thumb {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 9px;
  overflow: hidden;
  background: var(--grad-soft);
  color: var(--sky-700);
  border: 1px solid var(--line-2);
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}
.thumb .thumb-ph { display: block; }
.thumb .thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  background: #fff;
  transition: opacity 0.18s var(--ease);
}
.thumb.has-img .thumb-img { opacity: 1; }
.thumb.has-img .thumb-ph { visibility: hidden; }
.thumb.editable { cursor: pointer; }
.thumb.editable:hover { border-color: var(--sky-400); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18); }
.thumb.editable:hover::after {
  content: '换图';
  position: absolute;
  inset: auto 0 0 0;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  background: rgba(2, 132, 199, 0.84);
  color: #fff;
  padding: 1px 0;
  letter-spacing: 0.5px;
}
.thumb.uploading { opacity: 0.55; }
.thumb-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.thumb-row-main { min-width: 0; }

.mobile-only { display: none; }

/* ------------------------- 库存总表（手机优先） ------------------------- */
.board-cards { display: grid; gap: 10px; padding: 10px; }
.board-card { border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; background: #fff; }
.board-card.low { border-color: #fecdd3; background: #fff5f6; }
.board-head { display: flex; align-items: center; gap: 8px; }
.board-title { flex: 1; min-width: 0; font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-total { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--sky-700); white-space: nowrap; }
.board-shops { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.board-shop {
  flex: 1 1 96px;
  min-width: 96px;
  border: 1px solid var(--line-2);
  background: #f7fbfe;
  border-radius: 11px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: pointer;
  font-family: inherit;
}
.board-shop .bs-name { font-size: 11.6px; color: var(--muted); }
.board-shop .bs-num { font-size: 19px; font-weight: 750; color: var(--sky-700); font-variant-numeric: tabular-nums; line-height: 1.15; }
.board-shop .bs-num.zero { color: #be123c; }
.board-shop .bs-unit { font-size: 10.5px; color: var(--muted-2); }
.board-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
@media (max-width: 900px) {
  .board-card { padding: 10px; }
  .board-shop { flex: 1 1 46%; }
}

/* 手机底部的「安装到手机桌面」漂浮长条（唯一安装入口；装好后不再出现） */
.install-bar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 260;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 12px 26px rgba(2, 132, 199, 0.42);
  animation: pop 0.24s var(--ease);
}
.install-bar .icon { stroke-width: 2; flex: none; }
.install-bar-txt { flex: 1; min-width: 0; }
.install-bar-t { font-size: 14px; font-weight: 650; }
.install-bar-s { font-size: 11.6px; opacity: 0.9; }
.install-bar-x {
  position: absolute;
  right: -4px;
  top: -8px;
  width: 21px;
  height: 21px;
  border-radius: 99px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  line-height: 21px;
  text-align: center;
  opacity: 0.85;
  cursor: pointer;
}
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 35; }

/* 提醒开关的下拉菜单 */
.popover-wrap { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 250px;
  animation: pop 0.16s var(--ease);
}
.pop-row { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.pop-row:hover { background: var(--sky-50); }
.pop-row.active { background: var(--sky-50); }
.pop-row .pop-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.pop-row .pop-desc { font-size: 11.8px; color: var(--muted); line-height: 1.5; }
.pop-sep { height: 1px; background: var(--line); margin: 5px 6px; }

@media (max-width: 1080px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* 手机端：商品/规格长名字压窄，一屏看更多（电脑端不受影响） */
  .matrix-table .thumb-row-main { max-width: 44vw; }
  .matrix-table .thumb-row-main .strong,
  .matrix-table .thumb-row-main .muted {
    display: block;
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .matrix-table th, .matrix-table td { padding: 6px 6px; font-size: 12.2px; }
  .matrix-table .btn { padding: 3px 6px; font-size: 11.4px; }
  .matrix-table th:not(.sticky-col) { max-width: 62px; }
  /* 按店铺看：商品列也压窄 */
  #content .tbl td .thumb-row-main { max-width: 40vw; }
  #content .tbl td .thumb-row-main .ellipsis { max-width: 40vw; }
  /* 概览「低库存预警」列表：手机上一屏看更多（店铺竖排、商品/规格截断） */
  .low-shop {
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 0;
    padding: 3px 5px;
    max-width: 22px !important;
    line-height: 1.05;
    white-space: nowrap;
  }
  .low-title { max-width: 120px; }
  .low-sku { max-width: 74px; }
  .tbl { font-size: 12.4px; }
  .tbl th, .tbl td { padding: 6px 7px; }
  .thumb-row { gap: 6px; }
  /* 手机上顶部统计板块改成两列，一屏能看全（电脑端不变） */
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; transform: translateX(-102%); transition: transform 0.24s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 34px 26px; min-height: auto; }
  .login-hero h2 { font-size: 25px; }
  .login-feats { display: none; }
  .content { padding: 12px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-spacer { display: none; }
  .page-head { flex: 1 1 auto; min-width: 0; }
  .topbar h1 { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .sub { display: none; }
  .topbar .live span:not(.dot) { display: none; }
  .topbar > .badge { display: none; }
  /* 顶栏按钮只留图标，避免在窄屏挤爆 */
  .topbar .btn-label { display: none; }
  #notify-btn { padding: 7px 8px; }
  /* 手机上仍贴在底部：屏幕窄，放上方会横向压住卡片右侧的按钮（安卓/iOS 也习惯底部提示） */
  .toast-root {
    top: auto;
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    align-items: stretch;
  }
  .toast { min-width: 0; }
  .toast .t-msg { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* 卡片与表格在窄屏更紧凑 */
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  table.tbl { font-size: 12.8px; }
  table.tbl th, table.tbl td { padding: 8px 10px; }
  .list-row { padding: 9px 12px; }
  .stat-value { font-size: 23px; }
  .stat { padding: 13px 14px; }
  /* 筛选区在手机上占满整行，输入框不再固定宽度 */
  .search-box { width: 100%; min-width: 0; }
  .filter-bar { gap: 8px; }
  .filter-bar .toolbar-note { font-size: 12px; }
  /* 弹窗：更贴合手机屏幕，底部按钮更好点 */
  .modal-mask { padding: 10px; }
  .modal { border-radius: 14px; }
  .modal-body { max-height: 72vh; padding: 14px 16px; }
  .modal-head { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 45%; }
  .popover { min-width: 0; width: min(300px, calc(100vw - 24px)); }
}
@media (max-width: 420px) {
  /* 小屏手机也保持两列，把卡片压紧一点 */
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat { padding: 11px 12px; }
  .stat-top { font-size: 11.6px; }
  .stat-value { font-size: 19px; margin-top: 4px; }
  .stat-value small { font-size: 11.5px; }
  .stat-foot { font-size: 11.2px; margin-top: 4px; }
  .stat-icon { width: 26px; height: 26px; right: 8px; top: 8px; border-radius: 8px; }
  .stat-icon .icon { width: 15px; height: 15px; }
  .topbar h1 { font-size: 14px; }
}
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
}
