/* ORB Platform — fintech theme (Nexus-style).
   Dark by default: near-black canvas, charcoal cards with hairline borders, a
   soft mint glow. Interactive elements are neutral (white pills, grey active
   states); mint / red only ever mean data and P&L. General Sans for interface
   text and headline figures, JetBrains Mono for tabular figures.
   Theme is set on <html data-theme> by /static/theme.js before first paint. */

/* ---------- Fonts (self-hosted, no third-party requests) ---------- */
@font-face { font-family: 'General Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/GeneralSans-400.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/GeneralSans-500.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/GeneralSans-600.woff2') format('woff2'); }
@font-face { font-family: 'General Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/GeneralSans-700.woff2') format('woff2'); }
/* JetBrains Mono has no ₹ glyph — the stack falls back to General Sans for it */
@font-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-style: normal; font-display: swap;
  src: url('/static/fonts/JetBrainsMono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-style: normal; font-display: swap;
  src: url('/static/fonts/JetBrainsMono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Tokens: dark (default) ----------
   Nexus-style: near-black canvas, charcoal cards, hairline borders. Interactive
   elements are neutral (white pills); mint and red are reserved for data / P&L. */
:root {
  color-scheme: dark;
  --page: #0b0c0e;
  --surface: #131418;
  --surface-2: #191a1f;
  --surface-3: #212228;
  --border: rgba(255, 255, 255, 0.065);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f3f4f6;
  --text-2: #a7aab2;
  --text-3: #868993;
  --primary: #f3f4f6;          /* interactive emphasis: buttons, active states */
  --primary-hover: #ffffff;
  --primary-soft: rgba(255, 255, 255, 0.06);
  --primary-border: rgba(255, 255, 255, 0.16);
  --on-primary: #0b0c0e;
  --ring: #f3f4f6;
  --series-1: #3ddc97;
  --profit: #3ddc97;
  --profit-soft: rgba(61, 220, 151, 0.12);
  --profit-border: rgba(61, 220, 151, 0.3);
  --loss: #f26b77;
  --loss-soft: rgba(242, 107, 119, 0.12);
  --loss-border: rgba(242, 107, 119, 0.3);
  --warning: #eab650;
  --warning-soft: rgba(234, 182, 80, 0.1);
  --warning-border: rgba(234, 182, 80, 0.28);
  --gridline: rgba(255, 255, 255, 0.06);
  --glow: rgba(61, 220, 151, 0.07);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  /* sidebar + hero surfaces (sidebar shares the canvas in dark) */
  --deep: #0b0c0e;
  --deep-2: #18191e;
  --deep-text: #f3f4f6;
  --deep-text-2: #a7aab2;
  --deep-border: rgba(255, 255, 255, 0.065);
  --deep-pos: #3ddc97;
  --deep-neg: #f26b77;
  --deep-accent: #f3f4f6;

  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 20px;
  --radius-lg: 24px;
  --font: 'General Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'General Sans', ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Tokens: light (toggle, or "auto" on a light OS) ---------- */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --page: #f3f4f6; --surface: #ffffff; --surface-2: #f7f8fa; --surface-3: #eceef2;
    --border: #e4e6eb; --border-strong: #d0d3da;
    --text: #0e1013; --text-2: #4b5059; --text-3: #656b76;
    --primary: #0e1013; --primary-hover: #000000; --primary-soft: rgba(14, 16, 19, 0.06);
    --primary-border: rgba(14, 16, 19, 0.18); --on-primary: #ffffff; --ring: #0e1013;
    --series-1: #0f9d6a;
    --profit: #0a7a52; --profit-soft: #e2f6ee; --profit-border: #a8e3cb;
    --loss: #c4323e; --loss-soft: #fcecee; --loss-border: #f2bfc4;
    --warning: #935600; --warning-soft: #fff3df; --warning-border: #f1d29b;
    --gridline: #eceef2; --glow: rgba(15, 157, 106, 0.07);
    --shadow-sm: 0 1px 2px rgba(14, 16, 19, 0.05);
    --shadow: 0 1px 2px rgba(14, 16, 19, 0.04), 0 12px 32px rgba(14, 16, 19, 0.07);
    --deep: #ffffff; --deep-2: #f3f4f6; --deep-text: #0e1013; --deep-text-2: #4b5059;
    --deep-border: #e4e6eb; --deep-pos: #0a7a52; --deep-neg: #c4323e; --deep-accent: #0e1013;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f4f6; --surface: #ffffff; --surface-2: #f7f8fa; --surface-3: #eceef2;
  --border: #e4e6eb; --border-strong: #d0d3da;
  --text: #0e1013; --text-2: #4b5059; --text-3: #656b76;
  --primary: #0e1013; --primary-hover: #000000; --primary-soft: rgba(14, 16, 19, 0.06);
  --primary-border: rgba(14, 16, 19, 0.18); --on-primary: #ffffff; --ring: #0e1013;
  --series-1: #0f9d6a;
  --profit: #0a7a52; --profit-soft: #e2f6ee; --profit-border: #a8e3cb;
  --loss: #c4323e; --loss-soft: #fcecee; --loss-border: #f2bfc4;
  --warning: #935600; --warning-soft: #fff3df; --warning-border: #f1d29b;
  --gridline: #eceef2; --glow: rgba(15, 157, 106, 0.07);
  --shadow-sm: 0 1px 2px rgba(14, 16, 19, 0.05);
  --shadow: 0 1px 2px rgba(14, 16, 19, 0.04), 0 12px 32px rgba(14, 16, 19, 0.07);
  --deep: #ffffff; --deep-2: #f3f4f6; --deep-text: #0e1013; --deep-text-2: #4b5059;
  --deep-border: #e4e6eb; --deep-pos: #0a7a52; --deep-neg: #c4323e; --deep-accent: #0e1013;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background:
    radial-gradient(1100px 520px at 92% -8%, var(--glow), transparent 60%) no-repeat,
    var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; }
/* General Sans has a narrow word space (0.21em); at semibold with tight tracking
   words visually run together ("Recenttrades"), so open it up a touch */
body { word-spacing: 0.03em; }
h1, h2, h3, .brand, .h2h-name, .sym, strong, b, th { word-spacing: 0.09em; }
p { text-wrap: pretty; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong);
    text-underline-offset: 3px; transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease); }
a:hover { text-decoration-color: currentColor; }
.nav a, .sym a, .chip, .h2h-card, .badge, .btn-primary, .btn-light, .promo-stat, .trade-list a,
.compare-table thead a, .skip-link { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-xs); }
::selection { background: var(--primary-soft); }
code, pre, .raw-json { font-family: var(--font-mono); }
/* every figure lines up column-to-column */
.value, .num, .h2h-stats b, .chart-tooltip strong, .meta, .delta, .spec-list .v, .dir, .strat-tag { font-variant-numeric: tabular-nums; }
td.num, .h2h-stats b, .dir, .strat-tag, .code, .tl-pnl { font-family: var(--font-mono); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--space-3); top: -48px; z-index: 100;
  background: var(--deep); color: var(--deep-text);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  transition: top 150ms var(--ease);
}
.skip-link:focus { top: var(--space-3); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--deep);
  color: var(--deep-text);
  border-right: 1px solid var(--deep-border);
  display: flex; flex-direction: column;
  padding: var(--space-5) var(--space-3) var(--space-4);
  position: sticky; top: 0; height: 100dvh;
}
.brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-3); margin-bottom: var(--space-6);
  color: inherit; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; line-height: 1.25;
}
.brand svg { flex-shrink: 0; }
.brand .sub { display: block; font-size: 12.5px; font-weight: 500; color: var(--deep-text-2); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3); min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--deep-text-2); font-weight: 500; font-size: 14.5px;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
.nav a:hover { background: var(--primary-soft); color: var(--deep-text); }
.nav a[aria-current="page"] {
  background: var(--deep-2); color: var(--deep-text);
  box-shadow: inset 0 0 0 1px var(--deep-border);
  border-radius: 999px;
}
.nav a[aria-current="page"] svg { color: var(--deep-accent); }
.nav svg { flex-shrink: 0; }
.sidebar-footer { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--deep-border); padding-top: var(--space-3); }
.logout-btn, .theme-btn {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; padding: 10px var(--space-3); min-height: 44px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--deep-text-2); font-size: 14px; font-weight: 500; text-align: left;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
.theme-btn:hover { background: var(--primary-soft); color: var(--deep-text); }
.theme-btn .theme-value { margin-left: auto; font-size: 12.5px; color: var(--deep-text-2); }
.logout-btn:hover { background: var(--loss-soft); color: var(--loss); }
.sidebar :focus-visible { outline-color: var(--deep-accent); }

.main {
  flex: 1; min-width: 0; width: 100%; max-width: 1320px; margin-inline: auto;
  padding: var(--space-6) var(--space-6) var(--space-7);
}
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
.topbar .meta { color: var(--text-3); font-size: 13px; margin-top: var(--space-1); }
.badges { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface);
}
.badge svg { flex-shrink: 0; }
.badge.ok { color: var(--profit); border-color: var(--profit-border); background: var(--profit-soft); }
.badge.warn { color: var(--warning); border-color: var(--warning-border); background: var(--warning-soft); }
.badge.danger { color: var(--loss); border-color: var(--loss-border); background: var(--loss-soft); }
.badge.info { color: var(--primary); border-color: var(--primary-border); background: var(--primary-soft); }
a.badge:hover { text-decoration: none; filter: brightness(0.97); }

/* ---------- Cards & grid ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card h2 {
  margin: 0 0 var(--space-4);
  font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.015em;
}
.grid { display: grid; gap: var(--space-4); }
.tiles { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: var(--space-4); }
.two-col { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.tile { display: flex; flex-direction: column; }
.tile .label { font-size: 13.5px; font-weight: 500; color: var(--text-2); margin-bottom: var(--space-2); }
.tile .value { font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -0.03em; }
.tile .delta { font-size: 12.5px; color: var(--text-3); margin-top: auto; padding-top: var(--space-2); }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.delta .arrow { font-weight: 700; }

/* Hero tile (the one carrying .value.hero): deep panel, the dashboard's anchor */
.tile:has(.value.hero) {
  background:
    radial-gradient(120% 140% at 100% 0%, var(--profit-soft), transparent 60%),
    var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.tile .value.hero { font-size: 44px; letter-spacing: -0.045em; }

@media (min-width: 1100px) {
  .tiles:has(.value.hero) { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-2)); padding: 0 var(--space-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3);
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px var(--space-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td.num { font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 150ms var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr[data-href] { cursor: pointer; }
td.num, th.num { text-align: right; }
.sym { font-weight: 600; }
.sym a { color: inherit; }
.sym a:hover { color: var(--primary); }
.dir {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-xs);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
}
.dir.buy { color: var(--profit); background: var(--profit-soft); }
.dir.sell { color: var(--loss); background: var(--loss-soft); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-pill.open .dot { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.status-pill.target .dot { background: var(--profit); }
.status-pill.stopped .dot { background: var(--loss); }
.status-pill.eod .dot { background: var(--warning); }
.empty { padding: var(--space-7) var(--space-5); text-align: center; color: var(--text-3); font-size: 14px; }

/* ---------- Detail pages ---------- */
.back-link { margin: calc(-1 * var(--space-3)) 0 var(--space-4); font-size: 13.5px; }
.topbar h1 .dir, .topbar h1 .status-pill { vertical-align: middle; margin-left: var(--space-2); }
.detail-cols { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .detail-cols { grid-template-columns: 1fr; } }
.fineprint { margin: var(--space-3) 0 0; font-size: 12.5px; color: var(--text-3); }
.raw-json {
  margin: 0; padding: var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.65; color: var(--text-2);
  overflow-x: auto;
}

/* ---------- Forms & filters ---------- */
.filter-row { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); flex-wrap: wrap; }
.filter-row label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }
select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 8px 36px 8px 16px; min-height: 44px; font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  transition: border-color 200ms var(--ease);
}
select:hover { border-color: var(--text-3); }
.btn-primary {
  width: 100%; min-height: 48px;
  background: var(--primary); color: var(--on-primary);
  border: none; border-radius: 999px;
  font-size: 15px; font-weight: 600;
  transition: background 200ms var(--ease), transform 120ms var(--ease);
}
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); text-decoration: none; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.inline { width: auto; min-height: 44px; padding: 8px 20px; }

/* ---------- Chart ---------- */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: var(--space-2) var(--space-3);
  font-size: 12.5px; line-height: 1.5; white-space: nowrap;
  opacity: 0; transition: opacity 150ms var(--ease);
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .t-title { font-weight: 600; }
.chart-tooltip .t-row { color: var(--text-2); }
.chart-tooltip .t-row strong { color: var(--text); }

/* ---------- Spec lists & notes ---------- */
.spec-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.spec-list { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.spec-list li {
  display: flex; justify-content: space-between; gap: var(--space-4);
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.spec-list li:last-child { border-bottom: none; }
.spec-list .k { color: var(--text-2); }
.spec-list .k.wide { max-width: none; }
.spec-list .v { font-weight: 500; text-align: right; }
.note {
  margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-2);
}
.note strong { color: var(--text); font-weight: 600; }

/* ---------- Strategy tags ---------- */
/* Two categories, distinguished by fill (outlined vs solid), never by a colour that
   already means something here (green/red = P&L). */
.strat-tag {
  display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 5px; vertical-align: middle;
  color: var(--text-2); border: 1px solid var(--border-strong); background: transparent;
}
.strat-tag.gap { color: var(--page); background: var(--text); border-color: var(--text); }

/* ---------- Head-to-head ---------- */
.h2h { margin-bottom: var(--space-4); }
.h2h-head { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.h2h-head h2 { margin: 0; }
.h2h-head .meta { font-size: 13px; color: var(--text-3); }
.h2h-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: var(--space-4) 0; }
.h2h-card {
  display: block; padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: inherit;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), transform 120ms var(--ease), box-shadow 200ms var(--ease);
}
.h2h-card:hover { border-color: var(--primary-border); background: var(--surface); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.h2h-card:active { transform: translateY(1px); }
.h2h-name { font-weight: 600; margin-bottom: var(--space-2); display: flex; align-items: center; gap: var(--space-2); }
.h2h-card .value { font-size: 30px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.2; }
.h2h-stats { list-style: none; margin: var(--space-4) 0 0; padding: var(--space-3) 0 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.h2h-stats li { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-2); }
.h2h-stats b { color: var(--text); font-weight: 500; font-size: 13px; }
.h2h-stats .muted { color: var(--text-3); font-weight: 400; }

.filter-chips {
  display: inline-flex; gap: 2px; flex-wrap: wrap; margin-bottom: var(--space-4);
  padding: 3px; background: var(--surface-3); border-radius: 999px;
}
.chip {
  font-size: 13.5px; font-weight: 500; padding: 7px 16px; border-radius: 999px;
  color: var(--text-2);
  transition: color 200ms var(--ease), background 200ms var(--ease), box-shadow 200ms var(--ease), transform 120ms var(--ease);
}
.chip:hover { color: var(--text); text-decoration: none; }
.chip:active { transform: scale(0.97); }
.chip[aria-current="true"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }

/* ---------- Side-by-side backtests ---------- */
.compare-table th[scope="row"] { font-weight: 500; font-size: 14px; color: var(--text-2); text-align: left; border-bottom: 1px solid var(--border); padding: 12px var(--space-3); }
.compare-table td.big { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.compare-table thead a { color: inherit; }
.compare-table tr:last-child th { border-bottom: none; }
.compare-charts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-top: var(--space-4); }
.sym a.compare-link, .compare-link { font-size: 12.5px; font-weight: 500; color: var(--primary); }

/* ---------- Utilities ---------- */
.mt-4 { margin-top: var(--space-4); }
.ml-auto { margin-left: auto; }
.muted { color: var(--text-3); }
.lede { font-size: 14px; color: var(--text-2); margin: 0 0 var(--space-4); max-width: 65ch; }
.more-link { margin: var(--space-4) 0 0; font-size: 13.5px; font-weight: 500; }

/* Live status while a backtest is queued/running (page auto-refreshes) */
.live-note { display: flex; align-items: flex-start; gap: var(--space-2); border-left-color: var(--primary); }
.live-note .pulse {
  width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0;
  animation: pulse 1.6s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- Login & 404 ---------- */
.login-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  background:
    radial-gradient(900px 520px at 85% -10%, var(--glow), transparent 60%),
    radial-gradient(700px 420px at 0% 110%, var(--glow), transparent 60%),
    var(--page);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-7) var(--space-6) var(--space-6);
  box-shadow: var(--shadow);
}
.login-card .brand { padding: 0; margin-bottom: var(--space-6); color: var(--text); }
.login-card .brand .sub { color: var(--text-3); }
.login-card h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 var(--space-1); }
.login-card .lede { color: var(--text-2); font-size: 14px; margin: 0 0 var(--space-5); }
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.field input:hover { border-color: var(--text-3); }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); outline: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-3); border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--text); }
.login-error {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--loss-soft); border: 1px solid var(--loss-border);
  color: var(--loss); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); font-size: 13.5px; font-weight: 500;
  margin-bottom: var(--space-4);
}
.login-foot { margin: var(--space-5) 0 0; text-align: center; font-size: 12.5px; color: var(--text-3); }

.notfound { text-align: center; }
.notfound .code { font-size: 13px; color: var(--primary); margin: 0 0 var(--space-2); }
.notfound h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 var(--space-2); }
.notfound p { color: var(--text-2); font-size: 14px; margin: 0 0 var(--space-5); }
.notfound .btn-primary { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center;
    padding: var(--space-2) var(--space-3);
  }
  .brand { margin-bottom: 0; margin-right: auto; padding: 0 var(--space-2); }
  .brand .sub { display: none; }
  .nav { flex-direction: row; flex: 0; }
  .nav a span { display: none; }
  .nav a { padding: 10px; }
  .sidebar-footer { flex-direction: row; border-top: none; padding-top: 0; margin-left: var(--space-1); }
  .logout-btn span, .theme-btn span { display: none; }
  .logout-btn, .theme-btn { width: auto; padding: 10px; }
  .main { padding: var(--space-5) var(--space-4) var(--space-6); }
  .topbar h1 { font-size: 24px; }
  .card { padding: var(--space-4); }
  .tile .value.hero { font-size: 34px; }
}
@media (max-width: 480px) {
  .brand > div { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

.value.text { font-family: var(--font); letter-spacing: -0.02em; }

/* ======================================================================
   Dashboard (Nexus-style layout): KPI row + portfolio hero on the left,
   head-to-head card + recent trades on the right.
   ====================================================================== */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: var(--space-4); align-items: start; }
.dash-main, .dash-side { display: grid; gap: var(--space-4); min-width: 0; }
@media (max-width: 1180px) { .dash { grid-template-columns: 1fr; } }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h2 { margin: 0; }
.card-head .meta { font-size: 12.5px; color: var(--text-3); }
.link-quiet { font-size: 13px; font-weight: 500; color: var(--text-2); }
.link-quiet:hover { color: var(--text); }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.kpi { padding: var(--space-4) var(--space-5); }
.kpi-label { margin: 0 0 var(--space-3) !important; font-size: 13.5px !important; font-weight: 500 !important; color: var(--text-2) !important; }
.kpi-row { display: flex; align-items: center; gap: var(--space-2); }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-sub { margin: var(--space-2) 0 0; font-size: 12.5px; color: var(--text-3); }
.trend {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  color: var(--page);
}
.trend.up { background: var(--profit); }
.trend.down { background: var(--loss); }

/* Portfolio hero */
.portfolio { padding: var(--space-5) var(--space-5) var(--space-4); }
.portfolio-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; }
.portfolio-head h2 { margin: 2px 0 0; font-size: 20px; }
.eyebrow-icon { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text-2); }
.range-select select { min-height: 40px; background-color: var(--surface-2); }
.portfolio-figure { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-4) 0 var(--space-3); }
.big-value { font-size: 44px; font-weight: 600; letter-spacing: -0.045em; line-height: 1; margin-right: var(--space-2); }
.pill {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
}
.pill.up { color: var(--profit); background: var(--profit-soft); border-color: var(--profit-border); }
.pill.down { color: var(--loss); background: var(--loss-soft); border-color: var(--loss-border); }
.chart-box.equity { margin: 0 calc(-1 * var(--space-2)); }
.portfolio-foot {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3);
  margin: var(--space-3) 0 0; padding-top: var(--space-4); border-top: 1px solid var(--border);
}
@media (max-width: 700px) { .portfolio-foot { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.portfolio-foot dt { font-size: 12.5px; color: var(--text-3); margin-bottom: 2px; }
.portfolio-foot dd { margin: 0; font-size: 14px; font-weight: 500; }

/* Monthly bars + exit donut */
.dash-pair { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-4); }
@media (max-width: 800px) { .dash-pair { grid-template-columns: 1fr; } }
.bars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); align-items: end; }
.bar-col { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); text-align: center; min-width: 0; }
.bar-month { font-size: 12.5px; color: var(--text-2); }
.bar-track { height: 132px; display: flex; align-items: flex-end; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.bar {
  width: 100%; height: var(--h); border-radius: 10px 10px 4px 4px;
  transition: height 400ms var(--ease);
}
.bar.up {
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0, 0, 0, 0.12) 6px 8px),
              linear-gradient(180deg, var(--profit), var(--profit-soft));
  box-shadow: inset 0 2px 0 var(--profit);
}
.bar.down { background: linear-gradient(180deg, var(--loss), var(--loss-soft)); box-shadow: inset 0 2px 0 var(--loss); }
.bar.flat { background: var(--border-strong); }
.bar-value { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-value:not(.pos):not(.neg) { color: var(--text-3); }

.donut-wrap { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex-shrink: 0; }
.donut circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.donut-track { stroke: var(--surface-2); }
.donut-seg.target { stroke: var(--profit); }
.donut-seg.stopped { stroke: var(--loss); }
.donut-seg.eod { stroke: var(--warning); }
.donut-cap { fill: var(--text-3); font-size: 10px; text-anchor: middle; font-family: var(--font); }
.donut-num { fill: var(--text); font-size: 22px; font-weight: 600; text-anchor: middle; font-family: var(--font); letter-spacing: -0.03em; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); flex: 1; min-width: 160px; font-size: 13.5px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 40px; align-items: center; gap: var(--space-2); }
.legend b { font-weight: 600; text-align: right; }
.legend .muted { text-align: right; font-size: 12.5px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.target { background: var(--profit); }
.swatch.stopped { background: var(--loss); }
.swatch.eod { background: var(--warning); }

/* Right column: head-to-head promo card */
.promo {
  position: relative; overflow: hidden;
  background:
    radial-gradient(140% 90% at 100% 0%, var(--profit-soft), transparent 55%),
    linear-gradient(160deg, var(--surface-2), var(--surface));
}
.promo-kicker { margin: 0 0 var(--space-2); font-size: 12.5px; color: var(--text-2); }
.promo-title { font-size: 24px !important; font-weight: 600 !important; letter-spacing: -0.035em !important; line-height: 1.15; margin: 0 0 var(--space-4) !important; }
.promo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-bottom: var(--space-4); }
.promo-stat {
  display: flex; flex-direction: column; gap: 4px; padding: var(--space-3);
  border-radius: 14px; background: var(--primary-soft); border: 1px solid var(--border);
  color: var(--text); transition: border-color 200ms var(--ease), transform 120ms var(--ease);
}
.promo-stat:hover { border-color: var(--border-strong); }
.promo-stat:active { transform: translateY(1px); }
.promo-name { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.promo-value { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.promo-meta { font-size: 12px; color: var(--text-3); }
.promo-note { margin: 0 0 var(--space-4); font-size: 13px; color: var(--text-2); }
.btn-light {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 22px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font-size: 14px; font-weight: 600; transition: background 200ms var(--ease), transform 120ms var(--ease);
}
.btn-light:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-light:active { transform: scale(0.98); }

/* Right column: recent trades list */
.recent { padding-bottom: var(--space-3); }
.trade-list { list-style: none; margin: 0 calc(-1 * var(--space-3)); padding: 0; }
.trade-list a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-3);
  padding: 10px var(--space-3); border-radius: 12px; color: var(--text);
  transition: background 150ms var(--ease);
}
.trade-list a:hover { background: var(--surface-2); }
.trade-list li + li a { border-top: 1px solid var(--border); border-radius: 0; }
.trade-list li + li a:hover { border-radius: 12px; border-top-color: transparent; }
.tl-sym { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: var(--space-2); }
.tl-pnl { text-align: right; font-size: 13.5px; font-weight: 500; }
.tl-pnl:not(.pos):not(.neg) { color: var(--text-3); }
.tl-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.tl-status { text-align: right; font-size: 12px; color: var(--text-3); }
.paper-flag { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: 0 var(--space-2); font-size: 12.5px; color: var(--text-3); }

/* Brand mark follows the theme: ink tile, canvas-coloured line, mint dot */
.mark-bg { fill: var(--text); }
.mark-line { stroke: var(--page); fill: none; }
.mark-dot { fill: var(--profit); }

/* Phones: keep the three KPIs as one compact row instead of three tall cards */
@media (max-width: 700px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .kpi { padding: var(--space-3); }
  .kpi-label { font-size: 12px !important; margin-bottom: var(--space-2) !important; }
  .kpi-value { font-size: 22px; }
  .kpi-sub { font-size: 11.5px; }
  .trend { display: none; }
  .big-value { font-size: 36px; }
  .bar-track { height: 104px; }
}

/* ======================================================================
   Trades & Backtests (same language as the dashboard)
   ====================================================================== */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--space-4); }
@media (max-width: 900px) { .kpis.kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Segmented control: links, buttons, or radio+label pairs */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
}
.segmented a, .segmented button, .segmented label { text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: none; border-radius: 999px; background: none; cursor: pointer;
  font: 500 13.5px var(--font); color: var(--text-2); white-space: nowrap;
  transition: background 200ms var(--ease), color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.segmented a:hover, .segmented button:hover:not(:disabled), .segmented label:hover { color: var(--text); }
.segmented a[aria-current="true"], .segmented button[aria-pressed="true"], .segmented input:checked + label {
  background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong);
}
.segmented button:disabled { opacity: 0.45; cursor: default; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:focus-visible + label { outline: 2px solid var(--ring); outline-offset: 2px; }
.segmented .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }

/* Table card */
.table-card { padding-bottom: var(--space-3); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.data-table td { padding-top: 13px; padding-bottom: 13px; }
.data-table tbody tr[hidden] { display: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.cell-stack > span, .cell-stack > a { display: block; }
.cell-stack .sym { display: flex; }
.cell-stack .sub { margin-top: 2px; font-size: 12px; color: var(--text-3); font-family: var(--font); }
td.num.cell-stack .sub { font-family: var(--font-mono); font-size: 11.5px; }
.cell-stack .sym { align-items: center; gap: var(--space-2); }
.cell-stack .sub .strat-tag { margin-right: 4px; }
.arrow { color: var(--text-3); padding: 0 2px; }
.pnl { font-weight: 600; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-chip.open { color: var(--text); }
.status-chip.open .dot { background: var(--text); box-shadow: 0 0 0 3px var(--primary-soft); }
.status-chip.target { color: var(--profit); background: var(--profit-soft); border-color: var(--profit-border); }
.status-chip.target .dot { background: var(--profit); }
.status-chip.stopped { color: var(--loss); background: var(--loss-soft); border-color: var(--loss-border); }
.status-chip.stopped .dot { background: var(--loss); }
.status-chip.eod .dot { background: var(--warning); }

/* Backtests: run card + latest comparison */
.bt-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: var(--space-4); align-items: stretch; }
@media (max-width: 1100px) { .bt-top { grid-template-columns: 1fr; } }
.run-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.seg-field { border: none; margin: 0; padding: 0; min-width: 0; }
.seg-field legend { padding: 0; margin-bottom: 6px; font-size: 12.5px; color: var(--text-2); }
.run-card .note { background: var(--surface-2); }
.latest { display: flex; flex-direction: column; gap: var(--space-3); }
.latest .card-head { margin-bottom: 0; }
.latest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.latest-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-3); }
.latest-stats b { color: var(--text-2); font-weight: 600; font-family: var(--font-mono); }
.modeling { margin-top: auto; border-top: 1px solid var(--border); padding-top: var(--space-3); }
.modeling summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 6px; min-height: 32px; }
.modeling summary::before { content: "+"; font-family: var(--font-mono); color: var(--text-3); width: 12px; }
.modeling[open] summary::before { content: "−"; }
.modeling summary::-webkit-details-marker { display: none; }
.modeling .spec-list { margin-top: var(--space-2); font-size: 13px; }

/* Backtests: past runs table */
.strat-name { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pf-badge {
  display: inline-block; min-width: 48px; padding: 2px 8px; border-radius: 999px; text-align: center;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
}
.pf-badge.good { color: var(--profit); background: var(--profit-soft); border-color: var(--profit-border); }
.pf-badge.bad { color: var(--loss); background: var(--loss-soft); border-color: var(--loss-border); }
.data-table tr.pair-first td { border-bottom-color: transparent; }
.data-table tr.pair-first td:first-child, .data-table tr.pair-second td:first-child { box-shadow: inset 2px 0 0 var(--border-strong); }
.data-table tr.pair-second td { padding-top: 6px; }
.data-table tr.pair-second .compare-link { font-size: 12.5px; }

/* Phones: segmented controls scroll sideways; data tables become stacked cards */
@media (max-width: 700px) {
  .toolbar { gap: var(--space-2); }
  .toolbar .segmented { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .toolbar .segmented::-webkit-scrollbar { display: none; }

  #trades-table thead, #runs-table thead { display: none; }
  #trades-table, #runs-table, #trades-table tbody, #runs-table tbody { display: block; }
  #trades-table tr, #runs-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--space-3);
    padding: 14px var(--space-1); border-bottom: 1px solid var(--border);
  }
  #trades-table tr[hidden] { display: none; }
  #trades-table td, #runs-table td { padding: 0; border: none; text-align: left; white-space: normal; }

  /* trades: symbol | P&L, prices | status, date */
  #trades-table td:nth-child(2) { grid-area: 1 / 1; }
  #trades-table td:nth-child(5) { grid-area: 1 / 2; text-align: right; }
  #trades-table td:nth-child(3) { grid-area: 2 / 1; text-align: left; }
  #trades-table td:nth-child(4) { grid-area: 2 / 2; text-align: right; }
  #trades-table td:nth-child(1) { grid-area: 3 / 1 / 4 / 3; display: flex; gap: 6px; font-size: 12px; color: var(--text-3); }
  #trades-table td:nth-child(1) .sub { margin: 0; }
  #trades-table td:nth-child(1) > span { display: inline; }

  /* runs: date/link | net, strategy | PF, period; trades/win/DD hidden */
  #runs-table td:nth-child(1) { grid-area: 1 / 1; }
  #runs-table td:nth-child(8) { grid-area: 1 / 2; text-align: right; }
  #runs-table td:nth-child(2) { grid-area: 2 / 1; }
  #runs-table td:nth-child(6) { grid-area: 2 / 2; text-align: right; }
  #runs-table td:nth-child(3) { grid-area: 3 / 1 / 4 / 3; font-size: 12.5px; }
  #runs-table td:nth-child(4), #runs-table td:nth-child(5), #runs-table td:nth-child(7) { display: none; }
  #runs-table tr.pair-first { border-bottom-color: transparent; padding-bottom: 4px; }
  #runs-table tr.pair-first td:first-child, #runs-table tr.pair-second td:first-child { box-shadow: none; }
}

/* ======================================================================
   Detail pages (trade, backtest, comparison) + Strategy page
   ====================================================================== */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: var(--space-4); align-items: start; }
.detail-main, .detail-side { display: grid; gap: var(--space-4); min-width: 0; }
@media (max-width: 1180px) { .detail-grid { grid-template-columns: 1fr; } }
.hero-sym { display: flex; align-items: center; gap: var(--space-2); font-size: 22px !important; letter-spacing: -0.03em !important; }
.explainer { margin: var(--space-4) 0 0; font-size: 13px; color: var(--text-2); }
.empty.compact { padding: var(--space-5) var(--space-3); }
.modeling.raw { border-top: none; padding-top: 0; }
.modeling.raw .raw-json { margin-top: var(--space-3); max-height: 360px; overflow: auto; }

/* Price ladder: stop / entry / target above the track, exit below */
.ladder { padding: 46px 44px 46px; margin: var(--space-2) 0 0; }
.ladder-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); }
.zone { position: absolute; top: 0; bottom: 0; left: var(--l); width: var(--w); }
.zone.loss { background: var(--loss-soft); box-shadow: inset 0 0 0 1px var(--loss-border); border-radius: 999px 0 0 999px; }
.zone.profit { background: var(--profit-soft); box-shadow: inset 0 0 0 1px var(--profit-border); border-radius: 0 999px 999px 0; }
.mark {
  position: absolute; left: var(--l); bottom: calc(100% + 10px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; line-height: 1.3;
  font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; color: var(--text);
}
.mark b { font: 500 11.5px var(--font); color: var(--text-3); }
.mark::after {
  content: ""; position: absolute; top: 100%; left: 50%; width: 2px; height: 22px; margin-left: -1px;
  background: currentColor; border-radius: 2px;
}
.mark.sl::after { background: var(--loss); }
.mark.target::after { background: var(--profit); }
.mark.entry::after { background: var(--text); }
.mark.exit { bottom: auto; top: calc(100% + 10px); flex-direction: column-reverse; }
.mark.exit::after { top: auto; bottom: 100%; background: var(--text-2); }
.mark.exit.pos::after { background: var(--profit); }
.mark.exit.neg::after { background: var(--loss); }
@media (max-width: 700px) { .ladder { padding-inline: 34px; } .mark { font-size: 11px; } }

/* Horizontal flow bars (P&L breakdown, long vs short) */
.flow { display: grid; gap: var(--space-3); }
.flow-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); font-size: 13.5px; }
.flow-row > span { color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.flow-row b { font-family: var(--font-mono); font-size: 13px; font-weight: 600; text-align: right; min-width: 84px; }
.flow-row.total { padding-top: var(--space-3); border-top: 1px solid var(--border); }
.flow-row.total > span { color: var(--text); font-weight: 600; }
.flow-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.flow-bar i { display: block; height: 100%; width: var(--w); border-radius: 999px; }
.flow-bar i.up { background: var(--profit); }
.flow-bar i.down { background: var(--loss); }
.flow-bar i.cost { background: var(--warning); }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: var(--space-4) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.mini-stats dt { font-size: 12.5px; color: var(--text-3); }
.mini-stats dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.pf-badge.big { font-size: 14px; padding: 6px 14px; min-width: 0; }

/* Comparison */
.compare-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 700px) { .compare-cards { grid-template-columns: 1fr; } }
.compare-card { padding: var(--space-4) var(--space-5); gap: var(--space-2); }
.compare-card .big-value { font-size: 36px; margin: 0; }
.compare-table td.winner { color: var(--text); font-weight: 600; }
.win-dot { display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--profit); vertical-align: middle; }
.compare-table thead th.num { text-align: right; }

/* Strategy page */
.strategy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 1000px) { .strategy-grid { grid-template-columns: 1fr; } }
.strat-card .promo-kicker { display: flex; align-items: center; gap: 6px; }
.steps { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); counter-reset: none; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); align-items: start; }
.step-n {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
}
.steps b { display: block; font-size: 14.5px; font-weight: 600; margin-top: 3px; }
.steps p { margin: 2px 0 0; font-size: 13.5px; color: var(--text-2); }
.strat-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.rule-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.rule { padding: var(--space-4); border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.rule span { font-size: 12.5px; color: var(--text-2); }
.rule b { display: block; margin: 4px 0 2px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.rule p { margin: 0; font-size: 12.5px; color: var(--text-3); }
.reality { background: radial-gradient(120% 120% at 100% 0%, var(--loss-soft), transparent 60%), var(--surface); }
.reality-figure { margin: 0; font-size: 48px; font-weight: 600; letter-spacing: -0.05em; line-height: 1; color: var(--loss); }
.reality .explainer { margin-top: var(--space-3); }
.rule-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .rule-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card > .modeling:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.card-head .meta .win-dot { margin: 0 4px 0 0; }

/* Kite connect / result */
.kite-card { max-width: 640px; }
.kite-card .steps { margin-top: var(--space-2); }
.kite-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; margin-bottom: var(--space-4); color: var(--page); }
.kite-icon.ok { background: var(--profit); }
.kite-icon.bad { background: var(--loss); }
a.badge.warn { text-decoration: none; }

/* Trade chart (TradingView Lightweight Charts) */
.chart-card .card-head { margin-bottom: var(--space-3); }
.tv-chart { position: relative; height: 420px; margin: 0 calc(-1 * var(--space-2)); }
.tv-wrap { position: absolute; inset: 0; }
.tv-legend {
  position: absolute; top: 6px; left: 10px; z-index: 3; pointer-events: none;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline;
}
.tv-legend b { font-family: var(--font); color: var(--text); font-size: 13px; }
.tv-legend .k { color: var(--text-3); margin-left: 4px; }
.tv-chart .empty { padding-top: 160px; }
.chart-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.key-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.key-swatch.profit { background: var(--profit-soft); box-shadow: inset 0 0 0 1px var(--profit); }
.key-swatch.loss { background: var(--loss-soft); box-shadow: inset 0 0 0 1px var(--loss); margin-left: 8px; }
@media (max-width: 700px) { .tv-chart { height: 340px; } .tv-chart .empty { padding-top: 120px; } }
