html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#map {
  position: absolute;
  inset: 0;
}

#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 10px;
  padding: 14px 16px;
  width: 280px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  color: #1a1a1a;
}

#panel h1 {
  font-size: 15px;
  margin: 0 0 2px;
}

#panel .subtitle {
  margin: 0 0 12px;
  font-size: 11.5px;
  color: #666;
}

#panel .subtitle.section {
  margin: 12px 0 4px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-weight: 600;
  color: #444;
}

#mode-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.mode-btn {
  flex: 1;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 6px;
  padding: 7px 4px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
}

.mode-btn.active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
  font-weight: 600;
}

#powerflow-legend {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
}

#powerflow-legend.hidden {
  display: none;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #444;
  padding: 1px 0;
}

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

#municipality-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

#municipality-controls .mode-btn {
  flex: 0 0 auto;
  padding: 3px 10px;
  font-size: 11px;
}

#municipality-controls .count {
  margin-left: auto;
}

#municipality-list {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 8px;
}

.municipality-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  cursor: pointer;
}

.municipality-row input {
  margin: 0;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-top: 1px solid #eee;
}

.layer-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.layer-row input {
  margin: 0;
}

.count {
  color: #888;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Line layers: solid vs. dashed already differentiate lines/gas visually;
   lv-ok/lv-bad reuse the same green/red convention as the map itself. */
.swatch-line { background: #ea580c; height: 3px; border-radius: 2px; }
.swatch-gas {
  height: 0; width: 12px; border-top: 2px dashed #ca8a04;
  background: none; border-radius: 0;
}
.swatch-lv { background: #6b7280; height: 3px; border-radius: 2px; width: 12px; }
.swatch-mv {
  height: 0; width: 12px; border-top: 3px dashed #4b5563;
  background: none; border-radius: 0;
}

/* Point layers: each gets its own shape (matching the map's generated
   icons) plus a distinct color, so shape and color both help tell layers
   apart instead of relying on color alone. */
.swatch-substation { background: #2563eb; border-radius: 3px; }
.swatch-transformer {
  background: #dc2626; border-radius: 2px; width: 10px; height: 10px;
  transform: rotate(45deg);
}
.swatch-tower {
  background: none; width: 10px; height: 10px; position: relative;
}
.swatch-tower::before, .swatch-tower::after {
  content: ""; position: absolute; background: #78716c;
}
.swatch-tower::before { left: 3px; top: 0; width: 4px; height: 10px; }
.swatch-tower::after { top: 3px; left: 0; width: 10px; height: 4px; }
.swatch-plant {
  background: none; width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 10px solid #059669; border-radius: 0;
}
.swatch-datacenter {
  background: #4f46e5; width: 12px; height: 10px;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  border-radius: 0;
}
.swatch-candidate { background: none; border: 2px solid #0d9488; width: 8px; height: 8px; border-radius: 2px; }
.swatch-building { background: #64748b; width: 8px; height: 8px; border-radius: 50%; opacity: 0.7; }

/* power_plants and lv_transformers stay circles (their own per-feature
   color coding is the point), but a black vs. white stroke keeps the two
   circle-based layers visually distinct from each other and from anything
   else on the map. */
.swatch-power-plant { background: #7c3aed; border: 2px solid #1c1917; }
.swatch-real { background: #2563eb; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #ccc; }
.swatch-synthetic { background: #f59e0b; margin-left: -4px; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #ccc; }

/* Heatmap layers: a gradient swatch reads as "density surface" rather
   than implying a marker shape that doesn't exist on the map. */
.swatch-population {
  background: linear-gradient(135deg, #fef3c7, #f97316, #b91c1c);
  border-radius: 50%;
}
.swatch-wind {
  background: linear-gradient(135deg, #e0f2fe, #38bdf8, #075985);
  border-radius: 50%;
}

.hint {
  margin: 12px 0 0;
  font-size: 10.5px;
  color: #999;
  border-top: 1px solid #eee;
  padding-top: 8px;
}

#tooltip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  max-width: 240px;
  line-height: 1.4;
}

#tooltip.hidden {
  display: none;
}

.review-open-btn {
  width: 100%;
  margin-top: 14px;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: #f5a623;
  color: #1a1a1a;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.review-open-btn:hover {
  background: #e6981a;
}

#relocate-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: #1a1a1a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#relocate-banner.hidden {
  display: none;
}

#relocate-banner button {
  margin-left: 10px;
  border: none;
  background: #444;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11.5px;
}

#review-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  width: 320px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#review-panel.hidden {
  display: none;
}

.review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #eee;
}

.review-header h2 {
  font-size: 14px;
  margin: 0 0 2px;
}

.review-header .subtitle {
  margin: 0;
  font-size: 11.5px;
  color: #666;
}

.review-header button {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 0 2px;
}

.field-guide {
  margin: 10px 14px;
  padding: 8px 10px;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: #444;
}

.confidence-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
}

.confidence-badge.high { background: #ccfbf1; color: #0d9488; }
.confidence-badge.medium { background: #fef3c7; color: #a3690a; }
.confidence-badge.none { background: #eee; color: #999; }

.review-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
}

.review-actions button {
  flex: 1;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 6px;
  padding: 6px 4px;
  font-size: 11.5px;
  cursor: pointer;
}

.review-actions button:hover {
  background: #f0f0f0;
}

#review-list {
  overflow-y: auto;
  flex: 1;
}

.review-row {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}

.review-row.active {
  background: #fff8e8;
}

.review-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.review-row-title {
  font-weight: 600;
}

.review-row-sub {
  color: #888;
  font-size: 11px;
}

.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-badge.unreviewed { background: #fdf0d5; color: #a3690a; }
.status-badge.confirmed { background: #dcfce7; color: #15803d; }
.status-badge.not_found { background: #eee; color: #666; }
.status-badge.relocated { background: #fce7f3; color: #db2777; }

.review-row-links {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

.review-row-links a {
  font-size: 11px;
  color: #2b8ce6;
  text-decoration: none;
}

.review-row-links a:hover {
  text-decoration: underline;
}

.review-row-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.status-btn {
  flex: 1;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 5px;
  padding: 4px 2px;
  font-size: 10.5px;
  cursor: pointer;
}

.status-btn:hover { background: #f5f5f5; }
.status-btn[data-status="confirmed"]:hover { border-color: #15803d; color: #15803d; }
.status-btn[data-status="not_found"]:hover { border-color: #666; }
.status-btn[data-status="relocated"]:hover { border-color: #db2777; color: #db2777; }

.maplibregl-popup-content .status-btn {
  flex: 1;
}

.popup-row-links {
  display: flex;
  gap: 10px;
  margin: 6px 0;
}

.popup-row-links a {
  font-size: 12px;
  color: #2b8ce6;
}

.popup-status-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
