:root {
  --navy: #10223f;
  --navy-light: #1a4d8f;
  --gold: #ffd166;
  --gold-dark: #e0ab1f;
  --blue-bg: #eef5ff;
  --blue-accent: #1a6fb5;
  --warn-bg: #fff4e5;
  --warn-accent: #e08e00;
  --danger: #d64545;
  --success: #2e9e5b;
  --text: #1c2733;
  --text-muted: #6b7583;
  --border: #e3e7ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-accent); text-decoration: none; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 84px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  padding: 18px 18px 22px 18px;
  border-radius: 0 0 20px 20px;
}
.topbar .app-title { font-size: 15px; font-weight: 700; letter-spacing: .3px; opacity: .9; }
.topbar .app-sub { font-size: 12.5px; color: #c9d7ef; margin-top: 2px; }
.topbar .greeting { font-size: 20px; font-weight: 700; margin-top: 10px; }

/* ---------- Auth pages (centered card, no bottom nav) ---------- */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: 0 8px 24px rgba(16,34,63,0.08);
}
.auth-logo {
  text-align: center;
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  margin-bottom: 4px;
}
.auth-logo .accent { color: var(--gold-dark); }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin: 14px 0 6px 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-accent); }

.btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  padding: 13px 16px;
  border-radius: 9px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 18px;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; margin-top: 0; }

.form-error {
  background: #fdecec;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.form-note { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 16px; }

/* ---------- Cards / sections ---------- */
.content { padding: 16px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(16,34,63,0.05);
}
.card h3 { margin: 0 0 10px 0; font-size: 15px; color: var(--navy); font-family: Georgia, serif; }
.card .card-hint { font-size: 12px; color: var(--text-muted); margin-top: -6px; margin-bottom: 10px; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--blue-accent);
  font-weight: 700;
  margin: 20px 0 8px 4px;
}

/* ---------- Stat tiles ---------- */
.stat-row { display: flex; gap: 10px; margin-bottom: 4px; }
.stat-tile {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 12px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(16,34,63,0.05);
}
.stat-tile .label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.stat-tile .value { font-size: 17px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat-tile.warn .value { color: var(--danger); }
.stat-tile.good .value { color: var(--success); }

/* ---------- Progress bar ---------- */
.progress-bar { background: var(--border); border-radius: 8px; height: 10px; overflow: hidden; margin-top: 6px; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--blue-accent), var(--gold)); }

/* ---------- Category rows (anggaran) ---------- */
.kategori-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.kategori-row:last-child { border-bottom: none; }
.kategori-row .kname { font-weight: 600; font-size: 13.5px; }
.kategori-row .kpct { font-size: 11px; color: var(--text-muted); }
.kategori-row .kamounts { text-align: right; font-size: 13px; }
.kategori-row .kamounts .real { font-weight: 700; color: var(--navy); }
.kategori-row .kamounts .target { color: var(--text-muted); font-size: 11.5px; }

/* ---------- List items (expenses, debts) ---------- */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { font-size: 13.5px; font-weight: 600; }
.list-item .li-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.list-item .li-amount { font-weight: 700; color: var(--navy); font-size: 13.5px; }
.list-item .li-del { color: var(--danger); font-size: 11px; margin-left: 10px; cursor: pointer; background: none; border: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.badge-1 { background: #eef5ff; color: var(--blue-accent); }
.badge-2 { background: var(--warn-bg); color: var(--warn-accent); }
.badge-status-pending { background: var(--warn-bg); color: var(--warn-accent); }
.badge-status-active { background: #e7f7ee; color: var(--success); }
.badge-status-expired, .badge-status-suspended { background: #fdecec; color: var(--danger); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)) 4px;
  box-shadow: 0 -2px 10px rgba(16,34,63,0.06);
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 2px;
  text-align: center;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}
.bottom-nav button .icon { display: block; font-size: 19px; margin-bottom: 2px; }
.bottom-nav button.active { color: var(--navy); }
.bottom-nav button.active .icon { transform: translateY(-1px); }

.view { display: none; }
.view.active { display: block; }

.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 10px; }

.banner {
  margin: 14px 16px 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}
.banner-warn { background: var(--warn-bg); color: #8a5700; }
.banner-info { background: var(--blue-bg); color: #124a7a; }

.inline-row { display: flex; gap: 8px; }
.inline-row > * { flex: 1; }

table.simple { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
table.simple th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 6px 4px; border-bottom: 1.5px solid var(--border); font-size: 11px; }
table.simple td { padding: 8px 4px; border-bottom: 1px solid var(--border); }

.fab-add {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: 1.5px dashed var(--blue-accent);
  background: var(--blue-bg);
  color: var(--blue-accent);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,34,63,0.45);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-backdrop.active { display: flex; }
.modal-sheet {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom,0px)) 18px;
  max-height: 86vh; overflow-y: auto;
}
.modal-sheet h3 { margin-top: 0; color: var(--navy); font-family: Georgia, serif; }
.modal-close { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 12px; cursor: pointer; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { padding: 6px 12px; border-radius: 20px; background: var(--blue-bg); color: var(--blue-accent); font-size: 12px; font-weight: 600; cursor: pointer; border: 1.5px solid transparent; }
.chip.selected { background: var(--navy); color: #fff; }

.week-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.week-item:last-child { border-bottom: none; }
.week-item .wtitle { font-size: 12.5px; font-weight: 700; color: var(--navy); }
.week-item .wtext { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 8px 0; }

.status-select-row { display: flex; gap: 6px; }
.status-btn { flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 11px; text-align: center; border: 1.5px solid var(--border); background: #fff; color: var(--text-muted); cursor: pointer; font-weight: 600; }
.status-btn.active-Belum.on { background: #fdecec; color: var(--danger); border-color: var(--danger); }
.status-btn.active-Proses.on { background: var(--warn-bg); color: var(--warn-accent); border-color: var(--warn-accent); }
.status-btn.active-Selesai.on { background: #e7f7ee; color: var(--success); border-color: var(--success); }

.loading-dot { text-align: center; padding: 40px 0; color: var(--text-muted); font-size: 13px; }

.profile-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.profile-row .plabel { color: var(--text-muted); }
.profile-row .pvalue { font-weight: 600; }

/* ---------- Admin table ---------- */
.admin-user-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(16,34,63,0.05); }
.admin-user-card .u-name { font-weight: 700; font-size: 14px; color: var(--navy); }
.admin-user-card .u-email { font-size: 12px; color: var(--text-muted); }
.admin-user-card .u-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.admin-user-card .u-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.admin-user-card .u-actions .btn-sm { flex: 1; min-width: 100px; }

.form-success {
  display: none; background: #e7f7ee; color: var(--success); font-size: 13px;
  padding: 10px 12px; border-radius: 8px; margin-top: 12px; font-weight: 600;
}

/* ---------- Pembayaran / WhatsApp ---------- */
.btn-wa { background: #25d366; color: #fff; display: block; text-align: center; }
.btn-wa:active { background: #1ebe5b; }
.pay-box { background: var(--blue-bg); border-radius: var(--radius); padding: 14px; margin-top: 12px; text-align: left; }
.pay-box .pay-title { font-weight: 700; color: var(--navy); font-size: 13.5px; }
.pay-box .pay-price { font-size: 18px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.price-old { color: var(--danger); font-weight: 600; font-size: .85em; text-decoration: line-through; opacity: .85; }
.persen-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.persen-row .pl { flex: 1; font-size: 13.5px; font-weight: 600; }
.persen-row .pin { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.persen-row .pin input { width: 64px; text-align: center; padding: 8px 4px; }
.persen-row .pin span { font-weight: 700; color: var(--text-muted); }
.persen-row .prp { flex: 0 0 96px; text-align: right; font-size: 12px; color: var(--text-muted); }
.persen-now { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.persen-total { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--success); text-align: right; }
.persen-total.bad { color: var(--danger); }
.pay-box .pay-info { font-size: 12.5px; color: var(--text); white-space: pre-line; line-height: 1.6; margin-top: 6px; }
.banner .banner-actions { margin-top: 8px; }
.banner .banner-actions a { font-weight: 700; color: #1ebe5b; }

.temp-pass { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px;
  background: var(--blue-bg); color: var(--navy); padding: 12px; border-radius: 8px; text-align: center; margin: 10px 0; user-select: all; }

@media (min-width: 500px) {
  .app-shell { box-shadow: 0 0 40px rgba(16,34,63,0.08); }
}
