/* ============================================
   Layout — Dark Sidebar, Glass Topbar,
   Content Area, Responsive
   ============================================ */

/* ── App Shell ── */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: var(--bg-body);
    background-image: var(--gradient-mesh);
    background-attachment: fixed;
}

/* ── Sidebar (Dark Theme) ── */
.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-slow);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

/* Subtle light edge on the right */
.app-sidebar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(
        180deg,
        rgba(99, 102, 241, 0.3) 0%,
        rgba(139, 92, 246, 0.15) 50%,
        transparent 100%
    );
    pointer-events: none;
}

/* Dark sidebar scrollbar */
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}
.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}
.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* ── Sidebar Header ── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) var(--space-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: #fff;
}

.sidebar-logo:hover { color: #fff; }

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    color: #fff;
    border-radius: var(--radius-lg);
    font-weight: var(--font-bold);
    font-size: var(--text-lg);
    box-shadow: var(--shadow-primary);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.sidebar-logo:hover .logo-icon {
    transform: scale(1.05);
    box-shadow: var(--shadow-primary-lg);
}

.logo-text {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: #fff;
    letter-spacing: var(--tracking-tight);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: var(--text-2xl);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: var(--space-1);
    transition: color var(--transition-fast);
}

.sidebar-close:hover { color: #fff; }

/* ── Sidebar Navigation ── */
.sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
    scroll-behavior: auto;
}
.nav-item.active { scroll-margin-top: 8px; }

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    display: block;
    padding: var(--space-2) var(--space-4);
    font-size: 0.6875rem;
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: rgba(255, 255, 255, 0.35);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin: 2px 0;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: all var(--transition-normal);
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
    font-weight: var(--font-semibold);
}

/* Active glow indicator */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--gradient-primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.65;
    transition: opacity 0.15s ease;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-label { flex: 1; }

/* ── Sidebar Footer ── */
.sidebar-footer {
    padding: var(--space-4) var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    display: block;
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.4);
    text-transform: capitalize;
}

.nav-item-logout {
    color: rgba(239, 68, 68, 0.8);
}

.nav-item-logout:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

/* ── Main Content Area ── */
.app-main {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Topbar (Glass Effect) ── */
.app-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: var(--topbar-height);
    padding: 0 var(--space-8);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(99, 102, 241, 0.05);
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.hamburger:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.topbar-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

/* ── Content Area ── */
.app-content {
    flex: 1 1 0;
    min-width: 0; /* allow shrinking so wide content (e.g. leads table) doesn’t overflow */
    padding: var(--space-8);
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
    animation: fadeInUp 0.4s ease-out;
}

@media (min-width: 1401px) {
    .app-content {
        max-width: var(--content-max-width);
    }
}

/* ── Mobile Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: calc(var(--z-sidebar) - 1);
    transition: opacity var(--transition-normal);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-2xl);
    }

    .sidebar-close {
        display: block;
    }

    .hamburger {
        display: flex;
    }

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

    .app-content {
        padding: var(--space-5);
    }

    .app-topbar {
        padding: 0 var(--space-5);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .page-header {
        flex-direction: column;
        gap: var(--space-4);
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .app-content {
        padding: var(--space-4);
    }
}
/* ──────────────────────────────────────────────
   Mobile bottom navigation (STUDENT / PARENT only)
   Hidden by default, shown on screens < 768px.
   Provides quick reach to the 4 most-used pages
   without opening the hamburger sidebar.
   ────────────────────────────────────────────── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: rgba(15, 17, 23, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border, #2a2e3b);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: stretch;
}
.mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    color: var(--text-muted, #8b8f9e);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    min-height: 56px;
    transition: color 0.15s;
}
.mobile-bottom-nav a:active { transform: scale(0.95); }
.mobile-bottom-nav a.active { color: var(--primary-light, #818cf8); }
.mobile-bottom-nav .mbn-icon { font-size: 1.3rem; line-height: 1; }

@media (max-width: 768px) {
    .mobile-bottom-nav.show { display: flex; }
    /* Pad app content so the bottom nav doesn't cover the last bit */
    body.has-mobile-nav .app-content { padding-bottom: 100px !important; }
    /* Touch targets — minimum 44px tap area */
    .btn-sm { min-height: 38px; padding-left: 14px; padding-right: 14px; }
    .btn { min-height: 44px; }
    /* Form inputs need to be at least 16px to prevent iOS zoom-on-focus */
    input[type="text"], input[type="email"], input[type="password"],
    input[type="tel"], input[type="number"], input[type="date"],
    input[type="datetime-local"], input[type="time"], select, textarea {
        font-size: 16px;
    }
}

/* ══════════════════════════════════════════════════════
   GLOBAL DARK THEME  — applies to every page
   ══════════════════════════════════════════════════════ */
[data-theme="dark"] {
    color-scheme: dark;
}

/* Page background */
[data-theme="dark"] body,
[data-theme="dark"] .app-content { background: #0f172a !important; }

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar { width: 6px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 3px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.24); }

/* Topbar */
[data-theme="dark"] .app-topbar {
    background: rgba(15,23,42,0.92) !important;
    border-bottom: 1px solid #2a3549 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}
[data-theme="dark"] .topbar-title,
[data-theme="dark"] .app-topbar span { color: #f1f5f9 !important; }
[data-theme="dark"] .app-topbar .hidden.sm\:flex {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] .app-topbar .hidden.sm\:flex span { color: #f1f5f9 !important; }
[data-theme="dark"] #themeToggle { color: #94a3b8 !important; }
[data-theme="dark"] #themeToggle:hover { background: #1e293b !important; }

/* Cards */
[data-theme="dark"] .card {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] .card-body { background: #1e293b !important; color: #f1f5f9; }
[data-theme="dark"] .card-header {
    background: #151e2e !important;
    border-color: #2a3549 !important;
    color: #f1f5f9 !important;
}

/* Page header */
[data-theme="dark"] .page-header { border-color: #2a3549 !important; }

/* Headings */
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,
[data-theme="dark"] h4,[data-theme="dark"] h5,[data-theme="dark"] h6 { color: #f1f5f9 !important; }

/* Body text */
[data-theme="dark"] p { color: #94a3b8; }
[data-theme="dark"] .text-muted,[data-theme="dark"] .text-secondary { color: #94a3b8 !important; }
[data-theme="dark"] label { color: #cbd5e1 !important; }
[data-theme="dark"] strong { color: #f1f5f9; }
[data-theme="dark"] span { color: inherit; }
[data-theme="dark"] a:not(.btn):not(.nav-item):not(.btn-dark-primary):not(.btn-dark-secondary) { color: #818cf8; }

/* Forms */
[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #1e293b !important;
    border-color: #2a3549 !important;
    color: #f1f5f9 !important;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #475569 !important; }

/* Tables */
[data-theme="dark"] table { color: #f1f5f9; }
[data-theme="dark"] .data-table thead th,
[data-theme="dark"] th { background: #151e2e !important; color: #94a3b8 !important; border-color: #2a3549 !important; }
[data-theme="dark"] td { color: #f1f5f9 !important; border-color: #2a3549 !important; }
[data-theme="dark"] tr:nth-child(even) td { background: rgba(255,255,255,0.02) !important; }
[data-theme="dark"] tr:hover td { background: rgba(255,255,255,0.05) !important; }
[data-theme="dark"] .data-table { border-color: #2a3549 !important; }

/* Badges & status pills */
[data-theme="dark"] .badge { background: #1e293b !important; border-color: #2a3549 !important; color: #94a3b8 !important; }

/* Status badges — dark mode overrides for ALL status variants
   The .status-badge background color is the base, ::before is the dot indicator */
[data-theme="dark"] .status-badge,
[data-theme="dark"] .status-ACTIVE, [data-theme="dark"] .status-active,
[data-theme="dark"] .status-ENROLLED { background: rgba(16,185,129,0.15) !important; color: #6ee7b7 !important; }

[data-theme="dark"] .status-COMPLETED, [data-theme="dark"] .status-completed { background: rgba(59,130,246,0.15) !important; color: #93c5fd !important; }

[data-theme="dark"] .status-CANCELLED, [data-theme="dark"] .status-cancelled,
[data-theme="dark"] .status-NO_SHOW { background: rgba(239,68,68,0.15) !important; color: #fca5a5 !important; }

[data-theme="dark"] .status-ON_HOLD, [data-theme="dark"] .status-on_hold,
[data-theme="dark"] .status-PENDING { background: rgba(245,158,11,0.15) !important; color: #fcd34d !important; }

[data-theme="dark"] .status-SCHEDULED, [data-theme="dark"] .status-scheduled { background: rgba(168,85,247,0.15) !important; color: #d8b4fe !important; }

[data-theme="dark"] .status-ongoing { background: rgba(139,92,246,0.15) !important; color: #c4b5fd !important; }

[data-theme="dark"] .status-NEW,
[data-theme="dark"] .status-CONTACTED,
[data-theme="dark"] .status-QUALIFIED { background: rgba(148,163,184,0.15) !important; color: #cbd5e1 !important; }

[data-theme="dark"] .status-DEMO_SCHEDULED, [data-theme="dark"] .status-DEMO_COMPLETED { background: rgba(99,102,241,0.15) !important; color: #a5b4fc !important; }

[data-theme="dark"] .status-LOST, [data-theme="dark"] .status-NOT_INTERESTED { background: rgba(100,116,139,0.15) !important; color: #94a3b8 !important; }

/* Inline-styled white-ish buttons in dark mode (e.g. Connect Google Calendar with hardcoded #fff) */
[data-theme="dark"] [style*="background:#fff"]:not(.app-content):not(.modal-content),
[data-theme="dark"] [style*="background: #fff"]:not(.app-content):not(.modal-content),
[data-theme="dark"] [style*="background:white"]:not(.app-content):not(.modal-content),
[data-theme="dark"] [style*="background: white"]:not(.app-content):not(.modal-content) {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] [style*="color:#3c4043"],
[data-theme="dark"] [style*="color: #3c4043"],
[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #6b7280"] { color: #e2e8f0 !important; }

/* Light mode body — global default so right gap isn't pure white */
[data-theme="light"] body,
[data-theme="light"] .app-content,
[data-theme="light"] .app-main { background: #f1f5f9 !important; }
[data-theme="light"] .app-layout {
    background-color: #f1f5f9;
    background-image: radial-gradient(at 30% 15%, rgba(99,102,241,0.12) 0%, transparent 50%),
                      radial-gradient(at 85% 5%,  rgba(139,92,246,0.08) 0%, transparent 45%),
                      radial-gradient(at 5% 60%,  rgba(16,185,129,0.07) 0%, transparent 45%),
                      radial-gradient(at 75% 90%, rgba(249,115,22,0.06) 0%, transparent 40%);
    background-attachment: fixed;
}
[data-theme="light"] .card        { box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04) !important; }
[data-theme="light"] .stat-card   { box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04) !important; }
[data-theme="light"] .schedule-item { box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04) !important; }
[data-theme="light"] .table-container { box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04) !important; }
[data-theme="light"] .feature-card { box-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04) !important; }
[data-theme="light"] ::-webkit-scrollbar-track { background: #e2e8f0; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 3px; }

/* Dark mode overrides for newly var()-based component borders */
[data-theme="dark"] .stat-card {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] .schedule-item {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] .feature-card {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}

/* Alerts */
[data-theme="dark"] .alert {
    background: #1e293b !important;
    border-color: #2a3549 !important;
    color: #f1f5f9 !important;
}

/* Modals */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-overlay .card {
    background: #1e293b !important;
    border-color: #2a3549 !important;
    color: #f1f5f9 !important;
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}
[data-theme="dark"] .dropdown-item { color: #f1f5f9 !important; }
[data-theme="dark"] .dropdown-item:hover { background: #334155 !important; }

/* Code */
[data-theme="dark"] code {
    background: #0f172a;
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Dividers */
[data-theme="dark"] hr { border-color: #2a3549; }

/* Sidebar — ensure always dark in dark mode */
[data-theme="dark"] .app-sidebar {
    background: linear-gradient(180deg,#060e20 0%,#050d1a 100%) !important;
    border-right: 1px solid rgba(255,255,255,0.05) !important;
}

/* Buttons */
[data-theme="dark"] .btn-secondary {
    background: #1e293b !important;
    border-color: #2a3549 !important;
    color: #cbd5e1 !important;
}
[data-theme="dark"] .btn-secondary:hover {
    background: #334155 !important;
    color: #f1f5f9 !important;
}

/* Generic text and div catch-all for inline-styled elements */
[data-theme="dark"] .app-content div { color: #f1f5f9; }
[data-theme="dark"] .app-content span { color: inherit; }
[data-theme="dark"] .app-content .text-sm { color: #94a3b8; }
[data-theme="dark"] .app-content small { color: #94a3b8; }

/* Breadcrumb / topbar inline text */
[data-theme="dark"] .app-topbar div { color: #f1f5f9 !important; }

/* Enrollment, class, recording list items */
[data-theme="dark"] .app-content [style*="background:#fff"],
[data-theme="dark"] .app-content [style*="background: #fff"],
[data-theme="dark"] .app-content [style*="background:white"],
[data-theme="dark"] .app-content [style*="background: white"] {
    background: #1e293b !important;
    border-color: #2a3549 !important;
}

/* Progress bars & status indicators */
[data-theme="dark"] .progress { background: #0f172a !important; }

/* Tabs */
[data-theme="dark"] .nav-tabs { border-color: #2a3549 !important; }
[data-theme="dark"] .nav-tabs .nav-link { color: #94a3b8 !important; }
[data-theme="dark"] .nav-tabs .nav-link.active { color: #f1f5f9 !important; background: #1e293b !important; border-color: #2a3549 !important; }

/* Pagination */
[data-theme="dark"] .page-link { background: #1e293b !important; border-color: #2a3549 !important; color: #94a3b8 !important; }
[data-theme="dark"] .page-link:hover { background: #334155 !important; color: #f1f5f9 !important; }

/* Search & filter bars */
[data-theme="dark"] .filter-bar,
[data-theme="dark"] .search-bar { background: #1e293b !important; border-color: #2a3549 !important; }

/* Small text helpers */
[data-theme="dark"] small,.text-sm { color: #94a3b8; }

/* ── Sidebar Collapse (desktop only) ── */
/* sidebar-toggle-btn: always visible on desktop, hidden on mobile */
.sidebar-toggle-btn { display: none; }
@media (min-width: 769px) {
    .sidebar-toggle-btn { display: flex; }
    /* hamburger in topbar: hidden on desktop UNLESS sidebar is collapsed */
    .hamburger { display: none !important; }
    body.sidebar-collapsed .hamburger { display: flex !important; }
    /* collapsed state — translate extra 2px so the border/::after are fully off-screen */
    .app-sidebar.collapsed {
        transform: translateX(calc(-100% - 2px));
    }
    .app-sidebar.collapsed::after {
        display: none;
    }
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }
    /* When sidebar is collapsed, centre the content with balanced side gaps */
    body.sidebar-collapsed .app-content {
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
        padding-left: var(--space-10, 40px);
        padding-right: var(--space-10, 40px);
    }
    /* when collapsed the toggle button is inside the off-screen sidebar — hide it */
    body.sidebar-collapsed .sidebar-toggle-btn {
        display: none;
    }
    /* Sidebar and content transition in sync — no gap, smooth feel */
    .app-sidebar {
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .app-main {
        transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
}
/* on mobile: show close button (sidebar-toggle-btn acts as close) */
@media (max-width: 768px) {
    .sidebar-toggle-btn { display: flex; }
}

/* ════════════════════════════════════════════════════════════
   LANDING-PAGE-QUALITY DARK THEME — v23
   Applies to all authenticated pages globally
════════════════════════════════════════════════════════════ */

/* ── App background ── */
[data-theme="dark"] body,
[data-theme="dark"] .app-layout,
[data-theme="dark"] .app-main,
[data-theme="dark"] .app-content {
    background: #070B14 !important;
    background-image: none !important;
}

/* ── Sidebar — deep premium dark ── */
[data-theme="dark"] .app-sidebar {
    background: linear-gradient(180deg,#060e20 0%,#050d1a 60%,#040b16 100%) !important;
    border-right: 1px solid rgba(255,255,255,0.04) !important;
    box-shadow: 4px 0 32px rgba(0,0,0,0.4) !important;
}
[data-theme="dark"] .app-sidebar::after {
    content: '';
    position: absolute; right:0; top:0; bottom:0; width:1px;
    background: linear-gradient(180deg,rgba(99,102,241,.4) 0%,rgba(168,85,247,.2) 50%,transparent 100%);
    pointer-events: none;
}
[data-theme="dark"] .nav-item.active {
    background: linear-gradient(90deg,rgba(99,102,241,.18),rgba(99,102,241,.06)) !important;
    color: #a5b4fc !important;
}
[data-theme="dark"] .nav-item.active::before {
    background: linear-gradient(180deg,#6366f1,#a855f7) !important;
    box-shadow: 0 0 14px rgba(99,102,241,.7) !important;
    width: 3px !important;
}
[data-theme="dark"] .nav-item:hover {
    background: rgba(255,255,255,.05) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .nav-item:hover .nav-icon { opacity:1 !important; }
[data-theme="dark"] .nav-icon { transition: opacity .2s ease; }

/* ── Topbar — glass matching landing nav ── */
[data-theme="dark"] .app-topbar {
    background: rgba(5,11,22,.88) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border-bottom: 1px solid rgba(255,255,255,.05) !important;
    box-shadow: none !important;
    transition: box-shadow .3s ease !important;
}
[data-theme="dark"] .topbar-title,
[data-theme="dark"] .app-topbar span,
[data-theme="dark"] .app-topbar div { color: #e2e8f0 !important; }

/* ── Cards — glassmorphism ── */
[data-theme="dark"] .card {
    background: rgba(255,255,255,.025) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 20px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,.2) !important;
    transition: border-color .25s, box-shadow .25s, transform .2s !important;
}
[data-theme="dark"] .card:hover {
    border-color: rgba(99,102,241,.2) !important;
    box-shadow: 0 12px 40px rgba(0,0,0,.3), 0 0 0 1px rgba(99,102,241,.1) !important;
}
[data-theme="dark"] .card-header {
    background: transparent !important;
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
}
[data-theme="dark"] .stat-card {
    background: rgba(255,255,255,.025) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 20px !important;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s !important;
}
[data-theme="dark"] .stat-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,.3), 0 0 0 1px rgba(99,102,241,.12) !important;
    border-color: rgba(99,102,241,.18) !important;
}
[data-theme="dark"] .feature-card {
    background: rgba(255,255,255,.025) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 20px !important;
    transition: all .25s !important;
}
[data-theme="dark"] .feature-card:hover {
    border-color: rgba(99,102,241,.2) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 32px rgba(0,0,0,.25) !important;
}

/* ── Schedule items ── */
[data-theme="dark"] .schedule-item {
    background: rgba(255,255,255,.025) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 16px !important;
    transition: all .25s !important;
}
[data-theme="dark"] .schedule-item:hover {
    background: rgba(255,255,255,.04) !important;
    border-color: rgba(99,102,241,.18) !important;
    transform: translateX(4px) !important;
}

/* ── Tables — premium dark ── */
[data-theme="dark"] .table-container,
[data-theme="dark"] .data-table {
    background: rgba(255,255,255,.02) !important;
    border: 1px solid rgba(255,255,255,.06) !important;
    border-radius: 20px !important;
    overflow: hidden !important;
}
[data-theme="dark"] .data-table thead th,
[data-theme="dark"] th {
    background: rgba(255,255,255,.03) !important;
    border-bottom: 1px solid rgba(255,255,255,.07) !important;
    font-size: .7rem !important;
    font-weight: 700 !important;
    letter-spacing: .08em !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    padding: 14px 16px !important;
}
[data-theme="dark"] td {
    border-bottom: 1px solid rgba(255,255,255,.04) !important;
    padding: 13px 16px !important;
}
[data-theme="dark"] tr:hover td {
    background: rgba(99,102,241,.04) !important;
}

/* ── Forms — dark premium ── */
[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: rgba(255,255,255,.04) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
    border-radius: 12px !important;
    color: #f8fafc !important;
    transition: border-color .2s, box-shadow .2s, background .2s !important;
}
[data-theme="dark"] input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]):focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    border-color: rgba(99,102,241,.6) !important;
    background: rgba(99,102,241,.05) !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12) !important;
    outline: none !important;
}

/* ── Page header ── */
[data-theme="dark"] .page-header {
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
    padding-bottom: 22px !important;
    margin-bottom: 28px !important;
}
[data-theme="dark"] .page-header h1,
[data-theme="dark"] .page-header h2 {
    font-weight: 800 !important;
    letter-spacing: -.03em !important;
    color: #f8fafc !important;
}

/* ── Alerts ── */
[data-theme="dark"] .alert {
    border-radius: 14px !important;
    border: 1px solid !important;
    backdrop-filter: blur(8px) !important;
}
[data-theme="dark"] .alert-success {
    background: rgba(16,185,129,.08) !important;
    border-color: rgba(16,185,129,.25) !important;
    color: #6ee7b7 !important;
}
[data-theme="dark"] .alert-error {
    background: rgba(239,68,68,.08) !important;
    border-color: rgba(239,68,68,.22) !important;
    color: #fca5a5 !important;
}
[data-theme="dark"] .alert-warning {
    background: rgba(245,158,11,.08) !important;
    border-color: rgba(245,158,11,.22) !important;
    color: #fcd34d !important;
}
[data-theme="dark"] .alert-info {
    background: rgba(99,102,241,.08) !important;
    border-color: rgba(99,102,241,.22) !important;
    color: #a5b4fc !important;
}

/* ── Pagination ── */
[data-theme="dark"] .page-link {
    background: rgba(255,255,255,.04) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
    border-radius: 10px !important;
    color: #94a3b8 !important;
    transition: all .2s !important;
}
[data-theme="dark"] .page-link:hover {
    background: rgba(99,102,241,.12) !important;
    border-color: rgba(99,102,241,.3) !important;
    color: #a5b4fc !important;
}

/* ── Filter tabs ── */
[data-theme="dark"] .filter-tab-group {
    background: rgba(255,255,255,.03) !important;
    border: 1px solid rgba(255,255,255,.06) !important;
    border-radius: 12px !important;
    padding: 4px !important;
}
[data-theme="dark"] .filter-tab.active {
    background: rgba(99,102,241,.2) !important;
    color: #a5b4fc !important;
    border-radius: 9px !important;
}

/* ── Modal ── */
[data-theme="dark"] .modal-content {
    background: linear-gradient(145deg,rgba(13,19,35,.97),rgba(8,13,26,.99)) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
    border-radius: 24px !important;
    box-shadow: 0 40px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(99,102,241,.06) !important;
}

/* ── Toast ── */
[data-theme="dark"] .toast {
    background: linear-gradient(135deg,rgba(13,19,35,.95),rgba(8,13,26,.98)) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
    border-radius: 16px !important;
    backdrop-filter: blur(20px) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .toast-success { border-color: rgba(16,185,129,.3) !important; }
[data-theme="dark"] .toast-error   { border-color: rgba(239,68,68,.3) !important; }

/* ── Buttons in dark mode ── */
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg,#6366f1,#8b5cf6) !important;
    box-shadow: 0 4px 14px rgba(99,102,241,.35), 0 0 0 1px rgba(99,102,241,.2) !important;
    border: none !important;
}
[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 8px 28px rgba(99,102,241,.55) !important;
    transform: translateY(-2px) !important;
    color: #fff !important;
}
[data-theme="dark"] .btn-secondary {
    background: rgba(255,255,255,.05) !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    color: #cbd5e1 !important;
    border-radius: 10px !important;
}
[data-theme="dark"] .btn-secondary:hover {
    background: rgba(255,255,255,.09) !important;
    border-color: rgba(255,255,255,.18) !important;
    color: #f1f5f9 !important;
    transform: translateY(-1px) !important;
}
[data-theme="dark"] .btn-ghost {
    background: transparent !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255,255,255,.06) !important;
    color: #e2e8f0 !important;
}

/* ── Filter/search bar ── */
[data-theme="dark"] .filter-bar,
[data-theme="dark"] .search-bar {
    background: rgba(255,255,255,.025) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 16px !important;
    padding: 16px !important;
}

/* ── Light mode polish (also improves) ── */
[data-theme="light"] .card,
[data-theme="light"] .stat-card,
[data-theme="light"] .feature-card {
    border-radius: 20px !important;
    transition: all .25s ease !important;
}
[data-theme="light"] .card:hover,
[data-theme="light"] .stat-card:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 32px rgba(99,102,241,.1), 0 2px 8px rgba(0,0,0,.07) !important;
}
[data-theme="light"] .app-topbar {
    background: rgba(255,255,255,.92) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
/* ── Light mode sidebar ── */
html[data-theme="light"] .app-sidebar {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
    box-shadow: 2px 0 12px rgba(0,0,0,.06) !important;
}
html[data-theme="light"] .sidebar-header {
    border-bottom-color: #e2e8f0 !important;
}
/* Sidebar brand name */
html[data-theme="light"] .sidebar-header span[style*="color:#f1f5f9"] { color: #1e293b !important; }
/* Nav items */
html[data-theme="light"] .nav-item { color: #475569 !important; }
html[data-theme="light"] .nav-item:hover { background: #f1f5f9 !important; color: #1e293b !important; }
html[data-theme="light"] .nav-item.active { background: rgba(99,102,241,0.1) !important; color: #6366f1 !important; }
html[data-theme="light"] .nav-item .nav-icon { color: inherit !important; }
/* Section labels ("MAIN", "RM TOOLS" etc.) */
html[data-theme="light"] .sidebar-nav span[style*="rgba(255,255,255,.28)"],
html[data-theme="light"] [style*="color:rgba(255,255,255,.28)"] { color: #94a3b8 !important; }
/* Sidebar bottom border */
html[data-theme="light"] .sidebar-header { border-bottom-color: #f1f5f9 !important; }
/* Sign out link in light mode */
html[data-theme="light"] .nav-item-logout { color: #ef4444 !important; }
/* Sidebar toggle button */
html[data-theme="light"] .sidebar-toggle-btn { color: #94a3b8 !important; }
html[data-theme="light"] .sidebar-toggle-btn:hover { background: #f1f5f9 !important; color: #1e293b !important; }
/* Sidebar user name and role (bottom of sidebar) */
html[data-theme="light"] .sidebar-username { color: #1e293b !important; }
html[data-theme="light"] .sidebar-role { color: #64748b !important; }
/* Sidebar footer border */
html[data-theme="light"] .app-sidebar > div[style*="border-top"] { border-top-color: #e2e8f0 !important; }

/* App content animation */
.app-content { animation: appContentIn .5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes appContentIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
