  :root {
            --bg-color: #f0f2f5; --text-main: #111827; --text-muted: #6b7280;
            --accent-blue: #007aff; --accent-blue-hover: #0062cc;
            --glass-bg: rgba(255, 255, 255, 0.65); --glass-border: rgba(255, 255, 255, 0.8);
            --glass-shadow: 0 10px 40px -10px rgba(0,0,0,0.08), 0 2px 10px rgba(0,0,0,0.02);
            --radius-lg: 24px; --radius-md: 14px; --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        body { 
            margin: 0; padding: 0; background-color: var(--bg-color); 
            background-image: radial-gradient(circle at 10% 0%, rgba(0, 122, 255, 0.1) 0%, transparent 40%), radial-gradient(circle at 90% 10%, rgba(52, 199, 89, 0.08) 0%, transparent 40%);
            background-attachment: fixed; font-family: 'Inter', sans-serif; color: var(--text-main); height: 100vh; overflow: hidden;
        }

        .dms-container {
            max-width: 1400px;
            margin: 0 auto;
            width: 100%;
            box-sizing: border-box;
        }

        .sidebar { width: 260px; height: calc(100vh - 2rem); margin: 1rem 0 1rem 1rem; background: var(--glass-bg); backdrop-filter: saturate(180%) blur(30px); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--glass-shadow); display: flex; flex-direction: column; padding: 1.5rem; box-sizing: border-box; flex-shrink: 0; }

        .brand { 
            margin-bottom: 2.5rem; 
            display: flex; 
            align-items: center; 
            padding-left: 5px;
        }
        .brand-logo {
            max-width: 160px;
            height: auto;
            object-fit: contain;
        }

       .nav-menu { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
    overflow-y: auto; /* Enables vertical scrolling */
    overflow-x: hidden; /* Prevents horizontal wiggling */
    padding-right: 8px; /* Gives your custom scrollbar some breathing room */
}

        .nav-item { 
            padding: 0.75rem 1rem;
            font-size: 0.85rem;
            letter-spacing: 0.2px;
            border-radius: var(--radius-md); 
            color: var(--text-muted); 
            font-weight: 500; 
            cursor: pointer; 
            transition: var(--transition); 
            display: flex; 
            align-items: center; 
            gap: 10px;
        }
        .nav-item:hover { background: rgba(0, 0, 0, 0.03); color: var(--text-main); }
        .nav-item.active { background: #ffffff; color: var(--text-main); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); border: 1px solid #ffffff; font-weight: 600; }
        .nav-item svg { width: 18px; height: 18px; transition: var(--transition); }
        .nav-item.active svg { color: var(--accent-blue); }

        .workspace { flex: 1; display: flex; flex-direction: column; padding: 1rem 2rem; height: 100vh; box-sizing: border-box; overflow-y: auto; }
        
        .topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 1rem 0 2rem 0; }
        .page-title { grid-column: 2; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.5px; margin: 0; text-align: center; }
        .user-controls { grid-column: 3; display: flex; align-items: center; gap: 1rem; justify-content: flex-end; }
        
        .tenant-pillar { font-weight: 700; color: var(--text-main); font-size: 0.95rem; padding: 6px 12px; background: rgba(0,0,0,0.03); border-radius: 8px; border: 1px solid rgba(0,0,0,0.03); }
        .search-bar { background: rgba(255,255,255,0.8); border: 1px solid rgba(0,0,0,0.05); padding: 0.6rem 1.2rem; border-radius: 30px; font-family: 'Inter', sans-serif; font-size: 0.9rem; transition: var(--transition); }
        .search-bar:focus { outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(0,122,255,0.15); }
        .user-profile { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; cursor: pointer; text-decoration: none; color: var(--text-main); }
        .avatar { width: 36px; height: 36px; background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-main); font-weight: 700; border: 2px solid #fff; }
        
        .glass-module { background: var(--glass-bg); backdrop-filter: saturate(180%) blur(30px); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--glass-shadow); padding: 2.5rem; }
        .btn-primary { background: linear-gradient(180deg, #007aff 0%, #005bbf 100%); color: #fff; border: none; padding: 0.6rem 1.2rem; border-radius: 30px; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: var(--transition); box-shadow: 0 2px 4px rgba(0, 122, 255, 0.3); }
        .btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4); }
        .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
        .btn-danger { background: #ef4444; color: #fff; border: none; padding: 0.6rem 1.2rem; border-radius: 30px; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
      /* Modal System */
        .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; overflow-y: auto; padding: 2rem;}
        .modal-content { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); position: relative; display: flex; flex-direction: column; }
        .modal-header { padding: 1.5rem 2rem; border-bottom: 1px solid rgba(0,0,0,0.05); display: flex; justify-content: space-between; align-items: center; background: #fff; position: sticky; top: 0; z-index: 10; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
        .modal-body { padding: 2rem; }
        .close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
        .form-group { margin-bottom: 1.2rem; }
        .form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text-muted); }
        .form-group input, .form-group select, .form-group textarea { width: 100%; box-sizing: border-box; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1); padding: 0.6rem; font-family: 'Inter'; font-size: 0.95rem; }
        
        /* Specific Prep Styles */
        .stat-box { background: rgba(0, 122, 255, 0.05); border: 1px solid rgba(0, 122, 255, 0.2); border-radius: 12px; padding: 1.5rem; text-align: center; }
        .stat-num { font-size: 2.5rem; font-weight: bold; color: #007aff; margin-bottom: 0.5rem; }
        .foh-edit-input { background: transparent; border: 1px solid transparent; color: inherit; font-family: inherit; font-size: inherit; width: 100%; box-sizing: border-box; border-radius: 4px; padding: 2px 4px; }
        .foh-edit-input.is-editing { border: 1px dashed #007aff; background: rgba(0,122,255,0.05); }
        .foh-input { border: 1px solid #007aff; padding: 5px; border-radius: 4px; width: 80px; }
        .print-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
        .print-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
        .print-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; background: rgba(0,0,0,0.02); padding: 15px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.05); }
        .print-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; } 
        .print-table th, .print-table td { border: 1px solid rgba(0,0,0,0.1); padding: 8px; text-align: left; } 
        .print-table th { background: rgba(0, 122, 255, 0.1); color: #007aff; }
        .print-photos { display: flex; flex-wrap: wrap; gap: 10px; } 
        .print-photos img { width: 150px; height: 150px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; cursor: pointer; }

        .role-toggle { display: flex; background: rgba(0,0,0,0.05); border-radius: 12px; margin-bottom: 2rem; padding: 0.5rem; border: 1px solid rgba(0,0,0,0.05); }
        .role-btn { flex: 1; padding: 1rem; text-align: center; background: transparent; color: var(--text-muted); border: none; border-radius: 8px; font-family: 'Inter', sans-serif; font-weight: 600; cursor: pointer; transition: var(--transition); }
        .role-btn.active { background: #fff; color: var(--accent-blue); border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
        .driver-note { display: none; font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; font-style: italic; }
        .driver-note.visible { display: block; }
        .driver-note span { color: var(--accent-blue); font-weight: 600; }
        .upload-area { border: 2px dashed rgba(0, 122, 255, 0.3); background: rgba(0, 122, 255, 0.02); padding: 2rem; border-radius: 12px; text-align: center; cursor: pointer; display: block; margin-top: 1rem; transition: 0.3s; }
        .upload-area:hover { background: rgba(0, 122, 255, 0.05); border-color: rgba(0, 122, 255, 0.6); }
        .rag-red { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important; background: rgba(239, 68, 68, 0.05) !important; }
        .rag-amber { border-color: #f59e0b !important; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important; background: rgba(245, 158, 11, 0.05) !important; }
        .rag-green { border-color: #10b981 !important; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important; background: rgba(16, 185, 129, 0.05) !important; }
        .work-row { background: #f8fafc; padding: 1.5rem; border-radius: 12px; border: 1px solid #e2e8f0; margin-bottom: 1rem; position: relative; }
        .remove-row { position: absolute; top: 10px; right: 10px; background: #ef4444; color: white; border: none; border-radius: 50%; width: 25px; height: 25px; cursor: pointer; font-weight: bold; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1; }

        /* Print Styles for Invoice & Reports */
        @media print {
            body * { visibility: hidden; }
            #invoicePrintModal, #invoicePrintModal *, #reportViewModal, #reportViewModal *, #griddingViewModal, #griddingViewModal * { visibility: visible; }
            #invoicePrintModal, #reportViewModal, #griddingViewModal { position: absolute; left: 0; top: 0; width: 100%; max-width: 100%; background: #fff; box-shadow: none; display: block !important; padding: 0 !important; margin: 0 !important; overflow: visible !important;}
            .modal-content { box-shadow: none !important; border: none !important; max-width: 100% !important; width: 100% !important; padding: 0 !important; margin: 0 !important; background: white !important; color: #000 !important; display: block !important; overflow: visible !important; }
            .modal-overlay { background: transparent; backdrop-filter: none; position: static; display: block !important; padding: 0 !important;}
            .close-btn, .no-print { display: none !important; }
            .modal-header { border-bottom: none; padding-bottom: 0; }
            @page { size: A4; margin: 15mm 10mm 15mm 10mm; }
            body { background: white !important; height: auto !important; overflow: visible !important;}
            .print-grid-4, .print-table, .print-photos { page-break-inside: auto; }
            tr { page-break-inside: avoid !important; page-break-after: auto; }
            thead { display: table-header-group; } 
            .print-photos img { width: 45% !important; margin: 2% !important; page-break-inside: avoid !important; border: 1px solid #ccc !important; }
        }

        /* =========================================
           DARK MODE & LAYOUT ENHANCEMENTS
           ========================================= */

        /* 1. Core Variables (Premium Softer Palette) */
        body.dark-mode {
            --bg-color: #0f172a; 
            --text-main: #f8fafc; 
            --text-muted: #94a3b8; 
            --accent-blue: #3b82f6; 
            --accent-blue-hover: #60a5fa;
            --glass-bg: rgba(30, 41, 59, 0.75); 
            --glass-border: rgba(255, 255, 255, 0.08);
            --glass-shadow: 0 10px 40px -10px rgba(0,0,0,0.5), 0 2px 10px rgba(0,0,0,0.2);
            
            background-image: radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.1) 0%, transparent 40%), 
                              radial-gradient(circle at 90% 10%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
        }

        /* 3. Inputs & Base UI */
        body.dark-mode .nav-item.active { 
            background: rgba(255, 255, 255, 0.1) !important; 
            border-color: rgba(255, 255, 255, 0.1) !important; 
            color: #fff; 
        }
        body.dark-mode .search-bar,
        body.dark-mode .foh-edit-input,
        body.dark-mode .foh-input { 
            background: rgba(15, 23, 42, 0.8) !important; 
            border-color: rgba(255, 255, 255, 0.1) !important; 
            color: var(--text-main) !important; 
        }
        body.dark-mode .search-bar:focus { 
            background: #1e293b !important; 
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important; 
        }
        
        /* 4. Modals */
        body.dark-mode .modal-content,
        body.dark-mode .modal-header { 
            background: #1e293b !important; 
            border-color: rgba(255, 255, 255, 0.05) !important; 
            color: var(--text-main); 
        }
        body.dark-mode .close-btn { 
            color: var(--text-muted); 
        }
        
        /* 5. Tables & Data Grids */
        body.dark-mode table, 
        body.dark-mode th, 
        body.dark-mode td { 
            border-color: rgba(255,255,255,0.08) !important; 
            color: var(--text-main) !important; 
        }
        body.dark-mode thead tr { 
            background: rgba(0,0,0,0.2) !important; 
            color: var(--text-muted) !important; 
        }
        body.dark-mode tbody tr[style*="background: #fff"],
        body.dark-mode tbody tr[style*="background: #f8fafc"],
        body.dark-mode tbody tr[style*="background:#fff"],
        body.dark-mode tbody tr[style*="background:#f8fafc"] { 
            background: transparent !important; 
        }
        
        /* 6. Overriding JS Inline Styles for Inner Cards */
        body.dark-mode div[style*="background: #fff"],
        body.dark-mode div[style*="background: #ffffff"],
        body.dark-mode div[style*="background: rgba(255,255,255"] {
            background: rgba(30, 41, 59, 0.5) !important;
            border-color: rgba(255, 255, 255, 0.08) !important;
        }
        
        /* Preserve specific RAG (Red/Amber/Green) inline status backgrounds */
        body.dark-mode div[style*="background: rgba(16, 185, 129"],
        body.dark-mode div[style*="background: rgba(239, 68, 68"],
        body.dark-mode div[style*="background: rgba(245, 158, 11"],
        body.dark-mode div[style*="background: rgba(59, 130, 246"] {
            background-color: inherit; 
        }

        /* 7. Miscellaneous UI (Avatars, Toggles, Labels) */
        body.dark-mode .avatar { 
            background: linear-gradient(135deg, #334155 0%, #0f172a 100%); 
            border-color: #334155; 
        }
        body.dark-mode .role-btn.active { 
            background: #3b82f6 !important; 
            color: #fff !important; 
            border-color: #3b82f6 !important; 
        }
        body.dark-mode .role-toggle { 
            background: rgba(0,0,0,0.2); 
        }
        body.dark-mode .upload-area {
            background: rgba(59, 130, 246, 0.05);
            border-color: rgba(59, 130, 246, 0.3);
        }
        body.dark-mode .tenant-pillar { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.05); }
              /* Dark Mode overrides for Mobile Header */
        body.dark-mode .mobile-branding { border-color: rgba(255,255,255,0.05); }
        body.dark-mode .mobile-gemini-badge { background: rgba(0,0,0,0.2) !important; border-color: rgba(255,255,255,0.05) !important; }


        /* =========================================
           UI POLISH & MICRO-INTERACTIONS
           ========================================= */

        /* 1. Premium Custom Scrollbars */
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; }
        body.dark-mode ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
        ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.25); }
        body.dark-mode ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

        /* 2. Smooth Entrance Animations */
        @keyframes fadeSlideUp {
            from { opacity: 0; transform: translateY(15px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .glass-module { 
            animation: fadeSlideUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; 
        }
        .modal-content { 
            animation: fadeSlideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; 
        }

        /* 3. Interactive Data Grids */
        tbody tr { 
            transition: background 0.2s ease; 
        }
        tbody tr:hover { 
            background: rgba(0, 122, 255, 0.04) !important; 
        }
        body.dark-mode tbody tr:hover { 
            background: rgba(255, 255, 255, 0.06) !important; 
        }
                      /* =========================================
           MOBILE RESPONSIVENESS (SMARTPHONES/TABLETS)
           ========================================= */
        .mobile-menu-btn { display: none; background: none; border: none; color: var(--text-main); cursor: pointer; padding: 0; line-height: 1; }
        .mobile-branding { display: none; }

        @media (max-width: 900px) {
            /* 1. Global Mobile Font Scaling */
            html { font-size: 14px !important; } 

            /* 2. Body, Sidebar Drawer & Overlay */
            body { flex-direction: column; overflow-y: auto; display: block; }
            .sidebar {
                position: fixed; top: 0; left: -320px; height: 100vh; margin: 0; border-radius: 0;
                z-index: 9999; transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
                box-shadow: 10px 0 30px rgba(0,0,0,0.5); background: var(--bg-color);
            }
            .sidebar.mobile-open { left: 0; }
            .mobile-overlay {
                display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
                background: rgba(0,0,0,0.6); z-index: 9998; backdrop-filter: blur(2px);
            }
            .mobile-overlay.mobile-open { display: block; }
            
            /* 3. Workspace, Tables & Grids */
            .workspace { height: auto; overflow-y: visible; padding: 0 0.5rem 0.5rem 0.5rem !important; width: 100%; display: block; }
            .glass-module { padding: 1rem !important; margin-bottom: 1rem !important; border-radius: 16px !important; overflow-x: auto; }
            table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
            .print-grid-2, .print-grid-3, .print-grid-4 { grid-template-columns: 1fr !important; }
            
            /* 4. Sleeker Buttons & Inputs */
            .btn-primary, .btn-danger { padding: 0.5rem 1rem !important; font-size: 0.85rem !important; }
            .search-bar { padding: 0.6rem 0.8rem !important; font-size: 0.9rem !important; }
            th, td { padding: 0.75rem 1rem !important; font-size: 0.85rem !important; }

            /* 5. PREMIUM MOBILE HEADER RESTRUCTURING */
            .topbar { 
                display: flex !important; flex-wrap: wrap !important; gap: 15px !important; 
                padding: 0.5rem 0 1.5rem 0 !important; align-items: center !important; margin-top: 0 !important;
            }
            
            /* Row 1: Branding */
            .mobile-branding { 
                display: flex !important; justify-content: space-between !important; align-items: center !important; 
                width: 100% !important; order: 1 !important; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 15px; 
            }
            .mobile-menu-btn { display: inline-flex; margin-right: 0; }
            
            /* Row 2: Page Title & Icons */
            .page-title { 
                order: 2 !important; flex: 1 1 auto !important; font-size: 1.5rem !important; 
                text-align: left !important; margin: 0 !important; justify-content: flex-start !important; display: flex;
            }
            .user-controls {
                order: 3 !important; flex: 0 0 auto !important; justify-content: flex-end !important; gap: 10px !important; width: auto !important;
            }
            
            /* Clean Icon-Only Look (Hides the text on the Mode and Sign Out buttons) */
            .tenant-pillar, .user-controls small, .user-profile span { display: none !important; }
            .user-controls .btn-primary { 
                padding: 0 !important; width: 36px !important; height: 36px !important; 
                border-radius: 50% !important; justify-content: center !important; 
            }
            
            /* Row 3: Action Buttons (50/50 Grid) */
            .topbar-actions {
                order: 4 !important; width: 100% !important; display: grid !important; 
                grid-template-columns: 1fr 1fr !important; gap: 10px !important; 
                overflow-x: visible !important; white-space: normal !important;
            }
            .topbar-actions .btn-primary {
                padding: 0.7rem 0.5rem !important; font-size: 0.8rem !important; 
                text-align: center; justify-content: center; width: 100% !important; flex: none;
            }
        }