:root {
            --primary: #3b82f6;
            --primary-hover: #2563eb;
            --success: #10b981;
            --danger: #ef4444;
            --dark: #0f172a;
            --panel-bg: rgba(255, 255, 255, 0.85); /* Slightly less transparent for readability */
            --panel-border: rgba(255, 255, 255, 0.5);
            --text-main: #1e293b;
            --text-muted: #64748b;
            --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            --glow: 0 0 40px rgba(255, 255, 255, 0.5);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Outfit', sans-serif;
        }

        body, html {
            height: 100%;
            width: 100%;
            overflow: hidden;
            background-color: #f0f0f0; /* Light background behind map */
            color: var(--text-main);
        }

        #map {
            height: 100%;
            width: 100%;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
        }

        /* Glassmorphism Panels */
        .glass-panel {
            background: var(--panel-bg);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid var(--panel-border);
            border-radius: 16px;
            box-shadow: var(--shadow);
            z-index: 1000;
        }

        /* Top Header */
        .top-bar {
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 96%;
            height: 64px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 24px;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
        }

        .top-bar.hidden {
            transform: translate(-50%, -150%);
            opacity: 0;
            pointer-events: none;
        }

        .top-bar-right {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .logo {
            font-size: 1.25rem;
            font-weight: 700;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .logo i {
            color: var(--primary);
            font-size: 1.5rem;
        }

        .search-container {
            display: flex;
            align-items: center;
            background: rgba(0, 0, 0, 0.05);
            border-radius: 32px;
            padding: 10px 24px;
            width: 40%;
            max-width: 500px;
            border: 1px solid rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .search-container:focus-within {
            background: rgba(0, 0, 0, 0.1);
            border-color: var(--primary);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
        }

        .search-container input {
            background: transparent;
            border: none;
            color: var(--text-main);
            outline: none;
            width: 100%;
            margin-left: 12px;
            font-size: 0.95rem;
        }
        
        .search-container input::placeholder {
            color: rgba(0, 0, 0, 0.4);
        }

        .login-btn {
            background: linear-gradient(135deg, var(--primary), #6366f1);
            color: white;
            border: none;
            padding: 10px 24px;
            border-radius: 32px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
        }

        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
        }

        /* Left Panel */
        .left-panel {
            position: absolute;
            top: 100px;
            left: 2%;
            width: 300px;
            padding: 24px;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
            transform-origin: left center;
        }

        .left-panel.hidden {
            transform: translateX(-120%);
            opacity: 0;
            pointer-events: none;
        }

        .panel-title {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 20px;
            color: var(--text-main);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .panel-title .title-text {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        /* Dropdown & Buttons */
        .btn-group {
            position: relative;
            margin-bottom: 24px;
        }

        .btn {
            width: 100%;
            padding: 12px 16px;
            border: none;
            border-radius: 12px;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            transition: all 0.2s ease;
        }

        .btn-primary {
            background: rgba(59, 130, 246, 0.2);
            color: #60a5fa;
            border: 1px solid rgba(59, 130, 246, 0.4);
        }

        .btn-primary:hover {
            background: rgba(59, 130, 246, 0.3);
        }

        .submenu {
            position: absolute;
            top: 0;
            left: calc(100% + 10px); /* Show on the right instead of covering the edit mode toggle */
            width: 220px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(16px);
            border: 1px solid var(--panel-border);
            border-radius: 12px;
            overflow: hidden;
            display: none;
            flex-direction: column;
            z-index: 1001;
            box-shadow: var(--shadow);
        }

        .submenu.active {
            display: flex;
        }

        .submenu button {
            padding: 12px 16px;
            background: transparent;
            border: none;
            color: var(--text-main);
            text-align: left;
            cursor: pointer;
            transition: background 0.2s;
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 0.9rem;
        }

        .submenu button:hover {
            background: rgba(0, 0, 0, 0.05);
        }

        /* Toggle Switch */
        .toggle-group {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding: 16px;
            background: rgba(0, 0, 0, 0.05);
            border-radius: 12px;
        }

        .toggle-group label {
            font-weight: 500;
            font-size: 0.95rem;
        }

        .switch {
            position: relative;
            display: inline-block;
            width: 46px;
            height: 26px;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.2);
            transition: .4s;
            border-radius: 26px;
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        input:checked + .slider {
            background-color: var(--primary);
        }

        input:checked + .slider:before {
            transform: translateX(20px);
        }

        /* Checkboxes */
        .filter-group h4 {
            font-size: 0.9rem;
            color: var(--text-muted);
            margin-bottom: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .checkbox-item {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
            cursor: pointer;
            font-size: 0.95rem;
        }

        .checkbox-item input {
            appearance: none;
            width: 18px;
            height: 18px;
            border: 2px solid rgba(0, 0, 0, 0.3);
            border-radius: 4px;
            background: transparent;
            cursor: pointer;
            position: relative;
            transition: all 0.2s;
        }

        .checkbox-item input:checked {
            background: var(--primary);
            border-color: var(--primary);
        }

        .checkbox-item input:checked::after {
            content: '\f00c';
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            font-size: 10px;
            color: white;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        /* Right Panel */
        .right-panel {
            position: absolute;
            top: 100px;
            right: 2%;
            width: 380px;
            padding: 24px;
            max-height: calc(100vh - 120px);
            overflow-y: auto;
            transition: transform 0.3s ease, opacity 0.3s ease;
            transform-origin: right center;
        }
        
        .right-panel.hidden {
            transform: translateX(120%);
            opacity: 0;
            pointer-events: none;
        }

        .right-panel::-webkit-scrollbar { width: 4px; }
        .right-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

        .btn-toggle-panel {
            background: rgba(0,0,0,0.05);
            border: none;
            color: var(--text-main);
            border-radius: 8px;
            padding: 4px 8px;
            cursor: pointer;
            transition: background 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.85rem;
        }
        .btn-toggle-panel:hover {
            background: rgba(0,0,0,0.1);
        }

        .show-panel-btn {
            position: absolute;
            padding: 10px 18px;
            background: var(--panel-bg);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border: 1px solid var(--panel-border);
            color: var(--text-main);
            border-radius: 12px;
            cursor: pointer;
            z-index: 999;
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 600;
            font-size: 0.9rem;
            box-shadow: var(--shadow);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .show-panel-btn:hover {
            background: rgba(241, 245, 249, 0.95);
            transform: translateY(-2px);
        }
        .show-panel-btn.hidden {
            display: none;
            opacity: 0;
            pointer-events: none;
        }

        #showTopBarBtn { top: 20px; left: 50%; transform: translateX(-50%); }
        #showTopBarBtn:hover { transform: translateX(-50%) translateY(-2px); }
        #showControlsBtn { top: 100px; left: 2%; }
        #showStatsBtn { top: 100px; right: 2%; }
        #showLegendBtn { bottom: 30px; left: 2%; }

        .kpi-container {
            display: flex;
            gap: 12px;
            margin-bottom: 24px;
        }

        .kpi-box {
            flex: 1;
            background: rgba(0, 0, 0, 0.03);
            padding: 16px 12px;
            border-radius: 12px;
            text-align: center;
            border: 1px solid rgba(0, 0, 0, 0.05);
        }

        .kpi-value {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .kpi-label {
            font-size: 0.7rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            line-height: 1.2;
        }

        .text-success { color: var(--success); }
        .text-danger { color: var(--danger); }
        .text-primary { color: #60a5fa; }

        .chart-box {
            background: rgba(0, 0, 0, 0.03);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 20px;
            border: 1px solid rgba(0, 0, 0, 0.05);
        }
        
        .chart-box h4 {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin-bottom: 12px;
            text-align: center;
        }

        /* Gauge */
        .gauge-container {
            text-align: center;
            padding: 20px 0;
        }
        
        .gauge {
            width: 160px;
            height: 80px;
            margin: 0 auto;
            position: relative;
            overflow: hidden;
            background: rgba(0, 0, 0, 0.1);
            border-top-left-radius: 160px;
            border-top-right-radius: 160px;
        }

        .gauge-fill {
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(to right, var(--danger), var(--warning), var(--success));
            transform-origin: center top;
            transform: rotate(0turn);
            transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .gauge-cover {
            width: 130px;
            height: 65px;
            background: white;
            position: absolute;
            bottom: 0;
            left: 15px;
            border-top-left-radius: 130px;
            border-top-right-radius: 130px;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            padding-bottom: 10px;
            font-size: 1.5rem;
            font-weight: 700;
        }

        /* Legend */
        .legend {
            position: absolute;
            bottom: 30px;
            left: 2%;
            padding: 16px;
            font-size: 0.85rem;
            display: flex;
            flex-direction: column;
            gap: 10px;
            z-index: 1000;
            width: 230px;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
            transform-origin: left bottom;
        }
        .legend.hidden {
            transform: translateX(-120%);
            opacity: 0;
            pointer-events: none;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .legend-color {
            width: 18px;
            height: 18px;
            border-radius: 50%;
            border: 2px solid rgba(0,0,0,0.1);
        }

        .hub-legend-icon {
            width: 22px; height: 22px;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 11px; color: white; border: 1px solid rgba(255,255,255,0.8);
            box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        }

        /* Custom Map Icons & Popups */
        .leaflet-popup-content-wrapper {
            background: var(--panel-bg);
            backdrop-filter: blur(12px);
            color: var(--text-main);
            border: 1px solid var(--panel-border);
            border-radius: 12px;
        }
        .leaflet-popup-tip {
            background: var(--panel-bg);
        }
        .leaflet-popup-content h3 {
            margin: 0 0 8px 0;
            font-size: 1.1rem;
            border-bottom: 1px solid rgba(0,0,0,0.1);
            padding-bottom: 8px;
        }
        .leaflet-popup-content p {
            margin: 0 0 8px 0;
            font-size: 0.9rem;
            color: var(--text-muted);
        }
        .popup-slider-container {
            margin-top: 12px;
            background: rgba(0,0,0,0.05);
            padding: 10px;
            border-radius: 8px;
        }
        .popup-slider-container label {
            display: block;
            font-size: 0.8rem;
            margin-bottom: 6px;
            color: var(--text-muted);
        }
        .popup-slider-container input[type=range] {
            width: 100%;
            accent-color: var(--primary);
        }
        .popup-slider-container input[type=range]:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .citizen-modal {
            display: flex;
            gap: 20px;
        }
        .citizen-photo {
            width: 100px;
            height: 100px;
            background: rgba(0,0,0,0.05);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(0,0,0,0.3);
            font-size: 2rem;
            object-fit: cover;
        }
        .citizen-details {
            flex: 1;
        }

        /* Modal Overlay */
        .modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0, 0, 0, 0.6);
            backdrop-filter: blur(4px);
            z-index: 2000;
            display: none;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .modal-overlay.active {
            display: flex;
            opacity: 1;
        }
        .modal-content {
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: 16px;
            width: 100%;
            max-width: 400px;
            padding: 24px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.5);
            transform: translateY(20px);
            transition: transform 0.3s ease;
            color: var(--text-main);
        }
        .modal-overlay.active .modal-content {
            transform: translateY(0);
        }
        .modal-header {
            display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
        }
        .close-btn {
            background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
        }
        .form-group { margin-bottom: 16px; }
        .form-group label { display: block; font-size: 0.85rem; margin-bottom: 6px; color: var(--text-muted); }
        .form-control {
            width: 100%; padding: 10px 12px; background: rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.1);
            border-radius: 8px; color: var(--text-main); font-size: 0.95rem;
        }
        .form-control:focus { outline: none; border-color: var(--primary); }
        .modal-actions { display: flex; gap: 12px; margin-top: 24px; }
        .modal-actions .btn { flex: 1; }

        .btn-success { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
        .btn-success:hover { background: rgba(16, 185, 129, 0.3); }

        .placement-toast {
            position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
            padding: 12px 24px; border-radius: 30px; font-weight: 500;
            z-index: 1500; display: none; align-items: center; gap: 10px;
        }
        .placement-toast button {
            background: rgba(0,0,0,0.1); border: none; color: var(--text-main); padding: 6px 12px;
            border-radius: 12px; cursor: pointer; font-size: 0.8rem;
        }

        /* Login Specific Styles */
        .map-glow-overlay {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: radial-gradient(circle at center, rgba(255, 255, 255, 0.25) 0%, rgba(248, 250, 252, 0.85) 100%);
            z-index: 2;
            pointer-events: none;
        }

        .login-container {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1000;
            width: 100%;
            max-width: 400px;
            padding: 40px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--panel-border);
            border-radius: 24px;
            box-shadow: var(--shadow), var(--glow);
            display: flex;
            flex-direction: column;
            gap: 24px;
            animation: fadeIn 0.8s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translate(-50%, -40%); }
            to { opacity: 1; transform: translate(-50%, -50%); }
        }

        .btn-login {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, var(--primary), #6366f1);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 1.05rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
            margin-top: 10px;
        }

        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
        }

        .back-link {
            text-align: center;
            margin-top: 10px;
        }

        .back-link a {
            color: var(--text-muted);
            text-decoration: none;
            font-size: 0.9rem;
            transition: color 0.3s;
        }

        .back-link a:hover {
            color: var(--text-main);
        }

        @keyframes slideInRight {
            from { transform: translateX(120%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }
        @keyframes fadeInScale {
            from { transform: scale(0.95); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }

        /* Suppress native password reveal/clear buttons in IE/Edge to prevent double eye icon stacking */
        input::-ms-reveal,
        input::-ms-clear {
            display: none !important;
        }

        @keyframes pulse-border {
            0% {
                box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8), 0 4px 10px rgba(0,0,0,0.4);
            }
            70% {
                box-shadow: 0 0 0 8px rgba(239, 68, 68, 0), 0 4px 10px rgba(0,0,0,0.4);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 4px 10px rgba(0,0,0,0.4);
            }
        }
        .pulse-border {
            animation: pulse-border 1.8s infinite !important;
        }