/* ==========================================================================
   Crank the Numbers! — FastHTML Global Styles
   Mirrors Streamlit's default dark theme as closely as possible.
   ========================================================================== */

:root {
    /* ── Streamlit dark-theme palette ──
       Streamlit uses exactly two background tones:
         • backgroundColor:          #0e1117
         • secondaryBackgroundColor:  #262730
       Everything else derives from those.                                    */
    --bg-primary: #0e1117;
    --bg-secondary: #262730;
    --bg-sidebar: #262730;      /* sidebar = secondaryBackgroundColor          */
    --bg-card: #262730;         /* cards / inputs / table header               */

    --text-primary: #fafafa;
    --text-secondary: #c2c6cc;
    --text-muted: #808495;

    --accent: #ff4b4b;          /* Streamlit red (used sparingly)              */
    --accent-hover: #ff6e6e;
    --link: #4a9eff;            /* hyperlinks                                  */
    --link-hover: #74b3ff;

    --border: rgba(250, 250, 250, 0.1);
    --border-focus: rgba(74, 158, 255, 0.5);

    --success: #09ab3b;
    --warning: #faca2b;
    --error: #ff4b4b;

    /* Layout */
    --sidebar-width: 21rem;     /* Streamlit default ≈ 336 px                 */
    --content-max-width: 1400px;
}

/* ── NO light-mode override — always dark, like Streamlit ─────────────── */

/* ==========================================================================
   Reset & base
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    /* Source Sans 3 (the Google-Fonts rename of Source Sans Pro) */
    font-family: "Source Sans 3", "Source Sans Pro", -apple-system,
                 BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100%;
}

/* Dark scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #777;
}

a {
    color: var(--link);
    text-decoration: none;
}
a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* ==========================================================================
   Layout: Sidebar + Main
   ========================================================================== */

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.sidebar {
    background: var(--bg-sidebar);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: none;            /* Streamlit has no visible border          */
}

.sidebar-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-header .version {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Sidebar navigation (mimics Streamlit's auto-page nav) */

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.5rem;
}

.sidebar nav a {
    display: block;
    padding: 0.45rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    transition: background 0.12s, color 0.12s;
}

.sidebar nav a:hover {
    background: rgba(151, 166, 195, 0.15);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar nav a.active {
    background: rgba(151, 166, 195, 0.25);
    color: var(--text-primary);
    font-weight: 600;
}

/* Sidebar filter section below the nav */

.sidebar-form {
    margin: 0;
    padding: 0;
}

.sidebar-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

/* ── Main content ──────────────────────────────────────────────────────── */

.main-content {
    padding: 2rem 3rem;
    max-width: var(--content-max-width);
    width: 100%;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1 { font-size: 2rem;   font-weight: 700; margin-bottom: 0.5rem; color: var(--text-primary); }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.4rem; }

p  { margin-bottom: 0.75rem; }
ul, ol { margin: 0.25rem 0 0.75rem 1.5rem; }
li { margin-bottom: 0.25rem; }

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ==========================================================================
   Form Controls (Streamlit-inspired)
   ========================================================================== */

.form-group {
    margin-bottom: 0.85rem;
}

.form-group > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-group .help-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── Radio pills (horizontal, Streamlit-style for sidebar radios) ──── */

.radio-group {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--bg-primary);
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-group label {
    flex: 1 1 0;
    text-align: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    transition: background 0.12s, color 0.12s;
    margin-bottom: 0;
    white-space: nowrap;
}

.radio-group label:last-of-type {
    border-right: none;
}

.radio-group label:hover {
    background: rgba(151, 166, 195, 0.1);
    color: var(--text-primary);
}

.radio-group input[type="radio"]:checked + label {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

/* ── Select / text / number inputs ─────────────────────────────────── */

select,
input[type="text"],
input[type="number"],
input[type="search"],
input[type="date"] {
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-family: inherit;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

/* caret for <select> */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23808495'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2rem;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px var(--border-focus);
}

/* date input dark scheme helpers */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

/* Multi-select (native) – make it look decent in dark mode */
select[multiple] {
    background-image: none;
    padding: 0.25rem;
    min-height: 4.5rem;
}

select[multiple] option {
    padding: 0.3rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 1px;
    color: var(--text-primary);
    background: transparent;
}

select[multiple] option:checked {
    background: var(--accent) linear-gradient(0deg, var(--accent) 0%, var(--accent) 100%);
    color: white;
}

select[multiple] option:hover {
    background: rgba(151, 166, 195, 0.15);
}

/* ── Checkbox ──────────────────────────────────────────────────────── */

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.checkbox-group input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.checkbox-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    background: transparent;
    color: var(--text-primary);
    text-align: center;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.btn-danger {
    border-color: #d9534f;
    color: #d9534f;
}

.btn-danger:hover {
    background: #d9534f;
    border-color: #d9534f;
    color: white;
}

.btn-full {
    width: 100%;
}

/* ── Confirmed rider chip in comparison zone ───────────────────────── */

.confirmed-rider-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Range slider ──────────────────────────────────────────────────── */

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ==========================================================================
   Cards & Metrics (st.metric-like)
   ========================================================================== */

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
}

.metric-card .metric-label {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-card .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.15rem;
    line-height: 1.2;
}

/* ==========================================================================
   Tables (st.dataframe-like)
   ========================================================================== */

.data-table-container {
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-primary);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--text-primary);
    background: rgba(151, 166, 195, 0.12);
}

.data-table th .sort-indicator {
    font-size: 0.65rem;
    opacity: 0.7;
}

.data-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(250, 250, 250, 0.05);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: rgba(151, 166, 195, 0.08);
}

/* Alternating rows — subtle, like st.dataframe */
.data-table tbody tr:nth-child(even) {
    background: rgba(250, 250, 250, 0.015);
}
.data-table tbody tr:nth-child(even):hover {
    background: rgba(151, 166, 195, 0.08);
}

.data-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Chart container
   ========================================================================== */

.chart-container {
    width: 100%;
    min-height: 400px;
    margin: 0.75rem 0;
    overflow: hidden;
    position: relative;
}

/* Force Plotly SVGs to clip their contents — in HTML context, SVG
   elements default to overflow:visible which lets shapes at the
   paper boundary (like race-day vlines) leak past the viewBox. */
.chart-container svg {
    overflow: hidden !important;
}

.chart-container .js-plotly-plot {
    width: 100% !important;
}

/* Ensure each lazy-loaded section clips its contents so Plotly
   charts (especially SVG shapes like race-day vlines) never
   visually bleed into adjacent page sections.
   NOTE: #breakdown-section is excluded because it contains a
   Tom Select dropdown that must overflow the section boundary. */
#stacked-section,
#radar-section {
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   HTMX loading indicator
   ========================================================================== */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.loading-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(250, 250, 250, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

/* fade-in for HTMX-swapped content */
.htmx-added {
    animation: fadeIn 0.15s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ==========================================================================
   Details/Summary (replaces Streamlit expander)
   ========================================================================== */

details {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    margin: 1rem 0;
    background: var(--bg-card);
}

details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    list-style: none;
    user-select: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: "▶ ";
    font-size: 0.65rem;
    margin-right: 0.35rem;
    display: inline-block;
    transition: transform 0.15s;
}

details[open] summary::before {
    content: "▼ ";
}

details[open] > :not(summary) {
    margin-top: 0.5rem;
}

/* ==========================================================================
   Grid helpers
   ========================================================================== */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

.controls-row {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        padding: 1rem;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==========================================================================
   Messages / Alerts
   ========================================================================== */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin: 0.75rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.alert-info {
    background: rgba(74, 158, 255, 0.08);
    border: 1px solid rgba(74, 158, 255, 0.25);
    color: #7db9ff;
}

.alert-error {
    background: rgba(255, 75, 75, 0.08);
    border: 1px solid rgba(255, 75, 75, 0.25);
    color: var(--error);
}

.alert-warning {
    background: rgba(250, 202, 43, 0.08);
    border: 1px solid rgba(250, 202, 43, 0.25);
    color: var(--warning);
}

.alert-success {
    background: rgba(9, 171, 59, 0.08);
    border: 1px solid rgba(9, 171, 59, 0.25);
    color: var(--success);
}

/* ==========================================================================
   Tom Select — dark theme overrides
   ========================================================================== */

.ts-wrapper.multi .ts-control {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    min-height: 2.25rem;
}

.ts-wrapper.multi .ts-control:focus-within,
.ts-wrapper.multi.focus .ts-control {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.15);
}

.ts-wrapper .ts-control > input {
    color: var(--text-primary) !important;
}

.ts-wrapper .ts-control > input::placeholder {
    color: var(--text-muted) !important;
}

.ts-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-primary);
    margin-top: 2px;
}

.ts-dropdown .option {
    padding: 0.4rem 0.75rem;
    color: var(--text-primary);
}

.ts-dropdown .option:hover,
.ts-dropdown .active {
    background: rgba(74, 158, 255, 0.15);
    color: var(--text-primary);
}

.ts-wrapper .item {
    background: rgba(74, 158, 255, 0.2) !important;
    border: 1px solid rgba(74, 158, 255, 0.4) !important;
    color: var(--text-primary) !important;
    border-radius: 0.25rem !important;
    padding: 0.1rem 0.5rem !important;
    font-size: 0.8rem;
}

.ts-wrapper .item .remove {
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 1rem;
}

.ts-wrapper .item .remove:hover {
    color: var(--error) !important;
}

/* Hide the default native border when Tom Select is active */
.ts-wrapper.multi .ts-control > select {
    display: none;
}

/* ==========================================================================
   Section loading placeholder
   ========================================================================== */

.section-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Race Analysis — Creative Redesign
   ========================================================================== */

/* ── Race Hero Card ────────────────────────────────────────────────── */

.race-hero {
    background: linear-gradient(135deg, rgba(38, 39, 48, 0.9) 0%, rgba(14, 17, 23, 0.95) 100%);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.race-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #ff8c42, #ffd166, var(--accent));
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.race-hero-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.race-hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.race-hero-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Classification Badge ──────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.badge-1uwt  { background: rgba(255, 215, 0, 0.2);   color: #FFD700; border: 1px solid rgba(255, 215, 0, 0.4);  }
.badge-2uwt  { background: rgba(192, 192, 192, 0.15); color: #C0C0C0; border: 1px solid rgba(192, 192, 192, 0.3); }
.badge-1hc   { background: rgba(205, 127, 50, 0.15);  color: #CD7F32; border: 1px solid rgba(205, 127, 50, 0.3);  }
.badge-2hc   { background: rgba(184, 115, 51, 0.15);  color: #B87333; border: 1px solid rgba(184, 115, 51, 0.3);  }
.badge-pro   { background: rgba(74, 158, 255, 0.12);  color: #4A9EFF; border: 1px solid rgba(74, 158, 255, 0.3);  }
.badge-other { background: rgba(128, 132, 149, 0.12); color: #808495; border: 1px solid rgba(128, 132, 149, 0.3); }

/* ── Metric cards — vibrant variant for hero ─────────────────────── */

.race-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.race-metric {
    background: rgba(14, 17, 23, 0.6);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: center;
    transition: border-color 0.2s;
}

.race-metric:hover {
    border-color: rgba(74, 158, 255, 0.4);
}

.race-metric .metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}


/* ==========================================================================
   Tabs
   ========================================================================== */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}

.tab-btn {
    padding: 0.6rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--link);
    border-bottom-color: var(--link);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}


/* ==========================================================================
   Startlist Prediction
   ========================================================================== */

.startlist-textarea {
    width: 100%;
    min-height: 260px;
    max-height: 500px;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    resize: vertical;
    transition: border-color 0.2s;
}

.startlist-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.startlist-textarea::placeholder {
    color: var(--text-muted);
}

.startlist-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    align-items: center;
}

.match-summary {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.match-stat {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.match-stat strong {
    color: var(--text-primary);
}

.unmatched-list {
    background: rgba(255, 75, 75, 0.08);
    border: 1px solid rgba(255, 75, 75, 0.25);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.unmatched-list h4 {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    color: var(--accent);
}

.unmatched-list ul {
    margin: 0;
    padding-left: 1.25rem;
}

.unmatched-list li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Remove button in prediction table */
.remove-cell {
    cursor: pointer;
    color: var(--text-muted);
    text-align: center;
    font-size: 1.1rem;
    user-select: none;
    padding: 0 0.3rem;
    transition: color 0.15s;
}
.remove-cell:hover {
    color: var(--danger, #e74c3c);
}
#prediction-data-table th:last-child {
    width: 2rem;
    min-width: 2rem;
}

.race-metric .metric-label {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

.race-metric .metric-value.accent {
    color: var(--accent);
}

.race-metric .metric-value.success {
    color: var(--success);
}

/* ── View Toolbar — pill-style segmented controls ─────────────────── */

.view-toolbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.view-toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toolbar .toolbar-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.view-toolbar .toolbar-separator {
    width: 1px;
    height: 1.5rem;
    background: var(--border);
}

/* ── Section headings with icons ──────────────────────────────────── */

.section-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

.section-heading .section-icon {
    font-size: 1.2rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* ── View mode chips (above charts) ──────────────────────────────── */

.chart-mode-pills {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--bg-primary);
}

.chart-mode-pills .pill {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.12s;
    text-decoration: none;
}

.chart-mode-pills .pill:last-child {
    border-right: none;
}

.chart-mode-pills .pill:hover {
    color: var(--text-primary);
    background: rgba(151, 166, 195, 0.08);
}

.chart-mode-pills .pill.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

/* ── Race-list tab row ────────────────────────────────────────────── */

.race-overview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.race-overview-header .chart-mode-pills {
    flex-shrink: 0;
}

/* ── Terrain legend (inline) ──────────────────────────────────────── */

.terrain-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.5rem 0;
}

.terrain-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.terrain-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ── Animated transition for sections ─────────────────────────────── */

.race-section-enter {
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Empty state ──────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state .empty-text {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.empty-state .empty-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}
