html, body { margin:0; padding:0; height:100%; font-family: 'Helvetica Neue', Arial, sans-serif; }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 70px;
  left: 340px;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 500;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e0e0e0;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  margin-top: 15px;
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

/* Site Header */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
  padding: 12px 24px;
}

.site-branding {
  flex: 1;
}

.site-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.5px;
}

.site-tagline {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: #bdc3c7;
  font-weight: 400;
}

.site-nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  font-weight: 600;
}

/* Map and Sidebar adjusted for header */
#map { position:absolute; top:70px; bottom:0; width:100%; }
#sidebar {
  position:absolute;
  top:80px;
  left:10px;
  background:#fff;
  padding:12px 14px;
  z-index:1;
  border-radius:6px;
  box-shadow:0 1px 6px rgba(0,0,0,0.15);
  width:300px;
  max-height:calc(100vh - 90px);
  overflow-y:auto;
}
#sidebar h2 { margin:0 0 4px 0; font-size:18px; }
#sidebar h3 { margin:14px 0 6px 0; font-size:14px; font-weight:600; }
.intro { margin:0 0 10px 0; font-size:13px; color:#555; line-height:1.4; }

.state-selector {
  margin:12px 0;
  padding:8px;
  background:#f8f8f8;
  border-radius:4px;
  border:1px solid #ddd;
}

.state-selector label {
  display:block;
  font-size:12px;
  font-weight:600;
  margin-bottom:4px;
  color:#333;
}

.state-selector select {
  width:100%;
  padding:6px 8px;
  font-size:13px;
  border:1px solid #ccc;
  border-radius:3px;
  background:white;
  cursor:pointer;
}

.state-selector select:hover {
  border-color:#999;
}

.state-selector select:focus {
  outline:none;
  border-color:#0066cc;
}

/* Normalization Toggle */
.normalization-toggle {
  margin: 12px 0;
  padding: 10px;
  background: linear-gradient(145deg, #f0f7ff 0%, #e8f4ff 100%);
  border-radius: 6px;
  border: 1px solid #b8d4f0;
}

.normalization-toggle label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #2c3e50;
}

.toggle-buttons {
  display: flex;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #3498db;
}

.norm-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: white;
  color: #3498db;
  cursor: pointer;
  transition: all 0.2s ease;
}

.norm-btn:first-child {
  border-right: 1px solid #3498db;
}

.norm-btn:hover:not(.active) {
  background: #e8f4ff;
}

.norm-btn.active {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
}

.norm-description {
  font-size: 11px;
  color: #666;
  margin: 6px 0 0 0;
  font-style: italic;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.toggle { font-size:14px; flex: 1; }

.layer-controls {
  display: flex;
  gap: 2px;
}

.layer-up, .layer-down {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  color: #333;
}

.layer-up:hover, .layer-down:hover {
  background: #e0e0e0;
}

.layer-up:active, .layer-down:active {
  background: #d0d0d0;
}

.hover-toggle-btn {
  width: 100%;
  margin: 10px 0;
  padding: 8px 10px;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #0a3d62;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.hover-toggle-btn:hover {
  background: #e9f2fb;
  border-color: #adc5e6;
}

.hover-toggle-btn:active {
  transform: translateY(1px);
}

.hover-toggle-btn.active {
  background: #dceefd;
  border-color: #7aa9dd;
  color: #063559;
}

#legend {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 14px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 1px 4px rgba(0,0,0,0.1);
  min-width: 500px;
  max-width: 900px;
  z-index: 999;
  border: 1px solid rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  gap: 12px;
}

/* Horizontal Legend Bars */
.legend-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.legend-bar:not(:last-child) {
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 12px;
}

.legend-title {
  font-size: 12px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.legend-color-bar {
  display: flex;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #ccc;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.legend-segment {
  flex: 1;
  min-width: 0;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #666;
  margin-top: 2px;
}
#legend h3 { margin:0 0 6px 0; font-size:14px; font-weight:600; color:#2c3e50; }
.legend-desc { margin:0 0 10px 0; font-size:11px; color:#666; line-height:1.4; }
.legend-row { display:flex; align-items:center; margin-bottom:5px; font-size:12px; }
.swatch { width:14px; height:14px; margin-right:8px; display:inline-block; border:1px solid #ccc; flex-shrink:0; }
.methods { margin-top:14px; padding-top:10px; border-top:1px solid #e0e0e0; }
.methods h4 { margin:10px 0 4px 0; font-size:13px; font-weight:600; }
.methods p { margin:0 0 8px 0; font-size:12px; color:#555; line-height:1.4; }

/* Hospital Control Panel - Modern Design */
.hospital-panel {
  position: absolute;
  top: 80px;
  right: 10px;
  background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  width: 280px;
  z-index: 1000;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0,0,0,0.08);
}

.hospital-panel.collapsed .panel-content {
  max-height: 0;
  padding: 0 18px;
  overflow: hidden;
  opacity: 0;
}

.panel-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-icon {
  font-size: 20px;
  line-height: 1;
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.collapse-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

.collapse-btn svg {
  transition: transform 0.3s ease;
}

.hospital-panel.collapsed .collapse-btn svg {
  transform: rotate(-180deg);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255,255,255,0.25);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.35);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: rgba(46, 204, 113, 1);
  border-color: rgba(39, 174, 96, 1);
}

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

.panel-content {
  padding: 18px;
  max-height: 800px;
  opacity: 1;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-group {
  margin-bottom: 18px;
}

.control-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-group select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: #374151;
}

.control-group select:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.control-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: white;
}

.legend-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 2px solid #e5e7eb;
}

.legend-section label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#hospital-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#hospital-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

#hospital-legend .swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#hospital-legend .legend-ball {
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  flex-shrink: 0;
}

#hospital-legend .legend-note {
  font-size: 12px;
  color: #6b7280;
}

.hospital-row {
  gap: 12px;
}

.control-group input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e74c3c;
  cursor: pointer;
  transition: background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  background: #c0392b;
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e74c3c;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
  background: #c0392b;
}

#size-value {
  font-weight: 700;
  color: #e74c3c;
}

#size-plot {
  width: 100%;
  height: 110px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: crosshair;
  background: linear-gradient(145deg, #f9fafb 0%, #ffffff 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

/* Hospital Popup Constraints */
.hospital-popup .maplibregl-popup-content {
  width: 420px;
  max-width: 420px;
  height: 480px;
  max-height: 480px;
  overflow-y: auto;
  padding: 18px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.hospital-popup .maplibregl-popup-tip {
  border-top-color: white;
  border-bottom-color: white;
}

/* Scrollbar styling for hospital popup */
.hospital-popup .maplibregl-popup-content::-webkit-scrollbar {
  width: 8px;
}

.hospital-popup .maplibregl-popup-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.hospital-popup .maplibregl-popup-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.hospital-popup .maplibregl-popup-content::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}
