/* Kas RT — gaya tampilan. Terang/gelap lewat atribut data-theme pada <html>. */
:root {
  --bg: #F4F7F5; --kartu: #FFFFFF; --teks: #14221C; --teks2: #52645B; --garis: #DCE5E0;
  --hijau: #0F6E56; --hijau-hover: #0A5A46; --on-hijau: #FFFFFF; --hijau-bg: #E3F4EC; --hijau-teks: #0A5A46;
  --emas: #F2B544; --kuning-bg: #FFF3D1; --kuning: #7A5200; --merah: #B3261E; --merah-bg: #FDE9E7;
  --biru-bg: #E6F0FB; --biru: #1B4F8A; --abu-bg: #EEF2EF;
  --bayang: 0 1px 2px rgba(20, 34, 28, .06), 0 6px 18px rgba(20, 34, 28, .06);
  --r: 16px; --tinggi: 54px;
}
[data-theme="gelap"] {
  --bg: #0D1512; --kartu: #16211C; --teks: #E7F0EB; --teks2: #9BB0A5; --garis: #273630;
  --hijau: #46C29B; --hijau-hover: #6AD3B1; --on-hijau: #06201A; --hijau-bg: #10312A; --hijau-teks: #8EE3C7;
  --kuning-bg: #3A2F10; --kuning: #F2CF7A; --merah: #FF8A80; --merah-bg: #3A1816;
  --biru-bg: #12263B; --biru: #8DBCF0; --abu-bg: #1D2A25; --bayang: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--teks); font-size: 18px; line-height: 1.5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 1.45rem; line-height: 1.25; margin: .2rem 0 .3rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .6rem; }
small, .kecil { font-size: .82rem; color: var(--teks2); }
button, input, select, textarea { font: inherit; color: inherit; }
.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; }

/* ---------- kerangka ---------- */
.atas {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--hijau); color: var(--on-hijau);
}
.merek { display: flex; align-items: center; gap: 10px; min-width: 0; }
.merek b { display: block; font-size: 1.02rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merek small { color: inherit; opacity: .85; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merek > div { min-width: 0; }
.logo { width: 38px; height: 38px; flex: none; border-radius: 11px; background: #fff; display: grid; place-items: center; }
.logo svg { width: 28px; height: 28px; }
.kanan { display: flex; align-items: center; gap: 6px; flex: none; }
.ikon-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .16); color: inherit; display: grid; place-items: center; cursor: pointer; }
.ikon-btn:active { background: rgba(255, 255, 255, .28); }
[data-theme="gelap"] .atas { background: #12352C; color: #E7F0EB; }
.sinkron { font-size: .74rem; padding: 4px 9px; border-radius: 99px; background: rgba(255, 255, 255, .18); white-space: nowrap; border: 0; color: inherit; }
.sinkron.peringatan { background: var(--emas); color: #4A3000; }
.isi { padding: 16px 16px calc(104px + env(safe-area-inset-bottom)); }
.bawah {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 2px; overflow-x: auto;
  background: var(--kartu); border-top: 1px solid var(--garis); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}
.bawah button {
  flex: 1 0 74px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px; border: 0; background: none;
  color: var(--teks2); border-radius: 12px; font-size: .74rem; cursor: pointer; min-height: 58px;
}
.bawah button.aktif { color: var(--hijau); background: var(--hijau-bg); font-weight: 600; }
.bawah svg { width: 24px; height: 24px; }
.ikon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- kartu & teks ---------- */
.sapa { margin: 4px 0 14px; }
.sapa .peran { color: var(--teks2); font-size: .9rem; margin: 0; }
.kartu { background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--bayang); }
.kartu h2 { display: flex; align-items: center; gap: 8px; }
.label { font-size: .86rem; color: var(--teks2); margin: 0 0 2px; }
.angka-besar { font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.angka-besar.hijau { color: var(--hijau); }
.sub { color: var(--teks2); font-size: .9rem; margin: 4px 0 0; }
.dua { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dua .kartu { margin: 0; }
.kosong { text-align: center; color: var(--teks2); padding: 18px 8px; }
.kredit { text-align: center; font-size: .74rem; color: var(--teks2); margin: 22px 8px 0; }

/* ---------- tombol ---------- */
.tombol {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: var(--tinggi); padding: 10px 18px;
  border-radius: 14px; border: 1.5px solid var(--garis); background: var(--kartu); color: var(--teks); font-weight: 600; cursor: pointer; text-align: center;
}
.tombol:active { transform: scale(.985); }
.tombol.utama { background: var(--hijau); border-color: var(--hijau); color: var(--on-hijau); }
.tombol.utama:hover { background: var(--hijau-hover); }
.tombol.bahaya { color: var(--merah); border-color: var(--merah); background: transparent; }
.tombol.kecil { width: auto; min-height: 40px; padding: 6px 14px; font-size: .88rem; border-radius: 11px; }
.tombol[disabled] { opacity: .65; cursor: progress; }
.tombol-baris { display: flex; gap: 10px; margin-top: 14px; }
.tombol-baris > .tombol { flex: 1; }
.putar { width: 18px; height: 18px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: putar .8s linear infinite; }
@keyframes putar { to { transform: rotate(360deg); } }

/* ---------- formulir ---------- */
.medan { margin-bottom: 14px; }
.medan label, .medan .judul { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 5px; }
.medan .bantu { font-weight: 400; color: var(--teks2); font-size: .8rem; margin: 4px 0 0; }
input[type=text], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; min-height: var(--tinggi); padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--garis); background: var(--kartu);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--hijau) 35%, transparent); border-color: var(--hijau); }
.rp-input { position: relative; }
.rp-input span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--teks2); font-weight: 600; pointer-events: none; }
.rp-input input { padding-left: 48px; font-size: 1.35rem; font-weight: 700; }
.terbilang { font-size: .84rem; color: var(--teks2); min-height: 1.3em; margin-top: 4px; font-style: italic; }
details.hitung { border: 1.5px dashed var(--garis); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; }
details.hitung summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.pecahan { display: grid; grid-template-columns: 1fr 96px 1fr; gap: 8px; align-items: center; margin: 6px 0; font-size: .92rem; }
.pecahan input { min-height: 44px; padding: 6px 10px; text-align: center; }
.pecahan .jml { text-align: right; color: var(--teks2); }
.total-hitung { display: flex; justify-content: space-between; font-weight: 700; padding: 8px 0; border-top: 1px solid var(--garis); margin-top: 6px; }
.pilihan { display: flex; gap: 8px; }
.pilihan label { flex: 1; margin: 0; }
.pilihan input { position: absolute; opacity: 0; }
.pilihan span { display: flex; align-items: center; justify-content: center; min-height: var(--tinggi); border-radius: 14px; border: 1.5px solid var(--garis); font-weight: 600; cursor: pointer; }
.pilihan input:checked + span { background: var(--hijau-bg); border-color: var(--hijau); color: var(--hijau-teks); }
.pilihan input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--hijau) 35%, transparent); }

/* ---------- daftar ---------- */
.daftar { display: flex; flex-direction: column; }
.baris { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--garis); }
.baris:last-child { border-bottom: 0; }
.baris .kiri { min-width: 0; flex: 1; }
.baris .kiri b { display: block; }
.baris .kiri small { display: block; }
.baris .kanan-teks { text-align: right; flex: none; }
.baris.klik { cursor: pointer; background: none; border-width: 0 0 1px; width: 100%; text-align: left; color: inherit; }
.nominal { font-weight: 700; white-space: nowrap; }
.nominal.masuk { color: var(--hijau); }
.nominal.keluar { color: var(--merah); }
.batal-teks { text-decoration: line-through; opacity: .55; }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--abu-bg); color: var(--teks2); }
.chip.hijau { background: var(--hijau-bg); color: var(--hijau-teks); }
.chip.kuning { background: var(--kuning-bg); color: var(--kuning); }
.chip.merah { background: var(--merah-bg); color: var(--merah); }
.chip.biru { background: var(--biru-bg); color: var(--biru); }
.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.banner.info { background: var(--biru-bg); color: var(--biru); }
.banner.peringatan { background: var(--kuning-bg); color: var(--kuning); }
.banner.galat { background: var(--merah-bg); color: var(--merah); }
.banner.sukses { background: var(--hijau-bg); color: var(--hijau-teks); }
.banner .tombol { margin-top: 8px; }
.ringkas { display: grid; gap: 4px; font-size: .95rem; }
.ringkas div { display: flex; justify-content: space-between; gap: 12px; }
.ringkas .tebal { font-weight: 700; border-top: 1px solid var(--garis); padding-top: 6px; margin-top: 4px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px 22px; gap: 6px; }
.login .logo-besar { width: 92px; height: 92px; border-radius: 26px; background: var(--hijau); display: grid; place-items: center; margin-bottom: 10px; }
.login .logo-besar svg { width: 64px; height: 64px; }
.login p { color: var(--teks2); max-width: 340px; }
#gsi { min-height: 48px; display: flex; justify-content: center; margin: 14px 0 6px; }
.login form { width: 100%; max-width: 340px; text-align: left; margin-top: 10px; }

/* ---------- dialog, toast ---------- */
#modal .tirai { position: fixed; inset: 0; background: rgba(5, 15, 11, .55); z-index: 40; }
#modal .dialog {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow: auto;
  background: var(--kartu); border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
}
@media (min-width: 640px) { #modal .dialog { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 22px; } }
.dialog .besar { font-size: 1.9rem; font-weight: 800; margin: 4px 0 0; color: var(--hijau); }
.dialog .isi-dialog p { margin-bottom: .5rem; }
.dialog .galat-inline { color: var(--merah); font-size: .9rem; min-height: 1.2em; margin-top: 6px; }
#toast { position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
#toast div { max-width: 520px; padding: 12px 16px; border-radius: 14px; background: #14221C; color: #fff; font-size: .95rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); animation: muncul .2s ease-out; }
#toast div.galat { background: #B3261E; }
#toast div.sukses { background: #0F6E56; }
@keyframes muncul { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; } }

/* ---------- tanda serah terima ---------- */
.lapis { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow: auto; padding: 14px 14px calc(110px + env(safe-area-inset-bottom)); }
.lapis .aksi-tanda { position: fixed; left: 0; right: 0; bottom: 0; max-width: 720px; margin: 0 auto; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--kartu); border-top: 1px solid var(--garis); }
.lapis .aksi-tanda .tombol { flex: 1; min-height: 50px; padding: 8px; font-size: .9rem; }
.tanda { max-width: 600px; margin: 0 auto; background: #fff; color: #14221C; border: 1px solid #DCE5E0; border-radius: 6px; padding: 22px 20px; box-shadow: var(--bayang); }
.tanda .kop { display: flex; align-items: center; gap: 12px; border-bottom: 3px double #0F6E56; padding-bottom: 12px; margin-bottom: 14px; }
.tanda .kop .logo { background: #0F6E56; }
.tanda .kop small { color: #52645B; display: block; line-height: 1.3; }
.tanda h2 { text-align: center; font-size: 1.05rem; letter-spacing: .04em; margin: 8px 0 0; }
.tanda .nomor { text-align: center; color: #52645B; margin-bottom: 14px; font-size: .92rem; }
.tanda table { width: 100%; border-collapse: collapse; font-size: .95rem; margin-bottom: 14px; }
.tanda td { padding: 7px 0; border-bottom: 1px solid #E6ECE8; vertical-align: top; }
.tanda td:last-child { text-align: right; font-weight: 600; }
.tanda tr.total td { font-size: 1.1rem; font-weight: 800; border-bottom: 2px solid #14221C; color: #0A5A46; }
.tanda .status { border-radius: 8px; padding: 10px 12px; font-size: .92rem; margin-bottom: 14px; background: #EEF2EF; }
.tanda .status.ok { background: #E3F4EC; color: #0A5A46; }
.tanda .status.tunggu { background: #FFF3D1; color: #7A5200; }
.tanda .status.tidak { background: #FDE9E7; color: #B3261E; }
.tanda .tanda-tangan { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; font-size: .86rem; margin-top: 8px; }
.tanda .tanda-tangan > div { border: 1px dashed #B8C6BE; border-radius: 8px; padding: 10px 6px; }
.tanda .tanda-tangan b { display: block; margin: 6px 0 2px; font-size: .95rem; }
.tanda .cek { color: #0A5A46; font-weight: 700; }
.tanda .kaki { margin-top: 14px; font-size: .72rem; color: #52645B; text-align: center; }

@media print {
  body { background: #fff; }
  .app, #toast, #modal, .lapis .aksi-tanda { display: none !important; }
  .lapis { position: static; padding: 0; overflow: visible; background: #fff; }
  .tanda { border: 0; box-shadow: none; max-width: none; }
}
