/* =========================================================================
   VISUALISASI ANGIN — WILAYAH IKN
   Sistem desain: token surface/ink dari panduan data-viz; skala kecepatan
   angin memakai satu hue (ramp biru terang->gelap) karena kecepatan adalah
   data magnitudo terurut — bukan skala pelangi.
   ========================================================================= */

:root {
  /* Surfaces & ink */
  --plane:          #f9f9f7;
  --surface:        #fcfcfb;
  --surface-sunk:   #f4f4f1;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;
  --hairline:       rgba(11, 11, 11, 0.10);
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;

  /* Ramp biru (sequential/ordinal) — langkah 250/350/450/550/650 */
  --cls-1: #86b6ef;
  --cls-2: #5598e7;
  --cls-3: #2a78d6;
  --cls-4: #1c5cab;
  --cls-5: #104281;

  /* Chrome memakai langkah tergelap dari hue yang sama agar satu keluarga */
  --brand:      #0d366b;
  --brand-soft: #184f95;
  --accent:     #2a78d6;

  /* Status (palet status terpisah, tidak pernah dipakai sebagai warna seri) */
  --critical: #d03b3b;
  --warning:  #fab219;
  --warning-bg: #fdf5e3;

  /* Warna seri grafik (kategorikal, slot 1 & 2 — sudah lolos validasi) */
  --series-1: #2a78d6;
  --series-2: #eb6834;

  /* Palet status: dipakai HANYA untuk tingkat bahaya/AQI, tidak pernah
     sebagai warna seri, dan selalu disertai label teks. */
  --tone-good:     #0ca30c;
  --tone-warning:  #fab219;
  --tone-serious:  #ec835a;
  --tone-critical: #d03b3b;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.05), 0 1px 3px rgba(11, 11, 11, 0.06);
  --shadow-md: 0 4px 14px rgba(11, 11, 11, 0.10);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Permukaan tembus pandang di atas peta (legenda, kompas, kontrol layer) */
  --banner-ink: #6b4a06;
  --surface-veil: rgba(252, 252, 251, 0.95);
  --surface-veil-soft: rgba(252, 252, 251, 0.80);
  --header-bg: var(--brand);

  color-scheme: light;
}

/* =========================================================================
   MODE GELAP
   Bukan pembalikan otomatis: tiap langkah dipilih ulang untuk permukaan gelap
   #1a1a19 dan sudah divalidasi terhadap permukaan itu. Ramp kecepatan angin
   memakai langkah 600->200 (makin terang = makin kencang) agar nilai terendah
   justru menyatu dengan latar, sesuai kaidah skala magnitudo.
   ========================================================================= */
:root[data-theme="dark"] {
  --plane:        #0d0d0d;
  --surface:      #1a1a19;
  --surface-sunk: #232322;
  --ink:          #ffffff;
  --ink-2:        #c3c2b7;
  --ink-muted:    #898781;
  --hairline:     rgba(255, 255, 255, 0.12);
  --gridline:     #2c2c2a;
  --baseline:     #383835;

  --cls-1: #184f95;
  --cls-2: #256abf;
  --cls-3: #3987e5;
  --cls-4: #6da7ec;
  --cls-5: #9ec5f4;

  --brand:      #184f95;
  --brand-soft: #256abf;
  --accent:     #3987e5;

  --series-1: #3987e5;
  --series-2: #d95926;

  --warning-bg: #2e2410;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.50);

  --banner-ink: #f7c85a;
  --surface-veil: rgba(26, 26, 25, 0.94);
  --surface-veil-soft: rgba(26, 26, 25, 0.78);
  --header-bg: #12120f;

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plane:        #0d0d0d;
    --surface:      #1a1a19;
    --surface-sunk: #232322;
    --ink:          #ffffff;
    --ink-2:        #c3c2b7;
    --ink-muted:    #898781;
    --hairline:     rgba(255, 255, 255, 0.12);
    --gridline:     #2c2c2a;
    --baseline:     #383835;

    --cls-1: #184f95;
    --cls-2: #256abf;
    --cls-3: #3987e5;
    --cls-4: #6da7ec;
    --cls-5: #9ec5f4;

    --brand:      #184f95;
    --brand-soft: #256abf;
    --accent:     #3987e5;

    --series-1: #3987e5;
    --series-2: #d95926;

    --warning-bg: #2e2410;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.50);

    --banner-ink: #f7c85a;
  --surface-veil: rgba(26, 26, 25, 0.94);
    --surface-veil-soft: rgba(26, 26, 25, 0.78);
    --header-bg: #12120f;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Atribut hidden harus selalu menang atas display dari kelas apa pun. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--header-bg);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.header-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.header-titles h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.header-sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}
.header-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.header-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.header-meta-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
}

/* ---------- Banner (peringatan / status) ---------- */
.banner {
  padding: 10px 24px;
  font-size: 13px;
  text-align: center;
}
.banner-warning {
  background: var(--warning-bg);
  border-bottom: 1px solid var(--hairline);
  color: var(--banner-ink);
}
.banner-inline {
  margin: 14px 16px 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  text-align: left;
}
.banner code {
  background: rgba(127, 127, 127, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- Layout ---------- */
.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 16px;
  max-width: 1560px;
  margin: 16px auto;
  padding: 0 24px;
  align-items: start;
}
@media (max-width: 1020px) {
  .app-layout { grid-template-columns: 1fr; }
  .info-panel { order: 2; }
  .map-section { order: 1; }
}

.map-section,
.info-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.map-section { overflow: hidden; }

/* ---------- Toolbar: filter satu baris di atas peta ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.ctl {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ctl-end { margin-left: auto; }
.ctl-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Segmented control */
.btn-group {
  display: inline-flex;
  background: var(--surface-sunk);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-wrap: wrap;
}
.btn-group button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn-group button:hover { background: rgba(11, 11, 11, 0.05); color: var(--ink); }
.btn-group button.active {
  background: var(--surface);
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.10);
}
.btn-group button:focus-visible,
#basemap-select:focus-visible,
.btn-play:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#basemap-select {
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 190px;
}
#basemap-select:hover { border-color: var(--baseline); }

.btn-play {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  min-width: 118px;
}
.btn-play:hover { background: var(--brand-soft); }
.btn-play.playing {
  background: var(--critical);
  border-color: var(--critical);
}

/* ---------- Peta ---------- */
.map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10.5;
  min-height: 460px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.leaflet-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-sunk);
}

/* Canvas aliran angin: di atas tile & poligon, di bawah marker/panah. */
.wind-particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 450;
  pointer-events: none;
}

/* ---------- Simbol titik (gaya QGIS) ---------- */
.geo-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(11, 11, 11, 0.40));
  transition: transform 0.12s;
}
.geo-icon:hover { transform: scale(1.25); }
.geo-icon-fire { font-size: 17px; }
.geo-icon-water { font-size: 13px; }
.geo-icon-heli { font-size: 14px; }
.geo-icon-wb { font-size: 15px; }

.desa-label {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-shadow: 0 1px 2px #fff, 0 -1px 2px #fff, 1px 0 2px #fff, -1px 0 2px #fff;
  pointer-events: none;
}

/* ---------- Panah angin ---------- */
.wind-arrow-icon {
  cursor: pointer;
  filter: drop-shadow(0 1px 1.5px rgba(11, 11, 11, 0.45));
  animation: arrowFadeIn 0.3s ease-out;
}
@keyframes arrowFadeIn {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}
.wind-arrow-icon svg { display: block; overflow: visible; }
.wind-arrow-icon .arrow-shape {
  stroke: var(--surface-veil-soft);
  stroke-width: 0.9;
}
.wind-arrow-icon.cls-1 .arrow-shape { fill: var(--cls-1); }
.wind-arrow-icon.cls-2 .arrow-shape { fill: var(--cls-2); }
.wind-arrow-icon.cls-3 .arrow-shape { fill: var(--cls-3); }
.wind-arrow-icon.cls-4 .arrow-shape { fill: var(--cls-4); }
.wind-arrow-icon.cls-5 .arrow-shape { fill: var(--cls-5); }

.wind-arrow-icon .arrow-inner {
  animation-name: windFlow;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  transform-origin: center;
}
.wind-arrow-icon.cls-1 .arrow-inner { animation-duration: 2.6s; }
.wind-arrow-icon.cls-2 .arrow-inner { animation-duration: 2.0s; }
.wind-arrow-icon.cls-3 .arrow-inner { animation-duration: 1.5s; }
.wind-arrow-icon.cls-4 .arrow-inner { animation-duration: 1.1s; }
.wind-arrow-icon.cls-5 .arrow-inner { animation-duration: 0.8s; }
@keyframes windFlow {
  0%   { transform: translateY(3px) scaleY(0.94); opacity: 0.85; }
  50%  { transform: translateY(-2px) scaleY(1.05); opacity: 1; }
  100% { transform: translateY(3px) scaleY(0.94); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .wind-arrow-icon .arrow-inner { animation: none !important; }
  .wind-arrow-icon { animation: none !important; }
}

/* ---------- Tooltip Leaflet ---------- */
.leaflet-tooltip.wind-tooltip {
  background: rgba(11, 11, 11, 0.94);
  color: #fff;
  border: none;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  max-width: 240px;
  box-shadow: var(--shadow-md);
}
.leaflet-tooltip.wind-tooltip::before { display: none; }
.wind-tooltip b { color: #9ec5f4; font-variant-numeric: tabular-nums; }
.wind-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Overlay loading / error ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(249, 249, 247, 0.90);
  backdrop-filter: blur(2px);
  color: var(--ink);
  text-align: center;
  padding: 24px;
  z-index: 700;
}
.overlay p { margin: 0; max-width: 360px; font-size: 13.5px; }
.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--gridline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#retry-btn {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#retry-btn:hover { background: var(--brand-soft); }

/* ---------- Legenda ---------- */
.map-legend {
  position: absolute;
  left: 12px;
  bottom: 88px;
  z-index: 650;
  background: var(--surface-veil);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 208px;
  box-shadow: var(--shadow-sm);
}
.legend-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 7px;
}
.ramp {
  display: flex;
  gap: 2px;
  height: 10px;
  border-radius: 2px;
  overflow: hidden;
}
.ramp-step { flex: 1; }
.ramp-step.cls-1 { background: var(--cls-1); }
.ramp-step.cls-2 { background: var(--cls-2); }
.ramp-step.cls-3 { background: var(--cls-3); }
.ramp-step.cls-4 { background: var(--cls-4); }
.ramp-step.cls-5 { background: var(--cls-5); }
.ramp-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 10px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.ramp-unit {
  font-size: 10px;
  color: var(--ink-muted);
  text-align: right;
}
.legend-divider {
  height: 1px;
  background: var(--gridline);
  margin: 9px 0 7px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}
.legend-arrow { color: var(--cls-4); font-weight: 700; }
.legend-line { width: 16px; height: 0; display: inline-block; flex: none; }
.legend-line-ikn { border-top: 2.5px solid var(--brand); }
.legend-line-grid { border-top: 1.5px dashed var(--ink-muted); }
.legend-note {
  margin-top: 7px;
  font-size: 10px;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* ---------- Simbol peta SVG (menyamai QGIS) ---------- */
.map-symbol {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(11, 11, 11, 0.45));
  transition: transform 0.12s;
}
.map-symbol:hover { transform: scale(1.28); }
.map-symbol svg { display: block; overflow: visible; }
/* Titik yang sudah di-water bombing diberi lingkaran penegas */
.map-symbol.sym-sudah {
  border-radius: 50%;
  background: rgba(18, 160, 106, 0.22);
  box-shadow: 0 0 0 1.5px #12a06a;
}

/* Popup titik api */
.pop-status {
  display: inline-block;
  margin: 3px 0;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pop-sudah   { background: rgba(18, 160, 106, 0.16); color: #0d5c3f; }
.pop-rencana { background: rgba(208, 32, 32, 0.13);  color: #a52020; }
.pop-belum   { background: rgba(137, 135, 129, 0.18); color: #52514e; }
.pop-muted   { color: #898781; font-size: 11px; }
.pop-btn {
  margin-top: 7px;
  width: 100%;
  border: 1px solid var(--hairline);
  background: var(--surface-sunk);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pop-btn:hover { border-color: var(--accent); color: var(--brand-soft); }

/* Koordinat yang bisa diklik -> membuka Google Maps */
.pop-gmaps {
  display: inline-block;
  margin: 4px 0 2px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  color: var(--brand-soft) !important;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.pop-gmaps:hover { background: var(--accent); color: #fff !important; }

/* ---------- Tombol sembunyikan legenda ---------- */
.legend-toggle {
  position: absolute;
  left: 12px;
  bottom: 56px;
  z-index: 655;
  border: 1px solid var(--hairline);
  background: var(--surface-veil);
  color: var(--ink-2);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.legend-toggle:hover { color: var(--ink); border-color: var(--baseline); }
.map-legend.legend-collapsed { display: none; }

.map-compass {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 640;
  filter: drop-shadow(0 1px 3px rgba(11, 11, 11, 0.25));
}

/* ---------- Mode ambil koordinat dari peta ---------- */
.pick-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 690;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
}
.pick-hint button {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 3px 9px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.pick-hint button:hover { background: rgba(255, 255, 255, 0.26); }
.map-container.picking .leaflet-container { cursor: crosshair; }

/* Titik tambahan manual — dibedakan dari data sumber lewat cincin putus-putus */
.geo-icon-user {
  border: 1.5px dashed var(--brand);
  border-radius: 50%;
  background: var(--surface-veil-soft);
  box-sizing: border-box;
}

.legend-sym {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.legend-sym svg { width: 16px; height: 16px; }
.legend-hatch {
  width: 16px;
  height: 11px;
  flex: none;
  border: 1px solid #c0392b;
  background: repeating-linear-gradient(45deg,
    #c0392b 0 2px, rgba(208, 59, 59, 0.18) 2px 6px);
}
.legend-dot-hotspot {
  background: #e74c3c;
  border: 1px solid #a52020;
}

/* ---------- Ringkasan status water bombing ---------- */
.wb-block {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.wb-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.wb-summary { display: flex; flex-direction: column; gap: 6px; }
.wb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.wb-row b {
  margin-left: auto;
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.wb-sym {
  width: 20px;
  height: 20px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wb-sym svg { width: 18px; height: 18px; }
.wb-txt { line-height: 1.3; }
.wb-note {
  margin: 9px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* ---------- Panel informasi ---------- */
.info-panel { padding: 18px; }
.panel-head { margin-bottom: 16px; }
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.panel-context {
  margin: 4px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* Hero figure — satu angka utama per tampilan */
.hero {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--gridline);
}
.hero-label {
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.hero-figure {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--brand);
}
.hero-figure > span:first-child {
  font-size: 48px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.hero-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}

/* Stat tiles */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--gridline);
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 16px 0;
}
.stat {
  background: var(--surface);
  padding: 10px 11px;
}
.stat-label {
  font-size: 11px;
  color: var(--ink-muted);
  margin-bottom: 3px;
}
.stat-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.stat-value-text { font-size: 13.5px; }

.meta-list { margin: 0; }
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 12.5px;
}
.meta-row:last-child { border-bottom: none; }
.meta-row dt { color: var(--ink-muted); }
.meta-row dd { margin: 0; color: var(--ink-2); font-weight: 500; }

.panel-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--gridline);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-muted);
}
.panel-note code {
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.panel-note strong { color: var(--ink-2); }

/* ---------- Kontrol layer Leaflet ---------- */
.leaflet-control-layers {
  border: 1px solid var(--hairline) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-sm) !important;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--ink-2);
}
.leaflet-control-layers-expanded {
  padding: 10px 12px !important;
  max-width: 224px;
  background: var(--surface-veil);
}
.leaflet-control-layers-overlays label {
  margin-bottom: 5px;
  line-height: 1.35;
  cursor: pointer;
}
.leaflet-control-layers-overlays input { margin-right: 5px; }
.leaflet-control-scale-line {
  border-color: var(--baseline);
  color: var(--ink-2);
  background: var(--surface-veil-soft);
  font-size: 10.5px;
}
.leaflet-container { font-family: var(--font); }

/* ---------- Dialog tambah/kelola titik ---------- */
.btn-secondary {
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.btn-secondary:hover { border-color: var(--baseline); background: var(--surface-sunk); }
.btn-ghost {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--surface-sunk); }
.btn-danger {
  border: 1px solid rgba(208, 59, 59, 0.35);
  background: var(--surface);
  color: var(--critical);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: #fdf2f2; }
.btn-file { display: inline-flex; align-items: center; }

.ctl-actions { display: flex; gap: 8px; }

.point-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(11, 11, 11, 0.22);
  color: var(--ink);
  background: var(--surface);
  overflow: hidden;
}
.point-dialog::backdrop { background: rgba(11, 11, 11, 0.42); }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gridline);
  background: var(--surface);
}
.dialog-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}
.dialog-close {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.dialog-close:hover { color: var(--ink); background: var(--surface-sunk); }

.dialog-body {
  padding: 16px 18px 18px;
  overflow-y: auto;
  max-height: calc(86vh - 56px);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.field input,
.field select {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.field input[inputmode="decimal"] { font-variant-numeric: tabular-nums; }

.field-hint {
  margin: 0 0 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.field-hint code {
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 3px;
}
.field-feedback {
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.45;
}
.field-feedback.error {
  background: #fdf2f2;
  border: 1px solid rgba(208, 59, 59, 0.30);
  color: #8f2020;
}
.field-feedback.warn {
  background: var(--warning-bg);
  border: 1px solid rgba(250, 178, 25, 0.45);
  color: #6b4a06;
}
.field-feedback.ok {
  background: #eef7ee;
  border: 1px solid rgba(12, 163, 12, 0.30);
  color: #1c5c1c;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dialog-actions .spacer { flex: 1; }
.dialog-actions-end { margin-top: 14px; }
.dialog-divider {
  height: 1px;
  background: var(--gridline);
  margin: 18px 0 14px;
}

.saved-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.saved-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.saved-note { font-size: 11px; color: var(--ink-muted); }

.point-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 230px;
  overflow-y: auto;
}
.point-list:empty { display: none; }
.point-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  font-size: 12.5px;
}
.point-list li:last-child { border-bottom: none; }
.point-list li:nth-child(even) { background: #fafaf8; }
.pl-icon { font-size: 15px; flex: none; }
.pl-main { flex: 1; min-width: 0; }
.pl-name {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-coord {
  color: var(--ink-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.pl-actions { display: flex; gap: 4px; flex: none; }
.pl-actions button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.5px;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
}
.pl-actions button:hover { background: var(--surface-sunk); color: var(--ink); }
.pl-actions .pl-del:hover { background: #fdf2f2; color: var(--critical); }

.empty-note {
  margin: 0;
  padding: 14px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted);
  border: 1px dashed var(--gridline);
  border-radius: var(--radius-sm);
}
.dialog-note {
  margin: 14px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-muted);
}
.dialog-note strong { color: var(--ink-2); }

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .dialog-actions { gap: 6px; }
}

/* ---------- Toggle mode gelap ---------- */
.theme-toggle {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.20); }

/* ---------- Bagian analisis karhutla ---------- */
.analysis {
  max-width: 1560px;
  margin: 0 auto 20px;
  padding: 0 24px;
}
.analysis-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.analysis-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.analysis-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
}
.analysis-source {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.analysis-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13.5px;
}
.analysis-state p { margin: 0; text-align: center; }

.stat-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  margin: 0 0 16px;
}
.stat-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}
.stat-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.stat-badge.tone-good     { background: rgba(12, 163, 12, 0.14);  color: #0a7a0a; }
.stat-badge.tone-warning  { background: rgba(250, 178, 25, 0.18); color: #7a5405; }
.stat-badge.tone-serious  { background: rgba(236, 131, 90, 0.20); color: #9a4a22; }
.stat-badge.tone-critical { background: rgba(208, 59, 59, 0.16);  color: #a52020; }
.stat-badge.tone-muted    { background: var(--surface-sunk); color: var(--ink-muted); }
:root[data-theme="dark"] .stat-badge.tone-good     { color: #4fd14f; }
:root[data-theme="dark"] .stat-badge.tone-warning  { color: #f7c85a; }
:root[data-theme="dark"] .stat-badge.tone-serious  { color: #f0a082; }
:root[data-theme="dark"] .stat-badge.tone-critical { color: #f07070; }

.analysis-block {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.block-head { margin-bottom: 12px; }
.block-head h3 {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.block-note {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.5;
}
.block-note code {
  background: var(--surface-sunk);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.angstrom-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 8px;
}
.ang-day {
  border: 1px solid var(--gridline);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface);
}
.ang-day.tone-good     { border-left-color: var(--tone-good); }
.ang-day.tone-warning  { border-left-color: var(--tone-warning); }
.ang-day.tone-serious  { border-left-color: var(--tone-serious); }
.ang-day.tone-critical { border-left-color: var(--tone-critical); }
.ang-day.tone-muted    { border-left-color: var(--baseline); }
.ang-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ang-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.ang-label {
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.35;
  min-height: 2.7em;
}
.ang-meta {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.ang-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--gridline);
  font-size: 11px;
  color: var(--ink-muted);
}
.ang-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tone-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.tone-dot.tone-good     { background: var(--tone-good); }
.tone-dot.tone-warning  { background: var(--tone-warning); }
.tone-dot.tone-serious  { background: var(--tone-serious); }
.tone-dot.tone-critical { background: var(--tone-critical); }

/* ---------- Grafik ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 12px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 14px 8px;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
.chart-head h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.chart-unit { font-size: 11px; color: var(--ink-muted); }
.chart-legend {
  display: flex;
  gap: 14px;
  margin: 4px 0 2px;
  font-size: 11px;
  color: var(--ink-2);
}
.chart-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.chart-swatch {
  width: 10px;
  height: 2.5px;
  border-radius: 2px;
  display: inline-block;
}
.chart-plot { position: relative; }
.chart-svg {
  width: 100%;
  height: 175px;
  display: block;
  overflow: visible;
}
.chart-grid-line, .chart-grid { stroke: var(--gridline); stroke-width: 1; }
.chart-daysep { stroke: var(--gridline); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-tick, .chart-daylabel {
  fill: var(--ink-muted);
  font-size: 9px;
  font-family: var(--font);
}
.chart-line {
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.chart-cursor {
  stroke: var(--baseline);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.chart-hit { cursor: crosshair; }
.chart-empty {
  padding: 40px 10px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.chart-tip {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  background: rgba(11, 11, 11, 0.94);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 11.5px;
  line-height: 1.5;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.chart-tip .tip-time {
  color: #9ec5f4;
  font-weight: 600;
  margin-bottom: 2px;
}
.chart-tip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.chart-tip b { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .analysis { padding: 0 12px; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.app-footer {
  max-width: 1560px;
  margin: 0 auto 28px;
  padding: 4px 24px 0;
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.6;
}
.app-footer a { color: var(--brand-soft); }
.app-footer strong { color: var(--ink-2); }
.app-footer code {
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- Responsif ---------- */
@media (max-width: 640px) {
  .header-inner { padding: 14px 16px; }
  .header-meta { align-items: flex-start; text-align: left; }
  .app-layout { padding: 0 12px; gap: 12px; }
  .toolbar { gap: 12px; padding: 12px; }
  .ctl-end { margin-left: 0; }
  .map-container { aspect-ratio: 3 / 3.6; min-height: 400px; }
  .map-legend { max-width: 168px; font-size: 10.5px; padding: 9px 10px; }
  .app-footer { padding: 4px 16px 0; }
}

/* =========================================================================
   KUALITAS UDARA / ASAP & PELACAKAN ASAL ASAP
   Ramp PM2.5 memakai warna yang SAMA PERSIS dengan yang digambar di canvas
   (CONFIG.smoke.colors), supaya legenda dan peta tidak pernah berbeda warna.
   Warnanya tidak diubah di mode gelap: ini warna data di atas peta, bukan
   warna antarmuka.
   ========================================================================= */
:root {
  --smoke-1: #fff3c4;
  --smoke-2: #f9d648;
  --smoke-3: #f0932b;
  --smoke-4: #d03b3b;
  --smoke-5: #8e2f6b;
  --smoke-6: #5b1f47;

  --trace-back: #eb6834;
  --trace-fwd:  #7a3ea3;
}

/* Raster sebaran asap: di atas tile, DI BAWAH canvas aliran angin/asap. */
.smoke-raster-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 440;
  pointer-events: none;
}

/* ---------- Kontrol tanggal (dropdown + langkah harian) ---------- */
.date-ctl {
  display: inline-flex;
  align-items: stretch;
  gap: 4px;
}
#date-select {
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 158px;
}
#date-select:hover { border-color: var(--baseline); }
#date-select:focus-visible,
.step-btn:focus-visible,
#hour-range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.step-btn {
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-2);
  width: 30px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.step-btn:hover:not(:disabled) { border-color: var(--baseline); color: var(--ink); }
.step-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Penggeser jam ---------- */
.hour-ctl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 8px;
  background: var(--surface-sunk);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
#hour-range {
  width: 168px;
  accent-color: var(--brand);
  cursor: pointer;
}
#hour-readout {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 76px;
}

/* ---------- Legenda asap ---------- */
.ramp-step.smoke-1 { background: var(--smoke-1); }
.ramp-step.smoke-2 { background: var(--smoke-2); }
.ramp-step.smoke-3 { background: var(--smoke-3); }
.ramp-step.smoke-4 { background: var(--smoke-4); }
.ramp-step.smoke-5 { background: var(--smoke-5); }
.ramp-step.smoke-6 { background: var(--smoke-6); }
.ramp-scale-smoke { font-size: 9.5px; }
.legend-line-trace     { border-top: 2.5px dashed var(--trace-back); }
.legend-line-trace-fwd { border-top: 2.5px solid var(--trace-fwd); }

/* ---------- Mode pelacakan ---------- */
.trace-btn.active {
  background: var(--surface);
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.10);
}
.pick-hint-trace { background: #7a3410; }
.map-container.tracing .leaflet-container { cursor: crosshair; }

.trace-pin {
  color: var(--trace);
  font-size: 17px;
  line-height: 22px;
  text-align: center;
  text-shadow:
     0 0 3px rgba(252, 252, 251, 0.95),
     0 1px 2px rgba(11, 11, 11, 0.35);
}

/* ---------- Panel kualitas udara ---------- */
.air-block {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}
.air-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}
.air-figure {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.air-figure > span:first-child {
  font-size: 28px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.air-block .meta-row { padding: 5px 0; }
.air-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* ---------- Hasil pelacakan asal asap ---------- */
.trace-block {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--gridline);
  border-left: 3px solid var(--trace-back);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.trace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.trace-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.trace-lede {
  margin: 8px 0 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}
.trace-lede b { color: var(--ink); }
.trace-peak {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 9px 10px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}
.trace-peak-label {
  flex-basis: 100%;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.trace-peak-value {
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.trace-peak-meta {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.trace-table-wrap {
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
}
.trace-table,
.sector-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.trace-table th,
.sector-table th {
  position: sticky;
  top: 0;
  background: var(--surface-sunk);
  text-align: left;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
.trace-table td,
.sector-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--gridline);
  color: var(--ink-2);
}
.trace-table tr:last-child td,
.sector-table tr:last-child td { border-bottom: none; }
.trace-table .num,
.sector-table .num { text-align: right; }

.trace-sub {
  margin: 12px 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.trace-matches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trace-matches li {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}
.tm-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.tm-meta {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.5;
}
.trace-empty,
.trace-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-muted);
}
.trace-note { margin-top: 12px; }

/* ---------- Blok "dari arah mana asap datang" ---------- */
.sector-lede {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
}
.sector-lede b { color: var(--ink); }
.sector-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px;
}
.rose-svg {
  width: 210px;
  height: 210px;
  flex: none;
}
.rose-grid { stroke: var(--gridline); stroke-width: 1; }
.rose-wedge { stroke: var(--surface); stroke-width: 1; }
.rose-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--ink-muted);
  font-family: var(--font);
}
.sector-table {
  flex: 1;
  min-width: 260px;
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#sector-block .block-note { display: block; margin-top: 12px; }

/* Periodenya kini lebih dari sebulan, jadi strip harian dibatasi tingginya. */
.angstrom-strip {
  max-height: 348px;
  overflow-y: auto;
}

@media (max-width: 640px) {
  #hour-range { width: 130px; }
  #date-select { min-width: 132px; }
  .sector-body { gap: 12px; }
  .rose-svg { width: 170px; height: 170px; margin: 0 auto; }
}

.trace-coverage {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--banner-ink);
}

/* Sektor dengan sampel terlalu sedikit: ditampilkan, tetapi jelas dipudarkan
   supaya tidak terbaca sekuat sektor yang datanya tebal. */
.rose-wedge-thin { opacity: 0.35; }
.sector-table tr.sector-thin td { color: var(--ink-muted); }
.sector-flag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* =========================================================================
   LAHAN GAMBUT
   Kedalaman adalah besaran TERURUT, jadi rampnya satu hue cokelat terang ->
   gelap. Nilainya sama persis dengan CONFIG.peat.ramp di script.js supaya
   legenda dan poligon di peta tidak mungkin berbeda warna. Sengaja tidak
   diubah di mode gelap: ini warna data di atas peta, bukan warna antarmuka.
   ========================================================================= */
:root {
  --peat-1: #efe3cd;
  --peat-2: #dcc08a;
  --peat-3: #c3924f;
  --peat-4: #9c6428;
  --peat-5: #6b3f14;
}
.ramp-step.peat-1 { background: var(--peat-1); }
.ramp-step.peat-2 { background: var(--peat-2); }
.ramp-step.peat-3 { background: var(--peat-3); }
.ramp-step.peat-4 { background: var(--peat-4); }
.ramp-step.peat-5 { background: var(--peat-5); }
.ramp-scale-peat { font-size: 9.5px; }

/* Daftar ruas gambut pada hasil pelacakan */
.trace-peat {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.peat-row {
  position: relative;
  padding: 7px 9px 7px 22px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
}
.peat-swatch {
  position: absolute;
  left: 9px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  border: 1px solid rgba(11, 11, 11, 0.25);
}

/* Sorotan ketika lintasan melewati gambut dalam */
.trace-flag {
  margin: 0 0 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--peat-5);
  background: rgba(107, 63, 20, 0.10);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}
.trace-flag b { color: var(--ink); }
.trace-flag-soft {
  border-left-color: var(--peat-3);
  background: rgba(107, 63, 20, 0.06);
  color: var(--ink-muted);
}
