:root {
    /* Color Palette */
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --surface-hover: rgba(51, 65, 85, 0.8);
    --primary-color: #38bdf8;
    --primary-hover: #0ea5e9;
    --secondary-color: #6366f1;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.2);
    --success-color: #22c55e;
    --warning-color: #eab308;
    --danger-color: #ef4444;

    /* Spacing & Layout */
    --header-height: 70px;
    --sidebar-width: 250px;
    --border-radius: 12px;
    --transition-speed: 0.3s;

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.65);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --backdrop-blur: 12px;

    /* Shadow */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-speed);
}

ul {
    list-style: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }

p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

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

.main-content {
    flex: 1;
    padding: 2rem;
    margin-left: var(--sidebar-width); /* Default for desktop */
    transition: margin-left var(--transition-speed);
}

/* Glass Card Component */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur)); /* Safari support */
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.card-title {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-speed);
    font-size: 0.95rem;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.6);
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: rgba(56, 189, 248, 0.1);
}

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

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

/* Form Elements */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    color: var(--text-secondary);
    border-radius: 8px;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary-color);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

/* Top Header (Mobile mainly, but also user profile) */
.top-header {
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Align user implementation to right */
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
    margin-left: var(--sidebar-width); /* Align with content */
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-speed);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .top-header {
        margin-left: 0;
        justify-content: space-between;
    }
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

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

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: rgba(34, 197, 94, 0.1); color: var(--success-color); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-warning { background: rgba(234, 179, 8, 0.1); color: var(--warning-color); border: 1px solid rgba(234, 179, 8, 0.2); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Racing Theme (Black/Red/White) */
body.theme-racing {
    --bg-color: #000000;
    --surface-color: #1a1a1a;
    --surface-hover: #333333;
    --primary-color: #ef4444; /* Red */
    --primary-hover: #dc2626;
    --secondary-color: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db; /* Light gray */
    --glass-bg: rgba(20, 20, 20, 0.95);
    --border-color: #333333;
    --success-color: #22c55e;
    --warning-color: #eab308;
    --danger-color: #ef4444;
}

body.theme-racing .sidebar {
    background: #000000;
    border-right: 1px solid #333333;
}

body.theme-racing .card {
    border: 1px solid #333333;
    background: #111111;
}

body.theme-racing input, 
body.theme-racing select, 
body.theme-racing textarea {
    background: #222222;
    border-color: #444444;
    color: #ffffff;
}

body.theme-racing .logo-area {
    background: linear-gradient(to right, #ef4444, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
