:root {
  --paper: #eef2f0;
  --surface: #ffffff;
  --ink: #16211d;
  --muted: #5b6b65;
  --line: #d3ddd8;
  --brand: #0a6b5a;
  --brand-ink: #064a3e;
  --brand-soft: #dcefe9;
  --warn: #8a5300;
  --warn-bg: #fff1d6;
  --danger: #b3261e;
  --danger-bg: #fde8e6;
  --ok: #1b7f3b;
  --radius: 10px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101916;
    --surface: #17221e;
    --ink: #e7efec;
    --muted: #9bb0a8;
    --line: #2b3b35;
    --brand: #3fb59d;
    --brand-ink: #7fd8c3;
    --brand-soft: #173a32;
    --warn: #f2c26b;
    --warn-bg: #3b2c0c;
    --danger: #ff8b82;
    --danger-bg: #3d1916;
    --ok: #6fd18c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius);
  border: 1.5px solid var(--brand); background: var(--brand); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
}
@media (prefers-color-scheme: dark) { .btn { color: #06241e; } }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand-ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.btn.block { width: 100%; }

/* ---------- Login ---------- */
.login { max-width: 420px; margin: 0 auto; padding: 14vh 20px 40px; display: grid; gap: 22px; }
.login h1 { font-size: 2rem; font-weight: 800; }
.login form { display: grid; gap: 14px; }

/* ---------- Header & navigasi ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 6px; max-width: 1120px; margin: 0 auto; }
.brand { font-weight: 800; font-size: 1.05rem; color: var(--brand-ink); }
.who { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; color: var(--muted); }
.who b { color: var(--ink); font-weight: 700; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px; max-width: 1120px; margin: 0 auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 0 0 auto; padding: 10px 14px; text-decoration: none; color: var(--muted);
  font-weight: 700; border-bottom: 3px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--brand-ink); border-bottom-color: var(--brand); }
main { max-width: 760px; margin: 0 auto; padding: 18px 16px 120px; display: grid; gap: 16px; }
main.wide { max-width: 1120px; }

/* ---------- Kartu & form ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card > h3 { margin-bottom: 2px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.f { display: grid; gap: 4px; min-width: 0; }
.f > span { font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.f input, .f select, .f textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--surface);
}
.f input[type="text"], .f input:not([type]) { text-transform: uppercase; }
.f textarea { text-transform: none; min-height: 72px; resize: vertical; }
.f input:disabled, .f select:disabled, .f textarea:disabled { background: var(--paper); color: var(--ink); opacity: 0.85; }
.f input.invalid, .f select.invalid { border-color: var(--danger); background: var(--danger-bg); }
.f input.warn, .f select.warn { border-color: var(--warn); background: var(--warn-bg); }
.span2 { grid-column: 1 / -1; }

.issues { display: grid; gap: 6px; }
.issue { text-align: left; border: 0; border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; cursor: pointer; }
.issue.error { background: var(--danger-bg); color: var(--danger); }
.issue.warn { background: var(--warn-bg); color: var(--warn); }
.note { background: var(--brand-soft); color: var(--brand-ink); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.note.warn { background: var(--warn-bg); color: var(--warn); }

.member-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.member-head h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.savebar-in { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.savebar-in .btn { flex: 1; }

/* ---------- Scan ---------- */
.scan h2 { margin-bottom: 4px; }
.frame {
  position: relative; display: grid; place-items: center; text-align: center; cursor: pointer;
  aspect-ratio: 3 / 2; width: 100%; background: var(--surface); border-radius: 6px;
  padding: 24px; font-weight: 800; font-size: 1.15rem; color: var(--brand-ink);
}
.frame small { display: block; font-weight: 500; color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.frame i { position: absolute; width: 34px; height: 34px; border: 0 solid var(--brand); }
.frame i:nth-child(1) { top: 8px; left: 8px; border-top-width: 5px; border-left-width: 5px; border-top-left-radius: 8px; }
.frame i:nth-child(2) { top: 8px; right: 8px; border-top-width: 5px; border-right-width: 5px; border-top-right-radius: 8px; }
.frame i:nth-child(3) { bottom: 8px; left: 8px; border-bottom-width: 5px; border-left-width: 5px; border-bottom-left-radius: 8px; }
.frame i:nth-child(4) { bottom: 8px; right: 8px; border-bottom-width: 5px; border-right-width: 5px; border-bottom-right-radius: 8px; }
.tips { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.proc { display: grid; gap: 16px; justify-items: center; text-align: center; padding: 24px 0; }
.proc img { max-width: 100%; max-height: 38vh; border-radius: 8px; border: 1px solid var(--line); }
.spin { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

/* ---------- Rekap & daftar ---------- */
.stat { display: grid; gap: 10px; }
.stat-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stat-big b { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 3px 12px; font-size: 0.85rem; font-weight: 700; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--brand-soft); color: var(--ok); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .f { flex: 1 1 220px; }
.list { display: grid; gap: 8px; }
.item {
  display: grid; gap: 4px 12px; grid-template-columns: 1fr auto; align-items: center; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  text-decoration: none; color: inherit; cursor: pointer; width: 100%;
}
.item:hover { border-color: var(--brand); }
.item b { font-weight: 700; }
.item .meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* ---------- Komparasi ---------- */
.steps { counter-reset: s; display: grid; gap: 16px; }
.maprow { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; align-items: center; }
.maprow select { min-height: 42px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 8px; width: 100%; }
.sumgrid { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .sumgrid { grid-template-columns: 1fr 1fr; } }
.sum { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: left; cursor: pointer; display: grid; gap: 2px; }
.sum b { font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.sum span { font-size: 0.85rem; color: var(--muted); }
.sum[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.t { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { background: var(--paper); font-weight: 700; white-space: nowrap; }
.diff { display: block; }
.diff s { color: var(--danger); text-decoration-thickness: 1.5px; }
.diff ins { color: var(--ok); text-decoration: none; font-weight: 700; }

/* ---------- Toast & modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 50;
  transition: opacity 0.2s, transform 0.2s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.8); display: grid; grid-template-rows: auto 1fr; }
.modal[hidden] { display: none; }
.modal-bar { display: flex; justify-content: flex-end; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); }
.modal-body { overflow: auto; padding: 0 10px 20px; }
.modal-body img { width: 220%; max-width: none; display: block; }
@media (min-width: 900px) { .modal-body img { width: 100%; } }

/* ---------- Cetak ---------- */
#printArea { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body.printing { background: #fff; color: #000; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; font: 9pt/1.35 Arial, sans-serif; }
  #printArea h1 { font-size: 13pt; margin: 0 0 2mm; }
  #printArea .ph { margin-bottom: 4mm; color: #333; }
  #printArea .pk { break-inside: avoid; margin-bottom: 6mm; }
  #printArea .pk h3 { font-size: 10pt; margin: 0 0 1mm; }
  #printArea .pk .pm { margin-bottom: 1.5mm; color: #333; }
  #printArea table { border-collapse: collapse; width: 100%; }
  #printArea th, #printArea td { border: 0.6pt solid #444; padding: 1mm 1.5mm; text-align: left; vertical-align: top; font-size: 8pt; }
  #printArea th { background: #e8e8e8; }
  #printArea h2 { font-size: 11pt; margin: 5mm 0 2mm; break-after: avoid; }
}
