/* Tradelab design system. One file, cached by the browser. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #131722;
  --text-2: #434651;
  --muted: #787b86;
  --line: #e0e3eb;
  --line-2: #eef0f4;
  --accent: #2962ff;
  --accent-2: #1e53e5;
  --accent-soft: #eaf0ff;
  --up: #089981;
  --up-soft: #e3f5f1;
  --down: #f23645;
  --down-soft: #fde8ea;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(19, 23, 34, .04), 0 1px 1px rgba(19, 23, 34, .03);
  --sidebar: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #161a22;
    --surface-2: #1b2029;
    --text: #e6e8ee;
    --text-2: #b2b5be;
    --muted: #868993;
    --line: #2a2e39;
    --line-2: #222631;
    --accent: #4c7dff;
    --accent-2: #6a92ff;
    --accent-soft: #1b2440;
    --up: #22ab94;
    --up-soft: #12302b;
    --down: #f7525f;
    --down-soft: #3a1a1e;
    --warn: #f0a33c;
    --warn-soft: #33270f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.12rem; margin: 0 0 4px; font-weight: 650; }
h3 { font-size: .98rem; margin: 18px 0 8px; font-weight: 650; }
p { margin: 0 0 10px; }
code { font: 12.5px var(--mono); background: var(--surface-2); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .r { text-align: right; }
.up { color: var(--up); font-weight: 600; } .down { color: var(--down); font-weight: 600; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 9px; padding: 6px 10px 16px; color: var(--text); font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.nav-group { margin-bottom: 14px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 2px; }
.who { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.scrim { display: none; }
.shell > div { min-width: 0; }
.main { min-width: 0; padding: 22px 28px 60px; max-width: 1280px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .topbar .brand { padding: 0; }
  .main { padding: 16px 14px 60px; }
}

/* ------------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); overflow-x: auto; }
.card + .card { margin-top: 14px; }
:where(.builder, .grid-2, .form-grid, .kpis, .strats) > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: -2px 0 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.section { margin-top: 26px; scroll-margin-top: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 1.45rem; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th[title] { cursor: help; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; vertical-align: middle; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tr.bench td { color: var(--muted); }
td .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.side { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 5px; }
.side.long { color: var(--up); background: var(--up-soft); } .side.short { color: var(--down); background: var(--down-soft); }

/* ------------------------------------------------------------------ badges, alerts */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.live { color: var(--up); background: var(--up-soft); border-color: transparent; }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.verdict { background: var(--accent-soft); border: 1px solid transparent; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; color: var(--text); }
.verdict p:last-child { margin-bottom: 0; }
.error-box { background: var(--down-soft); color: var(--text); border-left: 3px solid var(--down); border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.note { background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.status { font-weight: 600; } .status.done { color: var(--up); } .status.error { color: var(--down); } .status.running, .status.queued { color: var(--accent); }

/* ------------------------------------------------------------------ buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: 600 13.5px var(--font); background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 8px 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.danger { background: var(--surface); color: var(--down); border-color: var(--line); }
.btn.danger:hover { background: var(--down-soft); border-color: var(--down); }
.btn .icon { width: 16px; height: 16px; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
textarea { width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px 22px; }
.field label.title, label.title { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.hint, .field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 11px; cursor: pointer; font-size: 13px; background: var(--surface); user-select: none; }
.chips label:hover { border-color: var(--muted); }
.chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips label:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.presets button { font: 12px var(--font); border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.presets button:hover { border-color: var(--accent); color: var(--accent); }
.saved-note { font-size: 12.5px; color: var(--muted); }
.subtabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; margin: 0 0 16px; }
.subtabs a { padding: 6px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.stack-list { display: grid; gap: 8px; }
.switch-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; background: var(--surface); }
.switch-row.on { border-color: var(--accent); background: var(--accent-soft); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; margin-top: 1px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch-title { font-weight: 600; cursor: pointer; display: block; }
.switch-setting { margin-top: 8px; }
.switch-row:not(.on) .switch-setting { display: none; }

/* ------------------------------------------------------------------ charts */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }
.chart-box.short { height: 220px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chart-legend button { display: inline-flex; align-items: center; gap: 6px; font: 12px var(--font); color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; cursor: pointer; }
.chart-legend button i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chart-legend button.off { opacity: .4; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 160px; }
.chart-tip .t { color: var(--muted); margin-bottom: 4px; }
.chart-tip .rowv { display: flex; justify-content: space-between; gap: 14px; }
.chart-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ misc components */
.setup { scroll-margin-top: 16px; }
.setup + .setup { margin-top: 16px; }
.setup-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.setup-head h2 { margin: 0; }
.setup-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.tickers { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ticker { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 5px 10px; font-size: 12.5px; background: var(--surface-2); }
.ticker b { font-weight: 600; margin-right: 6px; }
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty h3 { color: var(--text); margin-top: 0; }
.strats { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.strats .card p { margin: 6px 0 0; }
.guide summary, details > summary { cursor: pointer; }
dl.guide-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 10px 0 0; }
dl.guide-list dt { font-weight: 600; } dl.guide-list dd { margin: 0; color: var(--text-2); }
@media (max-width: 600px) { dl.guide-list { grid-template-columns: 1fr; } dl.guide-list dd { margin-bottom: 6px; } }
.progress { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .bar { width: 70px; height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar-cell .bar span { position: absolute; top: 0; bottom: 0; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; padding-bottom: 18px; font-size: 17px; }
.auth-form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.auth-form input { width: 100%; margin-top: 5px; padding: 9px 11px; }
.auth-form .btn { width: 100%; padding: 10px; margin-top: 4px; }

@media (max-width: 640px) { .opt { display: none; } .kpi .value { font-size: 1.2rem; } }
.ai-card { margin-bottom: 16px; }
.ai-card summary { cursor: pointer; font-size: 15px; }
.ai-steps { margin: 8px 0 0; padding-left: 0; list-style: none; }
.ai-steps > li { padding: 12px 0; border-top: 1px solid var(--line-2); }
.ai-steps > li:first-child { border-top: 0; }
.code-form { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: flex-end; }
.code-form label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; gap: 3px; }
.code-form .hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.site-foot { margin-top: 32px; padding: 16px 0; border-top: 1px solid var(--line-2); text-align: center; }
.site-foot a, .auth-card a:not(.brand) { color: inherit; text-decoration: underline; }
.agree { display: flex; gap: 8px; align-items: flex-start; font-weight: 400 !important; font-size: 12px; line-height: 1.5; }
.agree input { width: auto !important; margin: 2px 0 0 !important; flex: 0 0 auto; }
.legal { max-width: 760px; line-height: 1.6; }
.legal h2 { margin: 26px 0 8px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.legal h2:first-of-type { border-top: 0; padding-top: 0; }
.legal h3 { margin: 16px 0 4px; font-size: 15px; }
.legal ul { padding-left: 20px; } .legal li { margin: 4px 0; }
.danger-zone { border-color: var(--down); }
.danger-zone h3 { color: var(--down); }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.danger:hover { filter: brightness(0.93); }
/* admin health panel */
.signal { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; border-left: 4px solid var(--muted); background: var(--line-2); }
.signal.ok { border-color: var(--up); background: var(--up-soft, rgba(38,166,154,.1)); }
.signal.watch { border-color: var(--warn); background: var(--warn-soft); }
.signal.move { border-color: var(--down); background: var(--down-soft, rgba(242,54,69,.1)); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat .v { font-size: 1.4rem; font-weight: 700; }
.stat .sub { font-size: 11px; color: var(--muted); }
.spark-wrap { margin-top: 14px; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 56px; }
.spark span { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .75; }
.spark span:hover { opacity: 1; }
/* public landing page */
body.landing { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.land-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.land-head nav { display: flex; align-items: center; gap: 14px; }
.land-head nav a { color: var(--muted); text-decoration: none; }
.hero { text-align: center; padding: 48px 0 32px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); line-height: 1.1; margin: 0 0 16px; }
.hero .lead { font-size: 1.12rem; color: var(--text); max-width: 640px; margin: 0 auto 24px; line-height: 1.6; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.btn.big { padding: 13px 26px; font-size: 1.05rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; padding: 24px 0; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.feature h3 { margin: 0 0 8px; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.band { text-align: center; background: var(--line-2); border-radius: var(--radius); padding: 32px 20px; margin: 24px 0; }
.band h2 { margin: 0 0 10px; }
.band p { max-width: 620px; margin: 0 auto 18px; color: var(--muted); line-height: 1.6; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; padding: 8px 0; align-items: stretch; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; text-align: left; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan .tag { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.plan h3 { margin: 4px 0 2px; font-size: 1.3rem; }
.plan .price { font-size: 1.5rem; font-weight: 700; margin: 4px 0 2px; }
.plan .blurb { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; line-height: 1.5; }
.plan ul { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 9px; }
.plan li { font-size: 13.5px; padding-left: 23px; position: relative; line-height: 1.4; }
.plan li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.plan .btn.big { width: 100%; margin-top: auto; }
.plan .upgrade-note { font-size: 12px; margin: 8px 0 0; }
