:root {
  --brand: #fdb913;
  --brand-ink: #111111;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e2e0d8;
  --danger: #b42318;
  --ok: #067647;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1c;
    --surface-2: #242424;
    --text: #ececec;
    --muted: #a3a3a3;
    --line: #2e2e2e;
    --danger: #f97066;
    --ok: #47cd89;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}

/* ---------- Kerangka ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 4px solid var(--brand);
  background: var(--surface);
}
.topbar img { width: 36px; height: 36px; border-radius: 8px; }
.topbar .name { font-weight: 700; letter-spacing: 0.01em; }
.topbar .name small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 48px 16px; }
main.narrow { max-width: 420px; }
main.wide { max-width: 1040px; padding-top: 24px; }

footer {
  padding: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.lock-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  color: var(--brand);
  opacity: 0.6;
  text-decoration: none;
  vertical-align: -1px;
  transition: opacity 0.2s, transform 0.2s;
}
.lock-link:hover {
  opacity: 1;
  transform: scale(1.2);
}

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 6px; }
p { margin: 0 0 16px; color: var(--muted); }
p.flush { margin: 0; }
a { color: inherit; text-decoration-color: var(--brand); text-underline-offset: 3px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- Tab ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs [role="tab"] {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 14px;
  white-space: nowrap;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label, .form .label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
.form > button[type="submit"] { margin-top: 16px; align-self: flex-start; }
.narrow-form { max-width: 420px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 20px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
  border-color: transparent;
}

.search { display: block; margin: 12px 0 16px; max-width: 360px; }

/* ---------- Tombol ---------- */
button, .button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--brand-ink);
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}
button.secondary, .button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
button:focus-visible, .button:focus-within { outline: 3px solid var(--text); outline-offset: 2px; }
button:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Tabel ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.num.ok { color: var(--ok); }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: 6px; }
.empty { padding: 32px 16px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--line); }
.badge-aktif { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.badge-lunas { color: var(--ok); border-color: currentColor; }
.badge-batal { color: var(--muted); text-decoration: line-through; }

/* ---------- Kuitansi ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 20px; }
.terbilang { margin: 6px 0 0; min-height: 1.5em; font-style: italic; font-weight: 600; color: var(--text); }
.notice {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--brand);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}
.form-actions { margin-top: 16px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.88rem; }
.small-text { font-size: 0.8rem; margin: 4px 0 0; }
a.button { text-decoration: none; }
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.dialog-wide input[readonly] { margin-bottom: 4px; }
.pin-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0 16px;
  padding: 14px;
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  text-align: center;
}
.pin { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 2rem; letter-spacing: 0.3em; color: var(--text); }
.issued-actions { margin-top: 12px; }

.bank-section { margin-top: 28px; }

/* ---------- Salin rekening ---------- */
.bank-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.bank-card { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 12px 14px; }
.bank-card .bank-name { font-weight: 700; }
.bank-card .bank-number { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.1rem; letter-spacing: 0.03em; }
.bank-card .row { margin-top: 10px; }
.copied { outline: 2px solid var(--ok); }

/* ---------- Pratinjau PDF ---------- */
.viewer {
  width: min(980px, calc(100vw - 24px));
  height: min(92vh, 1100px);
  max-height: none;
  padding: 16px;
}
.viewer[open] { display: flex; flex-direction: column; gap: 10px; }
.viewer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.viewer-head h2 { margin: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1rem; }
.viewer-frame { flex: 1; width: 100%; min-height: 0; border: 1px solid var(--line); border-radius: 8px; background: #525659; }
.viewer-hint { margin: 0; }
.viewer .dialog-actions { margin-top: 0; }

/* ---------- Rekap ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { display: block; font-size: 0.8rem; color: var(--muted); }
.stat-value { display: block; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-main { border-left: 4px solid var(--brand); }
.report-grid { gap: 24px; align-items: start; }
.report-grid h2 { margin-bottom: 10px; }
.year-select { width: auto; min-height: 44px; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
tr.zero td { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; margin-top: 12px; }
.check input { width: auto; }
.link-button {
  background: none;
  border: 0;
  min-height: 0;
  padding: 0;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-underline-offset: 3px;
  font-weight: 600;
}
.void-note { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
tr.voided td:not(.actions) { opacity: 0.7; }

/* ---------- Halaman verifikasi publik ---------- */
.verdict {
  margin-bottom: 16px;
  padding: 20px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
}
.verdict h1 { font-size: 1.35rem; margin: 2px 0 6px; }
.verdict p { margin: 0; color: var(--text); }
.verdict p + p { margin-top: 8px; }
.verdict-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.verdict-ok { border-color: var(--ok); }
.verdict-ok .verdict-label { color: var(--ok); }
.verdict-void { border-color: var(--danger); }
.verdict-void .verdict-label { color: var(--danger); }

main > .panel + .panel, main > .panel + form, main > form + form, main > dl + form, main > dl + section { margin-top: 16px; }
.info { margin: 0; display: grid; gap: 10px; }
.info-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 12px; }
.info dt { color: var(--muted); font-size: 0.9rem; }
.info dd { margin: 0; overflow-wrap: anywhere; }
.details .info { margin: 12px 0 16px; }
.hash { font-size: 0.75rem; }
.pin-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.4rem; letter-spacing: 0.4em; max-width: 220px; }
.cek-form { display: flex; gap: 8px; flex-wrap: wrap; }
.cek-form input { flex: 1 1 200px; }

@media (max-width: 480px) {
  .info-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Gambar profil ---------- */
.image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-preview.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ---------- Dialog & notifikasi ---------- */
.dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
.toast-error { background: var(--danger); color: #fff; }

.error { color: var(--danger); margin: 8px 0 0; }
.success { color: var(--ok); margin: 8px 0 0; }

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .topbar-actions #who { display: none; }
  main.wide { padding: 16px; }
  th, td { padding: 10px; }
}
