/* =============================================================================
   Value Analyzer — design system
   Quant-terminal dark theme. Sport series use the CVD-validated categorical
   palette (worst adjacent ΔE 8.4 on this surface); P&L / CLV use status
   good/bad, always paired with a +/- sign so meaning is never colour-alone.
   Charts are dependency-free inline SVG (see charts.js) — no CDN, offline-safe.
============================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces (cool slate, near-black page plane) */
  --plane:      #0b0d12;
  --surface-1:  #141824;
  --surface-2:  #1b2130;
  --surface-3:  #232a3d;
  --border:        rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.15);

  /* Ink */
  --text:   #f1f3f8;
  --text-2: #b2b9cc;
  --muted:  #6b7488;
  --grid:   #222839;

  /* Interactive / brand */
  --accent:      #6d7cff;
  --accent-soft: rgba(109,124,255,.15);

  /* Status — shown with sign/icon, never colour alone */
  --pos:  #23c98a;
  --neg:  #f4595f;
  --warn: #f5a524;
  --pos-soft: rgba(35,201,138,.14);
  --neg-soft: rgba(244,89,95,.14);
  --warn-soft: rgba(245,165,36,.14);

  /* Sport identity — validated categorical slots 1-5 (dark) */
  --football:   #3987e5;
  --tennis:     #d95926;
  --basketball: #199e70;
  --baseball:   #c98500;
  --esports:    #d55181;
  --football-soft:   rgba(57,135,229,.16);
  --tennis-soft:     rgba(217,89,38,.16);
  --basketball-soft: rgba(25,158,112,.16);
  --baseball-soft:   rgba(201,133,0,.16);
  --esports-soft:    rgba(213,81,129,.16);

  --radius:    14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--plane);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  /* faint aurora so the plane isn't dead-flat */
  background-image:
    radial-gradient(900px 500px at 12% -8%, rgba(109,124,255,.10), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(25,158,112,.07), transparent 55%);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #9aa5ff; }

.container { max-width: 1440px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); margin: 2rem 0 .85rem; display: flex; align-items: center; gap: .6rem; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Navbar ---------------------------------------------------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.5rem;
  background: rgba(13,16,24,.72);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.nav-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.02rem; color: var(--text); letter-spacing: -.01em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #3a49d6);
  display: grid; place-items: center; color: #fff; font-size: .9rem; font-weight: 800;
  box-shadow: 0 2px 10px -2px rgba(109,124,255,.7);
}
.nav-links { display: flex; gap: .35rem; }
.nav-links a { color: var(--text-2); font-weight: 550; padding: .35rem .7rem; border-radius: 8px; font-size: .9rem; transition: background .15s, color .15s; }
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: #fff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(109,124,255,.35); }
.nav-sports { display: flex; gap: .4rem; margin-left: auto; flex-wrap: wrap; }

/* ---------- Sport tags ------------------------------------------------ */
.sport-tag {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  line-height: 1.4; white-space: nowrap;
}
.sport-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .95; }
.sport-football   { background: var(--football-soft);   color: #7fb2f2; }
.sport-tennis     { background: var(--tennis-soft);     color: #ef8a5f; }
.sport-basketball { background: var(--basketball-soft); color: #4fc79b; }
.sport-baseball   { background: var(--baseball-soft);   color: #e0aa3d; }
.sport-esports    { background: var(--esports-soft);    color: #e388a9; }
a.sport-tag { transition: transform .12s, filter .12s; }
a.sport-tag:hover { transform: translateY(-1px); filter: brightness(1.12); }

/* ---------- Cards ----------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--surface-1), #11151f);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Hero KPI row --------------------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.kpi {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-1), #10141d);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); opacity: .8; }
.kpi.pos::before { background: var(--pos); }
.kpi.neg::before { background: var(--neg); }
.kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; margin-top: .35rem; line-height: 1.05; }
.kpi-value.pos { color: var(--pos); }
.kpi-value.neg { color: var(--neg); }
.kpi-foot { margin-top: .3rem; font-size: .78rem; color: var(--text-2); display: flex; align-items: center; gap: .4rem; }
.kpi-spark { position: absolute; right: 10px; bottom: 8px; width: 96px; height: 34px; opacity: .9; }

.delta { display: inline-flex; align-items: center; gap: .15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.pos { color: var(--pos); }
.delta.neg { color: var(--neg); }

/* ---------- Per-sport stat cards ------------------------------------- */
.stats-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 1rem; }
.stat-card {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-1), #10141d);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-card .accent-bar { position: absolute; inset: 0 0 auto 0; height: 3px; }
.stat-card.sport-football   .accent-bar { background: var(--football); }
.stat-card.sport-tennis     .accent-bar { background: var(--tennis); }
.stat-card.sport-basketball .accent-bar { background: var(--basketball); }
.stat-card.sport-baseball   .accent-bar { background: var(--baseball); }
.stat-card.sport-esports    .accent-bar { background: var(--esports); }
.stat-card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.stat-card h3 { text-transform: capitalize; font-size: .95rem; font-weight: 650; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; margin: .3rem 0; font-size: .88rem; }
.stat-row span { color: var(--muted); }
.stat-row strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-card .spark-wrap { margin-top: .7rem; height: 40px; }

/* ---------- Filter bar ------------------------------------------------ */
.filter-bar { display: flex; gap: 1rem; align-items: center; margin: 1.25rem 0; flex-wrap: wrap; }
.filter-bar form { display: flex; gap: 1rem; flex-wrap: wrap; }
.filter-bar label { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--muted); }
.filter-bar select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .4rem .6rem; font-size: .85rem; font-family: inherit; cursor: pointer;
  transition: border-color .15s;
}
.filter-bar select:hover, .filter-bar select:focus { border-color: var(--accent); outline: none; }

/* ---------- Data table ------------------------------------------------ */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
.bet-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.bet-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: .7rem .85rem;
  color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.bet-table td { padding: .62rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.bet-table tbody tr { transition: background .12s; }
.bet-table tbody tr:hover td { background: var(--surface-2); }
.bet-table tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }
.bet-row td:first-child { position: relative; }
.bet-row.result-won td:first-child::before,
.bet-row.result-lost td:first-child::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; }
.bet-row.result-won  td:first-child::before { background: var(--pos); }
.bet-row.result-lost td:first-child::before { background: var(--neg); }

.evt-name { font-weight: 550; }
.evt-time { color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; }
.mkt-chip { font-family: var(--mono); font-size: .74rem; color: var(--text-2); background: var(--surface-3); padding: .12rem .4rem; border-radius: 5px; }
.sel-name { font-weight: 650; text-transform: capitalize; }

/* inline edge bar in the table */
.edge-cell { min-width: 92px; }
.edge-val { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.edge-bar { height: 4px; margin-top: .28rem; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.edge-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #9aa5ff); border-radius: 3px; }

.positive { color: var(--pos); font-weight: 650; font-variant-numeric: tabular-nums; }
.negative { color: var(--neg); font-weight: 650; font-variant-numeric: tabular-nums; }

.result-badge { display: inline-block; padding: .16rem .5rem; border-radius: 6px; font-weight: 700; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.result-won  { background: var(--pos-soft);  color: var(--pos); }
.result-lost { background: var(--neg-soft);  color: var(--neg); }
.result-void { background: rgba(107,116,136,.16); color: var(--muted); }
.pending-badge { color: var(--muted); font-size: .74rem; display: inline-flex; align-items: center; gap: .35rem; }
.pending-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

.badge { display: inline-block; padding: .14rem .45rem; border-radius: 6px; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-right: .25rem; }
.badge-single { background: var(--pos-soft); color: var(--pos); }
.badge-acca   { background: var(--accent-soft); color: #a5b0ff; }
.unrated-badge { display: inline-block; margin-top: .25rem; padding: .1rem .4rem; border-radius: 5px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--warn-soft); color: var(--warn); cursor: help; }

.link-cell a { font-size: .78rem; color: var(--muted); font-weight: 600; }
.link-cell a:hover { color: var(--accent); }

/* ---------- Pagination ------------------------------------------------ */
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1.25rem; color: var(--muted); font-size: .85rem; }
.pagination a, .pagination .pg-info { padding: .4rem .75rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); font-variant-numeric: tabular-nums; }
.pagination a { color: var(--text-2); font-weight: 600; transition: background .15s, border-color .15s; }
.pagination a:hover { background: var(--surface-2); border-color: var(--accent); color: var(--text); }

/* ---------- Charts ---------------------------------------------------- */
.chart-grid { display: grid; gap: 1.1rem; }
.chart-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.chart-card { background: linear-gradient(180deg, var(--surface-1), #11151f); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.2rem 1rem; box-shadow: var(--shadow); }
.chart-card h3 { font-size: .98rem; font-weight: 650; }
.chart-card .chart-sub { color: var(--muted); font-size: .8rem; margin-top: .1rem; margin-bottom: .5rem; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-axis text { fill: var(--muted); font-size: 10px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart-grid-line { stroke: var(--grid); stroke-width: 1; }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 2rem 0; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .7rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--text-2); cursor: default; }
.legend-key { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend-key.line { height: 3px; border-radius: 2px; width: 15px; }

/* SVG tooltip + crosshair */
.chart-tip {
  position: fixed; z-index: 80; pointer-events: none; opacity: 0; transform: translateY(-4px);
  transition: opacity .1s; background: rgba(20,24,36,.97); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: .55rem .7rem; font-size: .78rem; box-shadow: 0 8px 24px -8px rgba(0,0,0,.8); min-width: 130px;
}
.chart-tip .tip-title { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.chart-tip .tip-row { display: flex; align-items: center; gap: .45rem; margin: .18rem 0; }
.chart-tip .tip-row .k { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.chart-tip .tip-row .lbl { color: var(--text-2); margin-right: auto; }
.chart-tip .tip-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.hover-dot { stroke: var(--surface-1); stroke-width: 2; }

/* ---------- Meters (CLV / calibration verdicts) --------------------- */
.meter { margin: .55rem 0; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .82rem; margin-bottom: .3rem; }
.meter-head .m-label { color: var(--text-2); }
.meter-head .m-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-track { position: relative; height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.meter-track > i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.meter-track.diverging::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }

/* ---------- Detail page ---------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.1rem; align-items: start; }
.detail-card { padding: 1.3rem 1.4rem; }
.detail-card h2 { margin-bottom: 1rem; font-size: 1.25rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.detail-card h3 { margin: 1.3rem 0 .6rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th { width: 46%; text-align: left; padding: .48rem .1rem; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.detail-table td { padding: .48rem .1rem; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); font-weight: 550; }
.detail-table tr:last-child th, .detail-table tr:last-child td { border-bottom: none; }
.notes { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; font-family: var(--mono); font-size: .78rem; color: var(--text-2); word-break: break-word; }

/* probability comparison ladder on the detail page */
.prob-ladder { display: grid; gap: .6rem; margin: .3rem 0 .2rem; }
.prob-row { display: grid; grid-template-columns: 118px 1fr 52px; align-items: center; gap: .6rem; font-size: .82rem; }
.prob-row .p-label { color: var(--text-2); }
.prob-row .p-track { height: 9px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.prob-row .p-track > i { display: block; height: 100%; border-radius: 5px; }
.prob-row .p-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Verdict / callout --------------------------------------- */
.verdict { margin-top: .85rem; padding: .7rem .85rem; border-radius: var(--radius-sm); font-size: .82rem; line-height: 1.45; border: 1px solid transparent; display: flex; gap: .55rem; align-items: flex-start; }
.verdict::before { font-size: .95rem; line-height: 1.3; }
.verdict.ok   { background: var(--pos-soft);  border-color: rgba(35,201,138,.3);  color: #7fe3bd; }
.verdict.ok::before   { content: "✓"; color: var(--pos); }
.verdict.warn { background: var(--warn-soft); border-color: rgba(245,165,36,.3); color: #f4cd8a; }
.verdict.warn::before { content: "!"; color: var(--warn); font-weight: 800; }
.ok { color: var(--pos); }
.warn { color: var(--warn); }

/* ---------- Alerts / empty ------------------------------------------ */
.alert { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .85rem; border: 1px solid transparent; }
.alert-success { background: var(--pos-soft); border-color: rgba(35,201,138,.3); color: #7fe3bd; }
.alert-danger  { background: var(--neg-soft); border-color: rgba(244,89,95,.3); color: #f6a0a3; }

.empty-state { color: var(--muted); padding: 3rem 1rem; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: rgba(255,255,255,.01); }
.empty-state code { background: var(--surface-2); padding: .18rem .45rem; border-radius: 5px; font-size: .85rem; color: var(--text-2); font-family: var(--mono); }

.quick-links { display: flex; flex-wrap: wrap; gap: .6rem; }
.quick-links a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-1); color: var(--text-2); font-size: .8rem; font-weight: 600; transition: border-color .15s, color .15s; }
.quick-links a:hover { border-color: var(--accent); color: var(--text); }

/* ---------- Motion / responsive ------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kpi, .stat-card, .chart-card, .clv-card, .table-wrap, .detail-card { animation: rise .4s cubic-bezier(.2,.7,.3,1) both; }
.kpi:nth-child(2), .stat-card:nth-child(2), .chart-card:nth-child(2) { animation-delay: .05s; }
.kpi:nth-child(3), .stat-card:nth-child(3), .chart-card:nth-child(3) { animation-delay: .1s; }
.kpi:nth-child(4), .stat-card:nth-child(4), .chart-card:nth-child(4) { animation-delay: .15s; }
.stat-card:nth-child(5) { animation-delay: .2s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 820px) {
  .detail-grid { grid-template-columns: 1fr; }
  .nav-sports { width: 100%; margin-left: 0; }
  .kpi-value { font-size: 1.7rem; }
}

/* CLV cards reuse the chart-card frame */
.clv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; }
.clv-card { background: linear-gradient(180deg, var(--surface-1), #11151f); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.25rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.clv-card .accent-bar { position: absolute; inset: 0 0 auto 0; height: 3px; }
.clv-card.sport-football   .accent-bar { background: var(--football); }
.clv-card.sport-tennis     .accent-bar { background: var(--tennis); }
.clv-card.sport-basketball .accent-bar { background: var(--basketball); }
.clv-card.sport-baseball   .accent-bar { background: var(--baseball); }
.clv-card.sport-esports    .accent-bar { background: var(--esports); }
.clv-card h3 { display: flex; align-items: center; justify-content: space-between; margin-bottom: .2rem; text-transform: capitalize; font-size: 1.05rem; }
.clv-n { color: var(--muted); font-size: .78rem; margin-bottom: .9rem; }

/* =============================================================================
   Mobile / PWA layer
   Phone-first additions on top of the same design tokens above — no second
   :root block, because charts.js reads those custom properties off the
   document element and two sources of truth would drift.
============================================================================= */

/* ---------- Buttons, panels, form fields ----------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px;                     /* iOS minimum comfortable tap target */
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a68f0; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .3rem; }

.panel {
  background: linear-gradient(180deg, var(--surface-1), #11151f);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: .9rem; }

.field { display: block; margin: .75rem 0; }
.field > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.field input {
  width: 100%; min-height: 44px; padding: .55rem .7rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 16px;   /* 16px stops iOS zooming on focus */
}
.field input:focus { outline: none; border-color: var(--accent); }

.small { font-size: .8rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
.code-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .7rem; overflow-x: auto;
  font-family: var(--mono); font-size: .74rem; color: var(--text-2);
}
.count-pill, .pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 99px;
  background: var(--surface-3); color: var(--text-2);
  font-size: .68rem; font-weight: 600; letter-spacing: .02em;
}
.alert { padding: .7rem .85rem; border-radius: var(--radius-sm); margin-bottom: .8rem; font-size: .85rem; }
.alert-error, .alert-danger { background: var(--neg-soft); border: 1px solid var(--neg); color: var(--text); }
.alert-warn, .alert-warning { background: var(--warn-soft); border: 1px solid var(--warn); color: var(--text); }
.alert-success, .alert-info { background: var(--pos-soft); border: 1px solid var(--pos); color: var(--text); }
.push-status { margin-top: .6rem; font-size: .82rem; color: var(--text-2); min-height: 1.2em; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state p { margin-bottom: .5rem; }

/* ---------- Login / offline card ------------------------------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.25rem; }
.auth-card {
  width: 100%; max-width: 360px; text-align: center;
  background: linear-gradient(180deg, var(--surface-1), #11151f);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem 1.5rem; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.25rem; margin-bottom: .3rem; }
.auth-card .field { text-align: left; }
.auth-brand { margin-bottom: 1rem; }
.auth-brand .brand-mark { width: 48px; height: 48px; font-size: 1.5rem; margin: 0 auto; }

/* ---------- Bet cards (phone replacement for the wide table) --------- */
.bet-cards { display: grid; gap: .7rem; }
.bet-card {
  display: block; position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-1), #11151f);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.bet-card:hover { border-color: var(--border-strong); color: var(--text); }
.bet-card:active { transform: scale(.995); }
.bet-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; }
.bet-card.sport-football::before   { background: var(--football); }
.bet-card.sport-tennis::before     { background: var(--tennis); }
.bet-card.sport-basketball::before { background: var(--basketball); }
.bet-card.sport-baseball::before   { background: var(--baseball); }
.bet-card.sport-esports::before    { background: var(--esports); }

.bc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.bc-time { color: var(--text-2); font-size: .8rem; }
.bc-event { font-weight: 650; font-size: .95rem; line-height: 1.3; margin-bottom: .45rem; }
.bc-pick { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-bottom: .6rem; }
.bc-odds { font-weight: 700; }
.bc-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .55rem; }
.bc-metrics > div { display: flex; flex-direction: column; gap: .1rem; }
.bc-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.bc-flag { margin-top: .5rem; }

/* ---------- Settings: key vault -------------------------------------- */
.key-list { margin-top: .9rem; }
.key-row { padding: .9rem 0; border-top: 1px solid var(--border); }
.key-row:first-child { border-top: none; padding-top: .3rem; }
.key-head { display: flex; align-items: center; gap: .45rem; margin-bottom: .2rem; }
.key-current { font-size: .85rem; color: var(--text-2); margin-top: .35rem; }

/* Vault state is a body class set by app.js, so the markup stays declarative. */
.vault-unlocked-only, .vault-missing-only { display: none; }
body.vault-unlocked .vault-locked-only { display: none; }
body.vault-unlocked .vault-unlocked-only { display: block; }
body.vault-missing .vault-locked-only,
body.vault-missing .vault-unlocked-only { display: none; }
body.vault-missing .vault-missing-only { display: block; }

/* ---------- Bottom tab bar (phones only) ----------------------------- */
.tabbar { display: none; }

@media (max-width: 820px) {
  .navbar { display: none; }
  .container { padding: 1rem .9rem calc(5.5rem + env(safe-area-inset-bottom)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; inset: auto 0 0 0; z-index: 50;
    background: var(--surface-1);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);   /* clear the home indicator */
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .15rem; min-height: 56px; padding: .4rem 0;
    color: var(--muted); font-size: .68rem; font-weight: 600;
  }
  .tabbar a.active { color: var(--accent); }
  .tab-ico { font-size: 1.15rem; line-height: 1; }

  /* The wide bet table is unreadable at phone widths — cards replace it. */
  .table-wrap { display: none; }
  .page-head h1 { font-size: 1.15rem; }
  .kpi-row.compact { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .kpi-row.compact .kpi-value { font-size: 1.35rem; }
  .bc-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* Above the phone breakpoint the cards are redundant — the table is better. */
@media (min-width: 821px) {
  .bet-cards.table-alt { display: none; }
}

/* minmax(360px) overflows a 390px viewport once container padding is added. */
.chart-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.clv-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
