/* GridLab - Sim Racing Testing Platform */

:root {
    --accent: #9333ea;
    --accent-hover: #a855f7;
    --accent-dim: rgba(147, 51, 234, 0.15);
    --accent-gradient: linear-gradient(135deg, #9333ea, #6366f1);
    --accent-rgb: 147, 51, 234;
    --accent-glow: 0 0 20px rgba(var(--accent-rgb), 0.3);
    --gold: #fbbf24;
    --silver: #94a3b8;
    --bronze: #d97706;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #eab308;
    --font: 'Space Grotesk', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 8px;
    --radius-sm: 4px;
}

/* Dark theme (default) */
:root, [data-theme="dark"] {
    --bg: #1c1728;
    --bg-card: #262038;
    --bg-card-rgb: 38, 32, 56;
    --bg-input: #302848;
    --bg-hover: #382f52;
    --border: #443a60;
    --text: #f8fafc;
    --text-muted: #b8b0d0;
    --text-dim: #7e72a0;
    --zebra: rgba(var(--accent-rgb), 0.04);
}

/* Light theme */
[data-theme="light"] {
    --bg: #f5f3fa;
    --bg-card: #ffffff;
    --bg-card-rgb: 255, 255, 255;
    --bg-input: #ede9f5;
    --bg-hover: #e8e3f3;
    --border: #d4cde6;
    --text: #1a1426;
    --text-muted: #5c5272;
    --text-dim: #8a80a0;
    --zebra: rgba(var(--accent-rgb), 0.03);
}

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

html { font-size: 15px; }

/* Mobile: prevent any element from causing horizontal overflow */
@media (max-width: 480px) {
    *, *::before, *::after {
        max-width: 100vw;
    }
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Focus-visible accessibility */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Navigation */
.main-nav {
    background: var(--bg);
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 var(--border);
    width: 100%;
    max-width: 100vw;
}

.main-nav::after {
    content: '';
    display: block;
    height: 2px;
    background: var(--accent-gradient);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 1.5rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.brand-icon { font-size: 1.3rem; }

.brand-logo {
    width: auto;
    height: 28px;
    color: var(--accent);
    transition: filter 0.2s;
}

.nav-brand:hover .brand-logo {
    filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.5));
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    right: 50%;
    height: 2px;
    background: var(--accent);
    transition: left 0.2s, right 0.2s;
    border-radius: 1px;
}

.nav-links a:hover { color: var(--text); background: var(--bg-hover); }
.nav-links a:hover::after { left: 0.75rem; right: 0.75rem; }

.nav-links a.active { color: var(--accent); background: var(--accent-dim); }
.nav-links a.active::after { left: 0.75rem; right: 0.75rem; }

.nav-user {
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
}

.user-name {
    display: inline-block;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.user-name:hover { color: var(--text); background: var(--bg-hover); }

.user-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 150px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    margin-top: 0.25rem;
    z-index: 150;
}

/* Mobile-only user links (inside hamburger menu) */
.nav-mobile-user { display: none; }

.nav-user.open .user-menu { display: block; }

.user-menu a {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.user-menu a:hover, .user-menu .link-btn:hover { background: var(--bg-hover); color: var(--text); }

.user-menu .link-btn {
    display: block; width: 100%; padding: 0.6rem 1rem; color: var(--text-muted);
    background: none; border: none; font: inherit; font-size: 0.9rem;
    text-align: left; cursor: pointer; transition: all 0.15s;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.4rem;
}

.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
    position: relative;
    z-index: 10;
}

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

/* Accent Picker */
.accent-picker-wrapper {
    position: relative;
    z-index: 100;
}
.accent-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.accent-toggle:hover { border-color: var(--accent); background: var(--bg-hover); }
.accent-toggle .accent-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.accent-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 150;
}
.accent-dropdown.open { display: block; }
.accent-dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.accent-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.accent-swatch-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.accent-swatch-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.accent-swatch-btn.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,0.3);
}
.accent-reset-btn {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.accent-reset-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}
.accent-toggle {
    gap: 0.2rem;
}
.accent-swatch-secondary {
    width: 12px !important;
    height: 12px !important;
    border-width: 1px !important;
    margin-left: -4px;
}
.accent-auto-label {
    font-weight: 400;
    opacity: 0.6;
    font-style: italic;
}
.accent-reset-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.accent-reset-row .accent-reset-btn {
    flex: 1;
}
.accent-dropdown .accent-swatches + .accent-dropdown-header {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.accent-swatches-dark {
    gap: 0.35rem;
}
.accent-dark-btn {
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}
.accent-dark-btn:hover {
    border-color: rgba(255, 255, 255, 0.6) !important;
}
.accent-dark-btn.active {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent);
}
.accent-reset-row {
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 0;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.card h2 {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 600;
    padding-left: 0.75rem;
    border-left: 3px solid var(--accent);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header-row h2 {
    margin-bottom: 0;
}

.export-btn {
    flex-shrink: 0;
}

.export-icon {
    margin-right: 0.3rem;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
    display: inline-block;
}

.page-header h1::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 40px;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.page-header-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Subscription badge inline (dashboard) */
.subscription-badge-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subscription-badge-inline .trial-days {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.subscription-badge-inline .trial-days.expiring {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Upgrade button accent style */
.btn-accent {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
}

.btn-accent:hover {
    filter: brightness(1.1);
    color: #fff;
}

.upgrade-icon {
    font-size: 0.9rem;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Scrollable results table - matches logging form height */
.table-wrap-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.card-results-scroll {
    display: flex;
    flex-direction: column;
}

.card-results-scroll .table-wrap-scroll {
    flex: 1;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

/* Zebra striping */
tbody tr:nth-child(even) td { background: var(--zebra); }

th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover { color: var(--accent); }
th.sortable::after { content: ' \2195'; opacity: 0.3; font-size: 0.7rem; }

/* Row highlighting for missing data */
tr.row-no-data td { opacity: 0.5; }
tr.row-no-data:hover td { opacity: 0.8; }
th.sort-asc::after { content: ' \2191'; opacity: 1; color: var(--accent); }
th.sort-desc::after { content: ' \2193'; opacity: 1; color: var(--accent); }

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

tr:hover td:first-child {
    border-left: 2px solid var(--accent);
    padding-left: calc(0.75rem - 2px);
    box-shadow: inset 4px 0 8px -4px rgba(var(--accent-rgb), 0.3);
}

td.lap-time {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--accent);
    white-space: nowrap;
}

td a {
    color: var(--accent);
    text-decoration: none;
}

td a:hover { text-decoration: underline; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
    cursor: pointer;
}

textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Premium feature locked state */
/* Premium feature locked - standard card style */
.premium-feature-locked {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.05), rgba(var(--accent-rgb), 0.02));
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--text);
}

.premium-feature-locked .lock-icon-large {
    font-size: 2rem;
    flex-shrink: 0;
}

.premium-feature-locked .lock-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.premium-feature-locked .lock-title {
    font-size: 1rem;
    color: var(--text);
}

.premium-feature-locked .lock-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.premium-feature-locked .btn {
    align-self: flex-start;
    margin-top: 0.25rem;
}

/* Premium feature locked - compact inline style */
.premium-feature-locked.compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    background: var(--bg-hover);
    font-size: 0.85rem;
}

.premium-feature-locked.compact .lock-icon {
    font-size: 1rem;
}

.premium-feature-locked.compact .lock-text {
    color: var(--text-muted);
}

.premium-feature-locked a {
    color: var(--accent);
}

.premium-feature-locked a:hover {
    text-decoration: underline;
}

/* Mobile adjustments for feature locked */
@media (max-width: 480px) {
    .premium-feature-locked:not(.compact) {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .premium-feature-locked .btn {
        align-self: center;
        width: 100%;
    }
}

/* N/A toggle inline with form inputs */
.input-with-na { display: flex; align-items: center; gap: 0.75rem; }
.input-with-na input[type="number"] { flex: 1; min-width: 0; }
.na-toggle { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; cursor: pointer; display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0; }
.na-toggle input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* Fuel calculator */
.fuel-unit-toggle {
    display: flex;
    gap: 0;
    margin-top: 0.25rem;
}
.fuel-unit-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.15s, color 0.15s;
}
.fuel-unit-btn:first-child { border-radius: 4px 0 0 4px; }
.fuel-unit-btn:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.fuel-unit-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.fuel-calc-toggle {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.78rem;
    font-family: var(--font);
    cursor: pointer;
    padding: 0.2rem 0;
    margin-top: 0.15rem;
}
.fuel-calc-toggle:hover { color: var(--accent-hover); text-decoration: underline; }
.fuel-calc-panel {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
.fuel-calc-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}
.fuel-calc-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.fuel-calc-fields .form-group { margin-bottom: 0; }
.fuel-calc-input { font-family: var(--mono); }
.fuel-calc-result {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    min-height: 1.4em;
}
@media (max-width: 768px) {
    .fuel-calc-fields { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-dim); }

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-full { width: 100%; }

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.flash-success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.flash-error { background: rgba(239,68,68,0.15); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.flash-warning { background: rgba(234,179,8,0.15); color: var(--warning); border: 1px solid rgba(234,179,8,0.3); }

/* Demo banner */
.demo-banner {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(6, 182, 212, 0.08));
    border-bottom: 1px solid rgba(6, 182, 212, 0.3);
    color: #22d3ee;
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.demo-banner-icon { font-size: 1rem; }
.demo-banner strong { font-weight: 600; letter-spacing: 0.05em; }
.demo-banner-link {
    color: #fff;
    text-decoration: underline;
    font-weight: 500;
    margin-left: 0.5rem;
}
.demo-banner-link:hover { color: #22d3ee; }

/* Offline banner */
.offline-banner {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15), rgba(251, 146, 60, 0.08));
    border-bottom: 1px solid rgba(251, 146, 60, 0.3);
    color: #fb923c;
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.offline-banner[hidden] { display: none; }
.offline-banner-icon { font-size: 1rem; }
.offline-banner strong { font-weight: 600; letter-spacing: 0.05em; }

/* Login page animations */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
    50% { box-shadow: 0 0 20px 2px rgba(var(--accent-rgb), 0.2); }
}

/* Login page */
.login-page {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at centre, rgba(var(--accent-rgb), 0.08) 0%, transparent 70%),
        repeating-linear-gradient(
            135deg,
            transparent,
            transparent 48%,
            rgba(var(--accent-rgb), 0.03) 48%,
            rgba(var(--accent-rgb), 0.03) 52%,
            transparent 52%
        ),
        var(--bg);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}

@media (min-height: 700px) {
    .login-wrapper {
        align-items: center;
    }
}

.login-container {
    width: 100%;
    max-width: 400px;
    position: relative;
}

.login-header {
    text-align: center;
    margin-bottom: 1.25rem;
    animation: fadeSlideUp 0.4s ease-out;
}

.brand-icon-lg { font-size: 2.5rem; display: block; margin-bottom: 0.35rem; }

.brand-logo-lg {
    width: auto;
    height: 64px;
    color: var(--accent);
    margin-bottom: 0.5rem;
    animation: pulseGlow 3s ease-in-out infinite;
}

.login-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.login-season {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

/* Team selector wrapper - positioning context for dropdown */
.team-selector-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
    animation: fadeSlideUp 0.4s ease-out 0.05s both;
    z-index: 10;
}

/* Team pill selector */
.team-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: fit-content;
}

.team-pill:hover, .team-pill.open {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.15);
}

.team-pill-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.team-pill-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.team-pill-arrow {
    font-size: 0.6rem;
    color: var(--text-dim);
    transition: transform 0.2s;
}

.team-pill.open .team-pill-arrow {
    transform: rotate(180deg);
}

/* Team picker dropdown */
.team-picker {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    width: 100%;
    max-width: 320px;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s, max-height 0.3s;
    z-index: 100;
}

.team-picker.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
    max-height: 320px;
    overflow-y: auto;
}

.team-picker-group {
    padding: 0.5rem;
}

.team-picker-group + .team-picker-group {
    border-top: 1px solid var(--border);
}

.team-picker-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0.5rem;
}

.team-picker-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.team-picker-item:hover {
    background: var(--bg-hover);
}

.team-picker-item.selected {
    background: var(--accent-dim);
}

.team-picker-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.team-picker-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}

/* Login card */
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    animation: fadeSlideUp 0.4s ease-out 0.1s both;
}

/* Ensure password manager dropdowns aren't clipped */
.login-card,
.login-card form,
.login-card .form-group {
    overflow: visible;
}

.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* Quick select section */
.quick-select-section {
    margin-top: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    animation: fadeSlideUp 0.4s ease-out 0.15s both;
}

.quick-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    padding: 0 0.25rem;
}

.quick-select-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.quick-select-count {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.driver-grid-scroll {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.driver-grid-scroll::-webkit-scrollbar {
    width: 4px;
}

.driver-grid-scroll::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 2px;
}

.driver-grid-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.driver-grid-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.driver-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.driver-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.driver-btn:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.driver-btn.selected {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 0 1px var(--accent);
}

.driver-btn-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.driver-btn.selected .driver-btn-avatar {
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
}

.driver-btn-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Login footer */
.login-footer {
    text-align: center;
    margin-top: 0.75rem;
    padding: 0.5rem;
}

.login-footer a {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.15s;
}

.login-footer a:hover {
    color: var(--accent);
}

.footer-sep {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin: 0 0.35rem;
}

/* Mobile adjustments for login */
@media (max-width: 480px) {
    .login-wrapper {
        padding: 1rem 0.75rem;
    }

    .login-header {
        margin-bottom: 1rem;
    }

    .brand-icon-lg {
        font-size: 2rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .driver-grid-scroll {
        max-height: 150px;
    }

    .team-picker {
        max-width: calc(100% - 1rem);
    }
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: box-shadow 0.2s, transform 0.2s;
    animation: fadeSlideUp 0.35s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }
.stat-card:nth-child(6) { animation-delay: 0.25s; }

.stat-card:hover {
    box-shadow: var(--accent-glow);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--mono);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.profile-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.profile-info dt {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.profile-info dd {
    font-size: 0.9rem;
}

.profile-info a { color: var(--accent); text-decoration: none; }
.profile-info a:hover { text-decoration: underline; }

.profile-export-divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

/* Subscription card (settings) - sits next to Profile in grid */
.subscription-card {
    /* Removed grid-column: span 2 to allow side-by-side with Profile */
}

.subscription-status-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.subscription-status-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.subscription-current-plan {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subscription-current-plan .label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.subscription-expiry {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.expiry-warning {
    color: var(--warning);
    font-size: 0.85rem;
}

.expiry-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.days-badge {
    background: var(--bg-hover);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.days-badge.urgent {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.lifetime-badge {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.subscription-actions {
    flex-shrink: 0;
}

.subscription-promo {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.subscription-promo p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.promo-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.promo-feature {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(var(--accent-rgb), 0.08);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text);
}

.feature-icon {
    font-size: 0.9rem;
}

/* SVR Member - Free for Life Signage */
.lifetime-badge.svr-lifetime {
    background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(124,58,237,0.15));
    color: #a78bfa;
    border: 1px solid rgba(139,92,246,0.3);
    font-weight: 600;
}

.subscription-svr-info {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(124,58,237,0.04));
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 8px;
}

.svr-info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.svr-info-content {
    flex: 1;
}

.svr-info-content strong {
    display: block;
    color: #a78bfa;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.svr-info-content p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

.svr-info-content p strong {
    display: inline;
    color: var(--text);
    font-size: inherit;
    margin: 0;
}

.svr-info-note {
    color: var(--text-dim) !important;
    font-size: 0.78rem !important;
    font-style: italic;
    margin-bottom: 0 !important;
}

.kofi-support-link {
    color: var(--text-dim) !important;
    font-size: 0.8rem !important;
    margin-top: 0.75rem !important;
    margin-bottom: 0 !important;
}

.kofi-support-link a {
    color: var(--accent);
    text-decoration: none;
}

.kofi-support-link a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .subscription-card {
        grid-column: span 1;
    }

    .subscription-status-row {
        flex-direction: column;
    }

    .subscription-actions {
        width: 100%;
    }

    .subscription-actions .btn {
        width: 100%;
    }
}

/* Track calendar */
.track-grid {
    display: grid;
    gap: 0.5rem;
}

.track-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto auto auto;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

a.track-row:hover { border-color: var(--accent); background: var(--bg-hover); color: var(--text); }

.track-row.past { opacity: 0.5; }
.track-row.next { border-color: var(--accent); }

.track-round {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--accent);
    text-align: center;
}

.track-name { font-weight: 500; display: flex; align-items: center; gap: 0.4rem; }

.country-flag { width: 1.4em; height: 1em; object-fit: cover; border-radius: 2px; vertical-align: middle; }
.track-layout { color: var(--text-dim); font-size: 0.8rem; }
.track-date { color: var(--text-muted); font-size: 0.85rem; }

.track-badges {
    display: flex;
    gap: 0.35rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-fuel { background: rgba(var(--accent-rgb),0.2); color: var(--accent); border: 1px solid rgba(var(--accent-rgb),0.3); }
.badge-tyre { background: rgba(34,197,94,0.2); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.badge-reverse { background: rgba(239,68,68,0.2); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.badge-bop { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-limit-enforced { background: rgba(239,68,68,0.2); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.badge-limit-not_enforced { background: rgba(34,197,94,0.2); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }

/* Subscription status badges */
.badge-neutral { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.badge-warning { background: rgba(234,179,8,0.2); color: #eab308; border: 1px solid rgba(234,179,8,0.3); }
.badge-success { background: rgba(34,197,94,0.2); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.badge-premium { background: linear-gradient(135deg, rgba(147,51,234,0.2), rgba(99,102,241,0.2)); color: var(--accent); border: 1px solid rgba(var(--accent-rgb),0.3); }
.badge-svr { background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(124,58,237,0.15)); color: #a78bfa; border: 1px solid rgba(139,92,246,0.4); }
.badge-demo { background: linear-gradient(135deg, rgba(6,182,212,0.25), rgba(14,165,233,0.15)); color: #22d3ee; border: 1px solid rgba(6,182,212,0.4); }

/* Confidence rating badges: 1 (red/uncomfortable) → 5 (green/pushing hard) */
.badge-confidence-1 { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-confidence-2 { background: rgba(251,146,60,0.2); color: #fb923c; border: 1px solid rgba(251,146,60,0.3); }
.badge-confidence-3 { background: rgba(234,179,8,0.2); color: #eab308; border: 1px solid rgba(234,179,8,0.3); }
.badge-confidence-4 { background: rgba(74,222,128,0.2); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.badge-confidence-5 { background: rgba(34,197,94,0.2); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }

/* Driver confidence summary grid (car-detail) */
.driver-confidence-grid {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.driver-confidence-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.driver-confidence-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.driver-confidence-tests {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Confidence selector (testing form) */
.confidence-selector {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.confidence-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem 0.65rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    flex: 1;
    min-width: 0;
    text-align: center;
}

.confidence-btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.confidence-btn .confidence-num {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 700;
}

.confidence-btn .confidence-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.confidence-btn[aria-pressed="true"] {
    color: var(--text);
    font-weight: 600;
}

.confidence-btn[data-value="1"][aria-pressed="true"] { border-color: #f87171; background: rgba(239,68,68,0.15); }
.confidence-btn[data-value="2"][aria-pressed="true"] { border-color: #fb923c; background: rgba(251,146,60,0.15); }
.confidence-btn[data-value="3"][aria-pressed="true"] { border-color: #eab308; background: rgba(234,179,8,0.15); }
.confidence-btn[data-value="4"][aria-pressed="true"] { border-color: #4ade80; background: rgba(74,222,128,0.15); }
.confidence-btn[data-value="5"][aria-pressed="true"] { border-color: #22c55e; background: rgba(34,197,94,0.15); }

/* Track limits */
.track-limits-list { display: grid; gap: 0.5rem; }

.track-limit-item {
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.track-limit-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.track-limit-turn {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--accent);
    font-size: 0.9rem;
    min-width: 2rem;
}

.track-limit-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.track-limit-actions {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

.track-limit-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.4rem;
    line-height: 1.5;
}

.track-limit-meta {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 0.3rem;
}

.track-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.track-info-item {
    padding: 0.5rem 0;
}

.track-info-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.track-info-value {
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.4;
}

.track-trivia {
    border-left: 3px solid var(--accent);
}

.track-limit-form {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Track map (external SVG image) */
.track-map-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

.track-map-img {
    width: 100%;
    max-width: 480px;
    height: auto;
    max-height: 360px;
    object-fit: contain;
    border-radius: 8px;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .track-map-img {
    filter: invert(0.88) hue-rotate(180deg);
    background: rgba(30, 30, 30, 0.95);
}

.track-map-attr {
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.track-map-attr a {
    color: var(--text-muted);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .track-map-img { max-width: 320px; max-height: 260px; }
}

/* BoP speed filter (cars page) */
.bop-filter { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.bop-filter span { color: var(--text-muted); font-size: 0.85rem; }
.bop-speed-btns { display: flex; gap: 0.25rem; }
.bop-speed-btn {
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font);
    transition: all 0.15s;
}
.bop-speed-btn:hover { border-color: var(--accent); color: var(--text); }
.bop-speed-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* BoP specs table (car detail) */
.bop-table { width: auto; margin: 0; }
.bop-table th, .bop-table td { padding: 0.4rem 1rem; text-align: right; }
.bop-table th:first-child, .bop-table td:first-child { text-align: left; }
.bop-table .bop-label { font-weight: 500; color: var(--text-muted); }

/* Car images */
.car-thumb {
    width: 56px;
    height: 32px;
    object-fit: contain;
    vertical-align: middle;
    border-radius: 3px;
    transition: transform 0.2s;
}

.car-thumb:hover {
    transform: scale(1.05);
}

.car-hero {
    display: block;
    max-width: 400px;
    width: 100%;
    margin: 0 auto 1.5rem;
    border-radius: var(--radius);
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
    transition: transform 0.2s;
}

.car-hero:hover {
    transform: scale(1.02);
}

.car-image-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.car-hero-placeholder {
    max-width: 400px;
    width: 100%;
    margin: 0 auto 0.75rem;
    padding: 3rem 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.95rem;
}

.car-image-upload {
    max-width: 400px;
    margin: 0.75rem auto 0;
}

.car-image-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.car-image-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.car-image-status {
    font-size: 0.85rem;
    margin-top: 0.35rem;
    min-height: 1.2em;
}

.car-image-status.success {
    color: var(--success);
}

.car-image-status.error {
    color: var(--danger);
}

/* Driver livery section */
.driver-livery-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.driver-livery-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.driver-liveries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.driver-livery-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    transition: border-color 0.2s;
}

.driver-livery-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3);
}

.driver-livery-item img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-input);
}

.livery-info {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.livery-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-active {
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-sm);
}

.badge-shared {
    background: var(--success);
    color: white;
    font-size: 0.65rem;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-sm);
}

.livery-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.livery-actions .btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.livery-actions .btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.livery-actions .btn-danger:hover {
    background: var(--error);
    color: white;
}

.driver-image-upload {
    margin-top: 0.75rem;
}

.driver-image-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.driver-image-status {
    font-size: 0.85rem;
    margin-top: 0.35rem;
    min-height: 1.2em;
}

.driver-image-status.success {
    color: var(--success);
}

.driver-image-status.error {
    color: var(--error);
}

.car-image-badge {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -1rem;
    margin-bottom: 1rem;
}

.empty-hint {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.compare-car-img {
    width: 120px;
    height: 68px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    transition: transform 0.2s;
}

.compare-car-img:hover {
    transform: scale(1.05);
}

/* Unit preference options */
.unit-presets {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.unit-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.unit-row-label {
    width: 60px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.units-options {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.unit-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    position: relative;
}

.unit-option:not(.active):hover { border-color: var(--text-dim); background: var(--bg-hover); }

.unit-option.active,
.unit-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.unit-option.active:hover,
.unit-option:has(input:checked):hover {
    border-color: var(--accent-hover);
}

/* Show focus ring on unit-option when its input is focused */
.unit-option:has(input[type="radio"]:focus-visible),
.unit-option:has(input[type="checkbox"]:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.unit-option input[type="radio"],
.unit-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.unit-option-label {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Car detail */
.car-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.car-header h1 { font-size: 1.3rem; }
.car-meta { color: var(--text-muted); font-size: 0.85rem; }

.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.spec-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    text-align: center;
}

.spec-value {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent);
}

.spec-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Compare page */
.compare-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1.5rem;
}

.compare-controls .form-group { margin-bottom: 0; flex: 1; min-width: 180px; }

.compare-table th:first-child { min-width: 140px; }

.compare-best {
    color: var(--gold);
    font-weight: 600;
    position: relative;
    padding-left: 1.2em;
}

.compare-best::before {
    content: '\265B';
    position: absolute;
    left: 0;
    font-size: 0.85em;
    opacity: 0.8;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}

.empty-state p { margin-top: 0.5rem; font-size: 0.9rem; }

/* Filter notice banner */
.filter-notice {
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}
.filter-notice a { font-weight: 600; }

/* Team members on dashboard */
.team-list {
    display: grid;
    gap: 0.5rem;
}

.team-member {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.team-member:last-child { border-bottom: none; }

.team-member-name { font-weight: 500; }
.team-member-name a { color: var(--accent); text-decoration: none; }
.team-member-name a:hover { color: var(--accent-hover); text-decoration: underline; }
.team-member-tests { color: var(--text-muted); font-size: 0.85rem; font-family: var(--mono); }

/* Field guide */
.guide-text p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.field-guide {
    display: grid;
    gap: 0.6rem;
}

.field-guide dt {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.88rem;
}

.field-guide dd {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.4rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
}

.field-guide code {
    font-family: var(--mono);
    background: var(--bg-input);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.82rem;
}

/* Delta import */
.delta-import-card:hover { transform: none; }
.delta-import-card code {
    font-family: var(--mono);
    background: var(--bg-input);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.82rem;
}

.delta-lap-table { font-size: 0.85rem; }
.delta-lap-table th { font-size: 0.72rem; }
.delta-best-lap td { color: var(--gold); }
.delta-best-lap td.lap-time { color: var(--gold); }
.delta-excluded-lap td { opacity: 0.5; }
.delta-lap-tag { font-size: 0.65rem; padding: 0.1rem 0.35rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 3px; margin-left: 0.3rem; vertical-align: middle; }

.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
}

.btn-success:hover { background: #16a34a; }

/* Qualifying settings panel */
.quali-settings-card:hover { transform: none; }
.quali-settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.quali-setting {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    text-align: center;
}

.quali-setting-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
}

.quali-setting-value {
    display: block;
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--accent);
}

@media (max-width: 768px) {
    .quali-settings-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .quali-settings-grid { grid-template-columns: 1fr 1fr; }
}

/* Admin portal */
.admin-team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.admin-team-card {
    text-decoration: none;
    color: var(--text);
    padding: 1.25rem;
    cursor: pointer;
}

.admin-team-card-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.admin-team-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.admin-team-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.admin-team-name {
    font-weight: 600;
    font-size: 1rem;
}

.admin-team-stats {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.admin-team-count {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.admin-team-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-team-inactive {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.admin-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.admin-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.admin-breadcrumb a:hover {
    color: var(--accent);
}

.admin-breadcrumb-sep {
    color: var(--text-dim);
}

.admin-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.admin-row-inactive td {
    opacity: 0.5;
}

.admin-row-inactive td:last-child {
    opacity: 1;
}

.user-edit-link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dashed var(--border);
    transition: border-color 0.15s, color 0.15s;
}

.user-edit-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.btn-warning {
    background: rgba(234, 179, 8, 0.15);
    color: var(--warning);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.btn-warning:hover {
    background: rgba(234, 179, 8, 0.25);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.badge-active {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-role-admin {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-role-member {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-role-viewer {
    background: rgba(148, 163, 184, 0.2);
    color: var(--silver);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-role-coach {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-role-team-admin {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.badge-reserve {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-reserve-inactive {
    background: rgba(148, 163, 184, 0.2);
    color: var(--silver);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.btn-reserve-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    vertical-align: middle;
    margin-left: 0.25rem;
    line-height: 1;
}

.btn-reserve-add:hover {
    color: var(--success);
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.btn-reserve-remove:hover {
    color: var(--error);
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.role-info-banner {
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.role-info-banner strong {
    color: var(--text);
}

@media (max-width: 768px) {
    .admin-team-grid {
        grid-template-columns: 1fr;
    }

    .admin-actions {
        flex-direction: column;
    }

    .admin-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* Reserve drivers cross-team section */
.reserves-section { border-left: 3px solid #64748b; }

/* Recording context bar (dual-role driver toggle) */
.recording-context-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
}

.recording-context-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.context-btn {
    padding: 0.35rem 0.85rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.context-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
    background: var(--bg-hover);
}

.context-btn.active {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.badge-reserve-ctx {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-dim);
    font-size: 0.78rem;
    border-top: none;
    margin-top: 2rem;
    position: relative;
}

.site-footer::before {
    content: '';
    display: block;
    height: 2px;
    background: var(--accent-gradient);
    margin-bottom: 1.5rem;
}

/* Delete button */
.btn-delete {
    background: transparent;
    color: var(--text-dim);
    border: none;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-delete:hover { color: var(--error); background: rgba(239,68,68,0.1); }

/* Edit button */
.btn-edit {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.btn-edit:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.25);
    border-color: var(--accent);
}

.replay-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    transition: opacity 0.15s, background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    background: rgba(var(--accent-rgb), 0.08);
    white-space: nowrap;
}
.replay-link:hover { background: rgba(var(--accent-rgb), 0.18); }

/* Trend charts */
.trend-chart-wrap {
    position: relative;
    width: 100%;
    height: 300px;
}

.trend-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Car category badges */
.badge-category-gr3 { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-category-gr4 { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-category-gr1 { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-category-gr2 { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.badge-category-grb { background: rgba(251, 146, 60, 0.15); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.3); }
.badge-category-n { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-category-x { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-category-sf { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.badge-category-x2014 { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Category filter (cars page) */
.car-filters { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; align-items: center; }
.category-filter { display: flex; align-items: center; gap: 0.75rem; }
.category-filter span { color: var(--text-muted); font-size: 0.85rem; }
.category-btns { display: flex; gap: 0.25rem; }
.category-btn {
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font);
    transition: all 0.15s;
}
.category-btn:hover { border-color: var(--accent); color: var(--text); }
.category-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Car search */
.car-search { flex: 1; min-width: 150px; max-width: 300px; }
.car-search-input {
    width: 100%;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}
.car-search-input:focus { border-color: var(--accent); outline: none; }
.car-search-input::placeholder { color: var(--text-dim); }

/* Pin button (cars page, car-detail) */
.pin-col-header { width: 2rem; }
.pin-cell { padding: 0.3rem 0.25rem !important; text-align: center; }
.pin-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-dim);
    padding: 0.15rem;
    line-height: 1;
    transition: color 0.15s, transform 0.15s;
}
.pin-btn:hover { color: #facc15; transform: scale(1.2); }
.pin-btn.pinned { color: #facc15; }
.pin-badge {
    display: inline-block;
    color: #facc15;
    font-size: 0.85rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Responsive */
@media (max-width: 768px) {
    html { font-size: 14px; }

    /* Nav: hide desktop links, show hamburger */
    .nav-links { display: none; }
    .nav-toggle { display: block; order: 10; }

    .nav-inner {
        gap: 0.5rem;
    }

    /* Push theme toggle, accent picker and user to right, keep tidy spacing */
    .theme-toggle { order: 7; margin-left: auto; padding: 0.3rem 0.5rem; font-size: 1.1rem; }
    .accent-picker-wrapper { order: 8; }
    .accent-toggle { padding: 0.25rem; }
    .accent-toggle .accent-swatch { width: 16px; height: 16px; }
    .accent-dropdown { right: -40px; min-width: 180px; }
    .accent-swatches { grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
    .accent-swatch-btn { width: 32px; height: 32px; }
    .nav-user { order: 9; }
    .user-name { font-size: 0.8rem; padding: 0.3rem 0.4rem; }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem;
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        z-index: 200;
    }

    .nav-links.open a {
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
    }

    .nav-links.open a::after { display: none; }

    /* Show mobile user links in hamburger menu */
    .nav-links.open .nav-mobile-user {
        display: block;
        border-top: 1px solid var(--border);
        margin-top: 0.25rem;
        padding-top: 0.25rem;
    }
    .nav-links.open .nav-mobile-user a,
    .nav-links.open .nav-mobile-user .link-btn {
        display: block;
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
        color: var(--text-muted);
        text-decoration: none;
        border-radius: var(--radius-sm);
        transition: color 0.2s, background 0.2s;
    }
    .nav-links.open .nav-mobile-user a:hover,
    .nav-links.open .nav-mobile-user .link-btn:hover {
        color: var(--text);
        background: var(--bg-hover);
    }
    .nav-links.open .nav-mobile-user .link-btn {
        width: 100%;
        background: none;
        border: none;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .dashboard-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .track-row {
        grid-template-columns: 2rem 1fr;
        gap: 0.5rem;
    }

    .track-date, .track-badges { grid-column: 2; }

    .compare-controls { flex-direction: column; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .units-options { flex-direction: column; }

    .car-hero { max-width: 280px; }

    /* Allow text wrapping on mobile for long names */
    td { white-space: normal; }
    td.lap-time { white-space: nowrap; }
    .track-round { white-space: nowrap; }

    /* Recording context bar */
    .recording-context-bar { flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.75rem; }

    /* Delta import area */
    .delta-import-card .btn { font-size: 0.78rem; padding: 0.35rem 0.6rem; }
    #delta-url-input { min-width: 0; font-size: 0.8rem; }

    /* Qualifying settings */
    .quali-settings-grid { grid-template-columns: repeat(2, 1fr); }

    /* Car filters (category + BoP) */
    .car-filters { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .category-btns, .bop-speed-btns { flex-wrap: wrap; }
    .car-search { max-width: 100%; }
    .pin-col-header, .pin-cell { display: none; }

    /* Confidence selector */
    .confidence-btn { padding: 0.4rem 0.3rem; }
    .confidence-btn .confidence-label { font-size: 0; } /* Hide labels on mobile, show just numbers */
    .confidence-btn .confidence-num { font-size: 1.1rem; }

    /* Fuel calculator */
    .fuel-calc-fields { grid-template-columns: 1fr; }

    /* Specs grid (car detail) */
    .specs-grid { grid-template-columns: repeat(3, 1fr); }

    /* Card padding */
    .card { padding: 1rem; }
    .card h2 { font-size: 0.9rem; margin-bottom: 0.75rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .container {
        padding: 1rem 0.5rem;
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Nav: hide username on very small screens, keep toggle + hamburger */
    .user-name { display: none; }
    .nav-user { display: none; }

    /* Specs grid goes to 2 columns */
    .specs-grid { grid-template-columns: repeat(2, 1fr); }

    /* Confidence - shrink further */
    .confidence-btn { min-width: 0; padding: 0.4rem 0.2rem; }

    /* Table text smaller */
    table { font-size: 0.8rem; }
    th { font-size: 0.68rem; }
    th, td { padding: 0.4rem 0.5rem; }
}

/* Coaching notification badge (nav) */
.badge-notify {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 9999px;
    background: var(--error);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.25rem;
    vertical-align: middle;
}

/* Coming soon badge */
.badge-coming-soon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 0.3rem;
    vertical-align: middle;
}

/* Disabled nav link (feature coming soon) */
.nav-link-disabled {
    display: inline-flex;
    align-items: center;
    color: var(--text-dim);
    cursor: default;
    opacity: 0.7;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Coaching connection cards */
.coaching-connection-card {
    padding: 0.65rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Coaching connect panel (expandable details) */
.coaching-connect-panel summary {
    cursor: pointer;
    list-style: none;
}
.coaching-connect-panel summary::-webkit-details-marker { display: none; }
.coaching-connect-panel[open] summary { margin-bottom: 0; }

/* Coaching Notes */
.coaching-notes-list { display: flex; flex-direction: column; gap: 0.75rem; }
.coaching-note-item {
    padding: 0.75rem;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border);
}
.coaching-note-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.coaching-note-track { font-weight: 500; font-size: 0.85rem; }
.coaching-note-car { color: var(--text-muted); font-size: 0.82rem; }
.coaching-note-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-line;
}
.coaching-note-meta {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.coaching-note-actions {
    margin-left: auto;
    display: flex;
    gap: 0.3rem;
}

/* Coaching category badges */
.badge-coaching-general { background: rgba(100,116,139,0.2); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.badge-coaching-braking { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-coaching-racing_line { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-coaching-sector { background: rgba(34,197,94,0.2); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-coaching-setup { background: rgba(168,85,247,0.2); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.badge-coaching-fuel_tyre { background: rgba(251,146,60,0.2); color: #fb923c; border: 1px solid rgba(251,146,60,0.3); }

[data-theme="light"] .badge-coaching-general { color: #64748b; }
[data-theme="light"] .badge-coaching-braking { color: #dc2626; }
[data-theme="light"] .badge-coaching-racing_line { color: #2563eb; }
[data-theme="light"] .badge-coaching-sector { color: #16a34a; }
[data-theme="light"] .badge-coaching-setup { color: #9333ea; }
[data-theme="light"] .badge-coaching-fuel_tyre { color: #ea580c; }

/* Coaching Goals */
.goals-list { display: flex; flex-direction: column; gap: 0.75rem; }
.goal-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}
.goal-item.goal-active { border-left: 3px solid var(--accent); }
.goal-item.goal-achieved { opacity: 0.7; }
.goal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}
.goal-text { font-size: 0.95rem; margin-bottom: 0.5rem; }
.goal-progress {
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}
.goal-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.goal-owner { font-weight: 500; font-size: 0.85rem; }
.goal-coach { font-style: italic; }

/* Goal category badges */
.badge-goal-technique { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-goal-consistency { background: rgba(34,197,94,0.2); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-goal-pace { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-goal-racecraft { background: rgba(251,146,60,0.2); color: #fb923c; border: 1px solid rgba(251,146,60,0.3); }
.badge-goal-setup { background: rgba(168,85,247,0.2); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.badge-goal-other { background: rgba(100,116,139,0.2); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }

[data-theme="light"] .badge-goal-technique { color: #2563eb; }
[data-theme="light"] .badge-goal-consistency { color: #16a34a; }
[data-theme="light"] .badge-goal-pace { color: #dc2626; }
[data-theme="light"] .badge-goal-racecraft { color: #ea580c; }
[data-theme="light"] .badge-goal-setup { color: #9333ea; }
[data-theme="light"] .badge-goal-other { color: #64748b; }

/* Dashboard goals widget */
.dashboard-goals { display: flex; flex-direction: column; gap: 0.5rem; }
.dashboard-goal {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.dashboard-goal:last-child { border-bottom: none; }
.dashboard-goal-text { flex: 1; font-size: 0.9rem; }
.dashboard-goal-coach { font-size: 0.75rem; color: var(--text-dim); font-style: italic; }

/* Dashboard Layout Customisation */
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-icon {
    font-size: 0.9em;
}

.edit-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.edit-mode-bar[hidden] {
    display: none;
}

.edit-mode-actions {
    display: flex;
    gap: 0.5rem;
}

.layout-select-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    /* Removed grid-auto-flow: dense - was causing unexpected reflows when toggling widths */
}

.dashboard-section {
    position: relative;
    transition: opacity 0.2s;
    /* Default: sections span both columns (full width) */
    grid-column: span 2;
}

/* Half-width sections stack side by side */
.dashboard-section[data-width="half"] {
    grid-column: span 1;
}

/* Inner grids in half-width sections should be single column */
.dashboard-section[data-width="half"] .dashboard-grid {
    grid-template-columns: 1fr;
}

/* Prevent content from overflowing in half-width sections */
.dashboard-section[data-width="half"] .card {
    min-width: 0;
    overflow: hidden;
}

.dashboard-section[data-width="half"] .table-wrap {
    overflow-x: auto;
}

/* On mobile, all sections are full width */
@media (max-width: 900px) {
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
    .dashboard-section,
    .dashboard-section[data-width="half"] {
        grid-column: span 1;
    }
}

/* Scrollable sections have max height with scrollbar */
.dashboard-section[data-scrollable="true"] .card {
    max-height: 400px;
    overflow-y: auto;
}

.dashboard-section[data-scrollable="true"] .card h2 {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    z-index: 1;
}

.dashboard-section.dragging {
    opacity: 0.5;
}

.dashboard-section.drag-over {
    border-top: 3px solid var(--accent);
}

.section-edit-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

/* Fix: hidden attribute override - controls only show in edit mode */
.section-edit-controls[hidden] {
    display: none;
}

.section-label {
    flex: 1;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.section-drag-handle {
    cursor: grab;
    color: var(--text-dim);
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    transition: color 0.15s;
}

.section-drag-handle:hover {
    color: var(--accent);
}

.section-drag-handle:active {
    cursor: grabbing;
}

/* Mobile move buttons - shown on touch devices instead of drag */
.section-move-btns {
    display: none;
}

@media (max-width: 900px) {
    .section-drag-handle {
        display: none;
    }
    .section-move-btns {
        display: flex;
        gap: 0.25rem;
    }
}

.section-move-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.9rem;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    line-height: 1;
}

.section-move-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
}

.section-move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.section-hide-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    padding: 0.1rem 0.4rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.section-hide-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Width toggle button in section edit controls */
.section-width-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    text-transform: uppercase;
}

.section-width-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
}

.section-width-btn.is-half {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Scrollable toggle button */
.section-scroll-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.section-scroll-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.section-scroll-btn.is-scrollable {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Dashboard Layout Settings */
.dashboard-layout-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dashboard-layout-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, background 0.15s;
}

.dashboard-layout-item:hover {
    border-color: var(--text-dim);
    background: var(--bg-hover);
}

.dashboard-layout-item.dragging {
    opacity: 0.5;
}

.dashboard-layout-item.drag-over {
    border-color: var(--accent);
    border-top-width: 3px;
}

.layout-drag-handle {
    cursor: grab;
    color: var(--text-dim);
    font-size: 0.9rem;
    padding: 0.2rem;
    transition: color 0.15s;
}

.layout-drag-handle:hover {
    color: var(--accent);
}

.layout-drag-handle:active {
    cursor: grabbing;
}

.layout-item-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    cursor: pointer;
}

.layout-item-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.layout-item-name {
    font-weight: 500;
    font-size: 0.88rem;
}

.layout-item-desc {
    color: var(--text-dim);
    font-size: 0.78rem;
    margin-left: auto;
}

@media (max-width: 768px) {
    .layout-item-desc {
        display: none;
    }

    .page-header-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .edit-mode-bar {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .page-header-actions .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
}

/* Tuning Page */
.division-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.division-tab {
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

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

.division-info-banner {
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.restriction-blocked { color: var(--error); }
.restriction-allowed { color: var(--success); }

/* Division badges */
.badge-division-g1 { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-division-g2 { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-division-s1 { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-division-s2 { background: rgba(251, 146, 60, 0.2); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.3); }
.badge-division-rookie { background: rgba(100, 116, 139, 0.2); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }
.badge-featured { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }

/* Tuning layout */
.tuning-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 1024px) {
    .tuning-layout { grid-template-columns: 1fr; }
}

/* Setup form sections */
.setup-section {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.setup-section[open] .setup-section-toggle { transform: rotate(180deg); }

.setup-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.setup-section-header::-webkit-details-marker { display: none; }

.setup-section-icon { font-size: 1.1rem; }
.setup-section-label { flex: 1; font-weight: 500; font-size: 0.9rem; }
.setup-section-toggle { color: var(--text-dim); transition: transform 0.2s; }

.setup-section-body {
    padding: 0 0.85rem 0.85rem;
    border-top: 1px solid var(--border);
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
    margin-top: 0.75rem;
}

.param-group { margin-bottom: 0; }
.param-group label { font-size: 0.78rem; }
.param-group input { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.param-unit { color: var(--text-dim); font-weight: 400; }
.param-restricted { opacity: 0.5; }
.param-restricted input { background: var(--bg); cursor: not-allowed; }
.param-restricted label::after { content: ' (restricted)'; color: var(--text-dim); font-size: 0.7rem; }
.param-invalid input { border-color: #dc2626 !important; background: rgba(220, 38, 38, 0.1); }
.param-invalid label { color: #dc2626; }

@media (max-width: 768px) {
    .params-grid { grid-template-columns: 1fr; }
}

/* Setups grid */
.setups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.setup-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
    transition: border-color 0.15s;
}

.setup-card:hover { border-color: var(--accent); }
.setup-card.featured { border-color: rgba(251, 191, 36, 0.5); }

.setup-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.setup-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.setup-badges { display: flex; gap: 0.25rem; flex-shrink: 0; }

.setup-card-body { font-size: 0.85rem; margin-bottom: 0.5rem; }
.setup-car { color: var(--text); }
.setup-car-generic, .setup-track-generic { color: var(--text-dim); font-style: italic; }
.setup-track { color: var(--text-muted); }
.setup-meta { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.35rem; }

.setup-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.setup-card-toggles {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-btn:hover { border-color: var(--text-muted); color: var(--text-muted); }
.toggle-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.modal-content-large {
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
}

.modal-body-scroll {
    max-height: calc(90vh - 70px);
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; margin: 0; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    transition: color 0.15s;
}

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

.modal-body { padding: 1.25rem; }

.modal-setup-info { margin-bottom: 1rem; font-size: 0.9rem; }
.modal-setup-info p { margin: 0.35rem 0; color: var(--text-muted); }
.modal-setup-info strong { color: var(--text); }

.modal-setup-params { display: flex; flex-direction: column; gap: 1rem; }

.modal-param-category h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-param-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem 1rem;
}

.modal-param-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.modal-param-label { color: var(--text-muted); }
.modal-param-value { font-family: var(--mono); color: var(--accent); font-weight: 500; }

@media (max-width: 480px) {
    .modal-param-grid { grid-template-columns: 1fr; }

    /* Constrain all modals to viewport width on mobile */
    .modal-content,
    .feedback-modal-content,
    .help-modal-content,
    .help-modal-full {
        max-width: calc(100vw - 2rem);
        overflow-x: hidden;
    }

    /* Ensure images inside modals don't cause overflow */
    .modal-content img,
    .modal-body img {
        max-width: 100%;
        height: auto;
    }
}

/* Feedback modal */
.feedback-modal-content {
    max-width: 500px;
}

.feedback-intro {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.feedback-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.8rem;
}

.feedback-result {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.feedback-result.success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.feedback-result.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* File upload styling */
.form-file-input {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: var(--input);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

.form-file-input:hover {
    border-color: var(--accent);
}

.form-file-input::file-selector-button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    margin-right: 0.75rem;
    font-size: 0.85rem;
}

.form-file-input::file-selector-button:hover {
    background: var(--accent-hover);
}

.feedback-file-list {
    margin-top: 0.5rem;
}

.feedback-file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.feedback-file-item .file-icon {
    font-size: 1rem;
}

.feedback-file-item .file-name {
    color: var(--text);
    word-break: break-all;
}

.feedback-file-item .file-size {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.feedback-file-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

.feedback-icon {
    margin-right: 0.4rem;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Floating feedback button */
.feedback-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 100;
}

.feedback-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.feedback-fab:active {
    transform: scale(0.95);
}

.feedback-fab-icon {
    font-size: 1.25rem;
    line-height: 1;
}

@media (max-width: 480px) {
    .feedback-fab {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    .feedback-fab-icon {
        font-size: 1.1rem;
    }
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* Tuning guide */
.tuning-guide-sections {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guide-category {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.guide-category summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    list-style: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.guide-category summary::-webkit-details-marker { display: none; }
.guide-category-icon { font-size: 1rem; }

.guide-category-body {
    padding: 0 0.85rem 0.85rem;
    border-top: 1px solid var(--border);
}

.guide-explanation {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
    margin: 0.75rem 0;
}

/* Tuning Guides Grid */
.guides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.guide-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
}

.guide-card:hover {
    border-color: var(--accent);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.guide-card-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-subtle, rgba(var(--accent-rgb), 0.1));
    border-radius: var(--radius-sm);
}

.guide-card-content {
    flex: 1;
    min-width: 0;
}

.guide-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--text);
}

.guide-card-excerpt {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.guide-card-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.guide-card:hover .guide-card-arrow {
    transform: translateX(3px);
    color: var(--accent);
}

/* Guide Article Content */
.guide-article {
    line-height: 1.7;
    font-size: 0.92rem;
}

.guide-article h1 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
}

.guide-article h2 {
    font-size: 1.2rem;
    margin: 1.75rem 0 0.75rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

.guide-article h3 {
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--text);
}

.guide-article h4 {
    font-size: 0.92rem;
    margin: 1rem 0 0.4rem;
    color: var(--text-muted);
    font-weight: 600;
}

.guide-article p {
    margin: 0.6rem 0;
}

.guide-article ul, .guide-article ol {
    margin: 0.6rem 0;
    padding-left: 1.5rem;
}

.guide-article li {
    margin: 0.3rem 0;
}

.guide-article strong {
    color: var(--text);
}

.guide-article code {
    background: var(--bg-input);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
    color: var(--accent);
}

.guide-article pre {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.75rem 0;
}

.guide-article pre code {
    background: none;
    padding: 0;
}

.guide-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

.guide-article th, .guide-article td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.guide-article th {
    background: var(--bg-input);
    font-weight: 600;
}

.guide-article tr:nth-child(even) {
    background: var(--bg-input);
}

.guide-article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.guide-article blockquote {
    margin: 0.75rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid var(--accent);
    background: var(--bg-input);
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .guides-grid {
        grid-template-columns: 1fr;
    }

    .guide-article h1 {
        font-size: 1.25rem;
    }

    .guide-article h2 {
        font-size: 1.1rem;
    }
}

/* Resources */
.resource-filter {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.resource-filter-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.resource-filter-btn:hover { border-color: var(--accent); color: var(--text); }
.resource-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.resources-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.resource-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: flex-start;
}

.resource-type-icon { font-size: 1.25rem; flex-shrink: 0; }

.resource-content { flex: 1; min-width: 0; }

.resource-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--accent);
    text-decoration: none;
    display: block;
}

.resource-title:hover { text-decoration: underline; }

.resource-desc {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0.25rem 0 0;
    line-height: 1.5;
}

.resource-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.badge-resource-general { background: rgba(100,116,139,0.2); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.badge-resource-suspension { background: rgba(59,130,246,0.2); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-resource-aero { background: rgba(34,197,94,0.2); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-resource-brakes { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-resource-differential { background: rgba(168,85,247,0.2); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }

.resource-delete {
    flex-shrink: 0;
}

.add-resource-panel summary {
    cursor: pointer;
    list-style: none;
}

.add-resource-panel summary::-webkit-details-marker { display: none; }

.add-resource-form {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Print styles */
@media print {
    :root, [data-theme="dark"] {
        --bg: #fff;
        --bg-card: #fff;
        --bg-input: #f5f5f5;
        --bg-hover: #f0f0f0;
        --border: #ddd;
        --text: #000;
        --text-muted: #333;
        --text-dim: #666;
        --zebra: #f9f9f9;
    }

    .main-nav,
    .main-nav::after,
    .theme-toggle,
    .nav-toggle,
    .site-footer::before,
    .btn-delete,
    .btn-edit { display: none !important; }

    .card { box-shadow: none; border: 1px solid #ddd; }
    .card:hover { transform: none; }

    table { width: 100%; font-size: 10pt; }
    td, th { padding: 4px 6px; }

    .container { max-width: 100%; padding: 0; }
    body { font-size: 11pt; }
}

/* Help Button */
.help-toggle {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--mono);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
}

.help-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* Help Modal Styles */
.help-modal-content {
    max-width: 540px;
}

.help-modal-full {
    max-width: 800px;
    max-height: 85vh;
}

.help-icon {
    margin-right: 0.4rem;
}

.help-summary {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1.25rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.help-sections {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.help-section {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.help-section summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}

.help-section summary::after {
    content: '+';
    font-size: 1.1rem;
    color: var(--text-dim);
    transition: transform 0.2s;
}

.help-section[open] summary::after {
    content: '−';
}

.help-section summary::-webkit-details-marker {
    display: none;
}

.help-section summary:hover {
    background: var(--bg-hover);
}

.help-section p {
    margin: 0;
    padding: 0 1rem 1rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.help-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}

.help-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s;
}

.help-link:hover {
    color: var(--accent);
}

.help-no-content {
    color: var(--text-dim);
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem 1rem;
}

/* Full Help Guide */
.help-toc {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.help-toc h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin: 0 0 0.75rem 0;
}

.help-toc ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.35rem 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-toc a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: color 0.15s;
}

.help-toc a:hover {
    color: var(--accent);
}

.help-full-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.help-page-section {
    scroll-margin-top: 1rem;
}

.help-page-section h4 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    color: var(--text);
}

.help-page-section h4 .help-icon {
    font-size: 1.1rem;
}

.help-page-section > .help-summary {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
}

@media (max-width: 600px) {
    .help-toc ul {
        grid-template-columns: repeat(2, 1fr);
    }

    .help-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .help-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 0.85rem 1rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.pwa-install-banner.visible {
    transform: translateY(0);
}

.pwa-install-banner-content {
    flex: 1;
    min-width: 0;
}

.pwa-install-banner-text {
    font-size: 0.9rem;
    color: var(--text);
    margin: 0;
}

.pwa-install-banner-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.pwa-install-banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pwa-install-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.pwa-install-btn:hover {
    background: var(--accent-hover);
}

.pwa-dismiss-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.pwa-dismiss-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

@media (max-width: 480px) {
    .pwa-install-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 0.75rem;
    }

    .pwa-install-banner-actions {
        justify-content: center;
    }
}

/* Button Ripple Effect */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.btn {
    position: relative;
    overflow: hidden;
}

.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.5s linear;
    pointer-events: none;
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
}

/* Desktop: bottom-right */
@media (min-width: 481px) {
    .toast-container {
        bottom: 1.5rem;
        right: 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-end;
        max-width: 400px;
    }
}

/* Mobile: bottom, full-width */
@media (max-width: 480px) {
    .toast-container {
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }
}

@keyframes toastSlideInDesktop {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideInMobile {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastSlideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes toastSlideOutMobile {
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    min-width: 280px;
    max-width: 100%;
}

@media (min-width: 481px) {
    .toast {
        animation: toastSlideInDesktop 0.3s ease-out;
    }
    .toast.toast-exit {
        animation: toastSlideOut 0.2s ease-in forwards;
    }
}

@media (max-width: 480px) {
    .toast {
        animation: toastSlideInMobile 0.3s ease-out;
        width: 100%;
    }
    .toast.toast-exit {
        animation: toastSlideOutMobile 0.2s ease-in forwards;
    }
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    word-wrap: break-word;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    margin: -0.25rem -0.25rem -0.25rem 0;
    line-height: 1;
    transition: color 0.15s;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 0 var(--radius);
}

/* Toast variants */
.toast-success {
    border-left: 3px solid var(--success);
}
.toast-success .toast-icon { color: var(--success); }

.toast-error {
    border-left: 3px solid var(--error);
}
.toast-error .toast-icon { color: var(--error); }

.toast-warning {
    border-left: 3px solid var(--warning);
}
.toast-warning .toast-icon { color: var(--warning); }

.toast-info {
    border-left: 3px solid var(--accent);
}
.toast-info .toast-icon { color: var(--accent); }

/* ============================================
   Onboarding Tour System
   ============================================ */
.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9000;
    pointer-events: none;
}

.tour-highlight {
    position: absolute;
    border-radius: var(--radius);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
    pointer-events: none;
    z-index: 9001;
}

@keyframes tourPulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75), 0 0 0 0 rgba(var(--accent-rgb), 0.4); }
    50% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75), 0 0 0 8px rgba(var(--accent-rgb), 0.2); }
}

.tour-highlight.pulse {
    animation: tourPulse 2s ease-in-out infinite;
}

/* Desktop tooltip */
@media (min-width: 481px) {
    .tour-tooltip {
        position: absolute;
        z-index: 9002;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1rem 1.25rem;
        max-width: 320px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        animation: fadeSlideUp 0.3s ease-out;
        pointer-events: auto;
    }
}

/* Mobile bottom sheet style */
@media (max-width: 480px) {
    .tour-tooltip {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9002;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        border-radius: var(--radius) var(--radius) 0 0;
        padding: 1.25rem;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
        animation: toastSlideInMobile 0.3s ease-out;
        pointer-events: auto;
    }
}

.tour-tooltip-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.tour-tooltip-content {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.tour-tooltip-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.tour-tooltip-progress {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.tour-tooltip-btns {
    display: flex;
    gap: 0.5rem;
}

.tour-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tour-btn-skip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.tour-btn-skip:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.tour-btn-next {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
}

.tour-btn-next:hover {
    opacity: 0.9;
}

/* ============================================
   Ambient Racing Effects (Desktop Only)
   ============================================ */
@keyframes racingStripes {
    0% { background-position: 0 0; }
    100% { background-position: 60px 60px; }
}

.ambient-stripes {
    position: relative;
}

/* Only apply on desktop for performance */
@media (min-width: 769px) {
    .ambient-stripes::before {
        content: '';
        position: absolute;
        inset: 0;
        background: repeating-linear-gradient(
            135deg,
            transparent,
            transparent 20px,
            rgba(var(--accent-rgb), 0.02) 20px,
            rgba(var(--accent-rgb), 0.02) 40px
        );
        animation: racingStripes 4s linear infinite;
        pointer-events: none;
        z-index: 0;
    }
}

/* Racing-themed loading indicator */
@keyframes loadingTach {
    0% { transform: rotate(-45deg); }
    50% { transform: rotate(225deg); }
    100% { transform: rotate(-45deg); }
}

.loading-tach {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-radius: 50%;
    position: relative;
}

.loading-tach::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 16px;
    background: var(--accent);
    transform-origin: bottom center;
    animation: loadingTach 1.5s ease-in-out infinite;
    margin-left: -1px;
    margin-top: -16px;
}

/* ============================================
   Achievement Celebration System
   ============================================ */
@keyframes achievementSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-100%) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateY(10px) scale(1.05);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes achievementSlideOut {
    to {
        opacity: 0;
        transform: translateY(-100%);
    }
}

@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100px) rotate(720deg);
        opacity: 0;
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.achievement-popup {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: linear-gradient(135deg, #1a1625 0%, #2d2444 100%);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: achievementSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: calc(100vw - 2rem);
}

.achievement-popup.exit {
    animation: achievementSlideOut 0.3s ease-in forwards;
}

.achievement-badge {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--gold) 0%, #d97706 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
}

.achievement-content {
    min-width: 0;
}

.achievement-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 0.15rem;
    background: linear-gradient(90deg, var(--gold), #fef3c7, var(--gold));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2s linear infinite;
}

.achievement-title {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    margin-bottom: 0.15rem;
}

.achievement-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.confetti-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    pointer-events: none;
    animation: confetti 1.5s ease-out forwards;
    z-index: 9998;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .achievement-popup {
        left: 0.5rem;
        right: 0.5rem;
        transform: none;
        padding: 0.85rem 1rem;
    }

    .achievement-badge {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
}

/* Pinned Car Dashboard Section */
.pinned-car-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    max-width: 100%;
}

.pinned-car-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pinned-car-header h2 {
    margin: 0;
}

.pinned-car-content {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    overflow: hidden;
    max-width: 100%;
}

.pinned-car-image {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pinned-car-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pinned-car-placeholder {
    font-size: 2rem;
    opacity: 0.5;
}

.pinned-car-info {
    flex: 1;
    min-width: 0;
}

.pinned-car-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pinned-car-name a {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
}

.pinned-car-name a:hover {
    color: var(--accent);
}

.pinned-car-manufacturer {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.pinned-car-specs {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pinned-car-specs .spec {
    display: flex;
    gap: 0.25rem;
}

.pinned-car-specs .spec strong {
    color: var(--text);
}

.pinned-car-stats {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.pinned-car-times {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.pinned-car-times-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}

.pinned-car-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}

.pinned-car-time-row .track-name {
    color: var(--text-muted);
}

.pinned-car-time-row .lap-time {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-weight: 500;
}

.pinned-car-details {
    display: flex;
    gap: 1.5rem;
    align-items: stretch;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.pinned-car-fastest {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    background: var(--accent-dim);
    border-radius: var(--radius);
}

.pinned-car-fastest .fastest-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.pinned-car-fastest .fastest-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent);
}

.pinned-car-fastest .fastest-track {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.pinned-car-test-stats {
    display: flex;
    gap: 1rem;
}

.pinned-car-test-stats .test-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    min-width: 60px;
}

.pinned-car-test-stats .test-stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

.pinned-car-test-stats .test-stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

@media (max-width: 480px) {
    /* Force all pinned car elements to respect container width */
    .pinned-car-card,
    .pinned-car-card * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .pinned-car-content {
        flex-direction: column;
        width: 100%;
    }

    .pinned-car-image {
        width: 100%;
        height: 100px;
    }

    /* Ensure pinned car image doesn't overflow */
    .pinned-car-image img {
        max-width: 100%;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .pinned-car-info {
        width: 100%;
    }

    .pinned-car-specs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pinned-car-details {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .pinned-car-test-stats {
        justify-content: center;
        width: 100%;
    }

    .pinned-car-times {
        width: 100%;
    }

    /* Prevent all card images from causing overflow */
    .card img {
        max-width: 100%;
        height: auto;
    }
}

/* Team Switcher */
.team-switcher-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.team-switcher-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 1rem 0.5rem;
}

.team-switch-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}

.team-switch-option:hover {
    background: var(--bg-hover);
}

.team-switch-option.current {
    background: var(--accent-dim);
    cursor: default;
}

.team-accent-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.team-current-badge {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Mobile team switcher */
.team-switcher-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.team-switcher-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.25rem 0;
}

.team-switch-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.team-switch-link:hover {
    background: var(--accent);
    color: #fff;
}
