* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

#map { height: 100vh; width: 100%; }

#controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 260px;
}

#controlsHeader {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#collapseBtn {
  padding: 0 12px;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  background: #f0f0f0;
  color: #666;
  border-radius: 6px;
}
#collapseBtn:hover:not(:disabled) {
  background: #e0e0e0;
  transform: none;
}

#controlsBody {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
#controlsBody.collapsed { display: none; }

#status {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  padding: 12px 14px;
  background: #f8f9fa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#status.loading {
  background: #fff3cd;
  color: #856404;
  animation: pulse 1.5s ease-in-out infinite;
}
#status.error { background: #f8d7da; color: #721c24; }
#status.success { background: #d4edda; color: #155724; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.status-totals {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  margin-left: auto;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #ccc;
  border-top-color: #007bff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
#status.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #007bff;
  cursor: pointer;
}

.slider-row { display: flex; flex-direction: column; gap: 6px; }
.slider-header { display: flex; justify-content: space-between; font-size: 13px; color: #666; }
.slider-value { font-weight: 600; color: #007bff; }

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: linear-gradient(to right, #e0e0e0, #007bff);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #007bff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.radio-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
}
.radio-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
}
.radio-row input[type="radio"] {
  width: 14px;
  height: 14px;
}

.btn-row { display: flex; gap: 8px; }
.btn-row button { flex: 1; }

button {
  padding: 12px 20px;
  cursor: pointer;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}
button:hover:not(:disabled) { background: #0056b3; transform: translateY(-1px); }
button:disabled { background: #ccc; cursor: not-allowed; }

#catHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  padding: 8px 0;
}
#catHeader:hover { color: #007bff; }

#categories {
  display: none;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px;
}
#categories.visible { display: flex; }
#categories label { font-size: 13px; font-weight: 400; padding: 2px 0; }

.cat-count { color: #888; font-size: 11px; margin-left: 4px; }
.cat-buttons { display: flex; gap: 8px; margin-bottom: 8px; }
.cat-buttons button { padding: 4px 10px; font-size: 11px; }

#legend {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.green { background: #27ae60; }
.dot.red { background: #e74c3c; }
.dot.blue { background: #3388ff; }
