/* F1 Analytics — High-Contrast Dark Theme
   Mobile-first, readable, precision-engineered.
   Built on Outfit (display) + JetBrains Mono (data).
   Design tokens: se core.css (kanonisk källa) */

/* ─── Base ─── */
html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-display);
    background: var(--bg-abyss);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Safe area for modern iPhones (notch/Dynamic Island) */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

html { overflow-x: hidden; }

/* Subtle grain texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(225, 6, 0, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(0, 212, 255, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ─── Layout Shell ─── */
/* Sidebar layout lives in core.css (.f1-sidebar) */

/* ─── Page Header ─── */
.page-header {
    padding: 36px 44px 28px;
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-carbon) 100%);
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 160px;
    height: 2px;
    background: linear-gradient(90deg, var(--f1-red), transparent);
}

.page-header h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    color: var(--text-bright);
    letter-spacing: -0.3px;
    line-height: 1.15;
}

.page-header h1 .accent {
    color: var(--f1-red);
}

.page-subtitle {
    font-family: var(--font-data);
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ─── Page Content ─── */
.page-content {
    flex: 1;
    padding: 36px 44px;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ─── Cards (enhancements beyond core.css) ─── */
/* ─── Driver link ─── */
.driver-link {
    text-decoration: none;
    color: inherit;
    transition: color var(--dur-fast);
}

.driver-link:hover {
    color: var(--f1-cyan) !important;
}

.driver-link:hover span {
    color: var(--f1-cyan) !important;
}

.card {
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: border-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}

.card:hover {
    border-color: var(--border-medium);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
}

.card-header h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-primary);
}

.card--accent {
    border-top: 2px solid var(--f1-red);
}

.card--cyan {
    border-top: 2px solid var(--f1-cyan);
}

.card--orange {
    border-top: 2px solid var(--f1-orange);
}

.card--green {
    border-top: 2px solid var(--f1-green);
}

.card-divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 0;
}

/* ─── Stat Blocks ─── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-4);
}

.stat-block {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    transition: all var(--dur-med) var(--ease-out);
}

.stat-block:hover {
    border-color: var(--f1-cyan);
    box-shadow: var(--shadow-glow-cyan);
    transform: translateY(-2px);
}

.stat-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--f1-cyan), transparent);
    opacity: 0;
    transition: opacity var(--dur-med);
}

.stat-block:hover::before {
    opacity: 1;
}

.stat-value .unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

.stat-delta {
    font-family: var(--font-data);
    font-size: 0.78rem;
    margin-top: 8px;
}

.stat-delta.positive { color: var(--f1-green); }
.stat-delta.negative { color: var(--f1-red); }

/* ─── Data Tables ─── */
.data-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

/* Ensure card-body wrapping tables is scrollable even without .data-table-wrap */
.card-body:has(.data-table),
.card-body:has(.hourly-table) {
    overflow-x: auto;
}

.data-table {
    font-size: 0.94rem;
}

.data-table th {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--f1-red);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--dur-fast);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr {
    transition: box-shadow var(--dur-fast), background var(--dur-fast);
}

.data-table tbody tr:hover {
    box-shadow: inset 3px 0 0 var(--f1-red);
    background: rgba(255, 255, 255, 0.05);
}

.data-table .pos {
    font-family: var(--font-data);
    font-weight: 700;
    color: var(--text-bright);
    min-width: 44px;
    width: 44px;
    text-align: center;
    white-space: nowrap;
}

.data-table .pos-1 { color: var(--pos-1); }
.data-table .pos-2 { color: var(--pos-2); }
.data-table .pos-3 { color: var(--pos-3); }

.data-table .time {
    font-family: var(--font-data);
    font-weight: 500;
    color: var(--text-bright);
}

.data-table .gap {
    font-family: var(--font-data);
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.team-color-bar {
    display: inline-block;
    width: 3px;
    height: 16px;
    border-radius: 2px;
    margin-right: 10px;
    vertical-align: middle;
}

/* ─── Team Badges ─── */
.team-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.team-redbull { background: #3671c6; color: white; }
.team-ferrari { background: #e8002d; color: white; }
.team-mercedes { background: #27f4d2; color: #0a0a0a; }
.team-mclaren { background: #ff8700; color: white; }
.team-astonmartin { background: #229971; color: white; }
.team-alpine { background: #ff87bc; color: #0a0a0a; }
.team-williams { background: #64c4ff; color: #0a0a0a; }
.team-rb { background: #6692ff; color: white; }
.team-sauber { background: #52e252; color: #0a0a0a; }
.team-haas { background: #b6babd; color: #0a0a0a; }

/* ─── Tyre Compounds ─── */
.compound {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-family: var(--font-data);
    font-size: 0.78rem;
    font-weight: 700;
    border: 2px solid;
}

.compound-soft { background: rgba(255, 51, 51, 0.15); border-color: var(--compound-soft); color: var(--compound-soft); }
.compound-medium { background: rgba(255, 242, 0, 0.12); border-color: var(--compound-medium); color: var(--compound-medium); }
.compound-hard { background: rgba(235, 235, 235, 0.1); border-color: var(--compound-hard); color: var(--compound-hard); }
.compound-inter { background: rgba(67, 176, 42, 0.15); border-color: var(--compound-inter); color: var(--compound-inter); }
.compound-wet { background: rgba(0, 103, 173, 0.2); border-color: var(--compound-wet); color: var(--compound-wet); }

/* ─── Buttons (F1-specific, beyond core.css/Bootstrap) ─── */
.btn {
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow-red);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary:hover {
    border-color: var(--f1-cyan);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
    border-color: var(--border-medium);
}

.btn-text {
    background: none;
    color: var(--text-secondary);
    padding: var(--space-2) var(--space-3);
}
.btn-text:hover {
    color: var(--text-bright);
}

.btn-icon {
    padding: var(--space-2);
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
    border-color: var(--border-medium);
}

.btn-sm { padding: 6px 14px; font-size: var(--fs-caption); }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ─── Race Countdown ─── */
.countdown-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 34px;
    position: relative;
    overflow: hidden;
}

.countdown-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--f1-red), var(--f1-orange), transparent);
}

.countdown-title {
    font-family: var(--font-data);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.countdown-event {
    font-weight: 800;
    font-size: 1.7rem;
    color: var(--text-bright);
    margin-bottom: 6px;
    line-height: 1.15;
}

.countdown-location {
    font-family: var(--font-data);
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.countdown-timer {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.countdown-unit {
    text-align: center;
}

.countdown-number {
    font-family: var(--font-data);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--f1-orange);
    line-height: 1;
    text-shadow: 0 0 40px rgba(255, 135, 0, 0.2);
}

.countdown-label {
    font-family: var(--font-data);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.countdown-separator {
    font-family: var(--font-data);
    font-size: 2.6rem;
    color: var(--text-dim);
    line-height: 1;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0.2; }
}

/* ─── Grid Layouts ─── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Prevent grid children from overflowing container */
.grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-auto > * {
    min-width: 0;
}

/* ─── Utility flex ─── */
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ─── Event Cards (Calendar) ─── */
.event-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all var(--dur-med) var(--ease-out);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.event-card:hover {
    border-color: var(--border-medium);
    background: var(--bg-elevated);
    transform: translateX(3px);
}

.event-round {
    font-family: var(--font-data);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dim);
    min-width: 48px;
    text-align: center;
    line-height: 1;
    transition: color var(--dur-med);
}

.event-card:hover .event-round {
    color: var(--f1-red);
}

.event-info {
    flex: 1;
    min-width: 0;
}

.event-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-bright);
    margin-bottom: 2px;
}

.event-location {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.event-date {
    font-family: var(--font-data);
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

.event-card.is-next {
    border-color: var(--f1-red);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--f1-red-dim) 100%);
}

.event-card.is-next .event-round {
    color: var(--f1-red);
}

.event-card.is-past {
    opacity: 0.45;
}

.event-card.is-past:hover {
    opacity: 0.75;
}

/* ─── News Items ─── */
.news-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    transition: all var(--dur-fast);
    display: flex;
    gap: 14px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}

.news-item:hover {
    border-color: var(--border-medium);
    background: var(--bg-elevated);
}

.news-item.breaking {
    border-left: 3px solid var(--f1-red);
}

.news-source {
    font-family: var(--font-data);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.news-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-bright);
    margin-bottom: 4px;
    line-height: 1.45;
}

.news-meta {
    font-family: var(--font-data);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ─── Analysis Charts ─── */
.chart-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    transition: border-color var(--dur-med);
}

.chart-container:hover {
    border-color: var(--f1-orange);
}

.chart-container img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    display: block;
}

/* ─── Driver Cards ─── */
.driver-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--dur-med) var(--ease-out);
    text-decoration: none;
    color: inherit;
}

.driver-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
    border-color: var(--border-medium);
}

.driver-card-color {
    height: 3px;
}

.driver-card-body {
    padding: 18px 20px;
}

.driver-card-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.driver-card-stat {
    font-size: var(--fs-caption);
}

.driver-number {
    font-family: var(--font-data);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-dim);
    line-height: 1;
    float: right;
    margin-top: -2px;
}

.driver-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-bright);
    margin-bottom: 3px;
}

.driver-team {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─── Replay ─── */
.replay-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 12px;
    margin-bottom: 12px;
}

.replay-canvas-wrap {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 400px;
}

.replay-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 65vh;
    min-height: 400px;
}

.replay-hud {
    position: absolute;
    top: 10px;
    left: 12px;
    display: flex;
    gap: 16px;
    font: 600 11px var(--font-mono);
    color: var(--text-muted);
    background: rgba(13,13,16,0.85);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.replay-hud #rpClock { color: var(--accent-orange); }

/* Flag Lamp */
.rp-flag-lamp { display: flex; align-items: center; gap: 6px; }
.rp-flag-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--f1-green);
    box-shadow: 0 0 6px rgba(0,210,106,0.5);
    transition: background 0.3s, box-shadow 0.3s;
}
.rp-flag-dot.flag-green  { background: var(--f1-green);  box-shadow: 0 0 6px rgba(0,210,106,0.5); }
.rp-flag-dot.flag-yellow { background: #ffe000; box-shadow: 0 0 10px rgba(255,224,0,0.6); animation: flagPulse 1s ease-in-out infinite; }
.rp-flag-dot.flag-sc     { background: var(--f1-orange); box-shadow: 0 0 12px rgba(255,135,0,0.6); animation: flagPulse 1.5s ease-in-out infinite; }
.rp-flag-dot.flag-vsc    { background: #ffe000; box-shadow: 0 0 12px rgba(255,224,0,0.6); animation: flagPulseVsc 0.5s ease-in-out infinite; }
.rp-flag-dot.flag-red    { background: var(--f1-red); box-shadow: 0 0 14px rgba(225,6,0,0.7); animation: flagPulse 0.8s ease-in-out infinite; }
.rp-flag-text { font-family: var(--font-data); font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--text-secondary); }

@keyframes flagPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes flagPulseVsc { 0%,100% { opacity: 1; } 50% { opacity: 0.1; } }

/* Race Control Message Bar */
.rp-rc-bar {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.88); border: 1px solid rgba(255,224,0,0.3); border-radius: 4px;
    padding: 4px 14px; font-family: var(--font-data); font-size: 11px;
    color: #ffe000; white-space: nowrap; opacity: 0;
    transition: opacity 0.3s; pointer-events: none; z-index: 5;
}
.rp-rc-bar.visible { opacity: 1; }

/* Race Control Log — positioned under HUD on canvas */
.rp-rc-log {
    position: absolute;
    top: 44px;
    left: 12px;
    width: 320px;
    max-height: 280px;
    background: rgba(10,10,14,0.85);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    pointer-events: auto;
    z-index: 4;
    overflow: hidden;
}
.rp-rc-log:empty, .rp-rc-log-list:empty + .rp-rc-log-header { display: none; }
.rp-rc-log-header {
    font-family: var(--font-data);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 6px 8px 2px;
}
.rp-rc-log-list {
    max-height: 240px;
    overflow-y: auto;
    font-family: var(--font-data);
    font-size: 10px;
    line-height: 1.5;
    padding: 2px 0 4px;
}
.rp-rc-log-row {
    display: flex;
    gap: 6px;
    padding: 2px 8px;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
}
.rp-rc-log-row.rc-yellow { border-left-color: #ffe000; color: #ffe000; }
.rp-rc-log-row.rc-red    { border-left-color: var(--f1-red); color: var(--f1-red); }
.rp-rc-log-row.rc-green  { border-left-color: var(--f1-green); color: var(--text-muted); }
.rp-rc-log-row.rc-sc     { border-left-color: var(--f1-orange); color: var(--f1-orange); }
.rc-time   { min-width: 32px; color: var(--text-muted); }
.rc-lap    { min-width: 22px; color: var(--text-muted); font-weight: 600; }
.rc-driver { min-width: 28px; font-weight: 700; }
.rc-msg    { flex: 1; }

/* Driver Panel */
.replay-driver-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    max-height: 65vh;
    min-height: 400px;
    overflow: hidden;
}

.rp-panel-title {
    font: 700 11px var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.rp-driver-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.rp-panel-header {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.rp-btn-sm {
    font: 600 10px var(--font-mono);
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.rp-btn-sm:hover {
    color: var(--text-bright);
    border-color: var(--text-muted);
}

.rp-driver-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}

.rp-driver-row:hover { background: rgba(255,255,255,0.03); }
.rp-driver-row.selected {
    background: rgba(255,255,255,0.06);
    border-left-color: var(--f1-red);
}

.rp-driver-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font: 600 12px var(--font-mono);
    color: var(--text-bright);
}

.rp-driver-check input[type="checkbox"] {
    accent-color: var(--f1-red);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.rp-team-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rp-driver-abbr { white-space: nowrap; }

.rp-driver-speed {
    font: 500 10px var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 64px;
    text-align: right;
}

/* Telemetry Overlay — floats on canvas */
.rp-telem-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: 200px;
    background: rgba(10,10,14,0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    pointer-events: auto;
    z-index: 5;
    transition: opacity 0.2s, transform 0.2s;
}

.rp-telem-overlay:empty {
    display: none;
}

.rp-telem-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid currentColor;
}

.rp-telem-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}

.rp-telem-close:hover { color: var(--text-bright); }

.rp-telem-abbr {
    font: 700 14px var(--font-mono);
    color: var(--text-bright);
}

.rp-telem-team {
    font: 500 10px var(--font-mono);
    color: var(--text-muted);
}

.rp-telem-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 3px 0;
}

.rp-telem-label {
    font: 600 9px var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.05em;
    min-width: 60px;
}

.rp-telem-val {
    font: 700 13px var(--font-mono);
    color: var(--text-bright);
}

.rp-telem-val small {
    font-weight: 500;
    font-size: 10px;
    color: var(--text-muted);
}

.rp-telem-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}

.rp-telem-bar div {
    height: 100%;
    border-radius: 2px;
    transition: width 0.15s ease;
}

.rp-telem-gear {
    font-size: 18px !important;
    color: var(--accent-orange) !important;
}

.rp-drs-open { color: #33cc55 !important; }
.rp-drs-eligible { color: var(--accent-orange) !important; }
.rp-drs-closed { color: var(--text-muted) !important; font-size: 11px !important; }

.rp-compound {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    font-size: 10px;
    font-weight: 700;
    color: #000;
}

/* Controls Bar */
.replay-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    flex-wrap: wrap;
}

.rp-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--f1-red);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.rp-play-btn:hover { background: #cc0028; }

.rp-speed-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.rp-speed-wrap label {
    font: 500 10px var(--font-mono);
    color: var(--text-muted);
}

.rp-speed-wrap input[type="range"] {
    width: 80px;
    accent-color: var(--f1-red);
}

#rpSpeedLabel {
    font: 700 12px var(--font-mono);
    color: var(--accent-orange);
    min-width: 28px;
}

.rp-scrubber-wrap {
    flex: 1;
    min-width: 100px;
}

.rp-scrubber-wrap input[type="range"] {
    width: 100%;
    accent-color: var(--f1-red);
}

.rp-lap-counter {
    font: 700 12px var(--font-mono);
    color: var(--accent-cyan);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─── Auth Pages ─── */
.auth-container {
    max-width: 440px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-6);
}
.auth-card h1 {
    font-size: 1.5rem;
    color: var(--text-bright);
    margin-bottom: var(--space-5);
    text-align: center;
}
.auth-card .form-label {
    color: var(--text-secondary);
    font-size: var(--fs-small);
    margin-bottom: var(--space-1);
}
.auth-card .form-control {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
}
.auth-card .form-control:focus {
    border-color: var(--f1-red);
    box-shadow: 0 0 0 2px var(--f1-red-dim);
    background: var(--bg-elevated);
    color: var(--text-bright);
}
.auth-card .btn-primary {
    background: var(--f1-red);
    border: none;
    width: 100%;
    padding: var(--space-3);
    font-weight: 600;
    border-radius: var(--radius-sm);
    margin-top: var(--space-4);
}
.auth-card .btn-primary:hover {
    background: #c40500;
}
.auth-links {
    text-align: center;
    margin-top: var(--space-4);
    font-size: var(--fs-small);
}
.auth-links a {
    color: var(--f1-cyan);
}
.auth-alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    font-size: var(--fs-small);
}
.auth-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}
.auth-alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

/* Upgrade/Pricing */
.pricing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin: var(--space-5) 0;
}
.pricing-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    text-align: center;
}
.pricing-card.featured {
    border-color: var(--f1-red);
    box-shadow: var(--shadow-glow-red);
}
.pricing-card h3 {
    color: var(--text-bright);
    margin-bottom: var(--space-2);
}
.pricing-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--f1-red);
    font-family: var(--font-data);
}
.pricing-price small {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}
.pricing-card .btn {
    margin-top: var(--space-4);
    width: 100%;
}
.swish-instructions {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-top: var(--space-5);
}
.swish-ref {
    font-family: var(--font-data);
    font-size: 1.2rem;
    color: var(--f1-cyan);
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ─── Filters / Selects ─── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-bright);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.94rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--dur-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.filter-select:hover,
.filter-select:focus {
    border-color: var(--f1-cyan);
    outline: none;
}

.filter-select option {
    background: var(--bg-panel);
    color: var(--text-primary);
}

/* ─── Custom Select ─── */
.cs-wrap {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}
.cs-wrap.cs-disabled { opacity: 0.5; pointer-events: none; }

.cs-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    color: var(--text-bright);
    padding: 10px 36px 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 0.94rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--dur-fast);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.cs-trigger:hover,
.cs-trigger:focus {
    border-color: var(--f1-cyan);
    outline: none;
}
.cs-wrap.cs-open .cs-trigger {
    border-color: var(--f1-cyan);
}

/* Dropdown — appended to body with position:fixed */
.cs-dropdown {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--f1-cyan);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.cs-dropdown.cs-visible {
    display: block;
}

.cs-option {
    padding: 9px 16px;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background var(--dur-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-option:hover,
.cs-option.cs-highlighted {
    background: var(--bg-hover);
    color: var(--text-bright);
}
.cs-option.cs-selected {
    background: rgba(0, 212, 255, 0.12);
    color: var(--f1-cyan);
}
.cs-option.cs-disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.cs-group-label {
    padding: 8px 16px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
}

/* Scrollbar */
.cs-dropdown::-webkit-scrollbar { width: 6px; }
.cs-dropdown::-webkit-scrollbar-track { background: transparent; }
.cs-dropdown::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
.cs-dropdown::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Loading States ─── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--f1-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}

.animate-in-1 { animation-delay: 0.04s; }
.animate-in-2 { animation-delay: 0.08s; }
.animate-in-3 { animation-delay: 0.12s; }
.animate-in-4 { animation-delay: 0.16s; }
.animate-in-5 { animation-delay: 0.2s; }
.animate-in-6 { animation-delay: 0.24s; }

/* ─── Utilities ─── */
.text-mono { font-family: var(--font-data); }
.text-bright { color: var(--text-bright); }
.text-muted { color: var(--text-muted); }
.text-red { color: var(--f1-red); }
.text-orange { color: var(--f1-orange); }
.text-cyan { color: var(--f1-cyan); }
.text-green { color: var(--f1-green); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.p-0 { padding: 0; }
.fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }

.page-section {
    margin-bottom: var(--space-7);
}

.section-title {
    font-family: var(--font-data);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    padding-left: var(--space-3);
    border-left: 3px solid var(--f1-red);
}

/* ─── Analysis Grids ─── */
.analysis-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}
.analysis-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* ─── Testing Grid ─── */
.testing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* ─── Table scroll indicator ─── */
.data-table-wrap {
    position: relative;
}
.data-table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to left, var(--bg-card), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: var(--z-tooltip);
}
.data-table-wrap.has-scroll::after { opacity: 1; }

/* Sticky first column on scroll */
.data-table th:first-child,
.data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: var(--z-base);
    background: inherit;
}

/* ─── Chart containers (responsive height) ─── */
.chart-container {
    position: relative;
    width: 100%;
    height: 400px;
}
.chart-container.chart-tall { height: 500px; }
.chart-container canvas { width: 100% !important; }

/* Chart skeleton shimmer (removed by renderChart()) */
.chart-skeleton {
    overflow: hidden;
}
.chart-skeleton::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.03) 40%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 60%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    z-index: var(--z-base);
    border-radius: var(--radius);
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Row states ─── */
.row-dnf { opacity: 0.5; }

/* ─── Dashboard components ─── */
.page-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.dash-live-badge {
    display: flex;
    gap: 8px;
    align-items: center;
}
.dash-live-badge .live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--f1-green);
    display: inline-block;
    animation: blink 2s ease infinite;
}

.dash-progress-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
}
.progress-bar {
    background: var(--bg-elevated);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, var(--f1-red), var(--f1-orange));
    height: 100%;
    border-radius: 4px;
    transition: width 1s var(--ease-out);
}

.dash-stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
}
.dash-stat-label {
    font-family: var(--font-data);
    font-size: var(--fs-caption);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.dash-stat-value {
    font-family: var(--font-data);
    font-size: var(--fs-stat);
    font-weight: 700;
    color: var(--text-bright);
}

.winner-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    min-width: 200px;
    transition: all var(--dur-med) var(--ease-out);
}
.winner-card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

/* Sidebar user/auth/sponsor */
.sidebar-user { padding: 12px 16px; font-size: 0.82rem; }
.sidebar-user__name { display: block; color: var(--text-bright); font-weight: 600; margin-bottom: 4px; }
.sidebar-user a { color: var(--text-secondary); margin-right: 12px; font-size: 0.78rem; }
.sidebar-auth { padding: 12px 16px; display: flex; gap: 8px; }
.nav-lock { font-size: 0.7rem; margin-left: 4px; opacity: 0.5; }
.sidebar-sponsor { display: block; padding: 8px 16px; margin-bottom: 8px; }
.sidebar-sponsor__img { max-width: 100%; max-height: 48px; object-fit: contain; opacity: 0.7; }

/* Dashboard page header */
.dash-page-header { padding-bottom: 20px; }
.dash-date { font-size: var(--fs-caption); color: var(--text-secondary); }
.dash-live-text { font-size: var(--fs-caption); letter-spacing: 2px; color: var(--f1-green); font-weight: 700; }

/* Dashboard badges & buttons */
.dash-sprint-badge {
    font-size: var(--fs-caption);
    color: var(--f1-orange);
    border: 1px solid var(--f1-orange);
    padding: 1px 7px;
    border-radius: var(--radius-xs);
    margin-left: 6px;
    vertical-align: middle;
}
.dash-btn-sm {
    font-size: var(--fs-caption);
    padding: 6px 14px;
}

/* Session label (uppercase mono) */
.dash-session-label {
    font-family: var(--font-data);
    font-size: var(--fs-label);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

/* Secondary race countdown */
.dash-race-countdown {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    display: none;
}
.dash-race-timer {
    font-family: var(--font-data);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-bright);
}

/* Weekend schedule pills */
.dash-weekend-schedule {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Season progress percentage row */
.dash-pct-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 10px;
}
.dash-pct-big {
    font-family: var(--font-data);
    font-size: var(--fs-hero);
    font-weight: 700;
    color: var(--text-bright);
}
.dash-pct-sub {
    font-family: var(--font-data);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Dashboard grids */
.dash-hero-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
    align-items: start;
}
.dash-hero-right {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.dash-stats-mini { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.dash-stat-card--wide { grid-column: span 2; }
.dash-stat-value--cyan { color: var(--f1-cyan); }
.dash-nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.dash-nav-grid a { text-decoration: none; display: block; }
.dash-main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-5);
    align-items: start;
}
.dash-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}
.dash-session-label--muted {
    color: var(--text-muted);
    letter-spacing: 1.5px;
}
.dash-schedule-pill {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--bg-elevated);
    white-space: nowrap;
}
.dash-schedule-pill--race { background: rgba(225, 6, 0, 0.15); }
.placeholder-msg--padded { padding: 40px; }

/* Winners scroll */
.winners-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.winners-scroll::-webkit-scrollbar { height: 3px; }
.winners-scroll::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 2px; }
.winners-scroll a { text-decoration: none; flex-shrink: 0; }

/* Winner card inner layout */
.winner-p1 {
    font-family: var(--font-data);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--f1-yellow);
}
.winner-name { font-weight: 700; color: var(--text-bright); font-size: 0.9rem; }
.winner-fullname { font-size: var(--fs-caption); color: var(--text-secondary); }
.winner-event { font-size: var(--fs-caption); color: var(--text-secondary); }
.winner-year { font-family: var(--font-data); font-size: var(--fs-caption); margin-left: 4px; }
.winner-team { font-size: var(--fs-caption); color: var(--text-dim); margin-top: 2px; }

/* Standings shared helpers */
.standings-year { font-family: var(--font-data); font-size: var(--fs-caption); color: var(--text-dim); }
.standings-pts {
    font-family: var(--font-data);
    font-weight: 700;
    font-size: 0.82rem;
}
.standings-pts.has-pts { color: var(--text-bright); }
.standings-pts.no-pts { color: var(--text-dim); }
.driver-abbr { font-weight: 700; color: var(--text-bright); }
.driver-full { font-size: 0.82rem; color: var(--text-secondary); margin-left: 4px; }
.team-name-bright { font-weight: 600; color: var(--text-bright); }
.wins-badge { font-size: var(--fs-caption); color: var(--f1-yellow); margin-left: 4px; }
.dnf-reason { font-size: var(--fs-caption); color: var(--f1-red); margin-left: 4px; }

/* Small btn in card headers */
.btn-card { font-size: var(--fs-caption); padding: 5px 12px; }

/* "All Results" style link */
.event-label { color: var(--text-primary); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: var(--fs-caption); margin-left: 8px; }

/* No-data placeholder */
.placeholder-msg { padding: 30px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* Upcoming race days */
.dash-days-hot { color: var(--f1-red); font-weight: 700; font-size: var(--fs-caption); margin-top: 3px; }
.dash-days-dim { color: var(--text-dim); font-size: var(--fs-caption); margin-top: 3px; }
.dash-calendar-link { text-align: center; padding: 8px; color: var(--text-secondary); font-size: 0.8rem; text-decoration: none; transition: color 0.2s; }

/* Nav tiles */
.dash-nav-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    transition: all var(--dur-med) var(--ease-out);
}
.dash-nav-tile:hover {
    border-color: var(--border-medium);
    background: var(--bg-elevated);
    transform: translateY(-2px);
}
.dash-nav-tile-icon { font-size: 1.6rem; margin-bottom: 8px; }
.dash-nav-tile-title { font-weight: 700; font-size: 0.88rem; color: var(--text-bright); }
.dash-nav-tile-desc { font-size: var(--fs-caption); color: var(--text-muted); margin-top: 2px; }

/* Driver stat inline on drivers.php cards */
.driver-stat {
    text-align: center;
}
.driver-stat-value {
    font-family: var(--font-data);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-bright);
}
.driver-stat-label {
    font-size: var(--fs-caption);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

/* Results page helpers */
.results-subtitle { font-weight: 400; font-size: 1.2rem; color: var(--text-secondary); }
.driver-num { font-family: var(--font-data); margin-right: 8px; color: var(--text-muted); }
.engine-label { font-size: var(--fs-caption); color: var(--text-muted); display: block; margin-top: 2px; }
.time-purple { color: var(--f1-purple); font-weight: 700; }
.time-ko { font-size: var(--fs-caption); }
.status-label { font-size: 0.82rem; font-weight: 600; }

/* Empty states */
.empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-5);
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    margin: var(--space-4) 0;
}
.empty-state-icon { font-size: 2rem; margin-bottom: var(--space-3); opacity: 0.5; }
.empty-state-title { color: var(--text-bright); font-size: 1rem; margin-bottom: var(--space-2); }
.empty-state-sub { color: var(--text-muted); font-size: 0.85rem; max-width: 400px; margin: 0 auto; }

/* ─── CSS Tooltips ─── */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 20, 0.95);
    color: var(--text-bright);
    font-family: var(--font-data);
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-medium);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--dur-fast);
    z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* Qualifying elimination rows */
.row-q1-ko { opacity: 0.65; }

/* ─── Tab System ─── */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.f1-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-data);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 11px var(--space-4);
    cursor: pointer;
    transition: all var(--dur-med) var(--ease-out);
    margin-bottom: -1px;
    white-space: nowrap;
    flex-shrink: 0;
}
.f1-tab:hover { color: var(--text-bright); }
.f1-tab.active { color: var(--f1-red); border-bottom-color: var(--f1-red); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Collapsible cards ─── */
.card-collapsible .card-header {
    cursor: pointer;
    user-select: none;
}
.card-collapsible .card-header::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg);
    transition: transform var(--dur-med) var(--ease-out);
    flex-shrink: 0;
    margin-left: auto;
}
.card-collapsible .card-header[aria-expanded="false"]::after {
    transform: rotate(-45deg);
}
.card-collapsible .card-collapse {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-out);
}
.card-collapsible .card-collapse.collapsed {
    max-height: 0;
}

/* ─── Show-more fade wrapper ─── */
.fade-wrapper {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-out);
}
.fade-wrapper.expanded {
    max-height: none;
}
.fade-wrapper:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
}
.fade-toggle {
    display: block;
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--border-subtle);
    color: var(--f1-cyan);
    font-family: var(--font-data);
    font-size: var(--fs-caption);
    padding: var(--space-3);
    text-align: center;
    cursor: pointer;
    transition: color var(--dur-fast);
}
.fade-toggle:hover { color: var(--text-bright); }

/* ─── Interactive cursor ─── */
a, button, select, [role="button"], [role="tab"],
.nav-tab, .f1-tab, .export-btn, .btn, .btn-card,
summary, label[for] {
    cursor: pointer;
}

/* ─── Accessibility ─── */
:focus-visible {
    outline: 2px solid var(--f1-cyan);
    outline-offset: 2px;
}

/* ─── Export Button ─── */
.export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.10);
    color: rgba(0, 212, 255, 0.4);
    padding: 5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
}
.export-btn svg { flex-shrink: 0; }
.card:hover .export-btn,
.export-btn:focus-visible {
    opacity: 1;
    pointer-events: auto;
}
.export-btn:hover {
    color: var(--f1-cyan);
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.25);
}
.export-btn:active {
    transform: scale(0.92);
}
.export-btn:disabled {
    opacity: 0.5 !important;
    cursor: wait;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — consolidated @media blocks (all breakpoints)
   ═══════════════════════════════════════════════════════ */

/* ═══ Responsive: 1024px ═══ */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .page-content { padding: 24px; }
    .page-header { padding: 24px; }
}

/* ═══ Responsive: 900px ═══ */
@media (max-width: 900px) {
    .dash-hero-grid { grid-template-columns: 1fr !important; }
    .dash-main-grid { grid-template-columns: 1fr !important; }
    .dash-bottom-grid { grid-template-columns: 1fr !important; }
}

/* ═══ Responsive: 768px ═══ */
@media (max-width: 768px) {
    /* ── Scale up root for mobile readability ── */
    html { font-size: 16px; }

    /* ── Page layout — generous mobile spacing ── */
    .page-content { padding: 16px; }
    .page-header { padding: 18px 16px; padding-left: 60px; }
    .page-header h1 { font-size: 1.4rem; }
    .page-subtitle { font-size: var(--fs-small); letter-spacing: 1.5px; }

    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }

    .countdown-timer { flex-wrap: wrap; justify-content: center; gap: 14px; }
    .countdown-container { padding: 22px; }
    .countdown-title { font-size: 0.82rem; }
    .countdown-event { font-size: 1.3rem; }
    .countdown-location { font-size: 0.88rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-select { width: 100%; font-size: 1rem; padding: 12px 16px; }
    .cs-wrap { display: block; max-width: 100% !important; }
    .cs-trigger { font-size: 1rem; padding: 12px 36px 12px 16px; min-height: 44px; }

    /* ── Tables: scroll but READABLE (fluid type) ── */
    .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .data-table { font-size: 0.92rem; white-space: nowrap; }
    .data-table th { padding: 10px 12px; font-size: var(--fs-table-th); }
    .data-table td { padding: 10px 12px; font-size: var(--fs-table-td); }

    /* ── Cards (fluid type) ── */
    .card-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
    .card-header h3 { font-size: var(--fs-h3); }
    .card-body { padding: 16px; overflow-x: auto; }

    /* ── Event cards ── */
    .event-card { padding: 16px; gap: 14px; }
    .event-round { font-size: 1.5rem; min-width: 40px; }
    .event-name { font-size: 1rem; }
    .event-location { font-size: 0.92rem; }
    .event-date { font-size: 0.88rem; }

    /* ── Stat blocks (fluid type) ── */
    .stat-label { font-size: var(--fs-small); }
    .stat-value { font-size: 1.8rem; }
    .stat-block { padding: 18px; }

    /* ── Buttons — 44x44px touch targets (WCAG 2.5.5 + 2.5.8) ── */
    .btn { padding: 12px 20px; font-size: var(--fs-body); min-height: 44px; min-width: 44px; }
    .btn-primary { padding: 12px 22px; min-height: 44px; min-width: 44px; }
    .filter-select { min-height: 44px; min-width: 44px; font-size: var(--fs-body); }

    /* Spacing between adjacent targets (WCAG 2.5.8) */
    .card-header .btn + .btn,
    .filter-group .btn + .btn,
    .session-selector .btn + .btn { margin-left: 8px; }
    .filter-group { gap: 8px; }
    .filter-bar { gap: 8px; }

    /* ── Countdown ── */
    .countdown-number { font-size: 2.2rem; }
    .countdown-separator { font-size: 2.2rem; }
    .countdown-label { font-size: 0.78rem; }

    /* ── News items ── */
    .news-item { flex-direction: column; gap: 10px; }
    .news-title { font-size: 1.05rem; }
    .news-meta { font-size: 0.82rem; }
    .news-source { font-size: var(--fs-small); }

    /* ── Driver cards ── */
    .driver-name { font-size: 1.1rem; }
    .driver-team { font-size: 0.92rem; }
    .driver-number { font-size: 2rem; }

    /* ── Replay ── */
    .replay-layout { grid-template-columns: 1fr; }
    .replay-canvas-wrap canvas { height: 50vh; min-height: 280px; }
    .replay-driver-panel { max-height: none; min-height: auto; }
    .rp-driver-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px;
        max-height: 120px;
        overflow-y: auto;
    }
    .rp-driver-row {
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        background: var(--bg-surface);
        border-left: none;
        border: 1px solid var(--border-subtle);
        flex-shrink: 0;
    }
    .rp-driver-row.selected { border-color: var(--f1-red); background: rgba(232,0,45,0.1); }
    .rp-driver-speed { display: none; }
    .rp-telem-overlay { width: 170px; bottom: 8px; left: 8px; padding: 8px 10px; }
    .rp-speed-wrap input[type="range"] { width: 60px; }

    /* ── Charts ── */
    .chart-container { height: 260px; }
    .chart-container.chart-tall { height: 320px; }

    /* ── Tooltips ── */
    [data-tooltip]::after { display: none; }

    /* ── Mobile column hiding (tables) ── */
    .col-hide-mobile { display: none !important; }
    .col-q1, .col-q2 { display: none !important; }
    .winner-card { min-width: 155px; padding: 10px 14px; }

    /* ── Tab bar ── */
    .tab-bar {
        gap: 2px;
        margin-left: -10px;
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 10px;
    }
    .f1-tab { font-size: 0.78rem; padding: 10px var(--space-3); letter-spacing: 0.5px; }

    /* ── Analysis grids ── */
    .analysis-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .analysis-compare-grid { grid-template-columns: 1fr; }
}

/* ═══ Responsive: 480px ═══ */
@media (max-width: 480px) {
    html { font-size: 15px; }

    .stat-grid { grid-template-columns: 1fr; }
    .countdown-number { font-size: 1.8rem; }
    .countdown-separator { font-size: 1.8rem; }
    .countdown-label { font-size: 0.78rem; }

    .data-table th { padding: 8px 10px; }
    .data-table td { padding: 9px 10px; }

    .page-content { padding: 12px; }
    .page-header { padding: 16px 12px; padding-left: 60px; }
    .page-header h1 { font-size: 1.25rem; }

    /* Pricing */
    .pricing-grid { grid-template-columns: 1fr; }

    /* Dashboard */
    .dash-stats-mini { grid-template-columns: 1fr; }

    /* Tabs */
    .f1-tab { font-size: 0.78rem; padding: var(--space-2) 10px; }

    /* Analysis grids */
    .analysis-stat-grid { grid-template-columns: repeat(2, 1fr); }

    /* Testing grid */
    .testing-grid { grid-template-columns: 1fr; }
}

/* ═══ Responsive: 414px ═══ */
@media (max-width: 414px) {
    .page-content { padding: 10px; }
    .page-header { padding: 14px 10px; padding-left: 56px; }
    .page-header h1 { font-size: 1.15rem; }

    .card-header { padding: 12px 14px; }
    .card-body { padding: 14px; overflow-x: auto; }

    .stat-grid { grid-template-columns: 1fr; gap: 10px; }

    .countdown-timer { gap: 10px; }
    .countdown-number { font-size: 1.5rem; }
    .countdown-separator { font-size: 1.5rem; }
}

/* ═══ Touch devices ═══ */
@media (hover: none) and (pointer: coarse) {
    .export-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ═══ Reduced motion ═══ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══ Print ═══ */
@media print {
    .sidebar, .sidebar-toggle, .sidebar-overlay, .mobile-header,
    .tab-bar, .btn, .export-btn, .filter-bar,
    .chart-container, .chat-widget { display: none !important; }
    body { background: #fff; color: #000; }
    .main-content { margin-left: 0; padding: 20px; }
    .data-table { font-size: 10pt; }
    .data-table th { background: #eee; color: #000; border-bottom: 2px solid #333; }
    .data-table td { border-bottom: 1px solid #ccc; color: #000; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; background: #fff; }
    .card-header { background: #f5f5f5; }
    .page-header { background: #fff; color: #000; }
    .page-header h1 { color: #000; }
    a { color: #000; text-decoration: none; }
}
