/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Design tokens — Fantasy Football Predictor design system ("midnight" default).
   Midnight blue-black elevation ramp, one electric-blue brand accent, cyan
   secondary; green is decoupled from the brand and kept purely semantic
   (positive deltas / success). Position + model hues are categorical — each
   keeps its hue everywhere it appears. */
:root {
    /* ---- Surfaces (midnight blue-black ramp, lightest = most raised) ---- */
    --bg-primary: #070b14;     /* page background */
    --bg-secondary: #0e1422;   /* raised panels, header, cards bar */
    --bg-tertiary: #070b14;    /* recessed chip/code fill */
    --bg-card: #121a2c;        /* inset cards / meta badges */
    --bg-hover: #19223a;       /* row + control hover, headshot placeholder */
    --border: #232d47;         /* hairline borders, dividers */

    /* ---- Text ---- */
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #6b7280;

    /* ---- Accent: primary = electric blue (brand), secondary = electric cyan ---- */
    --accent: #3d8bff;
    --accent-dim: rgba(61, 139, 255, 0.15);
    --accent-secondary: #22d3ee;
    --accent-secondary-dim: rgba(34, 211, 238, 0.15);
    --glow-accent: 0 0 16px rgba(61, 139, 255, 0.38);

    /* Positive / success stays GREEN, decoupled from the brand accent. */
    --positive: #22c55e;
    --positive-dim: rgba(34, 197, 94, 0.15);

    /* ---- Semantic status ---- */
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.15);
    --yellow: #eab308;
    --yellow-dim: rgba(234, 179, 8, 0.12);
    --amber: #f59e0b;

    /* ---- Position accents (text + 15% tinted fill) ---- */
    --pos-qb: #f87171;   --pos-qb-bg: rgba(239, 68, 68, 0.15);
    --pos-rb: #4ade80;   --pos-rb-bg: rgba(34, 197, 94, 0.15);
    --pos-wr: #60a5fa;   --pos-wr-bg: rgba(59, 130, 246, 0.15);
    --pos-te: #facc15;   --pos-te-bg: rgba(234, 179, 8, 0.15);
    --pos-k:  #c084fc;   --pos-k-bg:  rgba(168, 85, 247, 0.15);
    --pos-dst:#fb923c;   --pos-dst-bg:rgba(244, 114, 57, 0.15);

    /* ---- Model series (chart lines + prediction columns) ---- */
    --model-ridge: #3b82f6;
    --model-nn: #22c55e;
    --model-attn-nn: #a855f7;
    --model-lgbm: #f59e0b;
    --model-nflcom: #06b6d4;
    --model-rotowire: #ec4899;
    --model-actual: #e8eaed;

    /* ---- Scrims ---- */
    --scrim: rgba(7, 11, 20, 0.8);          /* modal overlay */
    --scrim-loading: rgba(7, 11, 20, 0.92); /* loading overlay */

    /* ---- Typography (system stacks only — no webfonts) ---- */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* ---- Type scale / weights / tracking (design-system) ---- */
    --font-size-2xs: 10px;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-h3: 17px;
    --font-size-h2: 20px;
    --font-size-xl: 22px;
    --font-size-2xl: 24px;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --tracking-logo: -0.5px;
    --tracking-label: 0.8px;

    /* ---- Spacing scale (loose 4px rhythm with half-steps) ---- */
    --space-1: 4px;
    --space-1-5: 6px;
    --space-2: 8px;
    --space-2-5: 10px;
    --space-3: 12px;
    --space-3-5: 14px;
    --space-4: 16px;
    --space-4-5: 18px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;

    /* ---- Motion / stacking ---- */
    --transition-fast: 0.15s;
    --transition: 0.2s;
    --ease: ease;
    --z-menu: 30;

    /* ---- Radius / shadow / structure ---- */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 20px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --content-max: 1400px;
}

/* ---- OLED "pitch black" night mode (html[data-theme="oled"]) — pure-black
   page eased for eye comfort: panels a hair above black, structure carried by
   dim hairlines, inputs on a subtle gray fill, brightest text softened to cut
   halation. The electric-blue accent and every categorical (position / model)
   + status color are kept. Toggled by the header sun/moon button; persisted
   in localStorage("ffp-theme") and applied pre-paint by an inline script. ---- */
:root[data-theme="oled"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #000000;
    --bg-card: #1a1a1a;
    --bg-hover: #232323;
    --border: #2a2a2a;
    --text-primary: #dcdee3;
    --accent-dim: rgba(61, 139, 255, 0.18);
    --glow-accent: 0 0 14px rgba(61, 139, 255, 0.36);
    --scrim: rgba(0, 0, 0, 0.85);
    --scrim-loading: rgba(0, 0, 0, 0.92);
}

/* Drop the midnight halo so the OLED page background stays genuinely black. */
:root[data-theme="oled"] body {
    background-image: none;
}

/* OLED inputs get subtle gray fills (vs pure black) so they read gently. */
:root[data-theme="oled"] .search-box input,
:root[data-theme="oled"] select,
:root[data-theme="oled"] .filter-group input[type="number"] {
    background-color: var(--bg-card);
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    /* Midnight atmosphere: a faint electric-blue halo bleeding from the top.
       Sits behind the solid card fills, so only gutters/margins catch it. */
    background-image: radial-gradient(85% 55% at 50% -10%, rgba(61, 139, 255, 0.10), transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease;
}

/* === Public policy/support pages === */
.policy-page {
    width: min(860px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.policy-back {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

.policy-card {
    margin-top: 18px;
    padding: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.policy-kicker {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.policy-card h1 {
    margin-top: 6px;
    font-size: 32px;
    line-height: 1.15;
}

.policy-card h2 {
    margin-top: 24px;
    margin-bottom: 8px;
    font-size: 18px;
}

.policy-card p,
.policy-card li {
    color: var(--text-secondary);
}

.policy-card p {
    margin-top: 12px;
}

.policy-card ul {
    margin: 10px 0 0 22px;
}

.policy-card a {
    color: var(--accent);
}

.policy-updated {
    color: var(--text-muted);
    font-size: 13px;
}

/* === Header === */
.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    min-width: 0;
    gap: 12px;
}

.header-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    max-width: 100%;
    gap: 16px;
}

.scoring-toggle.pill-group {
    flex-wrap: nowrap;
    gap: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
}

.scoring-toggle .pill {
    padding: 5px 12px;
    font-size: 12px;
    border: none;
    border-radius: 18px;
    background: transparent;
    color: var(--text-muted);
}

.scoring-toggle .pill:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.scoring-toggle .pill.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
    text-shadow: var(--glow-accent);
    white-space: nowrap;
}

/* Theme toggle (sun / moon) — icon button left of the scoring switch. Both
   icons stay visible, slash-divided: the active mode lights up in the brand
   accent while the other dims — so it reads as a mode switch AND shows which
   mode is currently on. */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    flex: 0 0 auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
    display: block;
}

.theme-toggle .theme-ico {
    display: inline-flex;
    color: var(--text-muted);
    opacity: 0.45;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.theme-toggle .theme-ico.is-active {
    color: var(--accent);
    opacity: 1;
}

.theme-toggle .theme-divider {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
    opacity: 0.55;
    user-select: none;
}

/* Smooth cross-fade of the big surfaces when the color theme flips. */
.header,
.nav-tabs,
.filters,
.table-container,
.metric-card,
.pos-model-card,
.approach-banner {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.search-box {
    position: relative;
    width: 280px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* === Nav Tabs === */
.nav-tabs {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    /* Seven tabs overflow narrow screens; scroll horizontally instead of
       wrapping into a ragged second row. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 0 0 auto;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* === Loading === */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--scrim-loading);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-content p {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.error-message {
    color: var(--red);
    text-align: center;
    padding: 24px 16px;
    font-size: 14px;
}

/* Per-position degradation notice — populated by loadPredictions() in
   static/js/app.js when /api/predictions returns a non-empty
   degraded_positions list. Scoped `.hidden` (not a global utility) so
   toggling visibility doesn't collide with other elements. */
.degraded-banner {
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.35);
    border-left: 3px solid rgb(234, 179, 8);
    color: rgb(234, 179, 8);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin: 0 0 12px;
}

.degraded-banner.hidden {
    display: none;
}

/* Homepage (Next Week) projections banner — informational, not a warning. */
.homepage-banner {
    background: rgba(61, 139, 255, 0.10);
    border: 1px solid rgba(61, 139, 255, 0.30);
    border-left: 3px solid var(--accent);
    color: var(--text-muted);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin: 0 0 12px;
}

.homepage-banner.hidden {
    display: none;
}

/* K/DST chips on the homepage are "coming soon" until those pipelines land. */
.pill:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.col-matchup {
    white-space: nowrap;
}

.col-total {
    text-align: right;
}

.loading-sub {
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

/* === Main Content === */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

.view { display: none; }
.view.active { display: block; }

/* === Filters === */
.filters-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.filters-row-bottom {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.pill {
    padding: 7px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.pill.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

select {
    padding: 7px 32px 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa0b0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

select:focus {
    border-color: var(--accent);
}

.filter-group input[type="number"] {
    width: 90px;
    padding: 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.filter-group input[type="number"]:focus {
    border-color: var(--accent);
}

.column-filter {
    position: relative;
}

.column-filter-button {
    min-width: 128px;
    padding: 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.column-filter-button::after {
    content: "▾";
    float: right;
    color: var(--text-muted);
}

.column-filter-button:focus {
    outline: none;
    border-color: var(--accent);
}

.column-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    width: 190px;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.column-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}

.column-filter-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.column-filter-option input {
    accent-color: var(--accent);
}

/* === Filter Meta === */
.filter-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-end;
}

.meta-badge {
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* === Results Info === */
.results-info {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* === Tables === */
.table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

th.sortable {
    cursor: pointer;
    transition: color 0.2s;
}

th.sortable:hover {
    color: var(--text-primary);
}

th.active-sort {
    color: var(--accent);
}

.sort-arrow {
    font-size: 10px;
    margin-left: 4px;
}

tbody td {
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    transition: background 0.15s;
    cursor: pointer;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.col-rank {
    width: 40px;
    color: var(--text-muted);
    text-align: center;
}

.col-player { min-width: 200px; }

.col-pos, .col-team, .col-week, .col-games {
    text-align: center;
}

.col-actual, .col-pred, .col-delta {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-headshot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    /* Slightly lighter than the page bg so the (often dark-jersey) cutout pops. */
    background: var(--bg-hover);
    object-fit: cover;
    flex-shrink: 0;
}

.player-team-logo {
    object-fit: contain;
    padding: 4px;
}

.player-name {
    font-weight: 500;
}

.pos-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.pos-QB { background: var(--pos-qb-bg); color: var(--pos-qb); }
.pos-RB { background: var(--pos-rb-bg); color: var(--pos-rb); }
.pos-WR { background: var(--pos-wr-bg); color: var(--pos-wr); }
.pos-TE { background: var(--pos-te-bg); color: var(--pos-te); }
.pos-K { background: var(--pos-k-bg); color: var(--pos-k); }
.pos-DST { background: var(--pos-dst-bg); color: var(--pos-dst); }

.delta-positive {
    color: var(--positive);
}

.delta-negative {
    color: var(--red);
}

.delta-neutral {
    color: var(--text-muted);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    /* Many pages (the full dataset is thousands of player-weeks) produce a long
       button run; wrap to additional rows on narrow screens instead of pushing
       the whole page wider than the viewport. */
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* === Metrics === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.metric-card-header {
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.metric-card-body {
    padding: 14px 18px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.metric-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* === Charts === */
.section-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    margin-top: 8px;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.chart-box {
    min-width: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
}

.chart-box.wide {
    margin-bottom: 28px;
}

/* Modal player chart: fixed-height box so the canvas (maintainAspectRatio:false)
   fills it at a readable height on every screen size instead of collapsing to a
   thin width/2 strip. */
.modal .chart-box {
    position: relative;
    height: 340px;
    padding: 16px;
}

.modal .chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Shown in place of the player chart when a player has no prior-season game log
   to plot (e.g. a rookie / backup surfaced on the upcoming-week homepage who
   isn't in the backtest results). Centered in the fixed-height .modal .chart-box. */
.modal-note {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 0 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}
.modal-note.hidden {
    display: none;
}

/* === Modal === */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 28px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-right: 28px;
}

.modal-header > div { min-width: 0; }

.modal-headshot {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--bg-hover);
    object-fit: cover;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.modal-pos-team {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 20px;
}

.modal-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.modal-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

/* === Responsive === */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 12px 16px;
    }
    .header-right {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 8px;
    }
    .logo { white-space: normal; }
    .theme-toggle { height: 44px; justify-content: center; }
    .search-box { width: 100%; grid-column: 1 / -1; }
    .search-box input { min-height: 44px; font-size: 16px; }
    .scoring-toggle.pill-group { min-width: 0; }
    .scoring-toggle .pill { flex: 1; min-height: 38px; padding: 7px 6px; }
    .pill, select, .field-select, .text-field, .dropdown-trigger { min-height: 44px; }
    select, .field-select, .text-field, .filter-group input[type="number"] { font-size: 16px; }
    .filter-meta { margin-left: 0; }
    .charts-row { grid-template-columns: 1fr; }
    .subtitle { display: none; }

    /* Tighter gutters so tables/cards use the full narrow width. */
    .nav-tabs { padding: 0 12px; }
    .main-content { padding: 16px 12px 48px; }
    .filters-bar { padding: 12px; }

    /* Denser table cells so more columns fit before horizontal scroll kicks in. */
    thead th { padding: 10px 10px; }
    tbody td { padding: 9px 10px; font-size: 13px; }
    .col-player { min-width: 150px; }
    .player-headshot { width: 32px; height: 32px; }

    /* Modal: use nearly the full viewport and a slightly shorter chart. */
    .modal-content { width: 95%; padding: 20px 16px; max-height: 90vh; max-height: calc(100dvh - 24px); overscroll-behavior: contain; }
    .modal-headshot { width: 64px; height: 64px; }
    .modal-header h2 { font-size: 19px; }
    .modal-stat-value { font-size: 20px; }
    .modal .chart-box { height: 280px; padding: 12px; }
}

/* === Approach Banner === */
.approach-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px;
    background: var(--accent-dim);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.approach-icon {
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}

.approach-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

.approach-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* === Position Model Breakdown === */
.pos-model-section {
    margin-bottom: 28px;
}

.pos-model-section > .pill-group {
    margin-bottom: 16px;
}

.pos-model-detail {
    min-height: 100px;
}

.pos-model-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.pos-model-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pos-model-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.pos-model-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.pos-model-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-top: 18px;
}

.pos-model-section-label:first-of-type {
    margin-top: 0;
}

/* Target table inside position card */
.pos-model-table-wrap {
    border-radius: var(--radius);
}

.pos-model-table th {
    padding: 8px 12px;
    font-size: 10px;
}

.pos-model-table td {
    padding: 8px 12px;
    font-size: 13px;
}

.pos-model-table .tm-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.pos-model-table .tm-formula {
    color: var(--text-muted);
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.pos-model-table .tm-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.pos-model-table .tm-total-row td {
    border-top: 2px solid var(--border);
}

/* Feature badges */
.feature-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.feature-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Architecture info */
.arch-info {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.arch-val {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--accent-secondary);
    font-weight: 500;
}

.pos-model-empty {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

/* === Loading state for table re-fetch === */
.table-container.loading { opacity: 0.5; pointer-events: none; transition: opacity 0.15s; }

/* === Model Architecture View === */
.arch-diagram {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 24px;
    overflow-x: auto;
    white-space: pre;
}
.arch-bullets {
    list-style: disc;
    padding-left: 22px;
    margin: 0 0 24px 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.7;
}
.arch-bullets li { margin-bottom: 4px; }
.arch-bullets strong { color: var(--text-primary); font-weight: 600; }
.arch-bullets code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 1px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-primary);
}

.arch-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    margin-bottom: 24px;
}
.arch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 900px;
}
.arch-table th,
.arch-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.arch-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.arch-table tbody tr:last-child td { border-bottom: none; }
.arch-table tbody tr:hover { background: var(--bg-primary); }
.arch-pos-cell { font-weight: 600; color: var(--accent); }

.arch-loading,
.arch-error {
    padding: 16px 18px;
    color: var(--text-secondary);
    font-size: 13px;
}
.arch-error { color: var(--pos-qb); }

#arch-feature-accordions {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    overflow: hidden;
    margin-bottom: 24px;
}
.arch-accordion { border-bottom: 1px solid var(--border); }
.arch-accordion:last-child { border-bottom: none; }
.arch-accordion summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background 0.15s;
    user-select: none;
}
.arch-accordion summary::-webkit-details-marker { display: none; }
.arch-accordion summary::after {
    content: "▸";
    color: var(--text-secondary);
    font-size: 12px;
    transition: transform 0.2s;
    margin-left: auto;
}
.arch-accordion[open] summary::after { transform: rotate(90deg); }
.arch-accordion summary:hover { background: var(--bg-primary); }
.arch-pos-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--accent);
    min-width: 48px;
}
.arch-pos-count {
    font-size: 12px;
    color: var(--text-secondary);
}
.arch-accordion-body {
    padding: 4px 18px 18px 18px;
    background: var(--bg-primary);
}
.arch-accordion-meta {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px 0 14px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    line-height: 1.6;
}
.arch-accordion-meta strong { color: var(--text-primary); font-weight: 600; }

.feature-category { margin-bottom: 14px; }
.feature-category:last-child { margin-bottom: 0; }
.feature-category-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.feature-category-count {
    color: var(--accent);
    font-weight: 500;
    margin-left: 4px;
}
.feature-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.feature-chip {
    display: inline-block;
    max-width: 100%;
    padding: 3px 9px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: var(--text-primary);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* === Wiki View === */
.wiki-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.wiki-sidebar {
    flex: 0 0 240px;
    position: sticky;
    top: calc(var(--header-height, 60px) + 20px);
    max-height: calc(100vh - var(--header-height, 60px) - 40px);
    max-height: calc(100dvh - var(--header-height, 60px) - 40px);
    overflow-y: auto;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.wiki-sidebar-group { margin-bottom: 16px; }
.wiki-sidebar-group:last-child { margin-bottom: 0; }
.wiki-sidebar-heading {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 8px 6px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.wiki-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.wiki-sidebar-list li { margin: 0; }
.wiki-sidebar-link {
    display: block;
    padding: 6px 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    border-left: 2px solid transparent;
    transition: background 0.15s, color 0.15s;
}
.wiki-sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.wiki-sidebar-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-dim);
    font-weight: 500;
}
.wiki-content {
    flex: 1 1 auto;
    min-width: 0;
    padding: 24px 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4,
.wiki-content h5,
.wiki-content h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
}
.wiki-content h1 { font-size: 24px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-top: 0; }
.wiki-content h2 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.wiki-content h3 { font-size: 17px; }
.wiki-content h4 { font-size: 15px; color: var(--text-secondary); }
.wiki-content p { margin: 0 0 14px 0; color: var(--text-primary); }
.wiki-content a { color: var(--accent-secondary); text-decoration: none; }
.wiki-content a:hover { text-decoration: underline; }
.wiki-content ul,
.wiki-content ol {
    margin: 0 0 14px 0;
    padding-left: 24px;
    color: var(--text-primary);
}
.wiki-content li { margin-bottom: 4px; }
.wiki-content strong { color: var(--text-primary); font-weight: 600; }
.wiki-content em { color: var(--text-primary); }
.wiki-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    padding: 1px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}
.wiki-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin: 0 0 16px 0;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-secondary);
}
.wiki-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}
.wiki-content blockquote {
    margin: 0 0 16px 0;
    padding: 8px 16px;
    border-left: 3px solid var(--accent);
    background: var(--accent-dim);
    color: var(--text-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.wiki-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 0 0 16px 0;
    font-size: 13px;
}
.wiki-content th,
.wiki-content td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    overflow-wrap: anywhere;
    vertical-align: top;
}
.wiki-content th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--bg-primary);
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
}
.wiki-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}
.wiki-content img { max-width: 100%; height: auto; }

@media (max-width: 768px) {
    /* Stretch (not the desktop flex-start) so the stacked content fills the
       column width; flex-start sized .wiki-content to its widest child (a long
       <pre>/table line) and overflowed the page. min-width:0 + the children's
       own overflow-x:auto then keep wide blocks scrolling inside the card. */
    .wiki-layout { flex-direction: column; align-items: stretch; }
    .wiki-sidebar {
        flex: 1 1 auto;
        position: static;
        max-height: none;
        width: 100%;
    }
    .wiki-content { width: 100%; padding: 16px; }
}

/* === Benchmark History tab === */
#history-table .col-history-pr { white-space: nowrap; width: 90px; }
#history-table .col-history-ts { white-space: nowrap; width: 150px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
#history-table .col-history-time { white-space: nowrap; width: 110px; font-variant-numeric: tabular-nums; }
#history-table .col-history-mae { vertical-align: top; }

.history-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.history-pill-pos {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}
.history-pill-skip { color: var(--text-secondary); }
.history-empty { color: var(--text-secondary); }
.history-link { color: var(--accent); text-decoration: none; }
.history-link:hover { text-decoration: underline; }
.history-link code { font-size: 12px; }
.history-link-disabled { color: var(--text-secondary); }
.history-link-disabled code { font-size: 12px; }

/* History controls (detailed mode + group-by-model checkbox) */
.history-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    margin: 12px 0;
}
.history-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}
.history-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}
.history-check-hint { color: var(--text-secondary); font-size: 12px; }

/* Detailed mode: expandable run rows + per-target breakdown panel */
tr.history-row-expandable { cursor: pointer; }
tr.history-row-expandable:hover { background: var(--bg-primary); }
.history-caret {
    display: inline-block;
    margin-right: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    transition: transform 0.12s ease;
}
tr.history-row-expandable.expanded .history-caret { transform: rotate(90deg); }

.history-detail-row[hidden] { display: none; }
.history-detail-row > td { background: var(--bg-primary); padding: 14px 16px; }
.history-detail-block { margin-bottom: 16px; }
.history-detail-block:last-child { margin-bottom: 0; }
.history-detail-pos { margin-bottom: 6px; }
.history-detail-block .pos-model-table { width: auto; min-width: 380px; }

/* Regression highlighting: tint a pill vs the same pos+model's prior run. The
   fill alpha is set inline per-pill (deeper = larger relative change); the class
   carries the border color and the dim fallback used by the legend swatch. An
   all-time-best value gets a solid blue that overrides the green/red tint. */
.history-pill-improve { border-color: var(--positive); background: var(--positive-dim); }
.history-pill-regress { border-color: var(--red); background: var(--red-dim); }
.history-pill-record { border-color: var(--accent-secondary); background: var(--accent-secondary-dim); }
.history-pill-best { font-weight: 700; }

/* Legend in the history controls. */
.history-legend {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.history-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
}
.history-legend-best { font-weight: 700; color: var(--text-primary); }
.history-legend-hint { font-style: italic; }

/* Retry button on the error state. */
.history-retry {
    margin-left: 8px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
}
.history-retry:hover { background: var(--accent-dim); }

@media (max-width: 768px) {
    .history-controls { gap: 12px; }
    #history-table { font-size: 13px; }
    #history-table .col-history-pr,
    #history-table .col-history-ts,
    #history-table .col-history-time { width: auto; }
    .history-pill { font-size: 11px; padding: 2px 6px; margin: 2px 3px 2px 0; }
    .history-detail-block .pos-model-table { min-width: 320px; }
}

/* Predictions tab: expandable row + per-stat breakdown sub-table */
tr.predictions-row-expandable { cursor: pointer; }
tr.predictions-row-expandable:hover { background: var(--bg-primary); }
.row-caret {
    display: inline-block;
    margin-right: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    transition: transform 0.12s ease;
}
tr.predictions-row-expandable.expanded .row-caret { transform: rotate(90deg); }
.predictions-detail-row[hidden] { display: none; }
.predictions-detail-row > td { background: var(--bg-primary); padding: 12px 16px; }
.breakdown-msg { color: var(--text-secondary); font-size: 13px; }
.breakdown-table { width: auto; min-width: 420px; border-collapse: collapse; }
.breakdown-table th,
.breakdown-table td { padding: 5px 14px; text-align: right; font-size: 13px; }
.breakdown-table th { color: var(--text-secondary); font-weight: 600; }
.breakdown-table .bd-stat { text-align: left; }
.breakdown-table tbody tr:hover { background: var(--bg-secondary); }

/* ---------------------------------------------------------------------------
   Comparison tab — model vs expert scoreboard (two tables + metric toggle)
   --------------------------------------------------------------------------- */
.comparison-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 4px 0 18px;
}
.comparison-metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}
.comparison-metric-hint { font-size: 13px; color: var(--text-secondary); }
.comparison-table-block { margin-bottom: 22px; }

/* Static info tables — opt out of the generic clickable-row affordance. */
.comparison-table tbody tr { cursor: default; }
.comparison-table tbody tr:hover { background: var(--bg-hover); }
.comparison-pos { font-weight: 600; color: var(--text-primary); }
.comparison-num { text-align: right; font-variant-numeric: tabular-nums; }
.comparison-table thead th.comparison-num { text-align: right; }
.comparison-empty { color: var(--text-muted); }
.comparison-best { color: var(--positive); font-weight: 700; }
/* Paired-interval verdict under each position: muted for a tie, emphasized when decided. */
.comparison-gap {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
    max-width: 22em;
}
.comparison-gap-decided { color: var(--text-secondary); font-weight: 600; }
.comparison-arch {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}
.comparison-notes { margin-top: 8px; }
.comparison-note-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}
.comparison-note-list li { margin-bottom: 6px; }
.comparison-note-list strong { color: var(--text-primary); }
.comparison-note-meta { color: var(--text-muted); font-style: italic; }
.comparison-link { color: var(--accent); text-decoration: none; }
.comparison-link:hover { text-decoration: underline; }
.comparison-reliability-sub {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}
.comparison-reliability-sub strong { color: var(--text-primary); }
.comparison-reliability-note {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* ---- Prediction intervals (80% floor–ceiling bands) ---- */
#comparison-intervals-block { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 18px; }
.intervals-intro { color: var(--text-secondary); font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.intervals-intro strong { color: var(--text-primary); }
.intervals-sub-header {
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-muted); margin-bottom: 6px;
}
/* Coverage cell: colored by how close to nominal 80% it lands. */
.interval-cov { font-weight: 700; }
.interval-cov-ok { color: var(--positive); }
.interval-cov-tight { color: var(--amber); }   /* under-covers — band too tight */
.interval-cov-wide { color: var(--accent-secondary); }  /* over-covers — band too wide */
.interval-cov-sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.interval-totals {
    font-size: 10px; color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 3px; padding: 0 3px; vertical-align: middle;
}

.intervals-examples-controls { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.intervals-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .intervals-cols { grid-template-columns: 1fr; } }
.intervals-col-head {
    font-weight: 600; color: var(--text-primary); font-size: 13px;
    margin-bottom: 10px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.intervals-empty { color: var(--text-muted); font-size: 13px; font-style: italic; }

.band-row { margin-bottom: 14px; }
.band-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.band-player { font-weight: 600; color: var(--text-primary); }
.band-week { color: var(--text-muted); }
.band-proj { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.band-track {
    position: relative; height: 12px; border-radius: 6px;
    background: var(--bg-primary); border: 1px solid var(--border);
}
.band-fill {
    position: absolute; top: 0; bottom: 0; background: var(--accent-dim);
    border-left: 2px solid var(--accent); border-right: 2px solid var(--accent);
    border-radius: 3px;
}
.band-median { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--text-secondary); }
.band-actual {
    position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%;
    transform: translate(-50%, -50%); border: 2px solid var(--bg-card);
}
.band-actual-in { background: var(--positive); }
.band-actual-out { background: var(--amber); }
.band-foot {
    display: flex; justify-content: space-between; font-size: 11px;
    color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums;
}
.band-actual-label.band-actual-in { color: var(--positive); }
.band-actual-label.band-actual-out { color: var(--amber); }


/* === Design-system filter bar v2 (dropdown menus, auto-fit rows, fields) ===
   Plain token-driven classes lifted from the design system's component CSS;
   consumed by the React views' Columns/Filters menus, Age/Class filters,
   the team labels and the stat blocks Timeline renders. */

.field-label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
    margin-bottom: var(--space-1-5);
}

.field-select {
    padding: 7px 32px 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa0b0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.field-select:focus { border-color: var(--accent); }

.text-field {
    padding: 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    outline: none;
    transition: border-color var(--transition);
}
.text-field:focus { border-color: var(--accent); }
.text-field::placeholder { color: var(--text-muted); }
.text-field[type="number"] { width: 90px; }

/* ---- Dropdown menu (multi-select checkbox popover) ---- */
.dropdown-menu { position: relative; display: inline-flex; }

.dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.45;
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    transition: border-color var(--transition) var(--ease);
}
.dropdown-trigger:hover,
.dropdown-trigger.open,
.dropdown-trigger:focus-visible { border-color: var(--accent); }

.dropdown-count {
    font-size: var(--font-size-xs);
    font-weight: var(--weight-semibold);
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: var(--radius-pill);
    padding: 1px 7px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.dropdown-caret {
    width: 11px;
    height: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition) var(--ease);
}
.dropdown-trigger.open .dropdown-caret { transform: rotate(180deg); }

.dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: var(--z-menu);
    min-width: 210px;
    max-height: 340px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-1-5);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dropdown-panel.align-right { left: auto; right: 0; }

.dropdown-header {
    font-size: var(--font-size-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
    padding: var(--space-1-5) var(--space-2-5) var(--space-2);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2-5);
    padding: 7px var(--space-2-5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    user-select: none;
    transition: background var(--transition) var(--ease), color var(--transition) var(--ease);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.is-locked { cursor: default; color: var(--text-muted); }
.dropdown-item.is-locked:hover { background: transparent; }

.dropdown-item input { position: absolute; opacity: 0; width: 0; height: 0; }

.dropdown-check {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition) var(--ease), border-color var(--transition) var(--ease), color var(--transition) var(--ease);
}
.dropdown-check svg { width: 11px; height: 11px; display: block; }
.dropdown-item input:checked + .dropdown-check {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}
.dropdown-item.is-locked input:checked + .dropdown-check {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
}

.dropdown-item-label { flex: 1; }
.dropdown-lock {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
}

/* ---- Adaptive one-row filter bar (auto-fit + pinned right menus) ---- */
.filters-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.filters-row .filter-group { flex: 0 0 auto; }
.filter-menus {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
}
.filters-row--measure {
    position: fixed;
    top: -9999px;
    left: 0;
    visibility: hidden;
    pointer-events: none;
    flex-wrap: nowrap;
    width: max-content;
}

@media (max-width: 768px) {
    /* Constrain live controls, keeping the off-screen copy at its intrinsic
       width so auto-fit measurements still describe the desktop row. */
    .filter-group select, .filter-group input { font-size: 16px; }
    .filters-row:not(.filters-row--measure) > .filter-group {
        min-width: 0;
        max-width: 100%;
    }
    .filters-row:not(.filters-row--measure) .filter-menus {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 8px;
        width: 100%;
        margin-left: 0;
    }
    .filters-row:not(.filters-row--measure) .filter-menus > .meta-badge {
        grid-column: 1 / -1;
        justify-self: start;
    }
    .filter-menus > .filter-group { min-width: 0; }
    .filter-menus .dropdown-menu { width: 100%; }
    .filter-menus .dropdown-trigger {
        width: 100%;
        justify-content: space-between;
        gap: 4px;
        padding: 7px 8px;
    }
    .filter-menus .dropdown-count { padding: 1px 4px; }
    .filter-menus .dropdown-panel { max-width: calc(100vw - 50px); }
    .filter-menus > .filter-group:first-of-type .dropdown-panel { left: 0; right: auto; }
}

/* ---- Stat-block readout (Timeline per-model MAE) ---- */
.stat-block { display: flex; flex-direction: column; gap: 2px; }
.stat-block-label {
    font-size: var(--font-size-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
}
.stat-block-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}
.stat-block-value.neutral { color: var(--text-primary); }
.stat-block-row { display: flex; gap: var(--space-6); }

/* ---- Team abbreviation + logo (logo matches surrounding text size) ---- */
.team-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.team-logo {
    width: 1.35em;
    height: 1.35em;
    object-fit: contain;
    flex-shrink: 0;
}


/* === Changelog & Timeline tab (design-system callout + release rail) === */

.callout {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}
.callout.accent {
    background: var(--accent-dim);
    border: 1px solid rgba(61, 139, 255, 0.25);
}
.callout.secondary {
    background: var(--accent-secondary-dim);
    border: 1px solid rgba(34, 211, 238, 0.25);
}
.callout-icon { flex-shrink: 0; margin-top: 2px; }
.callout.accent .callout-icon { color: var(--accent); }
.callout.secondary .callout-icon { color: var(--accent-secondary); }
.callout-title {
    font-size: 15px;
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-1);
}
.callout.accent .callout-title { color: var(--accent); }
.callout.secondary .callout-title { color: var(--accent-secondary); }
.callout-desc {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.5;
}

.timeline-track-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-7);
}
.timeline-track-card .stat-block-row {
    align-items: center;
    flex-wrap: wrap;
    row-gap: var(--space-4);
}
.timeline-track-card .meta-badge { margin-left: auto; }

.release-controls { margin-bottom: var(--space-4); }
.release-list { margin-bottom: var(--space-7); }
.release-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: var(--space-3);
}
.release-rail { display: flex; flex-direction: column; align-items: center; }
.release-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-top: 8px;
    flex: 0 0 auto;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 0 0 1px var(--border);
}
.release-line { width: 2px; flex: 1 1 auto; background: var(--border); margin: 4px 0; }
.release-item:last-child .release-line { display: none; }
.release-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-3);
}
.release-head {
    display: flex;
    align-items: center;
    gap: var(--space-2-5);
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
}
.release-title { font-size: var(--font-size-h3); font-weight: var(--weight-semibold); color: var(--text-primary); }
.release-model { font-size: var(--font-size-sm); color: var(--text-muted); }
.release-date { margin-left: auto; font-family: var(--font-mono); font-size: var(--font-size-sm); color: var(--text-muted); }
.release-summary { margin: 0; font-size: var(--font-size-base); color: var(--text-secondary); line-height: 1.5; }
.release-metrics { display: flex; gap: var(--space-6); margin-top: var(--space-3); }
.release-metric { display: flex; flex-direction: column; gap: 2px; }
.release-metric-label {
    font-size: var(--font-size-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
}
.release-metric-value {
    font-size: var(--font-size-md);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.winner-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-weight: var(--weight-semibold);
}
.winner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}
