/* 路由层管理台。颜色、圆角、间距、阴影、动效都是变量；深色模式只覆盖变量。
 * 图表色 --chart-1 / --chart-fail 两套取值都过了色觉缺陷与对比度校验（浅色对 #fff、深色对 #17171b）。 */

:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --bg-subtle: #f1f1f3;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --overlay: #ffffff;
  --border: #e6e6ea;
  --border-strong: #d4d4da;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #85858f;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-press: #3730a3;
  --primary-weak: #eef0ff;
  --on-primary: #ffffff;
  --success: #15803d;
  --success-weak: #e8f6ed;
  --warning: #b45309;
  --warning-weak: #fdf3e2;
  --danger: #c2262e;
  --danger-hover: #a51d24;
  --danger-weak: #fdecec;
  --info: #1d6fd1;
  --info-weak: #e8f1fd;
  --neutral-weak: #f0f0f2;
  --chart-1: #4f46e5;
  --chart-fail: #c2262e;
  --chart-wash: rgb(79 70 229 / 0.1);
  --chart-grid: #ececf0;
  --focus: 0 0 0 3px rgb(79 70 229 / 0.32);
  --shadow-overlay: 0 12px 32px rgb(15 15 25 / 0.12), 0 2px 6px rgb(15 15 25 / 0.06);
  --scrim: rgb(15 15 20 / 0.36);
  --toast-bg: #18181b;
  --toast-text: #f4f4f5;
  --toast-act: #a5b4fc;
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 280ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.3, 0, 0, 1);
  --sidebar-w: 232px;
  --sidebar-w-mini: 64px;
  --topbar-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --bg-subtle: #131317;
    --surface: #17171b;
    --surface-2: #1b1b20;
    --overlay: #212127;
    --border: #2a2a31;
    --border-strong: #3a3a43;
    --text: #ececef;
    --text-2: #a8a8b3;
    --text-3: #777782;
    --primary: #8b8cf8;
    --primary-hover: #a3a4fa;
    --primary-press: #b8b9fb;
    --primary-weak: #23234a;
    --on-primary: #0e0e1f;
    --success: #4ade80;
    --success-weak: #13301f;
    --warning: #fbbf24;
    --warning-weak: #33270e;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-weak: #3a1719;
    --info: #60a5fa;
    --info-weak: #142843;
    --neutral-weak: #24242a;
    --chart-1: #7c7ef5;
    --chart-fail: #ea5257;
    --chart-wash: rgb(124 126 245 / 0.14);
    --chart-grid: #26262c;
    --focus: 0 0 0 3px rgb(139 140 248 / 0.4);
    --shadow-overlay: 0 0 0 1px var(--border-strong), 0 16px 40px rgb(0 0 0 / 0.4);
    --scrim: rgb(0 0 0 / 0.55);
    --toast-bg: #2a2a31;
    --toast-text: #ececef;
    --toast-act: #a3a4fa;
  }
}

/* ================================================================ 重置 */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p, ul, ol, pre, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: not-allowed; }
a { color: var(--primary); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
svg { display: block; flex: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: rgb(79 70 229 / 0.22); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 9999s;
}
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, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input::-ms-reveal, input::-ms-clear { display: none; }

/* ================================================================ 工具类 */

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--text-3); }
.secondary-text { color: var(--text-2); }
.warning-text { color: var(--warning); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.inline { display: inline-flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.pad { padding: var(--sp-4) var(--sp-5); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 641px) { .only-mobile { display: none !important; } }

/* ================================================================ 布局 */

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot::after {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite, appear var(--dur) 300ms both;
}
.noscript { padding: var(--sp-8); text-align: center; color: var(--text-2); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  transition: grid-template-columns var(--dur) var(--ease);
}
.app.mini { grid-template-columns: var(--sidebar-w-mini) minmax(0, 1fr); }

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: var(--sp-3) var(--sp-2);
  padding-top: max(var(--sp-3), env(safe-area-inset-top));
  padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 8px;
  margin-bottom: var(--sp-3);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  display: grid;
  place-items: center;
  flex: none;
}
.brand small { color: var(--text-3); font-weight: 500; font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--text-2);
  white-space: nowrap;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.nav-item:active { transform: scale(0.98); }
@media (hover: hover) { .nav-item:hover { background: var(--neutral-weak); color: var(--text); text-decoration: none; } }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); font-weight: 500; }
.nav-item[aria-current="page"] svg { color: var(--primary); }
.nav-item:focus-visible { box-shadow: var(--focus); }
.nav-item .count {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.count-dot { display: none; position: absolute; top: 7px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--bg-subtle); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: var(--sp-2); margin-top: var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.who { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 8px; color: var(--text-2); font-size: 13px; white-space: nowrap; min-width: 0; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-weak); color: var(--primary); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }

.app.mini .nav-label, .app.mini .brand-text, .app.mini .who-name, .app.mini .nav-item .count { display: none; }
.app.mini .nav-item, .app.mini .brand { justify-content: center; padding: 0; }
.app.mini .nav-item .count-dot:not([hidden]) { display: block; }
.app.mini .who { justify-content: center; padding: 6px 0; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex: none;
}
.topbar h1 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; white-space: nowrap; border-radius: var(--r-sm); padding: 4px 6px; font-variant-numeric: tabular-nums; }
@media (hover: hover) { .live:hover { color: var(--text-2); text-decoration: none; } }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; box-shadow: 0 0 0 3px var(--success-weak); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-weak); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-weak); }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-6); overscroll-behavior: contain; scroll-padding-top: var(--sp-4); }
.page { display: flex; flex-direction: column; gap: var(--sp-5); max-width: 1680px; margin: 0 auto; animation: page-in var(--dur) var(--ease-out); }
.page.narrow { max-width: 760px; }
.topbar .menu-btn { display: none; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }

/* ================================================================ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  user-select: none;
  flex: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), opacity var(--dur-fast);
}
a.btn { color: var(--text); }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--neutral-weak); text-decoration: none; }
  .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.ghost:hover:not(:disabled) { background: var(--neutral-weak); color: var(--text); }
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.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.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; border-radius: var(--r-sm); gap: 4px; }
.btn.block { width: 100%; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn.primary.loading::after, .btn.danger.loading::after { border-color: var(--on-primary); border-right-color: transparent; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  color: var(--text-2);
  flex: none;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast), transform var(--dur-fast);
}
@media (hover: hover) { .icon-btn:hover:not(:disabled) { background: var(--neutral-weak); color: var(--text); } }
.icon-btn:active:not(:disabled) { transform: scale(0.9); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn[aria-expanded="true"], .icon-btn[aria-pressed="true"] { background: var(--neutral-weak); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; border-radius: var(--r-sm); }
.icon-btn.ok { color: var(--success); }
.icon-btn.loading > svg { visibility: hidden; }
.icon-btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-3); border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* ================================================================ 表单控件 */

.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.error-text { font-size: 12px; color: var(--danger); }
.form-error { font-size: 13px; color: var(--danger); }
.form-error:empty { display: none; }
.form-error.info { color: var(--text-2); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-2); }
.input, .textarea, .select-trigger {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.5; display: block; }
.input.mono, .textarea.mono { font-size: 13px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:focus, .textarea:focus, .select-trigger:focus-visible { border-color: var(--primary); box-shadow: var(--focus); }
.input:disabled { opacity: 0.6; }
.field.invalid .input, .field.invalid .textarea, .field.invalid .select-trigger { border-color: var(--danger); }
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-wrap > svg + .input { padding-left: 32px; }
.input-wrap.with-action .input { padding-right: 40px; }
.input-wrap > .icon-btn { position: absolute; right: 4px; }
.input-unit { display: flex; align-items: center; gap: var(--sp-2); }
.input-unit .input { max-width: 180px; }
.unit { color: var(--text-3); font-size: 13px; }

.select { position: relative; min-width: 0; }
.select-trigger { display: flex; align-items: center; gap: 6px; text-align: left; cursor: pointer; padding-right: 30px; }
.select-trigger .value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger .placeholder { color: var(--text-3); }
.select-trigger > svg { position: absolute; right: 9px; color: var(--text-3); transition: transform var(--dur-fast) var(--ease); }
.select-trigger[aria-expanded="true"] { border-color: var(--primary); }
.select-trigger[aria-expanded="true"] > svg { transform: rotate(180deg); }
@media (hover: hover) { .select-trigger:hover { border-color: var(--text-3); } }

.popover {
  position: fixed;
  z-index: 70;
  min-width: 160px;
  max-width: min(440px, calc(100vw - 16px));
  max-height: min(360px, 60dvh);
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--overlay);
  box-shadow: var(--shadow-overlay);
  transform-origin: top;
  animation: pop-in var(--dur) var(--ease-out);
}
.popover.closing { animation: pop-out var(--dur-fast) var(--ease) forwards; }
.popover .search { margin-bottom: 4px; height: 32px; }
.options { display: flex; flex-direction: column; gap: 1px; outline: none; }
.option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--text);
  min-width: 0;
}
.option .ellipsis { flex: 1; }
.option .check { margin-left: auto; color: var(--primary); visibility: hidden; }
.option[aria-selected="true"] { font-weight: 500; }
.option[aria-selected="true"] .check { visibility: visible; }
.option.active, .option:focus-visible { background: var(--neutral-weak); box-shadow: none; }
@media (hover: hover) { .option:hover:not(:disabled) { background: var(--neutral-weak); } }
.option:disabled { color: var(--text-3); }
.option.danger { color: var(--danger); }
.option > svg:first-child { color: var(--text-3); }
.option.danger > svg:first-child { color: var(--danger); }
.option .sub { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.option-empty { padding: 10px; color: var(--text-3); font-size: 13px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(-4px) scale(0.98); } }

.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; user-select: none; position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch .track {
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--border-strong);
  position: relative;
  transition: background var(--dur) var(--ease);
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform var(--dur) var(--ease), width var(--dur-fast) var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch input:disabled + .track { opacity: 0.5; }

.checks { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.check-chip { position: relative; display: inline-flex; }
.check-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check-chip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 12px 4px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast);
}
.check-chip span::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface) center / 12px no-repeat;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.check-chip input:checked + span { border-color: var(--primary); color: var(--text); background: var(--primary-weak); }
.check-chip input:checked + span::before {
  border-color: var(--primary);
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5l4.5-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.check-chip input:focus-visible + span { box-shadow: var(--focus); }

.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--neutral-weak); gap: 2px; flex: none; max-width: 100%; overflow-x: auto; }
.seg button { height: 30px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; white-space: nowrap; transition: background var(--dur-fast), color var(--dur-fast); }
@media (hover: hover) { .seg button:hover { color: var(--text); } }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.05); font-weight: 500; }
.seg button:focus-visible { box-shadow: var(--focus); }

/* ================================================================ 卡片、徽标、指标 */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: 12px var(--sp-5); border-bottom: 1px solid var(--border); min-height: 52px; }
.card-head h2 { font-size: 14px; font-weight: 600; min-width: 0; }
.card-link { font-size: 13px; white-space: nowrap; }
.card-body { padding: var(--sp-4) var(--sp-5); min-width: 0; }
.card-body.flush { padding: 0; }
.fold-card > summary { cursor: pointer; list-style: none; }
.fold-card > summary::-webkit-details-marker { display: none; }
.fold-card > summary svg { color: var(--text-3); transition: transform var(--dur-fast) var(--ease); }
.fold-card[open] > summary svg { transform: rotate(90deg); }
.fold-card:not([open]) > summary { border-bottom: 0; }
.info-btn { color: var(--text-3); margin-left: -6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--neutral-weak);
  color: var(--text-2);
  flex: none;
  max-width: 100%;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.plain::before { display: none; }
.badge.success { background: var(--success-weak); color: var(--success); }
.badge.warning { background: var(--warning-weak); color: var(--warning); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.info { background: var(--info-weak); color: var(--info); }
.badge.primary { background: var(--primary-weak); color: var(--primary); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: var(--r-xs); font-size: 12px; background: var(--neutral-weak); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag.on { background: var(--warning-weak); color: var(--warning); }

/* 指标块按个数排成整行：6 个、5 个在宽屏一行，窄一些时三列，手机两列 */
.tiles { --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--sp-4); }
.tiles[data-n="5"] { --cols: 5; }
.tiles[data-n="6"] { --cols: 6; }
.tiles.small { gap: var(--sp-3); }
@media (max-width: 1239px) { .tiles[data-n="5"], .tiles[data-n="6"] { --cols: 3; } }
.tile { padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: 6px; min-height: 108px; min-width: 0; }
.tiles.small .tile { min-height: 84px; padding: var(--sp-3) var(--sp-4); gap: 4px; }
.tile.link { cursor: pointer; transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
@media (hover: hover) { .tile.link:hover { border-color: var(--border-strong); } }
.tile.link:active { transform: scale(0.99); }
.tile .label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiles.small .tile .value { font-size: 20px; }
.tile .value.changed { animation: value-flash 1.4s var(--ease); }
.tile .sub { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub:empty { display: none; }
.tile .meter { margin-top: auto; }
.tile .skeleton { margin: 2px 0; }
@keyframes value-flash { from { color: var(--primary); } }
.meter { height: 6px; border-radius: 3px; background: var(--primary-weak); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width var(--dur-slow) var(--ease); }
.meter.warn { background: var(--warning-weak); }
.meter.warn > i { background: var(--warning); }
.meter.bad { background: var(--danger-weak); }
.meter.bad > i { background: var(--danger); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-5); }
/* 并排的卡片等高；图表撑满自己的卡片，不留一截空白 */
.grid-2 > .card, .grid-3 > .card { display: flex; flex-direction: column; }
.grid-2 > .card > .card-body, .grid-3 > .card > .card-body { flex: 1; }
.chart-body { display: flex; flex-direction: column; }
.chart-body > .chart { flex: 1; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px var(--sp-5); font-size: 13px; align-items: baseline; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 641px) { .drawer .kv, .dialog .kv { grid-template-columns: 112px minmax(0, 1fr); } }

.list { display: flex; flex-direction: column; }
.list.bordered { border: 1px solid var(--border); border-radius: var(--r-md); }
.list-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 10px var(--sp-5); border-top: 1px solid var(--border); min-width: 0; text-align: left; }
.list.bordered .list-row { padding: 10px var(--sp-3); }
.list-row:first-child { border-top: 0; }
.list-row.wrap { flex-wrap: wrap; }
.list-row.clickable { cursor: pointer; transition: background var(--dur-fast); }
@media (hover: hover) { .list-row.clickable:hover { background: var(--surface-2); } }
.list-row.clickable:focus-visible { box-shadow: inset var(--focus); }
.list-row.leaving, tr.leaving { opacity: 0; transition: opacity var(--dur) var(--ease); }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row.wrap .list-main { flex-basis: 220px; }
.pos-badge { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-weak); color: var(--text-2); font-size: 12px; font-weight: 600; flex: none; font-variant-numeric: tabular-nums; }

pre.code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 44px 10px 12px;
  overflow: auto;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}
.code-block { position: relative; min-width: 0; }
.code-block > .icon-btn { position: absolute; top: 6px; right: 6px; background: var(--surface); border: 1px solid var(--border); }
.idcell { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; vertical-align: middle; }
.idcell > .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.secret { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 10px 10px 12px; border-radius: var(--r-md); background: var(--bg-subtle); border: 1px solid var(--border); }
.secret code { flex: 1; min-width: 0; word-break: break-all; font-size: 13.5px; user-select: all; color: var(--text); }

.banners { display: flex; flex-direction: column; gap: var(--sp-2); }
.banner { display: flex; align-items: flex-start; gap: var(--sp-3); padding: 10px var(--sp-4); border-radius: var(--r-lg); background: var(--info-weak); color: var(--info); font-size: 13px; }
.banner.warning { background: var(--warning-weak); color: var(--warning); }
.banner.danger { background: var(--danger-weak); color: var(--danger); }
.banner > svg { margin-top: 2px; }
.banner .text { flex: 1; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.banner-link { font-weight: 500; white-space: nowrap; color: inherit; }

.empty { padding: 44px var(--sp-5); text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty > svg { color: var(--text-3); margin-bottom: 2px; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.empty p { font-size: 13px; max-width: 440px; }
.empty .btn { margin-top: 6px; }
.empty.compact { padding: 24px var(--sp-5); flex-direction: row; justify-content: center; gap: var(--sp-2); }
.empty.compact > svg { margin: 0; }
.empty.compact h3 { font-size: 13px; font-weight: 500; color: var(--text-2); }

.skeleton {
  display: block;
  height: 14px;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--neutral-weak) 25%, var(--bg-subtle) 37%, var(--neutral-weak) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite, appear var(--dur) 200ms both;   /* 200 毫秒内就加载完的，骨架屏不出现 */
}
.skeleton.big { height: 28px; width: 55%; }
.skeleton.w1 { width: 100%; }
.skeleton.w2 { width: 78%; }
.skeleton.w3 { width: 56%; }
.skeleton-rows { display: flex; flex-direction: column; gap: 14px; padding: var(--sp-5); }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

.loading-fade { opacity: 0.55; transition: opacity var(--dur) var(--ease); pointer-events: none; }
.list-body { min-height: 120px; transition: opacity var(--dur) var(--ease); }
.load-more { display: flex; justify-content: center; padding: var(--sp-4); border-top: 1px solid var(--border); }
.summary-line { font-size: 13px; color: var(--text-2); }
.status-strip { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.link-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flags:empty { display: none; }
.conv-mark { color: var(--warning); font-family: var(--mono); }
.provider-states { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.provider-state { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-width: 0; }
.notes { display: flex; flex-direction: column; gap: 6px; }
.note-list { border: 1px solid var(--border); border-radius: var(--r-md); }
.note-list li { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 10px; font-size: 13px; border-top: 1px solid var(--border); }
.note-list li:first-child { border-top: 0; }
.steps { list-style: decimal; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.save-status { white-space: nowrap; }

/* ================================================================ 工具条 */

.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.toolbar > .grow { flex: 1 1 240px; }
.toolbar .select { width: 150px; }
.filters { display: contents; }
.search-group { display: flex; flex: 1 1 340px; min-width: 0; max-width: 560px; }
.search-group > .select { width: 108px; flex: none; }
.search-group .select-trigger { border-top-right-radius: 0; border-bottom-right-radius: 0; background: var(--surface-2); }
.search-group > .input-wrap { flex: 1; margin-left: -1px; }
.search-group > .input-wrap .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.search-group .select-trigger:focus-visible, .search-group .input:focus { position: relative; z-index: 1; }
.filter-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }

/* ================================================================ 表格：宽时是表，窄时是卡片 */

.table-wrap { container-type: inline-size; min-width: 0; }
.table-scroll { overflow-x: clip; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--text-3);
  font-weight: 500;
  font-size: 12px;
  text-align: left;
  padding: 0 var(--sp-3);
  height: 38px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.card > .list-body > .table-wrap .table th:first-child { border-top-left-radius: calc(var(--r-lg) - 1px); }
.card > .list-body > .table-wrap .table th:last-child { border-top-right-radius: calc(var(--r-lg) - 1px); }
.table td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 320px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--sp-5); }
.table th:last-child, .table td:last-child { padding-right: var(--sp-5); }
.table .right { text-align: right; }
.table .only-card { display: none; }
.table tbody tr { transition: background var(--dur-fast), opacity var(--dur); }
.table tbody tr.clickable { cursor: pointer; }
@media (hover: hover) { .table tbody tr.clickable:hover { background: var(--surface-2); } }
.table tbody tr:focus-visible { box-shadow: inset var(--focus); }
.table tbody tr.running td:first-child { box-shadow: inset 2px 0 0 var(--info); }
.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--primary-weak); } }
.cell-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.cell-main > .ellipsis { max-width: 100%; }
.cell-main.end { align-items: flex-end; }
.actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.table.compact th, .table.compact td { padding: 7px 10px; position: static; }
.table.compact th:first-child, .table.compact td:first-child { padding-left: 10px; }
.table.compact th:last-child, .table.compact td:last-child { padding-right: 10px; }

@container (max-width: 1080px) { .table.data .p3 { display: none; } }
@container (max-width: 840px) { .table.data .p2 { display: none; } }
@container (max-width: 640px) {
  .table.data, .table.data tbody { display: block; }
  .table.data thead { display: none; }
  .table.data tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "title status actions" "sub sub actions";
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
    padding: 12px var(--sp-4);
    border-bottom: 1px solid var(--border);
  }
  .table.data tbody tr:last-child { border-bottom: 0; }
  .table.data td { display: none; padding: 0 !important; border: 0; max-width: none; }
  .table.data td.c-title { display: block; grid-area: title; min-width: 0; font-weight: 500; }
  .table.data td.c-status { display: block; grid-area: status; justify-self: end; }
  .table.data td.c-actions { display: block; grid-area: actions; }
  .table.data td.c-sub { display: block; grid-area: sub; min-width: 0; color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table.data td.c-actions .wide { display: none; }
  .table.data tbody tr.running td:first-child { box-shadow: none; }
}

/* ================================================================ 路由规则 */

.rule-groups { display: flex; flex-direction: column; gap: var(--sp-4); }
.rule-group { container-type: inline-size; }
.rule-group .card-head h2 { font-family: var(--mono); font-size: 13.5px; }
.group-meta { white-space: nowrap; }
.rule {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.5fr) auto;
  gap: var(--sp-4);
  align-items: center;
  padding: 12px var(--sp-5) 12px var(--sp-3);
  border-top: 1px solid var(--border);
}
.rule:first-child { border-top: 0; }
.rule.disabled .rule-main, .rule.disabled .rule-plan { opacity: 0.5; }
.rule-order { display: flex; flex-direction: column; align-items: center; width: 28px; }
.rule-order .pos { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; line-height: 1; padding: 1px 0; }
.rule-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-provider { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.rule-plan { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.plan-item { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--r-sm); font-size: 12px; font-family: var(--mono); white-space: nowrap; background: var(--neutral-weak); color: var(--text-2); }
.plan-item.pass { background: var(--success-weak); color: var(--success); }
.plan-item.conv { background: var(--warning-weak); color: var(--warning); }
.plan-pass { font-family: var(--font); }
.rule-actions { display: flex; align-items: center; gap: 6px; }
.rule-actions > .switch { margin-right: 6px; }
.plan-preview { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--r-md); background: var(--bg-subtle); margin-top: -4px; }
.route-line { margin-top: -8px; }
@container (max-width: 780px) {
  .rule { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 8px; }
  .rule-order { grid-row: 1 / span 2; }
  .rule-main { grid-column: 2; grid-row: 1; }
  .rule-actions { grid-column: 3; grid-row: 1; }
  .rule-plan { grid-column: 2 / -1; grid-row: 2; }
  .rule-actions .wide { display: none; }
}

/* ================================================================ 浮层：对话框（手机上是底部面板）、抽屉、提示 */

.closing { pointer-events: none !important; }   /* 正在退场的浮层不再接收点击，免得吃掉紧接着的操作 */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); animation: appear var(--dur) var(--ease); }
.scrim.closing { animation: fade-out var(--dur-fast) var(--ease) forwards; }
.nav-scrim { z-index: 59; }
@keyframes fade-out { to { opacity: 0; } }

.dialog {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: 10dvh;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--overlay);
  box-shadow: var(--shadow-overlay);
  animation: dialog-in var(--dur-slow) var(--ease-out);
}
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dialog.closing { animation: dialog-out var(--dur-fast) var(--ease) forwards; }
.dialog-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-5); }
.dialog-head h2 { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dialog-body { padding: var(--sp-2) var(--sp-5) var(--sp-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-4); color: var(--text); overscroll-behavior: contain; }
.dialog-body > p { color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) var(--sp-5); border-top: 1px solid var(--border); }
.grabber { display: none; }
@keyframes dialog-in { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.98); } }

.drawer {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--overlay);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-overlay);
  animation: drawer-in var(--dur-slow) var(--ease-out);
}
.drawer.closing { animation: drawer-out var(--dur) var(--ease) forwards; }
.drawer-head { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--topbar-h); padding: env(safe-area-inset-top) var(--sp-3) 0 var(--sp-5); border-bottom: 1px solid var(--border); flex: none; }
.drawer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drawer-title h2 { font-size: 15px; font-weight: 600; line-height: 1.3; }
.drawer-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-sub:empty { display: none; }
.drawer-tools { display: flex; gap: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-6); padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom)); container-type: inline-size; overscroll-behavior: contain; transition: opacity var(--dur) var(--ease); }
.drawer-stack { display: flex; flex-direction: column; gap: var(--sp-6); transition: opacity var(--dur) var(--ease); }
.drawer-section { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.drawer-section > h3 { font-size: 13px; font-weight: 600; color: var(--text-2); }
.drawer .grid-2.tight { gap: var(--sp-6); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }

.attempt { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.attempt.bound { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.attempt-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-width: 0; }
.attempt-head .seq { font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
details.fold { border: 1px solid var(--border); border-radius: var(--r-md); min-width: 0; }
details.fold > summary { cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 6px; border-radius: var(--r-md); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary svg { transition: transform var(--dur-fast) var(--ease); color: var(--text-3); }
details.fold[open] > summary svg { transform: rotate(90deg); }
details.fold > .fold-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: var(--sp-2); }

.test-result { display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.reply { display: flex; flex-direction: column; gap: 6px; }
.reply-text { font-size: 15px; padding: 10px 12px; background: var(--bg-subtle); border-radius: var(--r-md); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow-y: auto; }
.waiting:empty { display: none; }

.toasts { position: fixed; z-index: 200; right: var(--sp-5); bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 8px 6px 8px 14px;
  border-radius: var(--r-lg);
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: var(--shadow-overlay);
  font-size: 13px;
  animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast.closing { animation: toast-out var(--dur) var(--ease) forwards; }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 3px 0; }
.toast .act { color: var(--toast-act); font-weight: 600; padding: 4px 8px; border-radius: var(--r-sm); white-space: nowrap; }
@media (hover: hover) { .toast .act:hover { background: rgb(255 255 255 / 0.1); } }
.toast .icon-btn { color: inherit; opacity: 0.6; }
@media (hover: hover) { .toast .icon-btn:hover { background: rgb(255 255 255 / 0.1); color: inherit; opacity: 1; } }
.toast.error > svg:first-child { color: #f87171; }
.toast.success > svg:first-child { color: #4ade80; }
.toast.info > svg:first-child { color: var(--toast-act); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ================================================================ 图表 */

.chart { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; container-type: inline-size; }
.chart-head { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; min-height: 26px; }
.chart-head figcaption { font-size: 13px; color: var(--text-2); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; }
.s-ok { background: var(--chart-1); }
.s-fail { background: var(--chart-fail); }
.cols-plot { display: flex; flex-direction: column; padding-left: 40px; flex: 1; }
.cols-area { position: relative; flex: 1; min-height: 168px; }
.cols-grid { position: absolute; inset: 0; pointer-events: none; }
.cols-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--chart-grid); }
.cols-line span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; line-height: 16px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; }
.cols-col { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; align-items: flex-end; border-radius: var(--r-xs); }
.cols-col:focus-visible { box-shadow: var(--focus); }
.cols-stack { width: min(24px, 72%); height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; }
.cols-seg { flex: none; min-height: 2px; transition: opacity var(--dur-fast) var(--ease); }
.cols-seg.top { border-radius: 4px 4px 0 0; }
@media (hover: hover) { .cols:hover .cols-col:not(:hover) .cols-seg { opacity: 0.45; } }
.cols:focus-within .cols-col:not(:focus) .cols-seg { opacity: 0.45; }
.cols-axis { position: relative; height: 18px; margin-top: 6px; }
.cols-axis span { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cols-axis span.first { left: 0; transform: none; }
.cols-axis span.last { right: 0; transform: none; }
@container (max-width: 520px) { .cols-axis span.alt { display: none; } }
.chart-table { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.chart-tip {
  position: fixed;
  z-index: 190;
  pointer-events: none;
  min-width: 128px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--overlay);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-overlay);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tip-title { color: var(--text-3); font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row strong { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.tip-row span { color: var(--text-2); }
.tip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.tip-key.none { background: transparent; }

.ranked { display: flex; flex-direction: column; gap: var(--sp-3); }
.ranked-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--sp-3); align-items: center; width: 100%; text-align: left; border-radius: var(--r-sm); padding: 2px 0; }
.ranked-row.clickable { cursor: pointer; }
@media (hover: hover) { .ranked-row.clickable:hover .ranked-name { color: var(--primary); } }
.ranked-row:focus-visible { box-shadow: var(--focus); }
.ranked-name { font-size: 13px; }
.ranked-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ranked-bar { grid-column: 1 / -1; height: 6px; border-radius: 0 3px 3px 0; overflow: hidden; }
.ranked-bar > i { display: block; height: 100%; min-width: 2px; background: var(--chart-1); border-radius: 0 3px 3px 0; }
.ranked-sub { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); }

.spark { width: 112px; height: 26px; overflow: visible; }
.spark .area { fill: var(--chart-wash); stroke: none; }
.spark .line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark.flat .area { fill: none; }
.spark.flat .line { stroke: var(--border-strong); }

/* ================================================================ 登录 */

.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-5); padding-bottom: max(var(--sp-5), env(safe-area-inset-bottom)); }
.login-card { width: min(380px, 100%); padding: var(--sp-8) var(--sp-6) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-5); animation: rise-in var(--dur-slow) var(--ease-out); }
.login-card .brand { margin: 0; padding: 0; }
.login-head { display: flex; flex-direction: column; gap: 4px; }
.login-head h1 { font-size: 20px; font-weight: 600; }
.login-head p { color: var(--text-2); font-size: 13px; }
.code-input { height: 54px; font-size: 26px; letter-spacing: 0.45em; text-align: center; font-variant-numeric: tabular-nums; font-family: var(--mono); padding-left: 0.45em; }
.code-input::placeholder { letter-spacing: 0.45em; color: var(--border-strong); }
.login-card .form-error { min-height: 20px; margin-top: -8px; }
.login-card .form-error:empty { display: block; }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }

/* ================================================================ 平板：侧栏收成图标栏 */

@media (max-width: 1024px) {
  .app, .app.mini { grid-template-columns: var(--sidebar-w-mini) minmax(0, 1fr); }
  .app .nav-label, .app .brand-text, .app .who-name, .app .nav-item .count { display: none; }
  .app .nav-item, .app .brand { justify-content: center; padding: 0; }
  .app .nav-item .count-dot:not([hidden]) { display: block; }
  .app .who { justify-content: center; padding: 6px 0; }
  .collapse-btn { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================================ 手机：单列，导航进抽屉，弹窗变底部面板 */

@media (max-width: 640px) {
  body { font-size: 15px; }
  .hide-mobile { display: none !important; }
  .app, .app.mini { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(288px, 84vw);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
    box-shadow: var(--shadow-overlay);
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease-out), visibility 0s; }
  .app .nav-label, .app .brand-text, .app .who-name { display: initial; }
  .app .nav-item .count { display: grid; }
  .app .nav-item .count-dot:not([hidden]) { display: none; }
  .app .brand { justify-content: flex-start; padding: 0 8px; }
  .app .nav-item { justify-content: flex-start; padding: 0 12px; height: 44px; }
  .app .who { justify-content: flex-start; padding: 8px 12px; }
  .topbar .menu-btn { display: inline-grid; margin-left: -8px; }
  .filters { display: none; }
  .topbar { padding: env(safe-area-inset-top) var(--sp-4) 0; height: calc(var(--topbar-h) + env(safe-area-inset-top)); gap: var(--sp-2); }
  .live-text { display: none; }
  .content { padding: var(--sp-4); padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom)); }
  .page { gap: var(--sp-4); }
  .input, .textarea, .select-trigger { font-size: 16px; height: 42px; }
  .textarea { height: auto; }
  .input.mono, .textarea.mono { font-size: 16px; }
  .btn { height: 40px; }
  .btn.small { height: 36px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.small { width: 34px; height: 34px; }
  .seg button { height: 36px; }
  .switch .track { width: 40px; height: 24px; border-radius: 12px; }
  .switch .track::after { width: 20px; height: 20px; }
  .switch input:checked + .track::after { transform: translateX(16px); }
  .tiles, .tiles[data-n="5"], .tiles[data-n="6"] { --cols: 2; gap: var(--sp-3); }
  .tile { padding: var(--sp-3) var(--sp-4); min-height: 96px; }
  .tile .value { font-size: 22px; }
  .card-head { padding: 10px var(--sp-4); min-height: 48px; }
  .card-body { padding: var(--sp-3) var(--sp-4); }
  .list-row { padding: 12px var(--sp-4); }
  .table th:first-child, .table td:first-child { padding-left: var(--sp-4); }
  .search-group { flex-basis: 100%; max-width: none; }
  .search-group > .select { width: 96px; }
  .toolbar .select { width: auto; flex: 1 1 140px; }
  .rule { padding: 12px var(--sp-4) 12px var(--sp-2); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .dialog, .dialog.wide {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    transform: none;
    max-height: 90dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-in var(--dur-slow) var(--ease-out);
  }
  .dialog.closing { animation: sheet-out var(--dur) var(--ease) forwards; }
  .grabber { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .dialog-head { padding-top: var(--sp-2); }
  .dialog-foot { flex-direction: column-reverse; border-top: 0; padding-top: var(--sp-2); }
  .dialog-foot .btn { width: 100%; height: 44px; }
  .drawer { width: 100vw; border-left: 0; }
  .drawer-body { padding: var(--sp-4); }
  .popover.sheet {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 72dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0;
    padding: 10px 8px max(12px, env(safe-area-inset-bottom));
    animation: sheet-in var(--dur-slow) var(--ease-out);
  }
  .popover.sheet.closing { animation: sheet-out var(--dur) var(--ease) forwards; }
  .popover.sheet .option { min-height: 46px; font-size: 15px; padding: 8px 12px; }
  .popover.sheet .search { height: 42px; margin-bottom: 6px; }
  .toasts { left: var(--sp-4); right: var(--sp-4); bottom: max(var(--sp-4), env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; min-width: 0; }
  .cols-area { min-height: 148px; }
  .login-card { padding: var(--sp-6) var(--sp-5) var(--sp-5); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }

/* ================================================================ 减少动态效果：去掉位移与缩放，只保留淡入淡出 */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: var(--dur-fast) !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .page, .dialog, .drawer, .popover, .popover.sheet, .toast, .login-card, .scrim { animation-name: appear !important; }
  .closing { animation-name: fade-out !important; }
  .skeleton { animation: appear var(--dur-fast) 200ms both !important; }
  .btn.loading::after, .icon-btn.loading::after, .boot::after { animation: spin 0.7s linear infinite !important; }
  .btn:active:not(:disabled), .icon-btn:active:not(:disabled), .nav-item:active, .tile.link:active { transform: none; }
}
