/* ==========================================================================
   NexAlpha 商业级后台设计系统（v3）
   原则：类名是接口——保持既有类名不变，app.js 渲染输出无需改动。
   设计令牌集中在 :root，换肤只改变量。
   对标：Stripe Dashboard / Linear / Bloomberg Terminal / Vercel
   ========================================================================== */

/* ==========================================================================
   设计令牌
   ========================================================================== */

:root {
  /* --- 背景层级：纯白基底 --- */
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --surface-hover: #f5f5f5;

  /* --- 边框 --- */
  --line: #e5e7eb;
  --line-soft: #f0f0f0;
  --line-strong: #d4d4d8;
  --bg-inverse: #09090b;

  /* --- 文字层级 --- */
  --text: #09090b;
  --text-2: #3f3f46;
  --text-3: #71717a;
  --muted: #a1a1aa;
  --faint: #d4d4d8;

  /* --- 品牌色 --- */
  --accent: #2563eb;
  --accent-2: #0891b2;
  --accent-3: #4f46e5;
  --accent-soft: rgba(37, 99, 235, 0.07);
  --accent-soft-2: rgba(8, 145, 178, 0.07);

  /* --- 主按钮色：墨黑 --- */
  --btn-primary: #18181b;
  --btn-primary-hover: #000000;

  /* --- 语义色 --- */
  --up: #dc2626;
  --down: #059669;
  --up-soft: rgba(220, 38, 38, 0.07);
  --down-soft: rgba(5, 150, 105, 0.07);

  /* --- 状态色 --- */
  --warn: #d97706;
  --ok: #059669;
  --danger: #dc2626;
  --warn-soft: rgba(217, 119, 6, 0.08);
  --ok-soft: rgba(5, 150, 105, 0.08);
  --danger-soft: rgba(220, 38, 38, 0.06);

  /* --- 几何 --- */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* --- 阴影：极简平层 --- */
  --shadow-xs: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-sm: 0 1px 3px rgba(9, 9, 11, 0.05), 0 1px 2px rgba(9, 9, 11, 0.03);
  --shadow-md: 0 4px 12px rgba(9, 9, 11, 0.06);
  --shadow-lg: 0 10px 24px rgba(9, 9, 11, 0.08);
  --shadow-xl: 0 20px 40px rgba(9, 9, 11, 0.1);
  --shadow-glow: 0 0 0 3px rgba(9, 9, 11, 0.05);

  /* --- 动效 --- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.18s;
  --dur-fast: 0.1s;
  --dur-slow: 0.3s;

  /* --- 布局 --- */
  --sidebar-w: 248px;
  --topbar-h: 58px;

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

  /* --- 间距刻度 --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg: #09090b;
  --bg-soft: #0c0c0f;
  --surface: #141417;
  --surface-2: #18181c;
  --surface-3: #1f1f25;
  --surface-hover: #1c1c21;

  --line: #27272e;
  --line-soft: #1c1c21;
  --line-strong: #3a3a44;
  --bg-inverse: #0a0a0f;

  --text: #fafafa;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;
  --muted: #71717a;
  --faint: #52525b;

  --accent: #60a5fa;
  --accent-2: #22d3ee;
  --accent-3: #818cf8;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --accent-soft-2: rgba(34, 211, 238, 0.1);

  --btn-primary: #f4f4f5;
  --btn-primary-hover: #ffffff;

  --up: #f87171;
  --down: #34d399;
  --up-soft: rgba(248, 113, 113, 0.12);
  --down-soft: rgba(52, 211, 153, 0.12);

  --warn: #fbbf24;
  --ok: #34d399;
  --danger: #f87171;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --ok-soft: rgba(52, 211, 153, 0.12);
  --danger-soft: rgba(248, 113, 113, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* ==========================================================================
   基础
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}
/* 主题切换时颜色平滑过渡：只过渡颜色/背景/边框/阴影，避免布局抖动 */
body.theme-transition,
body.theme-transition *,
body.theme-transition *::before,
body.theme-transition *::after {
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease),
              color 0.3s var(--ease), fill 0.3s var(--ease), stroke 0.3s var(--ease),
              box-shadow 0.3s var(--ease) !important;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; color: var(--text-2); }
h4 { font-size: 12.5px; color: var(--text-3); }

a { color: var(--accent); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--accent-3); }

/* 文本选择 */
::selection { background: var(--accent-soft); color: var(--text); }

code, .num, .kpi strong, td.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-warn { color: var(--warn); }
.big { font-size: 15px; }
[hidden] { display: none !important; }

/* 滚动条：纤细、克制 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background var(--dur) var(--ease);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* 焦点环：仅键盘导航时显示 */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   布局骨架：左侧栏 + 内容列
   ========================================================================== */

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* 网格项默认 min-width:auto 会被表格/长文本的 min-content 撑宽，
   窄屏下整页出现横向滚动。显式归零，让内部的 .table-wrap 自己滚。 */
#main,
.topbar {
  min-width: 0;
}

/* --- 侧边栏 ---------------------------------------------------------- */

.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 40;
}
.sidebar::before {
  content: "";
  position: absolute;
  right: -1px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line) 10%, var(--line) 90%, transparent);
  pointer-events: none;
}

.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); background-clip: padding-box; }

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: var(--surface);
  background: var(--btn-primary);
  flex-shrink: 0;
  position: relative;
  transition: transform var(--dur) var(--ease);
}
.logo:hover { transform: scale(1.04); }
.logo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent 55%);
  pointer-events: none;
}
.brand h1 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand .muted { font-size: 11px; margin: 1px 0 0; color: var(--muted); letter-spacing: 0.02em; }

.sidebar .nav-group {
  padding: 18px 18px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
  position: relative;
}
.sidebar .nav-group:not(:first-of-type)::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 18px;
  right: 18px;
  height: 1px;
  background: var(--line-soft);
}

/* 导航项 */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 10px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  text-align: left;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab:active { transform: scale(0.98); }
.tab.active {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
}
.tab.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  border-radius: 1px;
  background: var(--btn-primary);
}
.tab .tab-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--dur) var(--ease);
}
.tab:hover .tab-icon { opacity: 0.9; }
.tab.active .tab-icon { opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 14px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 12px;
}
.sidebar-foot .conn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-foot .foot-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-foot .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar-foot .pill:hover { color: var(--text-2); }
.sidebar-foot .pill.env {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.sidebar-foot .version {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}
.token-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.token-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}
.token-btn:active { transform: scale(0.97); }
.token-btn svg { flex-shrink: 0; }

/* --- 顶栏 ------------------------------------------------------------ */

.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.topbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--scroll-progress, 0%);
  background: var(--btn-primary);
  transition: width 0.1s linear;
  z-index: 1;
}
.topbar .page-title {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
}
.topbar .spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .clock {
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  padding: 5px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* 通知铃与面板 */
.bell-wrap { position: relative; }
.bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.bell-btn:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
.bell-btn:active { transform: scale(0.95); }
.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--surface);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--surface);
  animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.notif-panel {
  position: absolute;
  right: 0;
  top: 48px;
  width: 380px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  z-index: 60;
  animation: panel-in 0.2s var(--ease-out);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.notif-panel .notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
  backdrop-filter: blur(8px);
}
.notif-title { font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
.notif-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  cursor: default;
  transition: background var(--dur) var(--ease);
  animation: notif-in 0.25s var(--ease-out) both;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item:last-child { border-bottom: 0; }
.notif-item .n-title { font-size: 13px; font-weight: 600; color: var(--text); }
.notif-item .n-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.notif-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-icon {
  width: 28px;
  height: 28px;
  opacity: 0.5;
}
.check-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  color: var(--ok);
}
.mini-icon {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
  margin: 0 1px;
  display: inline-block;
}
.mini-icon.ok { color: var(--ok); }
.mini-icon.err { color: var(--down); }
@keyframes notif-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

/* --- 主内容区 --------------------------------------------------------- */

#main {
  grid-area: main;
  padding: 24px 28px 48px;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg);
}

.view { display: none; }
.view.active { display: block; animation: view-in 0.28s var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   组件
   ========================================================================== */

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease-out);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  pointer-events: none;
}
.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* 视图内卡片依次淡入：比同时出现更有呼吸感 */
.view.active .card {
  animation: card-in 0.4s var(--ease-out) both;
}
.view.active .card:nth-child(1) { animation-delay: 0.02s; }
.view.active .card:nth-child(2) { animation-delay: 0.05s; }
.view.active .card:nth-child(3) { animation-delay: 0.08s; }
.view.active .card:nth-child(4) { animation-delay: 0.11s; }
.view.active .card:nth-child(5) { animation-delay: 0.14s; }
.view.active .card:nth-child(6) { animation-delay: 0.17s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view.active .card, .kpi-grid .card.kpi, .table-anim tbody tr { animation: none !important; }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.card-head h2::before {
  content: "";
  width: 2px;
  height: 14px;
  border-radius: 1px;
  background: var(--text-3);
  display: inline-block;
  flex-shrink: 0;
}
.card-head .muted { font-size: 12px; }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-grid.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid .card.kpi { animation: kpi-in 0.4s var(--ease-out) both; }
.kpi-grid .card.kpi:nth-child(1) { animation-delay: 0.02s; }
.kpi-grid .card.kpi:nth-child(2) { animation-delay: 0.06s; }
.kpi-grid .card.kpi:nth-child(3) { animation-delay: 0.10s; }
.kpi-grid .card.kpi:nth-child(4) { animation-delay: 0.14s; }
.kpi-grid .card.kpi:nth-child(5) { animation-delay: 0.18s; }
.kpi-grid .card.kpi:nth-child(6) { animation-delay: 0.22s; }
@keyframes kpi-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kpi:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.card.kpi {
  position: relative;
  overflow: hidden;
  padding-left: 20px;
}
.card.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--btn-primary);
  opacity: 0.7;
}
.card.kpi[data-accent="up"]::before { background: var(--up); }
.card.kpi[data-accent="down"]::before { background: var(--down); }
.card.kpi[data-accent="warn"]::before { background: var(--warn); }
.card.kpi[data-accent="ok"]::before { background: var(--ok); }
.card.kpi .kpi-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.card.kpi[data-accent="up"] .kpi-icon { background: var(--up-soft); color: var(--up); }
.card.kpi[data-accent="down"] .kpi-icon { background: var(--down-soft); color: var(--down); }
.card.kpi[data-accent="warn"] .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.card.kpi[data-accent="ok"] .kpi-icon { background: var(--ok-soft); color: var(--ok); }

.kpi .kpi-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.kpi strong {
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 2px;
  transition: color var(--dur) var(--ease);
}
.kpi strong.flash-up, .flash-up { animation: flash-up 0.8s var(--ease-out); }
.kpi strong.flash-down, .flash-down { animation: flash-down 0.8s var(--ease-out); }
@keyframes flash-up {
  0% { color: var(--up); transform: scale(1.05); }
  100% { color: inherit; transform: scale(1); }
}
@keyframes flash-down {
  0% { color: var(--down); transform: scale(0.97); }
  100% { color: inherit; transform: scale(1); }
}
.kpi small { font-size: 11.5px; color: var(--muted); }

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
/* 网格项默认 min-width:auto 会被长错误码（如 MARKET_DEPTH_ENABLED=true）顶宽 */
.metric-row > * { min-width: 0; overflow-wrap: anywhere; }
.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease-out);
}
.metric:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); transform: translateY(-1px); }
.metric .kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.metric strong { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

/* 徽章 / 状态 */
.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.badge.big { font-size: 14px; padding: 6px 15px; }
.badge.ok, .pill.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.badge.bad, .pill.bad { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.badge.warn, .pill.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.badge.info, .pill.info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.badge.pos, .pill.pos { background: var(--up-soft); color: var(--up); border-color: color-mix(in srgb, var(--up) 20%, transparent); }
.badge.neg, .pill.neg { background: var(--down-soft); color: var(--down); border-color: color-mix(in srgb, var(--down) 20%, transparent); }
.badge:not(.ok):not(.bad):not(.warn):not(.info):not(.pos):not(.neg),
.pill:not(.ok):not(.bad):not(.warn):not(.info) {
  background: var(--surface-3); color: var(--text-2); border-color: var(--line);
}
.pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.85;
}
.pill.ok .dot { animation: dot-pulse 2s ease-in-out infinite; }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 按钮 */
button, .btn {
  font: inherit;
  border-radius: 10px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease-out);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 8px 15px;
  font-weight: 500;
}
button:hover, .btn:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
button:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost, button.ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 8px 15px;
  font-weight: 500;
}
.ghost:hover, button.ghost:hover { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
.ghost.small, button.ghost.small { padding: 5px 11px; font-size: 12px; }

button.primary, .btn.primary {
  background: var(--btn-primary);
  border: 1px solid var(--btn-primary);
  color: var(--surface);
  padding: 9px 18px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}
button.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), transparent 50%);
  opacity: 0.6;
  pointer-events: none;
}
button.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); box-shadow: var(--shadow-sm); color: var(--surface); }
button.primary:active { transform: scale(0.97); }

button.danger, .btn.danger {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--danger);
  padding: 8px 16px;
  font-weight: 600;
}
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
button.armed {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent);
}

button:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

button.is-loading, .btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
button.is-loading::after, .btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  color: inherit;
}
button.primary.is-loading::after, .btn.primary.is-loading::after {
  border-color: var(--surface);
  border-right-color: transparent;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* 主操作按钮：页面里最重要的动作 */
#btn-decide, #btn-replay, #btn-run-decide, #btn-refresh-news, #btn-news-refresh {
  background: var(--btn-primary);
  border: 1px solid var(--btn-primary);
  color: var(--surface);
  font-weight: 650;
  padding: 9px 20px;
  position: relative;
  overflow: hidden;
}
#btn-decide::after, #btn-replay::after, #btn-run-decide::after,
#btn-refresh-news::after, #btn-news-refresh::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), transparent 50%);
  opacity: 0.6;
  pointer-events: none;
}
#btn-decide:hover, #btn-replay:hover, #btn-run-decide:hover,
#btn-refresh-news:hover, #btn-news-refresh:hover {
  background: var(--btn-primary-hover);
  color: var(--surface);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* 表单 */
input, select, textarea {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

.form-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.form-row label { min-width: 90px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.inline input { min-width: 0; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-2); }
.checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
  color: var(--text);
}

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); position: relative; }
.table-wrap.compact { border: none; }
.table-wrap.scroll-x {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 11px 14px;
  color: var(--text-3);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  box-shadow: 0 1px 0 var(--line);
}
th:hover { background: var(--surface-3); color: var(--text); }
th .sort-arrow {
  display: inline-block;
  margin-left: 5px;
  font-size: 9px;
  color: var(--accent);
  opacity: 0.9;
  transition: transform var(--dur-fast) var(--ease);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
/* 首列通常是时间/代码，换行会让整行高度跳动 */
.table-wrap td:first-child { white-space: nowrap; }
tbody tr {
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  cursor: pointer;
  position: relative;
}
tbody tr:hover { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
tbody tr:active { background: var(--surface-3); }
tbody tr:last-child td { border-bottom: 0; }
tbody td { transition: border-color var(--dur) var(--ease); }
tbody tr:hover td { border-bottom-color: var(--line); }
tbody tr:has(td.muted) { cursor: default; }
tbody tr:has(td.muted):hover { background: transparent; }

/* 表格行交错淡入：数据加载时的细腻进场 */
.table-anim tbody tr {
  animation: row-in 0.32s var(--ease-out) both;
}
.table-anim tbody tr:nth-child(1) { animation-delay: 0.01s; }
.table-anim tbody tr:nth-child(2) { animation-delay: 0.03s; }
.table-anim tbody tr:nth-child(3) { animation-delay: 0.05s; }
.table-anim tbody tr:nth-child(4) { animation-delay: 0.07s; }
.table-anim tbody tr:nth-child(5) { animation-delay: 0.09s; }
.table-anim tbody tr:nth-child(6) { animation-delay: 0.11s; }
.table-anim tbody tr:nth-child(7) { animation-delay: 0.13s; }
.table-anim tbody tr:nth-child(8) { animation-delay: 0.15s; }
.table-anim tbody tr:nth-child(n+9) { animation-delay: 0.17s; }
@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
tr.row-active { background: var(--accent-soft) !important; }
tr.row-active:hover { background: var(--accent-soft) !important; }
tr.row-best { background: var(--ok-soft) !important; }
tr.row-bid { background: var(--up-soft); }
tr.row-bid:hover { background: color-mix(in srgb, var(--up) 12%, transparent); }
tr.row-ask { background: var(--down-soft); }
tr.row-ask:hover { background: color-mix(in srgb, var(--down) 12%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td:first-child { font-weight: 550; }
td .badge { min-width: 52px; justify-content: center; }

.pos { color: var(--up); }
.neg { color: var(--down); }
/* 状态语义色：不要复用涨跌色，否则「熔断正常」会显示成红色 */
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--danger); }

/* 进度条 */
.bar { position: relative; background: var(--surface-3); border-radius: 999px; height: 8px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(9, 9, 11, 0.06); }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s var(--ease-out); position: relative; }
.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent 50%);
  pointer-events: none;
}
.bar-fill.ok { background: var(--btn-primary); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--danger); }
.bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-wrap .bar { flex: 1; min-width: 40px; }
.bar-label {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bar-row { display: flex; align-items: center; gap: 12px; margin: 7px 0; }
.bar-row .bar-name { flex: 0 0 120px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.bar-row .bar-wrap { flex: 1; }
.bar-row .bar-label { min-width: 56px; text-align: right; }
.bar-row .num { min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-stack { display: flex; flex-direction: column; gap: 4px; }
.heat-stack { display: flex; flex-direction: column; gap: 2px; }

/* 提示 */
.note {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
}
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-left-color: var(--danger); background: var(--danger-soft); }
.note small { color: var(--muted); }

/* 横幅 */
.banner {
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.banner.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.banner .pill { flex-shrink: 0; }
.banner strong { display: block; font-size: 14px; margin-bottom: 2px; font-weight: 650; }
.banner p { margin: 0; color: var(--text-2); font-size: 13px; }
.banner .muted.small { color: var(--text-3); }
.ops-banner-btn { margin-left: auto; flex-shrink: 0; }

/* 运维：自检清单 */
.ops-checks { display: flex; flex-direction: column; }
.ops-check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.ops-check:last-child { border-bottom: 0; }
.ops-check-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.ops-check-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.ops-check-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.ops-check-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.ops-check-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ops-check-main strong { font-size: 13px; font-weight: 600; color: var(--text); }
.ops-check-main .small { overflow-wrap: anywhere; }
.ops-danger { border-color: color-mix(in srgb, var(--danger) 22%, var(--line)); }
.ops-danger .card-head h2 { color: var(--danger); }
.ops-danger .card-head h2::before { background: var(--danger); }
@media (max-width: 760px) {
  .ops-check { align-items: flex-start; }
  .ops-check .pill { margin-top: 1px; }
}

/* 网络错误横幅 */
.net-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  margin-bottom: 18px;
  animation: banner-in 0.3s var(--ease-out);
}
.net-banner-text { flex: 1; font-size: 13.5px; color: var(--text); }
.net-banner .badge { flex-shrink: 0; }
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* 加载进度条 */
.load-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 100;
  background: linear-gradient(90deg, transparent, var(--btn-primary), var(--line-strong), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: load-slide 1.1s ease-in-out infinite;
}
@keyframes load-slide {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

/* 骨架屏占位 */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 通用空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--faint);
  margin-bottom: 4px;
}
.empty-state .empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0;
}
.empty-state .empty-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  max-width: 360px;
  line-height: 1.5;
}
tbody td.muted { color: var(--muted); text-align: center; padding: 40px 16px; cursor: default; }
tbody td.muted .empty-state {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0.7;
}
tbody td.muted .empty-state svg { width: 26px; height: 26px; opacity: 0.5; }
tbody td.muted .empty-state span { font-size: 13px; font-style: italic; }

/* Toast */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 120;
  max-width: 400px;
}
.toast {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 13px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  color: var(--text);
  animation: toast-in 0.3s var(--ease-out);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: default;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.toast:hover { box-shadow: var(--shadow-xl); transform: translateX(-2px); }
.toast:active { transform: translateX(0) scale(0.99); }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(40px) scale(0.95); }
}

/* 原生对话框：告别浏览器默认白底灰边 */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xl);
  max-width: min(92vw, 440px);
  width: 100%;
  animation: dialog-in 0.22s var(--ease-out);
}
dialog::backdrop {
  background: color-mix(in srgb, var(--bg-inverse) 50%, transparent);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  animation: backdrop-in 0.2s var(--ease-out);
}
dialog > form { padding: 26px; }
dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: center;
  margin: 4px 0;
  font-size: 13px;
}
.shortcut-grid kbd {
  justify-self: start;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  min-width: 34px;
}
dialog .form-row { margin-top: 20px; justify-content: flex-end; }
dialog .form-row button.primary { min-width: 88px; }
@supports not (animation-timeline: none) {
  @starting-style {
    dialog { opacity: 0; transform: translateY(8px) scale(0.97); }
    dialog::backdrop { opacity: 0; }
  }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 命令面板（⌘K）：顶部对齐，输入即筛选 */
dialog.cmd-dialog {
  max-width: min(92vw, 560px);
  width: 100%;
  margin: 12vh auto auto;
  overflow: hidden;
}
.cmd-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.cmd-head > svg { flex-shrink: 0; }
#cmd-input,
#cmd-input:hover,
#cmd-input:focus {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  color: var(--text);
}
#cmd-input::-webkit-search-cancel-button { display: none; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
}
.cmd-list {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}
.cmd-group {
  padding: 9px 10px 4px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
}
button.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13.5px;
}
button.cmd-item:hover,
button.cmd-item.is-active {
  background: var(--surface-2);
  border-color: transparent;
}
.cmd-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
}
button.cmd-item.is-active .cmd-icon { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.cmd-item-main { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.cmd-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.cmd-item kbd { flex-shrink: 0; }
.cmd-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.cmd-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}
.cmd-foot span { display: inline-flex; align-items: center; gap: 4px; }
.cmd-count { margin-left: auto; }
.cmd-btn { width: auto; gap: 6px; padding: 0 10px; }
.cmd-btn-kbd { font-size: 11px; font-family: var(--mono); color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
td.pos-actions { white-space: nowrap; }
td.pos-actions button + button { margin-left: 4px; }
td.pos-actions .ghost { padding: 3px 8px; }
button.export-btn { display: inline-flex; align-items: center; gap: 5px; }
@media (max-width: 760px) {
  dialog.cmd-dialog { margin-top: 8vh; }
  .cmd-btn { width: 38px; padding: 0; }
  .cmd-btn-kbd { display: none; }
}

/* 分隔与布局工具 */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dim {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color var(--dur-fast) var(--ease);
}
.dim:hover { border-color: var(--line-strong); }
.dim strong { font-size: 15px; font-weight: 650; }
.dim small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.dim.dim-empty { opacity: 0.55; background: transparent; }
.dim.dim-empty strong { color: var(--muted); font-weight: 500; }
.dim-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }

/* 图表容器 */
.chart-xs { height: 120px; }
.chart-sm { height: 220px; }
.chart-md { height: 320px; }
.chart-lg { height: 440px; }
.chart-sm, .chart-md, .chart-lg, .chart-xs { position: relative; border-radius: var(--radius-sm); overflow: hidden; }
.chart-sm:empty, .chart-md:empty, .chart-lg:empty, .chart-xs:empty {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.chart-sm.chart-empty, .chart-md.chart-empty, .chart-lg.chart-empty, .chart-xs.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: 1px dashed var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 14px 0 0; }

/* 订单筛选 / 执行质量 / 详情对话框 */
.table-filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 2px 0 14px;
}
.table-filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.table-filters input, .table-filters select { min-width: 132px; }
.table-filters .filter-actions { display: flex; gap: 8px; }
.order-row { cursor: pointer; }
.order-actions { white-space: nowrap; }
.order-actions .ghost.small + .ghost.small { margin-left: 6px; }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.metric strong.ok { color: var(--ok); }
.metric strong.warn { color: var(--warn); }
.metric strong.bad { color: var(--danger); }
.metric strong.tca-grades { font-size: 13.5px; letter-spacing: 0; }

dialog.order-dialog {
  max-width: min(94vw, 720px);
  width: 100%;
  max-height: min(84vh, 860px);
  overflow: hidden;
}
dialog.order-dialog[open] { display: flex; flex-direction: column; }
.order-dialog-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 26px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.order-dialog-head h2 { margin: 0 0 3px; }
.order-dialog-head .muted { overflow-wrap: anywhere; }
.order-dialog-head > button { flex-shrink: 0; white-space: nowrap; }
.order-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 26px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
/* 滚动区内的表格自带 overflow:auto，会被 flex 压成 0 高；只让外层滚动 */
.order-dialog-body > * { flex-shrink: 0; }
.order-dialog-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 26px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.order-dialog-foot #od-hint { margin-right: auto; }
.order-dialog-foot > button { flex-shrink: 0; white-space: nowrap; }
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px 18px;
}
.kv-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv-item > span { font-size: 11px; color: var(--muted); font-weight: 500; }
.kv-item > strong { font-size: 13px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.od-section-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
dialog.order-dialog .od-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.od-metrics { margin-bottom: 0; }
.od-metrics .metric { padding: 9px 11px; }
.od-metrics .metric strong { font-size: 15px; }
.od-tca-detail { margin-top: -4px; }
.od-empty { margin: 10px 12px; }

/* 分段控件 */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-3);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); font-weight: 600; }

/* ==========================================================================
   复合组件
   ========================================================================== */

/* 新闻 */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.news-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.news-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.news-item header a {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  display: block;
}
.news-item header a:hover { color: var(--accent); }
.news-item p { margin: 6px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.news-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.news-list { display: flex; flex-direction: column; gap: 10px; }

/* 策略卡片 */
.strategy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.strategy-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.strategy-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.strategy-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.strategy-head h3 { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.strategy-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 12px; }
.strategy-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 辩论 */
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.debate-round {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.debate-round:hover { border-color: var(--line-strong); background: var(--surface-3); }
.turn { margin: 6px 0; }
.turn.bull .claims li::marker { color: var(--up); }
.turn.bear .claims li::marker { color: var(--down); }
.round-tag {
  font-size: 11px;
  color: var(--faint);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.claims { margin: 6px 0; padding-left: 18px; }
.claims li { margin: 4px 0; font-size: 13px; }
.rebut { color: var(--warn); list-style: none; padding-left: 0; }
.concede { color: var(--muted); list-style: none; padding-left: 0; font-style: italic; }

/* 决策详情 */
.detail-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.detail-stack { display: flex; flex-direction: column; gap: 16px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.findings { display: flex; flex-direction: column; gap: 6px; list-style: none; padding: 0; margin: 0; }
.findings li {
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-out);
}
.findings li:hover { background: var(--surface-3); transform: translateX(2px); }

/* 下单票据 */
.ticket-preview {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  white-space: pre-wrap;
}
.ticket-checks { min-height: 0; }
.algo-panel {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.algo-head { display: flex; align-items: baseline; gap: 8px; }
.algo-result { display: flex; flex-direction: column; gap: 8px; }

/* 热度条 */
.heat { display: inline-flex; align-items: center; gap: 4px; }
/* 不给固定宽度时条会缩成一个点，看不出热度差异 */
.heat .bar-wrap { width: 72px; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  white-space: nowrap;
  cursor: help;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.ok { border-color: color-mix(in srgb, var(--up) 25%, transparent); color: var(--up); background: var(--up-soft); }
.chip.warn { border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); background: var(--warn-soft); }
.chip.info { color: var(--muted); }

/* 页头横幅 */
.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 22px 30px;
  margin-bottom: 20px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  pointer-events: none;
}
.page-hero::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  pointer-events: none;
}
.page-hero .hero-title { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; color: var(--text); }
.page-hero .hero-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.page-hero .hero-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ==========================================================================
   AI 助手
   ========================================================================== */

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

/* 左侧对话区：占满高度，消息区可滚动 */
.assistant-conv {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 110px);
  min-height: 480px;
  overflow: hidden;
  position: relative;
}
.ai-side-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.assistant-conv:hover .ai-side-toggle { opacity: 1; }
.ai-side-toggle:hover { color: var(--accent); border-color: var(--line-strong); }
.assistant-layout.side-collapsed .ai-side-toggle svg { transform: rotate(180deg); }
.assistant-layout.side-collapsed .assistant-side { display: none; }
.assistant-layout.side-collapsed { grid-template-columns: minmax(0, 1fr); }
/* 触屏设备无 hover，常显折叠按钮 */
@media (hover: none) {
  .ai-side-toggle { opacity: 1; }
}
.assistant-conv .ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.assistant-conv .ai-messages::-webkit-scrollbar { width: 6px; }
.assistant-conv .ai-messages::-webkit-scrollbar-track { background: transparent; }
.assistant-conv .ai-messages::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.assistant-conv .ai-messages::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
.assistant-conv .ai-input-row {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  align-items: flex-end;
}
.assistant-conv .ai-input-row textarea {
  flex: 1;
  padding: 13px 16px;
  font-size: 14.5px;
  resize: none;
  max-height: 200px;
  line-height: 1.55;
  font-family: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.assistant-conv .ai-input-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.assistant-conv .ai-input-row textarea::placeholder {
  color: var(--text-3);
}
.assistant-conv .ai-input-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.assistant-conv .ai-hint {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.assistant-conv .ai-input-row .primary {
  padding: 0 18px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
  border-radius: 12px;
}
.assistant-conv .ai-input-row .primary.has-content {
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.assistant-conv .ai-input-row .primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.assistant-conv .ai-input-row .ghost.small {
  height: 46px;
  border-radius: 12px;
}

.ai-msg {
  max-width: 88%;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-in 0.22s var(--ease-out);
  position: relative;
  transition: transform var(--dur) var(--ease);
}
.ai-msg:hover { transform: translateY(-1px); }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.ai-msg .ai-avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.ai-msg.assistant .ai-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.ai-msg.user .ai-avatar {
  background: var(--surface-3);
  color: var(--text-2);
}
.ai-msg .ai-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  min-width: 0;
}
.ai-bubble code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--accent);
}
.ai-msg.user .ai-bubble code {
  background: rgba(255,255,255,0.18);
  color: inherit;
}
.ai-time {
  font-size: 10.5px;
  color: var(--text-3);
  align-self: flex-end;
  margin-bottom: 2px;
  opacity: 0.7;
  white-space: nowrap;
  order: 3;
}
.ai-msg.user .ai-time { margin-right: 0; }
.ai-msg.assistant .ai-time { margin-left: 4px; }
.ai-msg.assistant {
  align-self: flex-start;
}
.ai-msg.assistant .ai-bubble {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  color: var(--text-2);
}
.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.ai-msg.user .ai-bubble {
  background: var(--btn-primary);
  color: var(--surface);
  border-top-right-radius: 4px;
}
.ai-msg.err .ai-bubble {
  border-left: 3px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 6%, var(--surface-2));
  border-color: color-mix(in srgb, var(--danger) 25%, var(--line));
  color: var(--text);
}
.ai-msg.thinking .ai-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}
.ai-msg.thinking .ai-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-bounce 1.2s infinite ease-in-out both;
}
.ai-msg.thinking .ai-bubble span:nth-child(1) { animation-delay: -0.32s; }
.ai-msg.thinking .ai-bubble span:nth-child(2) { animation-delay: -0.16s; }
@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* 复制按钮：默认隐藏，hover 气泡时显示 */
.ai-copy {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
              color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ai-msg.assistant:hover .ai-copy { opacity: 1; transform: scale(1); }
.ai-copy:hover { color: var(--accent); border-color: var(--line-strong); background: var(--surface-2); }
.ai-copy.copied { color: var(--ok); border-color: var(--ok); }

/* 滚动到底部按钮 */
.ai-scroll-btn {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
              background var(--dur) var(--ease), color var(--dur) var(--ease);
  z-index: 2;
}
.ai-scroll-btn:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ai-scroll-btn:hover {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--line-strong);
}
.ai-scroll-btn:active { transform: translateX(-50%) scale(0.94); }

/* 右侧栏 */
.assistant-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 12px;
}

.quick-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.quick-section:last-child { margin-bottom: 0; }
.quick-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  padding-left: 2px;
}
.quick-prompts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.quick-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur-fast) var(--ease-out);
}
.quick-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.quick-prompt:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.quick-prompt:hover .quick-icon { opacity: 1; }
.quick-prompt:active { transform: translateY(0) scale(0.98); }

.tips {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
}
.tips code {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--accent);
}

/* ==========================================================================
   响应式
   ========================================================================== */

.menu-btn { display: none; }

@media (max-width: 1100px) and (min-width: 761px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: 1fr; }
  .assistant-side { position: static; }
  .news-grid { grid-template-columns: 1fr; }
  .strategy-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
  }
  .menu-btn {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease-out);
    box-shadow: var(--shadow-xl);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--bg-inverse) 50%, transparent);
    backdrop-filter: blur(2px);
    z-index: 39;
  }
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  #main { padding: 18px 16px 36px; }
  .kpi-grid.kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .split, .grid-2, .duel { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-grid.kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notif-panel { width: min(94vw, 380px); }
  .topbar .clock { display: none; }
  .page-hero { flex-direction: column; align-items: flex-start; }
  .page-hero .hero-actions { width: 100%; }
  .page-hero .hero-actions button { flex: 1; }
  .assistant-layout { grid-template-columns: 1fr; }
  .assistant-side { position: static; }
  .assistant-conv { height: 60vh; }
  .assistant-conv .ai-hint { display: none; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .card { padding: 16px; margin-bottom: 14px; }
  .card-head { padding-bottom: 12px; flex-wrap: wrap; row-gap: 6px; }
  /* 标题与按钮不允许被长说明挤成竖排；说明独占第二行 */
  .card-head h2 { white-space: nowrap; }
  .card-head .muted { order: 3; flex: 1 0 100%; }
  .card-head > button, .card-head .head-actions { flex-shrink: 0; margin-left: auto; }
  .card-head > button { white-space: nowrap; }
  table { font-size: 12.5px; }
  th, td { padding: 9px 10px; }
  /* 空表不该撑出一整屏空白 */
  tbody td.muted { padding: 24px 12px; }
  .empty-state { padding: 30px 16px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 600px; }
  /* 源表列多，硬撑 600px 会把「状态/许可」推到屏外；允许换行后可在单屏内读完 */
  #news-sources table { min-width: 0; }
  #news-sources td:first-child { white-space: normal; }
  /* 交易计划只有「项目/数值」两列，撑到 600px 会让数值整列跑到屏外 */
  #decision-detail .plan-table table { min-width: 0; }
  /* 概览的策略归因/告警只有四列，600px 会把胜率、来源挤出首屏 */
  #strategy-attr table, #alerts-table table { min-width: 0; }
  /* 合规清单的说明才是要看的内容，允许换行后不必横向滚动 */
  #checklist-table table { min-width: 0; }
  /* 风险提示一换行就把持仓行撑到 100px；表格本来就能横向滚动 */
  #positions-table td { white-space: nowrap; }
  /* 许可表同理：长 tag 换行后每行近 180px，扫一眼要滑很久 */
  #license-table td { white-space: nowrap; }
  #checklist-table td { padding-left: 8px; padding-right: 8px; }
  /* 成交明细只有五列短数据，600px 会把费用/盈亏藏到横向滚动外 */
  #od-fills table { min-width: 0; }
  #od-fills th, #od-fills td { padding-left: 7px; padding-right: 7px; font-size: 11.5px; }
  #od-fills td { white-space: nowrap; }
  /* 审计日志是长文本，横向滚动只能看到表头；窄屏改卡片式逐条展示 */
  #audit-table table { min-width: 0; }
  #audit-table thead { display: none; }
  #audit-table tbody,
  #audit-table tr,
  #audit-table td { display: block; width: auto; }
  #audit-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
  #audit-table tbody tr:last-child { border-bottom: 0; }
  #audit-table td { border: 0; padding: 3px 0; white-space: normal; text-align: left; }
  #audit-table td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 52px;
    color: var(--text-3);
    font-size: 11px;
  }
  #audit-table td.audit-detail { margin-top: 6px; word-break: break-all; }
  #audit-table td.audit-detail::before { display: block; margin-bottom: 2px; }
  dialog > form { padding: 20px; }
  dialog.order-dialog { max-height: 88vh; }
  .order-dialog-head { padding: 18px 18px 12px; }
  .order-dialog-body { padding: 14px 18px; }
  .order-dialog-foot { padding: 12px 18px 18px; }
  .table-filters input, .table-filters select { min-width: 0; flex: 1; }
  .table-filters label { flex: 1 1 130px; }
  .kpi strong { font-size: 22px; }
}

/* 大屏手机并排两列 KPI：单列会让六张卡片拉出一屏半 */
@media (min-width: 481px) and (max-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 超窄屏：成交明细五列要在一屏内读完，字号与内边距再收一档 */
@media (max-width: 420px) {
  #od-fills th, #od-fills td { padding-left: 4px; padding-right: 4px; font-size: 10.5px; }
}

/* ==========================================================================
   动效无障碍
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .load-bar { animation: none; background: var(--accent); }
}

/* ==========================================================================
   暗色主题微调
   ========================================================================== */

[data-theme="dark"] .topbar { background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); }

[data-theme="dark"] tbody tr:hover { background: var(--surface-3); }

[data-theme="dark"] .notif-panel { backdrop-filter: blur(16px); background: color-mix(in srgb, var(--surface) 95%, transparent); }

[data-theme="dark"] .seg-btn.active { background: var(--surface-3); }

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .empty-state .empty-icon {
  background: var(--surface-3);
  color: var(--muted);
}

[data-theme="dark"] tbody td.muted .empty-state svg { color: var(--muted); }
[data-theme="dark"] .ai-msg.thinking .ai-bubble span { background: var(--accent); }

/* 暗色主题：主按钮底色变浅，白色高光改为黑色压暗 */
[data-theme="dark"] button.primary::after,
[data-theme="dark"] #btn-decide::after,
[data-theme="dark"] #btn-replay::after,
[data-theme="dark"] #btn-run-decide::after,
[data-theme="dark"] #btn-refresh-news::after,
[data-theme="dark"] #btn-news-refresh::after {
  background: linear-gradient(180deg, rgba(0,0,0,0.12), transparent 50%);
}

[data-theme="dark"] .logo::after {
  background: linear-gradient(135deg, rgba(0,0,0,0.2), transparent 55%);
}

[data-theme="dark"] .bar { box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
[data-theme="dark"] .bar-fill::after {
  background: linear-gradient(180deg, rgba(0,0,0,0.2), transparent 50%);
}

/* 打印优化 */
@media print {
  .sidebar, .topbar, .toast-stack { display: none !important; }
  body { display: block; }
  #main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid var(--line-strong); page-break-inside: avoid; }
}
/* --- 组合风险卡片（M11） --------------------------------------------- */
.kpi-grid.tight { gap: 10px; margin-top: 10px; }
.notice-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.notice {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
}
.notice.ok {
  border-color: rgba(22, 163, 74, 0.25);
  background: rgba(22, 163, 74, 0.06);
  color: #15803d;
}
.notice.warn {
  border-color: rgba(217, 119, 6, 0.28);
  background: rgba(217, 119, 6, 0.07);
  color: #b45309;
}

/* --- 触发器配置（M14） ----------------------------------------------- */
#trigger-rules table td { vertical-align: middle; }
#trigger-rules input[type="number"] {
  width: 72px;
  margin-left: 4px;
  padding: 2px 4px;
  font-size: 12px;
}
#trigger-rules label.muted { margin-right: 8px; white-space: nowrap; }

/* --- 自动执行策略配置（M18） ----------------------------------------- */
.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 14px;
  margin: 12px 0 8px;
}
.policy-grid label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}
.policy-grid input {
  padding: 4px 6px;
  font-size: 12px;
}
.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* --- 预演留档（M19） -------------------------------------------------- */
.sim-history { margin-top: 8px; }
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 4px;
}
.compact-table th,
.compact-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.compact-table th { color: var(--text-3); font-weight: 500; }
.compact-table td:last-child { white-space: normal; }

/* --- 一致性诊断（M22） ------------------------------------------------ */
.diag-line,
#ae-diag-row {
  margin-top: 6px;
  padding: 5px 8px;
  border-left: 2px solid var(--line);
  line-height: 1.5;
}
