/* ==========================================================================
   STUDENT PORTAL - GLASSMORPHISM STYLESHEET & HIGH-END THEME TOKENS
   ========================================================================== */

:root {
    --bg-gradient: radial-gradient(circle at 15% 15%, #064e3b 0%, #0f172a 50%, #020617 100%);
    --bg-main: #0b0f19;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-card: rgba(30, 41, 59, 0.6);
    --glass-card-hover: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(16, 185, 129, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #10b981;
    --accent-emerald: #10b981;
    --accent-emerald-dark: #059669;
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    --accent-purple: #a855f7;

    --table-header-bg: rgba(15, 23, 42, 0.85);
    --table-row-hover: rgba(16, 185, 129, 0.08);

    --input-bg: rgba(15, 23, 42, 0.7);
    --input-border: rgba(255, 255, 255, 0.15);
    --input-focus: #10b981;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

    --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg-gradient: radial-gradient(circle at 15% 15%, #d1fae5 0%, #ecfdf5 50%, #f0fdf4 100%);
    --bg-main: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-card: rgba(255, 255, 255, 0.75);
    --glass-card-hover: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(16, 185, 129, 0.2);
    --glass-border-hover: rgba(16, 185, 129, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(16, 185, 129, 0.14);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --table-header-bg: rgba(241, 245, 249, 0.95);
    --table-row-hover: rgba(16, 185, 129, 0.08);

    --input-bg: rgba(255, 255, 255, 0.85);
    --input-border: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar: Hidden Slide-In Drawer Off-Screen By Default (Desktop & Mobile) */
.sidebar,
#sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow-y: auto !important;
    z-index: 99999 !important;
    background: #0b1329 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6) !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 22px 16px !important;
}

/* Slide-In Open State */
.sidebar.show-sidebar,
.sidebar.sidebar-open,
.sidebar.active,
.sidebar.open,
#sidebar.show-sidebar,
#sidebar.sidebar-open,
#sidebar.active,
#sidebar.open {
    left: 0 !important;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px 20px 4px;
    border-bottom: 1px solid var(--glass-border);
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.brand-text h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.nav-menu {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    transition: transform var(--transition-fast);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.12);
    transform: translateX(4px);
}

.nav-item:hover i {
    transform: scale(1.15);
}

.nav-item.active {
    color: white;
    background: var(--accent-gradient);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.38);
}

.sidebar-profile-card:hover {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
    transform: translateY(-2px);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 28px 36px;
    gap: 24px;
}

/* Topbar Header */
.top-header {
    position: relative;
    z-index: 9999 !important;
    overflow: visible !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 18px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

.page-title h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-title p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.header-user {
    position: relative;
    z-index: 9999 !important;
    overflow: visible !important;
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    overflow: hidden;
}

.user-info .user-name {
    font-size: 14px;
    font-weight: 700;
    display: block;
}

.user-info .user-role {
    font-size: 11px;
    color: var(--accent-emerald);
    font-weight: 600;
    background: rgba(16, 185, 129, 0.15);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

/* Circular Icon Button (Theme Toggle) */
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
    transform: translateY(-2px) rotate(15deg);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25);
}

/* Topbar Logout Button */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(244, 63, 94, 0.18);
    border-color: var(--accent-rose);
    color: var(--accent-rose);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.25);
}

/* Quick Shortcut Cards */
.quick-shortcut-card {
    background: var(--glass-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--glass-shadow);
}

.quick-shortcut-card:hover {
    background: var(--glass-card-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-3px);
    box-shadow: var(--glass-shadow), 0 0 20px rgba(16, 185, 129, 0.2);
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--glass-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
    box-shadow: var(--glass-shadow), 0 0 25px rgba(16, 185, 129, 0.25);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* View Sections */
.view-section {
    display: none;
    flex-direction: column;
    gap: 24px;
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
    display: flex;
}

.glass-panel {
    background: var(--glass-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--glass-shadow);
    transition: border-color var(--transition-normal);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.panel-header h3 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

/* Form Controls & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-control {
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

select.form-control option {
    background: var(--bg-main);
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45);
}

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
    background: var(--accent-rose);
    color: white;
    transform: translateY(-2px);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.data-table th {
    padding: 14px 18px;
    background: var(--table-header-bg);
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 1px solid var(--glass-border);
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--table-row-hover);
}

/* Badges */
.badge {
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success, .badge-present { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger, .badge-absent { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-warning, .badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); border: 1px solid rgba(99, 102, 241, 0.3); }

/* QR Reader Box Styling */
#qr-reader {
    border: 2px dashed var(--glass-border-hover) !important;
    border-radius: var(--radius-lg) !important;
    background: rgba(15, 23, 42, 0.5) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hamburger / Menu Toggle Button (Visible on Desktop & Mobile) */
.mobile-toggle-btn,
.sidebar-toggle-btn,
#hamburgerBtn,
#mobileMenuToggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md, 12px);
    color: var(--text-primary);
    font-size: 17px;
    cursor: pointer;
    margin-right: 14px;
    transition: all var(--transition-fast);
}

.mobile-toggle-btn:hover,
.sidebar-toggle-btn:hover,
#hamburgerBtn:hover,
#mobileMenuToggle:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
    transform: scale(1.05);
}

/* ==========================================================================
   DARK TRANSLUCENT BACKDROP OVERLAY
   ========================================================================== */
.sidebar-backdrop,
.mobile-overlay,
#sidebarBackdrop,
#mobileOverlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: block !important;
    pointer-events: none;
}

.sidebar-backdrop.active,
.sidebar-backdrop.open,
.sidebar-backdrop.sidebar-open,
.mobile-overlay.active,
.mobile-overlay.open,
#sidebarBackdrop.active,
#sidebarBackdrop.open,
#sidebarBackdrop.sidebar-open,
#mobileOverlay.active,
#mobileOverlay.open {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Sidebar Close Button */
.sidebar-close-btn,
.mobile-sidebar-close,
#sidebarCloseBtn,
#mobileSidebarClose {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sidebar-close-btn:hover,
.mobile-sidebar-close:hover,
#sidebarCloseBtn:hover,
#mobileSidebarClose:hover {
    color: var(--accent-rose, #f43f5e);
    background: rgba(244, 63, 94, 0.12);
}

/* Credential Cards Styling & Hover */
.credential-card {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.credential-card:hover {
    background: rgba(30, 41, 59, 0.8) !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .credential-card {
    background: rgba(241, 245, 249, 0.85) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .credential-card:hover {
    background: #ffffff !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.15);
}

/* ==========================================================================
   GLOBAL MODALS & LOGOUT CONFIRMATION DIALOGS (ELEVATED Z-INDEX)
   ========================================================================== */
#global-modal,
.logout-modal,
.modal-backdrop,
.custom-modal-overlay,
.confirm-modal-overlay,
.modal-overlay,
#logoutModal,
#confirmModal {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000000 !important; /* Higher than sidebar drawer (99999) */
}

#global-modal.active,
.logout-modal.active,
.custom-modal-overlay.active,
.confirm-modal-overlay.active,
.modal-overlay.active,
#logoutModal.active,
#confirmModal.active {
    display: flex !important;
    animation: fadeIn 0.2s ease;
}

.modal-content,
.logout-modal-content,
.modal-dialog,
.modal-container,
.confirm-modal-box,
#logoutModal .modal-box {
    position: relative !important;
    z-index: 1000001 !important;
    background: var(--glass-card, rgba(30, 41, 59, 0.95)) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15)) !important;
    border-radius: var(--radius-lg, 20px);
    width: 90% !important;
    max-width: 440px !important;
    margin: auto !important;
    padding: 28px !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 30px rgba(0, 0, 0, 0.5) !important;
    animation: scaleUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   SIDEBAR INTEGRATED PROFILE HEADER CARD
   ========================================================================== */
.sidebar-profile-header {
    margin: 14px 0 16px 0;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.85) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md, 14px);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.sidebar-profile-header:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(30, 41, 59, 0.9) 100%);
    border-color: rgba(16, 185, 129, 0.35);
    transform: translateY(-2px);
}

.sidebar-profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.sidebar-profile-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent-gradient, linear-gradient(135deg, #10b981 0%, #059669 100%));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.status-online-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #10b981;
    border: 2px solid #0f172a;
    border-radius: 50%;
}

.sidebar-profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-profile-name {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary, #f8fafc);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.2px;
}

.sidebar-profile-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sidebar-enroll-pill {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 105px;
}

.sidebar-sem-pill {
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-emerald, #10b981);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 2px 6px;
    border-radius: 6px;
}

.sidebar-status-text {
    font-size: 10.5px;
    font-weight: 600;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.status-pulse-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 6px #10b981;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.mobile-sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
    transition: color 0.2s ease;
}

.mobile-sidebar-close:hover {
    color: var(--accent-rose, #f43f5e);
}

.sidebar-logout-btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 700;
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.sidebar-logout-btn:hover {
    background: rgba(244, 63, 94, 0.22);
    border-color: rgba(244, 63, 94, 0.45);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 10000;
}

/* ==========================================================================
   TABLE RESPONSIVENESS & TOUCH OPTIMIZATION
   ========================================================================== */
.table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: block !important;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.3);
    border-radius: 4px;
}

.data-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
}

/* QR Camera Scanner Viewport Auto-fit */
#qr-reader-container {
    width: 100% !important;
    max-width: min(440px, 92vw) !important;
    margin: 0 auto !important;
}

#qr-reader {
    width: 100% !important;
    max-width: 100% !important;
}

#qr-reader video {
    width: 100% !important;
    height: auto !important;
    max-height: 320px !important;
    object-fit: cover !important;
    border-radius: var(--radius-md) !important;
}

/* ==========================================================================
   MOBILE OFF-CANVAS DRAWER & CLEAN HEADER (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .app-container {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        position: relative;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        width: 280px !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow-y: auto !important;
        z-index: 10001 !important;
        background: #0b1329 !important;
        border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.85) !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 18px 14px !important;
    }

    .sidebar.active,
    .sidebar.open {
        left: 0 !important;
    }

    .mobile-sidebar-close {
        display: block !important;
    }

    /* Backdrop Overlay */
    .mobile-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.65) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 10000 !important;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-overlay.active,
    .mobile-overlay.open {
        opacity: 1 !important;
        visibility: visible !important;
        display: block !important;
    }

    /* Clean Mobile Top Sticky Header */
    .top-header {
        padding: 10px 14px !important;
        border-radius: 0 0 16px 16px !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 9999 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }

    .mobile-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: var(--text-primary);
        font-size: 17px;
        cursor: pointer;
        margin-right: 6px;
    }

    .page-title {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .page-title h1 {
        font-size: 15px !important;
        font-weight: 800;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-title p {
        display: none !important;
    }

    .header-user {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .header-user .icon-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 14px !important;
    }

    .header-user .user-avatar {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        font-size: 14px !important;
        display: flex !important;
        cursor: pointer !important;
    }

    /* Clean Header: Hide bulky text and desktop logout in mobile view */
    .header-user .user-info,
    .header-user #topbarLogoutBtn,
    .header-user .logout-btn {
        display: none !important;
    }

    .notification-dropdown,
    #notificationDropdown {
        width: min(340px, calc(100vw - 24px)) !important;
        right: 0 !important;
    }

    .main-content {
        padding: 14px 12px !important;
        gap: 16px !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* Hero Banner: Stack vertically on mobile */
    .glass-panel {
        padding: 18px 16px !important;
    }

    .glass-panel > div[style*="display: flex; justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: center !important;
        gap: 14px !important;
    }

    .glass-panel > div[style*="display: flex; justify-content: space-between"] .btn {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 14.5px !important;
    }

    /* Quick Action Shortcuts: 2 Columns */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(180px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .quick-shortcut-card {
        padding: 12px 14px !important;
        min-height: 48px !important;
    }

    /* Stats Grid: 2 Columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 14px 16px !important;
    }

    .stat-card .stat-info h2 {
        font-size: 22px !important;
    }

    .stat-card .stat-icon {
        width: 42px !important;
        height: 42px !important;
        font-size: 18px !important;
    }

    /* Form Grid: 1 Column Stack */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Profile View Hero Card */
    #profile-view .glass-panel > div {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 16px !important;
    }

    #profile-view .glass-panel > div > div:first-child {
        flex-direction: column !important;
        align-items: center !important;
    }

    #profile-view .glass-panel div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Modals Responsive Viewport */
    .modal-container {
        width: min(420px, 92vw) !important;
        margin: auto !important;
        padding: 18px !important;
        border-radius: 16px !important;
    }
}

/* ==========================================================================
   EXTRA SMALL MOBILE SCREENS (< 480px)
   ========================================================================== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    div[style*="grid-template-columns: repeat(auto-fit, minmax(180px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    .top-header {
        padding: 8px 10px !important;
    }

    .page-title h1 {
        font-size: 14px !important;
    }

    .btn {
        min-height: 48px;
    }
}

/* ==========================================================================
   INTERACTIVE NOTIFICATION DROPDOWN POPUP COMPONENT
   ========================================================================== */
.notif-dropdown-wrapper {
    position: relative !important;
    display: inline-flex;
    align-items: center;
    z-index: 99999 !important;
    overflow: visible !important;
}

.notification-dropdown,
#notificationDropdown {
    position: absolute !important;
    top: calc(100% + 12px) !important;
    right: 0 !important;
    width: 390px !important;
    max-width: calc(100vw - 32px) !important;
    background: #0f172a !important; /* solid deep dark slate for high contrast */
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: var(--radius-md, 16px) !important;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(16, 185, 129, 0.25) !important;
    z-index: 100000 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: notifDropdownFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top right;
}

[data-theme="light"] .notification-dropdown,
[data-theme="light"] #notificationDropdown {
    background: #ffffff !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
    box-shadow: 0 25px 60px -10px rgba(16, 185, 129, 0.22), 0 0 0 1px rgba(16, 185, 129, 0.18) !important;
}

@keyframes notifDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .notif-dropdown-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
}

.notif-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary, #f8fafc);
}

.notif-pill-badge {
    background: rgba(16, 185, 129, 0.18);
    color: var(--accent-emerald, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
}

.notif-mark-read-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.notif-mark-read-btn:hover {
    color: var(--accent-emerald, #10b981);
    background: rgba(16, 185, 129, 0.12);
}

.notif-dropdown-body {
    max-height: 360px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notif-dropdown-body::-webkit-scrollbar {
    width: 5px;
}
.notif-dropdown-body::-webkit-scrollbar-track {
    background: transparent;
}
.notif-dropdown-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
}
.notif-dropdown-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-emerald, #10b981);
}

.notif-item-card {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: #1e293b !important; /* solid contrast card */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: left;
}

[data-theme="light"] .notif-item-card {
    background: #f8fafc !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

.notif-item-card:hover {
    background: #27354a !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    transform: translateX(2px);
}

[data-theme="light"] .notif-item-card:hover {
    background: #ffffff !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
}

.notif-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.notif-item-content {
    flex: 1;
    min-width: 0;
}

.notif-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.notif-item-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-primary, #f8fafc);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-badge {
    padding: 2px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.notif-item-msg {
    font-size: 12px;
    color: #cbd5e1 !important;
    line-height: 1.45;
    word-break: break-word;
    margin-bottom: 6px;
}

[data-theme="light"] .notif-item-msg {
    color: #475569 !important;
}

.notif-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    color: var(--text-muted, #94a3b8);
    gap: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 5px;
}

[data-theme="light"] .notif-item-meta {
    border-top-color: rgba(0, 0, 0, 0.08);
}

.notif-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
    text-align: center;
}

.notif-dropdown-footer {
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    text-align: center;
}

[data-theme="light"] .notif-dropdown-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
}

.notif-footer-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-emerald, #10b981);
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 4px 10px;
    border-radius: 8px;
}

.notif-footer-link:hover {
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    transform: translateX(2px);
}
