:root {
  color-scheme: dark;
  --bg: #111317;
  --rail: #15181d;
  --surface: #1a1e24;
  --surface-hi: #20252d;
  --border: #303641;
  --faint-border: #262c35;
  --text: #f5f5f2;
  --muted: #b1b9c6;
  --dim: #99a5b5;
  --gold: #f5c364;
  --gold-bg: #342b1e;
  --green: #7fdfb5;
  --red: #ff9a9c;
  --blue: #a9caff;
  --radius: 15px;
  --font: Geist, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  font-family: var(--font);
  font-size: 16px;
  font-synthesis: none;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
.skip-link { position: fixed; top: .8rem; left: .8rem; z-index: 9; transform: translateY(-250%); padding: .8rem 1rem; background: var(--bg); }
.skip-link:focus { transform: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.7rem); line-height: 1.1; letter-spacing: -.056em; }
h2 { font-size: 1rem; font-weight: 680; letter-spacing: -.021em; }
h3 { font-size: .96rem; letter-spacing: -.015em; }
.muted { color: var(--muted); }
.mono, .numbers { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.subtle { font-size: .82rem; color: var(--muted); line-height: 1.55; }
.product-icon { position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; background: var(--gold); color: #20190c; }
.product-icon span { width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid currentColor; }
.product-icon::after { content: ''; position: absolute; width: 4px; height: 4px; background: currentColor; transform: rotate(45deg); }
.access { display: grid; place-content: center; min-height: 100vh; min-height: 100svh; padding: max(2rem, env(safe-area-inset-top)) 1.35rem 2rem; background: radial-gradient(ellipse at 52% 8%, #24251f 0%, #15181d 42%, var(--bg) 72%); }
.login-card { width: min(420px, calc(100vw - 2.7rem)); padding: clamp(1.35rem, 5.5vw, 2.25rem); border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 34px 85px #07080b6b; }
.login-card .product { display: flex; align-items: center; gap: .65rem; font-size: .83rem; font-weight: 650; color: var(--gold); margin-bottom: 1.75rem; }
.login-card h1 { font-size: clamp(1.95rem, 7vw, 2.4rem); margin-bottom: .45rem; }
.login-card .muted { font-size: .92rem; }
.login-card .callout { margin-top: 1.35rem; }
.login-card form { display: grid; gap: .6rem; margin-top: 1.5rem; }
.login-card form input { margin-bottom: .38rem; }
.login-card form button { margin-top: .6rem; min-height: 46px; }
label { color: var(--muted); font-size: .82rem; font-weight: 650; }
input, select { width: 100%; color: var(--text); background: #15181e; padding: .58rem .72rem; min-height: 44px; border: 1px solid var(--border); border-radius: 8px; }
input:disabled, select:disabled { color: var(--dim); }
.button { display: inline-flex; justify-content: center; align-items: center; gap: .35rem; min-height: 42px; border: 1px solid var(--border); padding: .5rem .8rem; border-radius: 8px; font-size: .82rem; font-weight: 645; color: var(--text); background: var(--surface-hi); white-space: nowrap; }
.button:not(:disabled):hover { background: #2a303a; border-color: #566072; }
.button.primary { background: var(--gold); color: #20180a; border-color: var(--gold); }
.button.primary:not(:disabled):hover { background: #ffd487; border-color: #ffd487; }
.button.quiet { background: transparent; color: var(--muted); }
.button.danger { color: var(--red); background: #2e2127; border-color: #5b373e; }
.button:disabled { opacity: .72; }

.control-dialog { width: min(32rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); max-height: calc(100svh - 2rem); overflow: auto; padding: 1.35rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.control-dialog::backdrop { background: #090b10b8; }
.control-dialog h2 { margin: 0; font-size: 1.15rem; }
.control-dialog form { display: grid; gap: .85rem; }
.control-dialog p { margin: 0; }
.control-dialog label { display: block; margin-bottom: .35rem; font-size: .86rem; }
.control-dialog input { width: 100%; }
.control-dialog .actions { justify-content: flex-end; }
.control-preview { display: grid; gap: .7rem; min-width: 0; }
.control-preview[hidden] { display: none; }
#position-control-status:not(:empty) { margin-bottom: .75rem; }
#settings-control-status:empty { display: none; }
#settings-controls { min-width: 0; display: grid; gap: 17px; }
#strategy-control-status:empty { display: none; }
#strategy-settings { min-width: 0; display: grid; gap: 17px; }
.strategy-list { color: var(--muted); font-size: .84rem; line-height: 1.55; margin: .5rem 0; padding-inline-start: 1.15rem; }
.monitor-state, .evidence-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.monitor-state { margin: -.2rem 0 .95rem; color: var(--muted); font-size: .8rem; }
.monitor-state:empty { display: none; }
.financial-evidence .subtle { overflow-wrap: anywhere; }
.financial-evidence .evidence-line + .subtle { margin-top: .4rem; }
.financial-evidence + .kv { margin-top: .6rem; }
.evidence-line time { color: var(--muted); font-size: .8rem; }
.configuration-form { margin-top: .85rem; }
.configuration-form .filter-row { max-width: 36rem; }
.configuration-form small:not(:empty) { display: block; margin-top: .35rem; }
.export-link { text-decoration: none; }
.export-form, .export-stack { display: grid; gap: .85rem; min-width: 0; }
.export-form { margin-top: .95rem; }
.export-stack { justify-items: start; }
.export-field { display: grid; gap: .35rem; width: min(100%,32rem); }
.export-check { display: inline-flex; align-items: center; min-height: 44px; gap: .42rem; }
.export-check input { accent-color: var(--gold); min-width: auto; min-height: auto; width: 1.1rem; height: 1.1rem; margin: 0; }
.export-timeframes, .export-cohort { min-width: 0; margin: 0; border: 1px solid var(--border); border-radius: 8px; }
.export-timeframes { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.export-cohort { display: grid; gap: .6rem; }
.export-timeframes legend, .export-cohort legend { padding: 0 .26rem; color: var(--muted); font-size: .82rem; font-weight: 650; }
#export-estimate { display: grid; gap: .65rem; min-width: 0; }
#export-job:empty, #export-estimate:empty { display: none; }
#export-job progress { width: min(100%,22rem); height: .7rem; accent-color: var(--gold); }
.configuration-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,18rem),1fr)); gap: 11px; }
.configuration-parameter { min-width: 0; padding: .85rem; background: #181c22; border: 1px solid var(--faint-border); border-radius: 8px; }
.configuration-parameter .subtle { margin-top: .5rem; }
.trade-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .6rem; }
.trade-row > .button { min-height: 47px; }
.shell { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 100vh; min-height: 100svh; }
.rail { height: 100vh; height: 100svh; position: sticky; top: 0; display: flex; flex-direction: column; min-width: 0; padding: 26px 14px 22px; background: var(--rail); border-right: 1px solid var(--faint-border); }
.brand { display: flex; align-items: center; gap: .66rem; padding: 0 7px; margin-bottom: 38px; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: .88rem; letter-spacing: -.03em; }
.brand small { font-size: .72rem; color: var(--muted); margin-top: .18rem; }
.navigation { display: flex; flex-direction: column; gap: 3px; }
.navigation button { display: flex; align-items: center; text-align: left; gap: .68rem; padding: .54rem .67rem; min-height: 43px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: transparent; font-weight: 610; font-size: .88rem; white-space: nowrap; }
.navigation button span { width: 17px; text-align: center; font-size: 1.12rem; }
.navigation button:hover { background: var(--surface); color: var(--text); }
.navigation button[aria-current='page'] { background: #302a21; color: var(--gold); border-color: #453823; }
.rail-info { display: flex; align-items: center; gap: .55rem; padding: .8rem .55rem 0; margin-top: auto; border-top: 1px solid var(--faint-border); color: var(--muted); font-size: .75rem; }
.dot { background: #8491a2; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.work { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .65rem; min-height: 69px; padding: 10px clamp(18px, 3.1vw, 42px); border-bottom: 1px solid var(--faint-border); background: var(--rail); }
.mobile-brand { display: none; }
.head-right, .environment { display: flex; align-items: center; gap: .7rem; }
.environment { gap: 4px; padding: 4px; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; }
.environment button { min-width: 57px; min-height: 32px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font: 650 .72rem var(--mono); letter-spacing: .02em; }
.environment button[aria-pressed='true'] { color: var(--gold); background: var(--gold-bg); }
.environment button[data-env='REAL'][aria-pressed='true'] { color: var(--red); background: #342228; }
.freshness { color: var(--muted); line-height: 1.35; font: .75rem var(--mono); }
.workspace { max-width: 1540px; margin: 0 auto; padding: 30px clamp(18px, 3.1vw, 42px) max(40px, env(safe-area-inset-bottom)); }
.heading { display: flex; align-items: end; justify-content: space-between; gap: .9rem; margin-bottom: 23px; }
.view-context { margin-top: .5rem; font-size: .86rem; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.view-content { display: grid; gap: 17px; }
.callout { padding: .7rem .83rem; border: 1px solid #4a4232; border-radius: 8px; background: #2c261e; color: #f0d39b; font-size: .84rem; line-height: 1.55; overflow-wrap: anywhere; }
#data-status { margin: 0 0 18px; }
.callout.failure { background: #33252a; border-color: #68444a; color: #ffb9b7; }
.panel, .metric { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel { padding: 16px 17px; }
.panel.headline { padding: 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); background: linear-gradient(115deg,#25251f 0%,#1c2025 58%,var(--surface) 95%); }
.hero-primary { padding: 21px 23px; border-right: 1px solid var(--border); }
.hero-secondary { display: grid; gap: 15px; align-items: start; padding: 18px 20px; }
.metric-kicker { display: block; color: var(--muted); font-size: .82rem; font-weight: 610; }
.hero-value { display: block; margin: .65rem 0 .43rem; font-weight: 650; font-size: clamp(1.9rem, 4vw, 3.15rem); letter-spacing: -.075em; line-height: 1.05; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-foot { display: flex; align-items: center; flex-wrap: wrap; gap: .48rem; margin-top: 1rem; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 11px; }
.metric { padding: .87rem .92rem; }
.metric-value { display: block; margin-top: .38rem; font-size: clamp(1.05rem, 2vw, 1.31rem); font-weight: 660; line-height: 1.15; word-break: break-word; }
.metric-caption { display: block; margin-top: .42rem; font-size: .76rem; color: var(--muted); }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.section-title > * { min-width: 0; }
.section-title h2 { font-size: 1.05rem; }
.panel .subtle + .kv, .panel .subtle + .table-frame, .panel .callout + .table-frame { margin-top: .9rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .26rem .48rem; font-size: .74rem; font-weight: 680; color: var(--muted); background: #2a3039; border: 1px solid #454e5b; border-radius: 6px; vertical-align: middle; min-width: 0; line-height: 1.2; overflow-wrap: anywhere; }
.pill.ok { color: var(--green); border-color: #3f6858; background: #20332e; }
.pill.warn { color: var(--gold); border-color: #695630; background: var(--gold-bg); }
.pill.bad { color: var(--red); border-color: #70434b; background: #35242b; }
.pill.info { color: var(--blue); border-color: #425b81; background: #242e41; }
.kv { margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: baseline; gap: .55rem; padding: .52rem 0; border-bottom: 1px solid var(--faint-border); }
.kv-row:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: .81rem; line-height: 1.4; }
.kv dd { margin: 0; text-align: right; font-size: .83rem; line-height: 1.4; font-weight: 640; overflow-wrap: anywhere; }
.actions, .filter-row, .periods { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; }
.actions + .subtle, .filter-row + .table-frame, .periods + .filter-row { margin-top: .75rem; }
.filter-row label { display: flex; flex-direction: column; gap: .26rem; min-width: min(160px, 100%); flex: 1; }
.periods .button { font-size: .78rem; }
.periods .button[aria-pressed='true'] { color: var(--gold); border-color: #705932; background: var(--gold-bg); }
.table-frame { overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
.table-frame:focus-visible { outline-offset: -3px; }
table { min-width: 100%; border-collapse: collapse; white-space: nowrap; font-size: .82rem; }
th, td { text-align: left; padding: .64rem .63rem; border-bottom: 1px solid var(--faint-border); }
th:first-child, td:first-child { padding-left: .22rem; }
th { color: var(--muted); font-size: .72rem; font-weight: 630; }
td.wrapping { white-space: normal; min-width: 14rem; overflow-wrap: anywhere; }
td.time { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.trade-list { display: grid; gap: .65rem; }
.trade { border: 1px solid var(--border); border-radius: 10px; background: #181c22; }
.trade summary { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: .6rem; align-items: center; padding: .77rem .86rem; min-height: 47px; cursor: pointer; list-style: none; }
.trade summary::-webkit-details-marker { display: none; }
.trade summary::after { content: '›'; color: var(--muted); font-size: 1.15rem; }
.trade[open] summary { border-bottom: 1px solid var(--border); }
.trade[open] summary::after { transform: rotate(90deg); }
.trade-symbol { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; overflow-wrap: anywhere; }
.trade-mark { text-align: right; }
.trade-mark small { display: block; }
.trade-content { padding: .9rem; }
.position-evidence { display: grid; gap: .4rem; margin-bottom: .8rem; }
.position-evidence + .trade-list { margin-top: .6rem; }
.historical-trade { border-color: #695630; padding: .76rem .86rem; }
.historical-trade .trade-symbol { margin-bottom: .38rem; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: baseline; column-gap: .75rem; row-gap: .12rem; padding: .52rem 0; border-bottom: 1px solid var(--faint-border); font-size: .84rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline li span { overflow-wrap: anywhere; }
.chart { width: 100%; height: 205px; display: block; margin-top: .65rem; }
.chart-key { display: flex; flex-wrap: wrap; gap: .8rem; color: var(--muted); font-size: .74rem; margin-top: .4rem; }
.chart-key span::before { content: ''; display: inline-block; margin-right: .4rem; width: .6rem; height: .6rem; border-radius: 2px; background: var(--gold); }
.chart-key span.net::before { background: var(--green); }
.spaced { padding-top: .7rem; }
.compact { margin-top: .48rem; }

@media (max-width: 1040px) {
  .shell { grid-template-columns: 177px minmax(0,1fr); }
  .rail { padding-inline: 9px; }
  .brand { padding-inline: 4px; gap: .45rem; }
  .brand strong { font-size: .81rem; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 740px) {
  .shell { grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto 1fr; }
  .work { display: contents; }
  .rail { grid-row: 2; height: auto; position: static; padding: 6px 11px; border: 0; border-bottom: 1px solid var(--faint-border); }
  .rail .brand, .rail-info { display: none; }
  .navigation { flex-direction: row; overflow-x: auto; scrollbar-width: thin; gap: 3px; padding: 3px 2px; }
  .navigation button { justify-content: center; gap: .36rem; padding-inline: .57rem; min-height: 43px; font-size: .79rem; }
  .navigation button span { font-size: .95rem; width: 15px; }
  .topbar { grid-row: 1; min-height: 60px; padding: max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left)); }
  .mobile-brand { display: inline-flex; align-items: center; gap: .42rem; font-size: .81rem; }
  .workspace { grid-row: 3; padding: 23px clamp(12px, 3.3vw, 22px) max(30px,env(safe-area-inset-bottom)); }
  .freshness { display: none; }
  .heading { margin-bottom: 17px; }
  .view-content { gap: 13px; }
  .topbar .button { min-height: 40px; padding-inline: .58rem; }
}
@media (max-width: 510px) {
  .split, .panel.headline { grid-template-columns: minmax(0,1fr); }
  .hero-primary { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px; }
  .hero-secondary { padding: 13px 16px; }
  .mobile-brand strong { display: none; }
  .environment button { min-height: 34px; }
  .panel { padding: 13px; }
  .metrics { gap: 7px; }
  .metric { padding: .64rem .59rem; border-radius: 10px; }
  .metric-kicker, .subtle { font-size: .79rem; }
  .actions .button { padding-inline: .5rem; min-height: 44px; font-size: .74rem; }
  .chart { height: 180px; }
  .filter-row label { min-width: min(127px,100%); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
