/* ============================================================================
   个人量化工作台 · 看板样式
   设计规范见 docs/DESIGN.md：深色金融终端，A 股红涨绿跌，10px 圆角，
   纯 CSS/内联 SVG、无在线字体与 CDN、无构建。与 cloudflare/pages/styles.css 同一份。
   ========================================================================== */

/* ---- 0. tokens（DESIGN.md §1，勿随意改值） ---- */
:root {
  color-scheme: dark;

  --bg-0: #0B0E13;      /* 页面底 */
  --bg-1: #11161F;      /* 卡片 */
  --bg-2: #1A2130;      /* 悬浮/表头 */
  --border: #232C3B;
  --border-strong: #344054;
  --text-0: #E6EDF7;    /* 主文字 */
  --text-1: #9AA7BA;    /* 次文字 */
  --text-2: #5C6B80;    /* 弱文字/占位 */
  --up: #FF4D4F;        /* A 股：涨/正 */
  --down: #22C55E;      /* A 股：跌/负 */
  --flat: #8A94A6;
  --accent: #4C8DFF;
  --warn: #F5A623;

  --radius: 10px;
  --radius-btn: 8px;
  --radius-tag: 6px;

  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono",
    "Roboto Mono", "Noto Sans Mono", monospace;

  /* DESIGN.md §2：hover 120–160ms，状态切换 200–240ms */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-state: cubic-bezier(0.22, 1, 0.36, 1);

  --up-bg: rgba(255, 77, 79, 0.12);
  --down-bg: rgba(34, 197, 94, 0.12);
  --flat-bg: rgba(138, 148, 166, 0.13);
  --accent-bg: rgba(76, 141, 255, 0.1);
  --warn-bg: rgba(245, 166, 35, 0.12);
  --grid-line: rgba(230, 237, 247, 0.06);
  --hair: 1px solid var(--border);
}

/* ---- 1. reset ---- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-0);
  color: var(--text-0);
  font: 13px/1.45 var(--font-ui);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
b, strong { font-weight: 600; }
button { font: inherit; color: inherit; }
table { border-collapse: collapse; }
::selection { background: rgba(76, 141, 255, 0.3); color: #fff; }
[hidden] { display: none !important; }
body.gate-open { overflow: hidden; }

* {
  scrollbar-width: thin;
  scrollbar-color: #2b3648 transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #2b3648; border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

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

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -48px; left: 12px; z-index: 100;
  padding: 6px 10px; background: var(--bg-2); border: var(--hair);
  border-radius: var(--radius-btn); color: var(--text-0); font-size: 12px;
  text-decoration: none; transition: top 140ms var(--ease-out);
}
.skip-link:focus { top: 8px; }

.icon {
  width: 13px; height: 13px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -2px;
}
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-num); }

/* ---- 2. 顶部状态条 / 状态细条（DESIGN.md §3 状态提示） ---- */
.top-stack {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg-0);
}
.connbar {
  position: relative; height: 2px; background: var(--bg-2);
  transition: background-color 200ms var(--ease-out);
}
.connbar > i {
  position: absolute; inset: 0; display: block;
  background: var(--flat);
  transform: scaleX(1); transform-origin: left center;
  transition: background-color 200ms var(--ease-out), opacity 200ms var(--ease-out);
}
.connbar[data-state="live"] > i { background: var(--down); }
.connbar[data-state="connecting"] > i,
.connbar[data-state="reconnecting"] > i,
.connbar[data-state="degraded"] > i { background: var(--warn); }
.connbar[data-state="offline"] > i { background: var(--up); }

.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 54px; max-width: 1560px; margin: 0 auto; padding: 0 24px;
  border-bottom: var(--hair);
}
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark { width: 22px; height: 22px; color: var(--text-1); }
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-0); }
.brand-sub {
  font-family: var(--font-num); font-size: 8.5px; letter-spacing: 0.14em;
  color: var(--text-2); white-space: nowrap;
}
.topbar-mid {
  display: flex; align-items: center; gap: 12px; margin-left: 20px; min-width: 0;
}
.sep { width: 1px; height: 12px; background: var(--border); flex: none; }
.session, .status-text {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-1); white-space: nowrap;
}
.session .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--flat);
  transition: background-color 220ms var(--ease-state);
}
.session[data-state="open"] .dot { background: var(--accent); }
.session[data-state="auction"] .dot { background: var(--warn); }
.status-text .icon { color: var(--text-2); }
.chip {
  font-family: var(--font-num); font-size: 10.5px; line-height: 16px;
  color: var(--text-1); border: var(--hair); border-radius: var(--radius-tag);
  padding: 1px 6px; background: var(--bg-2); white-space: nowrap;
}
.topbar-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none;
}
.conn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-1); white-space: nowrap;
}
.conn .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--flat);
  transition: background-color 220ms var(--ease-state);
}
.conn[data-state="live"] .dot { background: var(--down); }
.conn[data-state="connecting"] .dot,
.conn[data-state="reconnecting"] .dot,
.conn[data-state="degraded"] .dot { background: var(--warn); }
.conn[data-state="offline"] .dot { background: var(--up); }
.conn[data-state="offline"] { color: var(--up); }

/* ---- 3. 按钮 / 标签 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 26px; padding: 0 9px;
  background: transparent; color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  font-size: 11px; line-height: 1; cursor: pointer;
  transition: background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.btn:hover { background: var(--bg-2); border-color: var(--border-strong); color: var(--text-0); }
.btn:active { background: #212a3b; }
.btn-icon { width: 26px; padding: 0; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #08111f; font-weight: 600;
}
.btn-primary:hover { background: #6aa0ff; border-color: #6aa0ff; color: #08111f; }
.btn.is-loading .icon { animation: spin 900ms linear infinite; }

.linklike {
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--text-1); font-size: inherit; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 2px;
  transition: color 140ms var(--ease-out);
}
.linklike:hover { color: var(--text-0); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 17px; padding: 0 5px;
  border: 1px solid var(--border); border-radius: var(--radius-tag);
  background: var(--bg-2); color: var(--text-1);
  font-size: 9.5px; line-height: 1; white-space: nowrap;
}
.tag-warn { color: var(--warn); border-color: rgba(245, 166, 35, 0.35); background: var(--warn-bg); }
.tag-up { color: var(--up); border-color: rgba(255, 77, 79, 0.32); background: var(--up-bg); }
.tag-down { color: var(--down); border-color: rgba(34, 197, 94, 0.32); background: var(--down-bg); }
.tag-flat { color: var(--flat); border-color: var(--border); background: var(--flat-bg); }
.tag-accent { color: #9dc0ff; border-color: rgba(76, 141, 255, 0.35); background: var(--accent-bg); }
.st-short { display: none; }
.tag-dev {
  color: var(--text-2); border-style: dashed; background: transparent;
  letter-spacing: 0.02em;
}
.is-pos { color: var(--up); }
.is-neg { color: var(--down); }

.dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--flat); vertical-align: 1px;
}
.dot-up { background: var(--up); }
.dot-down { background: var(--down); }
.dot-flat { background: var(--flat); }

/* ---- 4. 主网格与卡片 ---- */
.app {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px; max-width: 1560px; margin: 0 auto;
  padding: 16px 24px 24px; align-content: start;
}
.span-12 { grid-column: span 12; }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }

.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-1); border: var(--hair); border-radius: var(--radius);
  animation: card-in 340ms var(--ease-state) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.card-head {
  display: flex; align-items: center; gap: 10px; min-height: 38px;
  padding: 0 14px; border-bottom: var(--hair);
}
.card-title {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-0);
  white-space: nowrap;
}
.card-title .idx {
  font-family: var(--font-num); font-size: 9.5px; line-height: 15px;
  color: var(--text-2); border: var(--hair); border-radius: 4px; padding: 0 4px;
}
.card-sub {
  font-size: 10px; font-weight: 400; letter-spacing: 0.02em;
  color: var(--text-2); white-space: nowrap;
}
.card-meta {
  display: flex; align-items: center; gap: 9px; margin-left: auto;
  font-size: 10px; color: var(--text-2); font-family: var(--font-num);
  white-space: nowrap; overflow: hidden;
}
.meta-sep { width: 1px; height: 10px; background: var(--border); flex: none; }
.card-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; border-top: var(--hair);
  font-size: 10px; color: var(--text-2); line-height: 1.5;
}
.foot-right { margin-left: auto; color: var(--text-2); opacity: 0.85; }

.col-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.03em; color: var(--text-1);
  margin-bottom: 9px;
}
.col-meta {
  font-family: var(--font-num); font-size: 9px; color: var(--text-2);
  letter-spacing: 0; white-space: nowrap;
}

/* ---- 5. 方向信号卡 ---- */
.signal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.06fr) minmax(0, 1.12fr);
}
.sig-col { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; }
.sig-col + .sig-col { border-left: var(--hair); }

.sig-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.sym-tab {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 7px; border: 1px solid transparent; border-radius: var(--radius-tag);
  background: transparent; color: var(--text-1); cursor: pointer;
  font-family: var(--font-num); font-size: 11px; line-height: 1.2;
  transition: background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.sym-tab .sym-name {
  font-family: var(--font-ui); font-size: 9.5px; color: var(--text-2);
  transition: color 140ms var(--ease-out);
}
.sym-tab:hover { background: var(--bg-2); color: var(--text-0); }
.sym-tab[aria-selected="true"] {
  background: var(--bg-2); border-color: var(--border-strong); color: var(--text-0);
}
.sym-tab[aria-selected="true"] .sym-name { color: var(--text-1); }

.sig-dir-line {
  display: flex; align-items: center; gap: 12px; margin: 14px 0 12px;
}
.lamp { flex: none; display: flex; }
.lamp .dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--flat);
  transition: background-color 220ms var(--ease-state);
}
.lamp[data-dir="up"] .dot { background: var(--up); }
.lamp[data-dir="down"] .dot { background: var(--down); }
.lamp[data-dir="flat"] .dot { background: var(--flat); }
.sig-dir-block { min-width: 0; }
.sig-dir {
  font-size: 22px; font-weight: 600; line-height: 1.15; letter-spacing: 0.04em;
  color: var(--text-0);
  transition: color 220ms var(--ease-state);
}
.sig-dir[data-dir="up"] { color: var(--up); }
.sig-dir[data-dir="down"] { color: var(--down); }
.sig-dir[data-dir="flat"] { color: var(--text-0); }
.sig-tags { display: flex; gap: 4px; margin-top: 4px; min-height: 17px; }
.sig-price-block { margin-left: auto; text-align: right; min-width: 0; }
.sig-price {
  font-size: 21px; font-weight: 500; line-height: 1.15; color: var(--text-0);
  letter-spacing: -0.01em;
}
.sig-price-meta {
  margin-top: 3px; font-size: 9.5px; color: var(--text-2); font-family: var(--font-num);
  white-space: nowrap;
}
.sig-kv {
  display: flex; gap: 18px; margin-top: auto; padding-top: 9px;
  border-top: var(--hair); font-size: 9.5px; color: var(--text-2);
}
.sig-kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sig-kv b {
  font-family: var(--font-num); font-size: 10.5px; font-weight: 400; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 概率三分条（宽度用 transform: translateX + scaleX，只动合成层） */
.prob-bar {
  position: relative; height: 8px; margin: 2px 0 11px;
  border-radius: 2px; overflow: hidden; background: var(--bg-2);
}
.prob-bar .seg {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  transform-origin: left center;
  transform: translateX(0) scaleX(0);
  will-change: transform;
}
.prob-bar .seg-up { background: var(--up); }
.prob-bar .seg-flat { background: var(--flat); }
.prob-bar .seg-down { background: var(--down); }

.prob-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.prob-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.prob-item .k {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-1); white-space: nowrap;
}
.prob-item b {
  font-family: var(--font-num); font-size: 14px; font-weight: 400; color: var(--text-1);
  line-height: 1.1;
}
.prob-item[data-key="up"] .dot { background: var(--up); }
.prob-item[data-key="flat"] .dot { background: var(--flat); }
.prob-item[data-key="down"] .dot { background: var(--down); }
.prob-item.is-max b { color: var(--text-0); font-weight: 600; }
.prob-item.is-max .k { color: var(--text-0); }

.conf-block { margin-top: auto; padding-top: 12px; }
.conf-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; color: var(--text-1); margin-bottom: 7px;
}
.conf-head b {
  margin-left: auto; font-family: var(--font-num); font-size: 13px;
  font-weight: 400; color: var(--text-0);
}
.conf-bar {
  height: 4px; border-radius: 2px; background: var(--bg-2); overflow: hidden;
}
.conf-bar > i {
  display: block; width: 100%; height: 100%;
  background: var(--text-1); transform-origin: left center;
  transform: scaleX(0);
  transition: transform 240ms var(--ease-state);
}
.conf-note { margin-top: 6px; font-size: 9px; color: var(--text-2); }

/* 特征贡献 */
.feat-list { display: flex; flex-direction: column; }
.feat-row {
  display: grid;
  grid-template-columns: minmax(58px, 84px) minmax(0, 1fr) 46px 44px;
  align-items: center; gap: 8px; height: 27px; min-width: 0;
}
.feat-name {
  font-family: var(--font-num); font-size: 10px; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feat-track { height: 4px; border-radius: 2px; background: var(--bg-2); overflow: hidden; }
.feat-track > i {
  display: block; width: 100%; height: 100%; transform-origin: left center;
  transform: scaleX(0);
  transition: transform 240ms var(--ease-state);
}
.feat-row[data-sign="pos"] .feat-track > i { background: var(--up); }
.feat-row[data-sign="neg"] .feat-track > i { background: var(--down); }
.feat-row[data-sign="zero"] .feat-track > i { background: var(--flat); }
.feat-val {
  font-family: var(--font-num); font-size: 9.5px; color: var(--text-2);
  text-align: right; white-space: nowrap;
}
.feat-contrib {
  font-family: var(--font-num); font-size: 10px; text-align: right;
  white-space: nowrap; color: var(--text-1);
}
.feat-contrib.is-pos { color: var(--up); }
.feat-contrib.is-neg { color: var(--down); }

/* ---- 6. 指标卡 ---- */
.metrics {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border: var(--hair); border-radius: var(--radius-btn); overflow: hidden;
  background: var(--bg-1);
}
.metric {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 9px 11px 10px; border-left: var(--hair);
}
.metric:first-child { border-left: 0; }
.m-label {
  font-size: 9.5px; letter-spacing: 0.03em; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-value {
  font-family: var(--font-num); font-size: 20px; font-weight: 500; line-height: 1.2;
  color: var(--text-0); letter-spacing: -0.01em; white-space: nowrap;
}
.m-value.is-pos { color: var(--up); }
.m-value.is-neg { color: var(--down); }
.m-sub {
  font-size: 9px; line-height: 1.35; color: var(--text-2);
  white-space: normal; overflow: visible;
}
.m-flag {
  display: inline-block; margin-left: 4px; padding: 0 3px;
  font-size: 8px; line-height: 13px; font-weight: 400; letter-spacing: 0;
  color: var(--warn); border: 1px solid rgba(245, 166, 35, 0.35);
  border-radius: 3px; background: var(--warn-bg); vertical-align: 1px;
}
.m-sub code {
  font-family: var(--font-num); font-size: 9px; color: var(--text-2);
}

/* ---- 7. 回测区 ---- */
.bt-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 31%);
}
.bt-left { padding: 14px 16px; min-width: 0; }
.bt-right {
  display: flex; flex-direction: column; min-width: 0;
  padding: 14px 16px 12px; border-left: var(--hair);
}
.bt-sub {
  display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 20px; margin-top: 14px;
}
.bt-block { min-width: 0; }

.dir-row {
  display: grid; grid-template-columns: 62px minmax(0, 1fr) 48px 36px;
  align-items: center; gap: 8px; height: 26px; font-size: 10.5px;
}
.dir-row .dir-name {
  display: flex; align-items: center; gap: 5px; color: var(--text-1); white-space: nowrap;
}
.dir-row .dir-name .dot { width: 5px; height: 5px; }
.dir-row[data-dir="up"] .dot { background: var(--up); }
.dir-row[data-dir="flat"] .dot { background: var(--flat); }
.dir-row[data-dir="down"] .dot { background: var(--down); }
.dir-track { height: 4px; border-radius: 2px; background: var(--bg-2); overflow: hidden; }
.dir-track > i {
  display: block; width: 100%; height: 100%; transform-origin: left center;
  transform: scaleX(0); transition: transform 240ms var(--ease-state);
}
.dir-row[data-dir="up"] .dir-track > i { background: var(--up); }
.dir-row[data-dir="flat"] .dir-track > i { background: var(--flat); }
.dir-row[data-dir="down"] .dir-track > i { background: var(--down); }
.dir-hit { font-family: var(--font-num); font-size: 10.5px; color: var(--text-1); text-align: right; }
.dir-n { font-family: var(--font-num); font-size: 9px; color: var(--text-2); text-align: right; }

/* 通用表格 */
.tbl-wrap { overflow: auto; min-width: 0; }
.tbl { width: 100%; font-size: 12px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  height: 28px; padding: 0 12px; text-align: left;
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--text-1); background: var(--bg-2); border-bottom: var(--hair);
  white-space: nowrap;
}
.tbl tbody td {
  height: 36px; padding: 0 12px; border-bottom: var(--hair);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color 140ms var(--ease-out);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--bg-2); }
.tbl .num, .tbl th.num { text-align: right; font-family: var(--font-num); }
.tbl-tight tbody td { height: 28px; }
.tbl-sm { font-size: 10.5px; }
.tbl-sm thead th { height: 24px; padding: 0 8px; font-size: 9px; }
.tbl-sm tbody td { height: 28px; padding: 0 8px; }

.tbl-bench { table-layout: auto; }
.tbl-bench tbody td { height: 27px; font-size: 10.5px; }
.tbl-bench tbody tr[data-role="strategy"] td {
  color: var(--text-0); background: rgba(76, 141, 255, 0.06);
}
.tbl-bench tbody tr[data-role="strategy"] td:first-child { color: var(--text-0); font-weight: 600; }
.tbl-bench .bench-delta.is-pos { color: var(--up); }
.tbl-bench .bench-delta.is-neg { color: var(--down); }
.bench-flag { margin-left: 4px; }
.tbl-wrap-sm { max-height: none; }

.tbl-wrap-signals { max-height: 398px; }
.tbl-wrap-orders { max-height: 302px; }
.tbl-signals { table-layout: fixed; }
.tbl-signals .c-time { width: 13%; }
.tbl-signals .c-sym { width: 10%; }
.tbl-signals .c-name { width: 15%; }
.tbl-signals .c-dir { width: 10%; }
.tbl-signals .c-prob { width: 11%; }
.tbl-signals .c-conf { width: 12%; }
.tbl-signals .c-price { width: 14%; }
.tbl-signals .c-status { width: 15%; }
.tbl-orders { table-layout: fixed; }
.tbl-orders .c-time { width: 13%; }
.tbl-orders .c-sym { width: 9%; }
.tbl-orders .c-side { width: 8%; }
.tbl-orders .c-qty { width: 10%; }
.tbl-orders .c-price { width: 12%; }
.tbl-orders .c-filled { width: 12%; }
.tbl-orders .c-fee { width: 9%; }
.tbl-orders .c-status { width: 11%; }

.cell-dir { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.cell-dir[data-dir="up"] { color: var(--up); }
.cell-dir[data-dir="down"] { color: var(--down); }
.cell-dir[data-dir="flat"] { color: var(--text-1); }
.cell-dir .dot { width: 5px; height: 5px; }
.cell-dir[data-dir="up"] .dot { background: var(--up); }
.cell-dir[data-dir="down"] .dot { background: var(--down); }
.cell-dir[data-dir="flat"] .dot { background: var(--flat); }
.sym-name-m { display: none; }
.t-time .t-date { color: var(--text-2); }
.tbl tbody td.is-flash { color: var(--text-0); }
.tbl tbody tr[data-status="warming_up"] td { opacity: 0.72; }
.tbl tbody tr[data-status="stale"] .cell-dir { color: var(--text-1); }

/* 校准图（纯 DOM 散点，避免 SVG 拉伸变形） */
.cal-wrap { position: relative; flex: 1; min-height: 168px; display: flex; flex-direction: column; }
.cal-plot {
  position: relative; flex: 1; min-height: 140px; margin: 2px 0 4px 26px;
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background-image: linear-gradient(to top, var(--grid-line) 1px, transparent 1px);
  background-size: 100% 25%;
}
.cal-diag { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cal-diag line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.cal-pt {
  position: absolute; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--text-0); background: var(--bg-1);
  transform: translate(-50%, 50%); cursor: default;
  transition: transform 140ms var(--ease-out), border-color 140ms var(--ease-out);
  z-index: 2;
}
.cal-pt:hover, .cal-pt:focus-visible {
  transform: translate(-50%, 50%) scale(1.3); border-color: var(--accent); z-index: 4;
}
.cal-tip {
  position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
  padding: 4px 7px; border: 1px solid var(--border-strong); border-radius: var(--radius-tag);
  background: var(--bg-2); color: var(--text-0);
  font-size: 9.5px; font-family: var(--font-num); white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 140ms var(--ease-out);
}
.cal-pt:hover .cal-tip, .cal-pt:focus-visible .cal-tip { opacity: 1; }
.cal-ylabel {
  position: absolute; right: calc(100% + 6px); transform: translateY(50%);
  font-family: var(--font-num); font-size: 9px; color: var(--text-2);
  text-align: right; white-space: nowrap;
}
.cal-xaxis { position: relative; height: 13px; margin-left: 26px; flex: none; }
.cal-xaxis span {
  position: absolute; top: 2px; transform: translateX(-50%);
  font-family: var(--font-num); font-size: 9px; color: var(--text-2); white-space: nowrap;
}
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 2px 0 2px; font-size: 9px; color: var(--text-2);
}
.cal-legend > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lg-line { width: 12px; height: 0; border-top: 1px dashed var(--border-strong); }
.lg-dot {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid var(--text-0); background: var(--bg-1);
}
.cal-note { margin-top: 4px; font-size: 9px; line-height: 1.5; color: var(--text-2); }

/* ---- 8. 净值曲线 ---- */
.chart-body { padding: 12px 14px 10px; }
.chart-wrap { position: relative; height: 236px; min-height: 180px; }
.eq-grid-layout {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 16px;
}
.eq-labels { position: relative; grid-column: 1; grid-row: 1; }
.eq-y {
  position: absolute; right: 4px; transform: translateY(-50%);
  font-family: var(--font-num); font-size: 9px; color: var(--text-2); white-space: nowrap;
}
.eq-y.is-base { color: var(--text-1); }
.eq-plot { position: relative; grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; }
.eq-x {
  grid-column: 2; grid-row: 2; display: flex; justify-content: space-between;
  font-family: var(--font-num); font-size: 9px; color: var(--text-2);
  padding-top: 3px;
}
.eq-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.eq-svg .eq-grid { stroke: var(--grid-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.eq-svg .eq-base {
  stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}
.eq-svg .eq-line {
  fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.eq-svg .eq-area { opacity: 0; transition: opacity 400ms var(--ease-out); }
.eq-cross-x, .eq-cross-dot, .eq-tip {
  position: absolute; opacity: 0; pointer-events: none;
  will-change: transform;
}
.eq-cross-x {
  top: 0; bottom: 0; width: 1px; left: 0;
  background: rgba(230, 237, 247, 0.22);
}
.eq-cross-dot {
  width: 7px; height: 7px; left: -3.5px; top: -3.5px; border-radius: 50%;
  background: var(--bg-1); border: 1.5px solid var(--text-0);
}
.eq-tip {
  top: 0; left: 0; z-index: 3;
  padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-tag);
  background: var(--bg-2); color: var(--text-0);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
  font-size: 9.5px; font-family: var(--font-num); white-space: nowrap;
}
.eq-tip b { font-weight: 600; color: var(--text-0); }
.eq-tip span { color: var(--text-2); }
.eq-tip .eq-tip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---- 9. 模拟盘 / 账户 ---- */
.paper-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.metrics-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-radius: var(--radius-btn);
}
.metrics-2 .metric { border-top: var(--hair); }
.metrics-2 .metric:nth-child(1),
.metrics-2 .metric:nth-child(2) { border-top: 0; }
.metrics-2 .metric:nth-child(2n) { border-left: var(--hair); }
.metrics-2 .metric:nth-child(3) { border-left: 0; }
.metrics-2 .metric-wide { grid-column: span 2; border-left: 0; }
.metrics-2 .m-value { font-size: 17px; }
.paper-pos { min-width: 0; }
.paper-pos .tbl tbody td { height: 28px; font-size: 10.5px; padding: 0 8px; }
.paper-pos .tbl thead th { height: 24px; font-size: 9px; padding: 0 8px; }
.paper-pos .tbl th:first-child, .paper-pos .tbl td:first-child { padding-left: 0; }
.paper-pos .tbl th:last-child, .paper-pos .tbl td:last-child { padding-right: 0; }
.paper-pos .pos-name { color: var(--text-1); font-size: 9.5px; margin-left: 4px; }
.paper-pos .tbl tbody td { overflow: visible; }
.tbl-pos { table-layout: fixed; }
.tbl-pos th:nth-child(1) { width: 34%; }
.tbl-pos th:nth-child(2) { width: 18%; }
.tbl-pos th:nth-child(3) { width: 17%; }
.tbl-pos th:nth-child(4) { width: 16%; }
.tbl-pos th:nth-child(5) { width: 15%; }
.inline-empty { padding: 12px 0 4px; font-size: 10.5px; color: var(--text-2); }

/* ---- 10. 空状态 / 骨架屏 / 提示 ---- */
.card-empty { padding: 20px 16px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.empty-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-1);
}
.empty-title .icon { color: var(--warn); }
.empty p { font-size: 10.5px; line-height: 1.6; color: var(--text-2); }
.empty code {
  display: inline-block; max-width: 100%;
  font-family: var(--font-num); font-size: 10px; color: var(--text-1);
  background: var(--bg-2); border: var(--hair); border-radius: var(--radius-tag);
  padding: 3px 7px; white-space: pre-wrap; word-break: break-all; user-select: all;
}
.empty-note { font-size: 9.5px; color: var(--text-2); }

.sk { position: relative; overflow: hidden; background: var(--bg-2); border-radius: 4px; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(230, 237, 247, 0.055), transparent);
  transform: translateX(-100%);
  animation: sk-shimmer 1.2s linear infinite;
}
.sk-line { height: 9px; width: 100%; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-num { height: 19px; width: 68%; }
.sk-rows { display: flex; flex-direction: column; gap: 9px; padding: 4px 0; }
.sk-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 40px; gap: 10px; align-items: center; }
.sk-chart { position: absolute; inset: 0; border-radius: 4px; }
.sk-cal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.sk-tbl { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.sk-tbl > i { display: block; height: 26px; }
.sk-block + .sk-block { margin-top: 12px; }

/* ---- 11. 页脚 ---- */
.page-foot {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  max-width: 1560px; margin: 0 auto; padding: 12px 24px 26px;
  font-size: 10px; color: var(--text-2);
}
.page-foot .icon { color: var(--text-2); opacity: 0.8; }
.page-foot .foot-left, .page-foot .foot-mid { display: inline-flex; align-items: center; gap: 5px; }
.page-foot .foot-right { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; }
.page-foot code { font-family: var(--font-num); }

/* ---- 12. 人机验证覆盖层 / 限流提示 ---- */
.notice {
  display: flex; align-items: center; gap: 8px;
  max-width: 1560px; margin: 0 auto;
  padding: 5px 24px; border-bottom: var(--hair);
  background: var(--warn-bg); color: var(--warn);
  font-size: 10.5px; line-height: 1.5;
}
.notice .icon { color: var(--warn); }
.notice-count {
  font-family: var(--font-num); font-size: 10.5px; font-weight: 500;
  padding: 0 5px; border: 1px solid rgba(245, 166, 35, 0.35); border-radius: var(--radius-tag);
}
.notice-retry { color: var(--warn); margin-left: 2px; }

.gate {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; transition: opacity 200ms var(--ease-out);
}
.gate.is-open { opacity: 1; }
.gate-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 11, 0.72); }
.gate-card {
  position: relative; width: min(460px, 100%);
  background: var(--bg-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  outline: none;
}
.gate-card.is-error { border-color: rgba(245, 166, 35, 0.5); }
.gate-card.is-success { border-color: rgba(34, 197, 94, 0.45); }
.gate-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; border-bottom: var(--hair);
}
.gate-lock {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex: none;
  border: var(--hair); border-radius: var(--radius-tag);
  color: var(--text-1); background: var(--bg-2);
}
.gate-head h2 {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em;
}
.gate-sub {
  font-family: var(--font-num); font-size: 8.5px; letter-spacing: 0.13em;
  color: var(--text-2);
}
.gate-mode { margin-left: auto; }
.gate-body { padding: 13px 16px 12px; }
.gate-desc { font-size: 11px; line-height: 1.65; color: var(--text-1); }
.gate-widget {
  display: flex; align-items: center; justify-content: center;
  min-height: 66px; margin: 14px 0 10px;
}
.gate-check {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 66px; margin: 14px 0 10px;
  font-size: 12px; color: var(--text-0);
}
.gate-check-icon { width: 26px; height: 26px; color: var(--down); }
.gate-status { min-height: 14px; font-size: 10px; color: var(--text-2); }
.gate-hint { margin-top: 3px; font-size: 9px; line-height: 1.5; color: var(--text-2); opacity: 0.8; }
.gate-fail { margin-top: 6px; font-size: 10.5px; color: var(--warn); }
.gate-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; border-top: var(--hair);
  font-size: 9.5px; color: var(--text-2);
}
.gate-note { line-height: 1.4; }

/* ---- 13. 免责声明对话框 ---- */dialog {
  padding: 0; margin: auto; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--bg-1); color: var(--text-0);
  width: min(560px, calc(100vw - 28px)); max-height: min(86vh, 720px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}
dialog[open] { animation: dlg-in 200ms var(--ease-state); }
dialog::backdrop { background: rgba(5, 7, 11, 0.68); }
.dlg-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border-bottom: var(--hair);
}
.dlg-head h2 {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em;
}
.dlg-sub {
  font-family: var(--font-num); font-size: 8.5px; letter-spacing: 0.13em;
  color: var(--text-2);
}
.dlg-head .btn { margin-left: auto; }
.dlg-body {
  padding: 13px 16px; max-height: 56vh; overflow: auto;
  font-size: 11.5px; line-height: 1.7; color: var(--text-1);
}
.dlg-body ol {
  display: flex; flex-direction: column; gap: 6px;
  margin: 9px 0; padding-left: 18px; list-style: decimal;
}
.dlg-body li::marker { color: var(--text-2); font-family: var(--font-num); font-size: 10px; }
.dlg-body b { color: var(--text-0); }
.dlg-body code {
  font-family: var(--font-num); font-size: 10px; color: var(--text-1);
  background: var(--bg-2); padding: 1px 4px; border-radius: 4px;
}
.dlg-note {
  margin-top: 10px; padding-top: 9px; border-top: var(--hair);
  font-size: 9.5px; color: var(--text-2);
}
.dlg-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; border-top: var(--hair);
  font-size: 9.5px; color: var(--text-2);
}
.noscript {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  padding: 8px 12px; border: 1px solid var(--warn); border-radius: var(--radius-btn);
  background: var(--warn-bg); color: var(--warn); font-size: 11px; z-index: 60;
}

/* ---- 13. 动效 ---- */
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sk-shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes dlg-in {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- 14. 响应式：1440 可用，390 单列无横向滚动 ---- */
@media (max-width: 1180px) {
  .bt-grid { grid-template-columns: minmax(0, 1fr); }
  .bt-right { border-left: 0; border-top: var(--hair); }
  .cal-wrap { min-height: 150px; }
  .cal-plot { min-height: 120px; }
}

@media (max-width: 1020px) {
  .span-7, .span-5 { grid-column: span 12; }
  .signal-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sig-feat { grid-column: 1 / -1; border-left: 0 !important; border-top: var(--hair); }
  .sig-feat .feat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
  .bt-sub { gap: 16px; }
}

@media (max-width: 760px) {
  .topbar { height: 48px; padding: 0 16px; gap: 10px; }
  .brand-mark { width: 19px; height: 19px; }
  .brand-name { font-size: 12px; }
  .brand-sub { display: none; }
  .topbar-mid { display: none; }
  .btn-label { display: none; }
  .conn span { display: none; }
  .conn { padding: 0 2px; }
  .app { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px 16px 20px; }
  .card-head { padding: 0 12px; min-height: 36px; }
  .card-foot { padding: 7px 12px; font-size: 9.5px; }
  .signal-grid { grid-template-columns: minmax(0, 1fr); }
  .sig-col { padding: 12px; }
  .sig-col + .sig-col { border-left: 0; border-top: var(--hair); }
  .sig-feat { grid-column: auto; }
  .sig-feat .feat-list { grid-template-columns: minmax(0, 1fr); }
  .bt-left, .bt-right { padding: 12px; }
  .bt-sub { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics .metric { border-top: var(--hair); }
  .metrics .metric:nth-child(1), .metrics .metric:nth-child(2) { border-top: 0; }
  .metrics .metric:nth-child(2n) { border-left: var(--hair); }
  .metrics .metric:nth-child(3) { border-left: 0; }
  .metrics .metric:last-child { grid-column: span 2; border-left: 0; }
  .m-value { font-size: 18px; }
  .chart-wrap { height: 208px; }
  .paper-body { padding: 12px; }
  .chart-body { padding: 10px 10px 6px; }
  .page-foot { padding: 10px 16px 22px; gap: 6px; flex-direction: column; align-items: flex-start; }
  .page-foot .foot-right { margin-left: 0; }
  .tbl tbody td { height: 32px; padding: 0 8px; font-size: 11px; }
  .tbl thead th { padding: 0 8px; }
  .tbl-wrap-signals, .tbl-wrap-orders { max-height: 340px; }
  .card-meta { gap: 6px; font-size: 9px; }
  .meta-sep { display: none; }
  .cal-plot { margin-left: 22px; }
}

@media (max-width: 560px) {
  #btRange { display: none; }
  .meta-range { display: none; }
  .tbl-bench thead th, .tbl-bench tbody td { padding: 0 6px; font-size: 9.5px; }
  .tbl-bench .tag { display: none; }
  .tbl-pos .pos-name { display: none; }
  .tbl-pos th:nth-child(1) { width: 27%; }
  .tbl-pos th:nth-child(2) { width: 16%; }
  .tbl-pos th:nth-child(3) { width: 18%; }
  .tbl-pos th:nth-child(4) { width: 17%; }
  .tbl-pos th:nth-child(5) { width: 22%; }
  .paper-pos .tbl tbody td { padding: 0 4px; font-size: 9.5px; }
  .paper-pos .tbl thead th { padding: 0 4px; }
  /* 注意：表格单元格不能用 display:none（会被重排到前面的列），用 visibility 保持列映射 */
  .tbl-orders th:nth-child(4), .tbl-orders td:nth-child(4),
  .tbl-orders th:nth-child(5), .tbl-orders td:nth-child(5),
  .tbl-orders th:nth-child(7), .tbl-orders td:nth-child(7) {
    visibility: hidden; padding: 0; border-bottom: 0; font-size: 0;
  }
  .tbl-orders .c-qty, .tbl-orders .c-price, .tbl-orders .c-fee { width: 0; }
  .tbl-orders .c-time { width: 22%; }
  .tbl-orders .c-sym { width: 18%; }
  .tbl-orders .c-side { width: 14%; }
  .tbl-orders .c-filled { width: 24%; }
  .tbl-orders .c-status { width: 22%; }
  .tbl-orders tbody td { padding: 0 5px; }
  .tbl-signals .c-name { width: 0; }
  .tbl-signals th.col-name, .tbl-signals td.col-name {
    visibility: hidden; padding: 0; border-bottom: 0; font-size: 0;
  }
  .tbl-signals .c-time { width: 15%; }
  .tbl-signals .c-sym { width: 19%; }
  .tbl-signals .c-dir { width: 12%; }
  .tbl-signals .c-prob { width: 12%; }
  .tbl-signals .c-conf { width: 13%; }
  .tbl-signals .c-price { width: 16%; }
  .tbl-signals .c-status { width: 13%; }
  .tbl-signals tbody td { padding: 0 5px; font-size: 9.5px; }
  .tbl-signals thead th { padding: 0 5px; font-size: 9px; }
  .sym-name-m {
    display: block; font-family: var(--font-ui); font-size: 8.5px;
    color: var(--text-2); line-height: 1.2; margin-top: -1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .tbl-signals tbody td { height: 34px; }
  .tbl-signals .t-date { display: none; }
  .st-full { display: none; }
  .st-short { display: inline; }
  .tbl-orders tbody td { height: 32px; font-size: 10px; }
  .t-time .t-date { display: none; }
  .sig-dir { font-size: 20px; }
  .sig-price { font-size: 19px; }
  .sig-kv { gap: 12px; }
  .card-title { gap: 6px; }
  .card-sub { display: none; }
  .prob-item b { font-size: 13px; }
  .feat-row { grid-template-columns: minmax(52px, 78px) minmax(0, 1fr) 42px 40px; }
  .sup-hide { display: none; }
  .page-foot .foot-mid { display: none; }
}

/* 窄屏下仍保持单列密度：短表头 */
@media (max-width: 400px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .card-meta { max-width: 46%; }
}

/* ---- 15. reduced motion：关闭全部动画（DESIGN.md §2） ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sk::after { display: none; }
  .card { animation: none; opacity: 1; transform: none; }
  .eq-svg .eq-area { transition: none; }
}
