:root {
    --primary-color: #FF3B3B;
    /* Fresh Intense Red */
    --secondary-color: #E10600;
    /* Deep Red Accent */
    --accent-color: #FF3B3B;

    /* Dark Mode Defaults (Modern & Premium) */
    --bg-dark: #121212;
    /* Deep Neutral Black */
    --bg-card: #1E1E1E;
    /* Refined Card Black */
    --text-light: #FFFFFF;
    /* High contrast White */
    --text-muted: #B3B3B3;
    /* Perfect Secondary Gray */
    --glass-bg: rgba(30, 30, 30, 0.8);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --input-bg: #252525;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 4px 20px rgba(255, 59, 59, 0.15);

    --font-main: 'Inter', sans-serif;
}

[data-theme="light"] {
    --bg-dark: #F5F5F7;
    /* Apple-style Light Gray */
    --bg-card: #FFFFFF;
    /* Pure White Card */
    --text-light: #121212;
    /* Deep Black Text */
    --text-muted: #6E6E73;
    /* Soft Secondary Text */
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: 1px solid rgba(0, 0, 0, 0.05);
    --input-bg: #F2F2F7;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul {
    list-style: none;
}

/* Utilities */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 242, 255, 0.5);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--bg-dark);
    /* Keep dark text on hover for contrast */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Auth Pages (Login/Register) */
.auth-wrapper {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, var(--bg-card) 0%, var(--bg-dark) 100%);
    position: relative;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: var(--secondary-color);
    filter: blur(150px);
    opacity: 0.2;
    border-radius: 50%;
    top: 20%;
    left: 20%;
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-glow);
    z-index: 10;
    text-align: center;
}

.auth-card h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    background: -webkit-linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    outline: none;
    transition: 0.3s;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

.form-group select {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    outline: none;
    transition: 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2300f2ff%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65em auto;
}

.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}

.form-group select option {
    background-color: var(--bg-card);
    color: var(--text-light);
}

.auth-footer {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary-color);
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    transition: all 0.3s ease;
}

.sidebar {
    width: 250px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-light);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand span {
    color: var(--primary-color);
}

.nav-links li {
    margin-bottom: 10px;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--text-muted);
    gap: 10px;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(0, 242, 255, 0.1);
    color: var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background-color: var(--bg-dark);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.top-bar h1 {
    color: var(--text-light);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-light);
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 25px;
    transition: 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-glow);
    border-color: var(--primary-color);
}

.card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.card .value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-light);
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border-radius: 15px;
    padding: 20px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-weight: 600;
}

td {
    color: var(--text-light);
}

.status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status.active {
    background: rgba(0, 242, 255, 0.15);
    color: var(--primary-color);
}

.status.expired {
    background: rgba(255, 0, 85, 0.15);
    color: var(--accent-color);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 25px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        width: 250px;
        height: 100vh;
        left: -250px;
        top: 0;
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        width: 100%;
        padding: 15px;
    }

    .top-bar {
        margin-bottom: 20px;
    }

    h1 {
        font-size: 1.2rem;
    }

    .card .value {
        font-size: 2rem;
    }
}

/* Mobile Toggle Buttons */
.mobile-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 15px;
    color: var(--text-light);
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }
}