        :root {
            --primary-color: #3498db;
            --secondary-color: #2c3e50;
            --accent-color: #e74c3c;
            --sidebar-width: 260px;
            --header-height: 65px;
        }

        body {
            font-family: 'Noto Sans Thai', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f6f9;
            overflow: hidden;
        }

        .app-container {
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
        }

        .app-container.vh-100 {
            height: 100dvh !important;
        }

        .app-body {
            display: flex;
            flex: 1;
            min-height: 0;
            overflow: hidden;
            position: relative;
        }

        /* ── Header ─────────────────────────────── */
        .main-header {
            height: var(--header-height);
            background: #ffffff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
            z-index: 3001;
            flex-shrink: 0;
            width: 100%;
            box-sizing: border-box;
            border-bottom: 1px solid #f1f1f1;
            gap: 12px;
        }

        /* Bootstrap's .top-0 utility puts toasts behind the fixed top bar. */
        .toast-container.position-fixed.top-0 {
            top: calc(var(--header-height) + 12px) !important;
            z-index: 3102;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            min-width: 0;
        }

        .brand-logo {
            display: flex;
            align-items: center;
            text-decoration: none;
            white-space: nowrap;
            gap: 8px;
            color: inherit;
        }

        .brand-text {
            font-weight: 600;
            font-size: 1rem;
            color: #2c3e50;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .logo-icon {
            width: auto;
            height: 40px;
            background: transparent;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1rem;
            flex-shrink: 0;
            overflow: visible;
        }

        .logo-icon img {
            width: auto;
            height: auto;
            max-width: 140px;
            max-height: 40px;
            object-fit: contain;
            padding: 0;
        }

        /* Hamburger */
        .hamburger-btn {
            display: flex;
            background: none;
            border: none;
            cursor: pointer;
            color: #555;
            font-size: 1.2rem;
            padding: 6px;
            border-radius: 6px;
            flex-shrink: 0;
        }

        .hamburger-btn:hover { background: #f0f0f0; }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-shrink: 0;
            position: relative;
        }

        .topbar-notification-wrap {
            position: relative;
            flex-shrink: 0;
        }

        .topbar-notification {
            position: relative;
            width: 38px;
            height: 38px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: #475569;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
            padding: 0;
        }

        .topbar-notification:hover {
            color: #0f172a;
            background: #eef2ff;
            border-color: #c7d2fe;
            transform: translateY(-1px);
        }

        .topbar-notification-count {
            position: absolute;
            top: -5px;
            right: -5px;
            min-width: 19px;
            height: 19px;
            padding: 0 5px;
            border-radius: 999px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #ef4444;
            color: #fff;
            border: 2px solid #fff;
            font-size: 0.65rem;
            font-weight: 800;
            line-height: 1;
            box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25);
        }

        .topbar-notification-count.is-zero {
            background: #94a3b8;
            box-shadow: none;
        }

        .topbar-notification-panel {
            position: fixed;
            top: var(--topbar-notification-panel-top, calc(var(--header-height, 60px) + 10px));
            right: var(--topbar-notification-panel-right, 12px);
            width: min(360px, calc(100vw - 24px));
            max-height: calc(100dvh - var(--topbar-notification-panel-top, calc(var(--header-height, 60px) + 10px)) - 12px);
            background: rgba(255, 255, 255, 0.98);
            border: 1px solid rgba(226, 232, 240, 0.95);
            border-radius: 14px;
            box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
            overflow: hidden;
            z-index: 2147483000;
            opacity: 0;
            transform: translateY(-6px);
            pointer-events: none;
            transition: opacity 0.18s ease, transform 0.18s ease;
        }

        .topbar-notification-panel.show {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .topbar-notification-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 12px 14px;
            border-bottom: 1px solid #f1f5f9;
            color: #0f172a;
            font-weight: 700;
            font-size: 0.92rem;
        }

        .topbar-notification-head-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }

        .topbar-notification-read-all,
        .topbar-notification-read {
            border: 0;
            background: #eef2ff;
            color: #334155;
            border-radius: 999px;
            cursor: pointer;
            font-family: 'Noto Sans Thai', sans-serif;
            font-weight: 700;
        }

        .topbar-notification-read-all {
            padding: 4px 8px;
            font-size: 0.68rem;
        }

        .topbar-notification-read {
            padding: 3px 7px;
            font-size: 0.64rem;
            margin-top: 6px;
        }

        .topbar-notification-read-all:hover,
        .topbar-notification-read:hover {
            background: #dbeafe;
            color: #0f172a;
        }

        .topbar-notification-list {
            max-height: 260px;
            overflow-y: auto;
        }

        .topbar-notification-item {
            display: flex;
            gap: 10px;
            padding: 10px 14px;
            border-bottom: 1px solid #f8fafc;
        }

        .topbar-notification-item:last-child {
            border-bottom: 0;
        }

        .topbar-notification-dot {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            background: #ef4444;
            margin-top: 7px;
            flex-shrink: 0;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
        }

        .topbar-notification-dot.warning { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14); }
        .topbar-notification-dot.danger,
        .topbar-notification-dot.critical { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.14); }
        .topbar-notification-dot.info { background: #3b82f6; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14); }

        .topbar-notification-title {
            color: #1e293b;
            font-size: 0.84rem;
            font-weight: 600;
            line-height: 1.25;
        }

        .topbar-notification-meta {
            margin-top: 3px;
            color: #64748b;
            font-size: 0.72rem;
            line-height: 1.25;
        }

        .topbar-notification-message {
            margin-top: 2px;
            color: #475569;
            font-size: 0.72rem;
            line-height: 1.25;
        }

        .topbar-notification-empty {
            padding: 22px 14px;
            color: #94a3b8;
            text-align: center;
            font-size: 0.84rem;
        }

        .topbar-notification-footer {
            padding: 10px 12px;
            border-top: 1px solid #f1f5f9;
            background: #f8fafc;
        }

        .topbar-notification-all {
            width: 100%;
            height: 34px;
            border: 0;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            background: #0f172a;
            color: #fff;
            font-size: 0.82rem;
            font-weight: 700;
            text-decoration: none;
        }

        .topbar-notification-all:hover {
            color: #fff;
            background: #1e293b;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.9rem;
            color: #555;
            font-weight: 500;
            background: #f8f9fa;
            padding: 6px 12px;
            border-radius: 20px;
            border: 1px solid #eee;
        }

        /* Hide username text on very small screens */
        @media (max-width: 480px) {
            .user-info .user-name-text { display: none; }
            .brand-text { display: none; }
        }

        .logout-btn {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #e74c3c;
            background: #fff0f0;
            transition: all 0.2s;
            text-decoration: none;
            flex-shrink: 0;
        }

        .logout-btn:hover {
            background: #e74c3c;
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
        }

        /* ── Mobile Overlay ─────────────────────── */
        #sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 3999;
        }

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

        /* ── Sidebar ─────────────────────────────── */
        #sidebarCollapse.collapse {
            flex-shrink: 0;
            height: 100%;
            min-height: 0;
        }

        #sidebarCollapse.collapse.show {
            display: flex;
        }

        .sidebar {
            width: var(--sidebar-width);
            height: 100%;
            max-height: 100%;
            min-height: 0;
            overflow: hidden;
            background-color: #2c3e50;
            color: white;
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            transition: transform 0.2s ease;
            position: relative;
            z-index: 4000;
        }

        .sidebar.collapsed { width: 60px; }

        .sidebar-menu {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
        }

        .sidebar-menu a,
        .sidebar-menu button.sidebar-action {
            display: flex;
            align-items: center;
            width: 100%;
            padding: 10px 15px;
            color: #bdc3c7;
            background: transparent;
            border: 0;
            text-decoration: none;
            transition: background 0.2s, color 0.2s;
            white-space: nowrap;
            overflow: hidden;
            border-left: 4px solid transparent;
            font-size: 0.9rem;
            font-weight: 300;
            font-family: 'Noto Sans Thai', sans-serif;
            cursor: pointer;
            margin: 0 !important;
            border-top: 0 !important;
            border-right: 0 !important;
            border-bottom: 0 !important;
            border-left: 4px solid transparent !important;
            border-radius: 0 !important;
            box-shadow: none !important;
            outline: none !important;
            appearance: none !important;
            -webkit-appearance: none !important;
        }

        .sidebar-menu button.sidebar-action:focus,
        .sidebar-menu button.sidebar-action:focus-visible {
            outline: none !important;
            box-shadow: none !important;
            border-top: 0 !important;
            border-right: 0 !important;
            border-bottom: 0 !important;
            border-left: 4px solid transparent !important;
        }

        .sidebar.collapsed .sidebar-menu a,
        .sidebar.collapsed .sidebar-menu button.sidebar-action {
            padding: 10px 0;
            justify-content: center;
        }

        .sidebar-menu a i,
        .sidebar-menu button.sidebar-action i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 1.1rem;
            flex-shrink: 0;
        }

        .sidebar.collapsed .sidebar-menu a i { margin-right: 0; }
        .sidebar.collapsed .sidebar-menu a span { display: none; }
        .sidebar.collapsed .sidebar-menu button.sidebar-action i { margin-right: 0; }
        .sidebar.collapsed .sidebar-menu button.sidebar-action span { display: none; }

        /* Tooltip when collapsed (desktop) */
        .sidebar.collapsed:not(:hover) .sidebar-menu a:hover::after,
        .sidebar.collapsed:not(:hover) .sidebar-menu button.sidebar-action:hover::after {
            content: attr(title);
            position: absolute;
            left: 100%;
            top: 50%;
            transform: translateY(-50%);
            background: #333;
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            white-space: nowrap;
            z-index: 5000;
            margin-left: 10px;
            font-size: 0.85rem;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            pointer-events: none;
        }

        .sidebar-menu a:hover,
        .sidebar-menu a.active,
        .sidebar-menu button.sidebar-action:hover {
            background-color: #34495e;
            color: white;
            border-left: 4px solid #3498db !important;
        }

        .sidebar-menu a.is-navigating {
            background-color: #34495e;
            color: #ffffff;
            pointer-events: none;
        }

        .sidebar-menu a.is-navigating i {
            opacity: 0.72;
        }

        .menu-category {
            padding: 12px 15px 5px;
            font-size: 0.72rem;
            text-transform: uppercase;
            color: #7f8c8d;
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .sidebar.collapsed .menu-category { display: none; }
        .sidebar.collapsed:hover .menu-category { display: block; }

        /* ── Mobile Sidebar ─────────────────────── */
        @media (max-width: 767px) {
            .hamburger-btn { display: flex; }

            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                height: 100vh;
                height: 100dvh;
                max-height: 100dvh;
                overflow: hidden;
                width: 240px !important;
                transform: translateX(-100%);
                z-index: 4000;
            }

            .sidebar-menu {
                padding-bottom: env(safe-area-inset-bottom, 0px);
            }

            .sidebar.mobile-open { transform: translateX(0); }

            /* Always show labels on mobile (even when .collapsed is present) */
            .sidebar .sidebar-menu a,
            .sidebar.collapsed .sidebar-menu a { padding: 12px 20px; justify-content: flex-start; }
            .sidebar .sidebar-menu button.sidebar-action,
            .sidebar.collapsed .sidebar-menu button.sidebar-action { padding: 12px 20px; justify-content: flex-start; }
            .sidebar .sidebar-menu a i,
            .sidebar.collapsed .sidebar-menu a i { margin-right: 10px; }
            .sidebar .sidebar-menu button.sidebar-action i,
            .sidebar.collapsed .sidebar-menu button.sidebar-action i { margin-right: 10px; }
            .sidebar .sidebar-menu a span,
            .sidebar.collapsed .sidebar-menu a span { display: inline-block; }
            .sidebar .sidebar-menu button.sidebar-action span,
            .sidebar.collapsed .sidebar-menu button.sidebar-action span { display: inline-block; }
            .sidebar .menu-category,
            .sidebar.collapsed .menu-category { display: block; }
            .sidebar.collapsed .dvr-menu-group > .submenu-toggle .arrow-icon { display: inline-block; }
            .sidebar.collapsed .dvr-menu-group > .submenu-content { display: none; }
            .sidebar.collapsed .dvr-menu-group.open > .submenu-content { display: block !important; }
            .sidebar.collapsed:not(:hover) .sidebar-menu a:hover::after,
            .sidebar.collapsed:not(:hover) .sidebar-menu button.sidebar-action:hover::after { display: none; }
        }

        /* ── Main Content ────────────────────────── */
        .main-content-wrapper {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: #f4f6f8;
            position: relative;
            overflow: hidden;
            min-width: 0;
        }

        .page-content {
            flex: 1;
            position: relative;
            overflow: auto;
        }

        .app-footer {
            min-height: 32px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            padding: 6px 16px;
            background: rgba(255, 255, 255, 0.96);
            border-top: 1px solid rgba(226, 232, 240, 0.9);
            color: #64748b;
            font-size: 0.78rem;
            line-height: 1.25;
            flex-shrink: 0;
            z-index: 3000;
        }

        .app-footer span {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .app-footer-right {
            text-align: right;
        }

        @media (max-width: 640px) {
            .app-footer {
                min-height: 30px;
                padding: 5px 10px;
                font-size: 0.68rem;
                gap: 8px;
            }
        }

        /* ── Floating Panels (used by map page) ─── */
        .floating-panel {
            position: absolute;
            top: 20px;
            left: 20px;
            width: 320px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 16px;
            box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
            display: flex;
            flex-direction: column;
            max-height: calc(100% - 40px);
            z-index: 2000;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.5);
        }

        @media (max-width: 480px) {
            .floating-panel { width: calc(100vw - 32px); left: 16px; border-radius: 12px; }
        }

        /* ── Utility classes (used by modules) ──── */
        .text-danger { color: #ef4444; }
        .text-success { color: #10b981; }

        .badge {
            padding: 3px 8px;
            border-radius: 6px;
            font-size: 0.65rem;
            font-weight: 500;
            letter-spacing: 0.02em;
        }
        .badge-danger { background: #fef2f2; color: #ef4444; border: 1px solid #fee2e2; }
        .badge-success { background: #f0fdf4; color: #10b981; border: 1px solid #dcfce7; }
        .badge-warning { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
        .badge-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

        .panel-header {
            background: transparent;
            color: #1e293b;
            padding: 18px 20px 14px;
            font-weight: 500;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .panel-tabs { display: flex; border-bottom: 1px solid #f1f5f9; padding: 0 10px; }
        .panel-tab { flex: 1; text-align: center; padding: 10px 5px; cursor: pointer; font-size: 0.8rem; color: #64748b; font-weight: 400; transition: all 0.2s; position: relative; }
        .panel-tab:hover { color: #334155; }
        .panel-tab.active { color: #3b82f6; font-weight: 500; }
        .panel-tab.active::after { content: ''; position: absolute; bottom: -1px; left: 10%; right: 10%; height: 2px; background: #3b82f6; border-radius: 2px 2px 0 0; }

        .vehicle-list { overflow-y: auto; flex: 1; }
        .vehicle-list::-webkit-scrollbar { width: 4px; }
        .vehicle-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

        .vehicle-item {
            padding: 12px 20px;
            border-bottom: 1px solid #f8fafc;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .vehicle-item:hover { background-color: #f8fafc; }

        .status-indicator { width: 8px; height: 8px; border-radius: 50%; background-color: #cbd5e1; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); }
        .status-online  { background-color: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
        .status-offline { background-color: #94a3b8; }
        .status-moving  { background-color: #3b82f6; box-shadow: 0 0 0 2px #dbeafe; }
        .status-alarm   { background-color: #ef4444; box-shadow: 0 0 0 2px #fee2e2; }

        .vehicle-info { flex: 1; min-width: 0; }
        .vehicle-name { font-weight: 500; font-size: 0.9rem; color: #1e293b; letter-spacing: -0.01em; }
        .vehicle-detail { font-size: 0.7rem; color: #64748b; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }

        /* ── Leaflet Popup ───────────────────────── */
        .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 12px; box-shadow: 0 10px 30px -5px rgba(0,0,0,0.1); }
        .leaflet-popup-content { margin: 0; width: 300px !important; }
        .custom-popup { font-family: 'Noto Sans Thai', sans-serif; }
        .popup-header {
            background: transparent;
            color: #1e293b;
            padding: 16px 20px 12px;
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            border-bottom: 1px solid #f1f5f9;
        }
        .popup-license { font-size: 1.1rem; font-weight: 500; letter-spacing: -0.01em; }
        .popup-province { font-size: 0.75rem; color: #64748b; font-weight: 300; }
        .popup-status-row { display: flex; justify-content: space-around; padding: 12px 10px; border-bottom: 1px solid #f8fafc; background: #fafafa; }
        .popup-status-item { display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; color: #64748b; font-weight: 400; gap: 4px; }
        .popup-status-icon { font-size: 1.1rem; }
        .popup-details { padding: 12px 20px 20px; background: white; }
        .popup-detail-row { display: flex; gap: 12px; margin-bottom: 10px; font-size: 0.8rem; color: #334155; font-weight: 300; }
        .popup-detail-icon { color: #94a3b8; font-size: 1rem; width: 16px; text-align: center; margin-top: 1px; }
        .popup-detail-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
        .popup-label { color: #64748b; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }

        /* ── Floating Time/Company boxes ────────── */
        .floating-time-box {
            position: absolute; top: 20px; right: 20px;
            background: white; padding: 8px 15px; border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            z-index: 2000; font-size: 0.9rem; color: #555;
            display: flex; align-items: center; gap: 8px;
        }
        .floating-company-box {
            position: absolute; top: 60px; right: 20px;
            background: white; padding: 8px 15px; border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            z-index: 2000; font-size: 1rem; font-weight: 600; color: #2c3e50;
            display: flex; align-items: center; gap: 8px;
        }

        /* ── Submenu ─────────────────────────────── */
        .submenu-toggle { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
        .submenu-content { display: none; background-color: rgba(0, 0, 0, 0.18); padding-left: 0; }
        .submenu-content a { padding-left: 42px !important; font-size: 0.86rem !important; }
        .arrow-icon { font-size: 0.78rem; transition: transform 0.25s ease; margin-left: auto; }
        .dvr-menu-group { position: relative; }
        .dvr-menu-badge-new {
            margin-left: auto;
            padding: 2px 7px;
            border-radius: 5px;
            background: #0ea5e9;
            color: #ffffff;
            font-size: 0.68rem;
            font-weight: 700;
            line-height: 1.2;
            letter-spacing: 0.02em;
        }
        .sidebar.collapsed .dvr-menu-group > .submenu-toggle .arrow-icon { display: none; }
        .sidebar.collapsed .dvr-menu-group > .submenu-content { display: none !important; }
        @media (min-width: 768px) {
            .sidebar.collapsed { overflow: visible; }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content {
                display: block !important;
                position: absolute;
                left: 100%;
                top: 0;
                min-width: 215px;
                background: #0b5cab;
                border: 1px solid rgba(255, 255, 255, 0.14);
                border-radius: 0 8px 8px 0;
                box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
                z-index: 5200;
                overflow: hidden;
            }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content .dvr-flyout-header {
                display: block;
                padding: 10px 16px;
                background: #0d6efd;
                color: #ffffff;
                font-size: 0.9rem;
                font-weight: 700;
                border-bottom: 1px solid rgba(255, 255, 255, 0.15);
            }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content a {
                padding: 10px 16px !important;
                justify-content: space-between !important;
                color: #e2e8f0 !important;
                background: #074786;
            }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content a:hover,
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content a.active {
                background: #0b5cab !important;
                color: #ffffff !important;
            }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-content a span {
                display: inline-block !important;
            }
            .sidebar.collapsed .dvr-menu-group:hover > .submenu-toggle::after {
                display: none !important;
            }
        }
        .dvr-flyout-header { display: none; }

        /* ── Dark Mode (body.dark-mode) ──────────── */
        body.dark-mode {
            --bg-primary: #0f172a;
            --bg-secondary: #1e293b;
            --text-primary: #f1f5f9;
            --text-secondary: #94a3b8;
            --border-color: #334155;
            --accent-blue: #3b82f6;
            background-color: var(--bg-primary) !important;
            color: var(--text-primary);
        }

        body.dark-mode .main-header {
            background-color: var(--bg-secondary) !important;
            border-bottom: 1px solid var(--border-color) !important;
        }

        body.dark-mode .brand-text { color: #e2e8f0; }

        body.dark-mode .hamburger-btn { color: #94a3b8; }
        body.dark-mode .hamburger-btn:hover { background: #334155; }

        body.dark-mode .user-info {
            background: #1e293b;
            color: #e2e8f0;
            border-color: #334155;
        }

        body.dark-mode .topbar-notification {
            background: #0f172a;
            color: #cbd5e1;
            border-color: #334155;
        }

        body.dark-mode .topbar-notification:hover {
            background: #1e293b;
            color: #ffffff;
            border-color: #475569;
        }

        body.dark-mode .topbar-notification-count {
            border-color: #1e293b;
        }

        body.dark-mode .topbar-notification-panel {
            background: #1e293b;
            border-color: #334155;
            box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
        }

        body.dark-mode .topbar-notification-head,
        body.dark-mode .topbar-notification-item,
        body.dark-mode .topbar-notification-footer {
            border-color: #334155;
        }

        body.dark-mode .topbar-notification-head,
        body.dark-mode .topbar-notification-title {
            color: #f8fafc !important;
        }

        body.dark-mode .topbar-notification-meta,
        body.dark-mode .topbar-notification-message,
        body.dark-mode .topbar-notification-empty {
            color: #94a3b8 !important;
        }

        body.dark-mode .topbar-notification-read-all,
        body.dark-mode .topbar-notification-read {
            background: #334155;
            color: #e2e8f0;
        }

        body.dark-mode .topbar-notification-read-all:hover,
        body.dark-mode .topbar-notification-read:hover {
            background: #475569;
            color: #ffffff;
        }

        body.dark-mode .topbar-notification-footer {
            background: #0f172a;
        }

        body.dark-mode .main-content-wrapper { background-color: var(--bg-primary) !important; }
        body.dark-mode .app-footer {
            background: #0f172a;
            border-top-color: rgba(148, 163, 184, 0.16);
            color: #94a3b8;
        }

        body.dark-mode .sidebar {
            background-color: #020617 !important;
            border-right: 1px solid var(--border-color);
        }

        body.dark-mode .sidebar-menu a:hover,
        body.dark-mode .sidebar-menu a.active {
            background-color: #334155 !important;
            color: #fff !important;
            border-left: 4px solid #60a5fa !important;
        }

        body.dark-mode div[style*="background: white"],
        body.dark-mode div[style*="background-color: white"],
        body.dark-mode .dash-card,
        body.dark-mode .stat-card,
        body.dark-mode .content-card,
        body.dark-mode .card-header,
        body.dark-mode .card-body,
        body.dark-mode .report-menu {
            background-color: var(--bg-secondary) !important;
            background: var(--bg-secondary) !important;
            background-image: none !important;
            color: var(--text-primary) !important;
            border: 1px solid var(--border-color) !important;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
        }

        /* ── Vehicle Status Bar (Migrated to Header) ── */
        .vehicle-status-bar {
            display: flex;
            gap: 0;
            padding: 2px 1px;
            background: var(--status-bar-bg, rgba(255, 255, 255, 0.08));
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border: 1px solid var(--status-bar-border, rgba(255, 255, 255, 0.15));
            border-radius: 100px;
            margin-right: 8px;
            align-items: center;
            line-height: 1;
        }

        /* Default (Light Mode) overrides for status bar */
        body:not(.dark-mode) .vehicle-status-bar {
            background: rgba(0, 0, 0, 0.05);
            border-color: rgba(0, 0, 0, 0.1);
        }

        .status-summary-btn {
            display: flex;
            align-items: center;
            gap: 2px;
            padding: 0 1px;
            margin: 0 !important;
            border: 0 !important;
            background: none !important;
            box-shadow: none !important;
            outline: none !important;
            border-radius: 0 !important;
            appearance: none !important;
            -webkit-appearance: none !important;
            font-family: 'Noto Sans Thai', sans-serif;
            font-size: 0.74rem;
            font-weight: 400;
            line-height: 1;
            white-space: nowrap;
            color: #475569; /* Darker for light mode */
            user-select: none;
            cursor: default;
        }

        body.dark-mode .status-summary-btn {
            color: rgba(255, 255, 255, 0.9);
        }

        .status-summary-btn.active {
            font-weight: 600;
            color: #1e293b; /* Deep dark for active light mode */
        }

        body.dark-mode .status-summary-btn.active {
            color: #fff;
        }

        .status-summary-btn .status-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 17px;
            height: 17px;
            border-radius: 50%;
            font-size: 0.56rem;
            flex-shrink: 0;
        }

        .status-summary-btn .status-count {
            font-weight: 700;
            font-size: 0.8rem;
            min-width: 10px;
            text-align: center;
        }

        .status-summary-btn.status-off .status-icon { background: #ef4444; color: white; }
        .status-summary-btn.status-parked .status-icon { background: #f59e0b; color: white; }
        .status-summary-btn.status-moving .status-icon { background: #10b981; color: white; }
        .status-summary-btn.status-offline .status-icon { background: #64748b; color: white; }
        .status-summary-btn.status-na .status-icon { background: #475569; color: white; }

        @media (max-width: 768px) {
            :root {
                --header-height: 46px;
            }

            .main-header {
                height: var(--header-height) !important;
                min-height: var(--header-height) !important;
                padding: 4px 8px !important;
                gap: 6px !important;
                overflow: hidden;
            }

            .header-left {
                flex: 0 0 auto;
                gap: 6px !important;
            }

            .hamburger-btn {
                width: 34px;
                height: 34px;
                padding: 0 !important;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                font-size: 1rem !important;
            }

            .brand-logo {
                display: none !important;
            }

            .vehicle-status-bar {
                flex: 1 1 auto;
                min-width: 0;
                max-width: 100%;
                gap: 3px !important;
                margin: 0 !important;
                padding: 3px 4px !important;
                border-radius: 999px !important;
                overflow-x: auto;
                overflow-y: hidden;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
            }

            .vehicle-status-bar::-webkit-scrollbar {
                display: none;
            }

            .status-summary-btn {
                flex: 0 0 auto;
                gap: 3px !important;
                min-height: 32px;
                padding: 0 7px !important;
                border-radius: 999px !important;
                font-size: 0.74rem !important;
            }

            .status-summary-btn .status-icon {
                width: 22px !important;
                height: 22px !important;
                font-size: 0.7rem !important;
            }

            .status-summary-btn .status-count {
                min-width: 8px !important;
                font-size: 0.86rem !important;
                line-height: 1 !important;
            }

            .status-summary-btn .status-label {
                font-size: 0 !important;
                line-height: 1 !important;
            }

            .status-summary-btn .status-label::after {
                content: attr(data-mobile-label);
                font-size: 0.76rem;
                font-weight: 600;
                line-height: 1;
            }

            .status-summary-btn.status-na {
                display: none;
            }

            .user-profile {
                flex: 0 0 auto;
                gap: 4px !important;
            }

            .topbar-notification {
                width: 34px !important;
                height: 34px !important;
            }

            .topbar-notification-panel {
                position: fixed !important;
                top: calc(var(--header-height) + 8px) !important;
                right: 8px !important;
                width: calc(100vw - 16px) !important;
                max-width: 360px !important;
            }
        }



        body.dark-mode div[style*="background-color: #f8f9fe"],
        body.dark-mode div[style*="background-color: #f4f6f9"] {
            background-color: var(--bg-primary) !important;
        }

        body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4,
        body.dark-mode .card-title, body.dark-mode strong, body.dark-mode b {
            color: #ffffff !important;
            letter-spacing: 0.5px;
        }

        body.dark-mode div[style*="color: #555"],
        body.dark-mode div[style*="color: #2c3e50"],
        body.dark-mode div[style*="color: #7f8c8d"],
        body.dark-mode label, body.dark-mode li,
        body.dark-mode span, body.dark-mode th, body.dark-mode td {
            color: #cbd5e1 !important;
        }

        body.dark-mode .text-muted { color: #94a3b8 !important; }

        body.dark-mode input,
        body.dark-mode select,
        body.dark-mode textarea,
        body.dark-mode .custom-select,
        body.dark-mode .custom-input {
            background-color: #0f172a !important;
            color: #fff !important;
            border: 1px solid #475569 !important;
            color-scheme: dark;
        }

        body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator,
        body.dark-mode input[type="datetime-local"]::-webkit-calendar-picker-indicator,
        body.dark-mode input[type="time"]::-webkit-calendar-picker-indicator {
            filter: invert(1);
            cursor: pointer;
            opacity: 0.8;
        }

        body.dark-mode input:focus, body.dark-mode select:focus {
            border-color: #60a5fa !important;
            box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2) !important;
        }

        body.dark-mode table thead th {
            background-color: #0f172a !important;
            border-bottom: 2px solid #475569 !important;
            color: #e2e8f0 !important;
        }

        body.dark-mode table tbody td {
            background-color: var(--bg-secondary) !important;
            border-bottom: 1px solid var(--border-color) !important;
        }

        body.dark-mode table tbody tr:hover td { background-color: #334155 !important; }

        body.dark-mode i { opacity: 0.9; }

        /* ── Select2 Custom Styling ── */
        .select2-container--default .select2-selection--single {
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            height: 38px;
            display: flex;
            align-items: center;
            background-color: #fff;
        }
        .select2-container--default .select2-selection--single .select2-selection__rendered {
            color: #334155;
            font-size: 0.9rem;
            padding-left: 12px;
        }
        .select2-container--default .select2-selection--single .select2-selection__arrow {
            height: 36px;
        }
        .select2-dropdown {
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
        }

        /* Select2 Dark Mode */
        body.dark-mode .select2-container--default .select2-selection--single {
            background-color: #1e293b !important;
            border-color: #334155 !important;
        }
        body.dark-mode .select2-container--default .select2-selection--single .select2-selection__rendered {
            color: #f1f5f9 !important;
        }
        body.dark-mode .select2-dropdown {
            background-color: #1e293b !important;
            border-color: #334155 !important;
            color: #f1f5f9 !important;
        }
        body.dark-mode .select2-container--default .select2-results__option[aria-selected=true] {
            background-color: #334155 !important;
        }
        body.dark-mode .select2-container--default .select2-results__option--highlighted[aria-selected] {
            background-color: #3b82f6 !important;
        }
        body.dark-mode .select2-search--dropdown .select2-search__field {
            background-color: #334155 !important;
            border-color: #475569 !important;
            color: #f1f5f9 !important;
        }

        .gps-date-field {
            position: relative;
            display: inline-flex;
            align-items: center;
            width: 190px;
            max-width: 100%;
        }
        .gps-date-field .gps-date-display {
            width: 100%;
            min-width: 0;
            height: 42px;
            border: 1px solid #cbd5e1;
            border-radius: 12px;
            background: #fff;
            color: #334155;
            font: inherit;
            font-size: 1rem;
            padding: 9px 56px 9px 14px;
            cursor: pointer;
        }
        .gps-date-field .gps-native-date {
            position: absolute !important;
            inset: 0;
            width: 100% !important;
            height: 100% !important;
            opacity: 0 !important;
            pointer-events: none !important;
            margin: 0 !important;
            padding: 0 !important;
        }
        .gps-date-field .gps-date-button {
            position: absolute;
            right: 4px;
            top: 4px;
            width: 34px;
            height: 34px;
            border: 0;
            border-left: 1px solid #e2e8f0;
            border-radius: 10px;
            background: #fff;
            color: #64748b;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            box-shadow: -6px 0 14px rgba(15,23,42,.04);
            cursor: pointer;
        }
        .gps-date-field .gps-date-button:hover {
            color: #2563eb;
            background: #f8fafc;
        }
        body.dark-mode .gps-date-field .gps-date-display {
            background: #0b1727;
            border-color: #253355;
            color: #f8fafc;
        }
        body.dark-mode .gps-date-field .gps-date-button {
            background: #0b1727;
            border-left-color: #253355;
            color: #cbd5e1;
        }

/* Top Navigation Progress Bar (app-speed.js) */
#gpsNavProgress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    z-index: 2147483500;
    pointer-events: none;
    background: linear-gradient(90deg, #38bdf8, #2563eb, #60a5fa);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.65);
    opacity: 0;
    transition: width 0.2s ease, opacity 0.15s ease;
}
#gpsNavProgress.is-active {
    opacity: 1;
}
