/* OpenRouter 网关管理台
   设计取向：中性灰打底 + 一个靛蓝强调色；层级靠留白、字号与字重，不靠装饰。
   明暗跟随系统；所有颜色、间距、圆角走变量。 */

:root {
  color-scheme: light;
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --line: #e1e4e8;
  --line-strong: #cdd2d9;
  --text: #15181e;
  --text-2: #565d6b;
  --text-3: #8a909d;
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-ink: #ffffff;
  --accent-soft: #e6effb;
  --good: #0b7a0b;
  --good-soft: #e3f4e3;
  --warn: #9a6400;
  --warn-soft: #fdf1d3;
  --bad: #c22f2f;
  --bad-soft: #fbe6e6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e7e9ed;
  --shadow: 0 12px 32px rgba(18, 24, 38, .14), 0 2px 6px rgba(18, 24, 38, .08);
  --r-card: 12px;
  --r-ctl: 8px;
  --sidebar: 228px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei",
          "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121417;
    --surface: #1c1f23;
    --surface-2: #22262b;
    --surface-3: #2a2f35;
    --line: #2d3238;
    --line-strong: #3d444c;
    --text: #eceef1;
    --text-2: #a8aeb9;
    --text-3: #79808c;
    --accent: #6da7ec;
    --accent-hover: #86b6ef;
    --accent-ink: #0b1a2d;
    --accent-soft: #1b2b40;
    --good: #4cc04c;
    --good-soft: #17301a;
    --warn: #f0b23a;
    --warn-soft: #33290f;
    --bad: #f07a7a;
    --bad-soft: #3a1c1c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2a2f35;
    --shadow: 0 14px 36px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, td.r, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
        stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 外壳 ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.shell.collapsed { --sidebar: 64px; }
.side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; gap: 4px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
              display: grid; place-items: center; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-ctl);
  color: var(--text-2); white-space: nowrap; min-height: 40px; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .badge { margin-left: auto; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff;
         font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.who { padding: 2px 10px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who b { color: var(--text); font-weight: 600; display: block; font-size: 13.5px; }
.collapsed .brand span, .collapsed .nav a span, .collapsed .who, .collapsed .side-foot .btn span { display: none; }
.collapsed .nav a { justify-content: center; padding: 9px 0; }
.collapsed .nav .badge { position: absolute; top: 3px; right: 6px; min-width: 16px; height: 16px; font-size: 10.5px; padding: 0 4px; }
.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; font-weight: 650; }
.top .sp { flex: 1; }
.top .stamp { font-size: 12.5px; color: var(--text-3); }
.page { padding: 22px 24px 48px; max-width: 1320px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.btn.menu-btn { display: none; }
.scrim { display: none; }

/* ---------- 基础控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--r-ctl); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after { border-color: var(--accent-ink); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lab { font-size: 13px; font-weight: 550; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.field .err { font-size: 12.5px; color: var(--bad); }
.input, .textarea, .select-btn {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 72px; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .select-btn:hover { border-color: var(--text-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.bad { border-color: var(--bad); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .unit { position: absolute; right: 11px; color: var(--text-3); font-size: 12.5px; pointer-events: none; }
.input-wrap .input { padding-right: 58px; }

.select { position: relative; min-width: 0; }
.select-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; text-align: left; }
.select-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn svg { color: var(--text-3); width: 15px; height: 15px; }
.select-pop {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 280px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px;
}
.select-opt { padding: 8px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.select-opt:hover, .select-opt.active { background: var(--surface-3); }
.select-opt[aria-selected="true"] { color: var(--accent); font-weight: 600; }

.switch { position: relative; width: 38px; height: 22px; flex: none; border: 0; padding: 0; border-radius: 11px;
  background: var(--line-strong); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch[disabled] { opacity: .5; cursor: not-allowed; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; }
.switch-row > div { flex: 1; min-width: 0; }
.switch-row .t { font-weight: 550; font-size: 13.5px; }
.switch-row .d { font-size: 12.5px; color: var(--text-3); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-ctl); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2);
  white-space: nowrap; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px;
  font-weight: 550; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- 卡片与栅格 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px 20px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; font-weight: 650; }
.card-h .sp { flex: 1; }
.card-h .sub { font-size: 12.5px; color: var(--text-3); }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row .sp { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.stat .k { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 4px; letter-spacing: 0; }
.stat .s { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 16px; font-size: 13px; }
.kv dt { color: var(--text-2); white-space: nowrap; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* 覆盖条：实际成本落在计费额之内才算"悲观"成立 */
.cover { display: block; position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.cover i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--series-1); min-width: 2px; }
.cover.over i { background: var(--bad); }
.cover.sm { height: 6px; width: 84px; display: inline-block; vertical-align: middle; }
.cover-legend { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); margin-top: 6px; gap: 12px; flex-wrap: wrap; }

.todo { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r-card); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.todo:hover { border-color: var(--line-strong); background: var(--surface-2); }
.todo .n { font-size: 26px; font-weight: 650; min-width: 34px; font-variant-numeric: tabular-nums; }
.todo.hot { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); background: var(--bad-soft); }
.todo.hot .n { color: var(--bad); }
.todo.warm { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--warn-soft); }
.todo.warm .n { color: var(--warn); }
.todo .t { font-weight: 600; }
.todo .d { font-size: 12.5px; color: var(--text-2); }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; background: var(--warn-soft);
  color: var(--warn); font-size: 13.5px; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner ul { margin: 0; padding-left: 18px; }
.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 9px 12px; line-height: 1.6; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-card) var(--r-card); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-weight: 550; font-size: 12.5px; text-align: left;
  padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr.sel { background: var(--surface-2); }
th.r, td.r { text-align: right; }
td.nowrap { white-space: nowrap; }
td .sub { display: block; font-size: 12px; color: var(--text-3); }
.cell-clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; padding: 0; vertical-align: middle; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"]::after { content: ""; width: 9px; height: 5px; border: solid var(--accent-ink); border-width: 0 0 2px 2px;
  transform: rotate(-45deg) translate(1px, -1px); }
.empty { padding: 44px 20px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.more { display: flex; justify-content: center; padding: 14px; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--text-2); font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .badge { background: var(--surface-3); color: var(--text-2); }
.tabs button[aria-selected="true"] .badge.on { background: var(--bad); color: #fff; }

.skel { border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; min-height: 14px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 图表 ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .thresh { stroke: var(--bad); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .end-label { font-size: 11.5px; fill: var(--text-2); }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; white-space: nowrap; min-width: 120px; }
.tip b { display: block; margin-bottom: 4px; font-weight: 600; }
.tip div { display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.tip div span:last-child { margin-left: auto; padding-left: 14px; color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; display: inline-block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.mini h3 { font-size: 13.5px; font-weight: 600; }
.mini .now { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- 浮层 ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(10, 14, 22, .45); display: flex; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { margin: auto; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: pop .16s; }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.dialog h2 { font-size: 16.5px; font-weight: 650; }
.dialog .acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.drawer { margin-left: auto; width: min(680px, 100vw); height: 100dvh; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(28px); opacity: .4; } }
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font-size: 16px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-b { flex: 1; overflow: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 20px; }
.drawer-f { display: flex; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-f .sp { flex: 1; }
.sec h3 { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
pre.json { margin: 0; padding: 12px; background: var(--surface-2); border-radius: 8px; font: 12px/1.55 var(--mono); overflow: auto;
  max-height: 320px; white-space: pre-wrap; overflow-wrap: anywhere; }
#toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none; }
.toast { pointer-events: auto; max-width: min(420px, calc(100vw - 36px)); padding: 10px 14px; border-radius: 10px; background: var(--text);
  color: var(--bg); box-shadow: var(--shadow); font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start; animation: pop .16s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transition: opacity .2s; }

/* ---------- 登录 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-card .brand { padding: 0; font-size: 17px; }
.login-card h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.code { height: 52px; font: 600 24px/1 var(--mono); letter-spacing: .42em; text-align: center; padding-left: .42em; }
.login-card .btn { height: 44px; font-size: 15px; }

/* ---------- 定价编辑 ---------- */
.tier { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.tier-h { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); --sidebar: 248px; }
  .side { position: fixed; left: 0; top: 0; width: var(--sidebar); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 25; }
  .collapsed .brand span, .collapsed .nav a span, .collapsed .who { display: initial; }
  .collapsed .nav a { justify-content: flex-start; padding: 9px 10px; }
  .btn.menu-btn { display: inline-flex; }
  .btn.fold-btn { display: none; }
  .top { padding: 0 14px; }
  .page { padding: 16px 14px 40px; gap: 14px; }
  .nav a { min-height: 44px; }
}
@media (max-width: 720px) {
  .g4, .g3, .g2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .btn { height: 40px; }
  .btn.sm { height: 34px; }
  .input, .select-btn { height: 40px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .top .stamp { display: none; }
  /* 表格转卡片：每行一张，单元格自带字段名 */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--text-2); font-size: 12.5px; text-align: left; flex: none; }
  table.cards td:first-child, table.cards td:last-child { padding-left: 0; padding-right: 0; }
  table.cards td.head { font-weight: 600; font-size: 14.5px; text-align: left; justify-content: flex-start; padding-bottom: 6px; }
  table.cards td.head::before, table.cards td.bare::before { display: none; }
  table.cards td .cellc { min-width: 0; }
  table.cards td.head .cellc { text-align: left; }
  table.cards .cell-clip { max-width: 60vw; }
  .dialog { padding: 18px; }
  .dialog .acts .btn { flex: 1; }
  #toasts { left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); align-items: stretch; }
  .stat .v { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
