:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-emerald: #10b981;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --row-highlight: rgba(6, 182, 212, 0.25);
    --row-highlight-border: #06b6d4;
}

[data-theme="light"] {
    --bg-primary: #e2e8f0;
    --bg-secondary: #cbd5e1;
    --bg-glass: rgba(248, 250, 252, 0.85);
    --border-glass: rgba(15, 23, 42, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --shadow-premium: 0 10px 30px -10px rgba(15, 23, 42, 0.15);
    --row-highlight: rgba(59, 130, 246, 0.15);
    --row-highlight-border: #3b82f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
    transition: background-color 0.25s, border-color 0.25s;
}

html, body {
    width: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Form Elements Global Fix */
select {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}
option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Glassmorphism containers */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-premium);
}

/* Header & Top Navigation */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    z-index: 100;
}

.top-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--accent-emerald);
}

nav.main-nav {
    display: flex;
    gap: 20px;
}

nav.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

nav.main-nav a:hover, nav.main-nav a.active {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

nav.main-nav a.active {
    border-bottom: 2px solid var(--accent-emerald);
    border-radius: 8px 8px 0 0;
    background-color: rgba(16, 185, 129, 0.08);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

.user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.user-branch {
    font-size: 11px;
    color: var(--accent-cyan);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-glass);
}

.btn-logout {
    color: var(--accent-red);
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Main Container */
main {
    max-width: 1400px;
    width: 100%;
    margin: 24px auto;
    padding: 0 24px;
    flex: 1;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.widget-card {
    position: relative;
    overflow: hidden;
}

.widget-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.widget-card.emerald::before { background-color: var(--accent-emerald); }
.widget-card.cyan::before { background-color: var(--accent-cyan); }
.widget-card.blue::before { background-color: var(--accent-blue); }
.widget-card.amber::before { background-color: var(--accent-amber); }
.widget-card.red::before { background-color: var(--accent-red); }

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

.widget-title {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.widget-icon {
    font-size: 18px;
    color: var(--text-muted);
}

.widget-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.widget-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Dashboard Customization Pane */
.dashboard-customizer {
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-end;
}

.customize-trigger {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.customize-trigger:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.8);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Tables styling */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
    margin-bottom: 15px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    color: var(--text-primary);
    font-size: 14px;
}

/* Hover Row highlighting */
tbody tr {
    cursor: pointer;
    transition: background-color 0.15s, border-left-color 0.15s;
}

tbody tr:hover {
    background-color: var(--row-highlight) !important;
    outline: 1px solid var(--row-highlight-border);
}

/* Status Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.badge.active { background-color: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge.pending { background-color: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge.completed { background-color: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge.rejected { background-color: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge.missed { background-color: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge.written_off { background-color: rgba(100, 116, 139, 0.2); color: #94a3b8; }

/* Forms & UI Inputs */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.25);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.btn-primary { background-color: var(--accent-emerald); color: white; }
.btn-primary:hover { background-color: #059669; }

.btn-secondary { background-color: rgba(255,255,255,0.05); color: var(--text-primary); border: 1px solid var(--border-glass); }
.btn-secondary:hover { background-color: rgba(255,255,255,0.1); }

.btn-danger { background-color: var(--accent-red); color: white; }
.btn-danger:hover { background-color: #dc2626; }

.btn-cyan { background-color: var(--accent-cyan); color: white; }
.btn-cyan:hover { background-color: #0891b2; }
.btn-purple { background-color: var(--accent-purple); color: white; border: none; }
.btn-purple:hover { background-color: #8b5cf6; }
.btn-amber { background-color: var(--accent-amber); color: white; border: none; }
.btn-amber:hover { background-color: #d97706; }

/* Dashboard Columns Layout */
.dashboard-columns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 1024px) {
    .dashboard-columns {
        grid-template-columns: 1fr !important;
    }
}

/* Notification Simulator Sidebar and lists */
.notification-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 12px;
}

.notification-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.notification-text {
    line-height: 1.4;
}

/* Webcam Container */
.webcam-container {
    width: 100%;
    max-width: 400px;
    margin: 10px auto;
    position: relative;
    border: 2px solid var(--border-glass);
    border-radius: 8px;
    overflow: hidden;
    background-color: black;
}

#webcam-video {
    width: 100%;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px dashed var(--accent-cyan);
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(6,182,212,0.4);
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
    top: 0;
    animation: scanning 2.5s infinite linear;
}

@keyframes scanning {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Login Page Styling */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 800;
}

.login-logo span {
    color: var(--accent-emerald);
}

/* Detail Section and tables */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.detail-item {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    padding: 12px;
    border-radius: 8px;
}

.detail-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detail-val {
    font-size: 15px;
    font-weight: 600;
    margin-top: 4px;
}

.profile-section {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.profile-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-glass);
}

/* Dual-Tier Header System Styles */
.dual-tier-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-glass);
    position: fixed;
    top: 0;
    width: 100%;
    margin: 0;
    left: 0;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.header-top-tier {
    max-width: 1500px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.header-bottom-tier {
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-glass);
}

/* Light Theme Header Overrides */
[data-theme="light"] .dual-tier-header {
    background-color: #3567b2 !important;
    border-color: #2b5494 !important;
}

[data-theme="light"] .dual-tier-header .brand-slim,
[data-theme="light"] .dual-tier-header .header-clock,
[data-theme="light"] .dual-tier-header .user-name-label,
[data-theme="light"] .dual-tier-header .customize-trigger {
    color: #ffffff !important;
}

[data-theme="light"] .dual-tier-header .brand-slim span {
    color: #ffffff !important;
}

[data-theme="light"] .dual-tier-header .main-nav-slim a {
    color: rgba(255, 255, 255, 0.8) !important;
}

[data-theme="light"] .dual-tier-header .main-nav-slim a:hover,
[data-theme="light"] .dual-tier-header .main-nav-slim a.active {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="light"] .dual-tier-header .main-nav-slim a.active {
    border-bottom: 2px solid #ffffff !important;
}

[data-theme="light"] .header-bottom-tier {
    background-color: rgba(0, 0, 0, 0.1) !important;
}

.brand-slim {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.brand-slim span {
    color: var(--accent-emerald);
}

.main-nav-slim {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 16px;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.main-nav-slim::-webkit-scrollbar {
    height: 3px;
}
.main-nav-slim::-webkit-scrollbar-thumb {
    background-color: var(--border-glass);
    border-radius: 4px;
}

.main-nav-slim a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 12.5px;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    height: 28px;
}

.main-nav-slim a:hover, .main-nav-slim a.active {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.main-nav-slim a.active {
    border-bottom: 2px solid var(--accent-emerald);
    border-radius: 6px 6px 0 0;
    background-color: rgba(16, 185, 129, 0.06);
}

.user-menu-slim {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.page-header-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    padding-top: 20px;
    padding-bottom: 15px;
    margin-top: -20px;
    margin-bottom: 24px;
}
.page-header-sticky::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    backdrop-filter: blur(10px);
    background: rgba(15, 23, 42, 0.9);
    z-index: -1;
}

.btn-logout-slim {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background-color 0.15s;
}

.btn-logout-slim:hover {
    background-color: rgba(239, 68, 68, 0.12);
}

.caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 2px;
    vertical-align: middle;
    border-top: 4px dashed;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

/* Nav Dropdown CSS */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    background-color: #1a202c;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.35);
    z-index: 999;
    border-radius: 6px;
    border: 1px solid var(--border-glass);
    top: 100%;
    left: 0;
}

[data-theme="dark"] .nav-dropdown-content {
    background-color: #0f172a;
}

.nav-dropdown-content a {
    color: var(--text-secondary) !important;
    padding: 8px 12px !important;
    text-decoration: none !important;
    display: block !important;
    font-size: 12px !important;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background-color: transparent !important;
    border-radius: 0 !important;
    height: auto !important;
}

.nav-dropdown-content a:last-child {
    border-bottom: none;
}

.nav-dropdown-content a:hover {
    background-color: var(--accent-blue) !important;
    color: #ffffff !important;
}

.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

body {
    padding-top: 0;
}

/* Print Optimization */
/* ============================================
   MOBILE & TABLET RESPONSIVENESS
   ============================================ */

/* --- Hamburger Menu Button (hidden on desktop) --- */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.mobile-menu-toggle:hover {
    background: rgba(255,255,255,0.08);
}

/* Mobile nav drawer state */
.mobile-nav-open .main-nav-slim {
    display: flex !important;
}

/* ---- Tablet: 1024px ---- */
@media (max-width: 1024px) {
    .dashboard-columns, .stats-grid {
        grid-template-columns: 1fr !important;
    }
    .header-clock {
        font-size: 11px;
    }
    main {
        padding: 0 16px;
        margin: 16px auto;
    }
}

/* ---- Mobile: 768px ---- */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    /* -- Header Top Tier: compact row -- */
    .header-top-tier {
        padding: 10px 14px;
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: space-between;
        align-items: center;
    }

    /* Hide the centered absolute clock — no room on mobile */
    .header-clock {
        display: none !important;
    }

    /* Compact user menu: hide text labels, keep icons */
    .user-name-label {
        display: none !important;
    }
    .user-menu-slim {
        gap: 6px;
        flex-wrap: nowrap;
    }
    /* Hide branch location text on mobile */
    .user-menu-slim > span:first-child {
        display: none !important;
    }

    /* Show hamburger, hide nav by default */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* -- Nav: collapsible drawer -- */
    .header-bottom-tier {
        position: relative;
    }
    .main-nav-slim {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 2px;
        padding: 8px 12px 12px;
        max-height: 65vh;
        overflow-y: auto;
    }
    .main-nav-slim a {
        height: auto;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 8px;
        width: 100%;
    }
    .main-nav-slim a.active {
        border-bottom: none;
        border-left: 3px solid var(--accent-emerald);
        border-radius: 0 8px 8px 0;
    }

    /* Nav dropdowns: always expanded on mobile */
    .nav-dropdown {
        display: block;
        width: 100%;
    }
    .nav-dropdown > a {
        width: 100%;
        display: flex !important;
    }
    .nav-dropdown-content {
        display: block !important;
        position: static !important;
        box-shadow: none !important;
        border-radius: 0 0 8px 8px !important;
        margin-top: 0 !important;
        padding: 0 0 4px 16px;
        min-width: unset !important;
        border-left: 2px solid var(--border-glass);
        background: transparent !important;
    }
    .nav-dropdown-content a {
        font-size: 12px !important;
        padding: 7px 12px !important;
        border-bottom: none !important;
    }

    /* -- Main content area -- */
    main {
        padding: 0 10px;
        margin: 12px auto;
    }

    /* -- Glass panels -- */
    .glass-panel {
        padding: 14px !important;
        border-radius: 12px;
    }

    /* -- Dashboard widgets: 2-column on mobile -- */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .widget-value {
        font-size: 22px !important;
    }
    .widget-title {
        font-size: 11px !important;
    }
    .dashboard-columns, .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* -- Tables: convert to card rows on mobile -- */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 500px; /* force horizontal scroll rather than crush */
    }
    th, td {
        padding: 10px 12px;
        font-size: 12px;
    }
    th {
        font-size: 11px;
    }

    /* -- Modals: full-width on mobile -- */
    .modal-container {
        width: 96% !important;
        max-width: 96% !important;
        padding: 16px !important;
        border-radius: 12px !important;
        max-height: 92vh !important;
    }
    .modal-title {
        font-size: 15px !important;
    }

    /* -- Forms -- */
    .details-grid {
        grid-template-columns: 1fr !important;
    }
    .form-group {
        margin-bottom: 12px;
    }
    input, select, textarea {
        font-size: 16px !important; /* prevents iOS auto-zoom */
        padding: 10px 12px;
    }

    /* -- Buttons -- */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    /* Full-width action buttons inside forms */
    .modal-container .btn,
    .glass-panel > form .btn {
        width: 100%;
        justify-content: center;
    }

    /* -- Page sticky header -- */
    .page-top-sticky-container {
        padding: 12px 44px 10px 14px !important;
        margin: 8px 0 14px !important;
        border-radius: 10px;
    }
    .btn-close-page {
        top: 12px !important;
        right: 12px !important;
        width: 28px !important;
        height: 28px !important;
    }

    /* -- Tabs: scrollable on mobile -- */
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs .tab-link {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 12px;
    }

    /* -- Profile section -- */
    .profile-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .profile-large {
        width: 70px;
        height: 70px;
    }
}

/* ---- Small Mobile: 480px ---- */
@media (max-width: 480px) {
    /* Single column widgets on very small screens */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .brand-slim {
        font-size: 15px;
    }
    .brand-slim i {
        font-size: 16px;
    }
    .widget-value {
        font-size: 20px !important;
    }
    main {
        padding: 0 8px;
    }
    .glass-panel {
        padding: 12px !important;
        border-radius: 10px;
    }
}

@media print {
    .dual-tier-header, 
    .btn, 
    button, 
    .no-print, 
    .customize-trigger, 
    .dashboard-tabs, 
    .floating-action-button,
    form {
        display: none !important;
    }

    /* Force white background and black text for clear printing */
    body, .glass-panel, .main-content {
        background: white !important;
        background-color: white !important;
        color: black !important;
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Remove scrollbars from tables to show all data */
    .table-responsive {
        overflow: visible !important;
        overflow-x: visible !important;
    }

    /* Table borders for print */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    th, td {
        border: 1px solid #000 !important;
        color: black !important;
        padding: 8px !important;
    }

    /* Make sure table rows don't break across pages if possible */
    tr {
        page-break-inside: avoid !important;
    }

    /* Hide text shadows or specific glass effects */
    * {
        text-shadow: none !important;
        filter: none !important;
    }
}

/* Global Sticky Header */
.page-top-sticky-container {
    position: sticky;
    top: 65px; /* Fallback, dynamically overridden by JS */
    z-index: 100;
    background: var(--bg-secondary); /* Stronger background for contrast */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 15px 60px 10px 24px;
    margin-top: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-glass);
    border-bottom: 3px solid var(--accent-cyan);
    border-radius: 16px;
    box-shadow: var(--shadow-premium);
}

.page-top-sticky-container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: var(--bg-primary);
    z-index: -1;
}

.page-header-sticky {
    /* No sticky here, handled by parent container now */
}

.btn-close-page {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    margin-left: auto;
}

.btn-close-page:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

/* Tabs Navigation globally */
.tabs {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 1px;
}

.tabs .tab-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: -1px; /* Overlap the border */
}

.tabs .tab-link:hover {
    color: var(--text-primary);
}

.tabs .tab-link.active {
    color: var(--accent-cyan);
    border-bottom: 2px solid var(--accent-cyan);
    font-weight: 600;
}

/* Static Title & Close Button for Record Details Modal */
#details-modal .modal-container {
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    padding: 0;
}

#details-modal .modal-header {
    padding: 20px 24px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-glass);
}

#details-modal #details-modal-body {
    overflow-y: auto;
    flex-grow: 1;
    padding: 24px;
}

#details-modal .modal-container > div:last-child {
    padding: 15px 24px 20px 24px;
    margin-top: 0 !important;
    border-top: 1px solid var(--border-glass);
}

