/* MCP 路由层管理台
   中性灰 + 一个主色 + 状态色；颜色、圆角、间距、阴影、动效时长全部变量化；深色跟随系统。 */

:root {
  color-scheme: light dark;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --raised: #ffffff;
  --sunken: #f1f1f3;
  --border: #e4e4e8;
  --border-strong: #cfcfd6;
  --text: #1b1b1f;
  --text-2: #5c5c66;
  --text-3: #8b8b96;

  --primary: #5746d6;
  --primary-hover: #4a3ac2;
  --primary-press: #3f30ab;
  --primary-soft: #efedfc;
  --on-primary: #ffffff;

  --ok: #15803d;        --ok-soft: #e6f4ea;
  --warn: #a16207;      --warn-soft: #fbf1d7;
  --danger: #c0392b;    --danger-soft: #fbe9e7;
  --danger-hover: #a93226;
  --info: #1d6fb8;      --info-soft: #e5f0fa;
  --idle: #6b6b76;      --idle-soft: #ededf0;

  --r-s: 6px;
  --r-m: 8px;
  --r-l: 12px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;  --s-5: 24px;  --s-6: 32px;

  --shadow: 0 8px 28px rgba(22, 22, 40, .14), 0 1px 3px rgba(22, 22, 40, .08);
  --fast: .12s;
  --base: .18s;
  --slow: .26s;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --sidebar: 216px;
  --rail: 56px;
  --topbar: 52px;

  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101013;
    --surface: #17171b;
    --raised: #1f1f25;
    --sunken: #131316;
    --border: #2a2a31;
    --border-strong: #3a3a44;
    --text: #e9e9ee;
    --text-2: #a6a6b2;
    --text-3: #777784;

    --primary: #9a8cf5;
    --primary-hover: #aa9ef8;
    --primary-press: #8a7bee;
    --primary-soft: #262245;
    --on-primary: #14121f;

    --ok: #5cc98a;        --ok-soft: #16301f;
    --warn: #e0b356;      --warn-soft: #33290f;
    --danger: #f0857a;    --danger-soft: #3a1c19;
    --danger-hover: #f49a90;
    --info: #6eb4ee;      --info-soft: #14283a;
    --idle: #9a9aa6;      --idle-soft: #26262c;

    --shadow: 0 0 0 1px var(--border-strong), 0 12px 32px rgba(0, 0, 0, .5);
  }
}

/* —— reset —— */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--primary); text-decoration: none; }
table { border-collapse: collapse; border-spacing: 0; width: 100%; }
th { font-weight: 500; text-align: left; }
svg { display: block; flex: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-s); }
::selection { background: var(--primary-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 100px var(--surface) inset; -webkit-text-fill-color: var(--text); }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.noscript { padding: var(--s-5); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* —— 外壳 —— */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: var(--s-3) var(--s-2) calc(var(--s-3) + env(safe-area-inset-bottom)); }
.brand { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-4); font-weight: 600; min-width: 0; }
.brand-mark { width: 24px; height: 24px; border-radius: var(--r-s); background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--s-3); height: 34px; padding: 0 var(--s-2); border-radius: var(--r-s);
  color: var(--text-2); min-width: 0; transition: background var(--fast), color var(--fast); }
.nav a span.label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a[aria-current=page] { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav a:active { transform: scale(.98); }
.nav .count { font-size: 12px; min-width: 18px; padding: 0 5px; border-radius: 9px; text-align: center;
  background: var(--danger-soft); color: var(--danger); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding: var(--s-3) var(--s-2) 0; font-size: 12px; color: var(--text-3); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.topbar { height: var(--topbar); flex: none; display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-5); padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; overflow-y: auto; padding: var(--s-5) var(--s-5) calc(var(--s-6) + env(safe-area-inset-bottom)); }
.page { display: flex; flex-direction: column; gap: var(--s-5); }
.page.loading-soft { opacity: .55; transition: opacity var(--base); }
.btn.menu-btn { display: none; }
.scrim { display: none; }

/* —— 按钮 —— */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--r-s); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap; position: relative;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), color var(--fast); }
.btn:active:not(:disabled) { transform: scale(.97); background: var(--sunken); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:active:not(:disabled) { background: var(--primary-press); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:active:not(:disabled) { background: var(--danger-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.text { border: 0; background: none; height: auto; padding: 2px 4px; color: var(--primary); font-weight: 500; }
.btn.text.dangerous { color: var(--danger); }
.btn.icon { width: 32px; padding: 0; }
.btn.small { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .btn.danger.busy::after { border-color: rgba(255, 255, 255, .85); border-top-color: transparent; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--sunken); }
  .btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
  .btn.danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
  .btn.text:hover:not(:disabled) { background: none; text-decoration: underline; }
  .nav a:hover { background: var(--sunken); color: var(--text); }
  .nav a[aria-current=page]:hover { background: var(--primary-soft); color: var(--primary); }
  tbody tr.clickable:hover { background: var(--sunken); }
  .option:hover { background: var(--sunken); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* —— 表单 —— */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--text-2); }
.field .error { font-size: 12.5px; color: var(--danger); }
.input, .textarea, .select-btn { width: 100%; height: 34px; padding: 0 10px; border-radius: var(--r-s);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color var(--fast), box-shadow var(--fast); }
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus, .select-btn:focus-visible, .select-btn[aria-expanded=true] {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.input:disabled { background: var(--sunken); color: var(--text-3); }
.input-row { display: flex; align-items: center; gap: var(--s-2); }
.input-row .unit { color: var(--text-2); white-space: nowrap; }
.input.narrow { width: 120px; }
.form { display: flex; flex-direction: column; gap: var(--s-4); }

.select { position: relative; min-width: 0; }
.select-btn { display: flex; align-items: center; gap: 6px; text-align: left; cursor: pointer; }
.select-btn .value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.select-btn .placeholder { color: var(--text-3); }
.select-btn svg { color: var(--text-3); transition: transform var(--fast); }
.select-btn[aria-expanded=true] svg { transform: rotate(180deg); }
.popover { position: fixed; z-index: 60; min-width: 160px; max-height: 300px; overflow-y: auto; padding: 4px;
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-m); box-shadow: var(--shadow);
  animation: pop var(--fast) var(--ease); transform-origin: top; }
.option { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 32px; padding: 4px 8px;
  border-radius: var(--r-s); text-align: left; cursor: pointer; }
.option .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option[aria-selected=true] { color: var(--primary); font-weight: 500; }
.option.active { background: var(--sunken); }
.option.danger { color: var(--danger); }
.option svg.tick { visibility: hidden; }
.option[aria-selected=true] svg.tick { visibility: visible; }
.sheet-title { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }

.switch { width: 36px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; flex: none;
  transition: background var(--base); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--base) var(--ease); }
.switch[aria-checked=true] { background: var(--primary); }
.switch[aria-checked=true]::after { transform: translateX(16px); }
.switch:active::after { width: 19px; }
.switch[aria-checked=true]:active::after { transform: translateX(13px); }
.switch:disabled { opacity: .5; }
.switch-row { display: flex; align-items: flex-start; gap: var(--s-3); }
.switch-row .text { flex: 1; min-width: 0; }
.switch-row .text .title { font-weight: 500; }
.switch-row .text .hint { font-size: 12.5px; color: var(--text-2); }

.check { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; min-height: 28px; }
.check .box { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; color: var(--on-primary); flex: none; transition: background var(--fast), border-color var(--fast); }
.check[aria-checked=true] .box { background: var(--primary); border-color: var(--primary); }
.check .box svg { opacity: 0; }
.check[aria-checked=true] .box svg { opacity: 1; }

/* —— 卡片、区块 —— */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); }
.card-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); min-height: 48px; }
.card-head h2 { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
.card-body { padding: var(--s-4); }
.toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.toolbar .grow { flex: 1; min-width: 0; }
.toolbar .search { flex: 1 1 220px; max-width: 360px; min-width: 0; }
.toolbar .select { flex: 0 1 150px; }
.filters { display: contents; }
.btn.filter-toggle { display: none; }
.intro { color: var(--text-2); max-width: 78ch; flex: 0 1 auto; min-width: 0; }

.banner { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-m);
  border: 1px solid var(--border); background: var(--surface); }
.banner.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.banner.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.banner .text { flex: 1; min-width: 0; color: var(--text); }
.banner .text strong { font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 12px;
  font-weight: 500; white-space: nowrap; background: var(--idle-soft); color: var(--idle); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

/* —— 表格 —— */
.table-wrap { overflow-x: auto; }
table.table th { font-size: 12.5px; color: var(--text-2); padding: 9px var(--s-4); border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
table.table td { padding: 10px var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 0; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table td.fit, table.table th.fit { width: 1%; max-width: none; white-space: nowrap; }
table.table td.actions { width: 1%; max-width: none; white-space: nowrap; text-align: right; }
table.table tr.clickable { cursor: pointer; transition: background var(--fast); }
table.table tr.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--primary-soft); } }
.cell-main { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: var(--s-3); }
.idchip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.idchip .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { width: 22px; height: 22px; border-radius: var(--r-s); display: inline-grid; place-items: center; color: var(--text-3); flex: none; }
.copy:active { transform: scale(.9); }
.copy.done { color: var(--ok); }
.empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.empty .title { color: var(--text); font-weight: 500; }
.more-row { padding: var(--s-3); display: flex; justify-content: center; border-top: 1px solid var(--border); }

/* —— 概览 —— */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s-4); }
.stat { padding: var(--s-4); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat .name { font-size: 12.5px; color: var(--text-2); }
.stat .value { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--text-2); letter-spacing: 0; }
.stat .foot { font-size: 12.5px; color: var(--text-2); display: flex; gap: var(--s-3); flex-wrap: wrap; }
.meter { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; border-radius: 3px; background: var(--primary); transform-origin: left;
  transition: transform var(--slow) var(--ease), background var(--base); }
.meter.hot i { background: var(--warn); }
.meter.full i { background: var(--danger); }
.todo-list { display: flex; flex-direction: column; }
.todo-list a { display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-4); color: var(--text); border-bottom: 1px solid var(--border); }
.todo-list a:last-child { border-bottom: 0; }
.todo-list .n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 28px; }
.todo-list .t { flex: 1; min-width: 0; }
.todo-list .t small { display: block; color: var(--text-2); font-size: 12.5px; }
.chart { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); align-items: end; gap: 3px; height: 120px; padding: var(--s-4) var(--s-4) 0; }
.chart .bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 3px; }
.chart .bar i { display: block; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 0; transform-origin: bottom; opacity: .85; }
.chart .bar i.err { background: var(--danger); border-radius: 0; opacity: 1; }
.chart .bar i:first-child { border-radius: 3px 3px 0 0; }
.chart .bar.zero::after { content: ""; display: block; height: 2px; background: var(--border); border-radius: 1px; }
.chart-axis { display: flex; justify-content: space-between; padding: 6px var(--s-4) var(--s-3); font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: var(--s-4); font-size: 12.5px; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--primary); }
.legend span.err::before { background: var(--danger); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }

/* —— 详情 —— */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px var(--s-4); }
.kv dt { color: var(--text-2); white-space: nowrap; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.pre { font-family: var(--mono); font-size: 12.5px; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--r-m);
  padding: var(--s-3); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.secret { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-m); background: var(--sunken);
  border: 1px solid var(--border); }
.secret code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.section-title { font-size: 13px; font-weight: 600; margin-bottom: var(--s-2); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack.tight { gap: var(--s-2); }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow);
  animation: rise var(--base) var(--ease); }
.savebar .grow { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.alert-item { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); align-items: flex-start;
  transition: opacity var(--base); }
.alert-item:last-child { border-bottom: 0; }
.alert-item .body { flex: 1; min-width: 0; }
.alert-item .msg { overflow-wrap: anywhere; }
.alert-item .meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.alert-item.acked { opacity: .6; }
.audit-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-3); padding: 8px var(--s-4); border-bottom: 1px solid var(--border); font-size: 13px; }
.audit-item:last-child { border-bottom: 0; }

/* —— 骨架 —— */
.skel { border-radius: var(--r-s); background: linear-gradient(90deg, var(--sunken) 25%, var(--border) 50%, var(--sunken) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; height: 14px; }
.skel.block { height: 96px; border-radius: var(--r-l); }
.skel.row { height: 44px; margin: 0; border-radius: 0; border-bottom: 1px solid var(--surface); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* —— 弹窗、提示 —— */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15, 15, 25, .42); display: grid; place-items: center; padding: var(--s-4);
  animation: fade var(--base) ease-out; }
.overlay.closing { animation: fade var(--fast) ease-in reverse forwards; }
.dialog { width: min(520px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column; background: var(--raised);
  border-radius: var(--r-l); box-shadow: var(--shadow); animation: dialog-in var(--slow) var(--ease); }
.dialog.wide { width: min(720px, 100%); }
.overlay.closing .dialog { animation: dialog-in var(--fast) ease-in reverse forwards; }
.dialog-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-3) var(--s-5); }
.dialog-head h2 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; }
.dialog-body { padding: 0 var(--s-5) var(--s-4); overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5) calc(var(--s-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

#toasts { position: fixed; z-index: 80; right: var(--s-4); top: calc(var(--topbar) + var(--s-3)); display: flex;
  flex-direction: column; gap: var(--s-2); align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: var(--r-m); background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  animation: toast-in var(--base) var(--ease); }
.toast.leaving { animation: toast-in var(--fast) ease-in reverse forwards; }
.toast.error { background: var(--danger); color: #fff; }
.toast .btn.text { color: inherit; text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* —— 认证界面 —— */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-5); }
.auth-card { width: min(380px, 100%); padding: var(--s-6) var(--s-5) var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.auth-card .brand { padding: 0; }
.auth-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.code-input { height: 52px; font-size: 26px; letter-spacing: .38em; text-align: center; font-variant-numeric: tabular-nums;
  font-family: var(--mono); padding-left: .38em; }
.auth-card .btn { height: 40px; }
.auth-note { font-size: 12.5px; color: var(--text-3); }

/* —— 平板：侧栏收成图标栏 —— */
@media (max-width: 1100px) {
  .shell { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .sidebar { padding-left: var(--s-2); padding-right: var(--s-2); align-items: stretch; }
  .brand-name, .nav a span.label, .sidebar-foot { display: none; }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .nav a { justify-content: center; padding: 0; position: relative; }
  .nav .count { position: absolute; top: 2px; right: 2px; min-width: 14px; height: 14px; line-height: 14px; font-size: 10px; padding: 0 3px; }
  .hide-tablet { display: none !important; }
  .grid-2, .settings { grid-template-columns: minmax(0, 1fr); }
}

/* —— 手机：单列，导航进抽屉，表格变卡片，弹窗变底部面板 —— */
@media (max-width: 720px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 45; inset: 0 auto 0 0; width: min(78vw, 280px); transform: translateX(-102%);
    transition: transform var(--slow) var(--ease); padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-3) var(--s-3); box-shadow: var(--shadow); }
  .shell.drawer .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(15, 15, 25, .42); opacity: 0; pointer-events: none; transition: opacity var(--base); }
  .shell.drawer .scrim { opacity: 1; pointer-events: auto; }
  .brand-name, .nav a span.label, .sidebar-foot { display: block; }
  .brand { justify-content: flex-start; padding: var(--s-2) var(--s-2) var(--s-4); }
  .nav a { justify-content: flex-start; padding: 0 var(--s-3); height: 44px; }
  .nav .count { position: static; min-width: 18px; height: auto; line-height: inherit; font-size: 12px; padding: 0 5px; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding-left: var(--s-2); padding-right: var(--s-3); height: calc(48px + env(safe-area-inset-top)); }
  .content { padding: var(--s-3) var(--s-3) calc(var(--s-6) + env(safe-area-inset-bottom)); }
  .page { gap: var(--s-3); }
  .hide-mobile, .intro { display: none !important; }
  .input, .textarea, .select-btn { font-size: 16px; height: 40px; }
  .textarea { height: auto; }
  .btn { height: 38px; }
  .btn.small { height: 34px; }
  .btn.icon { width: 38px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .stat .value { font-size: 20px; }

  .toolbar .search { flex: 1 1 100%; max-width: none; order: -1; }
  .btn.filter-toggle { display: inline-flex; }
  .filters { display: none; }
  .filters.open { display: flex; flex-direction: column; gap: var(--s-2); flex: 1 1 100%; }
  .filters.open .select { flex: none; }

  .table-wrap { overflow: visible; }
  table.table thead { display: none; }
  table.table, table.table tbody { display: block; }
  table.table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  table.table tbody tr:last-child { border-bottom: 0; }
  table.table td { display: block; padding: 0; border: 0; max-width: none; width: auto !important; min-width: 0; text-align: left; }
  table.table td.m-main { flex: 1 1 0; order: 1; }
  table.table td.m-side { flex: none; order: 2; }
  table.table td.m-sub { flex: 1 1 100%; order: 3; font-size: 12.5px; color: var(--text-2); }
  table.table td.m-meta { flex: none; order: 4; font-size: 12.5px; color: var(--text-2); }
  table.table td.actions { flex: none; order: 5; margin-left: auto; }
  table.table td.m-hide { display: none; }
  table.table td.m-meta > * { display: inline; }
  /* 第一行只放名称和状态，其余信息另起一行 */
  table.table tr::after { content: ""; flex: 0 0 100%; height: 0; order: 2; margin-top: -4px; }
  table.table td[data-label]::before { content: attr(data-label) " "; color: var(--text-3); }

  .overlay { align-items: end; padding: 0; }
  .dialog, .dialog.wide { width: 100%; max-height: 92dvh; border-radius: var(--r-l) var(--r-l) 0 0; animation-name: sheet-in; }
  .overlay.closing .dialog { animation-name: sheet-in; }
  .dialog-foot .btn { flex: 1; }
  .popover { position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: auto !important; max-height: 70dvh; border-radius: var(--r-l) var(--r-l) 0 0; padding: var(--s-2) var(--s-2) calc(var(--s-3) + env(safe-area-inset-bottom));
    animation-name: sheet-in; animation-duration: var(--slow); }
  .popover .option { min-height: 46px; padding: 6px var(--s-3); font-size: 16px; }
  .sheet-title { display: block; padding: var(--s-2) var(--s-3); font-size: 13px; color: var(--text-2); }
  .sheet-scrim { position: fixed; inset: 0; z-index: 59; background: rgba(15, 15, 25, .42); animation: fade var(--base); }
  #toasts { left: var(--s-3); right: var(--s-3); top: auto; bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: var(--s-2); }
  .audit-item { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .savebar { bottom: env(safe-area-inset-bottom); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .overlay, .toast, .dialog, .popover { animation: fade var(--base) !important; }
  .skel { animation: none; }
}
