/* ================= Design tokens (TradingView-inspired dark, dense) ================= */
:root {
  --bg: #0d1117; --bg-2: #131a24; --surface: #161d29; --surface-2: #1b2331; --surface-3: #222c3c;
  --border: #232d3d; --border-2: #2f3b4e;
  --text: #e6ebf3; --text-2: #a7b1c2; --text-3: #94a0b4;
  --accent: #2f81f7; --accent-2: #1f6fe0; --accent-soft: rgba(47,129,247,.15);
  --green: #26a69a; --green-soft: rgba(38,166,154,.16); --red: #ef5350; --red-soft: rgba(239,83,80,.16);
  --amber: #f5a524; --amber-soft: rgba(245,165,36,.16); --purple: #a78bfa;
  --shadow: 0 12px 32px rgba(0,0,0,.4);
  --radius: 10px; --radius-sm: 6px;
  --rail-w: 60px; --topbar-h: 48px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang HK", "Noto Sans TC", "Helvetica Neue", sans-serif;
}
[data-theme="light"] {
  --bg: #f5f7fa; --bg-2: #eceff4; --surface: #ffffff; --surface-2: #f6f8fb; --surface-3: #eaeef4;
  --border: #e1e6ee; --border-2: #cbd3df;
  --text: #131722; --text-2: #4a5568; --text-3: #667386;
  --accent-soft: rgba(47,129,247,.12); --green-soft: rgba(38,166,154,.14); --red-soft: rgba(239,83,80,.12); --amber-soft: rgba(245,165,36,.16);
  --green: #087f68; --red: #ce2d3c; --amber: #d97706;
  --shadow: 0 12px 32px rgba(19,23,34,.12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; color: inherit; }
kbd { font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 4px; padding: 1px 5px; color: var(--text-3); }
.pos { color: var(--green); } .neg { color: var(--red); } .muted { color: var(--text-3); } .sub { color: var(--text-2); }
.mono { font-family: var(--mono); }
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ================= Shell ================= */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; }
.rail { background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; }
.rail-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; margin-bottom: 10px; }
.rail a { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 52px; padding: 8px 0; border-radius: 8px; color: var(--text-3); font-size: 10px; font-weight: 550; }
.rail a svg { width: 20px; height: 20px; }
.rail a:hover { background: var(--surface-2); color: var(--text); }
.rail a.active { background: var(--accent-soft); color: var(--accent); }
.rail-foot { margin-top: auto; }
.rail-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text-3); cursor: pointer; font-size: 16px; }
.rail-btn:hover { color: var(--text); border-color: var(--border-2); }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); flex-shrink: 0; }
.topbar .spacer { flex: 1; }
.content { --pad-t: 14px; --pad-x: 16px; --pad-b: 30px; flex: 1; min-height: 0; overflow: auto; padding: var(--pad-t) var(--pad-x) var(--pad-b); display: flex; flex-direction: column; gap: 14px; }
.content.desk-page { padding: 0; overflow: hidden; }

.search-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-3); cursor: pointer; min-width: 220px; font-size: 12.5px; }
.search-btn svg { width: 14px; height: 14px; } .search-btn span { flex: 1; text-align: left; }
.search-btn:hover { border-color: var(--accent); color: var(--text-2); }
.clock { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); padding: 0 10px; height: 32px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.clock .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.clock .dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.clock b { font-family: var(--mono); font-weight: 500; color: var(--text); }
.scan-status { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 15px; color: var(--text-3); }
.icon-btn.on { color: var(--amber); border-color: var(--amber); }

/* ================= Components ================= */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-weight: 550; font-size: 12.5px; cursor: pointer; transition: .12s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.sm { padding: 5px 9px; font-size: 12px; } .btn.xs { padding: 2px 7px; font-size: 11px; border-radius: 5px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); } .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--red); } .btn.success { color: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.spin { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 550; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--border-2); color: var(--text); } .chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 650; letter-spacing: .03em; line-height: 1.5; }
.badge.long { background: var(--green-soft); color: var(--green); } .badge.short { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); } .badge.accent { background: var(--accent-soft); color: var(--accent); } .badge.amber { background: var(--amber-soft); color: var(--amber); }
.tag { display: inline-flex; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; background: var(--surface-3); color: var(--text-2); font-weight: 550; }
.tag.close-sess { background: var(--amber-soft); color: var(--amber); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card .hd { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.card .hd h3 { margin: 0; font-size: 13px; font-weight: 650; } .card .hd .spacer { flex: 1; }
.card .bd { padding: 14px; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; }
.kpi .l { font-size: 11.5px; color: var(--text-3); font-weight: 550; } .kpi .v { font-size: 20px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; } .kpi .s { font-size: 11.5px; color: var(--text-2); margin-top: 1px; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.input, select.input { background: var(--surface); border: 1px solid var(--border-2); color: var(--text); border-radius: 7px; padding: 6px 9px; font-size: 12.5px; font-family: inherit; outline: none; min-width: 0; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } .input.sm { padding: 4px 8px; font-size: 12px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); font-size: 12.5px; } .empty b { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sh 1.4s infinite; border-radius: 6px; height: 14px; }
@keyframes sh { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }
.bar { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; } .bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar.g > i { background: var(--green); } .bar.r > i { background: var(--red); }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 8px; width: fit-content; }
.tabs button { border: 0; background: transparent; color: var(--text-2); padding: 5px 12px; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 12.5px; white-space: nowrap; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.tabs button.long.active { color: var(--green); } .tabs button.short.active { color: var(--red); }
.market-seg button.active { color: var(--accent); }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; }

/* tables */
.tbl-wrap { overflow: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
.tbl th.r, .tbl td.r { text-align: right; } .tbl th:hover { color: var(--text); } .tbl th.sorted { color: var(--accent); }
.tbl th.sorted::after { content: " ↓"; } .tbl th.sorted.asc::after { content: " ↑"; }
.tbl td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; height: 34px; }
.tbl tbody tr { cursor: pointer; } .tbl tbody tr:hover { background: var(--surface-2); } .tbl tr.dim td { color: var(--text-3); }
.tbl .sym { font-weight: 650; font-family: var(--mono); font-size: 12.5px; }
.tbl .mini-bar { display: inline-flex; align-items: center; gap: 6px; } .tbl .mini-bar .bar { width: 46px; }
.tbl td.cell-pos { background: var(--green-soft); color: var(--green); } .tbl td.cell-neg { background: var(--red-soft); color: var(--red); }
.tbl td.history-reasons { min-width: 240px; max-width: 390px; white-space: normal; line-height: 1.4; overflow-wrap: anywhere; }
.history-reason-label { color: var(--text-3); font-size: 10.5px; font-weight: 650; }
.history-reason-note { margin-top: 3px; color: var(--text-2); }
.history-exit-note { margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--border); color: var(--text-2); }
.pager { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.star { cursor: pointer; color: var(--text-3); font-size: 14px; } .star.on { color: var(--amber); }

/* ================= Desk (3-pane) ================= */
.desk { display: grid; grid-template-columns: var(--list-w, 340px) 6px minmax(0, 1fr) 6px var(--market-w, 300px); height: 100%; min-height: 0; }
.splitter { cursor: col-resize; background: var(--border); position: relative; z-index: 2; transition: background .12s; }
.splitter:hover, .splitter.active { background: var(--accent); }
.splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: -4px; right: -4px; }
body.resizing { cursor: col-resize; user-select: none; } body.resizing * { pointer-events: none; }
.pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.pane:last-child { border-right: 0; }
.pane-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-2); flex-shrink: 0; }
.pane-tabs button { flex: 1; border: 0; background: transparent; padding: 9px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.pane-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.pane-tabs button .n { font-size: 10.5px; background: var(--surface-3); color: var(--text-2); padding: 0 5px; border-radius: 4px; } .pane-tabs button.active .n { background: var(--accent-soft); color: var(--accent); }
.pane-filters { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.pane-filters .hint { font-size: 11px; color: var(--text-3); margin-left: auto; }
.list { overflow: auto; flex: 1; }
.lrow { display: grid; grid-template-columns: 82px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer; min-height: 44px; }
.lrow:hover { background: var(--surface-2); } .lrow.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.lrow .sym { font-family: var(--mono); font-weight: 650; font-size: 12.5px; display: flex; flex-direction: column; gap: 1px; }
.lrow .sym small { font-family: var(--sans); font-weight: 500; font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78px; }
.lrow .mid { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lrow .mid .l1 { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.lrow .mid .l1.signal-labels { flex-wrap: wrap; white-space: normal; overflow: visible; }
.lrow .mid .l2 { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lrow .mid .l2.signal-meta { flex-wrap: wrap; white-space: normal; overflow: visible; }
.lrow .mid .l2 > span { white-space: nowrap; }
.lrow .mid .bar { width: 44px; flex-shrink: 0; }
.lrow .px { text-align: right; font-family: var(--mono); font-size: 12.5px; display: flex; flex-direction: column; gap: 1px; }
.lrow .px b { font-weight: 600; } .lrow .px small { font-size: 11px; }
.lrow.long-side { border-left: 2px solid var(--green); } .lrow.short-side { border-left: 2px solid var(--red); }
.list-group { padding: 6px 10px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; background: var(--bg-2); position: sticky; top: 0; z-index: 1; }

.chart-pane { background: var(--bg); }
.sym-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0; min-height: 52px; }
.sym-head .symbol { font-size: 20px; font-weight: 700; font-family: var(--mono); letter-spacing: -.01em; }
.co-name { font-size: 14px; font-weight: 600; color: var(--text-2); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-head .price { font-size: 18px; font-weight: 600; font-family: var(--mono); }
.sym-head .meta { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sym-head .spacer { flex: 1; }
.chart-tools { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.chart-tools .ivl { display: flex; gap: 1px; background: var(--surface-2); border-radius: 6px; padding: 2px; }
.chart-tools .ivl button { border: 0; background: transparent; color: var(--text-3); font-family: var(--mono); font-size: 11.5px; padding: 3px 8px; border-radius: 4px; cursor: pointer; font-weight: 600; }
.chart-tools .ivl button.active { background: var(--surface); color: var(--text); }
.chart-tools .legend { display: flex; gap: 10px; font-size: 11px; color: var(--text-3); margin-left: 6px; }
.chart-tools .legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; }
.chart-body { flex: 1; min-height: 260px; position: relative; }
.chart-body #chart { position: absolute; inset: 0; }
.chart-body .chart-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 12.5px; pointer-events: none; }
.stats-strip { display: flex; gap: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; background: var(--bg-2); }
.stats-strip div { padding: 7px 12px; border-right: 1px solid var(--border); white-space: nowrap; }
.stats-strip .l { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; } .stats-strip .v { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.analysis { overflow: auto; flex: 0 0 300px; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.analysis.collapsed { flex-basis: 40px; overflow: hidden; }
.analysis-head { display: flex; align-items: center; gap: 8px; }
.narrative { font-size: 13px; line-height: 1.65; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 6px; }
.check { display: flex; gap: 9px; align-items: flex-start; padding: 7px 10px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); }
.check .ic { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.check.ok .ic { background: var(--green-soft); color: var(--green); } .check.no .ic { background: var(--red-soft); color: var(--red); }
.check .t { font-weight: 600; font-size: 12.5px; } .check .d { font-size: 11.5px; color: var(--text-2); }
.plan-box { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.plan-box > div { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; }
.plan-box .l { font-size: 10.5px; color: var(--text-3); font-weight: 550; } .plan-box .v { font-size: 15px; font-weight: 650; font-family: var(--mono); }

.market-pane { background: var(--bg-2); overflow: auto; }
.mp-section { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.mp-section h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.mp-section h4 .spacer { flex: 1; }
.sec-row { display: grid; grid-template-columns: 16px 1fr 70px 46px; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; font-size: 11.5px; border-radius: 4px; }
.sec-row:hover { background: var(--surface-2); }
.sec-row .rk { color: var(--text-3); font-size: 10.5px; font-family: var(--mono); } .sec-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.sec-row .trk { position: relative; height: 8px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.sec-row .trk i { position: absolute; top: 0; bottom: 0; } .sec-row .trk .z { left: 50%; width: 1px; background: var(--border-2); }
.sec-row .trk .f.pos { left: 50%; background: var(--green); } .sec-row .trk .f.neg { right: 50%; background: var(--red); }
.sec-row .v { text-align: right; font-family: var(--mono); font-size: 11px; font-weight: 600; }
.breadth { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.breadth i { display: block; height: 100%; }
.mp-kv { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 0; } .mp-kv b { font-family: var(--mono); font-weight: 600; }
.mover { display: grid; grid-template-columns: 70px 1fr auto; gap: 6px; font-size: 11.5px; padding: 3px 0; cursor: pointer; border-radius: 4px; align-items: center; }
.mover:hover { background: var(--surface-2); } .mover .sym { font-family: var(--mono); font-weight: 650; } .mover .sec { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.mover .v { font-family: var(--mono); font-weight: 600; }

/* ================= Heatmap ================= */
.heatmap-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
#heatmap { flex: 1; min-height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); position: relative; }
#heatmap svg { display: block; }
#heatmap .hm-labels { position: absolute; inset: 0; pointer-events: none; }
#heatmap .hm-sec { position: absolute; font-size: 12px; font-weight: 600; line-height: 14px; color: var(--text); white-space: nowrap; overflow: hidden; }
.hm-legend { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); }
.hm-legend .scale { width: 160px; height: 10px; border-radius: 4px; background: linear-gradient(90deg, #ef5350, #4a4f5a, #26a69a); }
.tooltip { position: fixed; z-index: 120; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow); pointer-events: none; display: none; max-width: 280px; }
.tooltip b { font-family: var(--mono); font-size: 13px; } .tooltip .r { display: flex; justify-content: space-between; gap: 14px; }

/* ================= Drawer / modal / search ================= */
.overlay { position: fixed; inset: 0; background: rgba(2,6,23,.55); backdrop-filter: blur(2px); z-index: 40; opacity: 0; pointer-events: none; transition: .2s; } .overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 96vw); background: var(--bg); border-left: 1px solid var(--border); z-index: 50; transform: translateX(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer.open { transform: translateX(0); }
.drawer .dh { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.drawer .dh .symbol { font-size: 20px; font-weight: 700; font-family: var(--mono); } .drawer .dh .price { font-size: 18px; font-weight: 600; font-family: var(--mono); }
.drawer .dbody { overflow: auto; padding: 14px 18px 30px; display: flex; flex-direction: column; gap: 12px; }
.drawer #dchart { height: 320px; flex: 0 0 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; } .stats .l { font-size: 10.5px; color: var(--text-3); font-weight: 550; } .stats .v { font-weight: 650; font-family: var(--mono); }
.modal-bg { position: fixed; inset: 0; background: rgba(2,6,23,.62); backdrop-filter: blur(2px); z-index: 80; display: none; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 18px 20px; width: min(440px, 92vw); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.modal h3 { margin: 0; font-size: 15px; } .modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .modal .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.search-bg { align-items: flex-start; padding-top: 12vh; }
.search-box { background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; width: min(640px, 94vw); box-shadow: var(--shadow); overflow: hidden; }
.search-input { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-input svg { width: 16px; height: 16px; color: var(--text-3); } .search-input input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text); font-size: 15px; font-family: inherit; }
.search-results { max-height: 50vh; overflow: auto; }
.sr { display: grid; grid-template-columns: 90px 1fr auto auto; gap: 10px; align-items: center; padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.sr:hover, .sr.sel { background: var(--accent-soft); } .sr .sym { font-family: var(--mono); font-weight: 650; } .sr .sec { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr .px { font-family: var(--mono); text-align: right; }
.field label { display: block; font-size: 11.5px; color: var(--text-2); font-weight: 550; margin-bottom: 3px; } .field .input { width: 100%; } .field .help { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.switch input { appearance: none; width: 34px; height: 19px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; cursor: pointer; transition: .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--text-3); transition: .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); } .switch input:checked::after { left: 17px; background: #fff; }
.setup-card { border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; background: var(--surface-2); }
.setup-card .hd2 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; } .setup-card .hd2 b { font-size: 13px; }
.setup-card .form-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.qqq-setup-footer { display: flex; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); text-align: right; }
.qqq-setup-footer .switch { align-items: flex-start; }
.qqq-setup-footer .switch span { max-width: 330px; }
.qqq-setup-footer .switch small { display: block; font-weight: 400; line-height: 1.4; margin-top: 3px; }
.preset-library { display: grid; gap: 12px; }
.builtin-presets, .custom-preset-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.custom-preset { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.custom-preset.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.custom-preset .btn { border: 0; border-radius: 0; min-height: 36px; }
.custom-preset .preset-main { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-preset .btn + .btn { border-left: 1px solid var(--border); }
.custom-preset .danger:hover { color: var(--red); }
.preset-empty { width: 100%; padding: 12px; border: 1px dashed var(--border); border-radius: 8px; }
.preset-note { font-size: 11.5px; }
.preset-save-panel { display: grid; grid-template-columns: minmax(180px,1fr) minmax(180px,280px) auto; align-items: end; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.preset-save-panel > div { display: grid; gap: 4px; font-size: 12px; }
.preset-save-panel .muted { font-size: 11px; }
/* 設定頁頂部分頁同底部儲存列：貼實捲動區邊（抵銷 content 內距），全闊實色底，後面內容唔會露出嚟 */
.savebar { position: sticky; bottom: calc(-1 * var(--pad-b)); z-index: 5; margin: 0 calc(-1 * var(--pad-x)) calc(-1 * var(--pad-b)); padding: 10px var(--pad-x) calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-2); border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(0, 0, 0, .12); display: flex; gap: 10px; align-items: center; }
.savebar .dirty-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-left: 7px; vertical-align: middle; }
.savebar .dirty-dot[hidden] { display: none; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 130; }
.toast { background: var(--surface); border: 1px solid var(--border-2); border-radius: 9px; padding: 9px 13px; font-size: 12.5px; box-shadow: var(--shadow); animation: up .2s; max-width: 380px; }
.toast.ok { border-left: 3px solid var(--green); } .toast.err { border-left: 3px solid var(--red); } .toast.alert { border-left: 3px solid var(--amber); }
@keyframes up { from { transform: translateY(8px); opacity: 0 } }
#equity { height: 220px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }

@media (max-width: 1100px) { .desk { grid-template-columns: var(--list-w, 290px) 6px minmax(0, 1fr); } .market-pane, .splitter.right { display: none; } }
@media (max-width: 900px) {
  /* Keep navigation in layout: content cannot scroll underneath it. dvh follows browser chrome. */
  .app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  .main { order: 0; flex: 1; height: auto; min-height: 0; }
  .rail { order: 1; flex: 0 0 auto; flex-direction: row; height: calc(56px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); padding: 0 max(2px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(2px, env(safe-area-inset-left)); gap: 0; justify-content: space-around; z-index: 30; }
  .rail a { flex: 1; min-width: 0; width: auto; min-height: 44px; }
  .rail-logo, .rail-foot, .clock, .search-btn span, .search-btn kbd { display: none; }
  .topbar { height: auto; min-height: 48px; padding: 6px 10px; gap: 6px; flex-wrap: wrap; }
  .topbar .spacer { min-width: 0; }
  .scan-status { order: 10; width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; }
  .search-btn { min-width: 32px; padding: 0 8px; }
  .content { --pad-t: 10px; --pad-x: 10px; --pad-b: 24px; scroll-padding-bottom: 24px; }
  .content > * { flex-shrink: 0; min-width: 0; }
  .content.desk-page { overflow: auto; }
  .desk { width: 100%; height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: clamp(220px, 35dvh, 320px) auto; }
  .pane { min-width: 0; }
  .splitter { display: none; }
  .list-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .chart-pane { min-height: 620px; }
  .chart-body { flex: none; height: 300px; }
  .analysis { flex: none; overflow: visible; }
  .analysis.collapsed { height: 40px; overflow: hidden; }
  .plan-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checks { grid-template-columns: minmax(0, 1fr); }
  .grid.responsive-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .card .hd { flex-wrap: wrap; }
  .btn[data-apply] { white-space: normal; text-align: left; max-width: 100%; }
  .setup-card { min-width: 0; }
  .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%,220px),1fr)); }
  .card .hd h3 { flex-shrink: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-width: 0; padding: 10px; }
  .kpi .v { font-size: 18px; overflow-wrap: anywhere; }
  .tbl-wrap { max-width: 100%; }
  .tbl th, .tbl td { height: 44px; }
  .savebar > .btn { flex: 1; }
  .preset-save-panel { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .preset-save-panel .btn { width: 100%; justify-content: center; }
  .custom-preset { width: 100%; }
  .custom-preset .preset-main { flex: 1; max-width: none; text-align: left; }
  .btn, .input, select.input { min-height: 40px; }
  input.input, select.input, textarea.input, .search-input input { font-size: 16px; }
  .chip { min-height: 32px; }
  .pager { flex-wrap: wrap; }
  .hm-legend { flex-wrap: wrap; }
  #heatmap { min-height: 480px; }
  .toasts { bottom: calc(68px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  .drawer { width: 100%; padding-bottom: env(safe-area-inset-bottom); }
  .modal { max-height: calc(100dvh - 32px - env(safe-area-inset-bottom)); overflow: auto; }
  .modal .row { grid-template-columns: minmax(0, 1fr); }
  .search-bg { padding-top: max(12px, env(safe-area-inset-top)); }
  .search-input input { min-width: 0; }
  .sr { grid-template-columns: 70px minmax(0, 1fr) auto; gap: 6px; }
  .sr > :last-child { grid-column: 2 / -1; }
}

@media (max-width: 360px) {
  #scan-btn { font-size: 0; gap: 0; padding: 8px; }
  #scan-btn svg { width: 18px; height: 18px; }
}

.tag.tf { background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-weight: 650; }
.preset-seg button.active { color: var(--amber); } .preset-seg button:disabled { cursor: default; }
.tf-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.tf-table th { text-align: left; font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px 4px 0; font-weight: 600; }
.tf-table td { padding: 3px 6px 3px 0; }
@media (max-width: 900px) { .preset-seg { display: none; } }

@keyframes cellflash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.flash { animation: cellflash 1.2s ease-out; border-radius: 3px; }

/* Private desks and realized P&L calendar */
.user-menu{display:flex;align-items:center;gap:8px;white-space:nowrap;font-size:12px}.user-avatar{width:27px;height:27px;border-radius:8px;background:var(--accent-soft,rgba(47,129,247,.15));display:grid;place-items:center;color:var(--text);font-weight:700}.user-menu button{color:var(--text-3);font-size:11px}.peer-picker{display:flex;gap:5px;align-items:center;flex-wrap:wrap}.peer-note{font-size:11px;color:var(--text-3)}
.auth-page{overflow:auto;display:grid;place-items:center;min-height:100vh;min-height:100dvh;background:radial-gradient(ellipse at 20% 0%,#192a3e,transparent 55%),#0d1117;color:#e6edf3}.auth-card{width:min(420px,calc(100vw - 40px));padding:38px;background:#131a23;border:1px solid #293443;border-radius:18px;box-shadow:0 24px 100px #0005}.auth-brand{font-size:28px;font-weight:700;color:#61a6ff;margin-bottom:42px}.auth-brand span{font-size:10px;letter-spacing:2px;color:#8495ac;margin-left:10px}.auth-card h1{font-size:30px;letter-spacing:-1px;margin-bottom:12px}.auth-card p{line-height:1.8;font-size:13px}.auth-card form{margin-top:30px;display:grid;gap:10px}.auth-card label{font-size:12px;color:#aebbd0}.auth-card input,.auth-card select{width:100%;margin-bottom:12px;background:#0d131c;color:#edf4ff;border-color:#334056;height:44px}.auth-card .primary{width:100%;justify-content:center;height:44px}.auth-footer{margin-top:26px;color:#768399;font-size:11px;text-align:center}#login-error{color:#fb8080;font-size:12px;margin:0}
@media(max-width:800px){.user-menu .user-name{display:none}.peer-picker{margin-bottom:10px}}

.lrow [data-quote] { max-width: 108px; white-space: normal; font-size: 9px; }

/* Shared review improvements: native controls, readable cards and mobile drill-down. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.mobile-back { display: none; }
.settings-sections { display: grid; gap: 12px; }
.settings-section { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.settings-section > summary { padding: 16px; cursor: pointer; font-weight: 650; font-size: 14px; }
.settings-section > .card { border: 0; margin: 0; }
.settings-section > .card > .hd { display: none; }
.sector-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px; margin: 16px 0; }
.sector-grid > h3 { grid-column: 1/-1; }
.stock-tile { display: flex; flex-direction: column; gap: 12px; padding: 18px; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); min-width: 0; }
.stock-tile:hover { border-color: var(--accent); }
.stock-tile strong { font: 650 24px var(--mono); }
.stock-tile small, .stock-tile > span { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.narrative { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; line-height: 1.7; margin: 12px 0; overflow-wrap: anywhere; }
@media(max-width:900px) {
  .desk { display: block; height: 100%; }
  .desk .list-pane { height: 100%; }
  .desk .chart-pane { display: none; }
  .desk.show-detail .list-pane { display: none; }
  .desk.show-detail .chart-pane { display: flex; min-height: 100%; }
  .mobile-back { display: inline-flex; flex: 0 0 auto; align-self: flex-start; margin: 8px; }
  .sector-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .stock-tile { padding: 12px; gap: 8px; }
  .stock-tile strong { font-size: 20px; }
  .tbl.mobile-cards, .tbl.mobile-cards tbody { display: block; width: 100%; min-width: 0; }
  .tbl.mobile-cards thead { display: none; }
  .tbl.mobile-cards tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 10px; gap: 4px 12px; border-bottom: 1px solid var(--border); }
  .tbl.mobile-cards tbody td { display: block; height: auto; min-width: 0; max-width: none; border: 0; padding: 5px 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .tbl.mobile-cards tbody td::before { content: attr(data-label); display: block; color: var(--text-2); font-size: 11px; font-weight: 400; margin-bottom: 3px; }
  .tbl.mobile-cards tbody td:first-child, .tbl.mobile-cards tbody td:last-child { grid-column: 1/-1; }
  .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(1) { order: -4; }
  .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(5), .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(9) { order: -3; }
  .tbl.mobile-cards .symcell { min-width: 0; }
  .settings-section > summary { padding: 14px; }
  .kpi .s { line-height: 1.6; }
}
.mobile-more { display: none; }
@media(max-width:900px) {
  .tbl.mobile-cards tbody tr:not(.expanded) td.mobile-secondary { display: none; }
  .tbl.mobile-cards tbody td.mobile-more { display: block; grid-column: 1/-1; order: 20; }
  .tbl.mobile-cards tbody td.mobile-more::before { display: none; }
  .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(2) { order: -5; grid-column: 1/-1; }
  .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(6), .tbl.mobile-cards[data-kind="screener"] tbody td:nth-child(12) { order: -3; }
  .tbl.mobile-cards[data-kind="screener"] tbody tr { position: relative; }
  .tbl.mobile-cards[data-kind="screener"] tbody td:first-child { position: absolute; right: 12px; top: 10px; }
  .tbl.mobile-cards[data-kind="history"] tbody td:nth-child(3), .tbl.mobile-cards[data-kind="history"] tbody td:nth-child(8) { order: -3; font-size: 16px; font-weight: 650; }
  .tbl.mobile-cards[data-kind="history"] tbody td.history-reasons { grid-column: 1/-1; }
}

@media(max-width:900px){.tbl-wrap:has(.mobile-cards){max-height:none !important;overflow:visible}.quote-stamp{font-size:11px;color:var(--text-2)}}

/* ================= 策略設定（Daytrade / Swing 第一級） ================= */
.strat-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-3); font-weight: 650; font-size: 12px; cursor: pointer; white-space: nowrap; }
.strat-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.strat-pill.on { color: var(--text); border-color: var(--green); background: var(--green-soft); }
.strat-pill.on .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(38,166,154,.25); }
.strat-pill small { font-family: var(--mono); font-weight: 500; color: var(--text-2); }
.strat-pill:hover { border-color: var(--accent); }
.preset-seg { display: flex; gap: 6px; align-items: center; background: transparent; padding: 0; }
.settings-top { display: flex; flex-direction: column; gap: 10px; position: sticky; top: calc(-1 * var(--pad-t)); z-index: 5; background: var(--bg-2);
  margin: calc(-1 * var(--pad-t)) calc(-1 * var(--pad-x)) 0; padding: var(--pad-t) var(--pad-x) 10px; border-bottom: 1px solid var(--border); }
.settings-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.sum-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.sum-pill.on { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.sum-pill.amber { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.settings-tabs button { padding: 7px 16px; font-size: 13px; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; }
.settings-panel[hidden] { display: none; }
.strategy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 14px; }
.strategy-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s; }
.strategy-card.on { border-color: var(--green); box-shadow: 0 0 0 1px var(--green-soft), inset 3px 0 0 var(--green); }
.strategy-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.strategy-title { display: flex; align-items: center; gap: 10px; }
.strategy-title .ico { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; background: var(--surface-3); }
.strategy-card.on .strategy-title .ico { background: var(--green-soft); }
.strategy-title b { font-size: 15px; display: block; } .strategy-title small { color: var(--text-3); font-size: 11.5px; }
.switch.big { font-size: 13px; } .switch.big input { width: 44px; height: 24px; } .switch.big input::after { width: 18px; height: 18px; } .switch.big input:checked::after { left: 22px; }
.strat-state { min-width: 44px; } .strategy-card.on .strat-state { color: var(--green); }
.strategy-status { font-size: 12px; color: var(--text-2); padding: 6px 10px; border-radius: 7px; background: var(--surface-2); }
.setup-rows { display: flex; flex-direction: column; gap: 4px; }
.setup-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; transition: background .12s; }
.setup-row:hover { background: var(--surface-2); }
.setup-row.off { opacity: .55; }
.setup-text { min-width: 0; } .setup-text b { display: block; font-size: 13px; } .setup-text small { display: block; color: var(--text-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-chips { display: flex; gap: 4px; } .tf-chips .chip { font-family: var(--mono); padding: 2px 8px; font-size: 11.5px; }
.tf-chips .chip:disabled { cursor: not-allowed; opacity: .5; }
.dir-sel { width: auto; padding: 3px 24px 3px 8px; font-size: 11.5px; } .dir-sel:disabled { opacity: .5; cursor: not-allowed; }
.strategy-rule { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 2px 10px 8px; font-size: 12px; }
.strategy-rule label { color: var(--text-3); font-weight: 600; }
.strategy-rule .input { width: auto; padding: 3px 24px 3px 8px; font-size: 11.5px; }
.setup-legend { font-size: 11px; color: var(--text-3); padding: 6px 10px 2px; line-height: 1.4; }
.foot-label { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; } .foot-label small { font-weight: 500; font-size: 10.5px; }
.strategy-card:not(.on) .setup-rows { opacity: .6; }
.strategy-foot { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12px; }
.strategy-foot .switch span { display: flex; flex-direction: column; line-height: 1.2; } .strategy-foot .switch small { font-weight: 500; font-size: 10.5px; }
.inline-num { display: inline-flex; align-items: center; gap: 6px; } .inline-num .field { display: flex; align-items: center; gap: 6px; } .inline-num .field label { margin: 0; order: 2; } .inline-num .input { width: 64px; padding: 4px 6px; }
.switch span small { display: block; font-weight: 500; color: var(--text-3); font-size: 10.5px; }
.big-toggle { margin-bottom: 12px; } .big-toggle .switch { font-size: 14px; } .big-toggle .switch input { width: 44px; height: 24px; } .big-toggle .switch input::after { width: 18px; height: 18px; } .big-toggle .switch input:checked::after { left: 22px; }
.adv-list { display: flex; flex-direction: column; gap: 6px; }
.adv-row { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.adv-row > summary { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; list-style: none; }
.adv-row > summary::-webkit-details-marker { display: none; } .adv-row > summary::after { content: "▾"; color: var(--text-3); } .adv-row[open] > summary::after { content: "▴"; }
.adv-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.tf-table input.input.sm { width: 76px; }
@media (max-width: 800px) {
  .setup-row { grid-template-columns: auto minmax(0, 1fr); } .setup-row .tf-chips, .setup-row .dir-sel { grid-column: 2; justify-self: start; }
  .strategy-head { flex-wrap: wrap; } .settings-top { position: static; }
  .settings-tabs { width: 100%; } .settings-tabs button { flex: 1; padding: 7px 6px; font-size: 12px; }
}

.drawer .chart-tools { border-bottom: 0; padding: 2px 0 6px; }

.setup-steps{list-style:none;padding:0;margin:8px 0;display:grid;gap:6px}.setup-steps li{display:grid;gap:2px;overflow-wrap:anywhere}.setup-steps small{color:var(--muted)}.setup-steps .passed b{color:var(--green)}

/* RDT research status stays scrollable on narrow screens. */
#rdt-desk-status { flex:none; max-height:35vh; overflow:auto; padding:8px 12px; border-bottom:1px solid var(--border); }
#rdt-desk-status[hidden] { display:none; }
.rdt-details summary { cursor:pointer; font-size:12px; }
.rdt-signal { padding:12px 0; border-top:1px solid var(--border); font-size:12px; }
.rdt-signal pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:240px; overflow:auto; }
.rdt-card p { margin:8px 0 14px; }

.bt-workspace {max-width:1480px;margin:auto;padding-bottom:32px}
.bt-nav,.bt-actions {display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:14px 0}
.bt-actions .input {max-width:300px}.bt-builder {display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:20px}
.bt-builder .card,.bt-workspace>.card {margin-bottom:16px}.bt-summary {align-self:start;position:sticky;top:12px}
.bt-metrics {display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:10px;margin:16px 0}.bt-metrics .bd {padding:16px}.bt-metrics strong {display:block;font-size:22px;font-variant-numeric:tabular-nums;margin-top:8px}
.bt-json {font-family:monospace;min-height:150px;white-space:pre;width:100%;resize:vertical}.bt-code {white-space:pre-wrap;overflow-wrap:anywhere;max-height:480px;overflow:auto}
.bt-setup {border-bottom:1px solid var(--border);padding:12px 0}.bt-setup summary {cursor:pointer}.bt-setup[open] .form-grid {padding:12px 0}
.bt-hist {height:130px;display:flex;align-items:flex-end;gap:4px;padding:14px}.bt-hist>div {flex:1;background:#3b82f6;min-width:12px;text-align:center;color:white}
.bt-months,.bt-heat {display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px;margin:14px 0}.bt-months>div {padding:12px;border:1px solid var(--border);border-radius:8px}.bt-heat button {display:flex;flex-direction:column;white-space:normal;overflow-wrap:anywhere}.bt-heat span {font-size:11px}
.bt-workspace table {width:100%;white-space:nowrap}.bt-workspace pre,.bt-workspace .tbl-wrap {max-width:100%;overflow:auto}.bt-workspace progress {width:100%;margin:16px 0}
@media(max-width:850px){.bt-builder{grid-template-columns:1fr}.bt-summary{position:static;grid-row:1}.bt-nav button{font-size:12px;padding:8px}.bt-workspace .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.bt-workspace .input{min-width:0}.bt-actions .input{max-width:100%}}
.bt-scatter {display:block;width:100%;max-width:600px;height:240px}
.bt-trade-drawer {position:fixed;z-index:150;right:0;top:0;bottom:0;width:min(740px,100vw);background:var(--surface);padding:20px;overflow:auto;box-shadow:-12px 0 40px #0005;padding-bottom:calc(100px + env(safe-area-inset-bottom))}
.bt-trade-drawer {margin:0 0 0 auto;max-width:100vw;max-height:100dvh;height:100dvh;color:var(--text);border:1px solid var(--border);padding-bottom:calc(24px + env(safe-area-inset-bottom))}
.bt-trade-drawer::backdrop {background:#0008}
.bt-trade-drawer .hd {position:sticky;top:0;background:var(--surface);z-index:1}
#bt-sweep-result td .btn {display:flex;flex-direction:column;width:100%;min-height:64px;background:var(--surface-2)}
#bt-sweep-result td .pos {background:var(--green-soft)}
#bt-sweep-result td .neg {background:var(--red-soft)}

/* Large native labels: one activation per click, with advanced controls separate. */
.bt-setup-toggle {display:flex;align-items:center;gap:12px;min-height:48px;padding:8px 12px;cursor:pointer;border-radius:8px;background:var(--surface-2)}
.bt-setup-toggle input {width:22px;height:22px;accent-color:var(--accent);flex:none}
.bt-setup-toggle span {flex:1;font-weight:600}.bt-setup-toggle strong {font-size:12px;color:var(--text-2)}
.bt-setup-toggle:focus-within {outline:2px solid var(--accent);outline-offset:2px}
.bt-setup details summary {padding:12px;min-height:44px}.setup-row .switch {min-width:44px;min-height:44px;display:flex;align-items:center}

.books-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 10px; margin: 0 0 12px; }
.book-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 12px; cursor: pointer; }
.book-card:hover { border-color: var(--accent); }
.book-card .bh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.book-card .bk { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; } .book-card .bk .l { font-size: 10.5px; color: var(--text-3); } .book-card .bk .v { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }

/* ===== 設定：交易計劃（Playbook） ===== */
.pb-nav button { display: inline-flex; align-items: center; gap: 6px; }
.pb-nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); opacity: .5; }
.pb-nav .dot.on { background: var(--pos); opacity: 1; }
.pb-hint { font-size: 11.5px; }
.pb { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.pb.on { border-color: color-mix(in srgb, var(--pos) 55%, var(--border)); }
.pb-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.pb-title { display: flex; align-items: center; gap: 10px; } .pb-title .ico { font-size: 22px; } .pb-title b { display: block; font-size: 16px; } .pb-title small { color: var(--text-3); font-size: 12px; }
.pb-library { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 12px; background: var(--surface-2); }
.pb-library .pbl-label { font-weight: 700; font-size: 12px; margin-right: 2px; } .pb-library select { width: auto; min-width: 180px; } .pb-library .pbl-state { font-size: 11.5px; margin-left: auto; }
.pb-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.pb-steps { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pb-step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.pb-step-hd { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pb-step-hd b { display: block; font-size: 13.5px; } .pb-step-hd small { color: var(--text-3); font-size: 11.5px; }
.pb-step-bd { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.pb-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 12.5px; flex: none; }
.pb-num.sm { width: 18px; height: 18px; font-size: 10.5px; margin-right: 6px; }
.pb-note { font-size: 11.5px; color: var(--text-3); }
.pb-group { display: flex; flex-direction: column; gap: 8px; } .pb-group + .pb-group { border-top: 1px dashed var(--border); padding-top: 10px; }
.pb-group-hd { display: flex; align-items: baseline; gap: 8px; } .pb-group-hd small { font-size: 11px; }
.pb-inline { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.setup-block { border: 1px solid transparent; border-radius: 8px; } .setup-block:hover { background: var(--surface-2); }
.setup-block.off { opacity: .55; }
.setup-block .setup-row { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.setup-block .setup-row:hover { background: transparent; }
.setup-params { padding: 4px 10px 12px 52px; display: flex; flex-direction: column; gap: 8px; }
.setup-params .tf-table { width: auto; }
.dir-fixed { font-size: 11.5px; }
.rel-tag { display: inline-block; margin-top: 3px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; line-height: 1.5; color: var(--text-2); background: var(--surface-3); white-space: nowrap; }
.pb-summary { position: sticky; top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: 12px; font-size: 12px; max-height: calc(100vh - 140px); overflow: auto; }
.pbs-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .pbs-top b { font-size: 13.5px; }
.pbs-sec + .pbs-sec { margin-top: 10px; } .pbs-h { display: flex; align-items: center; font-weight: 700; margin-bottom: 4px; }
.pbs-sec ul { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 3px; line-height: 1.45; color: var(--text-2); }
@media (max-width: 980px) {
  .pb-body { grid-template-columns: 1fr; } .pb-summary { position: static; max-height: none; order: -1; }
  .setup-block .setup-row { grid-template-columns: auto minmax(0, 1fr); } .setup-block .setup-row > :nth-child(n+3) { grid-column: 2; justify-self: start; }
  .setup-params { padding-left: 10px; } .pb-library .pbl-state { margin-left: 0; flex-basis: 100%; }
}
.setup-params[hidden] { display: none; }

/* 表格工具：排序／篩選列／Sector 多選 */
.tbl th.sortable { cursor: pointer; user-select: none; }
.filterbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.filterbar .input.sm { min-width: 0; }
.sector-picker { position: relative; display: inline-block; } .sector-picker summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.sector-picker summary::-webkit-details-marker { display: none; }
.sector-picker .sp-menu { position: absolute; z-index: 30; top: 100%; left: 0; margin-top: 4px; width: 280px; max-height: 320px; overflow: auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 6px; }
@media (max-width: 700px) { .sector-picker .sp-menu { left: auto; right: 0; width: min(280px, calc(100vw - 24px)); } }
.sector-picker .sp-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 11.5px; }
.sector-picker .sp-item { display: flex; gap: 6px; align-items: center; padding: 3px 6px; font-size: 12px; cursor: pointer; border-radius: 4px; } .sector-picker .sp-item:hover { background: var(--surface-2); }
.sr-group { padding: 6px 12px 2px; font-size: 10.5px; letter-spacing: .06em; color: var(--text-2); text-transform: uppercase; }
tr[hidden] { display: none; }
.dk-adv { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; } .dk-adv .input.sm { font-size: 11px; padding: 2px 6px; max-width: 150px; }
.sr-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.bt-filters { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: 6px; }
.qqq-card .qqq-sum { display: block; margin-top: 2px; color: var(--accent); font-family: var(--mono); font-size: 11px; }
.qqq-card .tf-chips label.chip { cursor: pointer; }
.qqq-block .setup-row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.modal.wide { width: min(980px, 96vw); max-height: 90vh; overflow: auto; }
.h2l2-bt-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; } .h2l2-bt-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-2); }
.h2l2-bt-out { display: flex; flex-direction: column; gap: 12px; } .h2l2-tbl .tbl td, .h2l2-tbl .tbl th { padding: 5px 8px; font-size: 12px; }
.h2l2-funnel tr.strong td { font-weight: 650; } .h2l2-funnel tr.loo td:first-child { padding-left: 18px; color: var(--text-2); }
.qqq-row-toggle { font-size: 11.5px; white-space: nowrap; margin-right: 4px; } .qqq-row-toggle input { transform: scale(.85); }

/* 期貨策略研究室 */
.lab .lab-grid { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
.lab .lab-form { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 8px; max-height: calc(100vh - 80px); overflow: auto; }
.lab .lab-out { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lab .lab-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.lab .lab-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-2); }
.lab .lab-params { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.lab .lab-param { display: grid; grid-template-columns: 1fr minmax(0, 1.1fr); gap: 8px; align-items: center; font-size: 12px; }
.lab .lab-param label { color: var(--text-2); }
.lab .lab-pin { display: flex; gap: 4px; align-items: center; } .lab .lab-pin .input { min-width: 0; flex: 1; }
.lab .lab-sw { font-size: 11px; white-space: nowrap; display: flex; gap: 2px; align-items: center; color: var(--accent); }
.lab .lab-swv { flex: 1.3; }
.lab details > summary { cursor: pointer; list-style: none; } .lab details > summary::-webkit-details-marker { display: none; }
.lab .lab-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lab .lab-eq { height: 260px; margin-top: 12px; }
.lab .lab-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.lab .lab-hist { display: flex; gap: 3px; align-items: flex-end; height: 120px; padding-top: 6px; }
.lab .lab-hist > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; }
.lab .lab-hist span { width: 100%; background: var(--accent); opacity: .7; border-radius: 2px 2px 0 0; }
.lab .lab-hist small { color: var(--text-2); font-size: 9px; white-space: nowrap; } .lab .lab-hist b { font-size: 10px; }
.lab .lab-mc, .lab .lab-dsr { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.lab .lab-dsr .l { font-size: 11.5px; color: var(--text-2); } .lab .lab-dsr .v { font-size: 20px; font-weight: 650; font-family: var(--mono); }
.lab .lab-heat td, .lab .lab-heat th { padding: 6px 8px; font-size: 12px; } .lab .lab-heat td.lab-best { outline: 2px solid var(--accent); outline-offset: -2px; }
.lab .lab-heat-ctl { display: flex; gap: 6px; align-items: center; font-size: 11.5px; }
.lab .lab-month td, .lab .lab-month th { padding: 4px 6px; font-size: 11.5px; }
.lab .lab-meta .bd { font-size: 12.5px; line-height: 1.6; }
@media (max-width: 980px) { .lab .lab-grid { grid-template-columns: 1fr; } .lab .lab-form { position: static; max-height: none; } .lab .lab-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lab .lab-fields label > .input, .lab .lab-fields label > input, .lab .lab-fields label > select { width: 100%; min-width: 0; box-sizing: border-box; }
.lab .card { min-width: 0; } .lab .lab-form .card .hd { flex-wrap: wrap; gap: 6px; }
.lab .lab-db-pick { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; } .lab .lab-db-pick label.chip { cursor: pointer; }
.lab .lab-db code { font-size: 11px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
/* 研究室：研究項目、關卡、forward test、組合 */
.lab .page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.lab .lab-top { margin-bottom: 4px; }
.lab #lab-body { margin-top: 12px; }
.lab .lab-proj { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 14px; align-items: start; }
.lab .lab-proj-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lab .lab-plist { display: flex; flex-direction: column; max-height: calc(100vh - 220px); overflow: auto; }
.lab .lab-pitem { padding: 10px 12px; border-top: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.lab .lab-pitem:hover { background: var(--surface-2); } .lab .lab-pitem.active { background: var(--accent-soft); }
.lab .lab-pitem .t { font-size: 13px; }
.lab .lab-bar { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; } .lab .lab-bar span { display: block; height: 100%; background: var(--green); }
.lab .lab-pipe { list-style: none; margin: 12px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lab .lab-pipe li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.lab .lab-pipe li .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.lab .lab-pipe li.ok .ic { background: var(--green-soft); color: var(--green); } .lab .lab-pipe li.bad .ic { background: var(--red-soft); color: var(--red); }
.lab .lab-pipe li.bad { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); } .lab .lab-pipe li.todo { opacity: .6; }
.lab .lab-pipe li .n { font-weight: 650; font-size: 13px; } .lab .lab-pipe li .d { font-size: 11.5px; color: var(--text-2); line-height: 1.5; }
.lab .lab-pipe li a { font-size: 11.5px; }
.lab .lab-fwrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 12.5px; }
.lab .lab-fwrow label.chip, .lab .lab-fwpick .chip, .lab .card .hd label.chip { cursor: pointer; }
.lab .lab-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.lab .lab-hist-list { margin-top: 10px; max-height: 220px; overflow: auto; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.lab .lab-check { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 6px 14px; font-size: 12.5px; }
.lab .lab-check li span:first-child { display: inline-block; width: 18px; font-weight: 700; } .lab .lab-check li.ok span:first-child { color: var(--green); } .lab .lab-check li.bad span:first-child { color: var(--red); }
.lab .lab-svg { width: 100%; height: auto; display: block; } .lab .lab-svg text { font-size: 10px; fill: var(--text-2); }
.lab .lab-svg .g { stroke: var(--border); stroke-dasharray: 3 3; } .lab .lab-svg .a { stroke: var(--text-2); }
.lab .lab-cone .b1 { fill: var(--surface-3); opacity: .7; } .lab .lab-cone .b2 { fill: var(--text-2); opacity: .18; }
.lab .lab-cone .mid { fill: none; stroke: var(--text-2); stroke-dasharray: 4 3; } .lab .lab-cone .act { fill: none; stroke: #2f81f7; stroke-width: 2; } .lab .lab-cone .dot { fill: #2f81f7; }
.lab .lab-cone-wrap { margin-top: 10px; }
.lab .lab-exc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.lab .lab-fwpick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.lab .lab-live { margin-top: 8px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.lab .lab-open { padding: 6px 8px; background: var(--surface-2); border-radius: 6px; }
@media (max-width: 980px) { .lab .lab-proj { grid-template-columns: 1fr; } .lab .lab-exc { grid-template-columns: 1fr; } .lab .lab-pipe li { grid-template-columns: 24px minmax(0, 1fr); } .lab .lab-pipe li .a { grid-column: 2; } }
/* 頂欄喺 901–1700px 寬度放唔晒：換行，唔好令成頁可以左右捲 */
.topbar { min-width: 0; }
@media (min-width: 901px) and (max-width: 1700px) {
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; row-gap: 6px; padding-top: 6px; padding-bottom: 6px; }
}
.lab .lab-groups { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.lab .lab-groups .tbl th, .lab .lab-groups .tbl td { padding: 5px 7px; font-size: 12px; white-space: nowrap; }
.lab .lab-hist > div { min-width: 0; }
.lab .lab-hist small { max-width: 100%; overflow: hidden; text-overflow: clip; }
.lab .lab-free-tbl td.seg { white-space: normal; font-size: 11px; line-height: 1.5; min-width: 180px; }
/* 研究室窄螢幕：格仔最細唔好闊過螢幕、標題同控制列可以換行 */
.lab .lab-groups { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.lab .lab-2col { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.lab .lab-check { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.lab .lab-mc, .lab .lab-dsr { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.lab .card > .hd { flex-wrap: wrap; row-gap: 6px; }
.lab .card > .hd h3 { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.lab .lab-heat-ctl { flex-wrap: wrap; }
.lab .lab-heat-ctl select { max-width: 100%; min-width: 0; }
/* Setup 設計原因 ⓘ：指住即時顯示，撳開大啲睇 */
.info-tip { position: relative; display: inline-block; margin-left: 6px; vertical-align: 1px; }
.info-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--accent); border-radius: 50%; width: 18px; height: 18px; padding: 0; font-size: 11px; line-height: 16px; cursor: pointer; font-weight: 700; }
.info-btn:hover, .info-btn:focus-visible { background: var(--accent-soft); outline: none; }
.info-pop { display: none; position: absolute; z-index: 60; left: 0; top: 24px; width: min(460px, 86vw); max-height: 60vh; overflow: auto; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); font-weight: 400; font-size: 12px; line-height: 1.5; white-space: normal; }
.info-tip:hover .info-pop, .info-tip:focus-within .info-pop { display: block; }
.info-pop > b { display: block; margin-bottom: 4px; font-size: 13px; }
.info-src { color: var(--text-3); font-size: 11px; margin-bottom: 6px; }
.info-rules { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.info-rules li b { display: block; font-size: 12px; color: var(--text); }
.info-rules li span { display: block; color: var(--text-2); font-size: 11.5px; }
.info-sub { margin-top: 10px; font-weight: 650; font-size: 12px; }
.info-na { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); font-size: 11.5px; }
.info-modal { max-height: 65vh; overflow: auto; font-size: 13px; }
.info-modal .info-rules li b { font-size: 13px; } .info-modal .info-rules li span { font-size: 12.5px; }
@media (hover: none) { .info-pop { display: none !important; } }   /* 手機：撳 ⓘ 開大版，唔出浮動框 */
/* 關咗嘅 setup：只淡化內容，唔好淡化 ⓘ 浮動框（opacity 會令佢透明兼俾下面嘅行蓋住） */
.setup-block.off { opacity: 1; }
.setup-block.off .setup-row > :not(.setup-text), .setup-block.off .setup-text small, .setup-block.off .setup-params { opacity: .55; }
.setup-block.off .setup-text > b { color: var(--text-3); }
.info-pop, .info-pop b { color: var(--text); }
/* 設定頁分頁喺窄螢幕放唔晒：分頁列自己左右滑，唔好撐闊成頁 */
.settings-top .settings-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.settings-top .settings-tabs::-webkit-scrollbar { display: none; }

/* ---- L2 order flow ---- */
.l2 { display: flex; flex-direction: column; gap: 12px; }
.l2-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.l2-title b { display: block; font-size: 15px; } .l2-title small { color: var(--text-3); font-size: 11.5px; }
.l2-status { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; align-items: center; } .l2-acts { margin-left: auto; display: flex; gap: 6px; }
.l2-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.l2-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); padding: 8px 12px; cursor: pointer; white-space: nowrap; font-size: 12.5px; }
.l2-tabs button.active { color: var(--text); border-bottom-color: var(--accent, #3b82f6); }
.l2-grid3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.l2-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 12px; align-items: start; }
.l2-book { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 12px; } .side-title { font-size: 11.5px; margin-bottom: 4px; }
table.book { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; } table.book td { padding: 2px 4px; }
table.book td.lvl { color: var(--text-3); width: 18px; } table.book td.vol { text-align: right; } table.book td.cnt { text-align: right; width: 28px; }
table.book td.bar { width: 34%; } table.book td.bar i { display: block; height: 8px; background: var(--surface-3); border-radius: 2px; }
table.book tr.wall td { background: rgba(201, 162, 39, .18); }
.l2-brokers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 12px; font-size: 12px; }
.bq { display: flex; gap: 6px; padding: 2px 0; border-bottom: 1px dashed var(--border); } .bq .pos-n { color: var(--text-3); width: 16px; } .bq .bid-id { width: 44px; font-variant-numeric: tabular-nums; } .bq .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.ticks { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; } table.ticks td { padding: 2px 6px; }
.l2-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.l2-stats .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; } .l2-stats .stat small { display: block; color: var(--text-3); font-size: 11px; } .l2-stats .stat b { font-size: 16px; }
.l2-log { font-size: 12px; max-height: 420px; overflow: auto; } .l2-log div { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.kv { display: grid; grid-template-columns: 1fr; gap: 6px; font-size: 12.5px; } .kv div { display: flex; justify-content: space-between; gap: 10px; } .kv span { color: var(--text-3); } .kv b { text-align: right; word-break: break-all; }
.l2-md { white-space: pre-wrap; font-size: 12px; line-height: 1.5; max-height: 70vh; overflow: auto; }
.warn { color: #c9a227; }
@media (max-width: 1100px) { .l2-grid3 { grid-template-columns: 1fr 1fr; } } @media (max-width: 700px) { .l2-grid3 { grid-template-columns: 1fr; } .l2-book { grid-template-columns: 1fr; } }

.l2 .card { min-width: 0; overflow: hidden; }
.l2 .card .bd { overflow-x: auto; }
.l2 table.tbl { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; }
.l2 table.tbl th, .l2 table.tbl td { padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.l2 table.tbl td.muted, .l2 table.tbl td.wrap { white-space: normal; word-break: break-word; }
.l2 table.tbl th:last-child, .l2 table.tbl td:last-child { white-space: normal; word-break: break-word; }
.l2 .l2-log div { white-space: normal; word-break: break-word; }
.l2-stack { display: flex; flex-direction: column; gap: 12px; }
.l2 table.sig-tbl td:nth-child(7), .l2 table.sig-tbl td:nth-child(8) { white-space: normal; word-break: break-word; }
.l2 .card .bd { max-height: 70vh; overflow-y: auto; }
@media (max-width: 700px) {
  .l2 .l2-top { gap: 8px; } .l2 .l2-acts { margin-left: 0; }
  .l2 table.sig-tbl colgroup, .l2 table.sig-tbl thead { display: none; }
  .l2 table.sig-tbl, .l2 table.sig-tbl tbody { display: block; width: 100%; }
  .l2 table.sig-tbl tr { display: grid; grid-template-columns: auto auto auto auto 1fr; gap: 2px 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); align-items: baseline; }
  .l2 table.sig-tbl td { display: block; padding: 0 !important; border: 0 !important; white-space: nowrap; overflow: visible; }
  .l2 table.sig-tbl td:nth-child(6) { display: none; }
  .l2 table.sig-tbl td:nth-child(7), .l2 table.sig-tbl td:nth-child(8) { grid-column: 1 / -1; white-space: normal; font-size: 11.5px; }
}

/* 研究室 · AI 研究員 */
.lab .lab-research { display: flex; flex-direction: column; gap: 14px; }
.lab .lab-hyps { display: flex; flex-direction: column; gap: 12px; }
.lab .lab-hyp-thesis { font-size: 14px; font-weight: 600; line-height: 1.4; }
.lab .lab-hyp-runs { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.lab .lab-hyp-runs details { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface-2, var(--surface)); }
.lab .lab-hyp-runs summary { cursor: pointer; }
.lab .lab-run-detail { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.lab .lab-verdict { margin-top: 10px; padding: 9px 11px; border-radius: var(--radius); background: var(--surface-3); font-size: 12.5px; line-height: 1.45; border-left: 3px solid var(--text-3); }
.lab .lab-verdict.short { border-left-color: var(--red); } .lab .lab-verdict.long { border-left-color: var(--green); } .lab .lab-verdict.amber { border-left-color: var(--amber); }
.lab .lab-rconds { display: flex; flex-wrap: wrap; gap: 3px; max-width: 520px; } .lab .lab-rconds .tag { white-space: nowrap; }
.lab .lab-rtbl td, .lab .lab-rtbl th { font-size: 11.5px; white-space: nowrap; } .lab .lab-rtbl td:first-child { white-space: normal; min-width: 260px; }
.lab .lab-rtbl tr.ok td { background: var(--green-soft); }
.lab .lab-ftbl td { white-space: normal; } .lab .lab-ftbl td:first-child { min-width: 0; }
.lab .lab-md { white-space: pre-wrap; font: 12px/1.5 var(--font-mono, ui-monospace, monospace); background: var(--surface-3); padding: 10px; border-radius: var(--radius); margin: 6px 0 0; max-height: 360px; overflow: auto; }
.lab .lab-md-body h4 { margin: 10px 0 4px; font-size: 12.5px; } .lab .lab-md-body h4:first-child { margin-top: 0; }
.lab .lab-md-item { font-size: 12.5px; line-height: 1.45; padding: 2px 0; }
.lab .lab-gloss { margin-top: 10px; } .lab .lab-gloss summary { cursor: pointer; font-size: 12px; } .lab .lab-gloss .help { margin-top: 6px; line-height: 1.6; }
.lab .lab-cand { padding: 8px 0; border-bottom: 1px solid var(--border); } .lab .lab-cand:last-child { border-bottom: 0; }
.lab .lab-other summary { cursor: pointer; }
