:root {
  /* Brand: a single teal used sparingly, for structure and primary actions. */
  --sea: #0e7490;
  --sea-dark: #0b5567;
  --sea-soft: #cffafe;

  /* Soft semantic palette for the summary cards. Pastel, low contrast on text,
     so each card reads as a category rather than an alarm. */
  --green-bg: #e8f6ee;
  --green-fg: #14663f;
  --green-line: #bfe3ce;

  --blue-bg: #e8f1fb;
  --blue-fg: #17548f;
  --blue-line: #c5dcf5;

  --red-bg: #fdeeee;
  --red-fg: #9c2f2f;
  --red-line: #f3d3d3;

  --purple-bg: #f2ecfb;
  --purple-fg: #5b3a91;
  --purple-line: #ded0f2;
  --amber-bg: #fdf3e2;
  --amber-fg: #8a5a12;
  --amber-line: #f0dcb4;

  --sand: #fef3c7;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #059669;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
/* Flat teal instead of the old diagonal gradient: the reference is a solid bar
   and the gradient only added visual noise. Height is kept tight. */
.topbar {
  background: var(--sea);
  color: #fff;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { font-size: 30px; line-height: 1; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.topbar p { margin: 2px 0 0; font-size: 13px; opacity: 0.9; }
.topbar-actions { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }

/* ---------- layout ---------- */
main { padding: 20px 0 60px; display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }

h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--ink); }

.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hint a { color: var(--sea); font-weight: 600; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }

/* Each summary card carries a tone class so the four categories read apart.
   The tone owns the background, border and value colour; everything else about
   the card is shared, which keeps the CSS maintainable. */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.card .value { font-size: 21px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; word-break: break-word; }
.card .value.ok { color: var(--sea); }
.card .value.warn { color: var(--warn); }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tone variants: soft pastel fill, tinted border, readable accent text. */
.card.tone-green { background: var(--green-bg); border-color: var(--green-line); }
.card.tone-green .label, .card.tone-green .sub { color: var(--green-fg); }
.card.tone-green .value { color: var(--green-fg); }

.card.tone-blue { background: var(--blue-bg); border-color: var(--blue-line); }
.card.tone-blue .label, .card.tone-blue .sub { color: var(--blue-fg); }
.card.tone-blue .value { color: var(--blue-fg); }

.card.tone-red { background: var(--red-bg); border-color: var(--red-line); }
.card.tone-red .label, .card.tone-red .sub { color: var(--red-fg); }
.card.tone-red .value { color: var(--red-fg); }

.card.tone-purple { background: var(--purple-bg); border-color: var(--purple-line); }
.card.tone-purple .label, .card.tone-purple .sub { color: var(--purple-fg); }
.card.tone-purple .value { color: var(--purple-fg); }

.card.tone-amber { background: var(--amber-bg); border-color: var(--amber-line); }
.card.tone-amber .label, .card.tone-amber .sub { color: var(--amber-fg); }
.card.tone-amber .value { color: var(--amber-fg); }

/* A small tone dot: colour cue without needing an icon font. */
.card .tone-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.card.tone-green .tone-dot { background: var(--green-fg); }
.card.tone-blue .tone-dot { background: var(--blue-fg); }
.card.tone-red .tone-dot { background: var(--red-fg); }
.card.tone-purple .tone-dot { background: var(--purple-fg); }
.card.tone-amber .tone-dot { background: var(--amber-fg); }

/* ---------- progress ---------- */
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.progress-target { font-size: 13px; color: var(--muted); }
.progress-target b { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress { background: #e2e8f0; border-radius: 999px; height: 12px; overflow: hidden; }
.progress-fill { background: var(--sea); height: 100%; transition: width 0.3s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 8px; gap: 10px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sea);
  box-shadow: 0 0 0 3px var(--sea-soft);
}
input[type="file"] { padding: 7px; font-size: 13px; }

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--sea); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--sea-dark); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.topbar .btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.panel .btn-ghost { color: var(--sea); border-color: var(--sea); }
.panel .btn-ghost:hover:not(:disabled) { background: var(--sea-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* Reject sits next to approve in the proof queue: quiet, but clearly the
   destructive one. Deliberately soft - it is a routine admin action here, not
   an emergency. */
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.panel .btn-danger:hover:not(:disabled) { background: #fef2f2; }

.proof-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; }
.filter-summary { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

/* ---------- admin ---------- */
.admin-panel { border-color: var(--sea); }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { flex: 1 1 220px; margin-bottom: 0; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.admin-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fcfdfe; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 420px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }

/* Tinted header instead of plain text on white, plus zebra rows for scanning
   long lists. Both are pure presentation. */
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sea-dark);
  font-weight: 600;
  white-space: nowrap;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
}
thead th { border-top: 1px solid var(--line); }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: #f1f5f9; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }

.member-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--sea);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.member-link:hover { color: var(--sea-dark); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap; }
.pill.DEPOSIT, .pill.REFUND { background: #dcfce7; color: #166534; }
.pill.EXPENSE { background: #fee2e2; color: #991b1b; }
.pill.ADJUSTMENT { background: #dbeafe; color: #1e40af; }

/* ---------- voucher ---------- */
/* A redeemed voucher is a deposit like any other, but it must never be
   mistaken for a transfer: the money is the organizer's, not the saver's. */
.pill.VOUCHER { background: #fef3c7; color: #92400e; }
.voucher-info { margin-top: 8px; padding: 10px 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }
.voucher-title { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.voucher-kv, .voucher-info .kv { margin-top: 6px; font-size: 13px; }
.voucher-summary { margin-bottom: 12px; padding: 10px 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; }
.voucher-summary-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #92400e; font-weight: 600; }
.pill.REVERSAL { background: #ede9fe; color: #5b21b6; }
.pill.VALID { background: #dcfce7; color: #166534; }
.pill.PENDING, .pill.NEED_REVIEW { background: var(--sand); color: #92400e; }
.pill.DUPLICATE, .pill.REJECTED, .pill.CANCELLED { background: #e2e8f0; color: #475569; }
.pill.ACTIVE { background: #dcfce7; color: #166534; }
.pill.INACTIVE { background: #e2e8f0; color: #475569; }

/* ---------- proof upload ---------- */
#form-proof { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: 12px; align-items: end; }

/* The upload button is the single most common action on the page, so it gets a
   little extra weight over the neighbouring primary buttons. */
.btn-upload { padding: 11px 20px; font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18); }
.proof-result { margin-top: 14px; border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.proof-result.ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.proof-result.review { background: #fffbeb; border: 1px solid #fde68a; }
.proof-result.err { background: #fef2f2; border: 1px solid #fecaca; }
.proof-result ul { margin: 8px 0 0; padding-left: 20px; }
.proof-result .kv { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.proof-result .kv span { color: var(--muted); }
.proof-result .kv b { font-variant-numeric: tabular-nums; }

.proof-queue { font-size: 13px; max-height: 260px; overflow-y: auto; }
.proof-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.proof-item img { max-width: 100%; border-radius: 6px; margin-bottom: 8px; display: block; }
.proof-item .caption { font-style: italic; color: var(--muted); }

.msg { margin: 10px 0 0; font-size: 13px; padding: 9px 12px; border-radius: 8px; }
.msg.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.msg.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(340px, calc(100vw - 32px)); }
/* white-space: pre-line so the multi-line duplicate notice keeps its line
   breaks - it names the colliding transaction on its own lines. */
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25); white-space: pre-line; }
.toast.ok { background: #047857; }
.toast.err { background: #b91c1c; }

/* ---------- footer ---------- */
footer { text-align: center; font-size: 12px; color: var(--muted); padding: 0 20px 40px; }
footer code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

/* ---------- ledger pagination ---------- */
/* Only shown when the ledger has more rows than one page, so a short ledger
   keeps exactly the layout it had before. */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-controls { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s ease;
}
.pager-btn:hover:not(:disabled):not(.is-active) { background: #f1f5f9; }
.pager-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pager-btn.is-active { background: var(--sea); border-color: var(--sea); color: #fff; font-weight: 600; }
.pager-gap { min-width: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- handbook (/panduan.html) ---------- */
/* Scoped to .doc so the participant guide gets its own layout without
   touching any of the portal's existing rules. */
.doc { max-width: 780px; }
.doc .panel { margin-bottom: 16px; }
.doc h3 { margin-top: 18px; }
.doc h3:first-of-type { margin-top: 0; }
.doc-accent { border-color: var(--sea); background: #f8fdff; }

.doc ol.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.doc ol.steps > li::marker { color: var(--sea); font-weight: 700; }
.doc ul.bullets { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.doc ul.bullets > li::marker { color: var(--muted); }
.doc .steps b, .doc .bullets b { color: var(--ink); }

.doc .facts { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 10px 28px; }
.doc .facts > div { display: flex; flex-direction: column; gap: 2px; }
.doc .facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.doc .facts dd { margin: 0; font-size: 15px; font-weight: 600; }
.doc .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }

.doc .doc-table { min-width: 0; }
.doc .doc-table td:first-child { white-space: normal; }

.doc .result { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.doc .result:last-child { margin-bottom: 0; }
.doc .result p { margin: 6px 0 0; }
.doc .result .hint { margin-bottom: 0; }
.doc .result.ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.doc .result.review { background: #fffbeb; border: 1px solid #fde68a; }
.doc .result.err { background: #fef2f2; border: 1px solid #fecaca; }

@media (max-width: 720px) {
  .doc .facts { gap: 10px 18px; }
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar h1 { font-size: 17px; }
  .topbar p { font-size: 12px; }
  main { gap: 14px; }
  .panel { padding: 14px; }
  #form-proof { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; }
  .cards { grid-template-columns: 1fr; }
  .card .value { font-size: 19px; }
  .table-wrap table { min-width: 340px; font-size: 13px; }
  th.hide-sm, td.hide-sm { display: none; }
  .toast-stack { left: 16px; right: 16px; max-width: none; }
}

@media (max-width: 380px) {
  .filters { grid-template-columns: 1fr; }
}
/* Shown while the voucher read is still running. Kept dim so it reads as a
   transient status rather than as part of the result. */
.polling {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.7;
  font-style: italic;
}
