:root {
  --bg: #0b0f14;
  --panel: #111821;
  --panel-2: #161f2a;
  --line: #223041;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #ff4d3d;
  --accent-2: #ff9f43;
  --prev: #5b7088;
  --land: #1b2734;
  --land-hi: #3a1d1d;
  --ok: #3ddc97;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1a1214 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}
a { color: var(--accent-2); }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; color: var(--text); margin-bottom: 12px; }

.demo-banner {
  background: #5a3b00; color: #ffe2a8; text-align: center;
  padding: 8px 16px; font-size: 13px; border-bottom: 1px solid #8a5a00;
}

.top {
  max-width: 1200px; margin: 0 auto; padding: 24px 16px 8px;
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: center; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pulse {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none;
  box-shadow: 0 0 0 0 rgba(255, 77, 61, .7); animation: pulse 2s infinite;
}
@keyframes pulse { to { box-shadow: 0 0 0 14px rgba(255, 77, 61, 0); } }

.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: 600 13px var(--sans); padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 16px 32px; display: grid; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.status { font: 12px var(--mono); color: var(--muted); }
.status.live::before { content: "● "; color: var(--ok); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.error { background: #2a1214; border: 1px solid #6b2a2a; color: #ffc9c4; border-radius: 12px; padding: 14px 16px; }
.error code { font-family: var(--mono); background: #3a181b; padding: 1px 5px; border-radius: 4px; }

/* Peta */
.map-wrap { position: relative; }
#map { width: 100%; height: auto; display: block; }
#map .land { fill: var(--land); stroke: #0b0f14; stroke-width: .5; }
#map .land.hi { fill: var(--land-hi); stroke: var(--accent); stroke-width: .8; }
#map .graticule { fill: none; stroke: #16202b; stroke-width: .5; }
#map .arc { fill: none; stroke: var(--accent); stroke-linecap: round; opacity: .85; }
#map .arc-bg { fill: none; stroke: var(--accent); stroke-opacity: .12; }
#map .dot { fill: var(--accent-2); }
#map .ring { fill: none; stroke: var(--accent-2); }
#map .home { fill: var(--accent); }
#map text { fill: var(--muted); font: 11px var(--sans); }

.map-list {
  position: absolute; right: 8px; top: 8px; margin: 0; padding: 10px 12px 10px 30px;
  background: rgba(11, 15, 20, .82); border: 1px solid var(--line); border-radius: 10px;
  font-size: 12px; max-width: 220px; backdrop-filter: blur(4px);
}
.map-list li { color: var(--muted); padding: 1px 0; }
.map-list li b { color: var(--text); font-weight: 600; }
.map-list li span { font-family: var(--mono); color: var(--accent-2); float: right; margin-left: 10px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font: 650 26px/1.2 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value.up { color: var(--accent); }
.kpi-value.down { color: var(--ok); }
.kpi-note { color: var(--muted); font-size: 12px; }

/* Tren */
#trend { width: 100%; height: auto; display: block; }
#trend .axis text { fill: var(--muted); font: 11px var(--mono); }
#trend .axis line, #trend .axis path { stroke: var(--line); }
#trend .line-now { fill: none; stroke: var(--accent); stroke-width: 2; }
#trend .area-now { fill: url(#trend-grad); }
#trend .line-prev { fill: none; stroke: var(--prev); stroke-width: 1.5; stroke-dasharray: 4 4; }
.legend { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-left: 8px; }
.sw-now { background: var(--accent); }
.sw-prev { background: var(--prev); }

/* Bar */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 4px 10px; align-items: center; }
.bar-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-val { font: 12px var(--mono); color: var(--muted); text-align: right; }
.bar-track { grid-column: 1 / -1; height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; width: 0; transition: width .6s ease; }
.empty { color: var(--muted); font-size: 13px; }

/* Tabel */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.arrow { color: var(--muted); }
tr.is-id td.side-id { color: var(--accent-2); font-weight: 600; }

.notes ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.notes li { margin: 4px 0; }
.notes strong { color: var(--text); }

footer { max-width: 1200px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 12px; }

.loading .kpi-value, .loading .bars, .loading #map, .loading #trend { opacity: .45; transition: opacity .2s; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  h1 { font-size: 18px; }
  .grid { grid-template-columns: 1fr; }
  .map-list { position: static; max-width: none; margin-top: 10px; }
  .kpi-value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse, #map .arc, #map .ring { animation: none !important; }
}

/* Peta provinsi */
.seg-sm button { padding: 5px 10px; font-size: 12px; }
.prov-lead { margin: 0 0 12px; }
.prov-lead strong { color: var(--text); }
.prov-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.prov-map-box { position: relative; min-width: 0; }
#prov-map { width: 100%; height: auto; display: block; }
#prov-map .prov { stroke: #0b0f14; stroke-width: .6; cursor: pointer; transition: opacity .15s; }
#prov-map .prov.nodata { fill: #18212c; }
#prov-map .prov:hover, #prov-map .prov.sel { stroke: #fff; stroke-width: 1.2; }
.prov-tip {
  position: absolute; pointer-events: none; background: rgba(11, 15, 20, .94); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 160px; transform: translate(-50%, calc(-100% - 12px));
}
.prov-tip b { display: block; color: var(--text); margin-bottom: 2px; }
.prov-tip span { display: block; color: var(--muted); font-family: var(--mono); }
.prov-legend { display: flex; align-items: center; gap: 8px; font: 11px var(--mono); color: var(--muted); margin-top: 6px; }
.prov-ramp { flex: 0 1 180px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #22303f, #ff9f43, #ff4d3d); }
.prov-list { margin: 0; padding: 0 0 0 26px; font-size: 13px; max-height: 360px; overflow-y: auto; }
.prov-list li { color: var(--muted); padding: 3px 0; cursor: default; }
.prov-list li b { color: var(--text); font-weight: 550; }
.prov-list li span { float: right; font-family: var(--mono); color: var(--accent-2); margin-left: 8px; }
.prov-list li.sel b { color: var(--accent-2); }
@media (max-width: 900px) {
  .prov-wrap { grid-template-columns: 1fr; }
  .prov-list { max-height: 300px; columns: 2; column-gap: 28px; }
}
@media (max-width: 520px) { .prov-list { columns: 1; } }
