:root {
  --bg: #0b0e13;
  --bg-2: #121820;
  --bg-3: #18202b;
  --line: #263140;
  --line-2: #3a485c;
  --text: #e7edf5;
  --muted: #8b95a7;
  --faint: #667386;
  --up: #ef4545;
  --down: #1aa36a;
  --flat: #9aa3b2;
  --gold: #c6a15b;
  --gold-2: #e4c98a;
  --font: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --mono: Consolas, "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 13px/1.45 var(--font); border-top: 2px solid var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-2); text-decoration: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.app { height: 100%; display: flex; flex-direction: column; min-width: 1080px; }
.top, .h5-top { display: flex; align-items: center; gap: 14px; padding: 0 14px; height: 52px; background: #0c1118; border-bottom: 1px solid var(--line); }
.brand strong { display: block; letter-spacing: .08em; font-size: 16px; }
.brand em { display: block; font-style: normal; color: var(--faint); font-size: 11px; }
.chip { border: 1px solid var(--line-2); color: var(--gold-2); padding: 4px 8px; font-size: 12px; }
.spacer { flex: 1; }
.session { text-align: right; }
.session b { display: block; font-weight: 560; }
.session span { color: var(--faint); font-family: var(--mono); font-size: 12px; }

.tape { display: flex; overflow: auto; background: #0c1118; border-bottom: 1px solid var(--line); }
.tape button, .tape .cell { flex: 0 0 auto; border: 0; border-right: 1px solid var(--line); background: transparent; color: inherit; padding: 7px 12px; display: flex; gap: 8px; align-items: baseline; }
.tape .nm { color: var(--muted); font-size: 12px; }

.body { flex: 1; min-height: 0; display: flex; }
.nav { width: 156px; background: #0c1118; border-right: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav button { text-align: left; background: transparent; border: 0; color: var(--muted); padding: 8px 10px; }
.nav button.active { color: var(--text); background: #171e29; box-shadow: inset 2px 0 var(--gold); }
.nav .foot { margin-top: auto; color: var(--faint); font-size: 11px; padding: 8px; line-height: 1.5; }
#main { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 14px 16px 28px; }
.eyebrow { color: var(--gold); font-size: 11px; letter-spacing: .16em; }
h1 { font-size: 18px; margin: 4px 0 6px; font-weight: 620; }
.lead { color: var(--muted); margin: 0 0 12px; max-width: 820px; }

.stats, .metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat, .metric { background: var(--bg-2); border: 1px solid var(--line); padding: 10px 12px; }
.stat span, .metric span { display: block; color: var(--faint); font-size: 12px; }
.stat b, .metric b { display: block; margin-top: 4px; font-family: var(--mono); font-size: 18px; font-weight: 600; }
.panel { background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.panel header { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--gold-2); font-size: 12px; letter-spacing: .08em; }
.pad { padding: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; }
.board-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 10px; min-height: 520px; }
.table-wrap { overflow: auto; max-height: 640px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: #151c27; color: var(--faint); font-weight: 500; font-size: 11px; text-align: right; padding: 7px 8px; }
th.l, td.l { text-align: left; }
td { padding: 6px 8px; border-bottom: 1px solid #1a2230; text-align: right; white-space: nowrap; }
tr:hover td { background: #17202c; }
tr.sel td { background: #1b2432; box-shadow: inset 2px 0 var(--gold); }
.toolbar, .form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 10px; }
label.field { display: flex; flex-direction: column; gap: 4px; color: var(--faint); font-size: 12px; }
input, select, textarea { background: #0c1118; border: 1px solid var(--line-2); border-radius: 2px; padding: 6px 8px; outline: none; }
textarea { min-height: 72px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.btn { background: transparent; border: 1px solid var(--gold); color: var(--gold-2); padding: 6px 12px; border-radius: 2px; }
.btn.ghost { border-color: var(--line-2); color: var(--text); }
.btn.danger { border-color: #6d3438; color: #e7a8ab; }
.btn:disabled { opacity: .45; }
.note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.empty { padding: 16px 12px; color: var(--muted); }
.tag { display: inline-block; border: 1px solid var(--line-2); color: var(--faint); font-size: 11px; padding: 0 4px; margin-right: 6px; }
.chart-box { position: relative; height: 280px; background: #0e141c; border: 1px solid var(--line); }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.side-h { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.px-lg { font-family: var(--mono); font-size: 28px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px 12px; }
.facts span { display: block; color: var(--faint); font-size: 11px; }
.facts b { font-family: var(--mono); font-weight: 540; }
.marks { padding: 0 12px 12px; }
.mark { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding: 6px 0; font-size: 12px; }
.kind-watch { color: #e4c98a; }
.kind-add { color: #7eb6ff; }
.kind-pressure { color: var(--up); }
.kind-risk { color: var(--down); }

.foot { height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; background: #0c1118; }
.toast { position: fixed; right: 16px; bottom: 48px; z-index: 40; background: #17202c; border: 1px solid var(--gold); padding: 10px 12px; max-width: 380px; }
.toast.bad { border-color: var(--up); }
.mask { position: fixed; inset: 0; background: rgba(6,8,12,.62); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dialog { width: min(420px, calc(100% - 32px)); background: #141b25; border: 1px solid var(--line-2); padding: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.ai-fab { position: fixed; right: 18px; bottom: 42px; z-index: 20; background: #141b25; border: 1px solid var(--gold); color: var(--gold-2); padding: 8px 12px; }
.ai-panel { position: fixed; right: 18px; bottom: 84px; width: min(420px, calc(100% - 24px)); height: min(560px, calc(100% - 120px)); background: #10161e; border: 1px solid var(--gold); z-index: 21; display: none; flex-direction: column; }
.ai-panel.open { display: flex; }
.ai-panel header { padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--gold-2); display: flex; justify-content: space-between; }
.ai-log { flex: 1; overflow: auto; padding: 10px 12px; }
.ai-msg { margin-bottom: 10px; white-space: pre-wrap; }
.ai-msg.user { color: var(--gold-2); }
.ai-form { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.ai-form input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.chips button { background: transparent; border: 1px solid var(--line-2); color: var(--muted); padding: 3px 8px; font-size: 12px; }

.check { flex-direction: row; align-items: center; color: var(--muted); }

body.h5 { min-width: 0; }
.happ { min-height: 100%; }
.h5-top { height: auto; padding: 10px 12px; }
.h5-main { padding: 12px 12px calc(120px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #0c1118; border-top: 1px solid var(--line); z-index: 6; padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; height: 52px; background: transparent; border: 0; color: var(--muted); }
.tabbar button.active { color: var(--gold-2); box-shadow: inset 0 -2px var(--gold); }
.qrow { width: 100%; display: flex; justify-content: space-between; gap: 8px; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 10px 2px; text-align: left; color: inherit; }
.qrow b { font-family: var(--mono); font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack .btn, .stack input, .stack select { width: 100%; }
.banner { position: sticky; top: 0; background: #2a1c14; border: 1px solid var(--gold); color: var(--gold-2); padding: 8px 10px; margin-bottom: 8px; }
body.h5 .ai-panel { left: 8px; right: 8px; width: auto; bottom: 64px; }
body.h5 .ai-fab { bottom: 64px; }
@media (max-width: 1280px) {
  .stats, .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .board-layout { grid-template-columns: 1fr; }
}
