:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --sawit: #eb6834;
  --nonsawit: #2a78d6;
  --good: #0ca30c;
  --serious: #d03b3b;
  --hover: rgba(42, 120, 214, 0.08);
  --bar: #86b6ef;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --sawit: #d95926;
    --nonsawit: #3987e5;
    --hover: rgba(57, 135, 229, 0.14);
    --bar: #256abf;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { display: flex; height: 100vh; height: 100dvh; }
.panel {
  width: 380px; flex: none; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--ring);
}
.panel-head { padding: 20px 20px 4px; position: relative; }
.panel-body { padding: 0 20px 24px; }
.panel-toggle { display: none; }
.eyebrow { margin: 0 0 4px; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
h1 { font-size: 20px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 13px; margin: 0 0 8px; color: var(--ink); }
.lede { margin: 0 0 16px; color: var(--ink-2); }

.block { border-top: 1px solid var(--grid); padding-top: 14px; margin-bottom: 18px; }
.hint { margin: -4px 0 8px; font-size: 12px; color: var(--muted); }

.search { display: flex; gap: 6px; }
.search input {
  flex: 1; min-width: 0; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: inherit;
}
.search button, .leaflet-control button {
  padding: 7px 12px; border-radius: 6px; border: 1px solid var(--axis);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.search button:hover { background: var(--hover); }

.legend, .legend-keys, .downloads, .sources ul { list-style: none; padding: 0; margin: 0; }
.legend > li { margin-bottom: 8px; }
.legend label { cursor: pointer; }
.legend-keys { margin: 4px 0 0 24px; color: var(--ink-2); font-size: 13px; }
.legend-keys li { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.key { width: 16px; height: 12px; border-radius: 3px; flex: none; }
.key-sawit { background: var(--sawit); opacity: .75; }
.key-nonsawit { background: var(--nonsawit); opacity: .75; }
.key-kh { border: 2px dashed var(--ink); }
.key-ok { background: var(--good); opacity: .7; }
.key-bad { background: var(--serious); opacity: .7; }
.key-air { background: #898781; opacity: .6; }
.status-ico { width: 12px; text-align: center; font-weight: 700; font-size: 12px; margin-left: -4px; }

.kab-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kab-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px 4px; border-bottom: 1px solid var(--axis); }
.kab-table td { padding: 5px 4px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.kab-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kab-table tbody tr { cursor: pointer; }
.kab-table tbody tr:hover, .kab-table tbody tr:focus { background: var(--hover); outline: none; }
.kab-table tfoot td { font-weight: 600; border-bottom: 0; }
.bar { height: 6px; margin-top: 4px; border-radius: 0 3px 3px 0; display: flex; gap: 2px; }
.bar span { display: block; height: 100%; }
.bar .b-sawit { background: var(--sawit); }
.bar .b-non { background: var(--nonsawit); border-radius: 0 3px 3px 0; }
.bar .b-sawit:last-child { border-radius: 0 3px 3px 0; }

.top-list { margin: 0; padding-left: 22px; font-size: 13px; }
.top-list li { margin: 3px 0; }
.top-list button {
  background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit;
  font-variant-numeric: tabular-nums;
}
.top-list .muted { color: var(--muted); }

.downloads li { margin: 4px 0; }
.sources { font-size: 12.5px; color: var(--ink-2); }
.sources li { margin-bottom: 6px; }
.sources p { margin: 8px 0; }
.muted { color: var(--muted); }
code { font-size: 12px; }

.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--page); }
.loading {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--surface); color: var(--ink); border: 1px solid var(--ring);
  padding: 6px 14px; border-radius: 16px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.loading[hidden] { display: none; }

/* MapLibre theming */
.maplibregl-map { font: inherit; }
.maplibregl-popup-content {
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: 12px 14px;
  min-width: 230px; font-size: 13px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; padding: 0 6px; }
.hover-pop .maplibregl-popup-content { min-width: 0; padding: 4px 8px; font-size: 12px; pointer-events: none; }
.hover-pop .maplibregl-popup-tip { display: none; }
.pop-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.pop-sub { color: var(--ink-2); margin-bottom: 8px; }
.pop-big { font-size: 20px; font-weight: 600; }
.pop-table { border-collapse: collapse; width: 100%; }
.pop-table th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 2px 8px 2px 0; vertical-align: top; }
.pop-table td { text-align: right; font-variant-numeric: tabular-nums; padding: 2px 0; }
.pop-table td.txt { text-align: left; font-variant-numeric: normal; }
.pop-status { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; margin-bottom: 6px; }
.pop-status .dot { width: 10px; height: 10px; border-radius: 50%; }
.pop-note { color: var(--muted); font-size: 12px; margin-top: 8px; }
.filter-row { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.filter-row label { font-size: 13px; color: var(--ink-2); }
.filter-row select {
  flex: 1; min-width: 0; padding: 7px 10px; border-radius: 6px; font: inherit; font-weight: 600;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
.filter-row .pt-search { flex: 1; min-width: 0; position: relative; }
.filter-row label { width: 74px; flex: none; }
.ghost { border: 0 !important; background: none !important; color: var(--ink-2) !important; padding: 7px 8px !important; }
.pt-card {
  border: 1px solid var(--accent); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px;
  background: var(--hover);
}
.pt-card h2 { font-size: 15px; margin: 0 0 2px; }
.pt-card .pt-grup { color: var(--ink-2); font-size: 12.5px; margin-bottom: 8px; }
.pt-card .pt-big { font-size: 22px; font-weight: 600; }
.pt-card .pop-table { margin-top: 6px; font-size: 12.5px; }
.pt-card .pt-blok { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; }
.pt-card .pt-blok button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.theme { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 13px; margin-bottom: 8px; }
.theme label { cursor: pointer; }
.theme-legend { margin-left: 0 !important; }
.key-line { height: 0; border-top: 2px dashed; border-radius: 0; background: none !important; }
.key-ilok { border-color: #2a78d6; }
.key-gfw { border-color: #eb6834; }
.pop-pt { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--grid); }
.pop-pt h3 { font-size: 12px; font-weight: 600; margin: 0 0 4px; color: var(--ink-2); }
.pop-pt ul { margin: 0; padding: 0 0 0 16px; }
.pop-pt li { margin: 2px 0; }
.pt-link, .pop-pt .pt-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.src-tag { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 3px; border: 1px solid var(--axis); color: var(--ink-2); margin-left: 4px; vertical-align: 1px; }
/* Pemilih peta dasar (di atas peta) */
.bm-ctrl { display: flex; flex-direction: column; background: var(--surface); border-radius: 6px; overflow: hidden; }
.bm-ctrl button {
  border: 0; border-bottom: 1px solid var(--grid); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 12.5px; padding: 6px 12px; text-align: left; cursor: pointer; width: auto; height: auto;
}
.bm-ctrl button:last-child { border-bottom: 0; }
.bm-ctrl button:hover { background: var(--hover); }
.bm-ctrl button[aria-pressed="true"] { font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.bm-ctrl .bm-title, .bm-ctrl .bm-title:hover { font-size: 11px; color: var(--muted); padding: 6px 12px 2px; border-bottom: 0; cursor: default; background: var(--surface); }
.basemap { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.basemap label { cursor: pointer; }
.key-inline { display: inline-block; width: 10px; height: 8px; }
.hint.indent { margin: 2px 0 4px 24px; }
.back-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; }

@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .map-wrap { flex: 1 1 55%; }
  .panel { width: 100%; flex: 0 0 auto; max-height: 45%; border-right: 0; border-top: 1px solid var(--ring); }
  .panel.collapsed { max-height: 64px; overflow: hidden; }
  .panel-toggle {
    display: block; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 14px; border: 0; background: none; cursor: pointer;
  }
  .panel-toggle::after { content: ""; display: block; margin: 4px auto; width: 36px; height: 4px; border-radius: 2px; background: var(--axis); }
  .panel-head { padding-top: 22px; }
  .panel.collapsed .lede, .panel.collapsed .eyebrow { display: none; }
  .maplibregl-ctrl-attrib { font-size: 9px; line-height: 1.3; max-width: 100%; }
}
@media (forced-colors: active) {
  .key { forced-color-adjust: none; }
}

/* ---------- Arco Maps ---------- */
.block-first { border-top: 0; padding-top: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.block-head h2 { margin: 0; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12.5px; }
.link:hover { text-decoration: underline; }

.panel-head .search { margin: 0 0 14px; }
.combo { position: relative; flex: 1; min-width: 0; display: flex; }
.combo-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
  max-height: 320px; overflow-y: auto;
}
.combo-list li { padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--hover); }
.combo-list .nm { display: block; font-weight: 600; font-size: 13px; }
.combo-list .mt { display: block; font-size: 11.5px; color: var(--muted); }
.combo-list .empty { color: var(--muted); cursor: default; }
.combo-list .empty:hover { background: none; }

.tree details { border-bottom: 1px solid var(--grid); }
.tree details:last-child { border-bottom: 0; }
.tree summary {
  cursor: pointer; padding: 9px 0; font-weight: 600; font-size: 13px; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--muted); font-size: 11px; width: 10px; }
.tree details[open] > summary::before { content: "▾"; }
.tree summary .cnt { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.tree summary .cnt.on { color: var(--accent); font-weight: 600; }
.lyr-list { list-style: none; margin: 0 0 8px; padding: 0; }
.lyr { padding: 3px 0; }
.lyr-row { display: flex; align-items: flex-start; gap: 8px; }
.lyr-row input[type=checkbox] { margin: 3px 0 0; flex: none; }
.lyr-row label { flex: 1; min-width: 0; cursor: pointer; }
.lyr-title { display: block; }
.lyr-meta { display: block; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; margin-top: 3px; border: 1px solid rgba(0,0,0,.15); }
.sw.sw-line { height: 0; border: 0; border-top: 3px solid; border-radius: 0; margin-top: 9px; }
.sw.sw-dash { height: 0; border: 0; border-top: 2px dashed; border-radius: 0; margin-top: 9px; }
.sw.sw-pt { border-radius: 50%; width: 11px; height: 11px; margin: 4px 1px 0 2px; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.info-btn {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--axis); background: none; color: var(--ink-2);
  font: inherit; font-size: 11px; line-height: 1; cursor: pointer; margin-top: 1px;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--hover); color: var(--accent); border-color: var(--accent); }
.lyr-detail { margin: 6px 0 8px 22px; padding: 8px 10px; border-left: 2px solid var(--grid); font-size: 12.5px; color: var(--ink-2); }
.lyr-detail p { margin: 0 0 6px; }
.lyr-detail .legend-keys { margin: 0 0 6px; font-size: 12.5px; }
.lyr-detail .legend-keys li { align-items: flex-start; }
.lyr-detail .legend-keys .sw { margin-top: 2px; }
.lyr-detail .legend-keys .lg-n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; }
.lyr-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.lyr-tools label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lyr-tools input[type=range] { width: 90px; }
.lyr-src { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.pt-card .pt-rows { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; }
.pt-card .pt-rows li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--ring); }
.pt-card .pt-rows .n { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.maplibregl-popup { max-width: 340px !important; }
.maplibregl-popup-content { max-height: min(60vh, 460px); overflow-y: auto; padding: 0; }
.pop-head { position: sticky; top: 0; background: var(--surface); padding: 10px 34px 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--grid); z-index: 1; }
.pop-feat { padding: 10px 14px 12px; border-bottom: 1px solid var(--grid); }
.pop-feat:last-child { border-bottom: 0; }
.pop-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); margin-bottom: 3px; }
.pop-chip .dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.pop-feat .pop-title { font-size: 14px; line-height: 1.3; margin-bottom: 6px; }
.pop-feat .pop-table th { width: 42%; font-size: 12.5px; }
.pop-feat .pop-table td { text-align: left; font-size: 12.5px; word-break: break-word; }
.pop-feat .pop-table td.num { font-variant-numeric: tabular-nums; }
.pop-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.badge { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 3px; border: 1px solid var(--axis); color: var(--ink-2); margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.badge.warn { border-color: var(--serious); color: var(--serious); }
.zoom-hint { color: var(--serious); }

@media (max-width: 760px) {
  /* Pemilih peta dasar dilipat: hanya pilihan aktif yang tampak sampai judulnya diketuk */
  .bm-ctrl .bm-title, .bm-ctrl .bm-title:hover { cursor: pointer; padding: 5px 10px 0; }
  .bm-ctrl .bm-title::after { content: " ▾"; }
  .bm-ctrl:not(.open) button[data-bm][aria-pressed="false"] { display: none; }
  .bm-ctrl button[data-bm] { padding: 4px 10px 6px; }
  .bm-ctrl:not(.open) button[aria-pressed="true"] { box-shadow: none; }
  .maplibregl-popup { max-width: 300px !important; }
}
