:root {
  color-scheme: dark;
  --bg: #080c13;
  --surface-1: #0f1520;
  --surface-2: #151d2b;
  --surface-3: #1c2637;
  --stroke: #243045;
  --stroke-soft: #1b2434;
  --text-primary: #e9eef7;
  --text-secondary: #a9b4c6;
  --text-muted: #77839a;
  --series-1: #3987e5;           /* price / equity line (validated vs --surface-1) */
  --series-2: #d95926;           /* exit marker */
  --good: #0ca30c;  --good-ink: #4fd17a;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b; --critical-ink: #ff7b7b;
  --radius: 14px;
  --gutter: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: #8fb8f0; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(8,12,19,.92); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--stroke-soft);
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px; }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; letter-spacing: .06em; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--series-1); }
.top-status { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.updated { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
main.wrap { max-width: 1280px; margin: 0 auto; padding: 14px var(--gutter) 32px; }
section.block { margin-top: 22px; scroll-margin-top: 70px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
h2 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-secondary); margin: 0; font-weight: 650; }
.panel { background: var(--surface-1); border: 1px solid var(--stroke-soft); border-radius: var(--radius); padding: 16px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid var(--stroke); color: var(--text-secondary); background: var(--surface-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.badge.good::before { background: var(--good); }
.badge.warn::before { background: var(--warning); }
.badge.bad::before { background: var(--critical); }
.badge.info::before { background: var(--series-1); }
.badge.plain::before { display: none; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-secondary);
  font-size: 11px; border: 1px solid var(--stroke-soft); white-space: nowrap; }
.chip.runner { color: #b9d4ff; border-color: #2c4b78; }

/* ---------- alert banner ---------- */
.alerts { display: grid; gap: 8px; margin-top: 4px; }
.alert { border-radius: 12px; padding: 11px 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert .ico { font-weight: 800; }
.alert.bad { background: #2a1214; border-color: #5c2226; color: #ffd0d0; }
.alert.warn { background: #2a2210; border-color: #5a4716; color: #ffe7b0; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--text-secondary); font-size: 12px; }
.hero-value { font-size: 44px; font-weight: 760; letter-spacing: -.03em; margin: 8px 0 4px; line-height: 1.05; }
.pos { color: var(--good-ink); } .neg { color: var(--critical-ink); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero-value { font-size: 38px; } }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kpi .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi .v { font-size: 17px; font-weight: 680; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--stroke-soft); stroke-width: 1; }
.chart .axis text { fill: var(--text-muted); font-size: 10px; }
.chart .zero { stroke: #3a465c; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#fade); }
.chart .crosshair { stroke: var(--text-secondary); stroke-width: 1; opacity: .6; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .stopline { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .entryline { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .lbl { font-size: 10px; font-weight: 650; }
.chart .lbl.stop { fill: var(--critical-ink); } .chart .lbl.entry { fill: var(--text-secondary); }
.chart .mk-entry { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .mk-exit { fill: var(--series-2); stroke: var(--surface-1); stroke-width: 2; }
.chart .candle-up { fill: #2f6fb8; } .chart .candle-dn { fill: #4b566b; }
.chart .wick { stroke: #5d6a80; stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--stroke); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 3; display: none; }
.empty { color: var(--text-muted); font-size: 13px; padding: 26px 0; text-align: center; }

/* ---------- position ---------- */
.pos-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.pos-sym { font-size: 24px; font-weight: 760; letter-spacing: -.01em; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin: 14px 0; }
@media (max-width: 520px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fact .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.fact .v { font-weight: 640; margin-top: 1px; overflow-wrap: anywhere; }

/* ---------- tables / lists ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-muted); min-width: 0; flex: 1 1 130px; }
.filters input, .filters select { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 9px; padding: 8px 9px;
  min-height: 38px; width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 550; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  padding: 8px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--stroke-soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; display: grid;
    grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  .tbl.cards td { border: 0; padding: 0; }
  .tbl.cards td[data-k]::before { content: attr(data-k) " "; color: var(--text-muted); font-size: 11px; }
  .tbl.cards td.primary { font-weight: 680; }
  .tbl.cards td.r { text-align: right; }
  .tbl.cards td.wide { grid-column: 1 / -1; }
}
.reasons { color: var(--text-muted); font-size: 12px; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.note { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.drawer { position: fixed; z-index: 41; background: var(--surface-1); border-left: 1px solid var(--stroke); top: 0; right: 0; bottom: 0;
  width: min(720px, 100vw); overflow-y: auto; padding: calc(14px + env(safe-area-inset-top)) var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 720px) {
  .drawer { top: auto; left: 0; width: 100vw; max-height: 92vh; border-left: 0; border-top: 1px solid var(--stroke);
    border-radius: 18px 18px 0 0; }
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: -14px;
  background: var(--surface-1); padding: 6px 0 10px; z-index: 2; }
.drawer h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-secondary); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 4px 12px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--text-muted); }
.kv div:nth-child(even) { overflow-wrap: anywhere; }
.btn { background: var(--surface-3); border: 1px solid var(--stroke); border-radius: 10px; padding: 8px 12px; cursor: pointer; min-height: 38px; }
.btn:hover { border-color: #3a4a64; }

/* ---------- bottom nav (mobile) ---------- */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: none; background: rgba(12,17,26,.96);
  border-top: 1px solid var(--stroke-soft); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: blur(10px); }
.bottomnav a { flex: 1; text-align: center; color: var(--text-secondary); text-decoration: none; font-size: 11px; padding: 8px 2px;
  border-radius: 10px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.bottomnav a:active { background: var(--surface-2); }
.sidenav { display: flex; gap: 4px; }
.sidenav a { color: var(--text-secondary); text-decoration: none; font-size: 12px; padding: 6px 10px; border-radius: 8px; }
.sidenav a:hover { background: var(--surface-2); }
@media (max-width: 900px) { .bottomnav { display: flex; } .sidenav { display: none; } }
@media (min-width: 901px) { body { padding-bottom: 0; } }

.footer { color: var(--text-muted); font-size: 11px; border-top: 1px solid var(--stroke-soft); margin-top: 28px; padding-top: 14px; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: var(--gutter); }
.login-card { width: min(380px, 100%); background: var(--surface-1); border: 1px solid var(--stroke-soft); border-radius: 18px; padding: 26px 22px; }
.login-card form { display: grid; gap: 12px; margin-top: 8px; }
.login-card label { display: grid; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.login-card input { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 10px; padding: 12px; font-size: 16px; }
.btn-primary { background: var(--series-1); color: #fff; border: 0; border-radius: 10px; padding: 12px; font-weight: 700; cursor: pointer; min-height: 46px; }
.notice:empty { display: none; }
.notice { color: var(--critical-ink); font-size: 13px; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.h-curve { height: 190px; } .h-pos { height: 220px; } .h-drawer { height: 240px; }
.gap-below { margin-bottom: 12px; } .flush { margin-top: 0; }
h2.sub { margin-bottom: 8px; } h2.sub.spaced { margin-top: 16px; }
.logline { padding: 7px 0; border-bottom: 1px solid var(--stroke-soft); } .logline:last-child { border-bottom: 0; }
.btn { white-space: nowrap; }
@media (max-width: 480px) { .updated { display: none; } .top-status { gap: 6px; } }
.booksel { background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 10px; padding: 6px 8px;
  min-height: 34px; max-width: 46vw; font-size: 12px; }
.alert.info { background: #10203a; border-color: #24426e; color: #cfe1ff; }
@media (max-width: 480px) { .topbar-inner { flex-wrap: wrap; } .top-status { margin-left: 0; width: 100%; } .booksel { flex: 1; max-width: none; } }
