:root {
    --bg-color: #F4F7FE; /* Premium SaaS background */
    --card-bg: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --topbar-bg: rgba(255, 255, 255, 0.75); /* Frosted topbar */
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    
    --primary-color: #4F46E5; /* Indigo */
    --primary-hover: #4338CA; 
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent-color: #0EA5E9;
    --danger-color: #EF4444;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --border-color: #E5E7EB;
    --sidebar-border: #E5E7EB;
    
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 84px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 40px -10px rgba(0, 0, 0, 0.08);

    --hover-bg: #F3F4F6;
    --active-bg: #EEF2FF;
    --table-header-bg: #F9FAFB;
    --input-focus-ring: rgba(79, 70, 229, 0.2);
    --border-radius: 8px;
}

[data-theme="dark"] {
    --bg-color: #0B0F19; /* Rich dark mode */
    --card-bg: #111827;
    --sidebar-bg: #111827;
    --topbar-bg: rgba(17, 24, 39, 0.75);
    
    --text-primary: #F9FAFB;
    --text-secondary: #9CA3AF;
    
    --border-color: #1F2937;
    --sidebar-border: #1F2937;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 15px 50px -10px rgba(0, 0, 0, 0.6);

    --hover-bg: rgba(255, 255, 255, 0.03);
    --active-bg: rgba(79, 70, 229, 0.15);
    --table-header-bg: #111827;
    --input-focus-ring: rgba(79, 70, 229, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    word-wrap: break-word; /* Ensure text never overflows */
}

a { color: var(--primary-color); text-decoration: none; transition: 0.2s; }
a:hover { color: var(--primary-hover); }

/* App Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1000;
}

.sidebar-brand {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 1.75rem;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    gap: 0.8rem;
    transition: all 0.3s ease;
}
.sidebar-brand span span { 
    color: var(--primary-color);
}
.sidebar-logo-img {
    height: 36px;
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}
.sidebar-brand:hover .sidebar-logo-img {
    transform: scale(1.05);
}

/* Floating Collapse Button (SaaS style) */
.sidebar-collapse-floating {
    position: absolute;
    right: -14px;
    top: 21px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #FFFFFF;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    z-index: 1010;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-collapse-floating:hover {
    color: #ffffff;
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.3);
}

/* For collapsed sidebar branding */
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
    height: 70px;
}
body.sidebar-collapsed .sidebar-logo-img {
    height: 26px;
}

/* Sidebar Navigation Links */
.sidebar-nav { 
    padding: 1.25rem 0.95rem; /* More container padding */
    flex: 1; 
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
    gap: 0.45rem; /* Sized up gaps between items */
}
.nav-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    margin: 0.8rem 0.5rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    font-weight: 700;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    margin: 0;
    border: 1px solid transparent;
}
.sidebar-nav a:hover {
    color: var(--primary-color);
    background: var(--hover-bg);
    transform: translateX(4px);
}
.sidebar-nav a.active {
    color: var(--primary-color);
    background: var(--active-bg);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.1);
}
.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px;
    background-color: var(--primary-color);
    border-radius: 0 4px 4px 0;
}
.sidebar-nav a .icon {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease, color 0.2s ease;
}
.sidebar-nav a:hover .icon, .sidebar-nav a.active .icon {
    color: var(--primary-color);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 0.9rem 0.5rem;
}

/* Logout Button */
.sidebar-nav a.nav-logout {
    color: rgba(239, 68, 68, 0.75);
    margin-top: auto;
}
.sidebar-nav a.nav-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.05);
}

/* Workspace / Mode Switcher styling */
.sidebar-nav a.nav-mode-switcher {
    margin-top: 1.2rem; /* More spacing */
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    padding: 0.8rem 1.25rem;
}
.sidebar-nav a.nav-mode-switcher.to-affiliate {
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2); /* Frosted solid border */
    color: #60a5fa !important;
}
.sidebar-nav a.nav-mode-switcher.to-affiliate:hover {
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.45);
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.2);
}
.sidebar-nav a.nav-mode-switcher.to-admin {
    background: rgba(248, 113, 113, 0.08);
    border: 1px dashed rgba(248, 113, 113, 0.3);
    color: #f87171 !important;
}
.sidebar-nav a.nav-mode-switcher.to-admin:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.5);
    color: #ffffff !important;
}

/* Sidebar Collapsed State overrides */
body.sidebar-collapsed .sidebar { 
    width: var(--sidebar-collapsed-width); 
}
body.sidebar-collapsed .logo-text,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-label { 
    display: none; 
}

body.sidebar-collapsed .sidebar-nav { 
    padding: 1rem 0.5rem; 
}
body.sidebar-collapsed .sidebar-nav a { 
    justify-content: center; 
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    margin: 0 auto 0.5rem;
}
body.sidebar-collapsed .sidebar-nav a .icon { 
    margin-right: 0; 
    font-size: 1.15rem; 
}
body.sidebar-collapsed .sidebar-nav a.active::before { 
    display: none; 
}
body.sidebar-collapsed .sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
body.sidebar-collapsed #sidebarCollapseBtn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    right: -14px;
}
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
    max-width: calc(100% - var(--sidebar-collapsed-width));
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    max-width: calc(100% - var(--sidebar-width));
    min-width: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: 70px;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 8px;
}
.btn-icon:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.topbar-right { display: flex; align-items: center; gap: 1.25rem; }

.balance-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Topbar Admin Badge */
.topbar-admin-badge {
    background: rgba(99, 102, 241, 0.06);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.15);
    padding: 0.45rem 1rem;
    border-radius: 99px; /* Modern capsule badge */
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Topbar User Widget */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem; /* Capsule padding */
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.topbar-user:hover {
    background: var(--card-bg);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.08);
}
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}
.topbar-user-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}
.topbar-user-role {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 1px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.topbar-chevron {
    font-size: 0.55rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}
.topbar-user:hover .topbar-chevron {
    transform: translateY(1px);
    color: var(--text-primary);
}

/* Mobile Header Profile */
.mobile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Content Area */
.container {
    padding: 2.5rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Headers */
.page-header { margin-bottom: 2rem; }
.page-header h2 { font-size: 1.75rem; color: var(--text-primary); margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.75rem;}
.page-header p { color: var(--text-secondary); font-size: 0.95rem; }

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
}
.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; }
.card-header h3 { color: var(--text-primary); font-size: 1.25rem; display: flex; align-items: center; gap: 0.75rem; margin: 0; font-weight: 800; letter-spacing: -0.02em;}
.card-header h3 i { color: var(--primary-color); font-size: 1.1rem; }

.grid-3, .grid-4 { 
    display: grid; 
    gap: 1.5rem; 
    margin-bottom: 2rem;
}
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Stat Boxes (Simple, Clean, Professional) */
.stat-box { 
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    min-height: 110px;
    min-width: 0;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
}
.stat-box::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.stat-box:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(79, 70, 229, 0.2);
}
.stat-box:hover::after {
    opacity: 1;
}
.stat-box-top { display: flex; justify-content: space-between; align-items: center; width: 100%; min-width: 0; margin-bottom: 0.15rem; }
.stat-box h3 { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.stat-box .icon { font-size: 1.1rem; flex-shrink: 0; color: var(--primary-color); }
.stat-box .value { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; line-height: 1; margin-top: 0.25rem; }

/* Forms & Inputs */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;}
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--input-focus-ring); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover { background-color: var(--primary-hover); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger-color); }
.btn-danger:hover { background-color: var(--danger-color); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2.25rem; padding: 0 2.25rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 1.15rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; background: var(--table-header-bg); border-bottom: 1px solid var(--border-color); border-top: 1px solid var(--border-color); white-space: nowrap; }
th:first-child { border-left: 1px solid var(--border-color); border-radius: 8px 0 0 8px; }
th:last-child { border-right: 1px solid var(--border-color); border-radius: 0 8px 8px 0; }
td { font-size: 0.9rem; vertical-align: middle; color: var(--text-primary); transition: background 0.2s; }
tbody tr:hover td { background-color: var(--hover-bg); }
tbody tr:last-child td { border-bottom: none; }

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.badge-active { background-color: rgba(16, 185, 129, 0.1); color: var(--accent-color); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-paused { background-color: rgba(239, 68, 68, 0.1); color: var(--danger-color); border: 1px solid rgba(239, 68, 68, 0.2); }
/* Responsive Grid Helpers */
.grid-2-col {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}
.grid-3-col {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr 1fr;
}
.grid-2-1-col {
    display: grid;
    gap: 1rem;
    grid-template-columns: 2fr 1fr;
}

/* Filter Form Styles */
.filter-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: flex-end;
    background: var(--table-header-bg);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.filter-form-group {
    flex: 1;
    min-width: 180px;
}
.filter-form-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Mobile Header and Sidebar Overlays */
.mobile-header {
    display: none;
}
.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .grid-2-col, .grid-3-col, .grid-2-1-col {
        grid-template-columns: 1fr !important;
    }
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-form-group {
        width: 100%;
        min-width: 100%;
    }
    .filter-form-buttons {
        width: 100%;
        flex-direction: column;
        margin-top: 0.5rem;
    }
    .filter-form-buttons .btn {
        width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 1001;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
    
    body.sidebar-collapsed .main-content { margin-left: 0; max-width: 100%; }
    body.sidebar-open .main-content { margin-left: 0; max-width: 100%; }
    
    .topbar { display: none !important; }
    
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        background-color: var(--sidebar-bg);
        color: white;
        padding: 0 1.5rem;
        position: sticky;
        top: 0;
        z-index: 999;
        border-bottom: 1px solid var(--sidebar-border);
    }
    .mobile-menu-btn {
        background: transparent;
        border: none;
        color: white;
        font-size: 1.35rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        border-radius: 6px;
        transition: background-color 0.2s;
    }
    .mobile-menu-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    .mobile-brand {
        font-size: 1.25rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .mobile-brand span span {
        color: var(--primary-color);
    }
    .mobile-brand .icon {
        color: var(--primary-color);
    }
    .mobile-balance {
        background: rgba(16, 185, 129, 0.15);
        color: #10b981;
        padding: 0.35rem 0.75rem;
        border-radius: 999px;
        font-weight: 600;
        font-size: 0.8rem;
        border: 1px solid rgba(16, 185, 129, 0.2);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1000;
        display: none;
        animation: fadeIn 0.2s ease-out;
    }
    
    body.sidebar-open .sidebar-overlay {
        display: block;
    }
    
    .container { padding: 1.5rem 1rem; }
    .card { padding: 1.5rem 1rem; }
    .table-responsive { margin: 0 -1rem; padding: 0 1rem; }
    
    /* Make stat boxes display well on mobile */
    .grid-3, .grid-4 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Custom Scrollbars to Match Premium Theme */

/* Modern Standard (Firefox) */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.2) transparent;
}

.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Webkit (Chrome, Safari, Edge, Opera) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.2);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.4);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Sidebar Nav Scrollbar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid transparent;
    background-clip: padding-box;
}

/* Responsive Screen Overrides for 100% Zoom Legibility */

@media (max-width: 1280px) {
    body {
        font-size: 0.95rem; /* scale text down slightly */
    }
    .container {
        padding: 1.5rem; /* Tighten margins */
    }
    .topbar {
        padding: 0 1.5rem;
    }
    .page-header {
        margin-bottom: 1.5rem;
    }
    .page-header h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 1200px) {
    th, td {
        padding: 0.65rem 0.5rem !important; /* Compact table cell padding */
    }
    th {
        font-size: 0.72rem;
    }
    td {
        font-size: 0.82rem;
    }
    .card {
        padding: 1.25rem 1.25rem; /* Reduce card padding */
    }
}

@media (max-width: 1024px) {
    th {
        white-space: normal !important; /* Allow headers to wrap */
    }
}

@media (max-width: 480px) {
    .mobile-brand span {
        display: none !important; /* Hide brand text, show only logo to save header space */
    }
}

/* Height-sensitive scaling to ensure fit on short screen heights */
@media (max-height: 800px) {
    .sidebar-brand {
        height: 60px;
        font-size: 1.25rem;
    }
    .sidebar-logo-img {
        height: 28px;
    }
    .sidebar-collapse-floating {
        top: 16px;
    }
    body.sidebar-collapsed .sidebar-brand {
        height: 60px;
    }
    .sidebar-nav {
        padding: 0.9rem 0.75rem;
        gap: 0.3rem;
    }
    .sidebar-nav a {
        padding: 0.7rem 1.1rem;
        font-size: 0.9rem;
    }
    .sidebar-nav a .icon {
        margin-right: 10px;
        font-size: 1rem;
        width: 22px;
    }
    .nav-divider {
        margin: 0.65rem 0.5rem;
    }
    .sidebar-nav a.nav-mode-switcher {
        margin-top: 0.65rem;
        padding: 0.7rem 1rem;
    }
}
@media (max-height: 680px) {
    .sidebar-brand {
        height: 52px;
        font-size: 1.15rem;
        padding: 0 1.25rem;
    }
    .sidebar-logo-img {
        height: 24px;
    }
    .sidebar-collapse-floating {
        top: 12px;
    }
    body.sidebar-collapsed .sidebar-brand {
        height: 52px;
    }
    .sidebar-nav {
        padding: 0.65rem 0.65rem;
        gap: 0.2rem;
    }
    .sidebar-nav a {
        padding: 0.58rem 0.95rem;
        font-size: 0.85rem;
    }
    .sidebar-nav a .icon {
        margin-right: 8px;
        font-size: 0.9rem;
        width: 20px;
    }
    .nav-divider {
        margin: 0.45rem 0.5rem;
    }
    .sidebar-nav a.nav-mode-switcher {
        margin-top: 0.45rem;
        padding: 0.58rem 0.85rem;
    }
    body.sidebar-collapsed .sidebar-nav a {
        width: 34px;
        height: 34px;
        margin-bottom: 0.35rem;
    }
    body.sidebar-collapsed .sidebar-nav a .icon {
        font-size: 1rem;
    }
}
