:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --good: #1a7f37;
  --good-bg: #e6f4ea;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --pick: #0b5cd5;
  --pick-bg: #e3edff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --ink: #e6e9ee;
    --muted: #9aa4b2;
    --line: #2a3038;
    --accent: #4c8dff;
    --good: #4ac26b;
    --good-bg: #13301d;
    --bad: #ff6b6b;
    --bad-bg: #3a1717;
    --warn: #e3b341;
    --warn-bg: #352a0c;
    --pick: #8cb4ff;
    --pick-bg: #1b2a46;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
select { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; }
.brand span { font-weight: 500; color: var(--muted); }
.weeknav { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.weeknav button { padding: 2px 10px; font-size: 18px; line-height: 1; }
.refresh { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.tabs { display: flex; gap: 4px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); background: var(--card); overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.card h3 { margin: 4px 0 8px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.scroll-x { overflow-x: auto; }

.toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar select { margin-left: 6px; }
.check { display: inline-flex; gap: 6px; align-items: center; }

#warnings { max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.warning { margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: 90vw;
}
.toast.error { background: var(--bad); color: #fff; }

/* ---------- slate ---------- */
.slate-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .slate-layout { grid-template-columns: 1fr; } .builder { order: -1; } }
.day { margin: 18px 0 8px; font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.day:first-child { margin-top: 0; }

.game { padding: 0; margin-bottom: 10px; overflow: hidden; }
.game-main { display: grid; grid-template-columns: 92px 1fr 1fr 200px; gap: 12px; padding: 12px 14px; align-items: center; }
.game-main > * { min-width: 0; }
@media (max-width: 1250px) { .game-main { grid-template-columns: 1fr 1fr; } .game-meta, .game-lines { grid-column: span 2; } .game-lines { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; } }
.game-meta { font-size: 12px; color: var(--muted); }
.game-meta b { color: var(--ink); font-size: 13px; }

.side {
  display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); min-height: 64px; width: 100%;
  /* Both teams in a matchup get the same height (the taller one's), with content top-aligned. */
  align-self: stretch; justify-content: flex-start;
}
.side .team { font-weight: 700; font-size: 15px; }
.side-head { display: flex; align-items: center; gap: 6px; }
/* Live / final score: large and pushed to the right edge of the team card. */
.side-score { margin-left: auto; padding-left: 10px; font-size: 28px; font-weight: 800; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums; }
/* Team icons */
.ti-helmet, .ti-logo { width: 28px; height: 22px; flex: 0 0 auto; vertical-align: middle; }
.side .ti-logo { width: 40px; height: 40px; margin: -4px 2px -4px -2px; }  /* matchup buttons */
.ti-logo { object-fit: contain; }
.ti-helmet .ti-shell { stroke: rgba(0, 0, 0, .35); stroke-width: 1; }
@media (prefers-color-scheme: dark) { .ti-helmet .ti-shell { stroke: rgba(255, 255, 255, .6); stroke-width: 1.2; } }
.lb-team { display: inline-flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; }
.lb-team.away { justify-content: flex-end; }
.lb-team .ti-helmet, .pick-name .ti-helmet { width: 22px; height: 18px; }
.lb-team .ti-logo, .pick-name .ti-logo { width: 28px; height: 28px; }
/* Helmets face each other: away faces right (as drawn), home is mirrored to face left. */
.lb-team.home .ti-helmet, .side.home-side .ti-helmet { transform: scaleX(-1); }
.pick-name { display: inline-flex; align-items: center; gap: 6px; }
.side .line { font-weight: 600; color: var(--muted); margin-left: 6px; }
.side .prob { font-size: 12px; color: var(--muted); }
.side .prob strong { font-size: 14px; }
.side.best { border-color: var(--good); }
.side.best .prob strong { color: var(--good); }
.side.picked { background: var(--pick-bg); border-color: var(--pick); box-shadow: inset 0 0 0 1px var(--pick); }
.side.picked .team::after { content: "  ✓ PICK"; color: var(--pick); font-size: 11px; }
.side.locked { cursor: not-allowed; }
.side .pop { font-size: 11px; color: var(--warn); }
.side.won { background: var(--good-bg); }
.side.lost { background: var(--bad-bg); }

.game-lines { font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
/* Odds block: labels in one column, odds in the next, every line value in the same style. */
.odds-grid { display: grid; grid-template-columns: max-content 1fr; gap: 3px 8px; align-items: baseline; }
.odds-label { color: var(--muted); white-space: nowrap; }
.odds { font-weight: 700; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.odds-note { color: var(--muted); font-size: 11px; white-space: nowrap; }
.badge { display: inline-block; white-space: normal; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--line); color: var(--ink); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.game details { border-top: 1px solid var(--line); }
.game summary { padding: 6px 14px; cursor: pointer; font-size: 12px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; padding: 4px 14px 14px; font-size: 12px; }
.detail-grid h4 { margin: 4px 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
table.mini { border-collapse: collapse; width: 100%; }
table.mini td, table.mini th { padding: 2px 6px 2px 0; text-align: left; border-bottom: 1px dashed var(--line); }
table.mini td.num, table.mini th.num { text-align: right; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* ---------- line value board ---------- */
.lineboard { margin-bottom: 14px; }
.lineboard h3 { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
.lb-sub { font-size: 11px; font-weight: 400; }
.lb-row {
  display: grid; grid-template-columns: 136px minmax(90px, 1fr) 136px minmax(260px, 1.6fr);
  gap: 8px; align-items: center; padding: 5px 4px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.lb-row:hover { background: var(--bg); }
.lb-started { opacity: .5; }
.lb-team { color: var(--muted); }
.lb-team.away { text-align: right; }
.lb-team.lb-value { color: var(--ink); font-weight: 700; }
.lb-bar { position: relative; height: 14px; }
.lb-axis { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.lb-fill { position: absolute; top: 2px; height: 10px; border-radius: 3px; background: var(--warn); opacity: .75; }
.lb-fill.strong { background: var(--good); opacity: 1; }
.lb-note, .lb-same { font-size: 12px; margin: 8px 0 0; }
@media (max-width: 760px) {
  .lb-row { grid-template-columns: 70px 1fr 70px; }
  .lb-text { grid-column: span 3; padding-left: 4px; }
}

.linestrip { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.ls-grid { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 14px; align-items: center; }
@media (max-width: 760px) { .ls-grid { grid-template-columns: 1fr; } }
.ls-text { display: flex; flex-direction: column; gap: 3px; }
.numline { width: 100%; height: auto; overflow: visible; }
.nl-axis { stroke: var(--muted); stroke-width: 1; }
.nl-tick { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.nl-key { stroke: var(--ink); stroke-width: 2; }
.nl-lbl, .nl-keylbl { font-size: 9px; text-anchor: middle; fill: var(--muted); }
.nl-keylbl { fill: var(--ink); font-weight: 700; }
.nl-band { fill: var(--good); opacity: .25; }
.nl-market { fill: var(--muted); stroke: var(--card); stroke-width: 1.5; }
.nl-league { fill: var(--good); stroke: var(--card); stroke-width: 1.5; }
.nl-lock { fill: none; stroke: var(--warn); stroke-width: 1.5; }
.nl-tag { font-size: 10px; font-weight: 700; text-anchor: middle; }
.nl-tag.league { fill: var(--good); }
.nl-tag.market { fill: var(--muted); }

/* ---------- league picks ---------- */
/* Win / loss colours stay the same in light and dark mode (light green and salmon with dark text). */
:root { --win: #c6efce; --win-ink: #0b5a1a; --loss: #fa8072; --loss-ink: #4a0900; --push: #fff2cc; --push-ink: #6b5200;
        --live-win: #e3f7e7; --live-loss: #fdd5cf; }
.lp-head { margin-bottom: 12px; }
.lp-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 13px; }
.lp-legend { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.lp-legend span { padding: 1px 8px; border-radius: 4px; font-size: 11px; border: 1px solid var(--line); }
table.lp-table { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.lp-table th { color: var(--muted); font-weight: 600; text-align: left; padding: 4px 6px; white-space: nowrap; }
table.lp-table td { padding: 5px 7px; white-space: nowrap; }
table.lp-table .num { text-align: right; }
.lp-rank { color: var(--muted); text-align: right; width: 2em; }
.lp-name { font-weight: 600; }
tr.lp-me td.lp-name, tr.lp-me td.lp-rank { box-shadow: inset 3px 0 0 var(--accent); background: var(--pick-bg); }
.lp-cell { border-radius: 5px; min-width: 104px; border: 1px solid var(--line); }
.lp-line { font-size: 11px; opacity: .8; }
.lp-live { display: block; font-size: 10px; font-weight: 700; }
.lp-empty { color: var(--muted); text-align: center; }
.lp-proj { font-size: 10px; color: var(--muted); font-weight: 400; }
.st-W { background: var(--win) !important; color: var(--win-ink) !important; border-color: var(--win) !important; }
.st-L { background: var(--loss) !important; color: var(--loss-ink) !important; border-color: var(--loss) !important; }
.st-P { background: var(--push) !important; color: var(--push-ink) !important; border-color: var(--push) !important; }
.st-winning { background: var(--live-win) !important; color: var(--win-ink) !important; border: 1px dashed #4caf50 !important; }
.st-losing, .st-pushing { background: var(--live-loss) !important; color: var(--loss-ink) !important; border: 1px dashed #e0533f !important; }
.st-pending { background: var(--card); }
.st-unknown { background: var(--card); opacity: .6; font-style: italic; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e0533f; margin-right: 4px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
/* Game boxes wrap onto as many rows as needed, so every game is visible without scrolling. */
.lg-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 8px; margin-bottom: 12px; }
.lg-chip { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12px; }
.lg-chip.lg-live { border-color: #e0533f; }
/* "On bye" spans the whole grid width, with the teams side by side on one line. */
.lg-chip.lg-bye { border-style: dashed; grid-column: 1 / -1; display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; }
.lg-chip.lg-bye .lg-when { margin: 0 4px 0 0; font-weight: 600; }
.lg-bye-team { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.lg-bye-team .ti-logo, .lg-bye-team .ti-helmet { width: 18px; height: 18px; }
.lg-when { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.lg-side { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; padding: 2px 5px; border-radius: 4px; margin-top: 2px; border: 1px solid transparent; }
.lg-score { font-weight: 700; text-align: right; min-width: 1.6em; }
.lg-n { opacity: .75; font-size: 11px; }

/* ---------- sheet check ---------- */
.sheet-check { margin-bottom: 12px; font-size: 13px; }
.sheet-check .sc-lines { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.sheet-check summary { cursor: pointer; color: var(--accent); }
.sheet-check h4 { margin: 12px 0 4px; font-size: 13px; }
table.audit-table td { text-align: left; white-space: normal; vertical-align: top; }
table.audit-table td.num, table.audit-table th:nth-child(3), table.audit-table th:nth-child(4), table.audit-table th:nth-child(5) { text-align: right; }
.lp-issue { outline: 2px solid #e0533f; outline-offset: -2px; position: relative; }
.lp-flag { color: #c62828; font-weight: 700; margin-right: 3px; }
td.lp-mismatch { color: #c62828; font-weight: 700; }
.lp-app-pts { font-size: 10px; font-weight: 600; white-space: nowrap; }
.lp-status .badge { margin: 1px 0; }

/* ---------- builder ---------- */
.builder { position: sticky; top: 12px; }
.builder h3 { display: flex; justify-content: space-between; }
/* My picks: the same four columns on every row, so logos, percentages and badges line up. */
.pick-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 46px 54px; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--line); }
.pr-icon { display: flex; justify-content: center; }
.pr-icon .ti-logo { width: 28px; height: 28px; }
.pr-team { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pr-name, .pr-opp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-opp { color: var(--muted); font-size: 12px; }
.pr-pct { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pr-act { display: flex; justify-content: center; }
.pr-locked { font-size: 10px; }
.pick-row .x { padding: 0 8px; }
.big { font-size: 26px; font-weight: 800; }
.stat { display: flex; justify-content: space-between; margin: 6px 0; }
.autopick { width: 100%; margin-top: 10px; }
.autopick-goal { font-size: 11px; text-align: center; margin-top: 4px; }
.empty-slot { color: var(--muted); padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ---------- tables ---------- */
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th { cursor: pointer; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
table.data td:first-child, table.data th:first-child { text-align: left; }

textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field input[type=text], .field input[type=password], .field select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.result { margin-top: 10px; font-size: 13px; }
.sheet-card { margin-bottom: 12px; }
.sheet-card #sheetInfo { margin-bottom: 10px; }
.result ul { margin: 4px 0; padding-left: 18px; }

.week-card { margin-bottom: 12px; }
.hist-summary { margin-bottom: 14px; }
.hist-summary h3 select { margin-left: 6px; font-weight: 600; }
table.hist-compare { border-collapse: collapse; width: 100%; max-width: 520px; font-size: 13px; font-variant-numeric: tabular-nums; }
table.hist-compare th, table.hist-compare td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.hist-compare th:first-child, table.hist-compare td:first-child { text-align: left; color: var(--muted); }
.hist-note { font-size: 12px; margin: 10px 0 0; }
.hist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .hist-grid { grid-template-columns: 1fr; } }
.h-title { font-size: 13px; margin-bottom: 4px; }
/* Fixed column widths so scores line up in the same place every week. */
table.hist-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.hist-table col.c-pick { width: 42%; }
table.hist-table col.c-score { width: 44%; }
table.hist-table col.c-res { width: 14%; }
table.hist-table td { padding: 4px 6px; border-bottom: 1px dashed var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.hist-table tr.shared td { background: var(--pick-bg); }
td.h-score { color: var(--muted); }
td.h-score .sc { display: grid; grid-template-columns: 3em 1.8em 1.2em 1.8em 3em; align-items: center; }
td.h-score .sc-num { text-align: right; color: var(--ink); }
td.h-score .sc-sep { text-align: center; }
td.h-score .sc-team:last-child { padding-left: 6px; }
td.h-res { text-align: center; }
.week-card h3 { display: flex; justify-content: space-between; align-items: center; }
.res-W { color: var(--good); font-weight: 700; }
.res-L { color: var(--bad); font-weight: 700; }
.res-P { color: var(--warn); font-weight: 700; }

picture { display: contents; }  /* logo wrapper: let the <img> size itself */
