.map-page {
  display: flex;
  min-height: calc(100vh - 76px);
  flex-direction: column;
  background: #edf2f5;
}

.map-page .page-hero-inner {
  padding-top: 20px;
  padding-bottom: 20px;
}

.map-page .page-hero h1 {
  font-size: clamp(1.5rem, 2.8vw, 2.15rem);
}

.map-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--gw-line);
}

.map-field {
  display: grid;
  gap: 5px;
}

.map-field label,
.map-field-label {
  color: #4f6472;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-field select,
.map-field input[type="date"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--gw-text);
  background: #fff;
  border: 1px solid #b8c8d2;
  border-radius: 8px;
  font: inherit;
}

.map-date {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 11px;
  color: #315064;
  background: var(--gw-soft-blue);
  border: 1px solid #cde1ed;
  border-radius: 8px;
  font-weight: 700;
}

.map-settings {
  position: relative;
}

.map-settings summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--gw-blue-dark);
  background: #fff;
  border: 1px solid #b8c8d2;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.map-settings summary::-webkit-details-marker { display: none; }
.map-settings summary::after { content: "▾"; margin-left: 9px; }
.map-settings[open] summary::after { content: "▴"; }
.map-settings-body {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 1400;
  min-width: 230px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--gw-line);
  border-radius: 9px;
  box-shadow: var(--gw-shadow);
}
.map-settings-body label { display: block; margin-bottom: 8px; font-size: 0.85rem; font-weight: 700; }
.map-settings-body input[type="range"] { width: 100%; }

.map-stage {
  position: relative;
  min-height: 520px;
  height: clamp(520px, calc(100vh - 310px), 820px);
  background: #dbe4e9;
}

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

.map-status {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 1000;
  max-width: calc(100% - 150px);
  padding: 7px 11px;
  color: #315064;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(125, 150, 166, 0.45);
  border-radius: 999px;
  box-shadow: 0 3px 12px rgba(24, 50, 71, 0.12);
  font-size: 0.82rem;
  font-weight: 700;
  transform: translateX(-50%);
  pointer-events: none;
}

.map-status[data-state="error"] { color: #8b2e2e; background: #fff3f3; border-color: #e5bcbc; }

.continuous-legend {
  position: absolute;
  right: 12px;
  bottom: 28px;
  z-index: 1000;
  width: min(380px, calc(100% - 56px));
  padding: 10px 13px 13px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(125, 150, 166, 0.5);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(24, 50, 71, 0.14);
}

.continuous-legend[hidden] { display: none !important; }
.continuous-legend-label { margin-bottom: 6px; text-align: center; font-size: 0.82rem; font-weight: 800; }
.continuous-legend-label span { display: block; }
.continuous-legend-label span + span { margin-top: 2px; font-size: 0.75rem; font-weight: 650; }
.continuous-scale {
  position: relative;
  height: 15px;
  margin-inline: 12px;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}
.continuous-scale::before,
.continuous-scale::after {
  content: "";
  position: absolute;
  top: 0;
  width: 12px;
  height: 100%;
  filter: drop-shadow(0 0 0.35px rgba(0, 0, 0, 0.45));
}
.continuous-scale::before {
  right: 100%;
  background: var(--legend-low-color, #ffffff);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
}
.continuous-scale::after {
  left: 100%;
  background: var(--legend-high-color, #ffffff);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.continuous-ticks { position: relative; height: 17px; margin: 4px 12px 0; }
.continuous-ticks span { position: absolute; font-size: 0.7rem; transform: translateX(-50%); }

.gdi-legend,
.boundary-control {
  color: #334e60;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(125, 150, 166, 0.5);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(24, 50, 71, 0.14);
  font-size: 0.76rem;
}

.gdi-legend { padding: 9px 10px; line-height: 1.3; }
.gdi-legend h2 { margin: 0 0 6px; font-size: 0.84rem; }
.legend-row { display: flex; align-items: center; gap: 6px; margin: 2px 0; white-space: nowrap; }
.legend-swatch { width: 15px; height: 15px; flex: 0 0 15px; border: 1px solid rgba(0, 0, 0, 0.15); }

.boundary-control { min-width: 150px; padding: 9px 10px; }
.boundary-control strong { display: block; margin-bottom: 5px; font-size: 0.8rem; }
.boundary-row { display: flex; align-items: center; gap: 7px; margin: 5px 0; }
.boundary-row input { width: 16px; height: 16px; margin: 0; }
.boundary-row label { cursor: pointer; }

.timeline-controls {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 11px 18px 14px;
  background: #fff;
  border-top: 1px solid var(--gw-line);
}
.timeline-controls button,
.map-toolbar button {
  min-height: 40px;
  padding: 7px 11px;
  color: var(--gw-blue-dark);
  background: #fff;
  border: 1px solid #b8c8d2;
  border-radius: 8px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.timeline-controls button:hover,
.map-toolbar button:hover { background: var(--gw-soft-blue); }
.timeline-controls input[type="range"] { width: 100%; }
.timeline-label { grid-column: 1 / -1; color: var(--gw-muted); font-size: 0.83rem; text-align: center; }

.map-help {
  width: min(1040px, calc(100% - 36px));
  margin: 18px auto 28px;
  color: var(--gw-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.map-help p { margin: 0; }

@media (max-width: 780px) {
  .map-toolbar { grid-template-columns: 1fr 1fr; }
  .map-settings { grid-column: 1 / -1; }
  .map-settings summary { justify-content: center; }
  .map-settings-body { left: 0; right: auto; }
  .map-stage { min-height: 470px; height: 62vh; }
  .timeline-controls { grid-template-columns: auto auto 1fr auto auto; padding-inline: 10px; }
  .timeline-controls button { min-width: 42px; padding-inline: 8px; }
}

@media (max-width: 520px) {
  .map-toolbar { grid-template-columns: 1fr; padding: 12px; }
  .map-settings { grid-column: auto; }
  .map-stage { min-height: 430px; }
  .map-status { top: 58px; max-width: calc(100% - 30px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .continuous-legend { right: 12px; bottom: 18px; width: calc(100% - 24px); }
  .timeline-controls { grid-template-columns: repeat(4, 1fr); }
  .timeline-controls input[type="range"] { grid-column: 1 / -1; grid-row: 1; }
  .timeline-label { grid-row: 3; }
}
