html, body { height: 100%; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
/* Map backdrop = textured "ocean". Solid dark navy + a tiled SVG turbulence
   filter for subtle wave-like character. The 512×512 tile (with the SVG
   filter's stitchTiles='stitch' attribute) gives wraparound noise that
   tiles seamlessly: the right edge mathematically matches the left, and
   the bottom matches the top, so no visible square seams appear. */
#map {
  position: absolute; inset: 0;
  background-color: #1a2332;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512'><filter id='o' x='0%25' y='0%25' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='3' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.42  0 0 0 0 0.85  0 0 0 0.13 0'/></filter><rect width='100%25' height='100%25' filter='url(%23o)'/></svg>");
  background-repeat: repeat;
  background-size: 512px 512px;
}

/* Title bar */
.title-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000; background: rgba(20, 30, 48, 0.92); color: #fff;
  padding: 8px 18px; border-radius: 4px; font-weight: 600; font-size: 14px;
  letter-spacing: 0.5px; border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.title-bar .sub { font-weight: 400; font-size: 11px; opacity: 0.75; margin-left: 8px; }

/* Bottom-left stack: holds the legend (on top) and the range-rings widget
   (below). Anchored to the map's bottom-left corner; height is content-
   driven, so the range tool's expanding "Clear" button + hint row push the
   legend upward instead of overlapping it. */
.bottom-left-stack {
  position: absolute; bottom: 10px; left: 10px; z-index: 1000;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  /* Reserve enough horizontal room for the legend's max-width but stop well
     short of the centered coords readout. */
  max-width: calc(50% - 200px);
}

/* Legend — sits inside .bottom-left-stack as a flex item (no longer
   absolutely positioned). The `hidden` attribute is removed by buildLegend()
   once the country features have loaded. */
.legend {
  background: rgba(255,255,255,0.96); padding: 10px 12px;
  border-radius: 4px; line-height: 1.5; font-size: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2); max-width: 220px;
}
.legend h4 { margin: 0 0 6px 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #555; }
.legend .swatch {
  display: inline-block; width: 14px; height: 14px; margin-right: 6px;
  vertical-align: middle; border: 1px solid rgba(0,0,0,0.3);
}
.legend .row { white-space: nowrap; }
.legend .group { font-size: 10px; color: #888; text-transform: uppercase; margin-top: 4px; }

/* Coordinate readout */
.coords {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255,255,255,0.92); padding: 4px 10px;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 11px;
  border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  pointer-events: none; line-height: 1.3; text-align: center;
}
.coords #coords-mgrs {
  color: #555; font-size: 10px; letter-spacing: 0.3px;
  min-height: 12px;  /* reserve space so the box doesn't jump on first move */
}

/* Popup — zero-size overlay root; tip vertex sits on the map coordinate */
.ol-popup-root {
  --popup-tip: #ffee00;
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ol-popup-bubble {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.28));
}
/* Tip-left: bubble extends east; tip vertex on the anchor point */
.ol-popup-bubble.ol-popup--tip-left {
  left: 0;
}
/* Tip-right: bubble extends west; tip vertex on the anchor point */
.ol-popup-bubble.ol-popup--tip-right {
  right: 0;
  flex-direction: row-reverse;
}
.ol-popup-inner {
  position: relative;
  background: var(--popup-tint, #fff);
  border: 3.5px solid var(--popup-border, #bbb);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 320px;
  pointer-events: auto;
}
.ol-popup-tip {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}
.ol-popup--tip-left .ol-popup-tip {
  border-right: 12px solid var(--popup-tip);
  margin-right: -1px;
}
.ol-popup--tip-right .ol-popup-tip {
  border-left: 12px solid var(--popup-tip);
  margin-left: -1px;
}
.ol-popup-inner h3 {
  margin: 0 0 6px 0; font-size: 14px;
  border-bottom: 1px solid var(--popup-divider, #eee);
  padding-bottom: 4px;
}
.ol-popup-inner .kv { display: grid; grid-template-columns: 80px 1fr; gap: 2px 8px; line-height: 1.6; }
.ol-popup-inner .k { color: #888; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
.ol-popup-inner .v { color: #222; }
.ol-popup-inner .v-coords {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.2px;
}
.ol-popup-inner .badge {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  background: #e8f1ff; color: #1f4e8c;
}
.ol-popup-close {
  position: absolute; top: 4px; right: 8px;
  cursor: pointer; color: #888; font-size: 16px; font-weight: bold;
  line-height: 1;
}
.ol-popup-close:hover { color: #333; }

/* Reset-view control button — sits below the default zoom buttons */
.ol-reset-view { top: 80px; left: 8px; }
.ol-reset-view button {
  font-size: 18px; font-weight: bold;
}

/* Tweak default OL controls so they don't fight the dark map */
.ol-zoom { top: 8px; left: 8px; }
.ol-attribution { background: rgba(255,255,255,0.85); }

/* Layers control — icon button (top-right) that toggles the panel below */
.layers-control {
  position: absolute; top: 12px; right: 12px; z-index: 1000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.layers-toggle {
  width: 32px; height: 32px; padding: 0;
  background: rgba(255,255,255,0.96); color: #333;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 0.12s, color 0.12s;
}
.layers-toggle:hover { background: #f4f4f4; }
.layers-control.open .layers-toggle {
  background: #1f4e8c; color: #fff; border-color: #1f4e8c;
}

/* Sibling top-right dropdowns. All three anchor to the top-right; each is
   offset inward by (button width 32px + inter-control gap 8px) per slot. */
.layers-control--wx   { right: 52px; }
.layers-control--poi  { right: 92px; }
.layers-control--info { right: 132px; }

/* Data-sources panel: text-heavy, slightly wider, allows wrapping. */
.info-panel {
  min-width: 280px;
  max-width: 340px;
  max-height: 70vh;
  overflow-y: auto;
}
.info-panel .info-group {
  font-size: 10px; color: #888; text-transform: uppercase;
  letter-spacing: 0.5px; margin: 10px 0 4px;
}
.info-panel .info-group:first-of-type { margin-top: 4px; }
.info-panel .info-row {
  font-size: 11px; line-height: 1.4; margin: 3px 0;
  color: #222;
}
.info-panel .info-row a { color: #1f4e8c; text-decoration: none; }
.info-panel .info-row a:hover { text-decoration: underline; }
.info-panel .info-row code,
.info-panel .info-footer code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px; background: #f0f3f8; padding: 0 3px; border-radius: 2px;
}
.info-panel .info-footer {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid #eee;
  font-size: 10px; color: #777; line-height: 1.4;
}
/* Annotation row under a data-source line — slightly indented and de-emphasized,
   used to explain derived columns (e.g. the hospital tier scheme). */
.info-panel .info-row--note {
  margin-left: 10px; font-size: 10px; color: #555; line-height: 1.45;
}

/* POI checkbox-row trimmings: a colored swatch + a soft count chip */
.poi-swatch {
  display: inline-block; width: 16px; height: 16px;
  margin: 0 4px 0 2px; vertical-align: middle;
  border-radius: 50%; text-align: center; line-height: 16px;
  font-weight: 700; font-size: 9px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  border: 1px solid rgba(0,0,0,0.2);
}
/* Major POI — matches map.js emphasis ring (r=11) + disc (r=7) proportions. */
.poi-swatch--map .poi-swatch-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--poi-ring, rgba(0,0,0,0.35));
  background: transparent;
  box-sizing: border-box;
  pointer-events: none;
}
.poi-swatch--map .poi-swatch-disc {
  /* 7/11 of the 16px canvas ≈ inner disc diameter on the map marker */
  position: absolute;
  width: 63.64%;
  height: 63.64%;
  top: 18.18%;
  left: 18.18%;
  border-radius: 50%;
  background: var(--poi-fill, #888);
  border: 1.2px solid var(--poi-stroke, rgba(0,0,0,0.35));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.poi-swatch--map .poi-swatch-glyph {
  position: static;
  font-size: 7px;
  line-height: 1;
  text-shadow: none;
}
.poi-count {
  color: #888; font-size: 10px; margin-left: 4px;
}
/* Multi-tier swatch — color strip with one map glyph centered on top. */
.poi-swatch-stack {
  position: relative;
  display: inline-block;
  width: 16px; height: 16px;
  vertical-align: middle;
  margin: 0 4px 0 2px;
  flex-shrink: 0;
}
.poi-swatch-strip {
  padding: 0; overflow: hidden;
  display: inline-flex; align-items: stretch;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  vertical-align: middle;
  margin: 0 4px 0 2px;
}
.poi-swatch-stack .poi-swatch-strip--bg {
  position: absolute;
  inset: 0;
  margin: 0;
}
.poi-swatch-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 9px;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  z-index: 1;
  text-shadow: 0 0 2px rgba(0,0,0,0.45);
}
.poi-swatch-seg {
  flex: 1;
  min-width: 0;
}

/* Compact tier legend under the hospital toggle: three small dots + labels,
   single line, indented under the checkbox column. */
.poi-tier-key {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 0 0 4px 26px;   /* aligns under the row's text, past checkbox+swatch */
  font-size: 10px; color: #555;
  line-height: 1.5;
}
.poi-tier-key--note {
  display: block; max-width: 240px; line-height: 1.35; color: #666;
}
.poi-tier-key > span { display: inline-flex; align-items: center; gap: 4px; }
.poi-tier-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.25);
  vertical-align: middle;
}
.poi-source {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee;
  font-size: 9px; color: #888; line-height: 1.35;
  text-transform: uppercase; letter-spacing: 0.3px;
}

/* Weather/layers panel — hidden by default, revealed under the button */
.weather-panel {
  background: rgba(255,255,255,0.96); padding: 10px 12px;
  border-radius: 4px; font-size: 12px; min-width: 220px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.weather-panel[hidden] { display: none; }
.weather-panel h4 {
  margin: 0 0 6px 0; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px; color: #555;
}
.weather-toggle { display: block; margin: 3px 0; cursor: pointer; user-select: none; }
.weather-toggle input { margin-right: 6px; vertical-align: middle; }

/* Inline slider used under the country-tint toggle */
.tint-slider { display: block; width: 100%; margin: 2px 0 4px; }
.tint-slider:disabled { opacity: 0.4; cursor: not-allowed; }

/* Section divider inside the panel */
.weather-panel hr {
  border: none; border-top: 1px solid #eee;
  margin: 10px -12px 8px;  /* negative margin so it spans full panel width */
}
.reset-map-btn {
  display: block; width: 100%; margin-top: 4px;
  font-size: 11px; padding: 6px 10px;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 4px;
  background: #fff; cursor: pointer; color: #444;
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
.reset-map-btn:hover { background: #f4f4f4; }
.weather-panel h4 + .weather-toggle { margin-top: 0; }

.wx-panel { min-width: 240px; max-width: 280px; }
.wx-note {
  margin: 0 0 8px; font-size: 10px; color: #666; line-height: 1.35;
}
.wx-section {
  border: none; margin: 0 0 8px; padding: 0;
}
.wx-section legend {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #555; margin-bottom: 4px;
}
.wx-section .weather-toggle { margin-left: 2px; }

.anim-controls {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee;
}
.anim-row { display: flex; align-items: center; gap: 6px; }
.anim-btn {
  width: 24px; height: 24px; border: 1px solid #ccc; border-radius: 3px;
  background: #fff; cursor: pointer; font-size: 11px; padding: 0;
  line-height: 1;
}
.anim-btn:hover { background: #f4f4f4; }
#wx-slider { flex: 1; min-width: 100px; margin: 0; }
.anim-time {
  font-family: ui-monospace, "SF Mono", monospace; font-size: 10px;
  color: #444; margin-top: 4px; text-align: center;
}
.anim-source {
  font-size: 9px; color: #888; margin-top: 6px;
  text-transform: uppercase; letter-spacing: 0.5px; text-align: center;
}
.anim-loading {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #ff9933; margin-left: 4px; opacity: 0;
  transition: opacity 0.15s;
}
.anim-loading.on { opacity: 1; }

/* Range-rings tool — bottom-left widget. Sits where the OL ScaleLine used
   to live; provides a button (with browser-native tooltip via title=),
   plus a Clear button that appears once rings are placed and an inline
   hint that appears the first time the tool is enabled. */
.range-tool {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  max-width: 360px;
}
.range-tool-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.96); color: #333;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  transition: background-color 0.12s;
}
.range-tool-btn:hover { background: #f4f4f4; }

/* (i) info button next to the Range Rings toggle — toggles a help blurb on
   and off (decoupled from the tool's active state). Smaller and rounder
   than the main toggle so it reads as ancillary. */
.range-tool-info {
  width: 22px; height: 22px; padding: 0;
  background: rgba(255,255,255,0.96); color: #555;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 0.12s, color 0.12s;
}
.range-tool-info:hover { background: #f4f4f4; }
.range-tool-info[aria-pressed="true"] {
  background: #1f4e8c; color: #fff; border-color: #1f4e8c;
}
/* The switch (toggle slider) — visual state-of-tool indicator. The whole
   button is the click target; the switch is decorative and follows
   aria-pressed on the button. */
.range-switch {
  position: relative; display: inline-block;
  width: 26px; height: 14px;
  background: #c4c4c4; border-radius: 999px;
  transition: background-color 0.15s;
  flex-shrink: 0;
}
.range-switch-thumb {
  position: absolute; top: 1px; left: 1px;
  width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.range-tool-btn[aria-pressed="true"] .range-switch { background: #1f4e8c; }
.range-tool-btn[aria-pressed="true"] .range-switch-thumb {
  transform: translateX(12px);
}
.range-tool-clear {
  font-size: 10px; padding: 4px 9px;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 4px;
  background: rgba(255,255,255,0.96); cursor: pointer; color: #444;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.range-tool-clear:hover { background: #f4f4f4; }
.range-tool-clear[hidden],
.range-tool-hint[hidden] { display: none; }
.range-tool-preset {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  width: 100%;
  padding: 4px 8px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  font-size: 10px;
  color: #444;
}
.range-tool-preset-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #666;
}
.range-preset-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.range-preset-opt input { margin: 0; vertical-align: middle; }
.range-tool-hint {
  width: 100%;  /* breaks onto its own line below the buttons */
  background: rgba(20, 30, 48, 0.92); color: #fff;
  font-size: 10px; padding: 4px 8px; border-radius: 3px;
  letter-spacing: 0.3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
}
