/* ==========================================================================
   BUDAKMILES Peduli Sosial: tampilan (HP dulu, lalu tablet dan desktop)
   ========================================================================== */
:root {
  --bg: #f3f5f9; --card: #fff; --text: #172033; --muted: #667085; --line: #e4e7ee;
  --field: #f8f9fc; --soft: #eef2f9;
  --primary: #2f5fb3; --primary-hover: #264f97; --primary-soft: #e8eefa; --primary-text: #fff;
  --danger: #c62828; --ok-bg: #e7f6ec; --ok: #1b6e3a;
  --err-bg: #fdecec; --warn-bg: #fff7e2; --warn-line: #f2dfa6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1318; --card: #181d25; --text: #e6e9ef; --muted: #9aa3b2; --line: #29303b;
    --field: #12161c; --soft: #1f2632;
    --primary: #6d9ef0; --primary-hover: #8ab2f5; --primary-soft: #1d2a40; --primary-text: #0b1520;
    --danger: #ef6b6b; --ok-bg: #16301f; --ok: #7fd59b;
    --err-bg: #3a1a1a; --warn-bg: #2e2612; --warn-line: #4a3c17;
    --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-underline-offset: 2px; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 4px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 12px; }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- Gerbang & login: kartu di tengah ---------- */
main.narrow { max-width: 420px; padding-top: 10vh; }
main.narrow .card { padding: 28px 24px; border-radius: 18px; box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.app-name { font-weight: 800; letter-spacing: .02em; color: var(--primary); margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
main.narrow .app-name::before { content: ""; width: 40px; height: 40px; flex: none; border-radius: 10px; background: url(/static/img/icon-192.png) center / cover; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 8px 16px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand who" "tabs tabs"; align-items: center; gap: 6px 12px; }
.brand { grid-area: brand; display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; color: var(--text); letter-spacing: .02em; min-width: 0; }
.brand img { border-radius: 7px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.tabs { grid-area: tabs; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a:hover { background: var(--soft); color: var(--text); }
.tabs a.on { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.who { grid-area: who; display: flex; gap: 12px; align-items: center; }
.who form { margin: 0; }
.who-name { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .9rem; flex: none; }
.who-text { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .who-text { display: none; } }
@media (min-width: 900px) {
  .topbar-inner { grid-template-columns: auto 1fr auto; grid-template-areas: "brand tabs who"; padding: 10px 16px; gap: 24px; }
  .tabs { margin: 0; padding: 0; }
}

/* ---------- Kartu & blok ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.center-card { text-align: left; }
.notice { background: var(--warn-bg); border-color: var(--warn-line); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notice.notice-text { display: block; line-height: 1.55; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; word-break: break-word; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.big { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.gap { gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.card.inner { background: var(--field); box-shadow: none; margin: 12px 0; }

/* ---------- Form ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.88rem; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); font-weight: 400; line-height: 1.45; }
label.check input { margin-top: 1px; flex: none; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; min-height: 44px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--card); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--primary); }
input[type=file] { padding: 8px; font-size: 14px; }
textarea { width: 100%; box-sizing: border-box; }
label > select, label > input:not([type=checkbox]):not([type=radio]) { width: 100%; }
input[data-rupiah] { font-size: 1.15rem; font-weight: 650; }

/* ---------- Tombol ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550; min-height: 44px; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; text-align: center; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 650; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 0.82rem; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 6px 0; text-decoration: underline; text-underline-offset: 2px; }
form.inline { display: inline-block; margin: 0 4px 4px 0; }
h1 .btn.small { vertical-align: middle; margin-left: 8px; }
@media (max-width: 640px) {
  .stack > .btn, .modal .btn.primary, .notice > .btn, .notice form.inline, .notice form.inline .btn, .save-qr { width: 100%; }
  .notice form.inline { margin: 0; }
}

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.76rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
th.right, td.right { text-align: right; }
tbody tr:hover { background: var(--field); }
tbody tr:last-child td { border-bottom: 0; }
tr.dim { opacity: 0.55; }

/* HP: setiap baris jadi kartu kecil, label kolom di kiri */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--card); }
  .table-wrap tbody tr:hover { background: var(--card); }
  .table-wrap td { border: 0; padding: 5px 0 5px 40%; position: relative; text-align: left; min-height: 30px; word-break: break-word; }
  .table-wrap td.right { text-align: left; }
  .table-wrap td.nowrap { white-space: normal; }
  .table-wrap td::before { content: attr(data-label); position: absolute; left: 0; top: 7px; width: 37%; font-size: .74rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .table-wrap td:not([data-label])::before { content: none; }
  .table-wrap td:not([data-label]) { padding-left: 0; }

  /* Daftar transaksi: kode + nominal di atas, nama, lalu tanggal + status. Seluruh kartu bisa diketuk. */
  .tx-table tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 14px; }
  .tx-table td { padding: 0; min-height: 0; width: auto; position: static; }
  .tx-table td::before { content: none; }
  .tx-table .c-code { flex: 1 1 auto; font-weight: 650; }
  .tx-table .c-code a { text-decoration: none; }
  .tx-table .c-code a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
  .tx-table .c-amt { font-weight: 750; text-align: right; }
  .tx-table .c-user { flex: 1 1 100%; }
  .tx-table .c-date { flex: 1 1 auto; color: var(--muted); font-size: .84rem; }
  .tx-table .c-status { flex: 0 0 auto; margin-left: auto; text-align: right; }
  .tx-table tbody tr:active { background: var(--field); }
}

/* ---------- Status ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 650; white-space: nowrap; background: var(--soft); }
.s-menunggu_bayar { background: #eceff3; color: #4a525c; }
.s-menunggu_konfirmasi { background: #fff1cc; color: #7a5600; }
.s-diterima { background: #dcebff; color: #0b4f99; }
.s-antre { background: #ffe3c7; color: #8a4300; }
.s-selesai { background: #dcf5e4; color: #186b37; }
.s-ditolak { background: #fde0e0; color: #9b1c1c; }
.s-dibatalkan { background: #eceff3; color: #8a9099; text-decoration: line-through; }

.quota-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.quota-dot.q-tersedia { background: #1f9d55; } .quota-dot.q-hampir { background: #e0a100; } .quota-dot.q-antre { background: #e06a00; } .quota-dot.q-penuh { background: #c62828; }
.qbar { height: 6px; border-radius: 999px; background: var(--soft); overflow: hidden; margin-top: 4px; }
.qbar > span { display: block; height: 100%; background: var(--primary); }
.qbar > span.full { background: #c62828; }

/* ---------- Grid ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stats > .card { margin-bottom: 0; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); opacity: .8; }
.stat .big { margin: 4px 0 2px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; align-items: end; margin: 12px 0; }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.filters > .row { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; } .filters > .row { grid-column: auto; } }
@media (max-width: 640px) { .filters > .row .btn { flex: 1; } }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: 0.88rem; }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }

/* ---------- Limit & QRIS ---------- */
.limit { background: linear-gradient(135deg, var(--primary) 0%, #4a6aa8 100%); color: #fff; border: 0; }
.limit .muted { color: rgba(255, 255, 255, .78); }
.limit .bar { background: rgba(255, 255, 255, .25); }
.limit .bar span { background: #fff; }
@media (prefers-color-scheme: dark) { .limit { background: linear-gradient(135deg, #24467f 0%, #2f4a7c 100%); } }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.qris-card { text-align: center; }
img.qris { display: block; width: 100%; max-width: 340px; margin: 12px auto; border-radius: 12px; background: #fff; padding: 8px; border: 1px solid var(--line); }
.qris.empty { display: grid; place-items: center; height: 200px; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); margin: 12px 0; }
.save-qr { margin-top: 12px; }
.fee-box { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); line-height: 1.55; }
.fee-box.warn { border-color: #e0a100; background: rgba(224, 161, 0, 0.12); }

details > summary { cursor: pointer; font-weight: 550; min-height: 28px; }
details[open] > summary { margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 440px; margin: 0; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .center { text-align: center; margin-top: 12px; }

@media (max-width: 640px) {
  main { padding: 16px 12px 56px; }
  .card { padding: 16px; }
  h1 { font-size: 1.3rem; }
}

/* Casual anti-copy: no text selection outside form fields. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; pointer-events: none; }
html.veil body { filter: blur(24px); }
html.veil body * { visibility: hidden; }

.pre-line { white-space: pre-line; }
.err-text { color: #c62828; }

.proof-merah { background: #fde0e0; color: #9b1c1c; }
.proof-kuning { background: #fff3c4; color: #7a5b00; }
.proof-hijau { background: #dcf5e4; color: #186b37; }
.proof-box { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--soft); }
.proof-box ul { margin: 6px 0 0; padding-left: 18px; }
