/* ============================================================================
   跟单监控 · Design System v3
   深色「终端」主题 + 浅色主题；令牌 → 基础 → 布局 → 组件 → 图表 → 响应式
   说明：本文件在所有页面 <head> 中先于页面自有样式加载，
        页面级样式可安全覆盖这里的默认值。
   ========================================================================== */

/* ---------------------------------------------------------------- 1. 令牌 */
:root {
  color-scheme: dark;

  /* 底色层次 */
  --bg: #080b11;
  --bg-2: #0d121b;
  --panel: #111826;
  --panel-2: #17202f;
  --panel-3: #1d2839;
  --overlay: rgba(4, 7, 12, .72);

  /* 描边 */
  --border: rgba(148, 163, 184, .13);
  --border-strong: rgba(148, 163, 184, .26);
  --border-accent: rgba(91, 140, 255, .42);

  /* 文本 */
  --text: #e9eefb;
  --muted: #92a1b8;
  --faint: #64748b;
  --inverse: #0a0f18;

  /* 品牌与语义色 */
  --accent: #5b8cff;
  --accent-2: #2dd4bf;
  --accent-soft: rgba(91, 140, 255, .14);
  --accent-line: linear-gradient(135deg, #5b8cff, #2dd4bf);
  --green: #2ed47a;
  --green-soft: rgba(46, 212, 122, .13);
  --red: #ff5d7a;
  --red-soft: rgba(255, 93, 122, .13);
  --yellow: #f5b544;
  --yellow-soft: rgba(245, 181, 68, .14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, .14);

  /* 交互 */
  --row-hover: rgba(148, 163, 184, .06);
  --ring: 0 0 0 3px var(--accent-soft);
  --header-bg: rgba(9, 13, 20, .78);
  --glow-1: rgba(91, 140, 255, .16);
  --glow-2: rgba(45, 212, 191, .10);

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

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* 字号 */
  --fs-2xs: 11px;
  --fs-xs: 12.5px;
  --fs-sm: 13.5px;
  --fs-md: 14.5px;
  --fs-base: 15px;
  --fs-lg: 17px;
  --fs-xl: 21px;
  --fs-2xl: 27px;
  --fs-3xl: 34px;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, 'JetBrains Mono', Menlo,
    Consolas, 'Liberation Mono', monospace;

  /* 行高 / 动效 */
  --lh-tight: 1.25;
  --lh-normal: 1.55;
  --lh-relaxed: 1.8;
  --t-fast: .13s cubic-bezier(.4, 0, .2, 1);
  --t-base: .22s cubic-bezier(.4, 0, .2, 1);
  --t-slow: .42s cubic-bezier(.22, 1, .36, 1);

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, .75);
  --shadow-glow: 0 18px 40px -22px var(--accent);

  --sb-w: 236px;
  --top-h: 56px;
  --content-max: 1480px;

  /* 旧版设计令牌别名：h5 / 旧模板仍在引用，保持向后兼容 */
  --card: var(--panel);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --danger: var(--red);
  --radius: var(--radius-lg);
  --shadow: var(--shadow-md);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-2: #eaeef6;
  --panel: #ffffff;
  --panel-2: #f3f6fc;
  --panel-3: #e8edf7;
  --overlay: rgba(15, 23, 42, .42);

  --border: rgba(15, 23, 42, .10);
  --border-strong: rgba(15, 23, 42, .20);
  --border-accent: rgba(59, 116, 240, .38);

  --text: #16203a;
  --muted: #5b6b86;
  --faint: #8794ab;
  --inverse: #ffffff;

  --accent: #3b74f0;
  --accent-2: #0aa6a0;
  --accent-soft: rgba(59, 116, 240, .12);
  --green: #0f9d58;
  --green-soft: rgba(15, 157, 88, .12);
  --red: #e03e5c;
  --red-soft: rgba(224, 62, 92, .10);
  --yellow: #b57408;
  --yellow-soft: rgba(181, 116, 8, .12);
  --purple: #7c3aed;
  --purple-soft: rgba(124, 58, 237, .10);

  --row-hover: rgba(15, 23, 42, .035);
  --header-bg: rgba(255, 255, 255, .8);
  --glow-1: rgba(59, 116, 240, .10);
  --glow-2: rgba(10, 166, 160, .08);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 10px 30px -14px rgba(15, 23, 42, .22);
  --shadow-lg: 0 28px 70px -28px rgba(15, 23, 42, .28);
  --shadow-glow: 0 18px 40px -24px var(--accent);
}

/* ---------------------------------------------------------------- 2. 基础 */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 环境光 + 极细网格，制造纵深但不抢夺内容 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -8%, var(--glow-1), transparent 62%),
    radial-gradient(760px 460px at 94% -4%, var(--glow-2), transparent 60%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .35;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 50% -10%, #000 0%, transparent 68%);
  -webkit-mask-image: radial-gradient(ellipse at 50% -10%, #000 0%, transparent 68%);
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: var(--lh-tight); letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.15em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5px 6px;
  color: var(--text);
  white-space: nowrap;
}
kbd {
  font-size: var(--fs-2xs);
  padding: 2px 6px;
  color: var(--muted);
  background: var(--panel-3);
  box-shadow: inset 0 -1px 0 var(--border-strong);
}

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

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

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- 3. 布局 */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 60;
  width: var(--sb-w);
  display: flex;
  flex-direction: column;
  padding: 16px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--header-bg);
  border-right: 1px solid var(--border);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  transition: transform var(--t-base);
}

#sidebar .sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 16px;
  min-width: 0;
}
#sidebar .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--accent-line);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  box-shadow: var(--shadow-glow);
}
#sidebar .sb-title {
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sidebar .brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: .04em;
}
#sidebar .sb-btns { margin-left: auto; display: flex; gap: 4px; flex: 0 0 auto; }
#sidebar .sb-btns .icon-btn { padding: 4px 7px; font-size: 12px; border-radius: var(--radius-xs); }

#sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  margin: 0 -2px;
}
#sidebar nav::-webkit-scrollbar { width: 5px; }
#sidebar .nav-label {
  margin: 14px 8px 6px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
#sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 550;
  white-space: nowrap;
  transition: color var(--t-base), background var(--t-base);
}
#sidebar nav a .ic {
  width: 17px; height: 17px;
  flex: 0 0 auto;
  opacity: .85;
  stroke-width: 1.8;
}
#sidebar nav a .nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--panel-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
}
#sidebar nav a:hover { color: var(--text); background: var(--row-hover); }
#sidebar nav a:hover .ic { opacity: 1; }
#sidebar nav a.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--border-accent);
}
#sidebar nav a.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  transform: translateY(-50%);
  background: var(--accent-line);
}
#sidebar nav a.active .ic { color: var(--accent); opacity: 1; }
#sidebar nav a.active .nav-badge { background: var(--accent-soft); color: var(--accent); }

#sidebar .sb-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
#sidebar .sb-foot .menu-wrap { width: 100%; }
#sidebar .sb-foot .menu-wrap > button { width: 100%; justify-content: flex-start; }
#sidebar .sb-foot .menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; }
#sidebar .sb-foot .build {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: .04em;
}

#sbMask {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}
#sbMask.on { opacity: 1; visibility: visible; }

#sbFab {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 50;
  width: 40px; height: 40px;
  padding: 0;
  font-size: 16px;
}

main {
  position: relative;
  z-index: 1;
  margin-left: var(--sb-w);
  padding: var(--space-5) var(--space-6) var(--space-7);
  max-width: calc(var(--content-max) + var(--sb-w));
  animation: page-in var(--t-slow);
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* 页头 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.page-head .eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--faint);
  font-size: var(--fs-2xs);
  font-weight: 650;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.page-head h1 { font-size: var(--fs-2xl); letter-spacing: -.02em; }
.page-head .page-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: color var(--t-base), gap var(--t-base);
}
.back-link:hover { color: var(--text); gap: 9px; }

/* ---------------------------------------------------------------- 4. 组件 */
.panel {
  position: relative;
  margin-bottom: var(--space-4);
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 42%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel::before {
  content: '';
  position: absolute;
  left: 18px; right: 18px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}
.panel > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  font-size: var(--fs-lg);
  font-weight: 650;
}
.panel > h2::before {
  content: '';
  width: 3px; height: 16px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--accent-line);
}
.panel > h2 .count { color: var(--faint); font-size: var(--fs-xs); font-weight: 600; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 20px 20px 0; }

.subsection {
  padding: 16px;
  margin-top: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.subsection h4 {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  padding-left: 15px;
  font-size: var(--fs-md);
}
.subsection h4::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translateY(-50%);
}

/* 按钮 */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  min-width: 36px;
  padding: 8px 15px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0)), var(--accent);
  box-shadow: var(--shadow-glow);
  transition: transform var(--t-fast), filter var(--t-base), box-shadow var(--t-base),
    background var(--t-base), border-color var(--t-base), color var(--t-base);
}
button:hover,
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active,
.btn:active { transform: translateY(0) scale(.98); filter: brightness(.97); }
button:disabled,
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }

button.ghost,
.btn.ghost {
  color: var(--text);
  font-weight: 550;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.ghost:hover,
.btn.ghost:hover { border-color: var(--border-strong); filter: none; box-shadow: var(--shadow-sm); }
button.ghost.danger { color: var(--red); border-color: rgba(255, 93, 122, .4); background: var(--panel-2); }
button.ghost.danger:hover { background: var(--red-soft); border-color: rgba(255, 93, 122, .65); }
button.danger:not(.ghost):not(.menu-item) {
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0)), var(--red);
  box-shadow: 0 18px 40px -24px var(--red);
}
button.safeOn { background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0)), var(--accent); }
button.btn-sm { min-height: 30px; min-width: 30px; padding: 4px 11px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
button.icon-btn { padding: 5px 8px; font-size: var(--fs-xs); min-height: 0; min-width: 0; border-radius: var(--radius-sm); }
button.block { width: 100%; }

/* 表单 */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
select {
  min-height: 40px;
  cursor: pointer;
  background-color: var(--panel-2);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
select option { color: var(--text); background: var(--panel-2); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"]:focus-visible { box-shadow: none; }
textarea { resize: vertical; min-height: 84px; }

label { color: var(--muted); font-size: var(--fs-sm); }
.form-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}
.form-group {
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.form-group .form-group-title {
  margin-bottom: var(--space-2);
  color: var(--accent);
  font-size: var(--fs-md);
  font-weight: 650;
}
.field-hint { margin-top: 5px; color: var(--faint); font-size: var(--fs-xs); line-height: 1.5; }

/* 统计卡（旧接口，保留兼容） */
.stat-cards { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.stat-card {
  position: relative;
  min-width: 150px;
  padding: 12px 16px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: transform var(--t-base), border-color var(--t-base);
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent-line);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-card .label { margin-bottom: 4px; color: var(--muted); font-size: var(--fs-xs); }
.stat-card .value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .value.up { color: var(--green); }
.stat-card .value.down { color: var(--red); }

/* KPI 磁贴 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.kpi {
  position: relative;
  padding: 15px 16px 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), transparent 60%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-base), transform var(--t-base);
}
.kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi .k {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: var(--fs-2xs);
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.kpi .v {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi .v.pos { color: var(--green); }
.kpi .v.neg { color: var(--red); }
.kpi .v .unit { margin-left: 4px; color: var(--faint); font-size: 12px; font-weight: 500; }
.kpi .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.kpi .spark { height: 26px; margin-top: 6px; }

/* 徽标 / 状态 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.pill.ok { color: var(--green); background: var(--green-soft); border-color: rgba(46, 212, 122, .3); }
.pill.err { color: var(--red); background: var(--red-soft); border-color: rgba(255, 93, 122, .3); }
.pill.warn { color: var(--yellow); background: var(--yellow-soft); border-color: rgba(245, 181, 68, .3); }
.pill.brand { color: var(--accent); background: var(--accent-soft); border-color: var(--border-accent); }
.pill.purple { color: var(--purple); background: var(--purple-soft); border-color: rgba(167, 139, 250, .3); }
.pill.off { color: var(--faint); background: var(--panel-2); }
.pill.size-sm { padding: 2px 8px; font-size: 11px; }
.pill.size-md { padding: 3px 11px; font-size: var(--fs-sm); }
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); animation: pulse 2.4s ease-in-out infinite; }
.dot.warn { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }
.dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--green-soft); }
  50% { box-shadow: 0 0 0 6px rgba(46, 212, 122, .04); }
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 550;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.live-chip .dot { animation: pulse 2.4s ease-in-out infinite; }
.live-chip.paused .dot { animation: none; background: var(--faint); box-shadow: none; }

/* 表格 */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--bg-2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
tbody tr { transition: background var(--t-fast); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted, .muted { color: var(--muted); }
td.faint { color: var(--faint); }
table.zebra tbody tr:nth-child(even) { background: rgba(148, 163, 184, .025); }
table.sticky-head thead th { position: sticky; top: 0; }
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--text); }
table.sortable th .arrow { margin-left: 4px; opacity: .4; font-size: 9px; }
table.sortable th[aria-sort="ascending"] .arrow,
table.sortable th[aria-sort="descending"] .arrow { opacity: 1; color: var(--accent); }
.table-empty { padding: 38px 16px; text-align: center; color: var(--muted); }

/* 分段控件 / 页签 */
.seg {
  display: inline-flex;
  gap: 3px;
  max-width: 100%;
  padding: 3px;
  overflow-x: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .18);
}
.seg button {
  min-height: 0;
  min-width: 0;
  padding: 7px 16px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: none;
}
.seg button:hover { color: var(--text); background: var(--row-hover); filter: none; transform: none; box-shadow: none; }
.seg button.on {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0)), var(--accent);
  box-shadow: 0 10px 22px -14px var(--accent);
}
.seg button.on:hover { color: #fff; }
[data-theme="light"] .seg button.on { color: #fff; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--space-4); }
.tabs button {
  padding: 7px 16px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: none;
}
.tabs button:hover { color: var(--text); transform: none; filter: none; }
.tabs button.on,
.tabs button.safeOn {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0)), var(--accent);
  border-color: transparent;
}

/* 芯片 */
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-group.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: all var(--t-fast);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.chip.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0)), var(--accent);
  border-color: transparent;
  box-shadow: 0 10px 20px -14px var(--accent);
}
.chip .close { padding: 0 2px; font-weight: 700; opacity: .7; }
.chip .close:hover { opacity: 1; }
.chip.token { padding: 2px 8px 2px 10px; color: var(--accent); background: var(--accent-soft); border-color: var(--border-accent); }

/* 弹窗 / 抽屉 */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal-bg.active { display: flex; }
.modal {
  width: 760px;
  max-width: 94vw;
  max-height: 90vh;
  padding: 24px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--t-slow) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.975); }
  to { opacity: 1; transform: none; }
}
.modal h3 { margin: 0 0 14px; font-size: var(--fs-xl); }
.modal .row { display: flex; gap: 12px; margin-bottom: 12px; }
.modal .row > label { flex: 1; }
.modal .row > label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: var(--fs-sm); }
.modal .actions { margin-top: 18px; text-align: right; }
.modal .actions button { margin-left: 8px; }

dialog.sheet {
  width: min(560px, 94vw);
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }

/* Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 16px;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 550;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: toast-in var(--t-slow) both;
}
.toast::before {
  content: '';
  width: 7px; height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.toast.err { border-color: rgba(255, 93, 122, .42); }
.toast.err::before { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.toast.warn::before { background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-soft); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}
#toast { display: none; }
#toast.toast { display: flex; }

/* 骨架 / 空态 */
.skeleton {
  display: block;
  height: 14px;
  margin: 6px 0;
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--bg-2) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton.w-lg { width: 80%; }
.skeleton.w-md { width: 50%; }
.skeleton.w-sm { width: 25%; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--muted);
}
.empty-state .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  margin: 0 auto var(--space-3);
  color: var(--accent);
  font-size: 26px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  border-radius: 18px;
}
.empty-state .title { margin-bottom: 4px; color: var(--text); font-size: var(--fs-lg); font-weight: 650; }
.empty-state .desc { margin-bottom: var(--space-4); font-size: var(--fs-sm); }
.empty-state .action { display: inline-flex; }
.empty { padding: 20px 8px; text-align: center; color: var(--muted); }
.empty .hint { margin-top: 6px; }

/* 下拉菜单 */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  display: none;
  min-width: 248px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.menu.open { display: block; animation: menu-fade var(--t-base) both; }
@keyframes menu-fade {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 0;
  min-width: 0;
  padding: 9px 11px;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.menu-item:hover { background: var(--row-hover); filter: none; transform: none; box-shadow: none; }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red-soft); }
.menu-item input { flex: 1; width: auto; min-width: 0; }
.menu-item .menu-label { flex-shrink: 0; color: var(--muted); font-size: var(--fs-xs); }
.menu-role { display: flex; justify-content: center; padding: 6px 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }

/* 提示 / 说明块 */
.sub { color: var(--muted); font-size: var(--fs-sm); }
.hint { margin-top: 8px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.6; }
.callout {
  display: flex;
  gap: 12px;
  padding: 13px 15px;
  margin: 14px 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.6;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
}
.callout .ci { flex: 0 0 auto; color: var(--accent); font-size: 16px; line-height: 1.4; }
.callout strong { color: var(--text); }
.callout.warn { background: var(--yellow-soft); border-color: rgba(245, 181, 68, .32); }
.callout.warn .ci { color: var(--yellow); }
.callout.danger { background: var(--red-soft); border-color: rgba(255, 93, 122, .32); }
.callout.danger .ci { color: var(--red); }
.callout.ok { background: var(--green-soft); border-color: rgba(46, 212, 122, .3); }
.callout.ok .ci { color: var(--green); }

/* 账号卡（mytrade 旧接口） */
.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  transition: background var(--t-base), border-color var(--t-base);
}
.account-card:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.account-card:last-child { border-bottom: 1px solid var(--border); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.account-card:hover:not(.active) { background: var(--row-hover); }
.account-card.active { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); cursor: default; }
.account-card .avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--panel-2), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.account-card.active .avatar { color: #fff; background: var(--accent-line); border-color: transparent; }
.account-card .info { flex: 1; min-width: 0; }
.account-card .info .name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-md); font-weight: 650; }
.account-card .info .meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 3px; color: var(--muted); font-size: var(--fs-xs); }
.account-card .actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tk-badge {
  display: inline-block;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.account-card.active .tk-badge.ex { color: var(--accent); background: var(--accent-soft); border-color: var(--border-accent); }

/* 持仓行（index / h5 旧接口） */
.pos-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: nowrap; font-size: var(--fs-sm); line-height: 1.8; }
.pos-line.wrap { flex-wrap: wrap; gap: 8px; line-height: var(--lh-relaxed); }
.pos-line code { padding: 2px 7px; font-size: var(--fs-xs); }

/* 数值 */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pos-text { color: var(--green); }
.neg-text { color: var(--red); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.toolbar .search {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
}
.toolbar .search input { padding-left: 34px; }
.toolbar .search svg {
  position: absolute;
  left: 11px; top: 50%;
  width: 15px; height: 15px;
  color: var(--faint);
  transform: translateY(-50%);
  pointer-events: none;
}
.toolbar .spacer { flex: 1; }
.toolbar .field {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--faint);
  font-size: var(--fs-xs);
}
.toolbar .field select { min-width: 104px; min-height: 34px; padding: 4px 30px 4px 10px; font-size: var(--fs-xs); }

/* 信号卡网格 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(322px, 1fr));
  gap: var(--space-3);
  align-items: start;
}
.cards.cols-2 { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.mcol { display: contents; }

.tcard {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 15px 15px 13px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, .022), transparent 55%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform var(--t-fast), border-color var(--t-base), box-shadow var(--t-base);
  animation: fade-in var(--t-slow) both;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.tcard:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.tcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tcard.static { cursor: default; }
.tcard.static:hover { transform: none; box-shadow: none; border-color: var(--border); }
.tc-head { display: flex; align-items: flex-start; gap: 11px; }
.tc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  background: var(--accent-line);
  border-radius: 11px;
  box-shadow: 0 10px 22px -14px var(--accent);
}
.tc-avatar.purple { background: linear-gradient(135deg, var(--purple), var(--accent-2)); box-shadow: 0 10px 22px -14px var(--purple); }
.tc-title { flex: 1; min-width: 0; }
.tc-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-md); font-weight: 650; overflow: hidden; }
.tc-name .star { color: var(--yellow); }
.tc-sub {
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: var(--fs-2xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tc-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 9px 11px;
  margin: 12px 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tc-metrics.m4 { grid-template-columns: repeat(4, 1fr); }
.tm .k { margin-bottom: 2px; color: var(--faint); font-size: 10.5px; letter-spacing: .04em; white-space: nowrap; }
.tm .v {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tc-pos { display: flex; flex-direction: column; gap: 0; min-height: 22px; }
.pos-row { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.pos-row:last-child { border-bottom: 0; }
.pos-row .pos-line { justify-content: space-between; align-items: center; gap: 10px; }
.pos-l { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.pos-r { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; }
.pos-pnl { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-roi { font-family: var(--font-mono); font-size: 11px; opacity: .85; }
.pos-sub { margin-top: 2px; color: var(--faint); font-size: 11px; }
.pos-sum {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 2px 6px;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.pos-sum .num { font-weight: 650; }
.tc-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 11px;
  margin-top: 11px;
  border-top: 1px solid var(--border);
}
.tc-empty { color: var(--faint); font-size: var(--fs-xs); }
.tc-flag { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tc-flag .pill { font-size: 10.5px; }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.pager .info { color: var(--faint); font-size: var(--fs-xs); }
.pager .pages { display: flex; gap: 4px; }
.pager .pg {
  min-width: 30px;
  min-height: 30px;
  padding: 4px 9px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.pager .pg:hover { color: var(--text); border-color: var(--border-strong); transform: none; filter: none; }
.pager .pg.on { color: #fff; background: var(--accent); border-color: transparent; }

/* ---------------------------------------------------------------- 5. 图表 */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-text { fill: var(--faint); font-family: var(--font-mono); font-size: 10px; }
.chart .series { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-accent { stroke: var(--accent); }
.chart .series-green { stroke: var(--green); }
.chart .series-red { stroke: var(--red); }
.chart .area { opacity: .9; }
.chart .marker { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; }
.chart .dot-hover { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.chart .crosshair { pointer-events: none; opacity: 0; transition: opacity var(--t-fast); }
.chart:hover .crosshair { opacity: 1; }
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 116px;
  padding: 7px 10px;
  pointer-events: none;
  color: var(--text);
  font-size: var(--fs-xs);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity var(--t-fast);
}
.chart-tip.on { opacity: 1; }
.chart-tip .tip-k { color: var(--faint); font-size: 10.5px; }
.chart-tip .tip-v { font-family: var(--font-mono); font-weight: 650; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: var(--fs-xs); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 9px; height: 3px; border-radius: 2px; background: var(--accent); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 78px 1fr 74px; gap: 10px; align-items: center; font-size: var(--fs-xs); }
.bar-row .bl { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 8px; overflow: hidden; background: var(--bg-2); border-radius: 99px; }
.bar-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 99px; background: var(--accent); }
.bar-fill.green { background: linear-gradient(90deg, rgba(46, 212, 122, .5), var(--green)); }
.bar-fill.red { background: linear-gradient(90deg, rgba(255, 93, 122, .5), var(--red)); }
.bar-row .bv { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 132px; height: 132px; flex: 0 0 auto; }
.donut circle { fill: none; stroke-width: 12; }
.donut .trk { stroke: var(--bg-2); }
.donut text { fill: var(--text); font-family: var(--font-mono); font-weight: 650; }
.donut .cap { fill: var(--faint); font-family: var(--font-sans); font-size: 9px; letter-spacing: .08em; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-xs); }
.donut-legend .row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.donut-legend .sw { width: 8px; height: 8px; border-radius: 3px; }
.donut-legend .val { margin-left: auto; color: var(--text); font-family: var(--font-mono); }

/* 进度条（额度等） */
.meter { height: 7px; overflow: hidden; background: var(--bg-2); border-radius: 99px; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--accent-line); }

/* 头像组 */
.avatars { display: flex; }
.avatars .av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  margin-left: -7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: var(--panel-3);
  border: 2px solid var(--panel);
  border-radius: 50%;
}
.avatars .av:first-child { margin-left: 0; }

/* 键值行 */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: var(--fs-sm); }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; color: var(--text); font-family: var(--font-mono); text-align: right; }

/* 命令面板 */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.cmdk.on { display: flex; }
.cmdk-box {
  width: min(560px, 92vw);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--t-base) both;
}
.cmdk-box input {
  padding: 15px 17px;
  font-size: var(--fs-md);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.cmdk-box input:focus { box-shadow: none; }
.cmdk-list { max-height: 52vh; overflow: auto; padding: 6px; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.cmdk-item .k2 { margin-left: auto; color: var(--faint); font-size: 11px; }
.cmdk-item.on,
.cmdk-item:hover { background: var(--accent-soft); filter: none; transform: none; box-shadow: none; }
.cmdk-empty { padding: 22px; color: var(--faint); font-size: var(--fs-sm); text-align: center; }

/* 工具类 */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.grow { flex: 1; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.fs-xs { font-size: var(--fs-xs); }
.fs-sm { font-size: var(--fs-sm); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* 滚动渐隐提示（横向表格） */
.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------------- 6. 响应式 */
@media (max-width: 1180px) {
  main { padding: var(--space-4) var(--space-4) var(--space-6); }
  :root { --sb-w: 214px; }
}
@media (max-width: 920px) {
  #sidebar { transform: translateX(-100%); box-shadow: none; }
  #sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  #sbFab { display: inline-flex; }
  main { margin-left: 0; padding: 60px 14px var(--space-6); }
  .page-head { margin-top: 4px; }
  .panel { padding: 16px; border-radius: var(--radius-md); }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .cmdk { padding-top: 8vh; }
}
@media (max-width: 640px) {
  :root { --fs-base: 14.5px; --fs-2xl: 23px; --fs-3xl: 28px; }
  body::after { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px 12px 11px; }
  .kpi .v { font-size: 20px; }
  .cards { grid-template-columns: 1fr; }
  .tc-metrics.m4 { grid-template-columns: repeat(2, 1fr); }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar .field { flex: 1; }
  .toolbar .field select { width: 100%; }
  .panel.flush > h2 { padding: 16px 16px 0; }
  .pager { justify-content: space-between; }
  .modal { padding: 18px; }
  .modal .row { flex-direction: column; gap: 10px; }
  th, td { padding: 9px 11px; }
  .table-wrap table { min-width: 560px; }
  .donut-wrap { justify-content: center; }
}

/* ---------------------------------------------------------------- 7. 打印 */
@media print {
  #sidebar, #sbFab, #sbMask, .toast, .page-actions, .toolbar, .cmdk { display: none !important; }
  body { background: #fff; color: #111; }
  body::before, body::after { display: none; }
  main { margin: 0; padding: 0; max-width: none; }
  .panel, .kpi, .tcard { break-inside: avoid; box-shadow: none; border-color: #ddd; background: #fff; }
  th { background: #f5f5f5; position: static; }
  a { color: #111; }
}
