<!-- UNCDF Map Style -->

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

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: #f7fafc;
            overflow-x: hidden; /* Add this line */
        }       

        .map-container {
            width: 100%;
            position: relative;
            xleft: 50%;
            xright: 50%;
            xmargin-left: -50vw;
            xmargin-right: -50vw;
            background: white;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            max-width: 100%;
        }

    /* Ensure Leaflet map itself is properly positioned */
        .leaflet-container {
            width: 100%;
            height: 100%;
        }

        .map-header {
            background: linear-gradient(135deg, #0a2463 0%, #3e92cc 100%);
            padding: 24px 16px;
            color: white;
        }

        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 20px;
        }

        .header-text {
            flex: 1;
        }

        .map-header h2,
        .header-text h2 {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 8px;
        }

        .map-header p,
        .header-text p {
            font-size: 16px;
            opacity: 0.9;
            margin: 0;
        }

        .header-buttons {
            display: flex;
            gap: 12px;
            align-items: right;
        }

        .header-btn {
            padding: 10px 20px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            background: rgba(255, 255, 255, 0.1);
            color: white;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            text-decoration: none;
        }

        .header-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.5);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .header-btn.active {
            background: white;
            color: #0a2463;
            border-color: white;
        }

        .header-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .header-btn i {
            font-size: 14px;
        }

        /* Refresh button specific styling */
        #refreshData {
            position: relative;
        }

        #refreshData.refreshing i {
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        .map-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            padding: 24px 16px;
            background: #f7fafc;
            border-bottom: 1px solid #e2e8f0;
        }

        .stat-item {
            text-align: center;
        }

        .stat-value {
            font-size: 32px;
            font-weight: 700;
            color: #0a2463;
            margin-bottom: 4px;
        }

        .stat-label {
            font-size: 14px;
            color: #718096;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 600;
        }

         #map {
            width: 100%;
            height: 800px;
            margin: 0;
            padding: 0;
        }

        .map-controls {
            padding: 16px 16px;
            background: white;
            border-top: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 16px;
            position: relative;
            z-index: 1000;
            max-width: 100%;
            box-sizing: border-box;
        }

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

        .legend-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            color: #4a5568;
        }

        .legend-color {
            width: 24px;
            height: 24px;
            border-radius: 4px;
            border: 2px solid #e2e8f0;
        }

        .view-toggle {
            display: flex;
            gap: 8px;
        }

        .toggle-btn {
            padding: 8px 16px;
            border: 1px solid #e2e8f0;
            background: white;
            color: #4a5568;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .toggle-btn:hover {
            background: #f7fafc;
            border-color: #cbd5e0;
        }

        .toggle-btn.active {
            background: #0a2463;
            color: white;
            border-color: #0a2463;
        }

        /* Leaflet Popup Styling */
        .leaflet-popup-content-wrapper {
            border-radius: 8px;
            padding: 0;
        }

        .leaflet-popup-content {
            margin: 0;
            min-width: 200px;
        }

        .popup-header {
            background: #0a2463;
            color: white;
            padding: 12px 16px;
            font-weight: 600;
            font-size: 16px;
        }

        .popup-body {
            padding: 16px;
        }

        .popup-stat {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid #e2e8f0;
        }

        .popup-stat:last-child {
            border-bottom: none;
        }

        .popup-label {
            color: #718096;
            font-size: 14px;
        }

        .popup-value {
            color: #1a202c;
            font-weight: 600;
            font-size: 14px;
        }

        .popup-link {
            display: block;
            text-align: center;
            padding: 12px;
            background: #f7fafc;
            color: #0a2463;
            text-decoration: none;
            font-weight: 600;
            font-size: 14px;
            transition: all 0.2s ease;
        }

        .popup-link:hover {
            background: #e2e8f0;
        }

        /* Hide refresh button from legend */
        .leaflet-control.info.legend #map-refresh-btn,
        .leaflet-control.info.legend .header-btn,
        .info.legend #map-refresh-btn,
        .info.legend button {
            display: none !important;
        }

        @media (max-width: 768px) {
            .map-header {
                padding: 20px 10px;
            }

            .header-content {
                flex-direction: column;
                align-items: flex-start;
                gap: 16px;
            }
            
            .header-buttons {
                width: 100%;
                justify-content: flex-end;
            }
            
            .header-btn {
                padding: 8px 16px;
                font-size: 13px;
            }
            
            .header-text h2,
            .map-header h2 {
                font-size: 20px;
            }
            
            .header-text p {
                font-size: 14px;
            }

            .map-stats {
                padding: 20px 10px;
                grid-template-columns: repeat(2, 1fr);
            }

            .stat-value {
                font-size: 24px;
            }

            #map {
                height: 400px;
            }

            .map-controls {
                padding: 16px 10px;
            }

            .legend {
                width: 100%;
                justify-content: center;
            }


.map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.map-loading-spinner {
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.map-loading-text {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.map-loading-subtext {
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
}

            /* Hide the map legend on mobile */
            .leaflet-control.info.legend {
                display: none !important;
            }
        }