/* Token: lihat DESIGN.md §2. Turunan design system InWebsite. */
:root {
  --bg: #FBFAF8;
  --bg-subtle: #F2F0EC;
  --surface: #FFFFFF;
  --border: #E3DFD8;
  --border-strong: #C9C3B8;
  --text: #14181F;
  --text-muted: #5A6472;
  --accent: #0B5FFF;
  --accent-hover: #0A4FD6;
  --accent-contrast: #FFFFFF;
  --accent-subtle: #E8F0FF;
  --focus: #0B5FFF;

  --padam: #E5484D;
  --padam-ink: #C62828;
  --padam-subtle: #FDECEC;
  --byarpet: #F5A524;
  --byarpet-ink: #8A5A00;
  --byarpet-subtle: #FBF1DC;
  --nyala: #2DA44E;
  --nyala-ink: #1B7A4B;
  --nyala-subtle: #E6F4EA;
  --none: #E9E5DE;

  --map-sea: #DDE6EF;
  --map-land: #E9E5DE;
  --map-edge: rgba(20, 24, 31, .18);
  --map-edge-strong: rgba(20, 24, 31, .42);

  --shadow: 0 8px 24px -12px rgba(20, 24, 31, .25);
  --font-head: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip b, .bar b, .rwtable td { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(var(--bg) 60%, rgba(251, 250, 248, 0));
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); padding: 4px; object-fit: contain; flex: none; }
.brand h1 .h1-sub { font: 600 12px/1 var(--font-body); color: var(--text-muted); margin-left: 6px; letter-spacing: 0; }
.brand h1 { margin: 0; font: 700 18px/1.2 var(--font-head); letter-spacing: -0.01em; }
.brand p { margin: 0; color: var(--text-muted); font-size: 13px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; min-height: 28px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }

/* ---------- peta ---------- */
#map { position: fixed; inset: 0; touch-action: none; background: var(--map-sea); }
#canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#canvas.dragging { cursor: grabbing; }
.zoom {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 4;
}
.zoom button {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 22px; line-height: 1; display: grid; place-items: center; color: var(--text);
}
.zoom button:hover { border-color: var(--border-strong); }
.zoom svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.legend {
  position: absolute; left: 16px; bottom: calc(var(--actions-h, 164px) + 8px); z-index: 4;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .94); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 12.5px; color: var(--text-muted);
}
.legend span { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.dot.padam { background: var(--padam); }
.dot.byarpet { background: var(--byarpet); }
.dot.nyala { background: var(--nyala); }
.dot.none { background: var(--none); box-shadow: inset 0 0 0 1px var(--border-strong); }
.hint {
  position: absolute; left: 50%; top: calc(112px + env(safe-area-inset-top)); transform: translateX(-50%);
  font-size: 12.5px; color: var(--text-muted); background: rgba(255, 255, 255, .92); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap; transition: opacity .4s; pointer-events: none;
}
@media (max-width: 560px) { .hint { display: none; } }

/* kredit + laporan masalah: DESIGN.md §6 */
.foot {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 6px;
  font-size: 12px; color: var(--text-muted); line-height: 1.3; max-width: 520px; width: 100%; margin: 0 auto;
}
.foot a, .foot button {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none; min-height: 28px;
  background: none; border: 0; padding: 0; font-size: 12px; color: var(--text-muted);
}
.foot a:hover, .foot button:hover { text-decoration: underline; }
.foot img { width: 16px; height: 16px; border-radius: 3px; }
.foot b { color: var(--text); font-weight: 600; }
.foot button { text-decoration: underline; text-underline-offset: 2px; flex-basis: 100%; justify-content: center; }

/* ---------- aksi bawah ---------- */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(251, 250, 248, 0), var(--bg) 35%);
}
.actions > button { max-width: 520px; width: 100%; margin: 0 auto; }
.primary, .ghost, .btn {
  min-height: 48px; border-radius: 12px; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; font-weight: 600;
  transition: background-color .15s, border-color .15s;
}
.primary { background: var(--accent); color: var(--accent-contrast); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.ghost:hover { border-color: var(--border-strong); }
.primary:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- panel ---------- */
.sheet {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  max-height: 58vh; max-height: 58dvh; display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0; box-shadow: 0 -12px 32px -12px rgba(20, 24, 31, .3);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 2px; flex: none; }
.close {
  position: absolute; top: 8px; right: 10px; width: 44px; height: 44px; border-radius: 10px;
  background: transparent; border: 0; font-size: 26px; color: var(--text-muted);
}
.close:hover { background: var(--bg-subtle); }
.sheet-body { overflow-y: auto; padding: 6px 16px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
@media (min-width: 900px) {
  .sheet { left: auto; right: 16px; top: 16px; bottom: 16px; width: 400px; max-height: none; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); }
  .grab { display: none; }
  .sheet-body { padding-top: 16px; }
  .actions { left: 0; right: auto; width: 420px; background: none; }
}

.sheet h2 { margin: 6px 44px 2px 0; font: 700 22px/1.25 var(--font-head); letter-spacing: -0.01em; }
.sub { color: var(--text-muted); margin: 0 0 14px; font-size: 13.5px; }
.sheet h3 { font-size: 11.5px; margin: 22px 0 8px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.status-big {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
}
.status-big .swatch { width: 6px; align-self: stretch; border-radius: 3px; flex: none; }
.status-big strong { font: 700 20px/1.2 var(--font-head); display: block; }
.status-big small { color: var(--text-muted); display: block; font-size: 13px; margin-top: 2px; }
.ink-padam { color: var(--padam-ink); }
.ink-byarpet { color: var(--byarpet-ink); }
.ink-nyala { color: var(--nyala-ink); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-subtle); color: var(--accent); margin-top: 6px; }
.bars { display: grid; gap: 6px; margin-top: 12px; }
.bar { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.bar .track { height: 8px; border-radius: 4px; background: var(--bg-subtle); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 4px; }
.bar b { text-align: right; color: var(--text); font-weight: 600; }

.claim { border: 1px solid var(--border); border-radius: 16px; padding: 14px; background: var(--surface); }
.claim img { width: 100%; max-height: 300px; object-fit: contain; border-radius: 10px; background: var(--bg-subtle); display: block; margin: 10px 0; }
.progress { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; font-size: 13px; color: var(--text-muted); }
.progress b { color: var(--text); }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border); }
.pips.yes i.on { background: var(--nyala); box-shadow: none; }
.pips.no i.on { background: var(--padam); box-shadow: none; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.btn { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.yes { background: var(--nyala-subtle); border-color: color-mix(in srgb, var(--nyala) 55%, transparent); color: var(--nyala-ink); }
.btn.no { background: var(--padam-subtle); border-color: color-mix(in srgb, var(--padam) 50%, transparent); color: var(--padam-ink); }
.btn.solid { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn.solid:hover { background: var(--accent-hover); }
.link { background: none; border: 0; color: var(--text-muted); text-decoration: underline; padding: 10px 0; font-size: 13px; min-height: 44px; }
.note { font-size: 13.5px; color: var(--text-muted); margin: 8px 0; }
.error { font-size: 13.5px; color: var(--padam-ink); background: var(--padam-subtle); border: 1px solid color-mix(in srgb, var(--padam) 40%, transparent); padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.okbox { font-size: 13.5px; color: var(--nyala-ink); background: var(--nyala-subtle); border: 1px solid color-mix(in srgb, var(--nyala) 40%, transparent); padding: 10px 12px; border-radius: 10px; margin: 10px 0; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; padding: 9px 12px; border-radius: 10px; background: var(--bg-subtle); font-size: 13.5px; }
.feed li .dot { margin-top: 6px; }
.feed small { color: var(--text-muted); display: block; font-size: 12.5px; }
.rwtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rwtable td, .rwtable th { padding: 7px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.rwtable th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice {
  min-height: 80px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-subtle);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; text-align: center;
}
.choice strong { font-size: 15px; font-weight: 600; }
.choice small { color: var(--text-muted); font-size: 11.5px; line-height: 1.25; }
.choice[aria-pressed="true"].padam { border-color: var(--padam); background: var(--padam-subtle); }
.choice[aria-pressed="true"].byarpet { border-color: var(--byarpet); background: var(--byarpet-subtle); }
.choice[aria-pressed="true"].nyala { border-color: var(--nyala); background: var(--nyala-subtle); }
.field { display: grid; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }
.field select, .field input {
  min-height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-subtle); color: var(--text);
  padding: 8px 12px; font: 400 16px var(--font-body); width: 100%;
}
.field select:hover, .field input:hover { border-color: var(--border-strong); }
.locbox { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--accent-subtle); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); }
.locbox svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; }
.ts { margin-top: 12px; min-height: 0; }
.photo-pick { display: grid; place-items: center; gap: 6px; min-height: 120px; border: 2px dashed var(--border-strong); border-radius: 12px; color: var(--text-muted); text-align: center; padding: 12px; cursor: pointer; background: var(--bg-subtle); }
.photo-pick img { max-height: 220px; max-width: 100%; border-radius: 10px; }
.list-kec { margin-top: 14px; }
.list-kec h3 { margin: 0 0 6px; }
.list-kel { display: grid; gap: 4px; }
.list-kel button {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; text-align: left;
  min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 0; background: var(--bg-subtle);
}
.list-kel button:hover { background: var(--border); }
.list-kel small { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.disclaimer { font-size: 12.5px; color: var(--text-muted); margin-top: 20px; border-top: 1px solid var(--border); padding-top: 12px; }
.disclaimer a { font-weight: 600; color: var(--text); }

.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translateX(-50%);
  max-width: min(92vw, 460px); padding: 10px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--nyala); font-size: 14px; box-shadow: var(--shadow);
}
.toast.err { border-left-color: var(--padam); }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .hint { transition: none; } }

/* ---------- form laporan masalah ---------- */
.opts { display: grid; gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-subtle); cursor: pointer; font-size: 14.5px;
}
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-subtle); }
.opt input, .check input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; margin: 0; }
.field textarea {
  min-height: 96px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-subtle); color: var(--text);
  padding: 10px 12px; font: 400 16px/1.45 var(--font-body); width: 100%; resize: vertical;
}
.field textarea:hover { border-color: var(--border-strong); }
.field small { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.check input { margin-top: 1px; }
.error .link { color: var(--padam-ink); padding: 6px 0 0; min-height: 0; }
.ring { display: inline-flex; gap: 2px; flex: none; }
.ring i { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.ring i:nth-child(1) { opacity: .25; }
.ring i:nth-child(2) { opacity: .55; }

/* ---------- pilihan layer: listrik / air / sinyal HP ---------- */
.layers { display: flex; gap: 4px; margin-top: 10px; padding: 3px; border-radius: 12px; background: var(--bg-subtle); border: 1px solid var(--border); width: fit-content; max-width: 100%; }
.layers button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 9px;
  border: 0; background: transparent; color: var(--text-muted); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.layers button svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.layers button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 24, 31, .12); }
.layers button[aria-selected="true"] svg { color: var(--accent); }
.ops { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.ops-label { font-size: 12.5px; color: var(--text-muted); margin-right: 2px; }
.ops button {
  min-height: 30px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255, 255, 255, .92);
  font-size: 12.5px; color: var(--text-muted);
}
.ops button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-subtle); color: var(--accent); font-weight: 600; }
.legend small { display: block; font-size: 11px; color: var(--text-muted); opacity: .85; margin-left: 4px; }
.legend span:has(small) { align-items: baseline; }
@media (max-width: 560px) { .legend small { display: none; } }
.hint { top: calc(var(--top-h, 150px) + 4px); }

/* ringkasan tiga layer di panel kelurahan */
.triple { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.triple button {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 10px; text-align: left;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-subtle);
}
.triple button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-subtle); }
.triple small { display: block; font-size: 11.5px; color: var(--text-muted); }
.triple b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.status-big .eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin: 0 0 2px; }

/* form laporan */
.h-icon { width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; margin-right: 6px; }
.req, .opt-tag { font-size: 10.5px; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.req { background: var(--accent-subtle); color: var(--accent); }
.opt-tag { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }
.hint-sm { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }
/* Header ringkas di HP: baris operator & ringkasan satu baris, bisa digeser ke samping. */
@media (max-width: 899px) {
  .ops, .summary { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .ops::-webkit-scrollbar, .summary::-webkit-scrollbar { display: none; }
  .ops button, .ops-label, .chip { flex: none; }
  .summary .chip:first-child { display: none; }
}
