/* ── Reset & base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  background: #1e2a3a;
  color: #fff;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 17px;
  color: gainsboro;
}

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filters {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  height: 50px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 16px;
  color: #718096;
  font-weight: 500;
}

/* ── Dropdown checkbox menu ───────────────────────────────────────────────── */
.dropdown {
  position: relative;
}

.dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  height: 30px;
  white-space: nowrap;
}

.dropdown-btn:hover {
  background: #f7fafc;
}

.dropdown-btn[aria-expanded="true"] {
  border-color: #4299e1;
  outline: 2px solid rgba(66, 153, 225, 0.3);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 900;
  min-width: 190px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.dropdown-panel.open {
  display: flex;
}

/* ── Checkboxes ───────────────────────────────────────────────────────────── */
.cb-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: #1a1a1a;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}

.cb-label input[type="checkbox"] {
  display: none;
}

.cb-box {
  width: 15px;
  height: 15px;
  border: 1.5px solid #cbd5e0;
  border-radius: 3px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.cb-label input[type="checkbox"]:checked + .cb-box {
  background: #4299e1;
  border-color: #4299e1;
}

.cb-label input[type="checkbox"]:checked + .cb-box::after {
  content: "";
  display: block;
  width: 4px;
  height: 7px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Disabled state — JPS before data is available */
.cb-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Small pill tag next to a checkbox label (e.g. "coming soon" / "loaded") */
.cb-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #718096;
  margin-left: auto;
  white-space: nowrap;
}

/* ── Data status label ────────────────────────────────────────────────────── */
.data-status {
  font-size: 15px;
  color: #a0aec0;
  font-style: italic;
  margin-left: auto;
}

select,
input[type="date"] {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 15px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  height: 30px;
}

select:focus,
input:focus {
  outline: 2px solid #4299e1;
  outline-offset: 1px;
}

/* ── Main grid ────────────────────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 60% 40%;
  height: calc(100vh - 88px);
  overflow: hidden;
}

/* ── Map panel ────────────────────────────────────────────────────────────── */
.map-panel {
  position: relative;
  overflow: hidden;
}

#map-container {
  width: 100%;
  height: 100%;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  z-index: 0;
}

.zoom-btns {
  position: absolute;
  bottom: 80px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 800;
}

.zoom-btn {
  width: 30px;
  height: 30px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5568;
  font-weight: 300;
  line-height: 1;
}

.zoom-btn:hover {
  background: #f7fafc;
}

/* ── Right panel ──────────────────────────────────────────────────────────── */
.right-panel {
  display: flex;
  flex-direction: column;
  background: #f4f5f7;
  min-height: 0;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  flex: 0 0 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.panel-tab {
  flex: 0 0 auto;
  border: 0;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.panel-tab-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel-tab-content {
  width: 100%;
}

.panel-tab-content[hidden] {
  display: none;
}

.card {
  flex: 0 0 auto;
  background: #fff;
  margin: 12px 12px 0;
  border-radius: 10px;
  padding: 14px;
  border: 1px solid #e2e8f0;
}

.card h3 {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-sub {
  font-size: 15px;
  color: #718096;
  margin: 12px 0;
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi {
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
}

.kpi-val {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.kpi-lbl {
  font-size: 10px;
  color: #718096;
  margin-top: 2px;
}

/* Selected info banner */
.selected-info {
  background: #fffbeb;
  border: 1px solid #f6e05e;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #744210;
}

/* Chart */
.chart-wrap {
  position: relative;
  height: 170px;
  width: 100%;
}

.chart-legend {
  display: flex;
  gap: 12px;
  margin: 8px;
  margin-bottom: 11px;
  flex-wrap: wrap;
}

.cl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #4a5568;
}

.cl-swatch {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.cl-dashed {
  border-top: 2.5px dashed #e8a020;
  background: none;
  height: 0;
}

/* Score row */
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.score-label {
  font-size: 11px;
  color: #718096;
}
.score-big {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.score-bar-wrap {
  flex: 1;
}

.score-bar-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.score-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #a0aec0;
  margin-top: 3px;
}

/* Risk badge */
.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.risk-high {
  background: #fed7d7;
  color: #742a2a;
}
.risk-med {
  background: #fefcbf;
  color: #744210;
}
.risk-low {
  background: #c6f6d5;
  color: #22543d;
}

/* Factors box */
.factors-box {
  background: #eef6ff;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid #bee3f8;
  margin-bottom: 12px;
}

.factors-title {
  font-size: 14px;
  font-weight: 600;
  color: #2b6cb0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.risk-description {
  color: #2c5282;
  font-size: 13px;
  line-height: 1.55;
}

.risk-description p + p {
  margin-top: 10px;
}

.risk-source-description {
  padding-top: 8px;
  border-top: 1px solid rgba(66, 153, 225, 0.22);
}

.factors-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.factors-list li {
  font-size: 13px;
  color: #2c5282;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.factors-list li::before {
  content: "•";
  color: #4299e1;
  font-size: 14px;
  line-height: 1.2;
  flex-shrink: 0;
}

.factors-list li.factor-day {
  color: #1a365d;
  font-weight: 700;
  margin-bottom: 2px;
}

.factors-list li.factor-day::before {
  content: none;
}

.factors-list li.factor-source {
  color: #2b6cb0;
  font-weight: 600;
}

.factors-list li.factor-source::before {
  content: none;
}

/* Soil fields */
.soil-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.soil-field {
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
}

.soil-label {
  font-size: 10px;
  color: #718096;
  margin-bottom: 2px;
}
.soil-val {
  font-size: 12px;
  font-weight: 500;
  color: #1a1a1a;
}

/* ── Dark monitoring theme ──────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #14191f;
  --surface: #20262f;
  --surface-raised: #282f39;
  --surface-soft: #303946;
  --border: #3a4655;
  --text: #edf3fa;
  --text-muted: #93a4b8;
  --accent: #58a6ff;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0.005em;
  font-size: 16px;
}

.topbar {
  background: #11161c;
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}

.topbar-title {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.topbar-right,
.filter-label,
.data-status,
.card-sub,
.score-label,
.score-bar-labels,
.cl-item {
  color: var(--text-muted);
}

.filters {
  height: 56px;
  padding: 10px 24px;
  background: #191f27;
  border-bottom-color: var(--border);
}

.dropdown-btn,
.dropdown-panel,
select,
input[type="date"],
.zoom-btn {
  color: var(--text);
  background: var(--surface-raised);
  border-color: var(--border);
}

.dropdown-btn,
select,
input[type="date"] {
  font-size: 15px;
}

.dropdown-btn:hover,
.zoom-btn:hover {
  background: var(--surface-soft);
}

.dropdown-panel {
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.cb-label {
  color: var(--text);
}

.cb-box {
  background: #171c23;
  border-color: #43536a;
}

.main {
  height: calc(100vh - 112px);
  background: #12171d;
}

.map-panel {
  background: #101722;
  border-right: 1px solid var(--border);
}

.leaflet-tile-pane {
  filter: brightness(0.68) saturate(0.92) contrast(1.15) hue-rotate(4deg);
}

.leaflet-control-attribution,
.leaflet-tooltip {
  color: var(--text) !important;
  background: rgba(17, 24, 36, 0.94) !important;
  border-color: var(--border) !important;
}

.leaflet-tooltip.dun-tooltip {
  padding: 7px 10px;
  border: 1px solid rgba(125, 211, 252, 0.45) !important;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.dun-tooltip-content {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.25;
  white-space: nowrap;
}

.dun-tooltip-content strong {
  color: #e0f2fe;
  font-size: 13px;
}

.dun-tooltip-content span {
  color: #a8b6c8;
  font-size: 11px;
}

/* Leaflet focuses clicked SVG paths with a rectangular browser outline. */
.leaflet-dun-boundaries-pane .leaflet-interactive:focus {
  outline: none;
}

.right-panel {
  gap: 14px;
  padding: 22px;
  background: #181e25;
}

.panel-tabs {
  gap: 6px;
  padding: 0 0 1px;
  overflow-x: hidden;
  background: transparent;
  border-bottom: 1px solid #405064;
}

.panel-tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 10px clamp(6px, 1.2vw, 18px);
  color: #a9bad0;
  background: rgba(128, 128, 128, 0.2);
  border-radius: 6px 6px 0 0;
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 550;
  line-height: 1.2;
  white-space: normal;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.panel-tab:hover {
  color: var(--text);
  background: rgba(88, 166, 255, 0.08);
}

.panel-tab.is-active {
  color: #0b63ce;
  background: #e7f1ff;
  font-weight: 700;
}

.panel-tab.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -2px;
  left: 0;
  height: 2px;
  background: #58a6ff;
}

.panel-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card {
  padding: 28px;
  background: var(--surface);
  border-color: var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Cards keep their natural height; the viewport scrolls the whole card. */
.card.panel-tab-content {
  flex: 0 0 auto;
}

.card h2,
.card h3 {
  color: var(--text);
  font-size: 21px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sub {
  margin: 8px 0 22px;
  font-size: 17px;
  line-height: 1.5;
}

.selected-info {
  margin-bottom: 16px;
  padding: 10px 12px;
  color: #dceaff;
  background: rgba(56, 139, 253, 0.1);
  border-color: rgba(88, 166, 255, 0.35);
  border-radius: 8px;
  font-size: 15px;
}

/* Risk score box, plus an "Avg FS" box beside it for slope stations. */
.score-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.score-row.has-fs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.score-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 14px 16px;
  background: #252c35;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.score-box-head {
  display: flex;
  flex-wrap: wrap; /* badge drops under the label in narrow boxes */
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.score-box-head .score-label {
  margin-bottom: 0;
}

.score-box-note {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* Slopes at the selected station, below the risk chart. */
.slope-list {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.slope-list h3 {
  margin: 0;
  font-size: 16px;
}

.slope-list h3 span,
.slope-list-hint {
  color: var(--text-muted);
  font-weight: 400;
}

.slope-list-hint {
  margin: 4px 0 12px;
  font-size: 13px;
}

.slope-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.slope-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slope-table th,
.slope-table td {
  padding: 9px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.slope-table thead th {
  position: sticky;
  top: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  background: #1f252d;
}

.slope-table thead small {
  font-weight: 400;
}

.slope-table tbody tr:last-child > * {
  border-bottom: 0;
}

.slope-table tbody tr:hover > * {
  background: #2b333d;
}

/* Slope ID stays visible while scrolling sideways. */
.slope-table :is(thead th, tbody th):first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #252c35;
  box-shadow: 1px 0 0 var(--border);
}

.slope-table thead th:first-child {
  z-index: 2;
  background: #1f252d;
}

.slope-table tbody th {
  font-weight: 600;
}

.slope-table td:nth-child(2),
.slope-table td:nth-child(3) {
  font-weight: 700;
}

.slope-table .risk-badge {
  padding: 3px 9px;
  font-size: 12px;
}

.score-label {
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.score-big {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.score-bar-track {
  height: 9px;
  background: #263345;
}

.score-bar-labels {
  margin-top: 6px;
  font-size: 12px;
}

.risk-badge {
  padding: 6px 12px;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.risk-high {
  color: #ffb4ad;
  background: rgba(248, 81, 73, 0.17);
}

.risk-med {
  color: #ffd486;
  background: rgba(210, 153, 34, 0.17);
}

.risk-low {
  color: #8de6ad;
  background: rgba(46, 160, 67, 0.17);
}

.chart-wrap {
  height: 220px;
  margin-top: 4px;
}

.chart-legend {
  gap: 18px;
  margin: 12px 0 0;
}

.cl-item {
  font-size: 15px;
}

.chart-legend + h2 {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.factors-box {
  margin-bottom: 0;
  padding: 18px;
  background: #252e39;
  border-color: rgba(88, 166, 255, 0.22);
  border-radius: 10px;
}

.factors-title {
  margin-bottom: 12px;
  color: #79b8ff;
  font-size: 17px;
}

.risk-description {
  color: #c4d2e3;
  font-size: 16px;
  line-height: 1.7;
}

.risk-description strong {
  color: #f4f8fc;
  font-weight: 650;
}

.risk-description p + p {
  margin-top: 16px;
}

.risk-source-description {
  padding-top: 14px;
  border-top-color: rgba(88, 166, 255, 0.16);
}

/* Dashboard card accents */
.risk-card,
.population-card {
  position: relative;
}

.risk-card::before,
.population-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: 14px 0 0 14px;
}

.risk-card::before {
  background: linear-gradient(#f0a51a, #ef5b4c);
}

.population-card::before {
  background: linear-gradient(#58a6ff, #2dd4bf);
}

.population-heading {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.risk-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.risk-heading .card-sub {
  margin: 3px 0 0;
  font-size: 17px;
}

.risk-heading-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #ffb44a;
  background: rgba(240, 165, 26, 0.12);
  border: 1px solid rgba(240, 165, 26, 0.25);
  border-radius: 10px;
}

.population-heading .card-sub {
  margin: 3px 0 0;
  font-size: 17px;
}

.population-heading-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #79b8ff;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.22);
  border-radius: 10px;
}

.population-location {
  max-width: 170px;
  padding: 6px 10px;
  overflow: hidden;
  color: #dceaff;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.population-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.population-kpi {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
  background: #252c35;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.population-kpi-total {
  background: linear-gradient(
    135deg,
    rgba(88, 166, 255, 0.17),
    rgba(45, 212, 191, 0.07)
  );
  border-color: rgba(88, 166, 255, 0.38);
}

.population-kpi-label,
.population-kpi > span:last-child {
  color: var(--text-muted);
  font-size: 15px;
}

.population-kpi-label {
  min-height: 30px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.population-kpi strong {
  margin: 4px 0 2px;
  color: #f4f8fc;
  font-size: clamp(22px, 2.1vw, 31px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.population-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.population-breakdown {
  padding: 16px;
  background: #1b2129;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.population-card .population-breakdown h3 {
  margin-bottom: 14px;
  color: #dce7f4;
  font-size: 17px;
}

.population-breakdown-row {
  display: grid;
  grid-template-columns: minmax(98px, 0.9fr) minmax(80px, 1.4fr) auto;
  align-items: center;
  gap: 10px;
}

.population-breakdown-row + .population-breakdown-row {
  margin-top: 13px;
}

.population-group-label {
  min-width: 0;
  color: #b8c7d9;
  font-size: 16px;
}

.population-group-label small {
  display: block;
  margin-top: 2px;
  color: #71849a;
  font-size: 15px;
}

.population-bar-track {
  height: 8px;
  overflow: hidden;
  background: #263345;
  border-radius: 999px;
}

.population-bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, #58a6ff, #38bdf8);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.population-group-value {
  min-width: 62px;
  color: #e8f1fb;
  font-size: 16px;
  font-weight: 650;
  text-align: right;
}

.population-group-value small {
  display: block;
  margin-top: 2px;
  color: hsl(211, 20%, 58%);
  font-size: 15px;
  font-weight: 500;
}

.population-empty {
  padding: 18px;
  color: var(--text-muted);
  background: #1b2129;
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
}

.population-empty[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 52% 48%;
  }

  .right-panel {
    padding: 12px;
  }

  .card {
    padding: 18px;
  }

  .population-kpis,
  .population-detail-grid {
    grid-template-columns: 1fr;
  }

  .population-heading {
    grid-template-columns: auto 1fr;
  }

  .population-location {
    grid-column: 1 / -1;
    max-width: none;
    justify-self: start;
  }
}

/* ── Primary dashboard navigation ──────────────────────────────────────── */
.app-tabs {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  margin: 10px 16px;
  padding: 5px 7px;
  color: #fff;
  background: #11161c;
  border: 1px solid #242424;
  border-radius: 999px;
  box-shadow:
    0 3px 10px rgba(8, 15, 24, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.app-nav-brand {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  color: #1869ff;
  background: #fff;
  border-radius: 50%;
}

.app-nav-brand svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.app-tab-list {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
}

.app-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 34px;
  padding: 0 18px;
  color: #b8bec7;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    color 160ms ease,
    background 160ms ease;
}

.app-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.app-tab.is-active {
  color: #fff;
  background: #1e2a3a;
  box-shadow: none;
}

.app-tab.is-active::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 2px;
  left: 18px;
  height: 2px;
  background: #4d8dff;
  border-radius: 999px;
}

.app-tab:focus-visible {
  outline: 2px solid #63a1ff;
  outline-offset: 2px;
}

.app-nav-meta {
  padding: 9px 14px;
  color: #181818;
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.app-view[hidden] {
  display: none;
}

#landslideView .main {
  height: calc(100vh - 180px);
}

/* ── Disaster alert dashboard ──────────────────────────────────────────── */
.disaster-view {
  height: calc(100vh - 68px);
  overflow-y: auto;
  background: #f4f5f7;
  color: #ecf5ff;
}

.alert-header {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 15px 20px;
  color: #fff;
  background: #1e2a3a;
}

.alert-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-title-group h1 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
}

.alert-logo {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #ff858d;
  font-size: 19px;
  font-weight: 800;
}

.alert-date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 4px 6px 4px 11px;
  /* background: #202833;
  border: 1px solid #354252;
  border-radius: 10px; */
}

.alert-date-controls label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.alert-date-controls label span,
.alert-state-filter {
  color: #93a4b8;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.alert-date-controls input,
.alert-state-filter select {
  height: 34px;
  padding: 4px 10px;
  color: #edf3fa;
  background: #171d25;
  border: 1px solid #3c4a5c;
  border-radius: 7px;
  font-size: 13px;
}

.alert-date-controls input:hover,
.alert-state-filter select:hover {
  border-color: #58708b;
}

.date-separator {
  color: #6f8aaa;
  font-size: 14px;
}

.disaster-view > .filters {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 18px;
  width: 100%;
  height: auto;
  min-height: 64px;
  padding: 10px 20px;
  background: #191f27;
  border-bottom: 1px solid #3a4655;
}

.disaster-view > .filters > .filter-label,
.disaster-view .alert-date-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-type-filters {
  display: flex;
  flex: 1;
  gap: 6px;
  padding: 2px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.alert-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  color: #bdc9d7;
  background: #252e39;
  border: 1px solid #3b4858;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.alert-filter-chip:hover {
  color: #fff;
  background: #303b48;
  border-color: #536477;
  transform: translateY(-1px);
}

.alert-filter-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--chip-color, #58a6ff);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--chip-color, #58a6ff);
}

.alert-filter-chip.is-active {
  color: #fff;
  background: color-mix(in srgb, var(--chip-color, #58a6ff) 24%, #202833);
  border-color: color-mix(in srgb, var(--chip-color, #58a6ff) 70%, #536477);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chip-color, #58a6ff) 16%, transparent) inset;
}

.alert-state-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 145px;
  min-height: 44px;
  padding: 4px 6px 4px 11px;
  /* background: #202833;
  border: 1px solid #354252;
  border-radius: 10px; */
}

.alert-state-filter select {
  min-width: 170px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.alert-data-status {
  align-self: center;
  padding: 6px 9px;
  color: #91a6be;
  background: rgba(88, 166, 255, 0.08);
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.alert-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.56fr) minmax(390px, 0.94fr);
  grid-template-rows: auto minmax(580px, calc(100vh - 272px));
  gap: 12px;
  padding: 14px 22px 22px;
  background: #14191f;
}

.alert-kpis {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
}

.alert-kpi {
  position: relative;
  min-width: 0;
  padding: 14px 15px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(18, 43, 63, 0.96), rgba(12, 31, 47, 0.96));
  border: 1px solid #29465f;
  border-radius: 10px;
}

.alert-kpi::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 70px;
  height: 100%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--kpi-color) 12%, transparent));
}

.alert-kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b8cde1;
  font-size: 13px;
}

.alert-kpi-dot {
  width: 10px;
  height: 10px;
  background: var(--kpi-color);
  border-radius: 50%;
  box-shadow: 0 0 9px var(--kpi-color);
}

.alert-kpi strong {
  display: block;
  margin-top: 5px;
  color: #fff;
  font-size: 29px;
  line-height: 1;
}

.alert-kpi small {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #718eaa;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-map-card,
.alert-panel {
  background: rgba(11, 31, 47, 0.93);
  border: 1px solid #29465f;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  padding:10px;
}

.alert-map-card {
  position: relative;
  min-height: 580px;
  overflow: hidden;
}

#alert-map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.alert-map-card .leaflet-tile-pane {
  filter: brightness(0.68) saturate(0.92) contrast(1.15) hue-rotate(4deg);
}

.alert-map-legend {
  position: absolute;
  bottom: 34px;
  left: 14px;
  z-index: 500;
  display: grid;
  gap: 7px;
  min-width: 155px;
  padding: 11px 13px;
  background: rgba(6, 20, 32, 0.92);
  border: 1px solid #29465f;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.alert-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d1e2f2;
  font-size: 11px;
}

.alert-legend-symbol {
  width: 10px;
  height: 10px;
  background: var(--legend-color);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  box-shadow: 0 0 7px var(--legend-color);
}

.map-location-note {
  position: absolute;
  right: 10px;
  bottom: 5px;
  z-index: 500;
  max-width: 62%;
  color: #7291ad;
  font-size: 10px;
  text-align: right;
  text-shadow: 0 1px 3px #061420;
}

.alert-marker {
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50% 50% 50% 15%;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.55), 0 0 10px var(--marker-color);
  color: #fff;
  font-size: 14px;
  font-weight: 850;
  transform: rotate(-45deg);
}

.alert-marker > span {
  transform: rotate(45deg);
}

.alert-marker.is-selected {
  border-width: 3px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.18), 0 0 18px var(--marker-color);
}

.alert-insights {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  /* padding: 22px; */
  overflow: hidden;
  background: #181e25;
}

.alert-panel-tabs {
  flex: 0 0 auto;
}

.alert-tab-viewport {
  flex: 1 1 auto;
}

.alert-tab-viewport > .panel-tab-content {
  min-height: 100%;
  margin: 0;
}

.alert-tab-viewport > .alert-panel {
  padding: 24px;
  background: var(--surface);
  border-color: var(--border);
  border-radius: 14px;
}

.alert-panel {
  min-height: 0;
  height: fit-content;
  padding: 15px;
  overflow: hidden;
}

.alert-tab-viewport > .alert-panel {
  min-height: auto;
}

.alert-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.eyebrow {
  color: #4eb8ff;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.alert-panel-heading h2 {
  margin-top: 3px;
  color: #f2f7fc;
  font-size: 16px;
  line-height: 1.2;
}

.result-count,
.severity-pill {
  padding: 5px 8px;
  color: #dceaff;
  background: rgba(41, 101, 147, 0.18);
  border: 1px solid rgba(76, 161, 224, 0.28);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.alert-trend-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 400px;
}

.trend-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.alert-population-section::before,
.trend-panel::before,
.selected-alert-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 3px;
  border-radius: 14px 0 0 14px;
  pointer-events: none;
}

.trend-panel::before {
  background: linear-gradient(#58a6ff, #2dd4bf);
}

.selected-alert-panel::before {
  background: linear-gradient(#f0a51a, #ef5b4c);
}

.alert-population-section::before {
  background: linear-gradient(180deg, #a855f7 0%, #58a6ff 52%, #2dd4bf 100%);
}

.trend-panel .alert-panel-heading {
  flex: 0 0 auto;
  margin-bottom: 14px;
}

.trend-panel .incident-trend-heading {
  align-items: center;
  margin-bottom: 22px;
}

.alert-section-title {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.alert-section-title h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.alert-section-title .card-sub {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.5;
}

.incident-trend-heading .result-count {
  flex: 0 0 auto;
  padding: 6px 10px;
}

.selected-record-heading {
  align-items: center;
  margin-bottom: 22px;
}

.selected-record-heading .severity-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
}

.selected-alert-panel {
  position: relative;
  min-height: 0;
}

.alert-population-section {
  position: relative;
}

.alert-population-section h2,
.alert-population-section h3 {
  color: var(--text);
}

.alert-population-section .population-breakdown h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.alert-detail-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: #7593ad;
  font-size: 12px;
  text-align: center;
}

.alert-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.alert-detail-meta div {
  min-width: 0;
  padding: 7px 8px;
  background: rgba(25, 58, 83, 0.52);
  border: 1px solid #26465f;
  border-radius: 6px;
}

.alert-detail-meta span {
  display: block;
  color: #7190ab;
  font-size: 9px;
  text-transform: uppercase;
}

.alert-detail-meta strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: #e9f3fc;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-description {
  color: #b1c6d9;
  font-size: 12px;
  line-height: 1.45;
}

.alert-source-link {
  display: inline-block;
  margin-top: 8px;
  color: #55baff;
  font-size: 11px;
  text-decoration: none;
}

.records-panel {
  display: flex;
  flex-direction: column;
}

.alert-record-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: #345b78 transparent;
}

.alert-record-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 7px;
  color: inherit;
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(56, 86, 109, 0.5);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.alert-record-item:hover,
.alert-record-item.is-selected {
  background: rgba(41, 108, 157, 0.14);
}

.record-dot {
  width: 9px;
  height: 9px;
  background: var(--record-color);
  border-radius: 50%;
  box-shadow: 0 0 7px var(--record-color);
}

.record-main {
  min-width: 0;
}

.record-main strong,
.record-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-main strong {
  color: #dceaf6;
  font-size: 12px;
}

.record-main span,
.record-date {
  margin-top: 2px;
  color: #7592ac;
  font-size: 10px;
}

@media (min-width: 1101px) {
  .disaster-view {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .alert-header,
  .disaster-view > .filters {
    flex-shrink: 0;
  }

  .alert-dashboard {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .alert-map-card,
  .alert-insights {
    min-height: 0;
    min-width: 0;
  }
}

@media (max-width: 1100px) {
  .alert-dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto 560px auto;
  }

  .alert-map-card {
    min-height: 0;
  }

  .alert-insights {
    min-height: 430px;
    overflow: visible;
  }

  .selected-alert-panel {
    min-height: 320px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-tabs {
    height: 48px;
    margin: 8px;
    padding: 5px 7px;
  }

  .app-nav-brand {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .app-tab-list {
    position: static;
    flex: 1;
    justify-content: center;
    gap: 2px;
    transform: none;
  }

  .app-tab {
    height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }

  .app-nav-meta {
    display: none;
  }

  #landslideView .main {
    height: calc(100vh - 170px);
  }

  .disaster-view {
    height: auto;
    min-height: calc(100vh - 64px);
  }

  .alert-header,
  .disaster-view > .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .alert-date-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    justify-content: space-between;
  }

  .alert-date-controls label {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .alert-date-controls input {
    width: 100%;
  }

  .alert-type-filters {
    width: 100%;
  }

  .alert-state-filter {
    justify-content: space-between;
  }

  .alert-state-filter select {
    flex: 1;
  }

  .alert-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert-kpi:first-child {
    grid-column: 1 / -1;
  }

  .alert-dashboard {
    grid-template-rows: auto 480px auto;
    padding: 0 12px 16px;
  }

  .alert-map-card,
  #alert-map {
    min-height: 0;
  }

  .alert-insights {
    padding: 12px;
  }
}

/* ── Readable typography scale ─────────────────────────────────────────── */
/* Keep supporting copy and controls at one generous baseline size. */
body {
  font-size: 17px;
}

.filter-label,
.dropdown-btn,
.cb-label,
.cb-tag,
.data-status,
select,
input[type="date"],
.card h3,
.card-sub,
.kpi-lbl,
.selected-info,
.cl-item,
.score-label,
.score-bar-labels,
.risk-badge,
.factors-title,
.risk-description,
.factors-list li,
.soil-label,
.soil-val,
.dun-tooltip-content strong,
.dun-tooltip-content span,
.panel-tab,
.population-location,
.population-kpi-label,
.population-kpi > span:last-child,
.population-group-label,
.population-group-label small,
.population-group-value,
.population-group-value small,
.app-tab,
.app-nav-meta,
.alert-date-controls label span,
.alert-state-filter,
.alert-date-controls input,
.alert-state-filter select,
.date-separator,
.alert-filter-chip,
.alert-data-status,
.alert-kpi-label,
.alert-kpi small,
.alert-legend-item,
.map-location-note,
.eyebrow,
.result-count,
.severity-pill,
.alert-detail-empty,
.alert-detail-meta span,
.alert-detail-meta strong,
.alert-description,
.alert-source-link,
.record-main strong,
.record-main span,
.record-date,
.leaflet-tooltip,
.leaflet-control-attribution {
  font-size: 16px;
}

/* ── Rescue center fragility view ──────────────────────────────────────── */
.rescue-view {
  height: calc(100vh - 68px);
  overflow-y: auto;
  color: #eaf3ff;
  background:
    radial-gradient(circle at 78% 0, rgba(31, 86, 143, 0.16), transparent 35%),
    #0a121d;
}

.rescue-topbar {
  min-height: 54px;
  background: rgba(12, 23, 36, 0.95);
  border-bottom: 1px solid #304052;
}

.rescue-filters {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 20px;
  background: #101c2a;
  border-bottom: 1px solid #2c3d50;
}

.rescue-filters label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #a9c3e2;
  font-size: 16px;
  white-space: nowrap;
}

.rescue-filters select {
  min-width: 160px;
  height: 38px;
  padding: 0 34px 0 12px;
  color: #f3f7fc;
  background: #142234;
  border: 1px solid #3a5069;
  border-radius: 7px;
  font: inherit;
}

.rescue-filters label:nth-child(3) select {
  min-width: 190px;
}

.rescue-data-status {
  margin-left: auto;
  color: #9eb5d0;
  font-size: 16px;
  font-style: italic;
  white-space: nowrap;
}

.rescue-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(500px, 1fr);
  grid-template-rows: auto minmax(620px, calc(100vh - 285px));
  gap: 14px;
  padding: 14px 16px 18px;
}

.rescue-kpis {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.rescue-kpi {
  --kpi-accent: #49afff;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  min-width: 0;
  min-height: 100px;
  padding: 14px;
  overflow: hidden;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--kpi-accent) 15%, transparent), transparent 70%),
    #142234;
  border: 1px solid color-mix(in srgb, var(--kpi-accent) 38%, #30465e);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(1, 7, 14, 0.2);
}

.rescue-kpi-indigo { --kpi-accent: #85aef8; }
.rescue-kpi-teal { --kpi-accent: #53d4b0; }
.rescue-kpi-amber { --kpi-accent: #ffb52e; }
.rescue-kpi-red { --kpi-accent: #ff5664; }

.rescue-kpi-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--kpi-accent);
  background: color-mix(in srgb, var(--kpi-accent) 17%, transparent);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.rescue-kpi > div {
  min-width: 0;
}

.rescue-kpi div > span,
.rescue-kpi small {
  display: block;
  color: #b7cbe3;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.rescue-kpi strong {
  display: block;
  margin: 4px 0;
  color: var(--kpi-accent);
  font-size: 32px;
  line-height: 1;
}

.rescue-kpi small {
  color: #829bb7;
  font-size: 16px;
}

.rescue-map-card,
.rescue-insights {
  min-height: 620px;
  background: #101b29;
  border: 1px solid #294058;
  border-radius: 10px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
}

.rescue-map-card {
  position: relative;
  padding: 8px;
  overflow: hidden;
}

#rescue-map {
  width: 100%;
  height: 100%;
  min-height: 604px;
  border-radius: 6px;
}

.rescue-map-card .leaflet-tile-pane {
  filter: brightness(0.7) saturate(1.05) contrast(1.12);
}

.rescue-map-pin {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--pin-color);
  border: 3px solid #f8fbff;
  border-radius: 50% 50% 50% 10%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), 0 0 13px var(--pin-color);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.rescue-map-pin span {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
}

.rescue-map-pin.is-selected {
  border-width: 4px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.18), 0 0 18px var(--pin-color);
  transform: rotate(-45deg) scale(1.08);
}

.rescue-map-legend {
  position: absolute;
  bottom: 20px;
  left: 22px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding: 10px 13px;
  color: #e3ecf7;
  background: rgba(6, 15, 25, 0.92);
  border: 1px solid #30475f;
  border-radius: 9px;
  backdrop-filter: blur(8px);
}

.rescue-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
}

.legend-dot {
  width: 11px;
  height: 11px;
  background: #9aa6b2;
  border-radius: 50%;
}

.legend-dot.adequate { background: #2da8ff; }
.legend-dot.near { background: #ffb52e; }
.legend-dot.shortfall { background: #ff4d57; }

.rescue-insights {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* padding: 18px; */
  overflow: auto;
}

.rescue-insights::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(#2da8ff, #ffb52e, #ff4d57);
  border-radius: 10px 0 0 10px;
}

.rescue-section-heading,
.rescue-ranking-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rescue-section-heading > div {
  min-width: 0;
}

.rescue-eyebrow {
  color: #65aaff;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rescue-section-heading h2 {
  margin-top: 3px;
  overflow: hidden;
  color: #f5f8fc;
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rescue-section-heading p {
  margin-top: 3px;
  color: #91aac6;
  font-size: 16px;
}

.rescue-fragility-badge,
.rescue-table-status {
  color: var(--status-color, #91aac6);
  background: color-mix(in srgb, var(--status-color, #91aac6) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-color, #91aac6) 42%, transparent);
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.rescue-fragility-badge {
  padding: 7px 12px;
  font-size: 16px;
}

.rescue-fragility-title,
.rescue-victims-title {
  min-width: 0;
}

.rescue-fragility-heading .alert-section-title h2,
.rescue-victims-heading .alert-section-title h2 {
  margin: 0;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.rescue-fragility-heading .card-sub,
.rescue-victims-heading .card-sub {
  overflow-wrap: anywhere;
}

.rescue-fragility-heading #rescueSelectedLocation,
.rescue-victims-heading #rescueVictimsLocation {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.rescue-fragility-heading .rescue-fragility-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
}

.rescue-detail-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.rescue-detail-kpis article {
  min-width: 0;
  padding: 11px;
  background: #162538;
  border: 1px solid #2a435c;
  border-radius: 8px;
}

.rescue-detail-kpis article.is-gap {
  background: rgba(111, 33, 43, 0.26);
  border-color: #8b3e49;
}

.rescue-detail-kpis span,
.rescue-detail-kpis small {
  display: block;
  color: #a9bfd8;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.rescue-detail-kpis strong {
  display: block;
  margin: 5px 0 2px;
  color: #f5f8fc;
  font-size: 28px;
}

.rescue-detail-kpis .is-gap strong {
  color: #ff6973;
}

.rescue-score-card {
  display: grid;
  grid-template-columns: 115px minmax(100px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: #111e2d;
  border: 1px solid #283e55;
  border-radius: 9px;
}

.rescue-score-card div:first-child span {
  display: block;
  color: #a9bfd8;
  font-size: 16px;
}

.rescue-score-card strong {
  color: #f3f7fc;
  font-size: 32px;
}

.rescue-score-track {
  height: 9px;
  overflow: hidden;
  background: #25374b;
  border-radius: 999px;
}

.rescue-score-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms ease;
}

#rescueScoreLabel {
  min-width: 75px;
  font-size: 16px;
  font-weight: 750;
  text-align: right;
}

/* .rescue-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
} */

.rescue-mini-panel,
.rescue-ranking {
  padding: 12px;
  background: #111e2d;
  border: 1px solid #283e55;
  border-radius: 9px;
}

.rescue-mini-panel h3,
.rescue-ranking h3 {
  margin-bottom: 9px;
  color: #ecf3fb;
  font-size: 16px;
}

.rescue-mini-panel dl {
  display: grid;
  gap: 7px;
}

.rescue-mini-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #95adc7;
  font-size: 16px;
}

.rescue-mini-panel dd {
  overflow: hidden;
  color: #dce8f6;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rescue-mini-panel a {
  color: #60b4ff;
  text-decoration: none;
}

.rescue-ranking {
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.rescue-ranking-heading {
  padding: 11px 12px;
  border-bottom: 1px solid #283e55;
}

.rescue-ranking-heading h3 {
  margin: 0;
}

.rescue-ranking-heading span {
  color: #7f9ab7;
  font-size: 16px;
}

.rescue-table-wrap {
  overflow: auto;
}

.rescue-ranking table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.rescue-ranking th,
.rescue-ranking td {
  padding: 8px 7px;
  overflow: hidden;
  border-bottom: 1px solid rgba(47, 69, 91, 0.7);
  color: #b8cade;
  font-size: 16px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rescue-ranking th {
  color: #7894b2;
  font-weight: 600;
}

.rescue-ranking th:nth-child(1),
.rescue-ranking td:nth-child(1) { width: 28px; }
.rescue-ranking th:nth-child(2),
.rescue-ranking td:nth-child(2) { width: 29%; }

.rescue-ranking tbody tr {
  cursor: pointer;
}

.rescue-ranking tbody tr:hover,
.rescue-ranking tbody tr.is-selected {
  background: rgba(44, 125, 198, 0.13);
}

.rescue-ranking tbody tr:focus-visible {
  outline: 2px solid #4aa9ff;
  outline-offset: -2px;
}

.rescue-table-status {
  display: inline-block;
  max-width: 100%;
  padding: 3px 7px;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
}

/* Rescue details use the same tabs and card treatment as Disaster Alerts. */
.rescue-insights {
  overflow: hidden;
  background: #181e25;
}

.rescue-insights::before {
  display: none;
}

.rescue-panel-tabs {
  flex: 0 0 auto;
}

.rescue-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid #58a6ff;
  border-radius: 14px;
}

.rescue-detail-panel .rescue-section-heading h2 {
  white-space: normal;
  overflow-wrap: anywhere;
}

.rescue-detail-panel .rescue-breakdown-grid {
  grid-template-columns: 1fr;
}

.rescue-victims-status,
.rescue-victims-note {
  color: #a9bfd8;
  font-size: 16px;
  line-height: 1.5;
}

.rescue-victims-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.rescue-victims-breakdown {
  margin-bottom: 18px;
}

.rescue-victims-legend {
  display: flex;
  gap: 20px;
  margin: 12px 0 20px;
  color: #a9bfd8;
}

.rescue-victims-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rescue-victims-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.victims-male { background: #2da8ff; }
.victims-female { background: #b279ff; }

.rescue-victims-group + .rescue-victims-group {
  margin-top: 22px;
}

.rescue-victims-group h4 {
  margin-bottom: 10px;
  color: #ecf3fb;
  font-size: 16px;
}

.rescue-victims-bar-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: #a9bfd8;
  font-size: 16px;
}

.rescue-victims-bar-row strong {
  color: #ecf3fb;
  text-align: right;
}

.rescue-victims-bar-track {
  height: 10px;
  overflow: hidden;
  background: #263345;
  border-radius: 6px;
}

.rescue-victims-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

@media (max-width: 620px) {
  .rescue-detail-panel { padding: 16px; }
}

@media (min-width: 1101px) {
  .rescue-view {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .rescue-topbar,
  .rescue-filters {
    flex-shrink: 0;
  }

  .rescue-dashboard {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .rescue-map-card,
  .rescue-insights,
  #rescue-map {
    min-height: 0;
    min-width: 0;
  }

  .rescue-insights {
    overflow-y: auto;
  }

  .rescue-detail-panel {
    flex-shrink: 0;
  }
}

@media (max-width: 1250px) {
  .rescue-dashboard {
    grid-template-columns: minmax(0, 1.15fr) minmax(460px, 1fr);
  }

  .rescue-kpi {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 11px;
  }

  .rescue-kpi-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .rescue-filters {
    gap: 10px;
  }

  .rescue-filters select {
    min-width: 130px;
  }
}

@media (max-width: 1100px) {
  .rescue-view {
    height: auto;
    min-height: calc(100vh - 64px);
  }

  .rescue-filters {
    flex-wrap: wrap;
  }

  .rescue-data-status {
    margin-left: 0;
  }

  .rescue-dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto 560px auto;
  }

  .rescue-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rescue-map-card,
  #rescue-map {
    min-height: 0;
  }

  .rescue-insights {
    min-height: 0;
    overflow: visible;
  }

  .rescue-tab-viewport {
    flex: 0 0 auto;
    overflow: visible;
  }
}

/* Keep the stacked details reachable while the desktop body has scrolling disabled. */
@media (min-width: 761px) and (max-width: 1100px) {
  .rescue-view {
    height: calc(100vh - 68px);
    min-height: 0;
    overflow-y: auto;
  }
}

@media (max-width: 620px) {
  .rescue-filters label,
  .rescue-filters select {
    width: 100%;
  }

  .rescue-filters label {
    align-items: stretch;
    flex-direction: column;
  }

  .rescue-kpis,
  .rescue-detail-kpis,
  .rescue-breakdown-grid {
    grid-template-columns: 1fr;
  }

  .rescue-map-legend {
    right: 20px;
  }
}

/* Compact these two dashboards progressively; keep the desktop sizes above 1536px. */
@media (max-width: 1000px) {
  .disaster-view,
  .rescue-view {
    --dashboard-unit: clamp(0.75px, 0.0651041667vw, 1px);
    font-size: calc(17 * var(--dashboard-unit));
  }

  :is(.disaster-view, .rescue-view) :is(
    .panel-tab, .card-sub, .alert-date-controls label span,
    .alert-state-filter, .alert-date-controls input, .alert-state-filter select,
    .date-separator, .alert-filter-chip, .alert-data-status,
    .alert-kpi-label, .alert-kpi small, .alert-legend-item, .map-location-note,
    .eyebrow, .result-count, .severity-pill, .alert-detail-empty,
    .alert-detail-meta span, .alert-detail-meta strong, .alert-description,
    .alert-source-link, .record-main strong, .record-main span, .record-date,
    .population-location, .population-kpi-label, .population-kpi > span:last-child,
    .population-group-label, .population-group-label small,
    .population-group-value, .population-group-value small,
    .leaflet-tooltip, .leaflet-control-attribution,
    .rescue-filters label, .rescue-data-status, .rescue-kpi div > span,
    .rescue-kpi small, .rescue-section-heading p, .rescue-fragility-badge,
    .rescue-detail-kpis span, .rescue-detail-kpis small,
    .rescue-score-card div:first-child span, #rescueScoreLabel,
    .rescue-mini-panel h3, .rescue-mini-panel dl div,
    .rescue-victims-status, .rescue-victims-note, .rescue-victims-group h4,
    .rescue-victims-bar-row, .rescue-map-legend span
  ) {
    font-size: calc(16 * var(--dashboard-unit));
  }

  .disaster-view .alert-section-title .card-sub {
    font-size: calc(17 * var(--dashboard-unit));
  }

  .rescue-view :is(#rescueSelectedLocation, #rescueVictimsLocation) {
    font-size: calc(14 * var(--dashboard-unit));
  }

  .alert-title-group h1,
  .rescue-topbar .topbar-title {
    font-size: calc(20 * var(--dashboard-unit));
  }

  :is(.disaster-view, .rescue-view) :is(.alert-section-title h2, .population-heading h2, .rescue-section-heading h2) {
    font-size: calc(21 * var(--dashboard-unit));
  }

  .alert-kpi strong { font-size: calc(29 * var(--dashboard-unit)); }
  .rescue-kpi strong,
  .rescue-score-card strong { font-size: calc(32 * var(--dashboard-unit)); }
  .rescue-detail-kpis strong { font-size: calc(28 * var(--dashboard-unit)); }

  .alert-header,
  .rescue-topbar {
    min-height: calc(54 * var(--dashboard-unit));
    padding: calc(15 * var(--dashboard-unit)) calc(20 * var(--dashboard-unit));
  }

  .disaster-view > .filters,
  .rescue-filters {
    flex-wrap: wrap;
    min-height: calc(64 * var(--dashboard-unit));
    gap: calc(12 * var(--dashboard-unit));
    padding: calc(8 * var(--dashboard-unit)) calc(16 * var(--dashboard-unit));
  }

  .alert-date-controls,
  .alert-state-filter {
    min-height: calc(40 * var(--dashboard-unit));
    padding: calc(4 * var(--dashboard-unit));
    gap: calc(8 * var(--dashboard-unit));
  }

  .alert-type-filters { min-width: min(240px, 100%); }

  .alert-date-controls input,
  .alert-state-filter select,
  .rescue-filters select {
    height: calc(34 * var(--dashboard-unit));
    padding: calc(4 * var(--dashboard-unit)) calc(8 * var(--dashboard-unit));
  }

  .alert-state-filter select,
  .rescue-filters select,
  .rescue-filters label:nth-child(3) select {
    min-width: calc(150 * var(--dashboard-unit));
  }

  .alert-filter-chip {
    min-height: calc(36 * var(--dashboard-unit));
    padding: calc(7 * var(--dashboard-unit)) calc(12 * var(--dashboard-unit));
    gap: calc(7 * var(--dashboard-unit));
  }

  .alert-dashboard,
  .rescue-dashboard {
    gap: calc(12 * var(--dashboard-unit));
    padding: calc(12 * var(--dashboard-unit));
  }

  .alert-kpis,
  .rescue-kpis { gap: calc(10 * var(--dashboard-unit)); }
  .alert-kpi,
  .rescue-kpi { padding: calc(14 * var(--dashboard-unit)); }

  .rescue-kpi {
    grid-template-columns: calc(42 * var(--dashboard-unit)) minmax(0, 1fr);
    gap: calc(10 * var(--dashboard-unit));
    min-height: calc(100 * var(--dashboard-unit));
  }

  .rescue-kpi-icon {
    width: calc(42 * var(--dashboard-unit));
    height: calc(42 * var(--dashboard-unit));
    font-size: calc(22 * var(--dashboard-unit));
  }

  .alert-insights,
  .rescue-insights {
    padding: calc(18 * var(--dashboard-unit));
    gap: calc(12 * var(--dashboard-unit));
  }

  :is(.disaster-view, .rescue-view) .panel-tab {
    min-height: calc(44 * var(--dashboard-unit));
    padding: calc(10 * var(--dashboard-unit)) calc(8 * var(--dashboard-unit));
  }

  .alert-tab-viewport > .alert-panel,
  .rescue-detail-panel {
    padding: calc(24 * var(--dashboard-unit));
    gap: calc(18 * var(--dashboard-unit));
  }

  :is(.disaster-view, .rescue-view) :is(.risk-heading-icon, .population-heading-icon) {
    width: calc(42 * var(--dashboard-unit));
    height: calc(42 * var(--dashboard-unit));
  }

  :is(.disaster-view, .rescue-view) :is(.risk-heading-icon, .population-heading-icon) svg {
    width: calc(24 * var(--dashboard-unit));
    height: calc(24 * var(--dashboard-unit));
  }

  .alert-trend-wrap { min-height: calc(400 * var(--dashboard-unit)); }
  .rescue-detail-kpis article,
  .disaster-view .population-kpi { padding: calc(11 * var(--dashboard-unit)); }

  .rescue-score-card {
    grid-template-columns: minmax(70px, auto) minmax(40px, 1fr) auto;
    padding: calc(12 * var(--dashboard-unit));
    gap: calc(10 * var(--dashboard-unit));
  }

  .rescue-view #rescueScoreLabel { min-width: 0; }
}

@media (max-width: 1100px) {
  .alert-dashboard { grid-template-rows: auto clamp(320px, 45vw, 480px) auto; }
}

@media (max-width: 1100px) {
  .rescue-dashboard { grid-template-rows: auto clamp(320px, 45vw, 480px) auto; }
  .rescue-insights { min-height: 0; }
}

/* Wide screens can still have little vertical room, especially with browser zoom. */
@media (min-width: 1001px) and (max-height: 900px) {
  .app-view .panel-tab-content {
    --chart-font-size: 13px;
    font-size: 13px;
  }

  .app-view :is(.card.panel-tab-content, .alert-tab-viewport > .alert-panel, .rescue-detail-panel) {
    padding: 16px;
    gap: 12px;
  }

  .app-view .panel-tab-content :is(
    .selected-info, .score-label, .score-bar-labels, .risk-badge, .cl-item,
    .factors-title, .risk-description, .factors-list li,
    .population-kpi-label, .population-kpi > span:last-child,
    .population-group-label, .population-group-label small,
    .population-group-value, .population-group-value small, .population-empty,
    .alert-detail-empty, .alert-detail-meta span, .alert-detail-meta strong,
    .alert-description, .alert-source-link, .record-main strong,
    .record-main span, .record-date,
    .rescue-detail-kpis span, .rescue-detail-kpis small,
    .rescue-score-card div:first-child span, .rescue-mini-panel dl div,
    .rescue-victims-status, .rescue-victims-note, .rescue-victims-legend,
    .rescue-victims-group h4, .rescue-victims-bar-row
  ) {
    font-size: 13px;
    line-height: 1.4;
  }

  .app-view #rescueScoreLabel { font-size: 13px; }

  .app-view .panel-tab-content :is(.score-big, .population-kpi strong, .rescue-detail-kpis strong, .rescue-score-card strong) {
    font-size: 24px;
  }

  .app-view .panel-tab-content :is(.population-breakdown h3, .rescue-mini-panel h3) {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .app-view :is(.population-kpis, .rescue-detail-kpis) { gap: 6px; }
  .app-view :is(.population-kpi, .rescue-detail-kpis article) { padding: 8px; }
  .app-view .population-kpi-label { min-height: 22px; }

  .app-view :is(.population-breakdown, .population-empty, .factors-box, .rescue-mini-panel) {
    padding: 10px;
  }

  .app-view .population-breakdown-row + .population-breakdown-row { margin-top: 8px; }
  .app-view .risk-description p + p { margin-top: 10px; }
  .app-view .rescue-victims-group + .rescue-victims-group { margin-top: 14px; }
  .app-view .rescue-victims-legend { gap: 12px; margin: 8px 0 12px; }
  .app-view :is(.rescue-victims-kpis, .rescue-victims-breakdown) { margin-bottom: 12px; }

  .app-view :is(.score-box, .rescue-score-card) {
    padding: 10px;
    gap: 10px;
  }

  .app-view .score-row { gap: 10px; }

  .app-view .score-row { margin-bottom: 12px; }
  .app-view .chart-legend { gap: 12px; margin-top: 8px; }
  .app-view .chart-legend + h2 { margin-top: 20px; padding-top: 16px; }
  .app-view .alert-trend-wrap { min-height: 280px; }
  .app-view .chart-wrap { height: 180px; }
  .app-view .alert-detail-empty { min-height: 80px; }

  .app-view :is(.alert-section-title, .population-heading, .risk-heading, .rescue-section-heading) h2 {
    font-size: 17px;
    line-height: 1.25;
  }

  .app-view :is(.alert-section-title, .population-heading, .risk-heading, .rescue-section-heading) .card-sub,
  .app-view :is(#rescueSelectedLocation, #rescueVictimsLocation) {
    font-size: 13px;
    line-height: 1.35;
  }

  .app-view :is(.alert-panel-heading, .population-heading, .risk-heading) {
    gap: 8px;
    margin-bottom: 12px;
  }

  .app-view :is(.alert-section-title, .rescue-section-heading) {
    gap: 8px;
  }

  .app-view :is(.risk-heading-icon, .population-heading-icon) {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .app-view :is(.risk-heading-icon, .population-heading-icon) svg {
    width: 20px;
    height: 20px;
  }

  .app-view :is(.result-count, .severity-pill, .population-location, .rescue-fragility-badge) {
    padding: 4px 8px;
    font-size: 13px;
  }

  .disaster-view .alert-type-filters {
    gap: 5px;
  }

  .disaster-view .alert-filter-chip {
    min-height: 28px;
    padding: 4px 9px;
    gap: 5px;
    font-size: 13px;
  }

  .disaster-view .alert-filter-chip::before {
    width: 6px;
    height: 6px;
  }

  :is(.disaster-view, .rescue-view) .panel-tab {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.2;
  }

  .disaster-view .alert-kpi {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 10px 14px;
  }

  .disaster-view .alert-kpi-label {
    font-size: 14px;
  }

  .disaster-view .alert-kpi strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-top: 0;
    font-size: 26px;
  }

  .disaster-view .alert-kpi small {
    grid-column: 1;
    margin-top: 0;
    font-size: 12px;
  }

  .rescue-view .rescue-kpi {
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 0;
    padding: 9px 12px;
  }

  .rescue-view .rescue-kpi-icon {
    width: 30px;
    height: 30px;
    font-size: 17px;
  }

  .rescue-view .rescue-kpi > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 8px;
  }

  .rescue-view .rescue-kpi div > span {
    font-size: 14px;
    line-height: 1.25;
  }

  .rescue-view .rescue-kpi small {
    grid-column: 1;
    font-size: 12px;
    line-height: 1.25;
  }

  .rescue-view .rescue-kpi strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 24px;
  }

  .disaster-view > .filters,
  .rescue-view .rescue-filters {
    flex-wrap: wrap;
    min-height: 48px;
    padding: 6px 16px;
    gap: 8px 12px;
  }

  .disaster-view > .filters :is(.filter-label, .alert-date-field, .date-separator, .alert-state-filter, .alert-data-status) {
    font-size: 13px;
  }

  .disaster-view > .filters :is(.alert-date-controls, .alert-state-filter) {
    min-height: 28px;
    padding: 0;
    gap: 6px;
  }

  .disaster-view > .filters :is(input[type="date"], select) {
    height: 28px;
    padding: 3px 8px;
    font-size: 13px;
  }

  .disaster-view > .filters select { min-width: 120px; }

  .rescue-view .rescue-filters label {
    gap: 6px;
    font-size: 13px;
  }

  .rescue-view .rescue-filters select {
    min-width: 120px;
    height: 28px;
    padding: 3px 8px;
    font-size: 13px;
  }

  .rescue-view .rescue-filters label:nth-child(3) select {
    min-width: 150px;
  }

  .rescue-view .rescue-data-status { font-size: 13px; }

  .rescue-view .rescue-insights {
    /* padding: 14px; */
    gap: 10px;
  }

  .rescue-view .rescue-score-card {
    grid-template-columns: 90px minmax(60px, 1fr) auto;
  }

  .rescue-view #rescueScoreLabel { min-width: 60px; }
  .rescue-view .rescue-score-track,
  .rescue-view .rescue-victims-bar-track { height: 7px; }
  .rescue-view .rescue-victims-bar-row { gap: 8px; margin-top: 6px; }
  .rescue-view .rescue-victims-legend i { width: 9px; height: 9px; }
  .rescue-view .rescue-map-legend { padding: 8px 10px; gap: 5px; }
  .rescue-view .rescue-map-legend span { font-size: 12px; }
}

@media (max-width: 760px) {
  .disaster-view > .filters > .filter-label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .disaster-view .alert-date-field {
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .disaster-view .alert-date-field input { width: 100%; }
}

/* Disaster impact and readiness: isolated dark planning dashboard. */
/* Use the Rescue Center type scale, resizing continuously with viewport width. */
.impact-view {
  --dashboard-unit: clamp(0.6875px, calc(0.25px + 0.0390625vw), 1.25px);
  --impact-text-size: calc(16 * var(--dashboard-unit));
  --impact-filter-font-size: clamp(12px, calc(10px + 0.15625vw), 14px);
  --impact-heading-size: calc(21 * var(--dashboard-unit));
  --impact-subheading-size: calc(16 * var(--dashboard-unit));
  --impact-kpi-label-size: calc(16 * var(--dashboard-unit));
  --impact-kpi-note-size: calc(16 * var(--dashboard-unit));
  --impact-kpi-value-size: calc(32 * var(--dashboard-unit));
  --impact-detail-value-size: calc(28 * var(--dashboard-unit));
  --impact-legend-size: calc(16 * var(--dashboard-unit));
}
.impact-view { height: calc(100dvh - 68px); overflow: auto; background: #0b121c; color: #dce5f5; font-size: calc(17 * var(--dashboard-unit)); color-scheme: dark; }
.impact-view .topbar { background: #101824; border-bottom: 1px solid #2a384c; padding: 12px 18px; }
.impact-view .topbar-title { font-size: calc(20 * var(--dashboard-unit)); }
.impact-snapshot { color: #9baecb; font-size: var(--impact-text-size); }
.impact-filters { display:flex; flex-wrap:wrap; gap:12px 20px; padding:12px 16px; border-bottom:1px solid #243247; background:#0f1824; }
.impact-filters label { display:flex; align-items:center; gap:9px; font-size:var(--impact-filter-font-size); line-height:1.4; }
.impact-exposure-filters { flex-basis:100%; display:flex; flex-wrap:wrap; gap:12px 20px; }
.impact-exposure-filters input { width:94px; min-width:94px; box-sizing:border-box; }
.impact-view select,.impact-view input { background:#152132; border:1px solid #2b3d57; border-radius:5px; color:#e1e8f3; padding:6px 8px; min-height:31px; font:inherit; }
.impact-view .impact-filters :is(select, input) { font-size:var(--impact-filter-font-size); line-height:1.4; height:auto; }
.impact-content { padding:10px 12px 18px; }
.impact-kpis { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; margin-bottom:12px; }
.impact-view .danger { --impact-color:#f06979; --impact-tint:#402332; }
.impact-view .blue { --impact-color:#80a7ef; --impact-tint:#203553; }
.impact-view .green { --impact-color:#78d89c; --impact-tint:#183d39; }
.impact-view .amber { --impact-color:#f5af56; --impact-tint:#403522; }
.impact-view .purple { --impact-color:#afa0ff; --impact-tint:#302857; }
.impact-view .muted { --impact-color:#a2aaba; --impact-tint:#303747; }
.impact-kpi { display:grid; grid-template-columns:38px minmax(0,1fr); align-items:center; gap:10px; min-width:0; min-height:92px; padding:14px; overflow:hidden; background:linear-gradient(115deg,color-mix(in srgb,var(--impact-color) 15%,transparent),transparent 70%),#142234; border:1px solid color-mix(in srgb,var(--impact-color) 38%,#30465e); border-radius:10px; box-shadow:0 10px 26px rgba(1,7,14,.2); }
.impact-kpi.danger { --impact-color:#ff5664; }
.impact-kpi.blue { --impact-color:#49afff; }
.impact-kpi.green { --impact-color:#53d4b0; }
.impact-kpi.amber { --impact-color:#ffb52e; }
.impact-kpi-icon { display:grid; place-items:center; background:color-mix(in srgb,var(--impact-color) 17%,transparent); border-radius:8px; font-size:22px; font-weight:800; color:var(--impact-color); width:38px; height:38px; }
.impact-kpi > div { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:4px 8px; min-width:0; }
.impact-kpi div>span { display:block; color:#b7cbe3; font-size:var(--impact-kpi-label-size); line-height:1.25; overflow-wrap:anywhere; }
.impact-kpi strong { grid-column:2; grid-row:1 / span 2; display:block; color:var(--impact-color); font-size:var(--impact-kpi-value-size); line-height:1; margin:0; }
.impact-kpi div>small { grid-column:1; font-size:var(--impact-kpi-note-size); color:#829bb7; display:block; line-height:1.25; overflow-wrap:anywhere; }
@media (min-width:1001px) and (max-height:900px) {
  .impact-kpi { grid-template-columns:30px minmax(0,1fr); gap:8px; min-height:0; padding:9px 12px; }
  .impact-kpi-icon { width:30px; height:30px; font-size:17px; }
}
@media (max-width:800px) {
  .impact-kpi { grid-template-columns:minmax(0,1fr); padding:12px; }
  .impact-kpi > div { grid-template-columns:minmax(0,1fr); }
  .impact-kpi strong { grid-column:1; grid-row:auto; }
}
.impact-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; align-items:start; }
.impact-insights { min-width:0; }
.impact-map-card { position:sticky; top:0; height:max(520px,calc(100dvh - 305px)); overflow:hidden; border-radius:7px; border:1px solid #243650; }
#impact-map { width:100%; height:100%; background:#12283b; }
.impact-map-legend { position:absolute; bottom:12px; left:12px; max-width:calc(100% - 24px); z-index:500; padding:12px; background:#0b1423ed; border:1px solid #35465d; border-radius:8px; font-size:var(--impact-legend-size); }
.impact-map-legend summary { display:flex; align-items:center; justify-content:space-between; gap:20px; cursor:pointer; list-style:none; font-weight:700; color:#DCE5F5; }
.impact-map-legend summary::-webkit-details-marker { display:none; }
.impact-map-legend summary::after { content:'+'; font-size:1.2em; line-height:1; }
.impact-map-legend[open] summary::after { content:'−'; }
.impact-map-legend-items { display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.impact-dot { display:inline-block; width:9px; height:9px; border-radius:50%; background:var(--impact-color); margin-right:6px; }
.impact-detail-tabs { display:flex; gap:6px; margin-bottom:8px; }
.impact-detail-tabs button { flex:1; font-size:var(--impact-text-size); font-weight:600; border:1px solid #2a384b; border-radius:5px 5px 0 0; padding:10px 5px; background:#1c2738; color:#b4c4df; cursor:pointer; }
.impact-detail-tabs button.is-active { background:#dce7ff; color:#3c68d9; }
.impact-view [hidden] { display:none!important; }
.impact-card { background:linear-gradient(130deg,#192432,#111b28); border:1px solid #2f4057; border-radius:7px; padding:12px; margin-bottom:9px; min-width:0; }
.impact-card h2 { font-size:var(--impact-heading-size); margin:0 0 4px; }
.impact-card h3 { font-size:var(--impact-subheading-size); font-weight:600; color:#c6d4ed; margin:0 0 8px; }
.impact-section-heading { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.impact-section-heading h3 { margin:0; color:#DCE5F5; font-weight:700; font-size:var(--impact-heading-size); }
.impact-section-icon { display:grid; place-items:center; flex:0 0 auto; width:clamp(32px,calc(40 * var(--dashboard-unit)),44px); height:clamp(32px,calc(40 * var(--dashboard-unit)),44px); color:#ffb52e; background:rgba(255,181,46,.12); border:1px solid rgba(255,181,46,.3); border-radius:10px; }
.impact-section-icon svg { width:60%; height:60%; }
.impact-card p { color:#9eafc9; font-size:var(--impact-text-size); line-height:1.6; }
.impact-incident-heading > div { min-width:0; overflow-wrap:anywhere; }
.impact-incident-heading { display:flex; align-items:center; gap:12px; margin-bottom:12px; }
.impact-warning { display:grid; place-items:center; color:#f06979; background:#422331; width:43px; height:43px; font-size:25px; border-radius:5px; }
.impact-badge { margin-left:auto; background:#41242f; color:#f77c8b; border-radius:20px; padding:7px 10px; font-size:var(--impact-text-size); white-space:nowrap; }
.impact-mini-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:8px; }
.impact-mini-kpis>div { padding:8px; border:1px solid #293a50; border-radius:4px; min-width:0; }
.impact-mini-kpis span { font-size:var(--impact-text-size); color:#aebfda; display:block; margin-bottom:5px; }
.impact-mini-kpis b { font-size:var(--impact-detail-value-size); overflow-wrap:anywhere; }.impact-mini-kpis small { display:block; font-size:var(--impact-text-size); margin-top:4px; color:#98abc8; }
.impact-mini-kpis .impact-unit { font-size:var(--impact-filter-font-size); font-weight:400; }
.impact-view td small { font-size:var(--impact-text-size); }
.impact-accent { color:#f06979; }
.impact-large { font-size:var(--impact-detail-value-size); font-weight:700; margin-bottom:10px; }.impact-large small { font-size:var(--impact-text-size); font-weight:500; }
.impact-meter { height:9px; background:#101927; border-radius:5px; overflow:hidden; margin:7px 0; }.impact-meter>span { height:100%; display:block; background:var(--impact-color); border-radius:4px; }
.impact-stack { display:flex; height:14px; border-radius:6px; overflow:hidden; margin:8px 0 12px; }.impact-stack>span { background:var(--impact-color); }
.impact-age-grid { display:grid; grid-template-columns:repeat(3,1fr); margin:10px 0; }.impact-age-grid>div { padding:0 8px; border-right:1px solid #29364a; }.impact-age-grid>div:first-child { padding-left:0; }.impact-age-grid>div:last-child { border:0; }.impact-age-grid span { display:block; font-size:var(--impact-text-size); overflow-wrap:anywhere; color:#aebfda; }.impact-age-grid b { display:block; font-size:var(--impact-detail-value-size); margin:5px 0; }.impact-age-grid small { color:#9badc7; font-size:var(--impact-text-size); }
.impact-stats>div { display:flex; justify-content:space-between; gap:8px; margin:8px 0; font-size:var(--impact-text-size); }.impact-stats dt { color:#adbed9; }.impact-stats dd { text-align:right; }
.impact-table-wrap { overflow:auto; }.impact-view table { border-collapse:collapse; width:100%; font-size:var(--impact-text-size); text-align:left; }.impact-view th { color:#afc4e9; font-weight:500; background:#202d40; white-space:nowrap; }.impact-view th,.impact-view td { padding:6px; border-bottom:1px solid #243247; }.impact-view td small { display:block; color:#869bb8; margin-top:3px; max-width:170px; }.impact-view td .impact-meter { height:5px; min-width:45px; margin:4px 0 0; }
.impact-tag { display:inline-block; padding:3px 6px; border-radius:3px; color:var(--impact-color); background:var(--impact-tint); white-space:nowrap; }.impact-link,.impact-area-link { color:#7baeff; cursor:pointer; background:none; border:0; font:inherit; }.impact-link { float:right; }.impact-area-link { text-align:left; }.impact-area-link:hover { text-decoration:underline; }.impact-view tr.is-selected { background:#20314b; }
.impact-method { margin-top:4px; }.impact-method summary { cursor:pointer; color:#b8cbea; font-size:var(--impact-subheading-size); font-weight:600; }.impact-method p { margin-top:12px; }.impact-method b { color:#d6e0f4; }.impact-assumptions { display:flex; flex-wrap:wrap; gap:15px; margin-top:15px; }.impact-assumptions label { display:flex; flex-direction:column; gap:7px; font-size:var(--impact-text-size); }.impact-assumptions input { width:130px; }
.impact-empty { padding:18px; color:#9daec7; }.impact-pin { color:var(--impact-color); width:32px; height:32px; display:grid; place-items:center; }.impact-pin.green { color:#00ad46; }.impact-pin.amber { color:#f59e0b; }.impact-pin.danger { color:#ef4444; }.impact-map-icon { background:none; border:0; }
.impact-view button:focus-visible,.impact-view summary:focus-visible,.impact-view input:focus-visible,.impact-view select:focus-visible { outline:2px solid #89b4ff; outline-offset:3px; }
@media(min-width:1600px) { .impact-tables { grid-template-columns:1.4fr 1fr; } }
@media(max-width:1200px) { .impact-kpis { grid-template-columns:repeat(3,1fr); }.impact-layout { grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr); }.impact-map-card { height:650px; }.impact-snapshot { max-width:210px; text-align:right; } }
@media(max-width:800px) { .impact-layout { grid-template-columns:1fr; }.impact-map-card { position:relative; height:380px; }.impact-view .topbar { align-items:flex-start; gap:12px; } .impact-mini-kpis { grid-template-columns:1fr 1fr; }.impact-filters { gap:9px; }.impact-filters label { flex-direction:column; align-items:flex-start; }.app-tab-list { max-width:100%; overflow-x:auto; }.impact-kpi-icon { display:none; } }
@media(max-width:520px) { .impact-kpis { grid-template-columns:1fr 1fr; }.impact-snapshot { display:none; }.impact-incident-heading { flex-wrap:wrap; }.impact-badge { margin-left:0; } }

.impact-view .yellow { --impact-color:#e6d56c; --impact-tint:#3c3924; }

/* Temporary map-only presentation; remove impact-map-only to restore details. */
.impact-map-only .impact-kpis,
.impact-map-only .impact-insights { display: none; }
.impact-map-only .impact-layout { grid-template-columns: minmax(0, 1fr); }
.impact-map-only .impact-map-card { position: relative; height: max(380px, calc(100dvh - 235px)); }

/* Let drawing clicks pass through DUN and district boundaries to the map. */
.spatial-drawing .leaflet-dun-boundaries-pane .leaflet-interactive {
  pointer-events: none;
}

/* Map tools and controls (formerly spatial.css). */
.spatial-tools{position:absolute;top:12px;left:52px;z-index:1000;background:white;padding:12px;border-radius:8px;box-shadow:0 2px 12px #0003;max-width:330px;font:13px Arial}.spatial-tools button{padding:7px 10px;margin:3px;border:1px solid #ccd5d8;border-radius:4px;background:#f4f8fa;cursor:pointer}.spatial-tools button:disabled{opacity:.5;cursor:default}.spatial-tools p{margin:6px 0;line-height:1.4}.spatial-results{max-height:32vh;overflow:auto}.spatial-results summary{padding:8px;cursor:pointer;font-weight:bold}.spatial-results ul{padding-left:20px}.spatial-results li{margin:4px 0}.spatial-results li button{text-align:left}.spatial-label{background:#fffe;border:1px solid #ccc;font-size:11px}.spatial-error{color:#a32626}@media(max-width:600px){.spatial-tools{left:45px;max-width:240px;padding:8px}.spatial-results{max-height:22vh}}
.spatial-tools,.spatial-tools button{color:#18333b}.spatial-tools{box-sizing:border-box;width:330px}.spatial-tools p{color:#365760}.spatial-tools .spatial-error{color:#a32626}
.spatial-tools{position:static;top:auto;left:auto;z-index:auto;width:100%;max-width:none;background:#202732;border:1px solid #405064;box-shadow:none;padding:18px;border-radius:8px;color:#e3edf7;font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.spatial-tools button{color:#e3edf7;background:#273346;border-color:#53637b;font:inherit}.spatial-tools p{color:#aebfd1}.spatial-tools .spatial-error{color:#ffaaa0}.spatial-results{max-height:none;overflow:visible}.spatial-results ul{padding-left:16px}.spatial-results summary{border-bottom:1px solid #405064}.spatial-results li button{margin:0;padding:5px 8px}.panel-tabs{overflow-x:auto}.panel-tab{min-width:100px}@media(max-width:600px){.main{grid-template-columns:1fr;grid-template-rows:minmax(260px,48%) minmax(0,1fr)}.right-panel{min-height:0}.spatial-tools{padding:12px;width:100%;max-width:none}.spatial-results{max-height:none}.panel-tab{min-width:110px}}
.clear-area-results{padding:6px 12px;background:#273346;color:#e3edf7;border:1px solid #53637b;border-radius:5px;font:inherit;cursor:pointer}.clear-area-results:hover{background:#35445b}@media(max-width:600px){.filters{height:auto;min-height:50px}.main{height:calc(100dvh - 160px)}}
.map-search-form{display:grid;gap:10px;margin-top:16px}.map-search-form input{width:100%;min-width:0;padding:10px;background:#141d29;color:#e3edf7;border:1px solid #53637b;border-radius:5px;font:inherit}.map-search-results{list-style:none;padding:0}.map-search-results button{width:100%;text-align:left;margin:4px 0;padding:10px}.map-search-results button[aria-pressed="true"]{border-color:#ffb000;background:#493b1c}#landslideView .leaflet-tile-pane{filter:none}
.basemap-select{max-width:100%;padding:6px 10px;border:1px solid #53637b;border-radius:5px;background:#273346;color:#e3edf7;font:inherit}#landslideView>.filters{height:auto;min-height:50px}#landslideView{display:flex;flex-direction:column;min-height:0}#landslideView[hidden]{display:none}#landslideView>.main{flex:1;min-height:0;height:auto}
#landslideView{height:calc(100dvh - 68px)}#landslideView>.topbar,#landslideView>.filters{flex-shrink:0}@media(max-width:900px){#landslideView{height:calc(100dvh - 64px)}}
#landslideView #landslideBasemap{box-sizing:border-box;appearance:none;-webkit-appearance:none;width:260px;max-width:100%;height:40px;min-height:40px;padding:9px 36px 9px 12px;font-family:inherit;font-size:14px;font-weight:400;line-height:20px;color:#e3edf7;background-color:#273346;background-image:linear-gradient(45deg,transparent 50%,#b9c8dc 50%),linear-gradient(135deg,#b9c8dc 50%,transparent 50%);background-position:calc(100% - 17px) 17px,calc(100% - 12px) 17px;background-size:5px 5px;background-repeat:no-repeat;border:1px solid #53637b;border-radius:6px;cursor:pointer}#landslideView #landslideBasemap:focus-visible{outline:2px solid #89b4ff;outline-offset:2px}#landslideView .filter-group:has(#landslideBasemap){align-items:center;gap:9px}#landslideView #landslideBasemap option{background:#273346;color:#e3edf7}
.area-category-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;margin:14px 0}.spatial-tools .area-category-tabs button{min-width:0;margin:0;padding:9px 4px;overflow-wrap:anywhere;font-size:12px}.spatial-tools .area-category-tabs button[aria-selected="true"]{background:#dbeaff;border-color:#90b8f5;color:#15273e}.area-filter{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px;align-items:center}.area-filter label{grid-column:1/-1;color:#b9c8dc}.area-filter input{width:100%;min-width:0;padding:8px;border-radius:5px;border:1px solid #53637b;color:#e3edf7;background:#141d29;font:inherit}.area-filter button{margin:0}.area-map-toggle{display:flex;gap:7px;align-items:center;margin:12px 0}.area-pager{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:10px 0}.area-pager span{font-size:12px;color:#b9c8dc}.spatial-results .area-page-list{list-style:none;padding:0;max-height:340px;overflow-y:auto}.area-page-list button{display:block;width:100%;text-align:left}.area-browser-note{font-size:12px;color:#aebfd1}@media(max-width:600px){.area-category-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}.spatial-results .area-page-list{max-height:260px}}
#searchPanel .map-search-results{max-height:none;overflow:visible;margin-top:8px}#searchPanel .map-search-results button{margin:3px 0;padding:6px 9px;font-size:13px;line-height:1.35}#searchPanel .map-search-form{gap:7px;margin-top:10px}#searchPanel.spatial-tools{padding:14px}
#landslideView .spatial-results .area-page-list,#landslideView #mapSearchResults{max-height:none;overflow:visible}
#searchPanel .map-search-results button{display:block;padding:4px 8px;margin:2px 0;font-size:13px;line-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#searchPanel.spatial-tools{padding:12px}#searchPanel .map-search-form{gap:5px;margin-top:8px}#searchPanel #mapSearchStatus{font-size:12px;line-height:1.35;margin:6px 0}
#landslideBoundaries{font-size:14px}

/* Haze Map tab: title bar like the other views, the embedded haze-map/ app fills the rest. */
/* Map fills the space below the filters, like the right panel; AI Overview is below it (scroll). */
.rainfall-map-wrap { position:relative; flex:0 0 calc(100% - var(--ai-peek)); height:calc(100% - var(--ai-peek)); min-height:340px; }
/* How much of the AI Overview card shows below the map, so users can see there is more to scroll to. */
#landslideView .map-panel { --ai-peek:72px; }
#landslideView .map-panel { display:flex; flex-direction:column; min-width:0; overflow-y:auto; scroll-behavior:smooth; }
.rainfall-map-wrap .zoom-btns { bottom:28px; }
.rainfall-card { scroll-margin-top:0; outline:none; }
.rainfall-card:focus-visible { outline:2px solid var(--accent); outline-offset:-3px; }
.rainfall-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.rainfall-heading h2 { font-size:18px; font-weight:650; margin:0 0 5px; }
.rainfall-heading .card-sub { font-size:13px; margin:0; line-height:1.5; }
.rainfall-controls { display:flex; align-items:flex-end; flex-wrap:wrap; gap:10px; margin-top:18px; }
.rainfall-controls>label { display:flex; flex-direction:column; gap:5px; font-size:13px; color:var(--text-muted); }
.rainfall-card input[type="month"],.rainfall-card input[type="date"],.rainfall-card button,.rainfall-node-picker>summary { min-height:34px; padding:7px 10px; font:inherit; font-size:13px; color:var(--text); background:var(--surface-raised); border:1px solid var(--border); border-radius:5px; }
.rainfall-card button,.rainfall-node-picker>summary { cursor:pointer; }
.rainfall-card button:hover { border-color:var(--accent); }
.rainfall-card button:focus-visible,.rainfall-card input:focus-visible,.rainfall-node-picker>summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.rainfall-node-picker { position:relative; font-size:13px; }
.rainfall-node-picker>summary { list-style:none; min-width:130px; }
.rainfall-node-picker>summary::-webkit-details-marker { display:none; }
.rainfall-node-picker>summary::after { content:'▾'; margin-left:12px; color:var(--text-muted); }
#rainfallNodeCount { color:var(--text-muted); margin-left:8px; }
.rainfall-node-options { position:absolute; top:calc(100% + 6px); left:0; z-index:20; width:290px; max-width:75vw; padding:8px; background:var(--surface-raised); border:1px solid var(--border); border-radius:6px; box-shadow:0 8px 24px #0006; }
.rainfall-node-options label { display:flex; align-items:center; gap:9px; padding:9px 5px; cursor:pointer; }
.rainfall-node-options input { accent-color:var(--accent); }
.rainfall-status { color:var(--text-muted); font-size:13px; margin:12px 0 5px; min-height:18px; }
.rainfall-chart-wrap { position:relative; height:270px; min-width:0; }
.rainfall-empty { position:absolute; inset:25px 20px 35px 55px; display:grid; place-content:center; text-align:center; padding:18px; background:#20262feF; color:var(--text-muted); font-size:13px; line-height:1.6; pointer-events:none; }
.rainfall-empty[hidden] { display:none; }
.rainfall-legend { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin:8px 0; }
.rainfall-legend button { background:transparent; border-color:transparent; padding:5px 8px; }
.rainfall-legend button::before { content:''; display:inline-block; width:16px; height:3px; background:var(--node-color); vertical-align:middle; margin-right:6px; }
.rainfall-legend button.is-highlighted { border-color:var(--node-color); }
.rainfall-legend button[aria-pressed="true"] { border-color:var(--node-color); background:var(--surface-raised); font-weight:650; }
.rainfall-legend button[hidden] { display:none; }
.rainfall-hint { color:var(--text-muted); font-size:13px; line-height:1.6; margin:8px 0; }
.rainfall-anomaly-symbol { display:inline-block; width:18px; height:16px; vertical-align:-3px; }
.rainfall-anomaly-symbol svg { display:block; width:100%; height:100%; }
/* Map anomaly: dashed red ring around the (risk-coloured) node, warning triangle above-right. */
.rainfall-map-anomaly { background:none; border:0; }
.rainfall-anomaly-ring { position:absolute; inset:0; border:2px dashed #e5484d; border-radius:50%; pointer-events:none; }
.rainfall-anomaly-warning { position:absolute; right:-12px; top:-16px; width:22px; height:20px; filter:drop-shadow(0 1px 2px #0009); }
.rainfall-anomaly-warning svg { display:block; width:100%; height:100%; }
.rainfall-tooltip-anomaly { color:#ff9592; }
.rainfall-reading-heading { display:flex; align-items:center; flex-wrap:wrap; gap:8px; border-top:1px solid var(--border); margin-top:18px; padding-top:16px; }
.rainfall-reading-heading h3 { font-weight:600; margin:0 auto 0 0; }
.rainfall-reading-date { font-size:16px; color:var(--text-muted); }
.rainfall-reading-date strong { color:var(--text); font-weight:600; }
.rainfall-reading-options { display:flex; flex-wrap:wrap; gap:6px; margin:12px 0; }
.rainfall-reading-options button[aria-pressed="true"] { color:#dbeaff; background:#263f5d; border-color:var(--accent); }
.rainfall-details { padding:14px; background:var(--surface-raised); border:1px solid var(--border); border-radius:7px; font-size:13px; }
.rainfall-details h4 { font-size:13px; margin:0 0 7px; }
.rainfall-detail-status { color:var(--text-muted); margin:0; line-height:1.6; }
.rainfall-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin:16px 0 0; }
.rainfall-metrics dt { color:var(--text-muted); font-size:13px; line-height:1.5; }
.rainfall-metrics dd { color:var(--text); font-size:15px; margin:5px 0 0; font-variant-numeric:tabular-nums; }
.rainfall-reason { margin:16px 0 5px; color:#dac6f2; line-height:1.6; }
.rainfall-confidence { margin:0; color:var(--text-muted); font-size:13px; }
@media(max-width:1000px) { .rainfall-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) {
  #landslideView>.main { display:flex; flex-direction:column; overflow-y:auto; }
  #landslideView .map-panel { flex:0 0 auto; overflow:visible; }
  #landslideView .right-panel { flex:0 0 auto; min-height:450px; overflow:visible; }
  #landslideView .panel-tab-viewport { overflow:visible; }
  .rainfall-map-wrap { height:360px; }
  .rainfall-heading { flex-wrap:wrap; }
  .rainfall-chart-wrap { height:260px; }
}

.haze-view { display: flex; flex-direction: column; height: calc(100dvh - 68px); }
.haze-view > .topbar { flex-shrink: 0; }
.haze-view iframe { display: block; flex: 1; width: 100%; min-height: 0; border: 0; }
@media (max-width: 900px) { .haze-view { height: calc(100dvh - 64px); } }

/* Live river & rain stations on the alert map (GET /api/alerts) */
.live-station-control {
  display: grid;
  gap: 6px;
  max-width: 260px;
  padding: 9px 11px;
  color: #dbe6f2;
  background: rgba(17, 23, 31, 0.92);
  border: 1px solid #354252;
  border-radius: 9px;
  font-size: 12px;
}

.live-station-control label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  cursor: pointer;
}

.live-station-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.live-station-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.live-station-legend i {
  width: 10px;
  height: 10px;
  border: 1px solid #fff;
  border-radius: 50%;
}

.live-station-control small {
  color: #93a4b8;
}

/* AI Overview sits under the landslide map. */
#landslideView .ai-overview-card { flex:0 0 auto; margin:16px; padding:22px; }

/* Search Area tab: same card + heading as Risk Prediction / Population Impact,
   with each tool as an inset section like the population breakdown. */
#areaPanel .spatial-tools,
#areaPanel #areaDunCoverage { padding:16px; background:#1b2129; border:1px solid var(--border); border-radius:10px; box-shadow:none; color:var(--text); font:inherit; font-size:14px; line-height:1.5; }
#areaPanel #areaDunCoverage::before { display:none; }
#areaPanel > * + * { margin-top:14px; }
#areaPanel .area-section-title,
#areaPanel #areaDunCoverage h4 { margin:0 0 12px; color:#dce7f4; font-size:17px; font-weight:650; line-height:1.35; }
#areaPanel .spatial-tools p,
#areaPanel #mapSearchStatus { color:var(--text-muted); font-size:13px; line-height:1.5; }
#areaPanel .spatial-tools button { padding:7px 12px; margin:0 6px 6px 0; color:var(--text); background:var(--surface-raised); border:1px solid var(--border); border-radius:6px; font-size:13px; cursor:pointer; }
#areaPanel .spatial-tools button:hover:not(:disabled) { border-color:var(--accent); }
#areaPanel .spatial-tools button:disabled { opacity:.5; cursor:default; }
#areaPanel .spatial-tools button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#areaPanel .map-search-form label { color:var(--text-muted); font-size:13px; }
#areaPanel .map-search-form input { background:#141a21; border-color:var(--border); border-radius:6px; }
#areaPanel #searchPanel .map-search-results button { margin:3px 0; }
#areaPanel .spatial-tools .area-category-tabs button { margin:0; padding:9px 4px; font-size:12px; }
#areaPanel .spatial-tools .area-category-tabs button[aria-selected="true"] { background:#dbeaff; border-color:#90b8f5; color:#15273e; }
#areaPanel .spatial-tools .area-filter button { margin:0; }
#areaPanel .spatial-tools .map-search-results button[aria-pressed="true"] { border-color:#ffb000; background:#493b1c; }

/* Rainfall Monitoring tab in the landslide right panel */
#rainfallSection .rainfall-controls { margin-top:0; }
#rainfallSection .rainfall-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); }

/* Map tooltips wrap long text (e.g. a station's node list) instead of running off the map. */
/* Percent widths would resolve against Leaflet's zero-width tooltip pane, so use px/vw. */
#landslideView .leaflet-tooltip { white-space:normal; width:max-content; min-width:160px; max-width:min(380px, 70vw); overflow-wrap:break-word; }
#landslideView .leaflet-tooltip::before { display:none; } /* the pointer arrow is misplaced once a tooltip is shifted inside the map */
#landslideView .map-panel { overflow-x:hidden; }

/* Rainfall tab for a station without readings: hide node controls, show the message. */
#rainfallSection.is-no-data :is(.rainfall-node-picker, .rainfall-legend, .rainfall-hint, .rainfall-reading-heading, .rainfall-reading-options) { display:none; }
#rainfallSection.is-no-data .rainfall-empty { position:static; display:grid; min-height:160px; border:1px dashed var(--border); border-radius:8px; }
#rainfallSection.is-no-data .rainfall-chart-wrap { height:auto; }
#rainfallSection.is-no-data #rainfallChart { display:none; }

/* Forecast dropdown in the rainfall tab (styled after the Impact tab's "Calculation formula"). */
.rainfall-forecast { margin-top:18px; padding:14px 16px; background:#1b2129; border:1px solid var(--border); border-radius:8px; }
.rainfall-forecast summary { cursor:pointer; color:#b8cbea; font-size:16px; font-weight:600; }
.rainfall-forecast summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.rainfall-forecast[open] summary { margin-bottom:10px; }
.rainfall-forecast-source { margin:0 0 12px; color:var(--text-muted); font-size:13px; }
.rainfall-forecast-empty { margin:0; padding:18px; text-align:center; color:var(--text-muted); font-size:13px; border:1px dashed var(--border); border-radius:8px; }
.rainfall-forecast-empty[hidden], #rainfallForecastBody[hidden] { display:none; }
.rainfall-forecast-table { width:100%; border-collapse:collapse; font-size:13px; }
.rainfall-forecast-table th, .rainfall-forecast-table td { padding:7px 8px; text-align:left; border-bottom:1px solid var(--border); }
.rainfall-forecast-table th { color:var(--text-muted); font-weight:600; }
.rainfall-forecast-table td:last-child { color:var(--text); font-variant-numeric:tabular-nums; }
.rainfall-forecast-chart-wrap { position:relative; height:220px; margin-top:14px; min-width:0; }
.rainfall-forecast-summary { margin:12px 0 0; color:var(--text); font-size:13px; line-height:1.6; }
.rainfall-forecast-note { margin:10px 0 0; color:var(--text-muted); font-size:13px; line-height:1.6; }
.rainfall-forecast-note b { color:#d6e0f4; }

/* Rainfall tab holds two cards: monitoring + forecast. */
.rainfall-panel { display:flex; flex-direction:column; gap:14px; flex:0 0 auto; }
.rainfall-panel > .card { flex:0 0 auto; }
.rainfall-forecast-card .risk-heading { margin-bottom:16px; }
.rainfall-forecast-card .rainfall-forecast-chart-wrap { margin-top:16px; }
.rainfall-forecast-summary { margin-top:14px; }
.rainfall-forecast-summary h3 { margin:0 0 6px; color:#dce7f4; font-size:15px; line-height:1.4; }
.rainfall-forecast-summary ul { margin:0; padding-left:20px; color:var(--text); font-size:13px; line-height:1.7; }
.rainfall-reading-heading:focus { outline:none; }
#rainfallDetailsHeading { scroll-margin-top:8px; }
@media (min-width: 1001px) and (max-height: 900px) { .rainfall-panel > .card { padding:16px; } }

/* Tabs that hold more than one card (Risk Prediction, Search Area). */
.panel-stack { display:flex; flex-direction:column; gap:14px; flex:0 0 auto; }
.panel-stack > .card { flex:0 0 auto; }
#areaPanel.panel-stack > * + * { margin-top:0; }
#areaAnalysisCard > #areaDunCoverage { margin-top:14px; }
/* Map Search is its own card, so its tools are not an inset box. */
#areaPanel .search-tools { padding:0; background:none; border:0; border-radius:0; }
#areaPanel .search-tools .map-search-form { margin-top:0; }
@media (min-width: 1001px) and (max-height: 900px) { .panel-stack > .card { padding:16px; } }

/* Risk score + Avg FoS boxes: same height at every width, values aligned along the bottom. */
.score-row.has-fs { align-items:stretch; }
/* Grid rows stretch both boxes to the taller one when a label wraps; no fixed minimum height. */
.score-row .score-box-head { flex-wrap:nowrap; align-items:flex-start; }
.score-row .score-box-head .risk-badge { flex-shrink:0; white-space:nowrap; }
.score-row .score-label { line-height:1.35; }
.score-row .score-big { margin-top:auto; }
.score-label-wrap { display:flex; align-items:flex-start; gap:6px; min-width:0; }
.score-info-btn { display:inline-grid; place-items:center; flex-shrink:0; width:22px; height:22px; padding:0; color:var(--text-muted); background:none; border:0; border-radius:50%; cursor:pointer; }
.score-info-btn:hover { color:var(--accent); background:#58a6ff1a; }
.score-info-btn:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }

/* Risk score calculation card (styled after the Impact tab's "Calculation formula"). */
.risk-formula-card summary { cursor:pointer; color:#b8cbea; font-size:16px; font-weight:600; }
.risk-formula-card summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.risk-formula-card[open] summary { margin-bottom:12px; }
.risk-formula-card { scroll-margin-top:8px; }
.formula-table { width:100%; border-collapse:collapse; font-size:13px; }
.formula-table th, .formula-table td { padding:7px 8px; text-align:left; vertical-align:top; border-bottom:1px solid var(--border); line-height:1.5; }
.formula-table th { color:var(--text-muted); font-weight:600; }
.formula-table td:first-child { color:var(--text-muted); width:38%; }
.formula-table td:last-child { color:var(--text); }
.risk-formula-card p { margin:12px 0 0; color:#9eafc9; font-size:13px; line-height:1.7; }
.risk-formula-card b { color:#d6e0f4; }

.rainfall-forecast-summary li strong { color:#f4f8fc; font-weight:700; }

/* Risk score calculation card: intro above the table, note below it. */
.risk-formula-card .formula-intro { margin:0 0 12px; }
.risk-formula-card .formula-note { color:var(--text-muted); }
