/* NBA Totals — base styles. Light and dark follow the system setting. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #646d78;
  --accent: #2457d6;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e5f5ec;
  --warn: #9a6100;
  --warn-bg: #fff4dc;
  --bad: #c0392b;
  --bad-bg: #fde8e6;
  --info: #2457d6;
  --info-bg: #e7eefc;
  --track: #e8ebf0;
  --code-bg: #f1f3f6;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --border: #2b313a;
    --text: #e7eaee;
    --muted: #98a2ae;
    --accent: #6b93ff;
    --accent-text: #0b1020;
    --ok: #56c98a;
    --ok-bg: #173325;
    --warn: #f0b443;
    --warn-bg: #3a2c10;
    --bad: #ff7b6e;
    --bad-bg: #3d1a17;
    --info: #8fb0ff;
    --info-bg: #1c2742;
    --track: #2a3038;
    --code-bg: #14181d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* League bar (NBA / EuroLeague / EuroCup) */
.league-bar {
  display: flex;
  gap: .25rem;
  padding: .35rem 1.5rem;
  background: var(--text);
  overflow-x: auto;
}
.league-bar a {
  color: var(--bg);
  opacity: .7;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: .2rem .8rem;
  border-radius: 999px;
  white-space: nowrap;
}
.league-bar a:hover { opacity: 1; }
.league-bar a.active { opacity: 1; background: var(--accent); color: var(--accent-text); }
.league-bar .lb-manage { margin-left: auto; opacity: .55; }  /* the league list (fetch new leagues) */

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { font-weight: 400; color: var(--muted); }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: 6px;
}
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  padding: .25rem .7rem;
  border-radius: 999px;
}
.worker-box { display: flex; align-items: center; gap: .5rem; }
.worker-box form { margin: 0; }
.worker-box form[hidden] { display: none; }
.btn-small { padding: .25rem .7rem; font-size: .85rem; border-radius: 999px; }

.pill .dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-bad { color: var(--bad); background: var(--bad-bg); }

/* Layout */
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.section { margin-bottom: 2rem; }

.notice { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; }
.notice-warn { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn); }

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 640px;
}
.lead { font-size: 1.1rem; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: .5rem 1rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.card p { margin: 0; }
/* Space between cards stacked on a page (cards inside .cards / .grid-2 use the grid's gap). */
.page > .card, .page > .cards, .page > .grid-2 { margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* Status badges */
.badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--track);
  color: var(--muted);
}
.status-queued { background: var(--warn-bg); color: var(--warn); }
.status-running { background: var(--info-bg); color: var(--info); }
.status-done { background: var(--ok-bg); color: var(--ok); }
.status-failed { background: var(--bad-bg); color: var(--bad); }

/* Progress */
.progress { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.progress.indeterminate .bar {
  width: 35% !important;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}
.progress-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); min-height: 1.3em; }

/* Log */
.log summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.log pre {
  margin: .5rem 0 0;
  max-height: 260px;
  overflow: auto;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .6rem .75rem;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.log pre:empty::before { content: "No log yet."; color: var(--muted); }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 640px) {
  .page { padding: 1rem; }
  .topbar { padding: .75rem 1rem; gap: .75rem; }
  .league-bar { padding: .35rem 1rem; }
}

/* --- Phase 5 pages ---------------------------------------------------------------- */
.page { max-width: 1240px; }
.notice-info { background: var(--info-bg); border: 1px solid var(--info); }
.notice-ok { background: var(--ok-bg); border: 1px solid var(--ok); }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.lead-sub { font-size: 1.05rem; margin: -.5rem 0 1.25rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.update-box { min-width: 320px; max-width: 420px; flex: 1; }
.job-card-compact { gap: .4rem; padding: .75rem .9rem; }
.job-card-compact .run-form { display: flex; align-items: center; gap: .75rem; }

.day-buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.day-buttons .btn-empty:not(.btn-primary) { opacity: .6; }  /* a shown day with no game */
/* Running now: a bar under each live score counting down to the next reload. */
.swap-form { display: inline; margin-left: .25rem; }
.logout-form { display: inline; }
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 22rem; }
.login-card .field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }
.live-fav { display: block; margin-top: .2rem; }
.winner-move { white-space: nowrap; }
.move-big { font-weight: 600; }
.live-next { display: flex; align-items: center; gap: .35rem; margin-top: .25rem; white-space: nowrap; width: 11rem; }
.live-countdown-text { display: inline-block; width: 6.25rem; font-variant-numeric: tabular-nums; }
/* fixed width, so the countdown text changing every second never moves the table */
.games td.time-cell, .table td.time-cell { width: 13rem; min-width: 13rem; max-width: 13rem; }
.games td.game-cell, .table td.game-cell { min-width: 18rem; }
.live-countdown { display: inline-block; width: 4.5rem; height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.live-countdown-fill { display: block; height: 100%; width: 100%; background: var(--ok); transition: width .25s linear; }
/* The filter box (Tonight, All leagues): one field per line, the boxes lined up in a column. */
.filter-box { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; margin-bottom: .5rem; }
.filter-field { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.filter-field label { min-width: 14rem; }
.filter-box input[type=number], .filter-box select { font: inherit; padding: .3rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.filter-box input[type=number] { width: 6rem; }
.filter-count { padding: .2rem .6rem; border-radius: 999px; background: var(--info-bg); color: var(--info); font-size: .85rem; white-space: nowrap; }
@media (max-width: 600px) { .filter-field label { min-width: 0; width: 100%; } }
.freshness { margin: 0 0 1rem; }

.table-wrap { overflow-x: auto; }
.table.games td { vertical-align: top; }
.game-row { cursor: pointer; }
.game-row:hover td { background: var(--bg); }
.game-row.is-value td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.injury-row td, .ladder-row td { background: var(--bg); padding-top: .35rem; }
.ladder { margin: .25rem 0; }
.ev { font-weight: 700; font-variant-numeric: tabular-nums; }
.ev-pos { color: var(--ok); }
.ev-neg { color: var(--muted); }
.chip { display: inline-block; font-size: .8rem; padding: .1rem .5rem; margin: .1rem .25rem .1rem 0; border-radius: 999px; background: var(--track); }
.chip-neg { background: var(--bad-bg); color: var(--bad); }
.chip-pos { background: var(--ok-bg); color: var(--ok); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.table.kv td:last-child, .table.kv th:last-child { text-align: right; }
.table.compact th, .table.compact td { padding: .3rem .6rem; }
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.tile-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.form-card { max-width: 420px; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field input, .field select { font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.name-list { columns: 2; margin: 0; padding-left: 1.1rem; }
.setup { max-width: 760px; }

.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; flex-direction: row; max-width: 560px; }
.form-inline .field input { width: 7.5rem; }
.form-inline { max-width: 720px; }

/* Game page: a team's last games against the model's expected points */
.team-last .ou { font-weight: 600; white-space: nowrap; }
.team-last .ou-over { color: var(--ok); }
.team-last .ou-under { color: var(--info); }

/* Enhanced model (test) */
/* Enhanced total, Winner and Last 20 games: wrap inside a narrow column instead of one long line. */
.table td.enhanced-cell, .table td.winner-cell, .table td.last20-cell { white-space: normal; min-width: 7.5rem; max-width: 10rem; line-height: 1.3; }
.table td.enhanced-cell .small, .table td.winner-cell .small, .table td.last20-cell .small { font-size: .75rem; }

/* Ladder: lines bookmakers offer now */
.ladder tr.has-offers td { background: var(--code-bg); }
.ladder tr.has-offers.is-value td { background: var(--ok-bg); }
.my-book { margin: 0 0 .75rem; }

/* --- Phase 8: sport chooser and soccer ------------------------------------------- */
.sport-bar {
  display: flex;
  gap: .25rem;
  padding: .3rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.sport-bar a {
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 700;
  padding: .15rem .8rem;
  border-radius: 999px;
}
.sport-bar a:hover { color: var(--text); }
.sport-bar a.active { color: var(--accent-text); background: var(--accent); }
.sport-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.sport-card { display: flex; flex-direction: column; gap: .5rem; color: var(--text); text-decoration: none; }
.sport-card:hover { border-color: var(--accent); }
.sport-card .btn { align-self: flex-start; margin-top: auto; }
ul.plain { list-style: none; padding: 0; margin: 0; }
.verdict { display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .5rem; border-radius: 999px;
  background: var(--track); color: var(--muted); white-space: nowrap; }
.verdict-bet, .verdict-edge, .verdict-edge-all-leagues { background: var(--ok-bg); color: var(--ok); }
.verdict-value { background: var(--warn-bg); color: var(--warn); }
.verdict-no-edge { background: var(--bad-bg); color: var(--bad); }
.pick-cell { min-width: 9.5rem; }
.pick-bet { background: var(--ok-bg); }
.score-chip { display: inline-block; padding: .1rem .5rem; margin: 0 .25rem .25rem 0; border: 1px solid var(--border);
  border-radius: 999px; font-size: .85rem; }
.score-grid td, .score-grid th { padding: .2rem .4rem; }
@media (max-width: 640px) { .sport-bar { padding: .3rem 1rem; } }

/* Manage leagues: "Fetch all shown" above the league table (PLAN.md Phase 11) */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .75rem 0; }

/* Collapsible card sections (<details>): an arrow before the title, closed by default. */
details.collapsible > summary { display: flex; align-items: baseline; gap: .6rem; cursor: pointer; list-style: none; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before { content: "▸"; font-size: 1.1rem; transition: transform .15s; }
details.collapsible[open] > summary::before { transform: rotate(90deg); }
details.collapsible > summary h2 { margin: 0; }
details.collapsible[open] > summary { margin-bottom: .6rem; }

/* Cold matchups (both teams scoring below the model lately): blue badges and text. */
.badge.badge-cold { background: #dbeafe; color: #1e40af; }
.badge.badge-very-cold { background: #1e40af; color: #fff; }
.text-cold { color: #1e40af; }
@media (prefers-color-scheme: dark) {
  .badge.badge-cold { background: #1e3a8a; color: #dbeafe; }
  .text-cold { color: #93c5fd; }
}

/* "Worth betting" button in the filter row */
.hot-filter .btn-picks { font-weight: 700; }
