/* ═══════════════════════════════════════════════════════════════════
   smshub 控制台 · 设计系统
   零依赖 / 系统字体 / 8pt 网格 / 亮暗双主题
   ───────────────────────────────────────────────────────────────────
   1. tokens   2. reset   3. 排版   4. 布局   5. 组件   6. 页面
   7. 动效     8. 响应式
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────── 1. tokens ─────────────── */
:root {
  /* 间距 · 8pt 网格 */
  --s0: 0;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* 字阶 · 流体 */
  --t-hero: clamp(2.125rem, 1.35rem + 3.4vw, 3.125rem);
  --t-xl: clamp(1.375rem, 1.1rem + 1.1vw, 1.75rem);
  --t-lg: clamp(1.0625rem, .98rem + .5vw, 1.25rem);
  --t-md: .9375rem;
  --t-sm: .875rem;
  --t-xs: .8125rem;
  --t-2xs: .75rem;
  --t-3xs: .6875rem;

  --fn-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial,
    sans-serif;
  --fn-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-body: 1.6;

  /* 动效 */
  --dur-1: 130ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .5, 1);

  /* 色板 · 亮 */
  --bg: #f5f5f7;
  --bg-deep: #eceef2;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --surface-3: #f2f3f6;
  --line: #e6e7eb;
  --line-2: #d7d9e0;
  --ink: #15171c;
  --ink-2: #575d68;
  --ink-3: #8a909b;
  --ink-4: #aeb3bd;
  --accent: #2f56d4;
  --accent-soft: #e9edfd;
  --accent-ink: #ffffff;
  --ok: #0f8f5c;
  --ok-soft: #e3f5ec;
  --warn: #b87400;
  --warn-soft: #fdf1dd;
  --danger: #ce3b44;
  --danger-soft: #fdeaeb;
  --info: #2f56d4;
  --info-soft: #e9edfd;

  --sh-1: 0 1px 2px rgba(18, 22, 33, .05), 0 1px 1px rgba(18, 22, 33, .03);
  --sh-2: 0 10px 26px -10px rgba(18, 22, 33, .16), 0 2px 6px rgba(18, 22, 33, .04);
  --sh-3: 0 28px 64px -20px rgba(12, 16, 26, .38);

  --tabbar-h: 58px;
  --sidebar-w: 226px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f13;
    --bg-deep: #080a0d;
    --surface: #14171c;
    --surface-2: #191d23;
    --surface-3: #1f242b;
    --line: #262b33;
    --line-2: #343b45;
    --ink: #e9ebef;
    --ink-2: #a3aab5;
    --ink-3: #767d88;
    --ink-4: #5a616b;
    --accent: #7d99f8;
    --accent-soft: #1c2440;
    --accent-ink: #0c1020;
    --ok: #43c98c;
    --ok-soft: #10241c;
    --warn: #e0a83a;
    --warn-soft: #2a2110;
    --danger: #f87077;
    --danger-soft: #2a1416;
    --info: #7d99f8;
    --info-soft: #1c2440;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .5);
    --sh-2: 0 12px 30px -12px rgba(0, 0, 0, .7);
    --sh-3: 0 30px 70px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

html[data-theme="dark"] {
  --bg: #0d0f13;
  --bg-deep: #080a0d;
  --surface: #14171c;
  --surface-2: #191d23;
  --surface-3: #1f242b;
  --line: #262b33;
  --line-2: #343b45;
  --ink: #e9ebef;
  --ink-2: #a3aab5;
  --ink-3: #767d88;
  --ink-4: #5a616b;
  --accent: #7d99f8;
  --accent-soft: #1c2440;
  --accent-ink: #0c1020;
  --ok: #43c98c;
  --ok-soft: #10241c;
  --warn: #e0a83a;
  --warn-soft: #2a2110;
  --danger: #f87077;
  --danger-soft: #2a1416;
  --info: #7d99f8;
  --info-soft: #1c2440;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .5);
  --sh-2: 0 12px 30px -12px rgba(0, 0, 0, .7);
  --sh-3: 0 30px 70px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ─────────────── 2. reset ─────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fn-sans);
  font-size: var(--t-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; flex: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ─────────────── 3. 排版 ─────────────── */
.num {
  font-family: var(--fn-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--fn-mono); font-size: var(--t-2xs); }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.trunc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.label {
  font-size: var(--t-3xs);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.t-2xs { font-size: var(--t-2xs); }
.t-xs { font-size: var(--t-xs); }
.t-sm { font-size: var(--t-sm); }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

/* ─────────────── 4. 布局 ─────────────── */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--s6) var(--s5) var(--s5);
  box-shadow: var(--sh-2);
  animation: rise-in var(--dur-3) var(--ease-out) both;
}
.login-brand {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  margin-bottom: var(--s4);
}
.login-card h1 { font-size: var(--t-lg); letter-spacing: -.01em; }
.login-card > p { color: var(--ink-3); font-size: var(--t-xs); margin: var(--s1) 0 var(--s5); }
.login-err {
  margin-top: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--t-2xs);
}

.shell { min-height: 100dvh; }
.main { display: flex; flex-direction: column; min-height: 100dvh; }
.view {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s5) var(--s4) var(--s7);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .view { padding: var(--s6) var(--s6) var(--s8); }
  .main { min-height: 100dvh; }
}

/* 侧栏 */
.sidebar {
  display: none;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s5) var(--s3);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100dvh;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2); }
.sidebar-brand .mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex: none;
}
.sidebar-brand b { font-size: var(--t-sm); letter-spacing: -.01em; display: block; }
.sidebar-brand span { font-size: var(--t-3xs); color: var(--ink-3); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar-foot { margin-top: auto; }
@media (min-width: 1024px) { .sidebar { display: flex; } }

.navlink {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  position: relative;
  white-space: nowrap;
}
.navlink:hover { background: var(--surface-3); color: var(--ink); }
.navlink.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.navlink .badge-n {
  margin-left: auto;
  font-size: var(--t-3xs);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-title h2 { font-size: var(--t-lg); letter-spacing: -.015em; line-height: var(--lh-tight); }
.topbar-title p { font-size: var(--t-3xs); color: var(--ink-3); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
@media (min-width: 1024px) { .topbar { padding: var(--s4) var(--s6); } }

.hint { font-size: var(--t-3xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) { .hint { display: none; } }

/* 平板横向导航 */
.topnav {
  display: none;
  gap: var(--s1);
  overflow-x: auto;
  padding: var(--s2) var(--s4) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav .navlink { padding: var(--s2) var(--s3); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.topnav .navlink.on { background: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
@media (min-width: 641px) and (max-width: 1023px) { .topnav { display: flex; } }

/* 移动底部 Tab */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .navlink {
  flex-direction: column;
  gap: 3px;
  padding: var(--s2) 2px calc(var(--s2) + 2px);
  border-radius: 0;
  font-size: 9.5px;
  min-height: var(--tabbar-h);
  min-width: 0;
  justify-content: center;
  align-items: center;
  letter-spacing: -.02em;
}
.tabbar .navlink span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbar .navlink.on { background: transparent; color: var(--accent); }
.tabbar .navlink.on::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--accent);
}
@media (min-width: 641px) { .tabbar { display: none; } }
@media (max-width: 640px) { .view { padding-bottom: calc(var(--tabbar-h) + var(--s7)); } }

/* 栅格 */
.grid { display: grid; gap: var(--s3); }
.grid-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.grid-cards { grid-template-columns: 1fr; }
@media (min-width: 641px) {
  .grid-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
.split { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 900px) { .split-2 { grid-template-columns: 1.35fr 1fr; align-items: start; } }

.stack { display: flex; flex-direction: column; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row--tight { gap: var(--s1); }
.spacer { flex: 1; min-width: var(--s2); }

/* ─────────────── 5. 组件 ─────────────── */

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--sh-1);
}
.card--flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
}
.card--flush .card-head { padding: var(--s4) var(--s4) 0; margin-bottom: var(--s3); }
.card-head h3 { font-size: var(--t-sm); font-weight: 650; letter-spacing: -.01em; }
.card-head .sub { font-size: var(--t-3xs); color: var(--ink-3); }
.card-note {
  font-size: var(--t-3xs);
  color: var(--ink-3);
  line-height: var(--lh-snug);
  padding-top: var(--s2);
  border-top: 1px dashed var(--line);
  margin-top: var(--s3);
}

/* 指标 */
.metric {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  overflow: hidden;
  min-width: 0;
}
.metric-v {
  font-size: var(--t-lg);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.metric-l { font-size: var(--t-3xs); color: var(--ink-3); }
/* 概览页"领衔"指标：只保留左侧色条 + 主色数字来立层次，字号不再放大 */
.metric--hero {
  padding: var(--s3);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.metric--hero .metric-v { font-size: var(--t-xl); font-weight: 620; }
.metric--accent .metric-v { color: var(--accent); }
.metric--warn .metric-v { color: var(--warn); }
.metric--danger .metric-v { color: var(--danger); }
.metric--ok .metric-v { color: var(--ok); }
.metric-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: .0;
}
.metric--hero .metric-bar { opacity: 1; }
.metric--hero.metric--ok .metric-bar { background: var(--ok); }
.metric--hero.metric--danger .metric-bar { background: var(--danger); }
.metric--hero.metric--warn .metric-bar { background: var(--warn); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 36px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 26, 48, .18);
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--line)); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--sm { min-height: 30px; padding: 0 var(--s2); font-size: var(--t-2xs); border-radius: var(--r-xs); }
.btn--block { width: 100%; }
.btn--lg { min-height: 44px; font-size: var(--t-sm); padding: 0 var(--s5); }
.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
@media (max-width: 640px) { .btn { min-height: 40px; } .btn--sm { min-height: 34px; } }

/* 表单 */
.field { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s3); }
.field > .fl {
  font-size: var(--t-2xs);
  color: var(--ink-2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.field .fl .hint-inline { color: var(--ink-3); font-weight: 400; font-size: var(--t-3xs); }
.inp, .sel, .ta {
  width: 100%;
  min-height: 38px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--t-sm);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease);
}
.inp:hover, .sel:hover, .ta:hover { border-color: var(--ink-4); }
.inp:focus, .sel:focus, .ta:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.ta { min-height: 92px; resize: vertical; line-height: var(--lh-snug); font-family: var(--fn-mono); font-size: var(--t-xs); }
.sel {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(1em + 1px), calc(100% - 10px) calc(1em + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s7);
}
.inp--num { font-family: var(--fn-mono); font-variant-numeric: tabular-nums; }
.inp--mono { font-family: var(--fn-mono); font-size: var(--t-xs); }
.help { font-size: var(--t-3xs); color: var(--ink-3); line-height: var(--lh-snug); }
.form-help { font-size: var(--t-3xs); color: var(--ink-3); }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--line-2);
  transition: background var(--dur-2) var(--ease);
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .sw-label { font-size: var(--t-xs); }
.switch--row { width: 100%; justify-content: space-between; }

/* 徽章 / 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--t-3xs);
  font-weight: 600;
  line-height: 1.5;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--danger { background: var(--danger-soft); color: var(--danger); }
.tag--info { background: var(--info-soft); color: var(--info); }
.tag--line { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-4);
  flex: none;
  display: inline-block;
}
.dot--on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot--off { background: var(--ink-4); }
.dot--live { animation: pulse 2.4s var(--ease) infinite; }

/* 验证码 chip */
.code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--r-xs);
  background: var(--ok-soft);
  color: var(--ok);
  font-family: var(--fn-mono);
  font-weight: 700;
  font-size: var(--t-xs);
  letter-spacing: .06em;
  border: 1px solid color-mix(in srgb, var(--ok) 26%, transparent);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
}
.code:hover { filter: brightness(.96); transform: translateY(-1px); }
.code:active { transform: translateY(0) scale(.97); }
.code sup { font-size: 9px; opacity: .75; font-weight: 500; letter-spacing: 0; }

/* 信号条 */
.sig { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 12px; }
.sig i { width: 2.5px; border-radius: 1px; background: var(--line-2); display: block; }
.sig i:nth-child(1) { height: 4px; }
.sig i:nth-child(2) { height: 6.5px; }
.sig i:nth-child(3) { height: 9px; }
.sig i:nth-child(4) { height: 12px; }
.sig i.on { background: var(--ok); }
.sig.s2 i.on { background: var(--warn); }
.sig.s1 i.on { background: var(--danger); }

/* 列表 */
.list { display: flex; flex-direction: column; }
.list-item {
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  transition: background var(--dur-1) var(--ease);
}
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item--new { animation: flash-in var(--dur-3) var(--ease-out) both; }
.list-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.list-body { font-size: var(--t-sm); color: var(--ink); line-height: var(--lh-snug); }
.list-foot {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: var(--t-3xs);
  color: var(--ink-3);
}
.phone {
  font-family: var(--fn-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: .02em;
}
.phone--big { font-size: var(--t-xl); letter-spacing: .01em; }
.rail {
  border-left: 2px solid var(--line-2);
  padding-left: var(--s3);
  margin-left: -2px;
}
.rail--sms { border-color: var(--accent); }
.rail--call { border-color: var(--warn); }
.rail--rec { border-color: var(--ok); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: var(--t-xs); }
table.tb th {
  text-align: left;
  font-size: var(--t-3xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tb td {
  padding: var(--s3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.tb tr:last-child td { border-bottom: 0; }
table.tb tbody tr { transition: background var(--dur-1) var(--ease); }
table.tb tbody tr:hover { background: var(--surface-2); }
table.tb .kv { color: var(--ink-3); }

@media (max-width: 640px) {
  table.tb thead { display: none; }
  table.tb, table.tb tbody, table.tb tr, table.tb td { display: block; width: 100%; }
  table.tb tr {
    border-bottom: 1px solid var(--line);
    padding: var(--s2) 0;
  }
  table.tb tr:last-child { border-bottom: 0; }
  table.tb td {
    border: 0;
    padding: var(--s1) var(--s4);
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: var(--s2);
    align-items: baseline;
  }
  table.tb td::before {
    content: attr(data-l);
    font-size: var(--t-3xs);
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  table.tb td[data-l=""]::before { display: none; }
  table.tb td[data-l=""] { display: block; }
}

/* 空/骨架/加载 */
.empty {
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--t-sm);
}
.empty b { color: var(--ink-2); display: block; margin-bottom: var(--s1); font-size: var(--t-sm); }
.sk {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 37%, var(--surface-3) 63%);
  background-size: 300% 100%;
  animation: shimmer 1.3s var(--ease) infinite;
  height: 12px;
}
.sk-line { height: 12px; margin-bottom: var(--s2); }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-card { height: 74px; border-radius: var(--r-md); }
.spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin .7s linear infinite;
  flex: none;
  display: inline-block;
}

/* 分页 / 工具栏 */
.toolbar {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .grow { flex: 1; min-width: 160px; }
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-xs);
  font-size: var(--t-2xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 30px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--sh-1);
}
.seg button .n { color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: 4px; font-size: var(--t-3xs); }

/* 弹窗 */
dialog.modal {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  max-width: none;
  max-height: none;
}
dialog.modal::backdrop { background: rgba(10, 13, 20, .42); }
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-3);
  padding: var(--s5);
  overflow-y: auto;
}
dialog.modal {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  width: 100%;
}
.modal-panel { border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 88dvh; padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom)); }
dialog.modal[open] { animation: sheet-in var(--dur-3) var(--ease-out) both; }
dialog.modal[open]::backdrop { animation: fade-in var(--dur-2) var(--ease) both; }

@media (min-width: 641px) {
  dialog.modal { inset: 0; margin: auto; width: min(620px, 94vw); height: fit-content; }
  .modal-panel { border-radius: var(--r-lg); max-height: 86vh; }
  dialog.modal[open] { animation: pop-in var(--dur-2) var(--ease-out) both; }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.modal-head h3 { font-size: var(--t-lg); letter-spacing: -.015em; }
.modal-head p { font-size: var(--t-2xs); color: var(--ink-3); margin-top: 2px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-foot {
  display: flex;
  gap: var(--s2);
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.modal-foot .left { margin-right: auto; }

/* Toast */
.toast-wrap {
  position: fixed;
  z-index: 90;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 24px));
}
@media (min-width: 641px) {
  .toast-wrap { left: auto; right: var(--s5); bottom: var(--s5); transform: none; align-items: flex-end; }
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: 100%;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--t-2xs);
  box-shadow: var(--sh-2);
  animation: rise-in var(--dur-2) var(--ease-out) both;
}
.toast--ok { background: var(--ok); color: #fff; }
.toast--err { background: var(--danger); color: #fff; }
.toast.out { animation: fade-out var(--dur-2) var(--ease) both; }

/* 快捷操作条 */
.qbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.qbar-top { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 720px) { .qbar-top { grid-template-columns: 1fr 1fr; gap: var(--s4); } }
.qbar-summary {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}
.qbar-actions { display: flex; gap: var(--s2); margin-left: auto; }
@media (max-width: 640px) { .qbar-actions { margin-left: 0; width: 100%; } .qbar-actions .btn { flex: 1; } }

/* 文档块 */
.docs { display: flex; flex-direction: column; gap: var(--s3); }
.docs-group { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.docs-group > header {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--surface-3);
  font-size: var(--t-2xs);
  font-weight: 600;
}
.docs-group > header .spacer { flex: 1; }
.docs-group .docs-body { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.snippet {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s3);
  padding-right: 52px;
  font-family: var(--fn-mono);
  font-size: var(--t-3xs);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink-2);
  margin: 0;
}
.snippet .copy-btn, .snippet-wrap .copy-btn { position: absolute; top: var(--s2); right: var(--s2); }
.snippet-wrap { position: relative; }
.snippet b { color: var(--ink); font-weight: 600; }

/* 日志控制台 */
.console {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s3);
  max-height: 62vh;
  overflow: auto;
  font-family: var(--fn-mono);
  font-size: var(--t-3xs);
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  tab-size: 2;
}
.console .ln { display: block; padding: 0 2px; border-radius: 3px; }
.console .ln:hover { background: var(--surface-3); }

/* 统计条（心跳） */
.pulse-row {
  display: flex;
  gap: var(--s4);
  flex-wrap: wrap;
  font-size: var(--t-3xs);
  color: var(--ink-3);
}
.pulse-row b { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }

/* 设备卡 */
.dev { display: flex; flex-direction: column; gap: var(--s3); }
.dev-head { display: flex; align-items: flex-start; gap: var(--s3); flex-wrap: wrap; }
.dev-name { font-size: var(--t-sm); font-weight: 650; display: flex; align-items: center; gap: var(--s2); }
.dev-meta { display: flex; gap: var(--s3); flex-wrap: wrap; font-size: var(--t-3xs); color: var(--ink-3); }
.slot-chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.slot-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  min-width: 132px;
}
.slot-chip .n { font-size: var(--t-xs); color: var(--ink-3); }

/* 概览 · 设备卡片网格：一行多张，点卡片直接下发常用指令 */
.dev-grid {
  display: grid;
  gap: var(--s3);
  padding: 0 var(--s4) var(--s4);
  grid-template-columns: 1fr;
}
@media (min-width: 680px) { .dev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1020px) { .dev-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.dev-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-3) var(--ease), background var(--dur-3) var(--ease), transform var(--dur-3) var(--ease-out);
}
.dev-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--surface-3);
  transform: translateY(-1px);
}
.dev-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dev-card-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.dev-card-meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  font-size: var(--t-3xs);
  color: var(--ink-3);
}
.dev-card-slots { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); }
.dev-slot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.dev-slot-n { font-size: var(--t-3xs); color: var(--ink-3); }
.warn-strip {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--t-2xs);
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
}
.info-strip {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--info-soft);
  color: var(--info);
  font-size: var(--t-3xs);
  line-height: var(--lh-snug);
}

/* 音频 */
.audio-wrap { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
audio { height: 34px; max-width: 100%; border-radius: var(--r-pill); }
audio::-webkit-media-controls-panel { background: var(--surface-3); }

/* 规则 / 行内编辑 */
.kv-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); font-size: var(--t-2xs); align-items: baseline; }
.kv-grid dt { color: var(--ink-3); white-space: nowrap; }
.kv-grid dd { margin: 0; font-variant-numeric: tabular-nums; }

.group-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s2) 0 var(--s1);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
}
.group-head h4 { font-size: var(--t-2xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 650; }
.group-head .line { flex: 1; height: 1px; background: var(--line); }

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s2);
  padding: var(--s3) 0;
  border-bottom: 1px dashed var(--line);
}
.field-row:last-child { border-bottom: 0; }
@media (min-width: 720px) {
  .field-row { grid-template-columns: minmax(180px, 1.1fr) minmax(200px, 1fr); gap: var(--s4); align-items: start; }
}
.field-row.dirty { background: color-mix(in srgb, var(--warn-soft) 60%, transparent); border-radius: var(--r-sm); }
.field-name { display: flex; flex-direction: column; gap: 3px; }
.field-name b { font-size: var(--t-xs); font-weight: 600; }
.field-name .k { font-family: var(--fn-mono); font-size: 10px; color: var(--ink-4); }
.unit { color: var(--ink-3); font-size: var(--t-2xs); align-self: center; }
.inline-num { display: flex; align-items: center; gap: var(--s2); }

/* ─────────────── 6. 页面细节 ─────────────── */
.metric-grid-8 { display: grid; gap: var(--s2); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 641px) { .metric-grid-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); } }
@media (min-width: 1200px) { .metric-grid-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.metric-grid-8 + .metric-grid-8--tight { margin-top: var(--s3); }

.hero-grid { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  /* 4 张主卡一行排开：auto-fit 让平板是 2×2、桌面是 1×4，不会留孤行 */
  .hero-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

.msg-content {
  font-size: var(--t-sm);
  line-height: var(--lh-snug);
  color: var(--ink);
  word-break: break-word;
}
.msg-content mark {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}

.sticky-actions { position: sticky; bottom: 0; }

/* ─────────────── 7. 动效 ─────────────── */
@keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -20% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes flash-in {
  0% { opacity: 0; transform: translateY(-6px); background: var(--accent-soft); }
  60% { background: var(--accent-soft); }
  100% { opacity: 1; transform: none; background: transparent; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 42%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ok) 0%, transparent); }
}
.enter { animation: rise-in var(--dur-3) var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────────── 8. 打印与杂项 ─────────────── */
@media (max-width: 400px) {
  .view { padding-left: var(--s3); padding-right: var(--s3); }
  .card { padding: var(--s3); }
  .tabbar .navlink { font-size: 9px; }
  .phone--big { font-size: var(--t-lg); }
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
