:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: rgba(20, 30, 45, 0.12);
  --text: #121821;
  --text-2: #4a5462;
  --muted: #6b7482;
  --accent: #3afba5;
  --accent-ink: #0b8a55;
  --entry: #1f7fb2;
  --up: #1b9e5f;
  --down: #d64f44;
  --up-text: #11794a;
  --down-text: #b73a30;
  --up-soft: rgba(27, 158, 95, 0.12);
  --down-soft: rgba(214, 79, 68, 0.12);
  --amber: #996a10;
  --chart-grid: rgba(20, 30, 45, 0.07);
  --chart-text: #5c6675;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f13;
    --surface: #12161c;
    --surface-2: #181d25;
    --border: rgba(255, 255, 255, 0.09);
    --text: #e8ecf1;
    --text-2: #b3bcc8;
    --muted: #8a95a5;
    --accent: #3afba5;
    --accent-ink: #3afba5;
    --entry: #3f9ac2;
    --up: #2aa76e;
    --down: #c94b3e;
    --up-text: #3cc184;
    --down-text: #ec6a5c;
    --up-soft: rgba(42, 167, 110, 0.15);
    --down-soft: rgba(201, 75, 62, 0.16);
    --amber: #c89a3e;
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-text: #97a3b4;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f13; --surface: #12161c; --surface-2: #181d25; --border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf1; --text-2: #b3bcc8; --muted: #8a95a5; --accent: #3afba5; --accent-ink: #3afba5; --entry: #3f9ac2;
  --up: #2aa76e; --down: #c94b3e; --up-text: #3cc184; --down-text: #ec6a5c;
  --up-soft: rgba(42, 167, 110, 0.15); --down-soft: rgba(201, 75, 62, 0.16); --amber: #c89a3e;
  --chart-grid: rgba(255, 255, 255, 0.06); --chart-text: #97a3b4; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 40px; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* hero */
.hero { margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 48px; width: auto; display: block; flex: none; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
.brand-text { border-left: 1px solid var(--border); padding-left: 14px; }
.byline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.subtitle { margin: 12px 0 10px; color: var(--text-2); font-size: 15px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.chip-muted { color: var(--muted); }
.method {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px 14px; color: var(--text-2); font-size: 13.5px; box-shadow: var(--shadow);
}
.method strong { color: var(--accent-ink); margin-right: 4px; }

/* sizing selector */
.view-bar { margin-bottom: 12px; min-width: 0; }
.seg-scroll { scroll-snap-type: x proximity; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 550; color: var(--text-2); background: none; border: 0;
  border-radius: 7px; padding: 7px 12px; cursor: pointer; white-space: nowrap; scroll-snap-align: start;
}
.seg button .tag { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; margin-left: 6px; opacity: 0.75; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.view-note { margin: 8px 0 0; color: var(--text-2); font-size: 12.5px; }
.view-basis { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pos { color: var(--up-text); }
.neg { color: var(--down-text); }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.readout { font-size: 13px; color: var(--text-2); text-align: right; min-height: 38px; font-variant-numeric: tabular-nums; }
.readout b { font-size: 17px; color: var(--text); }
.chart { width: 100%; position: relative; }
.chart-curve { height: 300px; }
.chart-trade { height: 420px; }
.chart-empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 3px; }
select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 28px 6px 10px; min-width: 120px;
}

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 550; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
th.num { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
table.trades tbody tr { cursor: pointer; }
table.trades tbody tr:hover, table.trades tbody tr:focus-visible { background: var(--surface-2); outline: none; }
tr.is-open td { background: color-mix(in srgb, var(--entry) 6%, transparent); }
.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-transform: inherit; letter-spacing: inherit; }
.sym { font-weight: 600; }
.side { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; }
.side-long { color: var(--up-text); background: var(--up-soft); }
.side-short { color: var(--down-text); background: var(--down-soft); }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: color-mix(in srgb, var(--entry) 16%, transparent); color: var(--entry); }
.reason { color: var(--text-2); }
.footnote { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }
.empty-row td { color: var(--muted); text-align: center; padding: 22px; }
details.fills { margin-top: 12px; }
details.fills summary { cursor: pointer; color: var(--text-2); font-size: 13px; padding: 6px 0; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 18, 0.55); }
.modal-panel {
  position: relative; width: 100%; max-width: 980px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); min-width: 0;
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.icon-btn {
  font-size: 24px; line-height: 1; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; flex: none;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.legend i.dash { border-top-style: dashed; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; }
.facts div { background: var(--surface-2); border-radius: 8px; padding: 9px 12px; min-width: 0; }
.facts dt { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.foot { color: var(--muted); font-size: 12.5px; margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.foot strong { color: var(--text-2); }
.foot-brand { margin-top: 8px; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .page { padding: 18px 16px 32px; }
  .logo { height: 40px; }
  h1 { font-size: 22px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 20px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .chart-curve { height: 240px; }
  .chart-trade { height: 320px; }
  .modal { padding: 0; }
  .modal-panel { border-radius: 0; min-height: 100%; padding: 14px; }
  .readout { text-align: left; }
  select { min-width: 0; }
}
