: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); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.tile {
  border: 1px solid var(--ring); border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; background: var(--surface);
}
.tile-hero { grid-column: 1 / -1; }
.tile-label { font-size: 12px; color: var(--ink-2); }
.tile-value { font-size: 18px; font-weight: 600; white-space: nowrap; }
.tile-hero .tile-value { font-size: 30px; }
.tile-sub { font-size: 12px; color: var(--muted); }

.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 { font-size: 11px; color: var(--muted); padding: 6px 12px 2px; }
.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; }
}
