/* Gaya dasar aplikasi Kredensial PLKK (tanpa framework CSS, berjalan offline). */

:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #616e7c;
  --border: #d9e2ec;
  --error: #b42318;
  --error-bg: #fef3f2;
  --warning-bg: #fffaeb;
  --warning-border: #f5c26b;
  --success-bg: #ecfdf3;
  --success-border: #75e0a7;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }
code { background: #eef2f6; padding: .1rem .3rem; border-radius: 4px; font-size: .9em; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.main { padding-top: 1.5rem; padding-bottom: 3rem; }
.muted { color: var(--muted); margin: 0; }

/* Topbar */
.topbar { background: var(--primary); color: #fff; }
.topbar__inner { display: flex; align-items: center; gap: 1.5rem; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: #fff; font-weight: 700; text-decoration: none; }
.brand__logo { box-sizing: content-box; height: 36px; width: auto; flex: none; display: block; padding: 4px 8px; background: #fff; border-radius: 6px; } /* rasio asli 1280x297 dipertahankan; latar putih agar logo terbaca di navbar hijau */
.brand__text span { font-weight: 400; opacity: .85; }
.nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; opacity: .9; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.nav__akun { display: flex; align-items: center; gap: .6rem; margin: 0; }
.nav__email { color: #fff; font-size: .85rem; opacity: .9; }

/* Layout umum */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stats .card { margin-bottom: 0; }
.stat { display: flex; flex-direction: column; }
.stat__label { color: var(--muted); font-size: .9rem; }
.stat__value { font-size: 1.8rem; font-weight: 700; }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem 1.5rem; }
.status-list li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: .25rem 0; }

/* Tombol */
.btn { display: inline-block; padding: .55rem 1rem; border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn--danger { background: transparent; color: var(--error); border-color: #fda29b; }
.btn--danger:hover { background: var(--error-bg); }
.btn--danger-solid { background: var(--error); color: #fff; }
.btn--sm { padding: .3rem .7rem; font-size: .85rem; }
.btn--block { width: 100%; }
.btn[hidden] { display: none; }

/* Form */
.form-card { max-width: 720px; }
.field { margin-bottom: 1.1rem; }
.field--narrow { max-width: 200px; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input, .field select { width: 100%; padding: .55rem .7rem; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.field select:disabled, .field input:disabled { background: #f0f3f6; color: var(--muted); }
.field__readonly { background: #f0f3f6 !important; font-family: ui-monospace, Consolas, monospace; }
.field__help { color: var(--muted); font-size: .85rem; margin: .3rem 0 0; }
.field__error { color: var(--error); font-size: .85rem; margin: .3rem 0 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }
fieldset.field { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
fieldset.field legend { font-weight: 600; margin-bottom: .35rem; padding: 0; }
.faskes-baru { border-left: 3px solid var(--warning-border); padding-left: .9rem; margin-bottom: 1.1rem; }
.faskes-baru__kepala { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }

/* Pemilih faskes: satu kontrol cari + pilih (combobox, static/js/kredensial_baru.js). Daftar melayang di bawah input. */
.pemilih { position: relative; }
.pemilih__daftar {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .25rem 0; list-style: none;
  max-height: min(20rem, 55vh); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 20px rgba(31, 41, 51, .14);
}
.pemilih__opsi { display: flex; flex-direction: column; gap: .1rem; padding: .5rem .7rem; cursor: pointer; overflow-wrap: anywhere; }
.pemilih__opsi:hover, .pemilih__opsi--aktif { background: #e6f4f2; }
.pemilih__opsi[aria-selected="true"] .pemilih__nama { font-weight: 600; }
.pemilih__meta { color: var(--muted); font-size: .85rem; font-family: ui-monospace, Consolas, monospace; }
.pemilih__info { padding: .5rem .7rem; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.pemilih__tambah { margin-top: .6rem; }
.checkbox { display: flex; align-items: flex-start; gap: .5rem; font-weight: 600; cursor: pointer; }
.checkbox input { width: auto; margin-top: .25rem; flex: none; }

/* Alert */
.alert { padding: .75rem 1rem; border-radius: 6px; border: 1px solid var(--border); background: #eef2f6; margin-bottom: 1rem; }
.alert--error { background: var(--error-bg); border-color: #fda29b; color: var(--error); }
.alert--warning { background: var(--warning-bg); border-color: var(--warning-border); }
.alert--success { background: var(--success-bg); border-color: var(--success-border); }

/* Tabel */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* Badge status */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef2f6; color: var(--text); white-space: nowrap; }
.badge--in_progress { background: #e0f2fe; color: #075985; }
.badge--ready_for_export { background: #ede9fe; color: #5b21b6; }
.badge--waiting_signed_document { background: #fef3c7; color: #92400e; }
.badge--completed { background: #dcfce7; color: #166534; }
.badge--faskes-baru { background: #fef3c7; color: #92400e; }

/* Detail */
.info { display: grid; grid-template-columns: fit-content(45%) 1fr; gap: .4rem 1.5rem; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; }
.steps { margin: .75rem 0 0; padding-left: 1.25rem; color: var(--muted); }

/* ===== Tahap 2: info kredensial, stepper, form identitas ===== */
.mono { font-family: ui-monospace, Consolas, monospace; }
.note { background: #eef6ff; border: 1px solid #bcd7f5; border-radius: 6px; padding: .6rem .9rem; margin: .75rem 0 1rem; font-size: .9rem; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card__head h2 { margin: 0; }
.info--grid { grid-template-columns: fit-content(30%) 1fr fit-content(30%) 1fr; gap: .4rem 1.5rem; }
.info .pre { white-space: pre-line; }
.alert--warning a, .alert--error a { color: inherit; font-weight: 600; }

.stepper { margin-bottom: 1.25rem; }
.stepper ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; }
.step__isi { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .5rem; row-gap: .1rem; height: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
a.step__isi:hover { border-color: var(--primary); }
.step__nomor { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #e4e9ee; font-size: .8rem; font-weight: 700; }
.step__label { font-weight: 600; }
.step__ket { grid-column: 2; font-size: .78rem; color: var(--muted); }
.step--aktif .step__isi { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(15, 118, 110, .2); }
.step--aktif .step__nomor { background: var(--primary); color: #fff; }
.step--nonaktif .step__isi { background: #f0f3f6; color: var(--muted); cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.form-grid .field--full { grid-column: 1 / -1; }
.field__static { padding: .55rem .7rem; background: #f0f3f6; border: 1px solid var(--border); border-radius: 6px; font-weight: 600; }
.field textarea { width: 100%; padding: .55rem .7rem; font: inherit; border: 1px solid var(--border); border-radius: 6px; resize: vertical; }
.field textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.field--error input:not([type=radio]), .field--error textarea, .field--error select { border-color: var(--error); }
.wajib { color: var(--error); font-weight: 700; }
.radio-group { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.radio { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400 !important; margin: 0 !important; cursor: pointer; }
.radio input { width: auto !important; }
.form-actions--split { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.form-actions__kanan { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ===== Tahap 3: Aspek Legalitas & dokumen ===== */
.step__cek { color: var(--primary); font-weight: 700; }
.butir { scroll-margin-top: 1rem; }
.butir--error { border-color: #fda29b; }
.butir__kepala { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.butir__judul { font-size: 1rem; margin: 0; display: flex; gap: .6rem; align-items: baseline; flex: 1 1 320px; }
.butir__nomor { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #e4e9ee; font-size: .8rem; font-weight: 700; }
.butir__tersimpan { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }
.radio--nonaktif { opacity: .5; cursor: not-allowed !important; text-decoration: line-through; }
.dokumen-blok { border-top: 1px dashed var(--border); margin-top: 1rem; padding-top: 1rem; }
.dokumen-blok h4 { margin: 0 0 .5rem; font-size: .95rem; }
.dasar-ya { font-size: .9rem; padding: .45rem .7rem; border-radius: 6px; background: #f0f3f6; margin: 0 0 .75rem; }
.dasar-ya--ok { background: var(--success-bg); }
.dasar-ya--larang { background: var(--error-bg); color: var(--error); font-weight: 600; }
.dokumen { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; margin-bottom: .9rem; background: #fbfcfd; scroll-margin-top: 1rem; }
.dokumen__kepala { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.dokumen__nama { font-weight: 600; word-break: break-all; }
.dokumen__aksi { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-start; margin-top: .75rem; }
.dokumen__aksi form { margin: 0; }
.info--kecil { font-size: .88rem; margin-bottom: .6rem; }
.info--kecil dd { font-weight: 400; }
.konfirmasi { border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .5rem; }
.info-durasi { background: var(--warning-bg); border: 1px dashed var(--warning-border); border-radius: 6px; padding: .6rem .8rem; margin: .5rem 0 .75rem; font-size: .9rem; }
.info-durasi p { margin: .4rem 0 0; }
.sementara { color: #92400e; font-weight: 600; }
.upload { margin-top: .5rem; }
.upload--inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.upload--inline label { font-weight: 600; font-size: .9rem; }
.mentah { margin-top: .75rem; font-size: .85rem; }
.mentah pre { white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; background: #f0f3f6; padding: .6rem; border-radius: 6px; }
.histori { margin-top: .75rem; font-size: .88rem; }
.histori ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.badge-dok--uploaded, .badge-dok--processing { background: #e0f2fe; color: #075985; }
.badge-dok--needs_review { background: #fef3c7; color: #92400e; }
.badge-dok--failed { background: var(--error-bg); color: var(--error); }
.badge-dok--verified { background: #dcfce7; color: #166534; }
.badge-dok--expired { background: #fee4e2; color: #912018; }

/* ===== Tahap 4: Aspek SDM & daftar dokter ===== */
.sub-judul { font-size: 1rem; margin: 0 0 .5rem; }
.kecil { font-size: .8rem; margin: .15rem 0 0; }
.catatan { color: #92400e; }
.tengah { text-align: center; }
.ringkas { font-size: .9rem; background: #f0f3f6; border-radius: 6px; padding: .45rem .7rem; }
.alur { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; counter-reset: alur; }
.alur__langkah { font-size: .82rem; padding: .25rem .65rem; border-radius: 999px; background: #eef2f6; color: var(--muted); }
.alur__langkah--selesai { background: #dcfce7; color: #166534; font-weight: 600; }
.badge-daftar--tahap_1 { background: #fef3c7; color: #92400e; }
.badge-daftar--menunggu_review { background: #e0f2fe; color: #075985; }
.badge-daftar--final { background: #dcfce7; color: #166534; }
.badge-proses--uploaded, .badge-proses--processing { background: #e0f2fe; color: #075985; }
.badge-proses--extracted { background: #dcfce7; color: #166534; }
.badge-proses--failed { background: var(--error-bg); color: var(--error); }
.table--kandidat input[type=text], .table--kandidat select { width: 100%; min-width: 9rem; padding: .35rem .5rem; font: inherit; font-size: .9rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.table--kandidat td:nth-child(2) { min-width: 15rem; }
.table--kandidat .js-spesialisasi-lainnya { margin-top: .3rem; }
.baris--duplikat { background: var(--warning-bg); }
.baris--error { background: var(--error-bg); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; background: #eef2f6; margin: .25rem .25rem 0 0; }
.tag--warning { background: #fef3c7; color: #92400e; }
.duplikat { border: 1px dashed var(--warning-border); background: var(--warning-bg); border-radius: var(--radius); padding: .75rem .9rem; margin: .75rem 0 1rem; scroll-margin-top: 1rem; }
.duplikat h4 { margin: 0 0 .25rem; }
.duplikat__item { border-top: 1px solid var(--warning-border); padding-top: .6rem; margin-top: .6rem; }
.duplikat__ket { font-size: .88rem; margin: 0 0 .35rem; font-weight: 600; }
.duplikat__aksi { display: flex; gap: .5rem; margin-top: .4rem; }
.daftar-masalah { margin: .4rem 0 0; padding-left: 1.2rem; }
.tambah { margin-top: 1rem; }
.tambah summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.tambah form { margin-top: .75rem; }
.form-actions--kiri { justify-content: flex-start; flex-wrap: wrap; }
.form-actions--kiri form { margin: 0; }
.stats--kecil { margin: .75rem 0; }
.stats--kecil .stat__value { font-size: 1.5rem; }
.table--sdm td:first-child { width: 2.5rem; }
.table--sdm td:last-child { width: 6rem; }
.baris-sub td { padding-top: .35rem; padding-bottom: .35rem; font-size: .92rem; }
.baris-sub td:nth-child(2) { padding-left: 1.5rem; }
.perlu-konfirmasi { color: #92400e; font-weight: 700; }
.nilai-aspek { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1rem 0 .5rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: #f0f3f6; font-weight: 600; }
.nilai-aspek--final { background: var(--success-bg); border-color: var(--success-border); }
.nilai-aspek__angka { font-size: 1.8rem; }

/* Aspek Sarana dan Prasarana (Tahap 5) */
.daftar-kelompok { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: .5rem 0 0; padding-left: 1.25rem; }
.radio-group--kolom { flex-direction: column; gap: .3rem; }
.riwayat { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .9rem; }

/* Review keseluruhan (Tahap 7) */
.review-status { font-weight: 700; font-size: .85rem; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: #f0f3f6; white-space: nowrap; }
.review-status--siap { background: var(--success-bg); border-color: var(--success-border); }
.review-status--belum_lengkap { background: var(--warning-bg); border-color: var(--warning-border); }
.review-status--needs_review { background: var(--warning-bg); border-color: var(--warning-border); color: #92400e; }
.review-aksi { margin: .75rem 0 0; }
.hasil-akhir { border-width: 2px; }
.hasil-akhir--final { border-color: var(--success-border); }
.hasil-akhir__angka { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin: 1rem 0; }
.hasil-akhir__kategori { font-size: 2.2rem; }
.hasil-akhir__belum { font-size: 1.4rem; color: #92400e; margin: .25rem 0 .5rem; }
.kriteria { max-width: 420px; margin-top: 1rem; }
.kriteria--terpilih td { font-weight: 700; background: var(--success-bg); }

/* Dokumen akhir / arsip (Tahap 8) */
.badge--generated { background: #fef3c7; color: #92400e; }
.badge--signed_uploaded { background: #dcfce7; color: #166534; }
.table--arsip td { vertical-align: top; }
/* Badge status boleh membungkus agar tidak terpotong di kolom Status (mis. "PDF bertanda tangan sudah diupload"). */
.table--arsip .badge { white-space: normal; max-width: 11rem; text-align: left; line-height: 1.25; }
.table--arsip .upload--inline { margin-top: .4rem; }
.table--arsip input[type="file"] { max-width: 15rem; font-size: .8rem; }

/* ===================================================================================================
   Responsive (mobile / tablet). Hanya presentasi: isi, urutan DOM, dan perilaku form tidak berubah.
   Breakpoint:  <=900px tablet kecil | <=860px tabel -> kartu | <=700px mobile | <=400px HP kecil
   Target sentuh (>=44px) berlaku juga pada layar sentuh yang lebar (pointer: coarse).
   =================================================================================================== */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }
img, svg, video { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Teks tak terputus (nama file, e-mail, hash) tidak boleh mendorong layout keluar layar. */
.info dd, .dokumen__nama, .histori li, .info-durasi, .duplikat__item, .alert, .note { overflow-wrap: anywhere; }
.info dt, .info dd { min-width: 0; }
.form-grid > *, .page-head > *, .card__head > * { min-width: 0; }

/* Tabel yang tetap tabel: gulir horizontal dengan bayangan di tepi sebagai petunjuk. */
.table-wrap {
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) 0 0 / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) 100% 0 / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0)) 0 0 / .7rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0)) 100% 0 / .7rem 100% no-repeat scroll;
}

/* Input file: tombol pemilih berkas jelas dan input tidak melebihi kolomnya. */
input[type="file"] { max-width: 100%; font: inherit; font-size: .9rem; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; padding: .4rem .8rem; margin-right: .75rem;
  border: 1px solid var(--border); border-radius: 6px; background: #f0f3f6; color: var(--text); cursor: pointer;
}
.field input[type="file"] { padding: .4rem; }

.card__head, .nilai-aspek, .duplikat__aksi { flex-wrap: wrap; }
.stat__value { overflow-wrap: anywhere; }

/* ---- Tablet kecil ---- */
@media (max-width: 900px) {
  .info--grid { grid-template-columns: fit-content(40%) 1fr; }
  .table--arsip td, .table--arsip th { padding: .5rem .4rem; }
}

/* ---- Tabel -> kartu (<= 860px). Setiap sel memakai data-label sebagai judul barisnya. ---- */
@media (max-width: 860px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table--stack, .table--stack tbody { display: block; width: 100%; }
  .table--stack tr {
    display: block; margin-bottom: .75rem; padding: .3rem .8rem;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  }
  .table--stack td {
    display: grid; grid-template-columns: minmax(5.5rem, 34%) minmax(0, 1fr); column-gap: .75rem; align-items: start;
    padding: .45rem 0; border-bottom: 1px dashed var(--border); min-width: 0 !important; width: auto !important;
  }
  .table--stack td:last-child { border-bottom: 0; }
  .table--stack td:empty { display: none; }
  /* Isi sel selalu di kolom kanan (di bawah satu sama lain bila lebih dari satu elemen); label di kolom kiri. */
  .table--stack td > * { grid-column: 2; min-width: 0; }
  .table--stack td > br { display: none; }
  .table--stack td > .badge, .table--stack td > .tag { justify-self: start; }
  .table--stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; padding-top: .1rem; }
  .table--stack td:not([data-label]) { display: block; }
  .table--stack td:not([data-label])::before { content: none; }
  .table--stack td:empty { display: none; }
  .table--stack td.stack-penuh { grid-template-columns: minmax(0, 1fr); row-gap: .3rem; }
  .table--stack td.stack-penuh > * { grid-column: 1; }
  .table--stack td.tengah { text-align: left; }
  .table--stack tr.baris-sub { margin-bottom: .4rem; padding: .1rem .8rem; }
  .table--stack tr.baris-sub td { padding: .25rem 0; }
  .table--stack td.stack-penuh:not(:has(> :not([hidden]))) { display: none; } /* sel yang seluruh isinya tersembunyi (mis. spesialisasi untuk non-spesialis) */
  .table--stack td.stack-aksi > .btn { width: 100%; }
  .table--stack .baris-sub td:nth-child(2) { padding-left: 0; }
  .table--stack tr.baris--duplikat { background: var(--warning-bg); border-color: var(--warning-border); }
  .table--stack tr.baris--error { background: var(--error-bg); border-color: #fda29b; }
  .table--kandidat input[type=text], .table--kandidat select { min-width: 0; }
  .table--arsip .badge { max-width: none; }
  .table--arsip input[type="file"] { max-width: 100%; }
}

/* ---- Mobile (<= 700px) ---- */
@media (max-width: 700px) {
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.05rem; }
  .container { padding: 0 .75rem; }
  .main { padding-top: 1rem; padding-bottom: 2rem; }
  .card { padding: 1rem .9rem; margin-bottom: 1rem; }

  /* Header: merek di baris pertama, menu di bawahnya; tautan menu cukup besar untuk disentuh. */
  .topbar__inner { gap: 0 1rem; min-height: 0; padding-top: .35rem; padding-bottom: .1rem; }
  .brand { gap: .55rem; min-height: 44px; }
  .brand__logo { height: 28px; padding: 3px 6px; border-radius: 5px; }
  .nav { flex: 1 1 100%; gap: 0 1.25rem; }
  .nav a { display: inline-flex; align-items: center; min-height: 44px; }

  .page-head { margin-bottom: 1rem; }
  .page-head > .btn { width: 100%; }

  /* Dashboard: tiga ringkasan tetap sejajar; kartu statistik lain 2 kolom. */
  .stats { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; }
  .stats:not(.stats--kecil) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .stats:not(.stats--kecil) .card { padding: .75rem .6rem; }
  .stat__label { font-size: .8rem; }
  .stat__value { font-size: 1.5rem; }
  .stats--kecil .stat__value { font-size: 1.3rem; }
  .status-list { grid-template-columns: 1fr; }
  .hasil-akhir__angka { grid-template-columns: 1fr; }
  .hasil-akhir__kategori { font-size: 2rem; }
  .nilai-aspek { padding: .65rem .8rem; }
  .nilai-aspek__angka { font-size: 1.5rem; }

  /* Info (label/nilai) dan form: satu kolom. */
  .info, .info--grid { grid-template-columns: 1fr; gap: 0; }
  .info dt { margin-top: .5rem; font-size: .85rem; }
  .info dd { margin-bottom: .1rem; }
  .info--kecil dt { margin-top: .35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-card { max-width: none; }
  .field--narrow { max-width: none; }
  .field input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
  .field select, .field textarea,
  .table--kandidat input[type=text], .table--kandidat select {
    font-size: 16px; /* mencegah zoom otomatis iOS saat fokus */
    min-height: 44px;
  }
  .field textarea { min-height: 5.5rem; }
  input[type="file"] { min-height: 44px; }
  .field input[type="file"] { padding: .35rem .5rem; }
  .pemilih__opsi { min-height: 44px; justify-content: center; }
  .pemilih__tambah, .faskes-baru__kepala .btn { width: 100%; }

  /* Tahapan: dua kolom agar semua langkah dan keterangannya tetap terlihat tanpa gulir. */
  .stepper ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step__isi { min-height: 44px; }
  .step__label { overflow-wrap: anywhere; }

  /* Tombol aksi: lebar penuh dan bertumpuk; urutan DOM tidak diubah (Simpan Draft tetap tombol bawaan Enter). */
  .form-actions, .form-actions--split, .form-actions--kiri { flex-direction: column; align-items: stretch; gap: .6rem; }
  .form-actions__kanan { flex-direction: column; gap: .6rem; width: 100%; }
  .form-actions .btn, .form-actions form, .form-actions__kanan .btn, .form-actions__kanan form { width: 100%; }
  .form-actions form .btn { width: 100%; }
  .field__help { margin-top: .4rem; }

  .butir__kepala { gap: .6rem; }
  .butir__judul { flex-basis: 100%; }
  .dokumen { padding: .75rem; }
  .dokumen__aksi { flex-direction: column; align-items: stretch; }
  .dokumen__aksi .btn, .dokumen__aksi form { width: 100%; }
  .upload--inline { flex-direction: column; align-items: stretch; }
  .upload--inline .btn { width: 100%; }
  form > .btn { width: 100%; }
  .duplikat__aksi { flex-direction: column; }
  .duplikat__aksi .btn { width: 100%; }
  .card__head .btn { width: 100%; }
  .tautan-unduh { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
  .table--arsip .upload--inline { margin-top: .6rem; }
  .table:not(.table--stack) th, .table:not(.table--stack) td { padding: .45rem .4rem; }
  .table:not(.table--stack) td:nth-child(2) .muted { white-space: nowrap; }
  .kriteria { max-width: none; }
  .daftar-kelompok { gap: 0 1.25rem; }
  .daftar-kelompok a { display: inline-block; padding: .6rem 0; }
  .mentah pre { max-height: 240px; }
}

/* ---- HP kecil (<= 400px) ---- */
@media (max-width: 400px) {
  body { font-size: 14.5px; }
  .brand { gap: .45rem; }
  .brand__logo { height: 26px; padding: 3px 5px; }
  .brand__text { font-size: .85rem; } /* nama aplikasi tetap satu baris di 360px */
  .container { padding: 0 .6rem; }
  .card { padding: .9rem .75rem; }
  .stepper ol { gap: .4rem; }
  .step__isi { padding: .5rem .55rem; column-gap: .4rem; }
  .table--stack tr { padding: .25rem .65rem; }
  .table--stack td { grid-template-columns: minmax(4.75rem, 36%) minmax(0, 1fr); }
}

/* ---- Target sentuh (HP dan tablet): minimal ~44px untuk kontrol utama ---- */
@media (max-width: 700px), (pointer: coarse) {
  .btn, .btn--sm { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .radio-group { gap: .5rem .75rem; }
  .radio, .field .radio { display: inline-flex; align-items: center; }
  .radio { min-height: 44px; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; gap: .6rem; }
  .radio input { width: 1.25rem !important; height: 1.25rem; margin: 0; padding: 0; border: 0; flex: none; }
  .radio:has(input:checked) { border-color: var(--primary); background: #e6f4f2; }
  .radio-group--kolom { width: 100%; }
  .radio-group--kolom .radio { width: 100%; }
  input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }
  summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
}

/* ===== Aspek SDM: input jumlah (Rekap SIP Dokter + jumlah + Ya/Tidak) ===== */
.badge-rekap--ada { background: #dcfce7; color: #166534; }
.badge-rekap--belum { background: #fef3c7; color: #92400e; }
.jumlah-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .25rem 1.25rem; }
.jumlah-item { margin-bottom: .6rem; }
.jumlah-item label { overflow-wrap: anywhere; }
.jumlah-item input[type="number"] { -moz-appearance: textfield; }
.pilihan-daftar { display: grid; }
.pilihan { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem 1.5rem; padding: .6rem 0; border-top: 1px dashed var(--border); }
.pilihan:first-child { border-top: 0; }
.pilihan__label { flex: 1 1 16rem; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pilihan--error { background: var(--error-bg); border-radius: 6px; padding-left: .5rem; padding-right: .5rem; }
@media (max-width: 700px) {
  .pilihan { flex-direction: column; align-items: stretch; }
  .pilihan__label { flex-basis: auto; }
  .pilihan .radio-group { width: 100%; }
  .pilihan .radio { flex: 1 1 0; }
}
@media (max-width: 900px) {
  .jumlah-item input[type="number"] { min-height: 44px; font-size: 16px; }
  .pilihan .radio { min-height: 44px; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; gap: .6rem; }
  .pilihan .radio input { width: 1.25rem !important; height: 1.25rem; margin: 0; flex: none; }
  .pilihan .radio:has(input:checked) { border-color: var(--primary); background: #e6f4f2; }
}
