:root {
  --hijau: #1f4d3a; --hijau-2: #2d6a50; --hijau-muda: #dcebe1; --amber: #c8862a;
  --latar: #f4f2ec; --kartu: #ffffff; --teks: #1d2420; --redup: #6b746f; --garis: #e1ded5;
  --merah: #b3372b; --merah-muda: #fbe7e4; --kuning-muda: #fff4dc;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--latar); color: var(--teks); }
a { color: var(--hijau-2); }
h1 { font-size: 1.35rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
code { background: #eee; padding: 0 .3em; border-radius: 4px; }

/* Kepala */
.atas { background: var(--hijau); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.atas-isi { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.merek { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 600; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--amber); color: #fff; font-weight: 700; }
.logo.besar { width: 56px; height: 56px; font-size: 1.6rem; border-radius: 14px; margin: 0 auto .6rem; display: grid; }
.akun { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.akun a { color: #fff; text-decoration: none; }
.akun small { opacity: .75; }
.akun .tombol.garis { color: #fff; border-color: rgba(255,255,255,.5); background: transparent; }
.menu { max-width: 1200px; margin: 0 auto; display: flex; gap: .15rem; overflow-x: auto; padding: 0 .6rem; scrollbar-width: none; }
.menu::-webkit-scrollbar { display: none; }
.menu a { color: rgba(255,255,255,.82); text-decoration: none; padding: .55rem .8rem; white-space: nowrap; border-bottom: 3px solid transparent; font-size: .93rem; }
.menu a.aktif { color: #fff; border-bottom-color: var(--amber); font-weight: 600; }

.isi { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.bawah { text-align: center; color: var(--redup); font-size: .8rem; padding: 2rem 1rem; }

/* Kartu */
.kartu { background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.kartu.sempit { max-width: 460px; }
.judul-baris { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.judul-baris h1, .judul-baris h2 { margin: 0; }
.dua-kolom { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.dua-kolom .kartu { margin-bottom: 0; }
.dua-kolom + * { margin-top: 1rem; }
.ubin { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.angka-besar { margin: 0; display: flex; flex-direction: column; gap: .15rem; border-top: 4px solid var(--hijau-2); }
.angka-besar span { color: var(--redup); font-size: .85rem; }
.angka-besar b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.angka-besar small { color: var(--redup); }

.tengah { text-align: center; }
.kanan { text-align: right; }
.redup { color: var(--redup); }
.kecil { font-size: .85rem; }
.tebal { font-weight: 700; }

/* Tombol */
.tombol { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; background: var(--hijau-2); color: #fff; border: 1px solid var(--hijau-2);
  padding: .55rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.tombol:hover { background: var(--hijau); }
.tombol.garis { background: #fff; color: var(--hijau-2); }
.tombol.garis:hover { background: var(--hijau-muda); }
.tombol.kecil { padding: .25rem .6rem; min-height: 32px; font-size: .85rem; }
.tombol.bahaya { background: #fff; color: var(--merah); border-color: #e3b8b2; }
.tombol.penuh { width: 100%; }

/* Formulir */
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #cfcabd; border-radius: 7px; background: #fff; color: var(--teks); min-height: 40px; max-width: 100%; }
input:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 0; border-color: var(--amber); }
.formulir label { display: block; margin-bottom: .75rem; font-weight: 600; font-size: .9rem; }
.formulir label input, .formulir label select { display: block; width: 100%; margin-top: .25rem; font-weight: 400; }
.formulir h2 { margin-top: 1.2rem; }
.formulir.kisi { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.formulir.kisi .lebar { grid-column: 1 / -1; }
label.centang { display: inline-flex !important; align-items: center; gap: .35rem; font-weight: 400 !important; }
label.centang input { width: auto !important; min-height: 0; display: inline !important; margin: 0 !important; }
.baris-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .4rem 0; border-bottom: 1px dashed var(--garis); }
.baris-form input { flex: 1 1 140px; }
.baris-form input.pendek { flex: 0 0 80px; }
.baris-form .tombol { flex: 0 0 auto; }
input.angka { text-align: right; font-variant-numeric: tabular-nums; width: 100%; min-width: 64px; background: var(--kuning-muda); color: #1a3fa0; }
input.angka.harga { min-width: 110px; }
input.angka.opsional { background: #f6f6f6; color: var(--teks); }
input.angka.salah { outline: 2px solid var(--merah); background: var(--merah-muda); }
textarea.kode { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; }

.pilih-periode { display: flex; align-items: center; justify-content: center; gap: .4rem; flex-wrap: wrap; }
.pilih-periode form { margin: 0; }
.pilih-periode .tombol { min-width: 40px; font-size: 1.2rem; padding: .2rem .6rem; }
.tab { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab a { padding: .4rem .8rem; border-radius: 999px; background: #fff; border: 1px solid var(--garis); text-decoration: none; color: var(--teks); font-size: .9rem; }
.tab a.aktif { background: var(--hijau-2); color: #fff; border-color: var(--hijau-2); }

/* Pesan */
.pesan { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.pesan.ok { background: var(--hijau-muda); border-color: #b5d4c0; color: #17402f; }
.pesan.galat { background: var(--merah-muda); border-color: #ebc0ba; color: #7a2016; }
.pesan.peringatan { background: var(--kuning-muda); border-color: #ecd49d; color: #6a4a0c; }
.pesan.blok { display: block; text-decoration: none; }

/* Tabel */
.tabel-gulir { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }
.tabel { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabel th, .tabel td { padding: .45rem .55rem; border-bottom: 1px solid var(--garis); text-align: right; white-space: nowrap; }
.tabel th:first-child, .tabel td:first-child { text-align: left; }
.tabel thead th { background: var(--hijau-muda); color: #17402f; font-size: .82rem; text-align: center; position: sticky; top: 0; }
.tabel tbody th { font-weight: 600; }
.tabel tfoot th, .tabel tfoot td { font-weight: 700; border-top: 2px solid var(--hijau-2); background: #f7faf8; }
.tabel tr.subtotal th, .tabel tr.subtotal td { background: #fafaf7; font-weight: 600; }
.tabel.rapat th, .tabel.rapat td { padding: .3rem .4rem; font-size: .85rem; }
.tabel th.grup { border-left: 2px solid #fff; }
.tabel td.sisa, .tabel th.sisa { background: #f3f7f4; font-weight: 600; }
.tabel td.beda { background: var(--merah-muda); color: var(--merah); position: relative; }
.tabel td.beda::after { content: "•"; position: absolute; top: 0; right: 2px; }
.tabel tr.minggu th, .tabel tr.minggu td { border-bottom-color: #bdb8aa; }
.tabel tr.pilih th, .tabel tr.pilih td { background: #fff4dc; }
.tabel tr.nanti { color: #aaa; }
.tabel tr.awal td, .tabel tr.awal th { color: var(--redup); }
.tabel th a, a.polos { text-decoration: none; color: inherit; }
.tabel td.aksi { text-align: right; white-space: nowrap; }
.tabel td.aksi > * { margin-left: .25rem; }
.tabel td form { margin: 0; display: inline; }
.tabel td.minus { color: var(--merah); font-weight: 700; }
.tabel td.plus { color: #1a3fa0; font-weight: 700; }
.tabel td.ket { white-space: normal; min-width: 220px; text-align: left; }
.tabel.isian td { padding: .3rem; }
.tabel.isian input.angka { min-width: 70px; }
.tabel.grid input.angka.lebar { max-width: 160px; }

select[hidden] { display: none; }
.tabel.hak td { text-align: center; }

.status { display: inline-block; border-radius: 999px; padding: .1rem .55rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status.lunas { background: var(--hijau-muda); color: #17402f; }
.status.sebagian { background: var(--kuning-muda); color: #6a4a0c; }
.status.belum { background: var(--merah-muda); color: var(--merah); }
.status.kosong { background: #eee; color: var(--redup); font-weight: 400; }
details.bayar-sebagian { display: inline-block; }
details.bayar-sebagian > summary { list-style: none; cursor: pointer; }
details.bayar-sebagian > summary::-webkit-details-marker { display: none; }
details.bayar-sebagian[open] { display: block; margin-top: .3rem; white-space: normal; }

/* Kartu hari di tagihan */
details.hari { padding: 0; }
details.hari > summary { list-style: none; cursor: pointer; padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; }
details.hari > summary::-webkit-details-marker { display: none; }
details.hari > summary::before { content: "▸"; margin-right: .5rem; color: var(--redup); }
details.hari[open] > summary::before { content: "▾"; }
details.hari > summary span:first-child { flex: 1; }
details.hari form, details.hari .isi-hari { padding: 0 1rem 1rem; }
.lencana { background: var(--hijau-muda); color: #17402f; border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; font-weight: 600; }
.lencana.kosong { background: #eee; color: var(--redup); font-weight: 400; }

/* Halaman masuk */
.halaman-masuk { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--hijau) 0 35%, var(--latar) 35%); }
.kotak-masuk { background: #fff; padding: 1.75rem; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.12); text-align: center; }
.kotak-masuk.lebar { max-width: 560px; text-align: left; }
.kotak-masuk .formulir { text-align: left; margin-top: 1rem; }

/* Formulir stok di layar sempit: tiap item jadi kartu */
@media (max-width: 640px) {
  .isi { padding: .7rem; }
  h1 { font-size: 1.2rem; }
  .form-stok .tabel-gulir { overflow: visible; }
  .form-stok table, .form-stok tbody, .form-stok tr, .form-stok td, .form-stok th { display: block; }
  .form-stok thead { display: none; }
  .form-stok tr { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .6rem; border: 1px solid var(--garis); border-radius: 8px; padding: .6rem; margin-bottom: .6rem; }
  .form-stok tr th { grid-column: 1 / -1; border: 0; padding: 0; font-size: 1rem; }
  .form-stok td { border: 0; padding: 0; text-align: left !important; }
  .form-stok td::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--redup); }
  .form-stok td.sisa-hidup { font-size: 1.1rem; }
  .akun a:first-child small { display: none; }
  .tabel th, .tabel td { padding: .4rem .25rem; font-size: .86rem; }
  .kartu { padding: .75rem; }
  .tabel-gulir { margin: 0; padding: 0; }
  .tabel th:first-child { white-space: normal; }
  .form-tagihan .tabel { table-layout: fixed; }
  .form-tagihan .tabel th:first-child { width: 26%; white-space: normal; font-size: .85rem; }
  .form-tagihan .tabel th:last-child { width: 14%; }
  .form-tagihan .tabel td { padding: .2rem .15rem; }
  .form-tagihan .tabel thead th { padding: .35rem .1rem; font-size: .75rem; }
  .form-tagihan input.angka { min-width: 0 !important; padding: .4rem .3rem; }
  .form-tagihan td.jumlah-hidup { font-size: .85rem; }
  .form-tagihan .tabel-gulir { overflow: visible; }
}
.hanya-hp { display: none; }
@media (max-width: 640px) {
  .tabel-kartu thead { display: none; }
  .tabel-kartu, .tabel-kartu tbody, .tabel-kartu tfoot, .tabel-kartu tr { display: block; width: 100%; }
  .tabel-kartu tr { border: 1px solid var(--garis); border-radius: 8px; padding: .5rem .7rem; margin-bottom: .5rem; background: #fff; }
  .tabel-kartu tfoot tr, .tabel-kartu tr.subtotal { background: #f7faf8; border-color: var(--hijau-2); }
  .tabel-kartu th, .tabel-kartu td { display: flex; justify-content: space-between; align-items: center; gap: .5rem; border: 0 !important; padding: .15rem 0 !important; background: transparent !important; white-space: normal; }
  .tabel-kartu th { font-size: .95rem; margin-bottom: .2rem; }
  .tabel-kartu td::before { content: attr(data-label); color: var(--redup); font-weight: 400; font-size: .82rem; }
  .tabel-kartu td:empty, .tabel-kartu td.tanpa-hp { display: none; }
  .tabel-kartu .hanya-hp { display: inline; }
}
@media print {
  .atas, .bawah, .tombol, form, .pilih-periode { display: none !important; }
  .kartu { border: 0; padding: 0; }
}
.baris-aksi { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; margin-top: .75rem; }
.baris-aksi form { margin: 0; }
.baris-aksi details.bayar-sebagian[open] { flex-basis: 100%; }
.tabel td.kiri { text-align: left; }
.isi-sel { display: inline-block; text-align: right; }
.ringkas-utang { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem 1rem; margin: .5rem 0; }
.ringkas-utang div { display: flex; flex-direction: column; }
.ringkas-utang span { color: var(--redup); font-size: .8rem; }
.ringkas-utang b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ringkas-utang b.minus { color: var(--merah); }
.ringkas-utang small { color: var(--redup); font-size: .8rem; }
.bilah { height: 8px; background: #eee; border-radius: 999px; overflow: hidden; margin: .4rem 0 .2rem; }
.bilah span { display: block; height: 100%; background: var(--hijau-2); }
details.riwayat { margin-top: .75rem; border-top: 1px dashed var(--garis); padding-top: .5rem; }
details.riwayat > summary { cursor: pointer; color: var(--hijau-2); font-size: .9rem; }
.tabel td.porsi { min-width: 120px; }
.tabel td.porsi .bilah { margin: 0; display: inline-block; width: 70%; vertical-align: middle; }
.tabel td.porsi small { color: var(--redup); margin-left: .3rem; }
.tabel.laba-bersih { max-width: 560px; margin-top: .75rem; } .tabel.laba-bersih th { font-weight: 400; } .tabel.laba-bersih tfoot th { font-weight: 700; }
label .centang.kecil { display: inline-flex; gap: .3rem; align-items: center; font-weight: 400; margin-top: .3rem; } label .centang.kecil input { width: auto !important; display: inline !important; min-height: 0; margin: 0 !important; } label[hidden] { display: none !important; }
.baris-form input.pendek { flex: 0 0 80px !important; width: 80px; }
