:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --series-1: #2a78d6;   /* this market */
  --series-2: #eb6834;   /* paired market on the other site */
  --yes: #2a78d6;        /* flow buying YES (diverging pole) */
  --no: #e34948;         /* flow buying NO (diverging pole) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --grid: #e8e7e3;
  --accent-bg: #e6f0fc;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8d8c85;
    --series-1: #3987e5;
    --series-2: #d95926;
    --yes: #3987e5;
    --no: #e66767;
    --grid: #2a2a28;
    --accent-bg: #172638;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface-1: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8d8c85;
  --series-1: #3987e5; --series-2: #d95926; --yes: #3987e5; --no: #e66767;
  --grid: #2a2a28; --accent-bg: #172638;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text-secondary); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  padding: 16px 24px 12px;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.brand .sub { color: var(--text-muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); display: inline-block; align-self: center; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.dot.bad { background: var(--critical); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums;
}
.pill b { color: var(--text-primary); font-weight: 600; }

.tabs { display: flex; gap: 2px; padding: 0 24px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 10px 12px; font: inherit; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.active { color: var(--text-primary); border-bottom-color: var(--text-primary); font-weight: 600; }

main { padding: 16px 24px 48px; }
.tab { display: none; }
.tab.active { display: block; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--text-secondary); font-size: 13px; }
select {
  font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px;
}
.count { color: var(--text-muted); font-size: 13px; margin-left: auto; }
.hint { color: var(--text-secondary); font-size: 13px; max-width: 900px; }
.empty { color: var(--text-muted); padding: 24px 4px; }

.table-wrap { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th {
  text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-1);
  position: sticky; top: 0;
}
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.grid tr:last-child td { border-bottom: none; }
.grid tbody tr.click { cursor: pointer; }
.grid tbody tr.click:hover { background: var(--surface-2); }
.grid tr.new { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--accent-bg); } to { background: transparent; } }
.mkt { max-width: 420px; min-width: 220px; }
.mkt .t { font-weight: 500; }
.mkt .e { color: var(--text-muted); font-size: 12px; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.nowrap { white-space: nowrap; }

.score { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.score .lv { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-secondary); }
.score.high .lv { border-color: var(--critical); color: var(--text-primary); }
.score.high .lv::before { content: "▲ "; color: var(--critical); }
.score.medium .lv::before { content: "● "; color: var(--warning); }
.score.low .lv::before { content: "○ "; color: var(--text-muted); }

.dir { white-space: nowrap; font-weight: 500; }
.dir::before { display: inline-block; margin-right: 4px; }
.dir.yes::before { content: "▲"; color: var(--yes); }
.dir.no::before { content: "▼"; color: var(--no); }
.venue { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 320px; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.chip.strong { color: var(--text-primary); border: 1px solid var(--border); }
.pos { color: var(--text-primary); }
.pos::before { content: "+"; }
.delta-up::before { content: "▲ "; color: var(--good); font-size: 10px; }
.delta-down::before { content: "▼ "; color: var(--critical); font-size: 10px; }

button.btn {
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
button.btn:hover { background: var(--surface-2); }
.btns { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-secondary); }
.tag.confirmed { color: var(--text-primary); }
.tag.confirmed::before { content: "✓ "; color: var(--good); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.card .big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.card dt { color: var(--text-muted); }
.card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 9; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); z-index: 10;
  background: var(--surface-1); border-left: 1px solid var(--border); display: flex; flex-direction: column;
  box-shadow: -12px 0 32px rgba(0,0,0,.12);
}
.drawer-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 2px 0 0; font-size: 17px; line-height: 1.3; }
.eyebrow { font-size: 12px; color: var(--text-muted); }
.close { background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-secondary); padding: 0 4px; }
.drawer-body { overflow-y: auto; padding: 16px 20px 40px; }
.drawer h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 500; margin: 22px 0 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.kpi .l { font-size: 12px; color: var(--text-muted); }
.kpi .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 260px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--c); }
.legend span.mk::before { width: 0; height: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.legend span.mk.up::before { border-bottom: 8px solid var(--yes); }
.legend span.mk.down::before { border-top: 8px solid var(--no); }
ul.reasons { list-style: none; padding: 0; margin: 0; }
ul.reasons li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
ul.reasons li .p { font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; }
.news a { display: block; margin-bottom: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@media (max-width: 640px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 8px; }
  .grid th, .grid td { padding: 8px; }
  .count { margin-left: 0; }
}

/* trading */
.mode-tag { font-size: 10px; font-weight: 600; letter-spacing: .05em; padding: 1px 5px; border-radius: 4px; margin-left: 4px; border: 1px solid var(--border); color: var(--text-secondary); }
.mode-tag.live { border-color: var(--critical); color: var(--text-primary); }
.banner { border: 1px solid var(--border); background: var(--surface-1); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; font-size: 13px; color: var(--text-secondary); }
.banner b { color: var(--text-primary); }
.banner.live { border-color: var(--critical); }
.banner.live b::before { content: "▲ "; color: var(--critical); }
.banner.paper b::before { content: "○ "; color: var(--text-muted); }
.banner.demo b::before { content: "● "; color: var(--warning); }
h3.section { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 500; margin: 24px 0 8px; }
.ticket-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.ticket-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
input { font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-width: 0; }
.ticket-form input[name=ticker] { width: 240px; }
.ticket-form input[type=number] { width: 90px; }
button.btn.primary { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); font-weight: 600; }
button.btn.primary:hover { opacity: .88; background: var(--text-primary); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }
.form-msg { font-size: 13px; color: var(--text-secondary); }
.form-msg.err { color: var(--text-primary); }
.form-msg.err::before { content: "▲ "; color: var(--critical); }
.ticket { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.ticket .head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ticket .what { font-weight: 600; }
.ticket dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.ticket dt { font-size: 12px; color: var(--text-muted); }
.ticket dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.ticket .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticket .ttl { font-size: 12px; color: var(--text-muted); }
.status { font-size: 12px; white-space: nowrap; }
.status.filled::before { content: "✓ "; color: var(--good); }
.status.partial::before { content: "◐ "; color: var(--warning); }
.status.error::before, .status.unknown::before { content: "▲ "; color: var(--critical); }
.status.rejected, .status.expired, .status.unfilled { color: var(--text-muted); }
.copy-trade { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.copy-trade .row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.copy-trade label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.copy-trade input { width: 90px; }

/* ---- static demo ---- */
.demo-banner { background: var(--accent-bg); color: var(--text-secondary); border-bottom: 1px solid var(--border); padding: 8px 20px; font-size: 13px; }
.demo-banner b { color: var(--text-primary); }
.demo-off { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; color: var(--text-secondary); font-size: 13px; }
