/* mgauto design system
   方向：账本墨色 + 单一信号绿
   规则：无渐变、无玻璃、无静止阴影；颜色只用在数据、状态和唯一主操作上。
   两套主题共用一套 token；旧变量名保留别名，兼容各页面的历史内联样式。 */

:root {
  color-scheme: light;

  --ground: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --surface-3: #eef0eb;
  --border: #e2e4de;
  --border-strong: #d3d6cf;
  --rule: #eef0eb;

  --text: #141614;
  --text-2: #5c625b;
  --text-3: #6b7069;

  --accent: #1f6b52;
  --accent-soft: #e6f2ec;
  --positive: #1f6b52;
  --positive-soft: #e6f2ec;
  --negative: #b23a33;
  --negative-soft: #f8e9e7;
  --warning: #8a5a12;
  --warning-soft: #fdf4e3;

  --grid: #e6e8e2;
  --chart-span: 0.06;

  --net-bg: #f7f8f5;
  --net-star: #141614;
  --net-line: #1f6b52;
  --net-label: #141614;
  --net-pos: #1f6b52;
  --net-neg: #b23a33;
  --net-neu: #6b7069;
  --net-vignette: #e6f2ec;

  --radius-card: 10px;
  --radius-control: 7px;
  --radius-chip: 4px;
  --shadow-float: 0 10px 30px rgba(20, 22, 20, 0.12);

  --font: "Inter", "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;

  /* 旧变量名映射 */
  --bg: var(--ground);
  --card: var(--surface);
  --card-2: var(--surface-2);
  --card2: var(--surface-2);
  --border-2: var(--border-strong);
  --border2: var(--border-strong);
  --text2: var(--text-2);
  --text3: var(--text-3);
  --green: var(--positive);
  --red: var(--negative);
  --amber: var(--warning);
  --cyan: var(--accent);
  --accent-2: var(--accent);
  --serif: var(--font);
}

[data-theme="dark"] {
  color-scheme: dark;

  --ground: #0b0c0b;
  --surface: #121412;
  --surface-2: #181b18;
  --surface-3: #20241f;
  --border: #262a25;
  --border-strong: #343a33;
  --rule: #1d211d;

  --text: #f2f4f0;
  --text-2: #b0b6ae;
  --text-3: #8b9189;

  --accent: #5cc79a;
  --accent-soft: #143026;
  --positive: #5cc79a;
  --positive-soft: #143026;
  --negative: #f07a72;
  --negative-soft: #2c1a18;
  --warning: #d9a441;
  --warning-soft: #2a2113;

  --grid: #232722;
  --shadow-float: 0 12px 34px rgba(0, 0, 0, 0.45);

  --net-bg: #080b10;
  --net-star: #c8dceb;
  --net-line: #aac8e1;
  --net-label: #d7e4f2;
  --net-pos: #57c99a;
  --net-neg: #f87171;
  --net-neu: #94a3b8;
  --net-vignette: #1c2a3a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.num, .serif {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.neu { color: var(--text-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- 壳层 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: none;
  box-shadow: none;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  min-width: 0;
}
.logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}
button { font-family: inherit; }
button:not(.btn):not(.theme-btn) {
  background: var(--text);
  color: var(--surface);
  border: 0;
  border-radius: var(--radius-control);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:not(.btn):not(.theme-btn):hover { opacity: .9; }
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: none;
}
.tb-title { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; min-width: 0; overflow: hidden; flex-shrink: 1; }
.tb-title .over {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-3);
  text-transform: none;
}
.tb-title .main,
h1.tb-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 7px 10px;
  border-radius: var(--radius-control);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-3); font-weight: 600; }
.tb-status { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.tb-status a { white-space: nowrap; }
.tb-clock { font-size: 12px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--positive); white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); animation: livePulse 1.8s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--positive-soft); } 50% { opacity: .55; box-shadow: 0 0 0 4px transparent; } }
.live-pulse { width: 72px; height: 20px; display: block; }
.panel-in { animation: panelIn .4s ease; }
@keyframes panelIn { from { transform: translateY(6px); } to { transform: none; } }
.value-flash { animation: valueFlash .7s ease; }
@keyframes valueFlash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.theme-btn {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.theme-btn:hover { background: var(--surface-2); color: var(--text); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }

/* ---------- 标签 / 状态 ---------- */
.tag {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-2);
  text-transform: none;
}
.tag b { color: var(--text); font-weight: 600; }
.tag .sep { color: var(--text-3); margin: 0 6px; }
.capsule {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  background: transparent;
  color: var(--text-2);
  white-space: nowrap;
}
.capsule.green { background: var(--positive-soft); color: var(--positive); border-color: transparent; }
.capsule.red { background: var(--negative-soft); color: var(--negative); border-color: transparent; }
.capsule.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.capsule.amber { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.pill.on { color: var(--positive); border-color: transparent; background: var(--positive-soft); }
.pill.off { color: var(--text-3); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.dot.on { background: var(--positive); }
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.dot.pulse { background: var(--positive); animation: breathe 1.8s ease-in-out infinite; }

/* ---------- 可折叠分析区 ---------- */
.overview-more { margin-top: 16px; }
.overview-more-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.overview-more-toggle::-webkit-details-marker { display: none; }
.overview-more-toggle .chev { margin-left: auto; color: var(--text-2); transition: transform .2s; }
.overview-more[open] .overview-more-toggle { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.overview-more[open] .overview-more-toggle .chev { transform: rotate(180deg); }
.overview-more > .panel { margin-top: 12px; }
.overview-more[open] > .panel:first-of-type { margin-top: 12px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  margin-top: 16px;
  box-shadow: none;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  text-transform: none;
}
.panel-head > .tag:first-child { font-size: 15px; font-weight: 600; color: var(--text); }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 数值 ---------- */
.big-num {
  font-family: var(--font);
  font-size: 32px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 10px 0 4px;
  font-variant-numeric: tabular-nums;
}
.big-num .cents { font-size: 15px; font-weight: 500; vertical-align: top; color: var(--text-3); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--rule); color: var(--text); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sym { font-weight: 600; }
td .sub, td.sub { color: var(--text-3); font-size: 12px; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--surface); font-weight: 600; box-shadow: none; }
.btn.primary:hover { background: var(--text); opacity: .9; }
.btn.sel { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.btn.green { background: var(--positive-soft); border-color: transparent; color: var(--positive); }
.btn.red { background: var(--negative-soft); border-color: transparent; color: var(--negative); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 7px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.loading { color: var(--text-3); font-size: 12px; }

/* ---------- 指标条 ---------- */
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface);
}
.metric {
  flex: 1 1 auto;
  min-width: 100px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 12px 16px;
  box-shadow: none;
}
.metric:last-child { border-right: 0; }
.metric .k { font-size: 12px; color: var(--text-2); margin-bottom: 4px; letter-spacing: 0; }
.metric .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metrics:has(> .loading) { border: 0; background: transparent; }
.metrics:has(> .loading) .loading { display: block; padding: 12px 0; }
.metric-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.metric-table td { padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.metric-table td:first-child { padding-left: 0; }
.metric-table td:last-child { padding-right: 0; }
.metric-table td:nth-child(odd) { color: var(--text-2); }
.metric-table td:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.metric-table tr:last-child td { border-bottom: none; }
.result-meta { font-size: 12px; color: var(--text-3); margin-top: 10px; }
.metrics.metrics-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.metrics.metrics-grid-4 .metric:nth-child(4n) { border-right: 0; }
.metrics.metrics-grid-4 .metric:nth-child(-n+4) { border-bottom: 1px solid var(--border); }
.metrics.metrics-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.metrics.metrics-grid-3 .metric:nth-child(3n) { border-right: 0; }
.metrics.metrics-grid-3 .metric:nth-child(-n+6) { border-bottom: 1px solid var(--border); }
.metrics.metrics-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); }
.metrics.metrics-grid-5 .metric:nth-child(5n) { border-right: 0; }
.metrics.metrics-grid-5 .metric:nth-child(-n+5) { border-bottom: 1px solid var(--border); }
@media (max-width: 900px) {
  .metrics.metrics-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .metrics.metrics-grid-5 .metric:nth-child(5n) { border-right: 1px solid var(--border); }
  .metrics.metrics-grid-5 .metric:nth-child(3n) { border-right: 0; }
  .metrics.metrics-grid-5 .metric:nth-child(-n+5) { border-bottom: 0; }
  .metrics.metrics-grid-5 .metric:nth-child(-n+7) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .metrics.metrics-grid-4, .metrics.metrics-grid-3, .metrics.metrics-grid-5 { grid-template-columns: 1fr 1fr; }
  .metrics.metrics-grid-4 .metric:nth-child(n), .metrics.metrics-grid-3 .metric:nth-child(n), .metrics.metrics-grid-5 .metric:nth-child(n) { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .metrics.metrics-grid-4 .metric:nth-child(2n), .metrics.metrics-grid-3 .metric:nth-child(2n), .metrics.metrics-grid-5 .metric:nth-child(2n) { border-right: 0; }
  .metrics.metrics-grid-4 .metric:nth-last-child(-n+2), .metrics.metrics-grid-3 .metric:nth-last-child(-n+2), .metrics.metrics-grid-5 .metric:nth-last-child(-n+2) { border-bottom: 0; }
}

/* ---------- 底部 ---------- */
.footer {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0;
  color: var(--text-3);
  text-transform: none;
}
.footer .l { color: var(--positive); font-weight: 500; }

/* ---------- mgauto 页面组件 ---------- */
.row1 { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 900px) { .row1 { grid-template-columns: 1fr; } }
.pnl-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
@media (max-width: 700px) { .pnl-grid { grid-template-columns: 1fr; } }
.sub-metrics { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.stat-col { display: flex; flex-direction: column; gap: 8px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.stat-row .k { color: var(--text-2); }
.stat-row .v { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }

.win-list { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.win-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.win-item .amt { font-weight: 600; min-width: 76px; color: var(--positive); font-variant-numeric: tabular-nums; }
.win-item .sym { min-width: 58px; font-weight: 600; }
.win-item .date { color: var(--text-3); font-size: 12px; min-width: 90px; }
.win-item .bar { flex: 1; height: 3px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.win-item .bar i { display: block; height: 100%; background: var(--accent); }

.topwin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.topwin .hw { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.topwin .big-mult { font-family: var(--font); font-size: 32px; font-weight: 600; line-height: 1.1; margin: 10px 0 2px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.topwin .payout { position: absolute; top: 18px; right: 20px; font-size: 15px; font-weight: 600; color: var(--positive); font-variant-numeric: tabular-nums; }
.topwin .meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.topwin .flow { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-top: 10px; }
.topwin .flow .arr { color: var(--text-3); }
.topwin canvas { margin-top: auto; padding-top: 8px; }

.lattice-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .lattice-body { grid-template-columns: 1fr; } }
.scatter-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; background: var(--surface); }
.scatter-wrap canvas { display: block; width: 100%; height: 230px; }
.scatter-wrap::after { content: ''; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); opacity: .14; pointer-events: none; animation: scanX 8s linear infinite; }
.zone-label { position: absolute; bottom: 10px; font-size: 12px; font-weight: 600; letter-spacing: 0; }
.zone-label.loss { left: 12px; color: var(--negative); }
.zone-label.profit { right: 12px; color: var(--positive); }
.attr-stats { display: flex; flex-direction: column; gap: 10px; }

.risk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 800px) { .risk-grid { grid-template-columns: 1fr; } }
.risk-cell { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); }
.risk-cell .lab { font-size: 12px; color: var(--text-2); letter-spacing: 0; }
.risk-cell .val { font-size: 20px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.risk-cell .sub { font-size: 12px; color: var(--text-2); margin-top: 4px; }

.row4 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row4.single { grid-template-columns: 1fr; }
@media (max-width: 900px) { .row4 { grid-template-columns: 1fr; } }
.spark { width: 74px; height: 26px; }

.pulse-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-top: 12px; }
@media (max-width: 700px) { .pulse-grid { grid-template-columns: 1fr; } }
.price-block .k { font-size: 12px; color: var(--text-2); letter-spacing: 0; }
.price-block .v { font-size: 30px; font-weight: 600; margin-top: 5px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price-block .delta { font-size: 13px; font-weight: 600; margin-top: 3px; }
.updown { display: flex; gap: 10px; align-items: stretch; }
.ud-cell { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; background: var(--surface-2); }
.ud-cell .lab { font-size: 12px; color: var(--text-2); letter-spacing: 0; }
.ud-cell .val { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ud-cell.up { border-color: transparent; background: var(--positive-soft); }
.ud-cell.up .val { color: var(--positive); }
.ud-cell.down { border-color: transparent; background: var(--surface-3); }
.ud-cell.down .val { color: var(--text); }
.strength { display: flex; align-items: center; gap: 11px; margin-top: 15px; }
.strength .lab { font-size: 12px; color: var(--text-2); letter-spacing: 0; }
.strength .track { flex: 1; height: 6px; border: 0; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
.strength .track i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.strength .val { font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }

/* 通用卡片（risk / attribution / config / settings / admin） */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; margin-bottom: 16px; box-shadow: none; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0; }
.card-head .sub { font-size: 12px; color: var(--text-2); }
.card-body { padding: 18px 20px; }
.warn { background: var(--warning-soft); border: 1px solid transparent; border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--warning); margin-bottom: 16px; line-height: 1.55; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 12px; font-family: var(--mono); overflow: auto; color: var(--text-2); }

/* 响应式 */
@media (max-width: 900px) {
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .wrap { padding: 16px 16px 40px; }
  .tb-title .over { display: none; }
  .nav { margin-left: 4px; }
  .nav a { padding: 7px 8px; }
}
@media (max-width: 700px) {
  .topbar-inner { position: relative; }
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-float);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 120;
  }
  .topbar.nav-open .nav { display: flex; }
  .nav a { padding: 10px 12px; white-space: normal; }
  .tb-status { margin-left: 0; }
}
@media (max-width: 640px) {
  .topbar-inner { height: auto; min-height: 56px; flex-wrap: wrap; padding: 10px 16px; }
  .tb-status { margin-left: 0; width: 100%; justify-content: flex-end; }
  .wrap { padding: 14px 12px 36px; }
  .panel { padding: 14px 14px; }
  .big-num { font-size: 28px; }
  .metrics { display: grid; grid-template-columns: 1fr 1fr; }
  .metric { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
}

/* ---------- 通用表单 / KPI / 弹窗（两站共用） ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: none;
}
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 7px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { width: auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 16px;
}
@media (max-width: 800px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: transparent; border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 16px 18px; }
.kpi:last-child { border-right: 0; }
@media (max-width: 800px) {
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}
.kpi .k { font-size: 12px; color: var(--text-2); letter-spacing: 0; text-transform: none; }
.kpi .v { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.status-pill.running { color: var(--positive); border-color: transparent; background: var(--positive-soft); }
.status-pill.stopped { color: var(--text-3); border-color: var(--border); }

.subnav { margin: 0 0 16px; }
.subnav-group { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.subnav-group[hidden] { display: none; }
.subnav a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-control);
  cursor: pointer;
  white-space: nowrap;
}
.subnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.subnav a.active { color: var(--text); background: var(--surface-3); font-weight: 600; }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.legend-item b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-item .pos, .legend-item .neg { font-variant-numeric: tabular-nums; }

.rank-list { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 2px; }
.rank-row { display: grid; grid-template-columns: 96px 1fr 64px 92px; gap: 12px; align-items: center; }
.rank-name { font-size: 13px; font-weight: 600; color: var(--text); }
.rank-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.rank-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.rank-track .target { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); opacity: .5; }
.rank-val { text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-meta { text-align: right; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.live-hero { display: grid; grid-template-columns: 1fr 220px 220px; gap: 24px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 22px; margin-bottom: 16px; }
.live-hero-main .k { font-size: 12px; color: var(--text-2); }
.live-hero-main .v { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 4px 0; }
.live-hero-main .delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-spark { width: 220px; height: 64px; display: block; }
.live-hero-side { display: flex; flex-direction: column; gap: 8px; }
.live-hero-side .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.net-wrap { position: relative; height: 270px; border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; background: var(--net-bg); }
.net-wrap canvas { display: block; width: 100%; height: 100%; }
.net-tip { position: absolute; display: none; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; color: var(--text); box-shadow: var(--shadow-float); white-space: nowrap; }
.net-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 12px; color: var(--text-2); }
@media (max-width: 900px) { .live-hero { grid-template-columns: 1fr; gap: 14px; } .hero-spark { width: 100%; height: 64px; } }
@media (max-width: 640px) { .net-wrap { height: 200px; } }
#positionsBox, #overviewCompare, #dashPositions, #dashMarket, #dashTrades, #tradesBox, #historyBox { overflow-x: auto; }

.bal-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); margin: 4px 0 10px; }
.bal-note { font-size: 12px; color: var(--text-3); margin: 0 0 10px; }
.bal-sub-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin: 12px 0 6px; }
.bal-sub-head b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.bal-seg { height: 100%; border-right: 2px solid var(--surface); }
.bal-seg:last-child { border-right: 0; }
.bal-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 700px) { .bal-list { grid-template-columns: 1fr; } }
.bal-row { display: grid; grid-template-columns: 10px 1fr auto 56px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.bal-name { font-weight: 600; color: var(--text); }
.bal-amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.bal-share { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }
.bal-total { margin-top: 12px; text-align: right; font-size: 12px; color: var(--text-2); }
.bal-total b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

#overviewCompare, #overviewPositions, #historyTable, #pairTable, #tradesTable, #optTable, #wfTable { overflow-x: auto; }
#overviewCompare table { min-width: 760px; }
#overviewPositions table { min-width: 620px; }
#historyTable table, #tradesTable table, #optTable table, #wfTable table { min-width: 680px; }
#pairTable table { min-width: 520px; }
#overviewCompare th, #overviewCompare td,
#overviewPositions th, #overviewPositions td,
#historyTable th, #historyTable td,
#pairTable th, #pairTable td,
#tradesTable th, #tradesTable td,
#optTable th, #optTable td,
#wfTable th, #wfTable td { white-space: nowrap; }
@media (max-width: 640px) {
  .rank-row { grid-template-columns: 70px 1fr 56px; }
  .rank-meta { display: none; }
}

.chart-box { position: relative; height: 280px; margin-bottom: 16px; overflow: hidden; }
.chart-box::after { content: ''; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); opacity: .12; pointer-events: none; animation: scanX 9s linear infinite; }
@keyframes scanX { from { left: -2%; } to { left: 102%; } }
.tab { display: none; }
.tab.active { display: block; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.show { display: flex; }
.modal .panel { margin: 0; box-shadow: var(--shadow-float); }
pre.log {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  font-family: var(--mono);
  overflow: auto;
  max-height: 500px;
  white-space: pre-wrap;
  color: var(--text-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .live-dot, .panel-in, .value-flash { animation: none !important; }
  .scatter-wrap::after, .chart-box::after { display: none; }
}
@media (max-width: 640px) { .live-pulse { display: none; } }
