:root {
    --primary-color: #10b981;
    --primary-light: #34d399;
    --primary-dark: #059669;
    --medical-color: #ef4444;
    --dispensary-color: #10b981;
    --mobile-color: #f59e0b;
    --north-color: #3b82f6;
    --central-color: #8b5cf6;
    --south-color: #f97316;
    --bg-main: #0a0f0d;
    --text-primary: #e8f5e9;
    --text-secondary: #a5d6a7;
    --glass-bg: rgba(10, 30, 20, 0.65);
    --glass-border: rgba(16, 185, 129, 0.2);
    --glass-bg-light: rgba(16, 185, 129, 0.08);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
}

#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

.sidebar {
    position: absolute;
    top: 84px;
    bottom: 20px;
    width: 320px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar-toggle {
    position: relative;
    width: 44px;
    height: 44px;
    z-index: 1100;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: var(--glass-bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.5);
}

.sidebar-toggle.stats-toggle {
    margin-left: 8px;
}

.top-icon-bar .sidebar-toggle {
    margin-left: 8px;
}

.sidebar-toggle:hover {
    background: rgba(16, 185, 129, 0.12);
}

.sidebar-toggle.collapsed {
    border-color: var(--primary-color);
}

.sidebar.collapsed {
    transform: translateX(calc(-100% - 20px));
    opacity: 0.95;
    pointer-events: none;
}

.sidebar.right-sidebar.collapsed {
    transform: translateX(calc(100% + 20px));
}



.right-sidebar {
    left: auto;
    right: 20px;
}

.left-sidebar {
    right: auto;
    left: 20px;
}



/* ── Title Block (top-left) ─────────────────────────────── */
.title-block {
    position: absolute;
    top: 10px;
    left: 20px;
    z-index: 1100;
    padding: 12px 20px 14px;
    border-radius: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    max-width: 320px;
}

.title-main {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
    background: linear-gradient(135deg, #10b981 30%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px;
}

.title-estb {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.75;
}

.title-sub {
    font-size: 11px;
    color: white;
    line-height: 1.4;
    margin: 0;
}

.top-icon-bar {
    position: absolute;
    top: 20px;
    right: 20px;
    left: auto;
    z-index: 1100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.sidebar-region-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.sidebar-region-tabs .region-tab {
    position: relative;
    min-width: 100px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
}

.sidebar-type-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 16px 0 12px 16px;
    padding-left: 4px;
}

.sidebar-type-tabs.hidden {
    display: none;
}

.sidebar-type-tabs .type-tab {
    min-width: 100px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-type-tabs .type-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #062e16;
}

.sidebar-region-tabs .region-tab::after {
    display: none;
}

.sidebar-region-tabs .region-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #062e16;
}

.sidebar-region-tabs .region-tab[data-region="North"] {
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.sidebar-region-tabs .region-tab[data-region="Central"] {
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.25);
}

.sidebar-region-tabs .region-tab[data-region="South"] {
    box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.25);
}

.region-selection-controls,
.region-type-controls {
    display: none;
}

.region-selection-controls,
.region-type-controls {
    display: none;
}

.region-selection-label,
.region-type-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.region-select-group,
.region-toggle-group {
    display: flex;
    gap: 8px;
}

.region-select-btn,
.region-toggle-btn {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.region-select-btn.active,
.region-toggle-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #062e16;
}

.region-select-btn:hover,
.region-toggle-btn:hover {
    background: rgba(16, 185, 129, 0.12);
}

.region-list,
.north-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.region-list,
.north-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.region-list-item,
.north-list-item {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.region-list-item:hover,
.north-list-item:hover {
    background: rgba(16, 185, 129, 0.12);
    transform: translateY(-1px);
}

.region-item-title,
.north-item-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}

.region-item-subtitle,
.north-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.region-list-item.compact {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    gap: 10px;
    border-left-width: 4px;
    border-left-style: solid;
}

.compact-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compact-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    overflow: hidden;
    gap: 8px;
}

.region-item-title.truncate {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0;
    flex: 1;
}

.region-item-subtitle.truncate {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    text-align: right;
    max-width: 45%;
    flex-shrink: 0;
}

.no-results {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 12px;
}

.region-panel {
    display: none;
    padding: 0 0 16px 0;
}

.region-panel.active {
    display: block;
}

.region-panel.north.active {
    border-left: 4px solid var(--north-color);
    background: rgba(59, 130, 246, 0.08);
}

.region-panel.central.active {
    border-left: 4px solid var(--central-color);
    background: rgba(139, 92, 246, 0.08);
}

.region-panel.south.active {
    border-left: 4px solid var(--south-color);
    background: rgba(249, 115, 22, 0.08);
}

.detail-panel {
    display: block;
}

.detail-panel.hidden {
    display: none;
}



.region-panels {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 16px;
}

.region-panels::-webkit-scrollbar {
    width: 6px;
}

.region-panels::-webkit-scrollbar-track {
    background: transparent;
}

.region-panels::-webkit-scrollbar-thumb {
    background-color: rgba(16, 185, 129, 0.3);
    border-radius: 10px;
}

.region-panels::-webkit-scrollbar-thumb:hover {
    background-color: rgba(16, 185, 129, 0.5);
}



.placeholder-content {
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    opacity: 0.7;
}

.placeholder-content p {
    font-size: 14px;
    max-width: 220px;
    line-height: 1.5;
}

.detail-card {
    animation: fadeIn 0.4s ease-out forwards;
}

.facility-image-wrapper {
    width: 100%;
    min-height: 200px;
    overflow: hidden;
    border-radius: 18px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
}

.facility-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.badge-medical {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-dispensary {
    background: rgba(16, 185, 129, 0.1);
    color: #05ef1c;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.detail-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-primary);
    line-height: 1.3;
}

.detail-row {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
}

.detail-icon {
    margin-right: 12px;
    margin-top: 2px;
    color: var(--primary-light);
    flex-shrink: 0;
}

.detail-text {
    flex: 1;
}

.detail-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background-color: #0a0f0d;
}

.leaflet-container {
    background: #0a0f0d;
    font-family: inherit;
}

/* Move Leaflet controls to the top-left of the visible map area next to the left panel */
.leaflet-top.leaflet-left,
.leaflet-left.leaflet-top {
    top: 84px !important;
    left: 360px !important;
    right: auto !important;
    z-index: 1101;
}

/* Hide Leaflet attribution control */
.leaflet-control-attribution {
    display: none !important;
}

.leaflet-popup-content-wrapper {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
}

.leaflet-popup-tip {
    background: rgba(10, 30, 20, 0.85);
}

.leaflet-popup-content {
    margin: 14px 16px;
    line-height: 1.5;
}

.popup-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.popup-type {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Custom Tooltip Styling */
.leaflet-tooltip {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 8px;
    box-shadow: 0 8px 20px -5px rgba(0, 0, 0, 0.7);
    padding: 8px 12px;
    font-family: 'Inter', sans-serif;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
    border-top-color: var(--glass-bg);
    border-bottom-color: var(--glass-bg);
    border-left-color: var(--glass-bg);
    border-right-color: var(--glass-bg);
}

@media (max-width: 768px) {
    .sidebar {
        width: calc(100% - 40px);
        bottom: auto;
        height: 60vh;
        max-height: 350px;
    }
}

.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 24px;
    padding: 10px 16px;
    background: var(--glass-bg-light);
    color: var(--primary-light);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: translateY(-1px);
}

/* Statistics panel scroll container */
#stats-panel {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 24px;
    min-height: 0;
}

#stats-panel::-webkit-scrollbar {
    width: 6px;
}

#stats-panel::-webkit-scrollbar-track {
    background: transparent;
}

#stats-panel::-webkit-scrollbar-thumb {
    background-color: rgba(16, 185, 129, 0.3);
    border-radius: 10px;
}

#stats-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(16, 185, 129, 0.5);
}

/* Statistics classes */
.stat-region {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
}

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

.stat-region h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    gap: 8px;
    flex-wrap: nowrap;
}

.stat-value {
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
    min-width: 20px;
    text-align: right;
}

/* Left label wrapper inside stat-item to hold icon + text */
.stat-item .left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.stat-icon {
    width: 14px;
    height: 14px;
    display: inline-flex;
    color: var(--primary-color);
    flex-shrink: 0;
}

.stat-item .left>span {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Color coding per stat type */
.stat-item[data-filter="medical"] .stat-icon {
    color: var(--medical-color);
}

.stat-item[data-filter="dispensary"] .stat-icon {
    color: var(--dispensary-color);
}

.stat-item[data-filter="mobile"] .stat-icon {
    color: var(--mobile-color);
}

/* Region-specific exact colors */
.stat-region[data-region="North Region"] .stat-icon {
    color: var(--north-color);
}

.stat-region[data-region="Central Region"] .stat-icon {
    color: var(--central-color);
}

.stat-region[data-region="South Region"] .stat-icon {
    color: var(--south-color);
}