:root {
  --hijau: #1f5f3f; --hijau2: #2e7d52; --hijau-muda: #e6f2ea;
  --teks: #1c2420; --abu: #6b7570; --garis: #dde3df; --bg: #f5f7f6;
  --sehat: #2e7d32; --kurang: #e0a100; --merana: #d35400; --mati: #9e2a2b;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--teks); background: var(--bg); font-size: 15px; }
#topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--hijau); color: #fff; }
#topbar h1 { flex: 1; font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.icon { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 6px; }
.badge { font-size: 11px; padding: 3px 7px; border-radius: 10px; background: rgba(255,255,255,.18); white-space: nowrap; }
.badge.ok { background: #43a047; } .badge.warn { background: #f9a825; color: #222; } .badge.err { background: #c62828; }
main { padding: 12px 12px 90px; max-width: 900px; margin: 0 auto; }
#tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--garis); padding-bottom: env(safe-area-inset-bottom); z-index: 1000; }
#tabbar a { flex: 1; text-align: center; padding: 7px 0 8px; color: var(--abu); text-decoration: none; font-size: 20px; line-height: 1.1; }
#tabbar a span { display: block; font-size: 11px; }
#tabbar a.active { color: var(--hijau); font-weight: 600; }
body.fullscreen #tabbar { display: none; }
.card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card h3 { font-size: 14px; margin: 12px 0 6px; color: var(--hijau); }
.muted { color: var(--abu); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.grow { flex: 1; }
label { display: block; font-size: 13px; color: var(--abu); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--garis); border-radius: 10px; font-size: 16px; background: #fff; color: var(--teks); }
input[type=checkbox] { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 10px; border: 0; background: var(--hijau); color: #fff; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.sec { background: var(--hijau-muda); color: var(--hijau); }
.btn.danger { background: #fdecea; color: #b71c1c; }
.btn.block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 2px; border-bottom: 1px solid var(--garis); display: flex; align-items: center; gap: 10px; }
.list li:last-child { border-bottom: 0; }
.list a { color: inherit; text-decoration: none; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--hijau-muda); color: var(--hijau); font-weight: 600; }
.pill.belum { background: #eceff1; color: #546e7a; } .pill.proses { background: #fff3cd; color: #8a6100; } .pill.selesai { background: #dff3e4; color: #1b5e20; }
.pill.baik { background: #dff3e4; color: #1b5e20; } .pill.sedang { background: #fff3cd; color: #8a6100; } .pill.jelek { background: #fdecea; color: #b71c1c; }
.map { height: 46vh; min-height: 280px; border-radius: var(--radius); margin-bottom: 12px; z-index: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 5px; border-bottom: 1px solid var(--garis); text-align: left; vertical-align: top; }
th { background: #f0f4f1; font-weight: 600; }
td.n, th.n { text-align: right; }
.scroll { overflow-x: auto; }
.empty { text-align: center; padding: 30px 10px; color: var(--abu); }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 2000; max-width: 90%; text-align: center; }
#toast.show { opacity: .95; }

/* Navigasi ke PU */
.nav-box { display: flex; align-items: center; gap: 14px; }
.arrow { width: 74px; height: 74px; border-radius: 50%; background: var(--hijau-muda); display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--hijau); transition: transform .3s; }
.big { font-size: 28px; font-weight: 700; }

/* Tally */
.kondisi-bar { position: sticky; top: 52px; z-index: 50; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--bg); padding: 6px 0; }
.kbtn { border: 2px solid transparent; border-radius: 10px; padding: 12px 2px; font-weight: 700; font-size: 13px; color: #fff; }
.kbtn.sehat { background: var(--sehat); } .kbtn.kurang { background: var(--kurang); } .kbtn.merana { background: var(--merana); } .kbtn.mati { background: var(--mati); }
.kbtn:not(.on) { opacity: .38; }
.kbtn.on { border-color: #111; box-shadow: 0 0 0 2px #fff inset; }
.jenis-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.jbtn { background: #fff; border: 1px solid var(--garis); border-radius: 12px; padding: 12px 10px; text-align: left; font-size: 15px; font-weight: 600; min-height: 72px; position: relative; color: var(--teks); }
.jbtn:active { background: var(--hijau-muda); }
.jbtn .cnt { position: absolute; right: 8px; top: 8px; font-size: 18px; color: var(--hijau); }
.jbtn .sub { display: block; font-size: 11px; font-weight: 400; color: var(--abu); margin-top: 4px; }
.jbtn.lokal { border-left: 5px solid #8d6e63; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.sehat { background: var(--sehat); } .dot.kurang { background: var(--kurang); } .dot.merana { background: var(--merana); } .dot.mati { background: var(--mati); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--hijau-muda); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 20px; color: var(--hijau); }
.stat span { font-size: 12px; color: var(--abu); }
.thumbs { display: flex; gap: 6px; overflow-x: auto; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.tn-box { text-align: center; padding: 16px; border-radius: var(--radius); background: var(--hijau-muda); }
.tn-box .big { font-size: 40px; color: var(--hijau); }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
@media print {
  #topbar, #tabbar, .noprint, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; font-size: 12px; }
}

.role-viewer .edit-only { display: none !important; }
.userrow select { width: auto; padding: 6px; font-size: 14px; }
