/* ══════════════════════════════════════════════════════════════
   Jet Soft — Design System
   Dark motorsport theme with orange accent
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary:    #0d1117;
    --bg-secondary:  #161b22;
    --bg-tertiary:   #21262d;
    --bg-hover:      #292e36;
    --border:        #30363d;
    --border-light:  #444c56;
    --text-primary:  #e6edf3;
    --text-secondary:#9198a1;
    --text-muted:    #848d97;
    --accent:        #f97316;
    --accent-hover:  #ea580c;
    --accent-soft:   rgba(249,115,22,0.15);
    --yellow:        #f59e0b;
    --yellow-soft:   rgba(245,158,11,0.15);
    --green:         #22c55e;
    --green-soft:    rgba(34,197,94,0.15);
    --red:           #ef4444;
    --red-soft:      rgba(239,68,68,0.15);
    --blue:          #3b82f6;
    --blue-soft:     rgba(59,130,246,0.15);
    --purple:        #a855f7;
    --radius:        8px;
    --radius-sm:     4px;
    --radius-lg:     12px;
    --shadow:        0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg:     0 8px 24px rgba(0,0,0,0.4);
    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:     'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --transition:    150ms ease;
    --text-page-title: 1.57rem;
    --text-section:    1.07rem;
    --text-card:       0.93rem;
}

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

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

/* ── NAV BAR ─────────────────────────────────────────────── */

.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 8px;
}

.nav-logo {
    font-weight: 700; font-size: 1.15rem;
    color: var(--accent);
    margin-right: 24px;
    white-space: nowrap;
    letter-spacing: -0.02em;
}
.nav-logo span { color: var(--text-primary); }

.nav-links { display: flex; gap: 4px; flex: 1; }

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.92rem; font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-tertiary); text-decoration: none; }
.nav-link.active {
    color: var(--text-primary);
    background: transparent;
    font-weight: 600;
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
    padding-bottom: 4px;
}
.nav-link.active:hover { background: transparent; }

.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.nav-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 12px; border-radius: var(--radius);
    color: var(--text-secondary); font-size: 0.85rem;
    cursor: pointer; transition: all var(--transition);
    background: none; border: none; font-family: var(--font);
}
.nav-user:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.nav-avatar {
    width: 28px; height: 28px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem; font-weight: 700;
    color: #000;
    flex-shrink: 0;
    text-decoration: none;
}
.nav-separator {
    width: 1px; height: 20px;
    background: var(--border);
    margin: 0 8px;
}
.nav-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.7rem; font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    align-self: center;
}
.nav-badge:hover { color: var(--text-primary); text-decoration: none; }
.nav-badge[aria-current="page"] {
    color: var(--text-primary);
    background: rgba(249,115,22,0.12);
}

.nav-hamburger {
    display: none; background: none; border: none;
    color: var(--text-primary); font-size: 1.4rem; cursor: pointer;
    padding: 4px 8px;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */

#app {
    margin-top: 56px;
    padding: 24px;
    max-width: 1400px;
    margin-left: auto; margin-right: auto;
    min-height: calc(100vh - 56px);
}

/* ── CARDS ────────────────────────────────────────────────── */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1.05rem; font-weight: 600; }
.card-body { padding-top: 4px; }
.profile-detail-grid { padding: 4px 0; }
.profile-detail-row {
    display: flex; align-items: baseline; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.profile-detail-row:last-child { border-bottom: none; }
.profile-detail-label {
    width: 110px; flex-shrink: 0;
    font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-secondary);
}
.profile-detail-value { color: var(--text-primary); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* ── BUTTONS ─────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font); font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-outline {
    background: transparent; color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-light); background: var(--bg-tertiary); }

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}
.btn-danger-outline:hover:not(:disabled) { background: var(--red-soft); }

.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.form-select-sm { padding: 4px 8px; font-size: 0.82rem; width: auto; }
.btn-icon { padding: 6px; width: 34px; height: 34px; }

/* ── FORMS ────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block; margin-bottom: 4px;
    font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font); font-size: 0.92rem;
    transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-input::placeholder { color: var(--text-muted); }

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

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

.form-error { color: var(--red); font-size: 0.82rem; margin-top: 4px; }
.form-hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }

.form-inline {
    display: flex; gap: 8px; align-items: end;
}
.form-inline .form-group { margin-bottom: 0; flex: 1; }

/* ── CLASS CHECKBOX GROUPS ───────────────────────────────── */

.class-group-label {
    font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 10px 0 5px; display: block;
}
.class-group-label:first-child { margin-top: 0; }

/* ── COLLAPSIBLE FORM ────────────────────────────────────── */

.collapsible-form {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.collapsible-form-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer; user-select: none;
    font-weight: 600; font-size: 0.95rem;
    color: var(--text-primary);
    transition: background var(--transition);
}
.collapsible-form-header:hover { background: var(--bg-tertiary); }
.collapsible-form.open .collapsible-form-header {
    border-radius: var(--radius) var(--radius) 0 0;
}
.collapsible-form-body {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--border);
}
.collapsible-form.open .collapsible-form-body { display: block; }
.collapsible-form-toggle { color: var(--text-muted); font-size: 0.82rem; }

/* ── TABLES ───────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
    width: 100%; border-collapse: collapse;
    font-size: 0.9rem;
}
thead th {
    text-align: left; padding: 10px 12px;
    font-weight: 600; font-size: 0.8rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-secondary);
}
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

.table-mono { font-family: var(--font-mono); }

/* ── RESULTS ─────────────────────────────────────────────── */

.results-table .results-total-th,
.results-table .results-total-td {
    background: rgba(249,115,22,0.07);
    color: var(--accent);
    font-weight: 700;
}

/* Pill-style class tabs */
.results-tab {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: transparent;
    transition: all var(--transition);
}
.results-tab:hover { color: var(--text-primary); border-color: var(--border-light); }
.results-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Inline moto cell: P2 · 22 */
.moto-combined { white-space: nowrap; }
.moto-pos { color: var(--text-primary); font-weight: 500; }
.moto-pts { color: var(--text-muted); font-size: 0.82rem; }

/* ── BADGES ───────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-orange { background: var(--accent-soft); color: var(--accent); }
.badge-muted  { background: var(--bg-tertiary); color: var(--text-muted); }

/* ── APPEAL BANNERS ───────────────────────────────────────── */

.appeal-banner .card-header { align-items: center; gap: 12px; }
.appeal-banner.banner-provisional { border-left: 4px solid var(--yellow); }
.appeal-banner.banner-locked { border-left: 4px solid var(--text-muted); background: var(--bg-tertiary); }
.appeal-banner .ml-auto { margin-left: auto; }

/* ── STATUS DOTS ──────────────────────────────────────────── */

.status-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; margin-right: 6px;
}
.status-dot.live { background: var(--green); animation: pulse 2s infinite; }
.status-dot.stopped { background: var(--red); }
.status-dot.scheduled { background: var(--yellow); }
.status-dot.finished { background: var(--text-muted); }
.status-dot.cancelled { background: var(--text-muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── TABS ─────────────────────────────────────────────────── */

.tabs {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 20px;
    font-size: 0.9rem; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none; border-top: none; border-left: none; border-right: none;
    font-family: var(--font);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── EVENTS CALENDAR ─────────────────────────────────────── */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}
.calendar-weekday {
    background: var(--bg-secondary);
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.calendar-day {
    background: var(--bg);
    min-height: 110px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}
.calendar-day-blank { background: var(--bg-secondary); opacity: 0.4; }
.calendar-day-today { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-day-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.calendar-day-today .calendar-day-number { color: var(--accent); }
.calendar-event-pill {
    display: block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    background: var(--bg-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 3px solid var(--accent);
    transition: background 120ms;
}
.calendar-event-pill:hover { background: var(--bg-secondary); }
.calendar-event-pill.badge-green  { border-left-color: var(--green); }
.calendar-event-pill.badge-yellow { border-left-color: var(--yellow); }
.calendar-event-pill.badge-red    { border-left-color: var(--red); }
.calendar-event-pill.badge-blue   { border-left-color: var(--blue); }
.calendar-event-pill.badge-orange { border-left-color: var(--accent); }
.calendar-event-pill.badge-muted  { border-left-color: var(--text-muted); }
.calendar-event-more { padding: 0 8px; }
.calendar-legend { padding: 4px 0 16px; }

@media (max-width: 768px) {
    .calendar-day { min-height: 80px; padding: 4px; }
    .calendar-day-number { font-size: 0.75rem; }
    .calendar-event-pill { font-size: 0.7rem; padding: 1px 4px; }
    .calendar-weekday { padding: 6px 4px; font-size: 0.65rem; }
}

/* ── EMPTY STATE ─────────────────────────────────────────── */

.empty-state {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 48px 24px; gap: 6px;
}
.empty-state-icon {
    width: 48px; height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.empty-state-title {
    color: var(--text-primary);
    font-size: var(--text-section);
    font-weight: 600; margin: 0;
}
.empty-state-message {
    color: var(--text-muted);
    font-size: 0.9rem; margin: 0; max-width: 300px;
}
.empty-state-cta { margin-top: 12px; }

/* ── AUTH LAYOUT ──────────────────────────────────────────── */

.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 56px);
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 {
    font-size: 1.5rem; text-align: center; margin-bottom: 8px;
}
.auth-card .subtitle {
    text-align: center; color: var(--text-secondary);
    margin-bottom: 24px; font-size: 0.9rem;
}
.auth-card .logo-text {
    text-align: center; font-size: 1.6rem; font-weight: 700;
    color: var(--accent); margin-bottom: 24px;
}
.auth-card .logo-text span { color: var(--text-primary); }
.auth-card--wide { max-width: 520px; }
.form-section-label {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-secondary);
    border-bottom: 1px solid var(--border); padding-bottom: 8px;
    margin-bottom: 16px;
}

/* ── PAGE HEADER ──────────────────────────────────────────── */

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--text-secondary); margin-top: 4px; }

/* ── STAT CARDS ───────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.stat-card .value.mono { font-family: var(--font-mono); }

/* ── DASHBOARD METRICS ────────────────────────────────────── */

.dash-metric-row {
    display: flex;
    gap: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.dash-metric {
    display: flex;
    flex-direction: column;
}
.dash-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.dash-metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* ── TOAST NOTIFICATIONS ──────────────────────────────────── */

#toast-container {
    position: fixed; top: 72px; right: 24px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: slide-in 300ms ease;
    max-width: 380px;
    display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--yellow); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.fade-out { animation: slide-out 300ms ease forwards; }
.toast-undo-btn {
    background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm); padding: 3px 10px; font-size: 0.82rem; font-weight: 600;
    cursor: pointer; margin-left: 12px; white-space: nowrap; font-family: var(--font);
    transition: background var(--transition);
}
.toast-undo-btn:hover { background: rgba(255,255,255,0.25); }

@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ── MODAL ────────────────────────────────────────────────── */

#modal-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.6);
    align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
#modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px; width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modal-in 200ms ease;
}
.modal h2 { font-size: 1.15rem; margin-bottom: 12px; }
.modal p { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.92rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

@keyframes modal-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── CLASS CHECKBOXES ─────────────────────────────────────── */

.class-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.class-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.class-checkbox:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}
.class-checkbox:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.class-checkbox input[type="checkbox"] {
    width: 14px; height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── AUTOCOMPLETE ─────────────────────────────────────────── */

.ac-wrapper {
    position: relative;
}
.ac-dropdown {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    z-index: 50;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
}
.ac-dropdown.open { display: block; }

.ac-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active {
    background: var(--bg-hover);
}
.ac-item-name {
    font-weight: 600;
    font-size: 0.92rem;
}
.ac-item-team {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.ac-empty {
    padding: 12px 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.form-input.ac-selected {
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--text-primary);
}

/* ── FLASH ANIMATION (new laps) ──────────────────────────── */

@keyframes flash-row {
    0%   { background: var(--accent-soft); border-left: 3px solid var(--accent); }
    100% { background: transparent; border-left: 3px solid transparent; }
}
tr.flash { animation: flash-row 2s ease-out; }

/* ── LOADING SPINNER ──────────────────────────────────────── */

.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.loading-center { display: flex; justify-content: center; padding: 48px; }

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

/* ── RESPONSIVE ───────────────────────────────────────────── */

@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-hamburger { display: block; }
    .nav-links.open {
        display: flex; flex-direction: column;
        position: absolute; top: 56px; left: 0; right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        padding: 8px;
    }
    #app { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    /* Horizontal scroll for tab overflow */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex-shrink: 0; }
    /* Stack inline forms on mobile */
    .form-inline { flex-direction: column; }
    .form-inline .form-group { width: 100%; }
    .form-inline .btn { width: 100%; margin-top: 8px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 16px; }
}

/* ── UTILITY ──────────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* ── PAGINATION ───────────────────────────────────────────── */

.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.85rem; color: var(--text-secondary); }

/* ── Results / Championship Standings ───────────────────────────────────── */

.results-header {
    padding: 24px 0 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
.results-title h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.results-events {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.results-event-badge {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    min-width: 120px;
}
.event-date { font-size: 0.75rem; color: var(--accent); font-weight: 600; font-family: var(--font-mono); }
.event-name { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

.results-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
/* .results-tab styles consolidated above in the RESULTS section */

.results-section { padding: 20px 0; }
.results-class-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.results-class-header h2 { font-size: 1.15rem; font-weight: 700; }

.results-table-wrap { overflow-x: auto; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.results-table th {
    padding: 8px 10px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.results-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--bg-hover); }

/* Medal rows */
.results-table tr.medal-gold   td { background: rgba(234,179,8,0.06); }
.results-table tr.medal-silver td { background: rgba(156,163,175,0.06); }
.results-table tr.medal-bronze td { background: rgba(180,83,9,0.06); }
.results-table tr.medal-gold:hover   td,
.results-table tr.medal-silver:hover td,
.results-table tr.medal-bronze:hover td { background: var(--bg-hover); }

/* Place badge */
.place-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.place-badge.medal-gold   { background: #d97706; color: #fff; }
.place-badge.medal-silver { background: #6b7280; color: #fff; }
.place-badge.medal-bronze { background: #92400e; color: #fff; }

.col-place { width: 44px; text-align: center; }
.col-no    { width: 52px; font-family: var(--font-mono); }
.col-flag  { width: 36px; text-align: center; font-size: 1.1rem; }
.col-event { width: 72px; text-align: right; font-family: var(--font-mono); font-size: 0.78rem; }
.col-total { width: 64px; text-align: right; font-family: var(--font-mono); }
.col-riders { min-width: 120px; }

.bib { font-weight: 600; color: var(--text-secondary); }
.flag-cell { text-align: center; }
.racer-name { font-weight: 500; }
.pts-val   { text-align: right; font-family: var(--font-mono); color: var(--text-secondary); }
.pts-empty { text-align: right; color: var(--text-muted); font-family: var(--font-mono); }
.pts-dsq   { text-align: right; color: var(--red); font-size: 0.75rem; font-weight: 600; }
.total-cell { text-align: right; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.hidden { display: none !important; }

/* ── CHAMPIONSHIP POINTS (racer profile) ────────────────── */
.champ-entry { padding: 16px; }
.champ-entry-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.champ-entry-title { font-weight: 600; }
.champ-events-list { display: flex; flex-direction: column; gap: 8px; }
.champ-event-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.champ-event-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary, var(--bg-secondary));
    border-bottom: 1px solid var(--border);
}
.champ-event-name { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }
.champ-event-pts { font-size: 0.85rem; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); }
.champ-race-row {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
}
.champ-race-row:last-child { border-bottom: none; }
.champ-race-name { flex: 1; font-size: 0.88rem; color: var(--text-primary); text-decoration: none; }
.champ-race-name:hover { text-decoration: underline; color: var(--primary); }
.champ-race-meta { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.champ-race-pts { font-size: 0.88rem; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); min-width: 48px; text-align: right; }

/* ── SKIP-TO-CONTENT ────────────────────────────────────── */

.skip-link {
    position: absolute; left: -9999px;
    background: var(--accent); color: #fff;
    padding: 8px 16px; border-radius: var(--radius);
    font-weight: 600; font-size: 0.9rem;
    z-index: 999; text-decoration: none;
}
.skip-link:focus {
    position: fixed; top: 8px; left: 8px;
}

/* ── PREFERS REDUCED MOTION ─────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .status-dot.live { animation: none; }
    tr.flash { animation: none; }
    .toast { animation: none; }
    .toast.fade-out { animation: none; opacity: 0; }
    .modal { animation: none; }
}

/* --- Event checklist panel --- */
.event-checklist { border-left: 3px solid var(--accent); }
.event-checklist .card-header { cursor: default; }
.ecl-summary-bar {
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ecl-summary-bar.ecl-ready { color: var(--green); }
.ecl-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    width: 28px; height: 28px;
    margin-left: auto;
}
.ecl-toggle:hover { color: var(--text-primary); }
.ecl-items { padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.ecl-item {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
}
.ecl-item.ecl-done { border-color: rgba(34,197,94,0.3); }
.ecl-item.ecl-required-missing { border-color: rgba(239,68,68,0.35); }
.ecl-status { font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; }
.ecl-status.ecl-done { color: var(--green); }
.ecl-status.ecl-pending { color: var(--text-muted); }
.ecl-label { font-weight: 500; color: var(--text-primary); }
.ecl-summary { color: var(--text-secondary); font-size: 0.85rem; }
.ecl-req-tag { display: inline-block; margin-left: 8px; font-size: 0.7rem; color: var(--red); text-transform: uppercase; letter-spacing: 0.05em; }
.ecl-edit-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.ecl-edit-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.ecl-inline-editor {
    grid-column: 1 / -1;
    padding: 12px;
    margin-top: 4px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}
.ecl-inline-editor .form-group { margin-bottom: 10px; }
.ecl-inline-editor .ecl-editor-actions { display: flex; gap: 8px; margin-top: 8px; }
.ecl-publish-box {
    margin: 16px 16px 16px;
    padding: 14px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}
.ecl-publish-box.ecl-blocked { border-color: var(--red); }
.ecl-publish-box.ecl-ready { border-color: var(--green); }
.ecl-breadcrumb {
    background: var(--accent-soft);
    border: 1px solid rgba(249,115,22,0.3);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* TV view — hide all SPA chrome */
body.tv-mode {
    background: #0a0a0a;
    color: #f5f5f5;
}
body.tv-mode #nav,
body.tv-mode #toast-container,
body.tv-mode #modal-overlay,
body.tv-mode .skip-link {
    display: none !important;
}
body.tv-mode #app {
    max-width: none;
    padding: 0;
    margin: 0;
}
.ecl-breadcrumb a { color: var(--accent); cursor: pointer; }
