/* Obsidian Terminal design system — see DESIGN.md */
:root {
  /* surfaces */
  --l0: #090D14;                 /* base canvas */
  --l1: rgba(13, 19, 31, .85);   /* glass panels */
  --l2: #131B2B;                 /* raised / active */
  --l3: #162032;                 /* overlays */
  --field: #0A0E17;
  --line: #202B3E;
  --line-soft: rgba(32, 43, 62, .6);
  /* text */
  --text: #F8FAFC;
  --text-2: #CBD5E1;   /* slate-300 */
  --muted: #94A3B8;    /* slate-400 */
  --dim: #64748B;      /* slate-500 */
  --faint: #475569;    /* slate-600 */
  /* signal */
  --emerald: #10B981; --emerald-hi: #34D399; --emerald-bg: rgba(16, 185, 129, .12); --emerald-line: rgba(16, 185, 129, .3);
  --cyan: #06B6D4;    --cyan-bg: rgba(6, 182, 212, .15); --cyan-line: rgba(6, 182, 212, .3);
  --rose: #F43F5E;    --rose-hi: #FB7185; --rose-bg: rgba(244, 63, 94, .12); --rose-line: rgba(244, 63, 94, .3);
  --neutral-bg: rgba(148, 163, 184, .08); --neutral-line: rgba(148, 163, 184, .2);
  /* chart (read by app.js) */
  --green: #10B981; --red: #F43F5E; --blue: #06B6D4; --border: rgba(32, 43, 62, .7);
  /* type */
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  /* shape */
  --r: 4px; --r-lg: 8px; --r-xl: 12px;
  --shadow-overlay: 0 8px 32px -4px rgba(0, 0, 0, .75), 0 0 1px 1px rgba(255, 255, 255, .08);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; min-height: 100vh;
  font: 400 14px/20px var(--font-body);
  color: var(--text); background: var(--l0);
  background-image: radial-gradient(1200px 500px at 70% -10%, rgba(6, 182, 212, .06), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
.num, td.r, .value, input[type=number] { font-family: var(--font-mono); font-feature-settings: "tnum", "zero"; font-variant-numeric: tabular-nums slashed-zero; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 32px; border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 13, 20, .8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; padding: 3px; border-radius: var(--r-lg); background: var(--l2); border: 1px solid rgba(6, 182, 212, .35);
  fill: none; stroke-linecap: round; stroke-linejoin: round; box-shadow: 0 0 14px rgba(6, 182, 212, .2); }
.brand-mark .hex { stroke: #06B6D4; stroke-width: 2; }
.brand-mark .wick { stroke: #CBD5E1; stroke-width: 1.5; }
.brand-mark .up { fill: #10B981; }
.brand-mark .dn { fill: #F43F5E; }
.brand-pro { color: #06B6D4; }
h1 { margin: 0; font: 700 18px/24px var(--font-display); letter-spacing: -.01em; }
.brand-sub { margin: 0; font: 500 10px/14px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  padding: 3px 10px; border-radius: 9999px; font: 600 10px/14px var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-2); background: var(--neutral-bg); border: 1px solid var(--neutral-line);
}
.tag-cyan { color: var(--cyan); background: var(--cyan-bg); border-color: var(--cyan-line); }
.tag-rose { color: var(--rose-hi); background: var(--rose-bg); border-color: var(--rose-line); }

/* ---------- layout ---------- */
main { padding: 24px 32px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 1440px; margin: 0 auto; }
.col-main { display: grid; gap: 24px; min-width: 0; }
.grid > *, .metrics > * { min-width: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 24px; align-items: start; }

.panel, .metric {
  background: var(--l1); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); min-width: 0;
}
.metric { padding: 16px; transition: border-color .2s, background .2s; }
.metric:hover { background: var(--l2); border-color: var(--cyan-line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-body { padding: 16px; }

.card-title {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.card-title svg { width: 14px; height: 14px; fill: none; stroke: var(--cyan); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.value { margin-top: 12px; font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -.02em; color: var(--text); }
.sub { margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--muted); }
.up { color: var(--emerald-hi); } .down { color: var(--rose-hi); }

.section-label { margin: 24px 0 8px; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }

/* ---------- loading ---------- */
.skeleton { display: inline-block; width: 60%; height: 22px; border-radius: var(--r); vertical-align: middle;
  background: linear-gradient(90deg, var(--l2) 0%, #1A2438 50%, var(--l2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- chart ---------- */
.chart-body { position: relative; padding: 12px 16px 0; }
canvas { width: 100%; display: block; cursor: crosshair; touch-action: none; }
canvas.grabbing { cursor: grabbing; }
.legend .ohlc { color: var(--text-2); font-feature-settings: "tnum"; }
.legend .zoom { display: inline-flex; gap: 2px; padding: 2px; background: var(--field); border: 1px solid var(--line-soft); border-radius: var(--r); }
.legend .zoom button { width: 24px; height: 20px; padding: 0; border: 0; border-radius: 3px; background: none; color: var(--muted); font: 600 13px/1 var(--font-mono); cursor: pointer; }
.legend .zoom button:hover { background: var(--l2); color: var(--text); }
.chart-state { position: absolute; inset: 12px 16px 0; display: grid; place-items: center; text-align: center; padding: 16px;
  font: 500 12px/16px var(--font-mono); color: var(--dim); }
.chart-state:empty { display: none; }
.chart-state.error { color: var(--rose-hi); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 16px 0; font: 500 11px/16px var(--font-mono); color: var(--dim); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.indicators { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 12px; border-top: 1px solid var(--line-soft); }
.indicators div { padding: 12px 16px; font: 500 13px/18px var(--font-mono); font-feature-settings: "tnum"; color: var(--text); border-right: 1px solid var(--line-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.indicators div:last-child { border-right: 0; }
.indicators div span { display: block; margin-bottom: 2px; font: 600 10px/14px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }

/* segmented tabs (timeframes + table tabs) */
.segmented { display: inline-flex; gap: 2px; padding: 4px; background: var(--field); border: 1px solid var(--line-soft); border-radius: var(--r-lg); max-width: 100%; overflow-x: auto; }
.segmented button { padding: 4px 10px; border: 1px solid transparent; border-radius: var(--r); background: none; cursor: pointer; white-space: nowrap;
  font: 500 12px/16px var(--font-mono); color: var(--dim); transition: color .15s, background .15s; }
.segmented button:hover { color: var(--text-2); }
.segmented button.active { background: var(--l2); color: var(--text); border-color: rgba(255, 255, 255, .08); }
.segmented .count { margin-left: 6px; color: var(--dim); }
.tab-pane[hidden] { display: none; }

/* ---------- controls ---------- */
button, select, input { font: inherit; color: var(--text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r); font: 600 13px/18px var(--font-body); cursor: pointer;
  border: 1px solid transparent; transition: background .15s, box-shadow .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .5; cursor: wait; }
.btn:focus-visible, .segmented button:focus-visible, .btn-link:focus-visible, .thumb:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--cyan), 0 0 12px rgba(6, 182, 212, .2); }
.btn-primary { background: var(--emerald); color: var(--l0); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-primary:hover:not(:disabled) { background: var(--emerald-hi); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 16px rgba(16, 185, 129, .35); }
.btn-sell { background: var(--rose); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-sell:hover:not(:disabled) { background: var(--rose-hi); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 16px rgba(244, 63, 94, .35); }
.btn-ghost { background: rgba(19, 27, 43, .6); border-color: rgba(32, 43, 62, .8); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); color: #F1F5F9; }
.btn-link { margin-top: 16px; padding: 0; background: none; border: 0; cursor: pointer; font-size: 12px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; border-radius: var(--r); }
.btn-link:hover { color: var(--rose-hi); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.btn-row .btn { flex: 1 1 auto; }

input, select {
  width: 100%; padding: 8px 10px; border-radius: var(--r);
  background: var(--field); border: 1px solid rgba(32, 43, 62, .9); color: #F1F5F9; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--faint); font-family: var(--font-body); }
input:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 12px rgba(6, 182, 212, .2); }
select { font-family: var(--font-mono); font-size: 13px; }

.bot-status { display: flex; align-items: center; gap: 8px; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
  padding: 3px 10px; border-radius: 9999px; background: var(--neutral-bg); border: 1px solid var(--neutral-line); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* daily trade meter */
.meter { margin-top: 12px; }
.meter-head { display: flex; justify-content: space-between; font: 500 11px/16px var(--font-mono); color: var(--muted); }
.meter-head b { color: var(--text); font-weight: 500; white-space: nowrap; }
.meter-track { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-top: 6px; }
.meter-track i { height: 6px; border-radius: 1px; background: var(--l2); border: 1px solid var(--line-soft); }
.meter-track i.used { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 6px rgba(6, 182, 212, .35); }
.meter-track.full i.used { background: var(--rose); border-color: var(--rose); box-shadow: none; }

.scan-stats { margin-top: 8px; font: 400 11px/16px var(--font-mono); color: var(--dim); }
.scan-stats b { color: var(--text-2); font-weight: 500; }
.meter-bars { display: grid; gap: 6px; margin-top: 8px; }
.meter-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.meter-row .pill { text-align: center; }
.meter-row b { font: 500 11px/16px var(--font-mono); color: var(--text-2); text-align: right; white-space: nowrap; min-width: 52px; }
.meter-row .meter-track { margin-top: 0; }
.meter-track.swing i.used { background: var(--cyan); border-color: var(--cyan); }
.meter-track.scalp i.used { background: #FBBF24; border-color: #FBBF24; box-shadow: 0 0 6px rgba(251, 191, 36, .35); }
.meter-split { display: flex; gap: 16px; margin-top: 8px; font: 500 11px/16px var(--font-mono); color: var(--muted); }
.meter-split > span { display: inline-flex; align-items: center; gap: 6px; }

/* open trade + last decision */
.open-trade, .decision { margin-top: 12px; padding: 12px; border-radius: var(--r-lg); background: var(--l2); border: 1px solid var(--line-soft); font-size: 13px; }
.open-trade:empty, .decision:empty { display: none; }
.open-trade { border-color: var(--cyan-line); }
.ot-head, .decision-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font: 500 12px/16px var(--font-mono); color: var(--muted); }
.ot-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.ot-levels div { font: 500 13px/18px var(--font-mono); font-feature-settings: "tnum"; }
.ot-levels span { display: block; font: 600 10px/14px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.ot-levels em { font-style: normal; }
.ot-risk { margin-top: 8px; font: 500 12px/16px var(--font-mono); color: var(--muted); }
.ot-risk b { color: var(--text); font-weight: 500; }
.ot-reason { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft); font: 400 12px/17px var(--font-mono); color: var(--text-2); }
.legend .live { margin-left: auto; color: var(--faint); }
.legend .live::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--emerald); vertical-align: 1px; animation: pulse 2s ease-in-out infinite; }
.ot-bar { position: relative; height: 4px; margin-top: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--rose) 0 var(--split, 50%), var(--emerald) var(--split, 50%) 100%); opacity: .5; }
/* stop at breakeven: no risk left on the stop side */
.ot-bar.be { background: linear-gradient(90deg, var(--line-soft) 0 var(--split, 50%), var(--emerald) var(--split, 50%) 100%); opacity: .7; }
.ot-bar b { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--text); border-radius: 1px; transform: translateX(-1px); }
.decision.BUY { border-color: var(--emerald-line); box-shadow: 0 0 12px rgba(16, 185, 129, .12); }
.decision.SELL, .decision.ERROR { border-color: var(--rose-line); box-shadow: 0 0 12px rgba(244, 63, 94, .12); }
.decision p { margin: 8px 0 0; color: var(--text-2); line-height: 20px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.settings .btn { grid-column: span 2; }
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.rules li { display: flex; justify-content: space-between; gap: 8px; }
.rules b { font: 500 12px/16px var(--font-mono); color: var(--text-2); }
.manual { display: grid; grid-template-columns: 1fr 88px; gap: 8px; }
.manual input { min-width: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; text-align: left; padding: 10px 12px; white-space: nowrap;
  font: 600 10px/14px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--dim); background: rgba(9, 13, 20, .7);
  border-bottom: 1px solid var(--line-soft);
}
td { padding: 10px 12px; border-bottom: 1px solid rgba(32, 43, 62, .35); vertical-align: top; color: var(--text-2); }
td.t { font: 400 12px/18px var(--font-mono); color: var(--muted); white-space: nowrap; }
th.r, td.r { text-align: right; white-space: nowrap; }
td.src { font: 500 11px/18px var(--font-mono); color: var(--dim); white-space: nowrap; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, .015); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(6, 182, 212, .04); }
tbody tr:last-child td { border-bottom: 0; }
tr.active-order td { background: rgba(6, 182, 212, .07); }
tr.active-order td:first-child { box-shadow: inset 2px 0 0 var(--cyan); }
td.reason { min-width: 280px; max-width: 520px; color: var(--muted); }
td.empty { padding: 32px 16px; text-align: center; color: var(--dim); }
td.empty b { display: block; margin-bottom: 4px; font: 600 14px/20px var(--font-display); color: var(--text-2); }
#trades td { vertical-align: middle; }

/* P&L by period */
.pnl-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line-soft); }
.pnl-summary > div { padding: 14px 16px; border-right: 1px solid var(--line-soft); min-width: 0; }
.pnl-summary > div:last-child { border-right: 0; }
.pnl-summary span { display: block; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.pnl-summary b { display: block; margin-top: 4px; font: 500 18px/24px var(--font-mono); font-feature-settings: "tnum"; }
.pnl-summary small { display: block; margin-top: 2px; font: 400 11px/16px var(--font-mono); color: var(--muted); }
.pnl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.pnl-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.pnl-cell .bar { flex: 1; height: 8px; border-radius: 2px; background: var(--l2); position: relative; overflow: hidden; }
.pnl-cell .bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.pnl-cell .bar i.pos { left: 50%; background: var(--emerald); box-shadow: 0 0 8px rgba(16, 185, 129, .35); }
.pnl-cell .bar i.neg { right: 50%; background: var(--rose); box-shadow: 0 0 8px rgba(244, 63, 94, .35); }
.pnl-cell .bar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line); }
.pnl-cell b { min-width: 92px; text-align: right; font: 500 13px/18px var(--font-mono); font-feature-settings: "tnum"; }
@media (max-width: 767px) { .pnl-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pnl-summary > div:nth-child(2) { border-right: 0; } .pnl-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); } }

/* trade snapshots */
.thumbs { display: flex; gap: 6px; }
.thumbs figure { margin: 0; }
.thumbs figcaption { margin-bottom: 3px; font: 600 9px/12px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.thumb { display: block; width: 150px; height: 75px; padding: 0; overflow: hidden; cursor: zoom-in;
  background: var(--field); border: 1px solid var(--line-soft); border-radius: var(--r); transition: border-color .15s; }
.thumb:hover { border-color: var(--cyan-line); }
.thumb svg, .thumb img { width: 100%; height: 100%; display: block; }
.no-shot { font: 500 11px/16px var(--font-mono); color: var(--faint); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 13, .72); backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-card { width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--l3); border: 1px solid rgba(255, 255, 255, .08); border-radius: var(--r-xl); box-shadow: var(--shadow-overlay); }
.modal-card .panel-head { position: sticky; top: 0; background: var(--l3); }
.modal-shots { display: grid; gap: 12px; padding: 16px; }
.modal-shots figure { margin: 0; }
.shot-tabs { justify-self: start; }
.modal-shots figcaption { margin-bottom: 6px; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.modal-shots svg, .modal-shots img { width: 100%; height: auto; display: block; border-radius: var(--r-lg); border: 1px solid var(--line-soft); }
.modal-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.modal-meta div { font: 500 13px/18px var(--font-mono); }
.modal-meta span { display: block; font: 600 10px/14px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
.modal-note { padding: 0 16px 16px; margin: 0; color: var(--muted); font-size: 13px; }

/* pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 9999px; font: 600 10px/16px var(--font-mono); letter-spacing: .04em; white-space: nowrap;
  color: var(--text-2); background: var(--neutral-bg); border: 1px solid var(--neutral-line); }
.pill.BUY, .pill.buy, .pill.cover, .pill.WIN { color: var(--emerald-hi); background: var(--emerald-bg); border-color: var(--emerald-line); }
.pill.SELL, .pill.sell, .pill.short, .pill.ERROR, .pill.LOSS { color: var(--rose-hi); background: var(--rose-bg); border-color: var(--rose-line); }
.pill.BE { color: var(--text-2); }
.pill.APLUS { color: var(--l0); background: var(--emerald-hi); border-color: var(--emerald-hi); }
.pill.SCALP { color: #FBBF24; background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); }
.pill.SWING { color: var(--cyan); background: transparent; border-color: var(--cyan-line); }
.pill.OPEN { color: var(--cyan); background: var(--cyan-bg); border-color: var(--cyan-line); }
.ok { color: var(--emerald-hi); }

footer { text-align: center; color: var(--faint); font-size: 12px; padding: 8px 24px 32px; }

#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 50; max-width: 360px; padding: 12px 16px;
  background: var(--l3); border: 1px solid var(--cyan-line); border-radius: var(--r-xl); box-shadow: var(--shadow-overlay);
  font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { border-color: var(--rose-line); color: var(--rose-hi); }

.mobile-strip { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-main { display: contents; }
  .chart-panel { order: 1; } .bot-panel { order: 2; } .activity-panel { order: 3; }
  .indicators { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .indicators div:nth-child(3n) { border-right: 0; }
  .indicators div:nth-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
}
@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .topbar { padding: 12px 16px; position: static; }
  main, .grid { gap: 16px; }
  main { padding: 16px; }
  .metrics { gap: 12px; }
  .value { font-size: 18px; line-height: 26px; }
  .indicators { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .indicators div { border-right: 1px solid var(--line-soft) !important; border-bottom: 1px solid var(--line-soft); }
  .indicators div:nth-child(2n) { border-right: 0 !important; }
  .indicators div:nth-last-child(-n+2) { border-bottom: 0; }
  .settings { grid-template-columns: 1fr; }
  .settings .btn { grid-column: auto; }
  .thumb { width: 120px; height: 60px; }
  footer { padding-bottom: 88px; }
  #toast { left: 16px; right: 16px; bottom: 76px; max-width: none; }
  .mobile-strip {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr 1fr;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); gap: 12px;
    background: rgba(13, 19, 31, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line-soft);
  }
  .mobile-strip span { display: block; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
  .mobile-strip b { font-size: 14px; font-weight: 500; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* multi-symbol */
.symbol-select { background: var(--surface-2, #111827); color: inherit; border: 1px solid var(--border, #1A2333); border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 12px; margin-left: auto; margin-right: 8px; }
.ot-sep { border: 0; border-top: 1px solid var(--border, #1A2333); margin: 10px 0; }
.sym-scan { font-size: 11px; color: var(--text-muted, #64748B); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sym-scan b { color: inherit; font-weight: 600; margin-right: 4px; }
.meter-row.off { opacity: .55; }


/* timeframe buttons stay on the right, also when the header wraps */
#granularity { margin-left: auto; }
.chart-panel .symbol-select { margin-left: 0; }

/* chart header: symbol picker + JEV button */
.chart-tools { display: flex; align-items: center; gap: 8px; }
.chart-panel .chart-tools .symbol-select { width: auto; margin: 0; padding: 6px 10px; }
.btn-jev { padding: 6px 12px; border-radius: var(--r); background: rgba(6, 182, 212, .14); border: 1px solid rgba(6, 182, 212, .45); color: #22D3EE; font: 700 11px/16px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.btn-jev:hover { background: rgba(6, 182, 212, .24); }
.btn-jev:disabled { opacity: .6; cursor: wait; }
.jev-table td, .jev-table th { padding: 6px 8px; font-size: 12px; }
.jev-sym { cursor: pointer; }
.jev-sym:hover, .jev-sym:focus { background: rgba(6, 182, 212, .06); outline: none; }
.odds { position: relative; display: inline-block; width: 64px; height: 18px; border-radius: 4px; background: rgba(148, 163, 184, .08); overflow: hidden; vertical-align: middle; text-align: left; }
.odds i { position: absolute; top: 0; bottom: 0; left: 0; opacity: .35; }
.odds em { position: relative; font: 500 11px/18px var(--font-mono); font-style: normal; padding: 0 6px; }
.odds.buy i { background: #10B981; }
.odds.sell i { background: #F43F5E; }
.odds.hold i { background: #64748B; }
.odds.top { box-shadow: inset 0 0 0 1px currentColor; }
.odds.buy.top { color: #10B981; }
.odds.sell.top { color: #F43F5E; }
.odds.hold.top { color: #CBD5E1; }

/* JEV pop-up */
.jev-card { width: min(1100px, 100%); }
.jev-when { margin-left: 6px; font: 500 12px/16px var(--font-mono); color: var(--muted); text-transform: none; letter-spacing: 0; }
.btn-row-inline { display: flex; gap: 8px; }
.jev-body { padding: 4px 16px 12px; }
.jev-loading { padding: 32px 0; text-align: center; font: 500 13px/18px var(--font-mono); color: var(--muted); }
.jev-table .jev-symcell { white-space: nowrap; }
.jev-table .jev-setup { color: var(--muted); font-size: 12px; min-width: 220px; white-space: normal; }

/* per-symbol last scan: one full line each */
.meter-split:has(.sym-scan) { display: grid; gap: 2px; }
.sym-scan { display: block; white-space: normal; overflow: visible; line-height: 16px; }

.jev-table .jev-bot { font-size: 12px; min-width: 180px; white-space: normal; color: var(--text-2); }

/* strategy model picker + pop-ups */
.model-box { margin-top: 14px; padding: 12px; border-radius: var(--r-lg); background: var(--l2); border: 1px solid var(--line-soft); display: grid; gap: 8px; }
.model-label { font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.model-box .btn-row { margin-top: 0; }
.modal-body { padding: 12px 16px 16px; }
.strategy-card, .config-card { width: min(720px, 100%); }
.model-rules { margin: 0 0 12px; color: var(--text-2); line-height: 22px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
#suggestions .reason { min-width: 260px; white-space: normal; }

#suggestions .src-link { color: #22D3EE; font-size: 12px; white-space: nowrap; }

/* Configure strategy tabs */
.settings-tabs { display: grid; gap: 14px; }
.cfg-tabs { justify-self: start; }
.cfg-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cfg-group[hidden] { display: none; }
.cfg-group label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cfg-save { justify-self: start; }
.cfg-note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }
@media (max-width: 560px) { .cfg-group { grid-template-columns: 1fr; } }

/* chat assistant */
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(6, 182, 212, .5);
  background: #0E7490; color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .45), 0 0 18px rgba(6, 182, 212, .35); }
.chat-fab:hover { background: #0891B2; }
.chat-fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-panel { position: fixed; right: 20px; bottom: 88px; z-index: 50; width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--l3); border: 1px solid rgba(255, 255, 255, .08); border-radius: var(--r-xl); box-shadow: var(--shadow-overlay); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.chat-head b { display: block; font-size: 14px; }
.chat-head .sub { font-size: 11px; color: var(--muted); }
.chat-actions { display: flex; gap: 4px; }
.chat-icon { width: 30px; height: 30px; border-radius: var(--r); border: 1px solid var(--line-soft); background: transparent; color: var(--muted); cursor: pointer; }
.chat-icon:hover { color: var(--text); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 88%; padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 19px; white-space: normal; overflow-wrap: anywhere; }
.chat-msg.user { align-self: flex-end; background: rgba(6, 182, 212, .18); border: 1px solid rgba(6, 182, 212, .35); }
.chat-msg.assistant { align-self: flex-start; background: var(--l2); border: 1px solid var(--line-soft); color: var(--text-2); }
.chat-msg.typing { color: var(--muted); font-style: italic; }
.chat-empty { color: var(--muted); font-size: 13px; line-height: 19px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chat-chips[hidden] { display: none; }
.chat-chips button { padding: 5px 10px; border-radius: 9999px; border: 1px solid rgba(6, 182, 212, .35); background: transparent; color: #22D3EE; font-size: 12px; cursor: pointer; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.chat-form textarea { flex: 1; resize: none; min-height: 38px; max-height: 120px; }
.chat-form .btn { width: auto; }
@media (max-width: 560px) { .chat-panel { right: 16px; bottom: 84px; } .chat-fab { right: 16px; bottom: 16px; } }

/* chat assistant: robot icon */
.chat-fab { background: radial-gradient(circle at 30% 25%, #22D3EE, #0E7490 70%); }
.chat-fab svg { width: 28px; height: 28px; stroke-width: 1.7; }
.chat-fab svg .dot, .chat-avatar svg .dot { fill: currentColor; stroke: none; }
.chat-head { justify-content: flex-start; }
.chat-head .chat-actions { margin-left: auto; }
.chat-avatar { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #22D3EE; background: rgba(6, 182, 212, .14); border: 1px solid rgba(6, 182, 212, .35); }
.chat-avatar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* strategy buttons */
.btn-view { background: rgba(6, 182, 212, .14); border: 1px solid rgba(6, 182, 212, .45); color: #22D3EE; }
.btn-view:hover { background: rgba(6, 182, 212, .24); }
.btn-config { background: rgba(16, 185, 129, .14); border: 1px solid rgba(16, 185, 129, .45); color: #34D399; }
.btn-config:hover { background: rgba(16, 185, 129, .24); }

/* scan funnel */
.funnel { display: grid; gap: 4px; margin-top: 8px; }
.funnel-row { display: grid; grid-template-columns: 78px minmax(0, 1fr) 56px; align-items: center; gap: 8px; font: 500 11px/16px var(--font-mono); color: var(--muted); }
.funnel-row b { text-align: right; color: var(--text); font-weight: 500; }
.funnel-track { height: 8px; border-radius: 4px; background: var(--l2); overflow: hidden; }
.funnel-track i { display: block; height: 100%; border-radius: 4px; background: #0E7490; }
.funnel-track i.s1 { background: #0891B2; } .funnel-track i.s2 { background: #06B6D4; } .funnel-track i.s3 { background: #10B981; }

/* confidence badge */
.conf { position: relative; display: inline-block; width: 52px; height: 18px; border-radius: 4px; overflow: hidden; vertical-align: middle; background: rgba(148, 163, 184, .1); text-align: left; }
.conf i { position: absolute; top: 0; bottom: 0; left: 0; opacity: .35; }
.conf em { position: relative; padding: 0 6px; font: 500 11px/18px var(--font-mono); font-style: normal; color: var(--text); }
.conf.hi i { background: #10B981; } .conf.mid i { background: #F59E0B; } .conf.lo i { background: #F43F5E; }
.conf.hi { box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .5); } .conf.mid { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .5); } .conf.lo { box-shadow: inset 0 0 0 1px rgba(244, 63, 94, .5); }

/* equity curve */
.equity { margin: 12px 0; padding: 12px; border-radius: var(--r-lg); background: var(--l2); border: 1px solid var(--line-soft); }
.equity-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.equity-head .sub { color: var(--muted); font-size: 12px; }
.equity-plot { position: relative; width: 100%; overflow: hidden; }
.equity-plot svg { display: block; max-width: 100%; height: auto; }
.equity-empty { padding: 40px 0; text-align: center; color: var(--muted); font-size: 13px; }
.eq-grid { stroke: var(--line-soft); stroke-width: 1; }
.eq-zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.eq-axis { fill: var(--muted); font: 500 10px var(--font-mono); }
.eq-line { fill: none; stroke: #06B6D4; stroke-width: 2; stroke-linejoin: round; }
.eq-dot { stroke: var(--l2); stroke-width: 2; } .eq-dot.up { fill: #10B981; } .eq-dot.down { fill: #F43F5E; }
.eq-cross { stroke: var(--muted); stroke-width: 1; }
.eq-tip { position: absolute; top: 8px; display: grid; gap: 2px; padding: 6px 9px; border-radius: 6px; background: var(--l3); border: 1px solid rgba(255, 255, 255, .1); font: 500 11px/15px var(--font-mono); color: var(--text-2); pointer-events: none; min-width: 150px; }

/* Jev odds as a picture */
.odds-viz { margin-top: 10px; display: grid; gap: 8px; }
.odds-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--l2); }
.odds-bar i { display: block; min-width: 2px; opacity: .55; }
.odds-bar i.top { opacity: 1; }
.odd-buy { background: #10B981; } .odd-sell { background: #F43F5E; } .odd-hold, .odd-close { background: #64748B; }
.odd-close { background: #F59E0B; }
.odds-legend { display: flex; flex-wrap: wrap; gap: 12px; font: 500 12px/16px var(--font-mono); color: var(--muted); }
.odd-key { display: inline-flex; align-items: center; gap: 5px; }
.odd-key i { width: 8px; height: 8px; border-radius: 2px; }
.odd-key b { color: var(--text-2); font-weight: 500; }
.odd-key.top b { color: var(--text); font-weight: 700; }
.odds-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 9999px; border: 1px solid var(--line-soft); background: var(--l2); font: 500 11px/16px var(--font-mono); color: var(--muted); }
.chip b { color: var(--text); font-weight: 500; }

/* toast sits left of the chat bubble */
#toast { right: 88px; }
@media (max-width: 760px) { #toast { right: 16px; bottom: 84px; } }

/* auto-trading switch */
.auto-toggle { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-lg);
  border: 1px solid var(--line-soft); background: var(--l2); color: var(--text); font: 600 14px/20px var(--font-body); cursor: pointer; }
.auto-track { position: relative; width: 40px; height: 22px; border-radius: 9999px; background: #334155; transition: background .2s; flex: none; }
.auto-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #CBD5E1; transition: transform .2s, background .2s; }
.auto-toggle[aria-checked="true"] { border-color: var(--emerald-line); box-shadow: 0 0 12px rgba(16, 185, 129, .15); }
.auto-toggle[aria-checked="true"] .auto-track { background: #10B981; }
.auto-toggle[aria-checked="true"] .auto-knob { transform: translateX(18px); background: #fff; }
.auto-toggle[aria-checked="true"] #autoState { color: #34D399; }
.auto-toggle #autoState { color: var(--muted); }
.auto-toggle:disabled { opacity: .6; cursor: wait; }
@media (prefers-reduced-motion: reduce) { .auto-track, .auto-knob { transition: none; } }

/* P&L calendar */
.cal { margin: 12px 0; padding: 12px; border-radius: var(--r-lg); background: var(--l2); border: 1px solid var(--line-soft); }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav .btn { min-width: 36px; padding: 4px 10px; }
.cal-nav b { min-width: 150px; text-align: center; font: 500 13px/20px var(--font-mono); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, .9fr); gap: 4px; }
.cal-h { padding: 2px 6px; font: 600 10px/14px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.cal-d, .cal-w { min-height: 64px; padding: 6px; border-radius: 8px; border: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-d span { font: 500 11px/14px var(--font-mono); color: var(--muted); }
.cal-d b, .cal-w b { font: 500 13px/18px var(--font-mono); font-feature-settings: "tnum"; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-d small, .cal-w small { font: 400 10px/14px var(--font-mono); color: var(--muted); }
.cal-d.off { border-color: transparent; }
.cal-d.pos { background: color-mix(in srgb, var(--green) var(--a), transparent); }
.cal-d.neg { background: color-mix(in srgb, var(--red) var(--a), transparent); }
.cal-d.pos b { color: var(--green); }
.cal-d.neg b { color: var(--red); }
.cal-d.today { border-color: var(--blue); }
.cal-w { background: var(--l1, transparent); justify-content: center; }
@media (max-width: 640px) {
  .cal-d, .cal-w { min-height: 48px; padding: 4px; }
  .cal-d small, .cal-w small { display: none; }
  .cal-d b, .cal-w b { font-size: 10px; }
  .cal-nav b { min-width: 0; }
}
.pill.MECH { color: #A78BFA; background: rgba(167, 139, 250, .1); border-color: rgba(167, 139, 250, .3); }

/* readable setup checklist on the trade card */
.ot-reason .rs-head { display: block; font: 600 12px/18px var(--font-mono); color: var(--text); margin-bottom: 6px; letter-spacing: .02em; }
.rs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rs-list li { display: flex; align-items: baseline; gap: 8px; font: 400 13px/18px var(--font-sans, inherit); color: var(--text-2); }
.rs-list li i { flex: 0 0 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font: 700 10px/1 var(--font-mono); font-style: normal; }
.rs-ok i { color: var(--green); background: rgba(16, 185, 129, .14); }
.rs-warn i { color: #FBBF24; background: rgba(251, 191, 36, .14); }
.rs-info i { color: var(--blue); background: rgba(6, 182, 212, .14); }
.rs-warn { color: #FCD34D; }
.order-chips { margin-top: 10px; }
.chip.warn { color: #FCD34D; border-color: rgba(251, 191, 36, .35); }
.chip.ok { color: var(--green); border-color: rgba(16, 185, 129, .35); }
.decision .rs-list { margin-top: 10px; }
