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

body {
    display: flex;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f1a;
    color: #ccc;
}

/* Sidebar */
#sidebar {
    width: 300px;
    height: 100vh;
    overflow-y: auto;
    background: #14141f;
    border-right: 1px solid #2a2a3d;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

#sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #2a2a3d;
}

#sidebar-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

.subtitle {
    font-size: 0.78rem;
    color: #667;
    margin-top: 2px;
}

.section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #556;
    margin-bottom: 8px;
}

/* Discipline selector */
#discipline-controls {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a3d;
}

#discipline-select, #metric-select, #provider-category {
    width: 100%;
    padding: 8px 10px;
    background: #1a1a2a;
    color: #ddd;
    border: 1px solid #333348;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23667'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

#discipline-select:focus, #metric-select:focus, #provider-category:focus {
    outline: none;
    border-color: #6ab4ff;
}

/* HPSA toggles */
#hpsa-toggles {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a3d;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #bbc;
    padding: 5px 0;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    accent-color: #6ab4ff;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.toggle-hint {
    font-size: 0.7rem;
    color: #556;
}

.toggle-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.swatch-geographic {
    background: transparent;
    border: 3px solid #f97316;
}

.swatch-population {
    background: rgba(251, 191, 36, 0.3);
    border: 1px solid rgba(251, 191, 36, 0.5);
}

.swatch-facility {
    background: #f97316;
    border-radius: 50%;
}

/* Overlay controls */
#overlay-controls {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a3d;
}

#provider-filter {
    margin-top: 6px;
    padding-left: 22px;
}

#provider-filter.hidden {
    display: none;
}

/* View controls / data layers */
#view-controls {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a3d;
}

#view-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.view-btn {
    background: #1a1a2a;
    border: 1px solid #333348;
    color: #889;
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.view-btn:hover {
    background: #1e1e30;
    color: #bbc;
}

.view-btn.active {
    background: #1e2a3a;
    color: #6ab4ff;
    border-color: #6ab4ff;
}

#metric-controls {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
}

#metric-controls.hidden {
    display: none;
}

#metric-controls #metric-select {
    flex: 1;
}

.clear-btn {
    background: #2a1a1a;
    border: 1px solid #442;
    color: #c88;
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 5px;
    cursor: pointer;
}

.clear-btn:hover {
    background: #3a2020;
}

/* Legend */
#legend {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a3d;
}

.legend-row {
    margin-bottom: 6px;
}

.legend-label {
    font-size: 0.72rem;
    color: #889;
    display: block;
    margin-bottom: 4px;
}

.legend-scale {
    display: flex;
    gap: 3px;
}

.legend-chip {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #000;
}

/* Detail panel */
#detail-panel {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
}

#detail-content .placeholder {
    font-size: 0.8rem;
    color: #445;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

.detail-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.detail-type {
    font-size: 0.72rem;
    color: #889;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a3d;
}

.detail-section {
    margin-bottom: 14px;
}

.detail-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6ab4ff;
    margin-bottom: 6px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.78rem;
    border-bottom: 1px solid #1a1a2a;
}

.detail-row .label {
    color: #889;
}

.detail-row .value {
    color: #ddd;
    font-weight: 500;
}

.detail-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-critical { background: #3d1117; color: #f87171; }
.badge-high { background: #3d2517; color: #fb923c; }
.badge-moderate { background: #3d3517; color: #fbbf24; }
.badge-low { background: #17332a; color: #4ade80; }

.trend-up { color: #f87171; }
.trend-down { color: #4ade80; }
.trend-same { color: #889; }

/* Map */
#map {
    flex: 1;
    height: 100vh;
}

/* Score labels on map */
.score-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    color: #fff;
    text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7), 0 0 2px rgba(0,0,0,1);
}

/* Leaflet popups */
.leaflet-popup-content-wrapper {
    background: #1a1a2a;
    color: #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
    background: #1a1a2a;
}

.leaflet-popup-content {
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 12px 14px;
}

/* Cluster styling */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(106, 180, 255, 0.25);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background-color: rgba(106, 180, 255, 0.6);
    color: #fff;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
