/* Layout: one centered column — header + takeaway, controls bar, tile row, then card grid. Scoreboard-style condensed display face over a plain sans. */
:root {
  --bg: #f3f6f6;
  --panel: #ffffff;
  --fg: #13202a;
  --muted: #5a6a75;
  --line: #dbe3e6;
  --accent: #0e6b5f;
  --amber: #a8690f;
  --bad: #c0392b;
  --ok: #2c8653;
  --grid: #e7edef;
  --chart-muted: #b9c5cb;
  --ref: #13202a;
  --s1: #0e6b5f; --s2: #3d7fc1; --s3: #c98a1b; --s4: #8a5bb3; --s5: #b0557f; --s6: #4f9a8e;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d151b; --panel: #142029; --fg: #e5edf1; --muted: #93a4b0; --line: #243540;
    --accent: #43c2ac; --amber: #e3a646; --bad: #ef6b56; --ok: #58c486; --grid: #1c2a33; --chart-muted: #3c4f5b; --ref: #e5edf1;
    --s1: #43c2ac; --s2: #6ea8e6; --s3: #e3a646; --s4: #b18ae0; --s5: #e08ab3; --s6: #7fc9bd;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d151b; --panel: #142029; --fg: #e5edf1; --muted: #93a4b0; --line: #243540;
  --accent: #43c2ac; --amber: #e3a646; --bad: #ef6b56; --ok: #58c486; --grid: #1c2a33; --chart-muted: #3c4f5b; --ref: #e5edf1;
  --s1: #43c2ac; --s2: #6ea8e6; --s3: #e3a646; --s4: #b18ae0; --s5: #e08ab3; --s6: #7fc9bd;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font-body); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
code { font-size: .92em; background: var(--grid); padding: 1px 5px; border-radius: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 22px; }
.wrap.narrow { max-width: 720px; }

.head { display: grid; gap: 6px; }
.eyebrow { margin: 0; font: 600 12px/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.eyebrow a { color: inherit; text-decoration: none; }
h1 { margin: 0; font: 600 40px/1 var(--font-display); letter-spacing: .01em; text-wrap: balance; }
h2 { margin: 0; font: 600 20px/1.1 var(--font-display); letter-spacing: .02em; }
.take { margin: 0; max-width: 68ch; font-size: 17px; }
.take b { font-weight: 600; }
.take b.bad { color: var(--bad); }
.sub, .note { margin: 0; color: var(--muted); font-size: 13px; max-width: 74ch; }
.note ol, ol.note { padding-left: 1.2em; display: grid; gap: 4px; }

.bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tabs button { font: 600 14px/1 var(--font-body); border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--panel); }
.pick { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
select, input { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; max-width: 100%; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; align-content: start; }
.tile h3 { margin: 0; font: 600 12px/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.big { font: 600 38px/1 var(--font-display); }
.big.bad { color: var(--bad); }
.tile p { margin: 0; font-size: 13px; color: var(--muted); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; align-content: start; }
.card.wide { grid-column: 1 / -1; }
.steps { gap: 12px; }

.chart { position: relative; min-height: 300px; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 12px var(--font-body); }
.chart text.strong { fill: var(--fg); font-weight: 600; }
.chart text.bad { fill: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed var(--ref); border-radius: 0; width: 14px; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 6px 9px; font-size: 13px; white-space: nowrap; z-index: 3; }
.tip .k { color: var(--muted); font-size: 12px; }

.slots { display: grid; gap: 9px; }
.slot { display: grid; grid-template-columns: minmax(8rem, 1fr) 2fr 3.5em; gap: 10px; align-items: center; font-size: 14px; }
.meter { display: flex; gap: 3px; height: 10px; }
.meter i { flex: 1; border-radius: 2px; background: var(--grid); }
.meter i.on { background: var(--chart-muted); }
.meter.full i.on { background: var(--bad); }
.count { text-align: right; color: var(--muted); }
.slot-head { margin: 6px 0 0; font: 600 12px/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.cut { display: grid; gap: 8px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.cut p { margin: 0; }
.cut b { font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }
.btn { font: 600 13px/1 var(--font-body); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field input { width: 100%; font-family: ui-monospace, Consolas, monospace; }

.tablebox { overflow: auto; max-height: 36rem; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th.l, td.l { text-align: left; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .03em; }
thead th:first-child { z-index: 2; }
th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; }
th[aria-sort] button { color: var(--fg); }
th[aria-sort="descending"] button::after { content: " ↓"; }
th[aria-sort="ascending"] button::after { content: " ↑"; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--bg); }
tr.is-cut td, tr.is-cut:hover td { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); }
tr.is-cut td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.is-cut td:first-child::before { content: "✕ "; color: var(--bad); font-weight: 600; }
tr.expiring td.ends { color: var(--amber); font-weight: 600; }
tr.mine td { font-weight: 600; }
td.zero { color: var(--chart-muted); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--grid); color: var(--muted); margin-left: 6px; }
@media (max-width: 680px) { .opt { display: none; } h1 { font-size: 34px; } .big { font-size: 32px; } }

.status { padding: 28px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.status h2 { margin-bottom: 6px; }
.foot { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) { .tile, .card { animation: rise .35s ease-out both; } @keyframes rise { from { opacity: .4; transform: translateY(4px); } } }
.chip { display: inline-block; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 6px; background: var(--grid); color: var(--fg); }
.chip.from { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
.chip-v { margin-left: 8px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
td.good { color: var(--ok); }
td.bad { color: var(--bad); }
th.val, td.val { border-left: 1px solid var(--line); }

/* Trade tab */
.tr-side input[type="search"] { width: 100%; }
.tr-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.tr-row { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 10px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px; }
.tr-row:last-child { border-bottom: 0; }
.tr-row:hover { background: var(--bg); }
.tr-row.on { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.tr-row input { margin: 0; accent-color: var(--accent); }
.tr-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tr-pos { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
.tr-num { text-align: right; color: var(--muted); min-width: 44px; }
.tr-pick { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.tr-pick.on { background: var(--accent); color: var(--panel); }
.tr-pick.on .chip-v { color: inherit; opacity: .85; }
.tr-cap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; }
.tr-cap input { width: 90px; }
.tr-verdict { display: grid; gap: 8px; }
.tr-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--grid); }
.tr-bar-a { background: var(--accent); }
.tr-bar-b { background: var(--s2); }
.tr-bar-a + .tr-bar-b { border-left: 2px solid var(--panel); }
.tr-bar-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.tr-warn { margin: 0; padding: 10px 14px 10px 30px; border: 1px solid var(--bad); border-radius: 6px; color: var(--bad); font-size: 13.5px; display: grid; gap: 4px; }
.tr-table td, .tr-table th { white-space: nowrap; }
.tr-table tbody tr { cursor: default; }
.tr-table tr.strong td { font-weight: 600; }
@media (max-width: 680px) { .tr-end { display: none; } .tr-row { grid-template-columns: auto 1fr auto auto; } }
#tr-result { min-width: 0; display: grid; gap: 12px; }
.tr-side > * { min-width: 0; }
@media (max-width: 680px) {
  .tr-table th, .tr-table td { white-space: normal; padding: 7px 6px; font-size: 12.5px; }
  .tr-table th:first-child, .tr-table td:first-child { position: static; }
}
.nw { white-space: nowrap; }
