/* kline-ai-trader 面板样式 —— 固定亮色主题，禁止跟随系统深色模式。
 *
 * 设计系统「Ledger」：财经终端的克制感 + 编辑排版的秩序感。
 *   - 三层字体：display（Bahnschrift 窄体 grotesk，标题/导航/标签）
 *              / mono（等宽，所有数字数据 tabular-nums）
 *              / body（系统中文 UI 字体，正文与中文标题）
 *   - 品牌色仅用于交互态/操作态（Kelly 规则：荧光绿底 + 黑字 = 动作/选中），
 *     绝不与多空语义色混用；多头/空头始终是唯一的绿/红。
 */

:root {
  /* 版面 */
  --page-max: 1320px;

  /* 表面 */
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-sunken: #eceef2;
  --surface-tint: #f8f9fb;

  /* 墨色 */
  --ink: #14161c;
  --ink-2: #565b66;
  --ink-3: #8b8f99;
  --hairline: #e0e2e8;
  --hairline-strong: #c7cbd4;

  /* 品牌荧光绿 —— 仅用于交互/操作态，不参与多空语义 */
  --brand: #d2ff3d;
  --brand-strong: #b8e61f;
  --brand-tint: #f4ffd9;
  --brand-ink: #14161c;

  /* 交易语义色：多头/空头，铁律不变 */
  --long: #16a34a;
  --long-strong: #157a3a;
  --long-bg-1: #f0fdf4;
  --long-bg-2: #bbf7d0;
  --long-bg-3: #86efac;
  --short: #dc2626;
  --short-strong: #b91c1c;
  --short-bg-1: #fef2f2;
  --short-bg-2: #fecaca;
  --short-bg-3: #fca5a5;
  --flat: #78808f;
  --flat-bg: #eceef2;

  /* 状态色 */
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --warn-border: #fde68a;
  --info: #3457d5;
  --info-bg: #eef2ff;

  /* 模型分类色（图表用，刻意避开纯红/纯绿以免与多空语义冲突） */
  --m1: #3457d5;
  --m2: #d97706;
  --m3: #8b5cf6;
  --m4: #0e9488;
  --m5: #db2777;

  --shadow-sm: 0 1px 0 rgba(20, 22, 28, 0.03), 0 1px 3px rgba(20, 22, 28, 0.06);
  --shadow-md: 0 4px 10px -4px rgba(20, 22, 28, 0.12), 0 1px 2px rgba(20, 22, 28, 0.06);

  --font-display: "Bahnschrift", "SF Compact Display", "Segoe UI Semibold", "Segoe UI", -apple-system, sans-serif;
  --font-body: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", "JetBrains Mono", Consolas, "Microsoft YaHei", monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

::selection { background: var(--brand); color: var(--brand-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 6px; border: 2px solid var(--bg); }

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

/* ---------------------------------------------------------------- 导航 */

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  padding: 0 28px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topnav .brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-right: 28px;
  white-space: nowrap;
}

.topnav .brand .mark {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  flex: 0 0 auto;
}

.topnav a {
  font-family: var(--font-display);
  color: var(--ink-2);
  padding: 8px 15px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.topnav a:hover { background: var(--surface-sunken); text-decoration: none; color: var(--ink); }
.topnav a.active { color: var(--ink); background: var(--brand); font-weight: 700; }

/* ---------------------------------------------------------------- 版面基础 */

.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px 28px 56px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0 26px;
}
.page-head .bar {
  width: 4px;
  height: 26px;
  background: var(--brand);
  border-radius: 2px;
  flex: 0 0 auto;
}
.page-head h1 { margin: 0; }
.page-head .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 4px;
}

h1 {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 18px;
  color: var(--ink);
}
h1 .badge { vertical-align: middle; margin-left: 4px; }

h2 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 34px 0 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-2);
}
h2:first-of-type { margin-top: 0; }

h3 {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 14px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 22px;
}

.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 17px 19px;
}
.stat-card.is-halted { border-left-color: var(--short); }
.stat-card.is-paused { border-left-color: var(--flat); opacity: 0.82; }

.stat-card .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 11px;
}
/* 精确模型 ID 比品牌名长，允许换行，绝不截断/省略号 */
.stat-card .label { overflow-wrap: anywhere; }

.stat-card .value {
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.stat-card .value .unit {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 3px;
  letter-spacing: 0;
}

.stat-card .metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--hairline);
}
.stat-card .metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat-card .metric .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  white-space: nowrap;
}
.stat-card .metric .v {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card .banner { margin: 12px 0 8px; }

/* ---------------------------------------------------------------- 徽章 / 标签 */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.badge-active, .badge-ok, .badge-done { background: var(--long-bg-1); color: var(--long-strong); }
.badge-paused { background: var(--flat-bg); color: var(--flat); }
.badge-halted, .badge-failed, .badge-parse_failed, .badge-api_failed { background: var(--short-bg-1); color: var(--short-strong); }
.badge-partial { background: var(--warn-bg); color: var(--warn); }
.badge-running { background: var(--info-bg); color: var(--info); }

.flag-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  margin-right: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pill-long { background: var(--long-bg-1); color: var(--long-strong); }
.pill-short { background: var(--short-bg-1); color: var(--short-strong); }

.text-green { color: var(--long-strong); }
.text-red { color: var(--short-strong); }
.text-muted { color: var(--ink-3); }
.model-note {
  display: block;
  margin-top: 3px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
}
.model-heading-note { margin: -8px 0 12px; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 表格 */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
table.plain { background: transparent; }
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
th {
  font-family: var(--font-display);
  color: var(--ink-3);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  background: var(--surface-sunken);
}
tbody tr:hover { background: var(--surface-tint); }
tbody tr:last-child td { border-bottom: none; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.table-wrap table { border: none; box-shadow: none; }

.chart-box { width: 100%; height: 400px; }
.chart-box-sm { width: 100%; height: 230px; }

/* ---------------------------------------------------------------- 矩阵热力格 */

.matrix-table td { text-align: center; padding: 4px; white-space: normal; }
.matrix-table th {
  text-align: center;
  white-space: normal;
  font-size: 9.5px;
  line-height: 1.3;
  padding: 8px 5px;
  word-break: break-word;
}
.matrix-table .symbol-cell {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--surface-sunken);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.mcell {
  display: block;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 78px;
}
.mcell .score { display: block; font-size: 11px; font-weight: 500; opacity: 0.8; margin-top: 2px; }
.mcell:hover { filter: brightness(0.96); text-decoration: none; }

.cell-long-1 { background: var(--long-bg-1); color: #15803d; }
.cell-long-2 { background: var(--long-bg-2); color: #14532d; }
.cell-long-3 { background: var(--long-bg-3); color: #14532d; }
.cell-short-1 { background: var(--short-bg-1); color: #b91c1c; }
.cell-short-2 { background: var(--short-bg-2); color: #7f1d1d; }
.cell-short-3 { background: var(--short-bg-3); color: #7f1d1d; }
.cell-flat { background: var(--flat-bg); color: var(--ink-3); }
.cell-missing {
  background: var(--surface-tint);
  color: #c3c8d1;
  border: 1px dashed var(--hairline);
  font-family: var(--font-body);
  font-weight: 500;
}

/* ---------------------------------------------------------------- 分段控件 (tabs / selector) */

.tabs, .selector-bar { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a, .selector-bar a {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  background: var(--surface);
  transition: border-color .12s, background .12s, color .12s;
}
.tabs a:hover, .selector-bar a:hover { border-color: var(--hairline-strong); color: var(--ink); text-decoration: none; }
.tabs a.active, .selector-bar a.active { background: var(--brand); color: var(--ink); border-color: var(--brand); font-weight: 700; }

/* 模型 ID 比品牌名长（如 gemini-3.1-pro-preview），药丸选择器收紧字号，绝不截断 */
.selector-bar.model-selector a { font-size: 11px; letter-spacing: 0; padding: 6px 12px; }

select {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
}

/* ---------------------------------------------------------------- 图表网格 (K线原图) */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.charts-grid figure {
  margin: 0;
  background: var(--surface-tint);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 10px 8px;
}
.charts-grid img { width: 100%; border-radius: 4px; display: block; }
.charts-grid figcaption {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-top: 8px;
  text-align: center;
}
.chart-missing {
  width: 100%; aspect-ratio: 4/3; border-radius: 4px; border: 1px dashed var(--hairline);
  display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 12px;
}

/* ---------------------------------------------------------------- 原始输出折叠块 */

details.raw-response { margin-top: 10px; }
details.raw-response summary {
  cursor: pointer;
  color: var(--info);
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 0;
}
pre.raw-block {
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  max-height: 420px;
  overflow: auto;
  box-shadow: inset 0 1px 2px rgba(20, 22, 28, 0.04);
}

/* ---------------------------------------------------------------- 空状态 / 提示条 */

.empty-state {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13px;
}

.banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 3px solid var(--warn);
  color: #7c4a03;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-block;
  background: var(--brand);
  color: var(--brand-ink);
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn-danger { background: var(--short); color: #fff; }
.btn-danger:hover { background: var(--short-strong); }
.btn:disabled { background: var(--hairline); color: var(--ink-3); cursor: not-allowed; }

/* ---------------------------------------------------------------- 其它工具类 */

.kv-table td:first-child {
  color: var(--ink-3);
  width: 170px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; font-size: 13px; font-family: var(--font-mono); }
.pager a, .pager span { padding: 5px 12px; border: 1px solid var(--hairline); border-radius: 999px; }
.pager a:hover { border-color: var(--hairline-strong); text-decoration: none; background: var(--surface-tint); }
.pager .current { background: var(--brand); color: var(--ink); border-color: var(--brand); font-weight: 700; }
