:root {
    --primary: #2563eb;       /* Vibrant Blue */
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;          /* Slate 900 */
    --light: #f1f5f9;         /* Slate 100 */
    --white: #ffffff;
    --border: #e2e8f0;
    --text-main: #334155;
    --text-light: #94a3b8;
    --sidebar-w: 260px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--light);
    color: var(--text-main);
    margin: 0;
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    color: var(--white);
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 1000; /* High Z-index for mobile */
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.5px;
    display: flex; align-items: center; gap: 10px;
}

.nav-scroll { flex: 1; overflow-y: auto; padding: 20px 0; }

.nav-group {
    padding: 0 25px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary);
    font-weight: 700;
    margin-top: 15px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    border-left-color: var(--primary);
}

.nav-link i { width: 20px; margin-right: 12px; opacity: 0.8; text-align: center; }

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 900;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* Close Button (Mobile Only) */
.close-sidebar {
    background: none;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: none; /* Hidden on desktop */
}

/* --- Main Content --- */
.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    padding: 30px;
    transition: margin 0.3s ease;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: var(--white);
    padding: 15px 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.mobile-toggle {
    display: none; /* Hidden on desktop */
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
}

.page-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--dark); }

/* --- Cards & Grid --- */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 25px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 20px; margin-bottom: 25px; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-value { font-size: 28px; font-weight: 800; color: var(--dark); margin: 5px 0; }
.stat-label { color: var(--text-light); font-size: 12px; font-weight: 600; text-transform: uppercase; }

/* --- Buttons (Fixed Contrast) --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: 0.2s;
    color: #ffffff !important; /* Force white text */
}

.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th { text-align: left; padding: 15px; background: #f8fafc; color: var(--text-light); font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* --- Badges --- */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge.active { background: #dcfce7; color: #15803d; }
.badge.expired { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #e0f2fe; color: #0369a1; }

/* --- Forms --- */
input, select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 15px;
    background: #f8fafc; font-size: 14px; outline: none;
}
input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* --- Mobile Responsive Rules --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; box-shadow: 4px 0 15px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    
    .mobile-toggle { display: block; }
    .close-sidebar { display: block; }
    
    .main { margin-left: 0; width: 100%; padding: 15px; }
    
    .grid-2, .grid-4 { grid-template-columns: 1fr; }
}
/* --- Pagination & Table Controls --- */
.table-controls { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; margin-top: 10px; border-top: 1px solid var(--border); }
.pagination { display: flex; gap: 5px; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px; text-decoration: none; color: var(--text-main); font-size: 13px; background: var(--white); }
.pagination a:hover { background: var(--light); border-color: #cbd5e1; }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .disabled { opacity: 0.5; pointer-events: none; }
.per-page-select { width: auto; display: inline-block; padding: 6px 30px 6px 10px; margin: 0; font-size: 13px; height: auto; }