/* Keuangan Pribadi Web — mobile-first.
   Prinsip: satu kolom, max-width 560px di tengah (desktop tetap
   enak dibaca), tombol minimal 48px, font input >=16px supaya
   Chrome di HP tidak auto-zoom saat ketik, tanpa scroll horizontal. */
:root {
  --hijau: #1b6b4a;
  --hijau-muda: #e6f2ec;
  --biru: #2563eb;
  --oranye: #ea7a1f;
  --merah: #c0392b;
  --teks: #1c2430;
  --teks-redup: #6b7280;
  --garis: #e3e8ee;
  --latar: #f4f6f8;
  --kartu: #ffffff;
  --kuning-peringatan: #fef3c7;
  --kuning-teks: #92400e;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--latar);
  color: var(--teks);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--hijau); }
button, input, select, textarea { font-size: 16px; font-family: inherit; }
button { min-height: 48px; border-radius: 10px; border: 0; cursor: pointer;
  padding: 10px 16px; font-weight: 600; background: var(--hijau); color: #fff; }
button.sekunder { background: #e5e7eb; color: var(--teks); }
button.bahaya { background: var(--merah); }
button.kecil { min-height: 40px; padding: 6px 12px; font-size: 15px; }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea {
  width: 100%; min-height: 48px; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 10px 12px; background: #fff; color: var(--teks);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--hijau); outline-offset: 0; border-color: var(--hijau); }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 15px; }
.hint { font-size: 13px; color: var(--teks-redup); margin-top: 4px; }

/* --- header --- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--hijau); color: #fff;
  padding: 12px 16px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
header.top h1 { font-size: 18px; margin: 0; font-weight: 700; }
header.top .aksi { display: flex; gap: 8px; }
header.top button { min-height: 40px; background: rgba(255,255,255,.18); color: #fff; padding: 6px 12px; }

/* --- layout --- */
main { max-width: 560px; margin: 0 auto; padding: 12px 12px 96px; }
.view[hidden] { display: none; }
.kartu {
  background: var(--kartu); border: 1px solid var(--garis); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.kartu h2 { font-size: 17px; margin: 0 0 8px; }
.kartu h3 { font-size: 15px; margin: 14px 0 6px; }
.total-besar { font-size: 30px; font-weight: 800; line-height: 1.15; }
.subtotal { color: var(--teks-redup); font-size: 14px; }
.angka-masuk { color: var(--biru); font-weight: 700; }
.angka-keluar { color: var(--oranye); font-weight: 700; }
.angka-merah { color: var(--merah); font-weight: 700; }
.peringatan {
  background: var(--kuning-peringatan); color: var(--kuning-teks);
  border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px;
}
.baris { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--garis); }
.baris:last-child { border-bottom: 0; }
.baris .kiri { min-width: 0; }
.baris .kanan { text-align: right; white-space: nowrap; }
.baris .nama { font-weight: 600; overflow-wrap: anywhere; }
.baris .kecil { font-size: 13px; color: var(--teks-redup); }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px;
  padding: 2px 9px; margin-left: 6px; vertical-align: middle;
}
.badge.masuk { background: #dbeafe; color: #1e40af; }
.badge.keluar { background: #ffedd5; color: #9a3412; }
.badge.pindah { background: #e0e7ff; color: #3730a3; }
.badge.lunas { background: #dcfce7; color: #166534; }
.badge.belum { background: #fef3c7; color: #92400e; }
.badge.jatuh { background: #fee2e2; color: #991b1b; }
.badge.baru { background: #dcfce7; color: #166534; }
.badge.sudah { background: #e5e7eb; color: #374151; }
.tombol-baris { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tombol-baris button { flex: 1; }

/* segmented control (jenis transaksi) */
.seg { display: flex; gap: 6px; margin: 4px 0 8px; }
.seg button { flex: 1; background: #e5e7eb; color: var(--teks); min-height: 48px; }
.seg button.aktif { background: var(--hijau); color: #fff; }

/* chart batang (CSS murni, tanpa canvas) */
.chart-bar { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.chart-bar .grup { flex: 1; display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.chart-bar .batang { flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.chart-bar .batang.masuk { background: var(--biru); }
.chart-bar .batang.keluar { background: var(--oranye); }
.chart-bar .label-bulan { text-align: center; font-size: 12px; color: var(--teks-redup); margin-top: 4px; }
.chart-wrap { overflow-x: hidden; }
.legenda { display: flex; gap: 14px; font-size: 13px; color: var(--teks-redup); margin-top: 6px; }
.legenda .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

/* bar horizontal (donut/piutang diganti bar) */
.hbar { margin: 8px 0; }
.hbar .info { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
.hbar .rel { height: 12px; background: #e5e7eb; border-radius: 999px; margin-top: 4px; overflow: hidden; }
.hbar .isi { height: 100%; background: var(--hijau); border-radius: 999px; }
.hbar .isi.oranye { background: var(--oranye); }
.hbar .isi.biru { background: var(--biru); }
.progress { height: 12px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--hijau); }

/* grid ringkasan */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid3 .kotak { background: var(--hijau-muda); border-radius: 10px; padding: 10px; text-align: center; }
.grid3 .kotak .lbl { font-size: 12px; color: var(--teks-redup); }
.grid3 .kotak .nil { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }

/* nav bawah */
nav.bawah {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--garis);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; justify-content: center;
}
nav.bawah .dalam { display: flex; width: 100%; max-width: 560px; }
nav.bawah button {
  flex: 1; background: none; color: var(--teks-redup); border-radius: 0;
  min-height: 60px; font-size: 12px; font-weight: 600; padding: 6px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.bawah button .ikon { font-size: 21px; line-height: 1; }
nav.bawah button.aktif { color: var(--hijau); }
nav.bawah button.tambah { color: var(--hijau); }
nav.bawah button.tambah .ikon {
  background: var(--hijau); color: #fff; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  margin-top: -18px; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* sheet "Lainnya" */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.sheet button { display: block; width: 100%; background: none; color: var(--teks);
  text-align: left; border-bottom: 1px solid var(--garis); border-radius: 0; min-height: 52px; }
.sheet button:last-child { border-bottom: 0; }

/* toast + login */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 84px; z-index: 40; background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 15px; max-width: 92vw;
  text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
#toast[hidden] { display: none; }
.login-wrap { max-width: 420px; margin: 40px auto 0; padding: 0 12px 96px; }
.login-wrap .logo { text-align: center; margin-bottom: 16px; }
.login-wrap .logo .judul { font-size: 24px; font-weight: 800; }
.error { background: #fee2e2; color: #991b1b; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600; }
.ok-msg { background: #dcfce7; color: #166534; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-weight: 600; }
.kosong { color: var(--teks-redup); text-align: center; padding: 18px 0; }
.tabel-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--garis); vertical-align: top; }
th { color: var(--teks-redup); font-size: 13px; }
td.kanan, th.kanan { text-align: right; white-space: nowrap; }
@media (min-width: 640px) {
  main { padding-top: 16px; }
}
