/* bet.knuths.dev — sober "measurement lab" theme. Neutral slate, one restrained
   steel accent, tabular numerals. No green "go/money" cues. Light + dark. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5;
  --ink: #1a1f2b; --muted: #5b6472; --border: #e2e6ec;
  --accent: #3d5a80;            /* CLV running-mean line / links */
  --zero: #97a0ae;             /* zero reference line */
  --won: #2f6f61; --lost: #9a5c46; --warn: #8a6a2c;
  --clv-pos: #3d6b8a; --clv-neg: #9a6a4e;   /* CLV-tecken: kall neutral, INTE go/money-grönt (#154); fixar odefinierad var i heatmap/gauge */
  --radius: 12px; --maxw: 900px;
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a; --surface: #191d26; --surface-2: #20252f;
    --ink: #e6e9ef; --muted: #98a2b1; --border: #2a313d;
    --accent: #7aa0c4; --zero: #6b7480;
    --won: #5aa392; --lost: #c08a72; --warn: #c9a25e;
    --clv-pos: #7aa0c4; --clv-neg: #c08a72;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  line-height: 1.5; font-size: 16px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
h1, h2 { line-height: 1.2; text-wrap: balance; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }
.fine { color: var(--muted); font-size: 0.82rem; margin: 8px 2px 0; }
/* #161 — kreditvakt-notis (theme-aware; visas bara när budgeten degraderar) */
.credit-budget { margin: 8px 2px 0; padding: 6px 10px; border: 1px solid var(--warn); border-radius: 6px;
  color: var(--warn); font-size: 0.85rem; background: var(--surface-2); }
.credit-budget.orange { border-color: var(--lost); color: var(--lost); }
.credit-budget.red { border-color: var(--lost); color: var(--lost); font-weight: 600; }
/* #166 — historisk backfill: per-marknad-kort (CLV-siffran neutral, aldrig money-färgad) */
.bf-markets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.bf-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); }
.bf-card h3 { margin: 0 0 4px; font-size: 0.95rem; }
.bf-num { margin: 0 0 2px; font-size: 1.4rem; font-weight: 700; }
.bf-card .fine { margin: 2px 0 0; }
/* #167 — CLV-fördelning (staplar, neutral) + per-liga-tabell */
.bf-hist { display: flex; align-items: flex-end; gap: 1px; height: 56px; margin-top: 10px; }
.bf-bar { flex: 1 1 0; min-height: 1px; background: var(--clv-neg); opacity: 0.55; border-radius: 1px 1px 0 0; }
.bf-bar.zero { background: var(--accent); opacity: 0.9; }
.bf-histcap { margin-top: 3px; }
.bf-lg { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.8rem; }
.bf-lg th, .bf-lg td { padding: 2px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.bf-lg th { color: var(--muted); font-weight: 600; }
.bf-lg th:nth-child(n+2), .bf-lg td:nth-child(n+2) { text-align: right; }
/* #168 — kalibrerings-reliabilitetsdiagram (SVG, theme-aware) */
.cal-svg { width: 100%; max-width: 190px; height: auto; margin-top: 10px; display: block; }
.cal-box { fill: none; stroke: var(--border); }
.cal-diag { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; }
.cal-ci { stroke: var(--accent); stroke-width: 1.5; opacity: 0.35; }
.cal-pt { fill: var(--accent); }
/* #170 — modell mot marknad (log-loss-staplar) */
.mvm { margin-top: 16px; }
.mvm h3 { margin: 0 0 8px; font-size: 0.95rem; }
.mvm-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.85rem; }
.mvm-k { flex: 0 0 42%; }
.mvm-bar { flex: 1; height: 12px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.mvm-fill { display: block; height: 100%; }
.mvm-fill.accent { background: var(--accent); }
.mvm-fill.lost { background: var(--lost); }
.mvm-fill.muted { background: var(--muted); }
.mvm-v { flex: 0 0 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem;
  color: var(--muted); margin: 0 0 4px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* header + banner + footer */
.site { padding: 26px 0 6px; }
.wordmark { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.wordmark .tag { font-size: 0.62em; vertical-align: middle; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; margin-left: 6px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.banner { background: var(--surface-2); border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border); margin: 14px 0 24px; font-size: 0.9rem; }
.banner-row { display: flex; gap: 16px; align-items: flex-start; padding: 12px 20px; }
.banner p { margin: 0; }
.banner-toggle { display: none; background: none; border: 0; color: var(--accent); font: inherit;
  cursor: pointer; padding: 0 0 0 5px; text-decoration: underline; }   /* #148 — bara mobil */
@media (max-width: 640px) {
  .banner-toggle { display: inline; }
  .banner-more { display: none; }
  .banner.expanded .banner-more { display: inline; }
}
.ghost { background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 0.8rem; white-space: nowrap; }
.ghost:hover { color: var(--ink); }
.site-foot { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface);
  padding: 20px 0 40px; color: var(--muted); font-size: 0.85rem; }

/* sticky snabbnav (#146) — hoppa mellan CLV / Aktiva / Historik / Fördjupning */
.mininav { position: sticky; top: 0; z-index: 30; background: var(--surface);
  border-bottom: 1px solid var(--border); }
.mininav-row { display: flex; gap: 4px; overflow-x: auto; padding: 6px 20px; }
.mininav a { color: var(--muted); text-decoration: none; font-size: 0.85rem; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.mininav a:hover { color: var(--ink); }
.mininav a[aria-current="true"] { color: var(--ink); background: var(--surface-2); }
#clv, #marknader, #dagens, #historik, #deepdive { scroll-margin-top: 54px; }   /* #336 — marknadsjämförelsen nåbar via mininav */

/* hero */
.hero { text-align: center; margin: 8px 0 30px; }
.hero-num { font-family: var(--mono); font-size: clamp(2.6rem, 9vw, 4.2rem); font-weight: 600;
  margin: 0; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero-cap { margin: 2px 0 4px; color: var(--muted); font-size: 0.95rem; }
.hero-ctx { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.chart-card { margin: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.chart-card figcaption { text-align: left; font-size: 0.85rem; margin-bottom: 8px; }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
#clv-chart svg { touch-action: pan-y; }   /* #147 — vertikal scroll ok, horisontell drag → crosshair */
.permalink-actions { display: inline-flex; gap: 8px; }   /* #147 */
.upd { font-size: 0.8rem; font-weight: 400; }
.chart.small svg { max-height: 180px; }
.hero .chart-card + .chart-card { margin-top: 16px; }

/* time-window segmented control (#136) */
.window-control { display: inline-flex; margin: 0 0 16px; border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; background: var(--surface); }
.window-control .seg { background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 0.85rem; padding: 6px 16px; cursor: pointer; }
.window-control .seg + .seg { border-left: 1px solid var(--border); }
.window-control .seg:hover { color: var(--ink); }
.window-control .seg[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.market-control { margin-left: 8px; }   /* #336 — marknadstoggle bredvid tidsfönstret (wrappar naturligt på mobil) */
#clv-window-note { text-align: left; margin-top: 10px; }

/* omgång ≈ ISO-vecka (#137) — clearly a soft, derived label, never a real round */
.badge.omgang { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.hist-table td.c-date .wk { color: var(--muted); font-size: 0.85em; white-space: nowrap; }
#week-heatmap svg { max-height: 80px; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin: 0 0 30px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .v { font-family: var(--mono); font-size: 1.15rem; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .d { color: var(--muted); font-size: 0.74rem; margin-top: 4px; line-height: 1.35; }   /* #148/#155 klartext, läsbar på mobil */

/* bankroll */
.bankroll { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 30px; }
.bankroll h2 { margin: 0 0 8px; font-size: 1rem; }
.bk-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.bk-row label { font-weight: 600; font-size: 0.9rem; }
.bk-row input { font-family: var(--mono); font-size: 1rem; padding: 8px 10px; width: 140px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; }
#bk-note { font-size: 0.8rem; }

/* sections + cards */
main section { margin-bottom: 34px; }
main h2 { font-size: 1.15rem; margin: 0 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .match { font-weight: 600; }
.card .ko { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.card .pick-lead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card .pick-sel { font-size: 1.05rem; } .card .pick-sel b { font-weight: 700; }
.card .pick-odds { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .pick-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-detail { font-family: var(--mono); font-size: 0.85rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 0.9rem; }
.grid2 .k { color: var(--muted); }
.grid2 .v { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.stake { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 2px; }
.stake .pct { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; }
.stake .units { color: var(--muted); font-size: 0.85rem; }
.badge { display: inline-block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  border-radius: 999px; padding: 2px 8px; border: 1px solid var(--border); }
.badge.paper { color: var(--warn); border-color: var(--warn); }
.badge.tier-stark { color: var(--accent); border-color: var(--accent); }
.badge.tier-medel, .badge.tier-svag { color: var(--muted); }
.badge.pending { color: var(--muted); }
.badge.snapshotted { color: var(--accent); border-color: var(--accent); }
.badge.gen-date { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.badge.mock { color: var(--warn); border-color: var(--warn); font-weight: 700; }
.clv-pos { color: var(--clv-pos); } .clv-neg { color: var(--clv-neg); }   /* #154 — kall neutral, ej vinstgrön */
.won { color: var(--won); } .lost { color: var(--lost); }
.empty { color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center; }
/* #40 — "avvaktar resultat": spelad men olöst (feed-lucka). De-emfaserad så en enstaka
   feed-lucka aldrig läser som ett levande tips. Auto-settlas när resultatet dyker upp. */
.awaiting-h { font-size: 0.95rem; margin: 22px 2px 0; color: var(--muted); }
#today-awaiting .cards { margin-top: 8px; }
.card.awaiting { border-style: dashed; opacity: 0.72; }
.card.awaiting .pick-odds { font-size: 1.15rem; color: var(--muted); }
.badge.awaiting-badge { color: var(--muted); border-color: var(--muted); }
/* "senaste resultat"-korten (senast avgjorda med utfall + matchresultat) */
.recent-h { font-size: 0.95rem; margin: 22px 2px 0; color: var(--muted); }
#today-recent .cards { margin-top: 8px; }
.card.rc .rc-body { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 8px 0 6px; }
.card.rc .rc-sel { font-weight: 600; }
.card.rc .rc-score { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.card.rc .rc-foot { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.load-more-row { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.load-more-row .ghost { padding: 8px 18px; }

/* history filter chips + sortable headers + keyboard row nav (#142) */
.hist-controls { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 14px; align-items: center; }
.mobile-sort { display: none; }   /* #155 — visas bara på mobil (thead-sorteringen är clip-dold där) */
.mobile-sort select { font: inherit; font-size: 0.85rem; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--ink); }
@media (max-width: 640px) { .mobile-sort { display: inline-flex; align-items: baseline; gap: 6px; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 999px;
  padding: 4px 12px; font: inherit; font-size: 0.8rem; cursor: pointer; }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--accent); font-weight: 600; }
.clv-chips { justify-content: center; margin: 0 0 14px; }   /* #139 — centred under the hero */

/* #212 — keyboard-/screen-reader-reachable data table under the CLV chart (crosshair is pointer-only). */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.chart-data { margin-top: 8px; }
.chart-data > summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; }
.chart-data > summary:hover { color: var(--ink); }
.chart-data-body { max-height: 320px; overflow: auto; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: right; padding: 3px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th:nth-child(2), .data-table td:nth-child(2) { text-align: left; }
.data-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; }
.sortbtn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0;
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.72rem; font-weight: 600; }
.sortbtn:hover { color: var(--ink); }
.hist-table th[aria-sort="ascending"] .sortbtn::after { content: " ▲"; font-size: 0.8em; }
.hist-table th[aria-sort="descending"] .sortbtn::after { content: " ▼"; font-size: 0.8em; }
.hist-table tbody tr.row-active { background: var(--surface-2); }
.hist-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* signal drilldown + permalink (#141) */
.permalink { margin: 0 0 14px; }
.permalink .detail { border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.permalink-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.hist-table tr.detail-row td { padding: 0; border-bottom: 0; background: var(--surface-2); }
.hist-table tr.detail-row td::before { content: none; }
.detail { padding: 14px 16px; width: 100%; }
.detail .d-head { font-size: 1.02rem; margin-bottom: 8px; }
.detail .d-gauge svg { width: 100%; max-width: 300px; height: auto; display: block; margin: 4px 0 6px; }
.d-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; font-size: 0.9rem; align-items: baseline; }
.d-grid .d-k { color: var(--muted); }
.d-grid .d-v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.detail code { font-family: var(--mono); font-size: 0.82em; color: var(--muted); word-break: break-all; }
.dc { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }   /* #150 härledd dubbelchans */
.dc-h { font-size: 0.85rem; margin-bottom: 6px; }
.dc-row { display: grid; grid-template-columns: 3ch 1fr auto; gap: 10px; align-items: baseline;
  font-family: var(--mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; padding: 2px 0; }
.dc-row .dc-k { color: var(--muted); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--accent); }

/* History table — compact/scannable for browsing many old signals; wide content
   scrolls in its own container so the page body never scrolls horizontally. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); }
.hist-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; white-space: nowrap; }
.hist-table th, .hist-table td { padding: 9px 12px; text-align: left; }
.hist-table thead th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 600; border-bottom: 1px solid var(--border); }
.hist-table tbody tr { border-bottom: 1px solid var(--border); }
.hist-table tbody tr:last-child { border-bottom: none; }
.hist-table tbody tr:hover { background: var(--surface-2); }
.hist-table td.c-num, .hist-table td.c-outcome { font-family: var(--mono); text-align: right;
  font-variant-numeric: tabular-nums; }
.hist-table td.c-outcome { text-align: center; font-family: var(--sans); }
.hist-table td.c-match { font-weight: 600; }
.hist-table td.c-date, .hist-table td.c-pick { color: var(--muted); }
.hist-table tbody tr[data-id] { cursor: pointer; }   /* hela raden öppnar mätprotokollet */

/* #122 — /metod (statisk metod- & backtest-sida), återanvänder samma tokens/klasser */
.wrap.metod { max-width: 780px; }
.metod section { margin: 0 0 30px; }
.metod h3 { margin: 0 0 10px; font-size: 1.16rem; }
.metod .lede { font-size: 1.04rem; line-height: 1.6; }
.metod-hero h2 { font-size: 1.55rem; margin: 0 0 12px; }
.metod-lines { margin: 0 0 14px; padding-left: 1.3em; line-height: 1.55; }
.metod-lines li { margin: 0 0 8px; }
.metod-code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; overflow-x: auto; font-size: 0.84rem; }
.metod-code code { font-family: var(--mono); color: var(--ink); white-space: pre; }
.method-more { margin: 12px 0 0; }

/* #123 — per-liga-nedbrytning: kompakt tabell, scrollar i sin .table-wrap på smala skärmar */
.lg-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.lg-table th, .lg-table td { padding: 8px 12px; text-align: left; white-space: nowrap; }
.lg-table thead th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.lg-table th.c-num, .lg-table td.c-num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lg-table tbody tr { border-top: 1px solid var(--border); }
.lg-table tbody tr:hover { background: var(--surface-2); }
.lg-table td.c-league { font-weight: 600; }
.lg-table .wk { color: var(--muted); font-size: 0.85em; }

/* utfalls-pill (Vinst/Förlust/Inställd) — läsbar i tabell + kompakt mobilrad, sober outline */
.opill { display: inline-block; font-size: 0.75rem; font-weight: 600; border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.opill.won { color: var(--won); } .opill.lost { color: var(--lost); } .opill.void { color: var(--muted); }
/* "ditt odds → stängning" — en sammanslagen, färgad kolumn (färgen ÄR CLV-tecknet) */
.hist-table td.c-move { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend { font-size: 0.85rem; margin: 10px 0 16px; padding: 10px 13px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; }
.legend b { color: var(--ink); }
.legend .clv-pos, .legend .clv-neg { font-weight: 600; }

.method { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 16px; }
.method summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.method p { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; }

/* fördjupning: fäll ihop de avancerade/hypotetiska sektionerna (#146) */
.deepdive { margin: 0 0 34px; }
.deepdive > summary { cursor: pointer; list-style: none; padding: 13px 16px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.deepdive > summary::-webkit-details-marker { display: none; }
.deepdive > summary::before { content: "\25b8  "; color: var(--muted); }
.deepdive[open] > summary::before { content: "\25be  "; }
.deepdive[open] > summary { border-radius: var(--radius) var(--radius) 0 0; margin-bottom: 20px; }
.source { color: var(--muted); font-size: 0.82rem; text-align: center; }
.subscribe { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 0 0 6px; }  /* #124 */
.subscribe code { font-family: var(--mono); color: var(--ink); }

/* Monte-Carlo fan (#140) */
.mc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mc-head h2 { margin: 0 0 14px; }
.mc-readout { color: var(--muted); font-family: var(--mono); font-size: 0.88rem;
  font-variant-numeric: tabular-nums; margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) { .card { transition: border-color .15s; } }

/* ── loading skeletons (#135) — no "Laddar…" flash on cold load ────────────── */
.skeleton { display: block; border-radius: 8px; background-size: 200% 100%;
  background-image: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); }
.skeleton-hero { height: 3.2rem; width: min(240px, 70%); margin: 6px auto; }
.skeleton-stat { height: 2.4rem; width: 100%; }
.skeleton-chart { height: 220px; width: 100%; }
.skeleton-strip { height: 60px; width: 100%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s ease-in-out infinite; }   /* reduced-motion → static block */
  .seg, .ghost { transition: background .15s, color .15s; }
}

/* ── history → compact tappable rows under 640px ─────────────────────────────
   Each settled signal collapses to a TWO-LINE summary (match · utfall / datum ·
   CLV); the low-priority fields (val/odds/stängning/insats) live in the tap-to-
   expand mätprotokoll, so a long history is a tidy list, not a wall of 8-row
   cards. Latest first; "Visa fler" pages the rest. Replaces the old stacked view. */
@media (max-width: 640px) {
  /* #212 — ONLY the hist-table stacks into full-width cards, so only ITS wrap goes overflow-visible.
     Scoping with :has() means the per-league / scan / backtest tables keep their own horizontal-scroll
     container (the default .table-wrap `overflow-x:auto`) instead of the page body scrolling sideways.
     Falls back safely on browsers without :has() (all wraps stay auto → cards fit, so no scroll anyway). */
  .table-wrap:has(.hist-table) { overflow-x: visible; border: 0; background: none; border-radius: 0; }
  /* #123 — per-league table keeps its scroll container explicitly (redundant under :has, kept for clarity). */
  #league-table { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
  .hist-table { white-space: normal; font-size: 0.92rem; }
  .hist-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hist-table, .hist-table tbody { display: block; }
  /* #431 — egen rad för VALET: förr doldes Val-kolumnen på mobil, så en 1X2-rad och en Över/Under-rad
     såg identiska ut (samma match, olika signal) sedan O/U gick live (#336). */
  .hist-table tr[data-id] {
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "match outcome" "pick clv" "meta meta";
    column-gap: 12px; row-gap: 3px; align-items: baseline;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    margin: 8px 0; padding: 11px 14px; }
  .hist-table tr[data-id][aria-expanded="true"] { border-color: var(--accent); }
  .hist-table td { display: block; padding: 0; border: 0; white-space: normal; text-align: left; }
  .hist-table td::before { content: none; }
  .hist-table td[data-label="Insats"],
  .hist-table td[data-label="CLV"] { display: none; }   /* CLV%:et ersätts av den konkreta rörelsen */
  .hist-table td.c-pick { grid-area: pick; font-size: 0.86rem; color: var(--ink); }   /* #431 — 1X2 vs Ö/U syns */
  .hist-table td.c-match { grid-area: match; font-weight: 600; }
  .hist-table td.c-match::after { content: "›"; color: var(--muted); font-weight: 400; margin-left: 7px; }
  .hist-table tr[data-id][aria-expanded="true"] td.c-match::after { content: "⌄"; }
  .hist-table td.c-outcome { grid-area: outcome; text-align: right; }
  .hist-table td.c-date { grid-area: meta; color: var(--muted); font-size: 0.8rem; }
  .hist-table td.c-move { display: block; grid-area: clv; text-align: right; font-family: var(--mono);
    font-size: 0.9rem; font-variant-numeric: tabular-nums; }
  .hist-table tr.detail-row { display: block; margin: -4px 0 10px; }
  .hist-table tr.detail-row td { display: block; }
}

/* #scan — Dagens genomlysning: tabell över alla examinerade matcher + status/skäl. */
.scan-legend { font-size: 0.82rem; margin: 0.6rem 0 0.6rem; line-height: 2.1; }
.scan-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.scan-table th, .scan-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.scan-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.scan-table td.scan-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.scan-match { font-weight: 600; color: var(--ink); }
.scan-meta { font-size: 0.8rem; margin-top: 0.1rem; }
.scan-why { font-size: 0.82rem; margin-top: 0.25rem; max-width: 48ch; }
.scan-row.scan-tip td:first-child { border-left: 3px solid var(--accent); }
.scan-badge { display: inline-block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; padding: 0.12rem 0.5rem; border: 1px solid var(--muted); border-radius: 999px; color: var(--muted); white-space: nowrap; }
.scan-badge-tip { color: var(--accent); border-color: var(--accent); }
.scan-badge-ranked-out { color: var(--warn); border-color: var(--warn); }
.scan-rank { font-variant-numeric: tabular-nums; opacity: 0.75; margin-left: 0.15rem; }
/* #451 — marknadsetikett per rad + gruppering av en matchs marknads-rader */
.scan-market { display: inline-block; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.03em;
  padding: 0.08rem 0.4rem; margin-right: 0.35rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
/* Fortsättningsraden ska SITTA IHOP med raden ovan. Separatorn är `border-bottom` på raden FÖRE
   (border-collapse: collapse) — att nolla border-top här vore en no-op. Nolla den ovanför i stället. */
.scan-row:has(+ .scan-rowcont) td { border-bottom: 0; }
.scan-table td.scan-cont { padding-left: 1.6rem; }
.scan-contmark { font-size: 0.78rem; opacity: 0.65; }

/* #210 — datumnavigering + filter för skann-historiken. */
.scan-nav { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.6rem 0 0.2rem; }
.scan-navlink { font-size: 0.88rem; text-decoration: none; color: var(--accent); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.7rem; }
.scan-navlink:hover { border-color: var(--accent); }
.scan-navlink.disabled { color: var(--muted); opacity: 0.5; pointer-events: none; }
.scan-navdate { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.scan-filters { display: flex; align-items: center; gap: 0.6rem 0.9rem; flex-wrap: wrap; margin: 0.5rem 0 0.2rem; }
.scan-chips { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }
.scan-chip { font-size: 0.8rem; cursor: pointer; background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.18rem 0.7rem; }
.scan-chip:hover { border-color: var(--accent); }
.scan-chip.on { color: var(--surface); background: var(--accent); border-color: var(--accent); }
.scan-leaguelabel { font-size: 0.85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.scan-leaguelabel select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.2rem 0.4rem; max-width: 14rem; }

/* Agar-verktyg: token-gatad settle-panel (#357) */
.owner-tools{margin:2.5rem 0 .5rem}
.owner-toggle{font:inherit;cursor:pointer;background:none;border:1px solid #8884;color:#8889;border-radius:6px;padding:.3rem .7rem;font-size:.85rem}
#owner-panel{margin-top:.8rem;padding:1rem;border:1px solid #8884;border-radius:10px}
.owner-token{display:flex;gap:.5rem;flex-wrap:wrap;margin:.5rem 0 1rem}
.owner-token input{flex:1 1 12rem;padding:.4rem .6rem;border-radius:6px;border:1px solid #8884;background:transparent;color:inherit}
.owner-token button,.stuck-form button{font:inherit;cursor:pointer;padding:.35rem .8rem;border-radius:6px;border:1px solid #4a9a;background:#4a97;color:inherit}
.owner-token button.ghost,.stuck-form button.ghost{background:none;color:#8889;border-color:#8884}
.stuck-row{padding:.6rem 0;border-top:1px solid #8883}
.stuck-form{display:flex;align-items:center;gap:.4rem;flex-wrap:wrap;margin-top:.4rem}
.stuck-form input{width:3.2rem;padding:.3rem;border-radius:6px;border:1px solid #8884;background:transparent;color:inherit;text-align:center}
.stuck-msg{font-size:.85rem;color:#8889;margin-top:.3rem;min-height:1em}
.small{font-size:.85rem}

/* Slutresultat i avslutade kort/rader (#357) */
.hist-score{font-weight:600;padding:0 .35rem;border-radius:5px;background:#8882;font-variant-numeric:tabular-nums;white-space:nowrap}
.d-result{display:flex;align-items:center;gap:.6rem;margin:.5rem 0 .3rem}
.d-score{font-weight:700;font-size:1.3rem;font-variant-numeric:tabular-nums}
.hero-dl{font-size:.85rem;margin:.5rem 0 0}   /* #341 */
