:root {
  --bg: #f7f4ee; --card: #ffffff; --ink: #2a2620; --muted: #6f675c; --line: #e4ddd1;
  --green: #3d5a2a; --green-2: #e8f0e3; --brown: #7a4b2a; --warn: #b7791f; --warn-bg: #fdf3e1;
  --bad: #b03a2e; --bad-bg: #fbe9e7; --ok: #2f7d32; --ok-bg: #e6f4e7; --r: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.35rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
a { color: var(--green); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .7rem; }
.err-text { color: var(--bad); }
pre { white-space: pre-wrap; font: inherit; margin: .3rem 0 0; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--green); color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.status { border: 0; border-radius: 999px; padding: .35rem .7rem; font-size: .8rem; background: rgba(255,255,255,.15); color: #fff; cursor: pointer; }
.status.off { background: #6b6257; } .status.err { background: var(--bad); } .status.busy { background: var(--warn); }

.app { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.bottomnav a { flex: 1; text-align: center; padding: .45rem 0 .5rem; text-decoration: none; color: var(--muted); font-size: 1.15rem; }
.bottomnav a span { display: block; font-size: .7rem; }
.bottomnav a.active { color: var(--green); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin-bottom: 1rem; }
.narrow { max-width: 420px; margin: 1.5rem auto; }
.center { text-align: center; }
.big-ok { font-size: 2.5rem; color: var(--ok); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .9rem; }
.btn.block { display: flex; width: 100%; margin-top: .6rem; }
.btn:disabled { opacity: .6; }
.btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; display: flex; flex-direction: column; gap: .3rem; }
.tile.lot { background: var(--warn-bg); }
.tile-title { font-weight: 600; }
.tile-count { font-size: 1.8rem; font-weight: 700; color: var(--brown); }
.tile-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.notice { background: var(--warn-bg); border: 1px solid #f0d9a8; border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0; }
.notice.bad { background: var(--bad-bg); border-color: #f2c4bd; }
.notice .btn { margin-left: .4rem; }

.search { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; margin-bottom: .6rem; background: #fff; }
.list { display: flex; flex-direction: column; gap: .4rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem .8rem; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; }
.checks .row { justify-content: flex-start; cursor: pointer; }
.checks input { width: 22px; height: 22px; flex: none; }
.badges { display: flex; flex-direction: column; gap: .2rem; align-items: flex-end; }
.pill { display: inline-block; border-radius: 999px; padding: .1rem .55rem; font-size: .75rem; background: var(--green-2); color: var(--green); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

.fld { display: block; margin-bottom: 1rem; }
.fld > span { display: block; font-weight: 600; margin-bottom: .3rem; }
.fld.inline { display: flex; align-items: center; gap: .5rem; }
.fld.inline > span { margin: 0; font-weight: 500; }
.fld input:not([type=checkbox]):not([type=radio]), .fld select, .fld textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: inherit; }
.fld.inline select { width: auto; }
.fld input.pin { font-size: 1.6rem; letter-spacing: .6em; text-align: center; }
.fld.check { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; background: var(--green-2); padding: .8rem; border-radius: 10px; }
.fld.check input { width: 24px; height: 24px; flex: none; }
.fld.check > span { flex: 1; margin: 0; }
.fld.check small { width: 100%; }
.req { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; }
.chip input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--brown); }
.ref .ref-search { margin-bottom: .35rem; }
.ref-all { display: block; margin-top: .3rem; }
.gps { display: flex; gap: .4rem; }
.gps input { flex: 1; }
.foto { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.foto-prev { max-width: 160px; border-radius: 8px; border: 1px solid var(--line); }
.calc { background: var(--green-2); border-radius: 10px; padding: .6rem .8rem; margin: .4rem 0 1rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #faf7f1; font-weight: 600; white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 5rem; transform: translateX(-50%); background: #2a2620; color: #fff; padding: .6rem 1rem;
  border-radius: 10px; max-width: 90vw; z-index: 10; font-size: .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.label { display: flex; gap: 10px; align-items: center; border: 1px dashed #999; padding: 10px; background: #fff; break-inside: avoid; page-break-inside: avoid; }
.label .qr { width: 110px; height: 110px; flex: none; }
.label .qr svg { width: 100%; height: 100%; }
.label-text { line-height: 1.3; }
.lot-id { font-weight: 700; font-size: 1.05rem; font-family: ui-monospace, Menlo, monospace; }

@media print {
  .no-print, .toolbar, .bottomnav, .topbar, .toast { display: none !important; }
  body, html { background: #fff; }
  .app { padding: 0; max-width: none; }
  .labels { grid-template-columns: 1fr 1fr; gap: 0; }
  .label { height: 66mm; border: 1px dashed #bbb; }
  @page { size: A4; margin: 8mm; }
}

/* Poligon, rekaman, KTP, premium */
.poli { display: flex; flex-direction: column; gap: .5rem; border: 1px solid var(--line); border-radius: 10px; padding: .7rem; background: #fcfbf8; }
.poli-body:empty { display: none; }
.poli-svg { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.peta { height: 320px; border-radius: 10px; border: 1px solid var(--line); }
.audio { display: flex; flex-direction: column; gap: .4rem; }
.audio audio { width: 100%; }
.foto.rahasia { border: 1px dashed var(--bad); border-radius: 10px; padding: .6rem; background: var(--bad-bg); }
.foto.rahasia .foto-prev { max-width: 260px; }
.prem-form { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details summary { cursor: pointer; margin-bottom: .4rem; }
code { background: #f1ece2; padding: 0 .25rem; border-radius: 4px; }

/* ===== Proporsi: tinggi kontrol seragam ===== */
:root { --h: 46px; --h-sm: 38px; }
.btn { min-height: var(--h); }
.btn.small { min-height: var(--h-sm); }
.fld input:not([type=checkbox]):not([type=radio]), .fld select, .search, .filterbar select {
  min-height: var(--h); padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: inherit;
}
.fld textarea { min-height: calc(var(--h) * 2); }
.fld input:focus, .fld select:focus, .fld textarea:focus, .search:focus, .filterbar select:focus {
  outline: 2px solid rgba(61, 90, 42, .35); border-color: var(--green);
}
.head-row h1 { margin: 0; }
.head-row { margin-bottom: .6rem; }
.tile-actions .btn { flex: 1; }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-top: .8rem; }
.gps { align-items: stretch; }
.gps .btn { min-height: var(--h); white-space: nowrap; }
.chip span { display: inline-flex; align-items: center; min-height: 40px; }
.fld.inline select { min-width: 160px; }
.toolbar .btn { flex: none; }

/* Filter & pencarian */
.filterbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 36%); gap: .5rem; margin-bottom: .3rem; }
.filterbar select { width: 100%; }
.filterbar .search { margin: 0; }
@media (max-width: 360px) { .filterbar { grid-template-columns: 1fr; } }

/* Baris daftar (juga pengganti tabel) */
.row { min-height: 56px; }
.row-btn { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.row-btn:hover, a.row:hover { border-color: #cfc5b3; background: #fdfcf9; }
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; overflow-wrap: anywhere; }
.row-right, .badges { display: flex; align-items: center; gap: .5rem; flex: none; }
.badges { flex-direction: row; }
.right-stack { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.chev { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.block { display: block; }
.nowrap { white-space: nowrap; }

/* Modal detail */
dialog.modal { padding: 0; border: 0; background: transparent; width: min(560px, calc(100vw - 24px)); max-width: none; max-height: 90vh; }
dialog.modal::backdrop { background: rgba(30, 25, 20, .5); }
.modal-card { background: #fff; border-radius: 14px; display: flex; flex-direction: column; max-height: 88vh; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem .8rem .7rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-body { overflow: auto; padding: 1rem; }
.modal-foot { padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.modal-foot .btn { margin: 0; }
.kv.detail { grid-template-columns: minmax(96px, 38%) 1fr; }
.kv.detail dt, .kv.detail dd { padding: .35rem 0; border-bottom: 1px solid #f1ece2; }
.kv dd { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  dialog.modal { width: 100vw; margin: auto 0 0; max-height: 92vh; }
  .modal-card { border-radius: 16px 16px 0 0; max-height: 92vh; }
}

details.notice summary { cursor: pointer; list-style: none; }
details.notice summary::-webkit-details-marker { display: none; }
details.notice[open] summary { margin-bottom: .4rem; }
.catatan { margin: 0; padding-left: 1.1rem; }
.catatan li { margin: .25rem 0; }
.btn { text-align: center; line-height: 1.25; }
@media (min-width: 700px) {
  .bottomnav { justify-content: center; }
  .bottomnav a { max-width: 170px; }
}
