:root { --biru:#1F4E79; --biru-tua:#163A5C; --oranye:#E8772E; --latar:#F4F6F9; --garis:#D5DBE3; --teks:#1D2733; --pudar:#6A7788; --bahaya:#B42318; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; color: var(--teks); background: var(--latar); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.pudar { color: var(--pudar); } .kecil { font-size: 12px; }
.galat { color: var(--bahaya); min-height: 1.2em; margin: .4em 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: #fff; border: 1px solid var(--garis); border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 38px; }
button:hover { background: #EAF1F8; border-color: #9DB8D2; }
button:disabled { opacity: .55; cursor: default; }
button.utama { background: var(--oranye); border-color: #CF6420; color: #fff; font-weight: 600; }
button.utama:hover { background: #F0873F; }
button.bahaya { color: var(--bahaya); } button.bahaya:hover { background: #FDECEA; border-color: #E8A39B; }
input, select, textarea { width: 100%; background: #fff; border: 1px solid var(--garis); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--biru); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; padding: 0; }
textarea { resize: vertical; }

/* login */
#login, #belumSetel { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.kartu-login { background: #fff; border: 1px solid var(--garis); border-radius: 14px; padding: 28px 24px; width: min(380px, 100%); display: grid; gap: 12px; }
#belumSetel.kartu-login { margin: 12vh auto; }
.kartu-login h1 { color: var(--biru); font-size: 22px; }
.kartu-login label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.logo-login { height: 52px; justify-self: start; }

/* bar atas */
.bar { background: var(--biru); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); position: sticky; top: 0; z-index: 5; }
.bar-kiri { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-kiri img { height: 34px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.bar-kiri b { display: block; font-size: 17px; } .bar-kiri span { font-size: 12px; color: #BCD0E4; }
.bar-kanan { display: flex; gap: 8px; align-items: center; }
.bar-btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff; }
.bar-btn:hover { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.4); }
#namaAkun { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.menu { position: fixed; top: 54px; right: 16px; z-index: 20; background: #fff; border: 1px solid var(--garis); border-radius: 10px; padding: 6px; width: 260px; box-shadow: 0 8px 24px rgba(0,0,0,.18); display: grid; gap: 4px; }
.menu button { text-align: left; border: 0; } .menu p { margin: 4px 8px; }

/* daftar */
main { max-width: 1200px; margin: 0 auto; padding: 14px 16px 40px; }
.filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filter #cari { flex: 1 1 240px; width: auto; } .filter select { width: auto; flex: 0 1 160px; }
.tabel-bungkus { background: #fff; border: 1px solid var(--garis); border-radius: 10px; overflow-x: auto; }
table#tabel { width: 100%; border-collapse: collapse; }
#tabel th { background: #EDF1F6; color: var(--biru); text-align: left; padding: 9px 10px; font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--garis); user-select: none; }
#tabel th[data-urut] { cursor: pointer; } #tabel th[data-urut]::after { content: " " attr(data-arah); font-size: 10px; }
#tabel td { padding: 8px 10px; border-bottom: 1px solid #EEF1F5; vertical-align: middle; }
#tabel tbody tr { cursor: pointer; } #tabel tbody tr:hover { background: #F3F8FD; }
#tabel .cek { width: 38px; text-align: center; } #tabel .aksi { text-align: right; width: 70px; }
.kecil-btn { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.hp-sub { display: none; color: var(--pudar); font-size: 12px; }
.kosong { text-align: center; color: var(--pudar); padding: 28px; margin: 0; }

/* dialog formulir */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(960px, 96vw); max-height: 94dvh; background: #fff; color: var(--teks); }
dialog::backdrop { background: rgba(15,25,40,.5); }
dialog > form, #isiInfo form { display: flex; flex-direction: column; max-height: 94dvh; padding: 0; }
#isiInfo { padding: 20px; } #isiInfo h2 { margin-bottom: 10px; }
#dlgInfo { width: min(420px, 94vw); }
.dlg-kepala { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 8px; }
.dlg-kepala h2 { font-size: 18px; color: var(--biru); } .tutup { border: 0; background: none; font-size: 18px; padding: 4px 10px; }
.tab { display: flex; gap: 4px; padding: 0 14px; overflow-x: auto; border-bottom: 1px solid var(--garis); scrollbar-width: thin; }
.tab button { border: 0; border-radius: 8px 8px 0 0; background: #E6EBF1; color: var(--pudar); white-space: nowrap; padding: 8px 12px; min-height: 36px; }
.tab button[aria-selected=true] { background: #fff; color: var(--biru); font-weight: 700; box-shadow: inset 0 -2px 0 var(--biru); }
.dlg-isi { padding: 14px 18px; overflow-y: auto; flex: 1; min-height: 260px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 14px; }
.fld { display: grid; gap: 3px; align-content: start; } .fld > span { font-size: 12px; font-weight: 600; color: var(--pudar); }
.fld.lebar { grid-column: 1 / -1; }
.dlg-kaki { display: flex; justify-content: space-between; gap: 8px; padding: 10px 18px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--garis); background: #fff; }
.dlg-kaki .kanan { display: flex; gap: 8px; }
#galatForm { padding: 0 18px; margin: 0; }
.foto-blok { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.foto-kotak { width: 96px; height: 128px; border: 1px dashed #9AA7B8; border-radius: 8px; background: #EEF1F5; display: grid; place-items: center; color: var(--pudar); font-size: 12px; text-align: center; overflow: hidden; flex: none; }
.foto-kotak img { width: 100%; height: 100%; object-fit: contain; }
.btn-file { display: inline-block; background: #fff; border: 1px solid var(--garis); border-radius: 8px; padding: 8px 14px; cursor: pointer; margin-right: 6px; }
.halaman h3 { margin: 18px 0 8px; color: var(--biru); font-size: 14px; }
.baris { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) 40px; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--garis); border-radius: 10px; margin-bottom: 8px; background: #FAFBFD; }
.hapus-baris { padding: 6px; color: var(--bahaya); }
#toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); background: #1D2733; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 92vw; }
#toast.tampil { opacity: 1; transform: translate(-50%, 0); } #toast.galat { background: var(--bahaya); color: #fff; }

/* HP */
@media (max-width: 720px) {
  .bar { padding: 8px 10px; } .bar-kiri span { display: none; } .bar-kiri img { display: none; }
  .bar-btn, button.utama { padding: 8px 10px; }
  #btnCadang { display: none; }  /* cadangan lewat laptop */
  .menu { right: 8px; left: 8px; width: auto; top: 52px; }
  main { padding: 10px 10px 40px; }
  .filter select { flex: 1 1 45%; }
  #tabel .h-nis, #tabel .h-gen, #tabel .h-bat, #tabel .h-tgl, #tabel .h-usia, #tabel .h-pend, #tabel .h-wa, #tabel .h-foto { display: none; }
  #tabel th:nth-child(n+2):not(:nth-child(3)):not(:last-child) { display: none; }
  .hp-sub { display: block; }
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  dialog > form { height: 100dvh; max-height: 100dvh; }
  .grid { grid-template-columns: 1fr; }
  .baris { grid-template-columns: 1fr 1fr; } .baris .hapus-baris { grid-column: 1 / -1; }
  input, select, textarea { font-size: 16px; }   /* cegah zoom otomatis di iPhone */
}

/* cetak */
@media print {
  body.mencetak { background: #fff; }
  body.mencetak #app, body.mencetak dialog, body.mencetak #toast { display: none !important; }
  body.mencetak #cetak { display: block; }
}
