/* ============================================================================
   CEKP Kart Analyzer — F1-style Dark Premium Theme
============================================================================ */

:root {
    /* Surface */
    --bg-0:        #06070a;
    --bg-1:        #0b0d12;
    --bg-2:        #11141b;
    --bg-3:        #181c25;
    --bg-card:     #14181f;
    --bg-hover:    #1c2230;

    /* Borders */
    --border:      #1f2530;
    --border-soft: #2a3140;
    --border-acc:  rgba(225, 6, 0, 0.4);

    /* Text */
    --text-0:      #ffffff;
    --text-1:      #f1f3f7;
    --text-2:      #aab0bc;
    --text-3:      #6c7384;
    --text-muted:  #525a6c;

    /* Racing palette */
    --racing-red:    #e10600;
    --racing-red-2:  #b80500;
    --racing-yellow: #ffc700;
    --racing-amber:  #f59e0b;
    --racing-green:  #22c55e;
    --racing-blue:   #3b82f6;
    --racing-purple: #8b5cf6;

    /* Status */
    --success:   #22c55e;
    --warning:   #f59e0b;
    --danger:    #ef4444;
    --red-flag:  #dc2626;

    /* Podium */
    --gold:   #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow:    0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
    --shadow-red: 0 4px 24px rgba(225, 6, 0, 0.25);

    --radius-sm:  6px;
    --radius:     10px;
    --radius-lg:  16px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font-sans);
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(225, 6, 0, 0.08), transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(59, 130, 246, 0.04), transparent 70%),
        var(--bg-0);
    background-attachment: fixed;
    color: var(--text-1);
    min-height: 100vh;
    line-height: 1.5;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.container { max-width: 1440px; margin: 0 auto; padding: 24px 28px 40px; }

/* ============================================================================
   Header
============================================================================ */
.header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px;
    margin-bottom: 24px;
    position: relative;
}
.header::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--racing-red), transparent);
    opacity: 0.6;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.header-brand { display: flex; flex-direction: column; gap: 8px; }

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-sans);
}
.logo-mark {
    background: linear-gradient(135deg, var(--racing-red), var(--racing-red-2));
    color: white;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    box-shadow: var(--shadow-red);
}
.logo-divider {
    width: 1px;
    height: 22px;
    background: var(--border-soft);
}
.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-0);
    letter-spacing: -0.01em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-2);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.meta-dot { width: 6px; height: 6px; background: var(--racing-red); border-radius: 50%; box-shadow: 0 0 6px var(--racing-red); animation: pulse 2s infinite; }
.meta-sep { color: var(--text-muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Stage selector segmented */
.stage-selector {
    display: inline-flex;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    gap: 2px;
}
.stage-btn {
    background: transparent;
    border: none;
    color: var(--text-2);
    padding: 8px 16px;
    border-radius: 7px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    line-height: 1.2;
    transition: all 0.18s ease;
    position: relative;
}
.stage-btn:hover { color: var(--text-1); background: var(--bg-3); }
.stage-btn.active {
    background: linear-gradient(135deg, var(--racing-red), var(--racing-red-2));
    color: white;
    box-shadow: var(--shadow-red);
}
.stage-btn-label { letter-spacing: 0.02em; }
.stage-btn-meta {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    opacity: 0.85;
    letter-spacing: 0.05em;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-2);
}
#username-display { font-weight: 600; color: var(--text-1); padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.logout-btn {
    color: var(--text-2);
    text-decoration: none;
    background: var(--bg-2);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.18s;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.logout-btn:hover { background: var(--racing-red); color: white; border-color: var(--racing-red); }

/* ============================================================================
   Tabs
============================================================================ */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-button {
    background: transparent;
    border: none;
    color: var(--text-2);
    padding: 12px 18px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    position: relative;
    transition: color 0.18s;
    white-space: nowrap;
}
.tab-button::after {
    content: '';
    position: absolute;
    left: 14px; right: 14px; bottom: -1px;
    height: 2px;
    background: var(--racing-red);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}
.tab-button:hover { color: var(--text-1); }
.tab-button.active { color: var(--text-0); }
.tab-button.active::after { transform: scaleX(1); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================================
   Section
============================================================================ */
.section { margin-bottom: 32px; }
.section-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
}
.section-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-0);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.section-description { color: var(--text-2); font-size: 0.88rem; }

h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.section-tooltip { font-size: 0.85rem; color: var(--text-3); cursor: help; }
.tooltip-icon { display: inline-block; width: 14px; height: 14px; line-height: 14px; text-align: center; background: var(--bg-3); color: var(--text-2); border-radius: 50%; font-size: 0.65rem; cursor: help; font-weight: 600; }

/* ============================================================================
   Kart Search
============================================================================ */
.kart-search-container { flex: 1; min-width: 280px; max-width: 520px; }
.kart-search-wrapper { position: relative; }
.kart-search-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-1);
    padding: 11px 14px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    transition: all 0.18s;
}
.kart-search-input:focus {
    outline: none;
    border-color: var(--racing-red);
    box-shadow: 0 0 0 3px rgba(225, 6, 0, 0.15);
}
.kart-search-input::placeholder { color: var(--text-3); }

.kart-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.kart-search-dropdown.active { display: block; }
.kart-search-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--border);
}
.kart-search-dropdown-item:last-child { border-bottom: none; }
.kart-search-dropdown-item:hover, .kart-search-dropdown-item.active { background: var(--bg-3); }
.kart-search-dropdown-item-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kart-search-dropdown-item-number { font-weight: 700; color: var(--text-0); font-family: var(--font-mono); }
.kart-search-dropdown-item-team { color: var(--text-2); font-size: 0.88rem; }
.kart-search-dropdown-empty { padding: 14px; text-align: center; color: var(--text-3); font-size: 0.88rem; }

.kart-search-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kart-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    padding: 5px 8px 5px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.kart-chip-number { font-weight: 700; font-family: var(--font-mono); color: var(--text-0); }
.kart-chip-team { color: var(--text-2); }
.kart-chip-remove {
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 1.1rem;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.kart-chip-remove:hover { background: var(--racing-red); color: white; }

/* ============================================================================
   Cards & Grids
============================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-soft); transform: translateY(-1px); }
.stat-icon {
    width: 40px; height: 40px;
    background: var(--bg-3);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--racing-red);
    font-size: 1.1rem;
}
.stat-label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-value { font-size: 1.45rem; font-weight: 800; color: var(--text-0); font-family: var(--font-mono); line-height: 1.1; margin-top: 2px; }
.stat-value.small { font-size: 1.1rem; font-weight: 700; font-family: var(--font-sans); }

/* Hero (overview) */
.overview-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.hero-card--accent {
    background: linear-gradient(135deg, rgba(225, 6, 0, 0.12), rgba(225, 6, 0, 0.02));
    border-color: var(--border-acc);
}
.hero-card--accent::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 3px;
    background: var(--racing-red);
}
.hero-label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 6px; }
.hero-value { font-size: 1.75rem; font-weight: 900; color: var(--text-0); font-family: var(--font-mono); line-height: 1.1; letter-spacing: -0.02em; }
.hero-sub { font-size: 0.82rem; color: var(--text-2); margin-top: 4px; }

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.overview-pane {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

/* Metric cards */
.metrics-section, .pitstops-section, .endurance-insights-section, .stints-section { margin-bottom: 28px; }
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    position: relative;
    transition: all 0.18s;
}
.metric-card:hover { transform: translateY(-1px); border-color: var(--border-soft); }
.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--border-soft);
    border-radius: var(--radius) var(--radius) 0 0;
}
.metric-card.best::before { background: var(--success); }
.metric-card.qualifying::before { background: var(--racing-yellow); }
.metric-card.racepace::before { background: var(--racing-blue); }
.metric-card.average::before { background: var(--racing-purple); }
.metric-card.worst::before { background: var(--danger); }
.metric-card.consistency::before { background: var(--racing-red); }

.metric-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.metric-icon {
    width: 26px; height: 26px;
    background: var(--bg-3);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-1);
    font-size: 0.85rem;
}
.metric-title { font-size: 0.78rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { font-size: 1.45rem; font-weight: 800; color: var(--text-0); font-family: var(--font-mono); line-height: 1.1; margin-bottom: 2px; }
.metric-detail { font-size: 0.75rem; color: var(--text-3); }

/* Pit stop cards */
.pitstops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}
.pitstop-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all 0.18s;
}
.pitstop-card:hover { transform: translateY(-1px); }
.pitstop-card.valid { border-color: rgba(34, 197, 94, 0.3); background: linear-gradient(135deg, rgba(34, 197, 94, 0.06), transparent); }
.pitstop-card.invalid { border-color: rgba(239, 68, 68, 0.3); background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), transparent); }
.pitstop-card.neutral { border-color: var(--border); }
.pitstop-icon { font-size: 1.4rem; margin-bottom: 6px; color: var(--text-2); font-family: var(--font-mono); }
.pitstop-card.valid .pitstop-icon { color: var(--success); }
.pitstop-card.invalid .pitstop-icon { color: var(--danger); }
.pitstop-count { font-size: 1.5rem; font-weight: 800; color: var(--text-0); font-family: var(--font-mono); line-height: 1.1; }
.pitstop-label { font-size: 0.78rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.pitstop-detail { font-size: 0.72rem; color: var(--text-3); margin-top: 4px; }

/* Endurance cards */
.endurance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.endurance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: left;
    transition: all 0.18s;
}
.endurance-card:hover { transform: translateY(-1px); border-color: var(--border-soft); }
.endurance-icon {
    width: 32px; height: 32px;
    background: var(--bg-3);
    border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--racing-yellow);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.endurance-label { font-size: 0.78rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.endurance-value { font-size: 1.35rem; font-weight: 800; color: var(--text-0); font-family: var(--font-mono); line-height: 1.1; }
.endurance-detail { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }

.endurance-rating {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.endurance-rating.excellent { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.endurance-rating.good { background: rgba(59, 130, 246, 0.15); color: var(--racing-blue); }
.endurance-rating.average { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.endurance-rating.poor { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* CoV text colors (teams table) */
.cov-excellent { color: var(--success); font-weight: 700; }
.cov-good { color: var(--racing-blue); font-weight: 700; }
.cov-average { color: var(--warning); font-weight: 700; }
.cov-poor { color: var(--danger); font-weight: 700; }

/* ============================================================================
   Stints summary highlights
============================================================================ */
.stints-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.stint-highlight {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.stint-highlight.best-stint { border-left: 3px solid var(--success); }
.stint-highlight.worst-stint { border-left: 3px solid var(--danger); }
.stint-highlight strong { color: var(--text-0); margin-right: 6px; }

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

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead tr { background: var(--bg-2); border-bottom: 1px solid var(--border); }
thead th {
    text-align: left;
    padding: 12px 14px;
    color: var(--text-2);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 11px 14px; color: var(--text-1); vertical-align: middle; }
td.mono, .mono { font-family: var(--font-mono); }

.muted { color: var(--text-3); font-size: 0.82rem; }

/* Ranking position medals */
.ranking-position {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-0);
    background: var(--bg-3);
    border: 1px solid var(--border);
}
.ranking-position.gold { background: linear-gradient(135deg, #ffd700, #d4a017); color: #1a1300; border-color: #ffd700; box-shadow: 0 0 12px rgba(255, 215, 0, 0.3); }
.ranking-position.silver { background: linear-gradient(135deg, #d8d8d8, #a0a0a0); color: #1a1a1a; border-color: #c0c0c0; }
.ranking-position.bronze { background: linear-gradient(135deg, #cd7f32, #8b5a1f); color: #1a0d00; border-color: #cd7f32; }

/* Pit pills (teams) */
.pit-pill {
    display: inline-block;
    min-width: 24px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.78rem;
    margin-right: 4px;
}
.pit-pill.valid { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.pit-pill.invalid { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Stint badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: var(--font-mono);
}
.badge.valid { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge.invalid { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge.none { background: var(--bg-3); color: var(--text-3); }
.badge[title] { cursor: help; }

/* Evolution colors */
.evolution-positive { color: var(--success); font-weight: 700; }
.evolution-negative { color: var(--danger); font-weight: 700; }

/* ============================================================================
   Comparison
============================================================================ */
.comparison-selector {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.btn {
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    color: var(--text-1);
    padding: 11px 18px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 700;
    transition: all 0.18s;
    letter-spacing: 0.01em;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-3); }
.btn-primary {
    background: linear-gradient(135deg, var(--racing-red), var(--racing-red-2));
    border-color: var(--racing-red);
    color: white;
    box-shadow: var(--shadow-red);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(225, 6, 0, 0.35); }
.btn-secondary { background: var(--bg-3); border-color: var(--border-soft); color: var(--text-1); }
.btn-small { padding: 6px 12px; font-size: 0.8rem; }

.comparison-charts { display: grid; gap: 18px; }
.comparison-table-section { margin: 24px 0; }

/* ============================================================================
   Cross-Stage
============================================================================ */
.cross-stage-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.cross-stage-selector label { font-size: 0.9rem; color: var(--text-2); font-weight: 600; }
.cross-stage-select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-1);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    min-width: 320px;
    cursor: pointer;
}
.cross-stage-select:focus {
    outline: none;
    border-color: var(--racing-red);
    box-shadow: 0 0 0 3px rgba(225, 6, 0, 0.15);
}

.cross-stage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.cross-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
}
.cross-card-stage {
    display: inline-block;
    background: linear-gradient(135deg, var(--racing-red), var(--racing-red-2));
    color: white;
    font-weight: 800;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.cross-card-team { font-size: 0.85rem; color: var(--text-2); margin-bottom: 14px; }
.cross-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
    gap: 6px;
}
.cross-card-row:first-of-type { border-top: none; }
.cross-card-label { color: var(--text-2); font-size: 0.82rem; }

.delta {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
}
.delta-positive { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.delta-negative { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-soft);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
    color: var(--text-3);
    font-size: 0.95rem;
}

/* ============================================================================
   Charts
============================================================================ */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.chart-container { position: relative; height: 380px; }
.chart-container--md { height: 320px; }

/* ============================================================================
   Track visualizer
============================================================================ */
.track-visualization-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.track-viz-container {
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 480px;
    position: relative;
    margin-bottom: 14px;
}
#trackCanvas { width: 100%; height: 100%; display: block; }

.track-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.track-controls-buttons { display: flex; gap: 6px; }
.btn-track {
    background: var(--bg-3);
    border: 1px solid var(--border-soft);
    color: var(--text-1);
    width: 38px; height: 38px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.btn-track:hover { background: var(--bg-hover); border-color: var(--text-3); }
.btn-track-play {
    background: linear-gradient(135deg, var(--racing-red), var(--racing-red-2));
    border-color: var(--racing-red);
    color: white;
}
.btn-track-play.playing { background: linear-gradient(135deg, var(--warning), #d97706); border-color: var(--warning); }

.track-slider-container { flex: 1; min-width: 240px; }
.track-slider-label { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-1); display: block; margin-bottom: 6px; }
.track-slider { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; background: var(--bg-3); border-radius: 2px; outline: none; cursor: pointer; }
.track-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; background: var(--racing-red); border-radius: 50%; cursor: pointer; box-shadow: var(--shadow-red); }
.track-slider::-moz-range-thumb { width: 16px; height: 16px; background: var(--racing-red); border-radius: 50%; cursor: pointer; border: none; }
.track-slider-hint { font-size: 0.72rem; color: var(--text-3); margin-top: 4px; }

/* ============================================================================
   Footer
============================================================================ */
.footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-3);
    font-size: 0.82rem;
}
.footer strong { color: var(--text-1); }

/* ============================================================================
   Scrollbar (Webkit)
============================================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================================
   Responsivo
============================================================================ */
@media (max-width: 768px) {
    .container { padding: 16px 14px 32px; }
    .header-content { flex-direction: column; align-items: stretch; }
    .header-controls { justify-content: space-between; }
    .stage-btn { padding: 7px 12px; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .section-header h2 { font-size: 1.2rem; }
    .hero-value { font-size: 1.4rem; }
    .metric-value { font-size: 1.2rem; }
    .stat-value { font-size: 1.2rem; }
}

/* ============================================================================
   Pilotos (Drivers)
   ============================================================================ */
/* Cabeçalho fixo enquanto a lista longa de pilotos rola */
#drivers .table-container {
    max-height: calc(100vh - 200px);
    overflow: auto;
}
#drivers thead tr { position: sticky; top: 0; z-index: 3; }
#drivers thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-2);
    box-shadow: inset 0 -1px 0 var(--border);
}

.drivers-hero .hero-value {
    font-size: 1.15rem;
    font-family: var(--font-sans);
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drivers-compare-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.drivers-compare-hint { font-size: 0.85rem; color: var(--text-3); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
    padding: 9px 16px;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--border-acc); color: var(--text-0); }

.drivers-table th:first-child,
.drivers-table td:first-child { width: 34px; text-align: center; }
.driver-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--racing-red); }
.drivers-table tbody tr:hover { background: rgba(225, 6, 0, 0.04); }

.mini-badge { font-size: 0.85rem; }

.stint-driver {
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
}

.driver-tag {
    display: inline-block;
    background: rgba(225, 6, 0, 0.12);
    border: 1px solid var(--border-acc);
    color: var(--text-1);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.74rem;
    font-weight: 600;
    margin: 1px;
    white-space: nowrap;
}

.drivers-comparison { margin-top: 28px; }

/* Classe de peso: Super Graduado (105kg) marcado em amarelo */
.sg-badge {
    display: inline-block;
    background: rgba(255, 215, 0, 0.16);
    border: 1px solid rgba(255, 215, 0, 0.55);
    color: #ffd54a;
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
    vertical-align: middle;
    white-space: nowrap;
}
.hero-card--sg {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.02));
    border-color: rgba(255, 215, 0, 0.45);
}
.hero-card--sg::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 3px;
    background: #ffd54a;
}

/* ============================================================================
   Vitrine pública / Gating
   ============================================================================ */
.header-cta {
    background: var(--racing-red) !important;
    color: #fff !important;
    border-color: var(--racing-red) !important;
    font-weight: 700;
}
.header-cta:hover { box-shadow: 0 4px 18px rgba(225, 6, 0, 0.4); }

.tab-button.tab-locked::before {
    content: '🔒';
    font-size: 0.72rem;
    margin-right: 5px;
    opacity: 0.7;
}

/* Card de bloqueio (chamada para contratar) */
.locked-card {
    max-width: 560px;
    margin: 40px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.locked-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--racing-red);
}
.locked-icon { font-size: 2.4rem; margin-bottom: 10px; }
.locked-card h2 { font-size: 1.5rem; margin-bottom: 10px; }
.locked-text { color: var(--text-2); margin-bottom: 20px; }
.locked-features {
    list-style: none;
    text-align: left;
    max-width: 420px;
    margin: 0 auto 26px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.locked-features li {
    color: var(--text-1);
    font-size: 0.92rem;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.locked-cta { display: inline-block; padding: 13px 30px; font-size: 1rem; text-decoration: none; }
.locked-sub { margin-top: 16px; color: var(--text-3); font-size: 0.85rem; }
.locked-sub a { color: var(--racing-red); }

/* Nota de cálculo (compacta) */
.calc-note {
    font-size: 0.78rem;
    color: var(--text-3);
    margin: -2px 0 12px;
    line-height: 1.4;
}

/* Top pilotos / equipes na Visão Geral */
.ov-drivers-more { margin-top: 12px; font-size: 0.85rem; }
.ov-drivers-more a { color: var(--racing-red); font-weight: 600; }

/* Barra de seleção padronizada (Análise Individual, Comparação, Cross-Stage) */
.selector-bar {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.selector-bar .kart-search-container { max-width: 560px; }

/* Subtítulo em célula de tabela (ex: equipe sob o nome do piloto) */
.cell-sub { font-size: 0.74rem; color: var(--text-3); margin-top: 2px; }

/* ============================================================================
   Drilldown volta-a-volta (stints e pilotos)
   ============================================================================ */
.stint-expandable { cursor: pointer; }
.stint-expandable:hover { background: var(--bg-hover); }
.stint-expandable.expanded { background: var(--bg-hover); }
.caret { display: inline-block; color: var(--text-3); font-size: 0.7rem; width: 10px; }

.driver-name-link {
    color: var(--text-0);
    font-weight: 700;
    cursor: pointer;
    border-bottom: 1px dotted var(--text-3);
}
.driver-name-link:hover { color: var(--racing-red); border-bottom-color: var(--racing-red); }

.lap-detail-row > td { background: var(--bg-1); padding: 0 !important; }
.lap-drill {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1px 22px;
    padding: 12px 16px;
    max-height: 420px;
    overflow-y: auto;
}
.lap-drill-empty { padding: 14px 16px; }
.lap-row {
    display: grid;
    grid-template-columns: 40px 1fr 62px 66px;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 2px 0;
}
.lap-n { color: var(--text-3); font-family: var(--font-mono); }
.lap-bar { height: 7px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.lap-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--racing-amber), var(--racing-red)); }
.lap-t { text-align: right; font-size: 0.78rem; }
.lap-d { text-align: right; color: var(--text-3); font-size: 0.72rem; }
.lap-best .lap-t { color: var(--racing-yellow); font-weight: 700; }
.lap-best .lap-d { color: var(--racing-yellow); font-weight: 700; }
.lap-best .lap-bar-fill { background: var(--racing-yellow); }

/* Painel de detalhe do piloto */
.driver-detail {
    margin-top: 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-acc);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.driver-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.driver-detail-head h3 { font-size: 1.2rem; }
.driver-detail-meta { font-size: 0.85rem; color: var(--text-2); margin-top: 4px; }

/* Ordenação e busca na tabela de pilotos */
.driver-search { max-width: 300px; flex: 0 1 300px; }
#driversTable th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#driversTable th.sortable:hover { color: var(--text-0); }
#driversTable th.sortable::after { content: '⇅'; opacity: 0.3; margin-left: 5px; font-size: 0.9em; }
#driversTable th.sort-asc::after { content: '▲'; opacity: 1; color: var(--racing-red); font-size: 0.75em; }
#driversTable th.sort-desc::after { content: '▼'; opacity: 1; color: var(--racing-red); font-size: 0.75em; }
