:root {
    --bg-app: #09090b;
    --bg-panel: #18181b;
    --bg-hover: #27272a;
    --border: #3f3f46;
    --text-main: #e4e4e7;
    --text-muted: #a1a1aa;
    /* BRAND ORANGE */
    --accent: #f97316; 
    --accent-hover: #ea580c;
    --danger: #ef4444;
    --nav-width: 260px;
}

/* --- BASE RESETS & VIEW TRANSITIONS --- */
html { 
    scrollbar-gutter: stable; 
    height: 100%; 
}

body { 
    background-color: var(--bg-app); 
    color: var(--text-main); 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    margin: 0; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    position: relative; /* Context for absolute positioning */
}

a { text-decoration: none; color: inherit; transition: 0.2s; }

/* --- SMOOTH PAGE TRANSITIONS (View Transitions API) --- */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- BACKGROUND VIGNETTE LAYER --- */
/* The canvas (nodes) is injected by JS at z-index: -1. 
   This overlay sits on top of it to darken edges. */
body::after {
    content: "";
    position: fixed;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    z-index: 0; /* Above canvas (-1), below content (1) */
    background: radial-gradient(circle at 50% 50%, transparent 0%, rgba(9, 9, 11, 0.8) 100%);
    pointer-events: none;
}

/* Ensure interactive content floats above the background system */
main, nav, footer, .admin-layout {
    position: relative;
    z-index: 1;
}

/* --- UTILITY CLASSES --- */
.text-accent { color: var(--accent) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Discipline Specific Colors */
.rating-ow { color: #3b82f6 !important; }
.rating-sc { color: #10b981 !important; }
.rating-ov { color: #eab308 !important; }

/* --- LAYOUTS --- */
.admin-layout { 
    display: grid; 
    grid-template-columns: var(--nav-width) 1fr; 
    min-height: 100vh;
}

/* Admin Sidebar */
.admin-sidebar {
    background: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    /* Removed overflow-y: auto from here */
    box-sizing: border-box;
}

.admin-content { 
    padding: 30px; 
    box-sizing: border-box;
}

/* --- NAVIGATION COMPONENTS --- */
.nav-section { margin-bottom: 24px; }
.nav-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 700;
}
.nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
    color: var(--text-main);
    border-right: 3px solid transparent;
    transition: 0.2s;
}
.nav-link:hover { background: var(--bg-hover); }
.nav-link.active { 
    background: var(--bg-hover); 
    color: var(--accent);
    border-right-color: var(--accent);
}

/* --- CARDS & PANELS --- */
.admin-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.admin-card:hover { border-color: var(--accent); }

/* --- BUTTONS --- */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
}
.btn-modern:hover { background: var(--border); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); color: #000; }

/* --- FORMS --- */
input, select, textarea {
    background: #0f1115;
    border: 1px solid var(--border);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}


img[src*="flagcdn"] {
    color: transparent;
    text-indent: -10000px;
}
/* --- TABLES --- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; padding: 12px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.clickable-row:hover { background: var(--bg-hover); cursor: pointer; }

/* --- STATISTICS GRID (Driver Profile) --- */
.stat-box { background: var(--bg-hover); border-radius: 8px; border: 1px solid var(--border); margin-bottom: 12px; overflow: hidden; }
.stat-series { display: block; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; padding: 8px 12px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; text-align: center; padding: 10px; }
.stat-val { font-size: 1.1rem; font-weight: 800; color: #fff; line-height: 1.1; }
.stat-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }
.stat-rating { font-family: monospace; font-size: 0.9rem; font-weight: bold; margin-top: 8px; display: block; text-align: center; padding-bottom: 8px; }

/* --- BADGES --- */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.badge-ow { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid #3b82f6; }
.badge-sc { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.badge-ov { background: rgba(234, 179, 8, 0.2); color: #facc15; border: 1px solid #eab308; }

.lic-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 4px; font-weight: 800; color: white;
    font-size: 0.8rem; border: 1px solid rgba(255,255,255,0.1);
}
.lic-A { background: #3b82f6; } 
.lic-B { background: #10b981; } 
.lic-C { background: #eab308; }
.lic-D { background: #f97316; } 
.lic-R { background: #64748b; }

/* --- REVEAL ANIMATION (Used in lists) --- */
.reveal-row {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}
.reveal-row.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- HIGH PERFORMANCE REPORT MODAL --- */
.report-modal { 
    display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; 
    background-color: rgba(9, 9, 11, 0.96); backdrop-filter: blur(12px); 
    align-items: center; justify-content: center; cursor: zoom-out; 
    opacity: 0; will-change: opacity; transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
}
.report-modal.active { display: flex; opacity: 1; }
.report-content { 
    max-width: 92%; max-height: 92%; border-radius: 12px; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); border: 1px solid rgba(255,255,255,0.1); 
    opacity: 0; transform: scale(0.95) translateY(10px); will-change: transform, opacity; 
    transition: transform 0.25s cubic-bezier(0.05, 0.7, 0.1, 1.0), opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
}
.report-modal.active .report-content { opacity: 1; transform: scale(1) translateY(0); }

/* --- FIXED BACKGROUND CANVAS --- */
#beamgp-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    /* CSS handles the background color instantly (no flash) */
    background-color: var(--bg-app); 
    
    /* Start invisible to hide the "empty" state while JS loads */
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

/* Class added by JS once the first frame is ready */
#beamgp-bg.loaded {
    opacity: 1;
}