:root {
  --ink: #1c1917;
  --muted: #6b645e;
  --line: #e7e2dc;
  --bg: #faf8f5;
  --panel: #ffffff;
  --high: #b91c1c;
  --nominal: #f97316;
  --low: #facc15;
  --accent: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: inline-flex; width: 26px; height: 30px; flex: none; }
.brand-mark svg { display: block; overflow: visible; }
.flame-glow { fill: #f97316; opacity: .25; transform-box: fill-box; transform-origin: center; }
.flame-outer, .flame-inner { transform-box: fill-box; transform-origin: 50% 100%; }

/* Nyala api: badan api bergoyang pelan, inti api berkedip lebih cepat, bayangan berdenyut */
@media (prefers-reduced-motion: no-preference) {
  .flame-outer { animation: flame-sway 1.8s ease-in-out infinite alternate; }
  .flame-inner { animation: flame-flicker .9s ease-in-out infinite alternate; }
  .flame-glow { animation: flame-glow 1.8s ease-in-out infinite alternate; }
}
@keyframes flame-sway {
  0%   { transform: scale(1, 1) skewX(0deg); }
  30%  { transform: scale(.97, 1.05) skewX(-3deg); }
  65%  { transform: scale(1.02, .97) skewX(2deg); }
  100% { transform: scale(.98, 1.04) skewX(-1deg); }
}
@keyframes flame-flicker {
  0%   { transform: scale(1, 1) translateY(0); opacity: 1; }
  50%  { transform: scale(.9, 1.12) translateY(-.4px); opacity: .9; }
  100% { transform: scale(1.06, .92) translateY(.3px); opacity: 1; }
}
@keyframes flame-glow {
  0%   { transform: scaleX(.85); opacity: .18; }
  100% { transform: scaleX(1.1); opacity: .32; }
}
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.status { font-size: 12.5px; color: var(--muted); text-align: right; }
.top-right { display: flex; align-items: center; gap: 14px; }
.btn-ghost {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.btn-ghost:hover { background: #fdf3ee; border-color: #f2c9b4; }
.btn-ghost:focus-visible, .btn:focus-visible, .seg input:focus-visible + span { outline: 2px solid var(--nominal); outline-offset: 2px; }

/* Panduan awal */
dialog#guide {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  border: 0; border-radius: 12px; padding: 0; color: var(--ink); background: var(--panel);
  box-shadow: 0 20px 60px rgba(28, 25, 23, .25);
}
dialog#guide::backdrop { background: rgba(28, 25, 23, .45); }
.guide { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.guide h2 { font-size: 18px; text-transform: none; letter-spacing: -.01em; color: var(--ink); margin: 0; }
.guide-lead { margin: 0; font-size: 14px; line-height: 1.5; }
.guide-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.guide-list li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 13.5px; line-height: 1.5; }
.gi {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: #f4f1ee; color: var(--muted);
}
.gi.warn { background: #fde8e1; color: var(--high); }
.chip { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.chip.high { background: var(--high); color: #fff; }
.chip.nominal { background: var(--nominal); color: #fff; }
.chip.low { background: var(--low); color: var(--ink); }
.guide-how { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); padding: 10px 12px; background: var(--bg); border-radius: 8px; }
.guide a { color: var(--high); }

/* Pilihan titik / kepadatan */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px 0; font-size: 13px; cursor: pointer; }
.seg input:checked + span { background: var(--ink); color: #fff; font-weight: 600; }

/* Komposisi */
.comp { display: flex; flex-direction: column; gap: 12px; }
.comp-row .comp-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.comp-row .comp-head span:last-child { color: var(--muted); }
.stack { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--line); }
.stack i { display: block; height: 100%; }
.comp-keys { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.comp-keys b { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.comp-keys em { font-style: normal; color: var(--ink); font-variant-numeric: tabular-nums; }
.chartbox.short { height: 130px; }

.heatbar { width: 110px; height: 10px; border-radius: 3px;
  background: linear-gradient(90deg, rgba(254,240,138,.3), #fde047, #fb923c, #dc2626, #7f1d1d); }
.heatlbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.status .ok { color: var(--ok); font-weight: 600; }
.status .bad { color: var(--warn); font-weight: 600; }

.layout { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.panel { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
.block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }

label { display: block; font-size: 13px; margin-bottom: 10px; }
select, input[type=date] {
  display: block; width: 100%; margin-top: 4px; padding: 7px 8px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
select:disabled { color: var(--muted); background: var(--bg); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
fieldset { border: 0; padding: 0; margin: 4px 0 8px; }
legend { font-size: 13px; margin-bottom: 4px; }
label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

.btn {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 13.5px; font-weight: 600;
  color: #fff; background: var(--ink); border: 0; border-radius: 6px; cursor: pointer;
}
.btn:hover { background: #3a3532; }
.btn:disabled { opacity: .6; cursor: progress; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { display: flex; flex-direction: column; padding: 8px 4px; }
.num { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.lbl { font-size: 11.5px; color: var(--muted); }
#tHigh { color: var(--high); }

table.rank { width: 100%; border-collapse: collapse; font-size: 13px; }
.rank th { font-weight: 500; color: var(--muted); text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.rank td { padding: 5px 4px; border-bottom: 1px solid #f2eee9; }
.rank tbody tr { cursor: pointer; }
.rank tbody tr:hover { background: #fdf3ee; }
.rank .r { text-align: right; font-variant-numeric: tabular-nums; }
.rank .bar { display: block; height: 3px; margin-top: 3px; background: var(--nominal); border-radius: 2px; opacity: .7; }
.muted { color: var(--muted); }
.chartbox { position: relative; height: 180px; }
.note { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }

.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.legend {
  position: absolute; left: 12px; bottom: 28px; background: rgba(255,255,255,.94); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 1px solid rgba(0,0,0,.35); vertical-align: -1px; }
.dot.high { background: var(--high); }
.dot.nominal { background: var(--nominal); }
.dot.low { background: var(--low); }
.warn { color: var(--warn); font-weight: 600; }

.maplibregl-popup-content { font: 13px/1.45 system-ui, sans-serif; padding: 10px 12px; }
.pop h3 { margin: 0 0 4px; font-size: 13.5px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 0; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; }

.foot { font-size: 11.5px; color: var(--muted); padding: 6px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.foot a { color: inherit; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .mapwrap { order: -1; }
  .panel { border-right: 0; overflow: visible; }
  body { height: auto; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .status { text-align: left; }
  .top-right { flex-direction: row-reverse; justify-content: flex-end; width: 100%; }
}
.guide h2:focus { outline: none; }

/* Pilihan bahasa */
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button {
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 5px 10px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.lang button:focus-visible { outline: 2px solid var(--nominal); outline-offset: -2px; }
