/* ============================================================
   Presensi Sekolah — gaya resmi (biru tua / putih)
   ============================================================ */
:root {
  --navy-900: #0B2545;
  --navy-800: #123B6D;
  --navy-700: #17497F;
  --biru-600: #1D4ED8;
  --biru-500: #2563EB;
  --biru-100: #E7EEFC;
  --bg: #F3F5FA;
  --kartu: #FFFFFF;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #E4E7EC;
  --ok: #067647;
  --ok-bg: #ECFDF3;
  --warn: #B54708;
  --warn-bg: #FFFAEB;
  --bad: #B42318;
  --bad-bg: #FEF3F2;
  --info: #175CD3;
  --info-bg: #EFF8FF;
  --r: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .14);
}

* { box-sizing: border-box; }

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

a { color: var(--biru-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; color: var(--navy-900); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* ---------------- kerangka admin ---------------- */
.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 246px;
  flex: 0 0 246px;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 9px;
  background: #fff;
  color: var(--navy-900);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: .5px;
}
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: rgba(255, 255, 255, .68); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: rgba(255, 255, 255, .82);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a.aktif {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border-left-color: #7FA9FF;
  font-weight: 600;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-box {
  border-top: 1px solid rgba(255, 255, 255, .16);
  padding-top: 12px;
}
.user-nama { font-size: 14px; font-weight: 600; }
.user-sub { font-size: 12px; color: rgba(255, 255, 255, .66); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 22px; }
.topbar-kanan { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13.5px; }
.topbar-kanan .jam {
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy-800);
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}

/* ---------------- komponen ---------------- */
.kartu-panel {
  background: var(--kartu);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.panel-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* statistik */
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--biru-500);
}
.stat .label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat .angka { font-size: 27px; font-weight: 700; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.stat .ket { font-size: 12.5px; color: var(--muted); }
.stat.ok { border-top-color: var(--ok); }
.stat.warn { border-top-color: #DC6803; }
.stat.info { border-top-color: var(--info); }
.stat.bad { border-top-color: var(--bad); }

/* tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; background: var(--biru-600); color: #fff;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn:hover { background: #1a45bd; text-decoration: none; color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: #F9FAFB; color: var(--ink); border-color: #D0D5DD; }
.btn-navy { background: var(--navy-800); }
.btn-navy:hover { background: var(--navy-900); }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #05603a; }
.btn-bad { background: var(--bad); }
.btn-bad:hover { background: #912018; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* form */
label.field { display: block; margin-bottom: 14px; }
label.field .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid #D0D5DD; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--biru-500); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* tabel */
.tabel { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabel th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #F9FAFB;
}
.tabel td { padding: 11px 12px; border-bottom: 1px solid #F1F3F7; vertical-align: middle; }
.tabel tbody tr:hover { background: #FBFCFE; }
.tabel .num { font-variant-numeric: tabular-nums; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* badge */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: #F2F4F7; color: var(--ink-2);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: #F2F4F7; color: var(--muted); }

/* flash */
.flash {
  padding: 12px 15px; border-radius: var(--r); margin-bottom: 20px; font-size: 14px;
  border: 1px solid; background: var(--info-bg); border-color: #B2DDFF; color: #175CD3;
}
.flash.ok { background: var(--ok-bg); border-color: #ABEFC6; color: var(--ok); }
.flash.bad { background: var(--bad-bg); border-color: #FECDCA; color: var(--bad); }
.flash.warn { background: var(--warn-bg); border-color: #FEDF89; color: var(--warn); }

/* login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--navy-900), var(--navy-700) 70%, #1D4ED8);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 14px;
  padding: 32px; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .45);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.login-logo {
  width: 52px; height: 52px; border-radius: 11px; background: var(--navy-900); color: #fff;
  display: grid; place-items: center; font-weight: 800; margin-bottom: 18px; letter-spacing: .5px;
}

/* ---------------- halaman cetak kartu ---------------- */
.toolbar-cetak {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.lembar-kartu { display: flex; flex-wrap: wrap; gap: 12px; }

.kartu {
  width: 85.6mm; height: 54mm;
  border: 1px solid #98A2B3; border-radius: 8px;
  background: #fff; overflow: hidden; position: relative;
  display: flex; flex-direction: column;
  page-break-inside: avoid; break-inside: avoid;
}
.kartu-head {
  background: linear-gradient(90deg, var(--navy-900), var(--navy-700));
  color: #fff; padding: 6px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.kartu-head .nm { font-size: 11px; font-weight: 700; line-height: 1.2; flex: 1; min-width: 0; }
.kartu-head .tag { font-size: 8px; letter-spacing: .12em; text-transform: uppercase; opacity: .82; }
.kartu-body { display: flex; gap: 10px; padding: 9px 10px; flex: 1; align-items: center; }
.kartu-qr { width: 30mm; height: 30mm; flex: 0 0 30mm; }
.kartu-qr canvas, .kartu-qr img { width: 30mm !important; height: 30mm !important; display: block; }
.kartu-info { min-width: 0; }
.kartu-info .nama { font-size: 13px; font-weight: 700; color: var(--navy-900); line-height: 1.25; }
.kartu-info .baris { font-size: 10.5px; color: var(--ink-2); margin-top: 4px; }
.kartu-info .kode { font-family: ui-monospace, Menlo, monospace; font-size: 9.5px; color: var(--muted); margin-top: 5px; }
.kartu-foot {
  border-top: 1px dashed #D0D5DD; padding: 4px 10px; font-size: 8px;
  color: var(--muted); display: flex; justify-content: space-between;
}

/* grafik batang sederhana */
.batang { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.batang .kolom { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.batang .isi { width: 100%; max-width: 42px; background: linear-gradient(180deg, var(--biru-500), var(--navy-800)); border-radius: 5px 5px 0 0; min-height: 3px; }
.batang .cap { font-size: 11.5px; color: var(--muted); }
.batang .nilai { font-size: 12px; font-weight: 600; color: var(--navy-800); }

/* matriks laporan */
.matriks-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.matriks { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.matriks th, .matriks td { padding: 4px 5px; text-align: center; border-bottom: 1px solid #EEF1F5; white-space: nowrap; }
.matriks th.nama, .matriks td.nama { position: sticky; left: 0; background: #fff; text-align: left; min-width: 190px; z-index: 1; }
.matriks thead th { position: sticky; top: 0; background: #F9FAFB; color: var(--muted); font-weight: 600; z-index: 2; }
.matriks thead th.nama { z-index: 3; }
.sel { display: inline-grid; place-items: center; width: 21px; height: 21px; border-radius: 5px; font-weight: 700; font-size: 11px; }
.sel.h { background: var(--ok-bg); color: var(--ok); }
.sel.t { background: var(--warn-bg); color: var(--warn); }
.sel.i { background: var(--info-bg); color: var(--info); }
.sel.a { background: var(--bad-bg); color: var(--bad); }
.sel.l { background: #F2F4F7; color: #98A2B3; }

@media (max-width: 900px) {
  /* Cegah halaman meluber mendatar di layar sempit: tabel digeser di dalam kartunya */
  .kartu-panel { overflow-x: auto; }
  .sidebar-foot .btn-block { padding: 8px 10px; font-size: 13px; }
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 20px 16px 50px; }
}

@media print {
  .sidebar, .topbar, .toolbar-cetak, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .lembar-kartu { gap: 6mm; }
  @page { margin: 10mm; }
}

/* ============================================================
   Halaman cetak (rekap harian / bulanan / semester)
   ============================================================ */
.kop-cetak {
  display: flex; align-items: center; gap: 18px;
  border-bottom: 3px double var(--navy-900);
  padding-bottom: 12px; margin-bottom: 20px;
}
.kop-logo {
  width: 66px; height: 66px; flex: 0 0 66px; border-radius: 50%;
  background: var(--navy-900); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 19px; letter-spacing: .5px;
}
.kop-tengah { flex: 1; text-align: center; }
.kop-nama { font-size: 19px; font-weight: 700; color: var(--navy-900); letter-spacing: .02em; }
.kop-alamat { font-size: 12.5px; color: var(--muted); }
.kop-judul { font-size: 15px; font-weight: 700; margin-top: 8px; text-transform: uppercase; letter-spacing: .05em; }
.kop-ket { font-size: 13px; color: var(--ink-2); }
.kop-kanan { flex: 0 0 66px; }

.tanda-tangan { display: flex; justify-content: space-between; gap: 30px; margin-top: 40px; page-break-inside: avoid; }
.tt-kolom { flex: 1; text-align: center; font-size: 13px; }
.tt-jabatan { margin-bottom: 4px; }
.tt-ruang { height: 62px; }
.tt-nama { font-weight: 700; border-top: 1px solid var(--ink-2); padding-top: 4px; display: inline-block; min-width: 190px; }
.tt-nip { font-size: 11.5px; color: var(--muted); }

.cetak-saja { display: none; }

/* Tabel lebar (mis. matriks bulanan) dapat digeser mendatar, tidak merusak tata letak */
.tabel-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.legenda { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin: 4px 0 14px; }
.legenda > span { display: inline-flex; align-items: center; gap: 6px; }

.cetak-stat { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.cetak-stat .kotak {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; min-width: 118px; background: #fff;
}
.cetak-stat .kotak .lb { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.cetak-stat .kotak .nk { font-size: 19px; font-weight: 700; color: var(--navy-900); font-variant-numeric: tabular-nums; }

.tabel-cetak { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tabel-cetak th, .tabel-cetak td { border: 1px solid #C7CDD6; padding: 5px 7px; }
.tabel-cetak th { background: #EEF2F9; text-align: center; font-weight: 600; color: var(--navy-900); }
.tabel-cetak td.num { text-align: center; font-variant-numeric: tabular-nums; }
.tabel-cetak tbody tr:nth-child(even) td { background: #FAFBFD; }
.tabel-cetak th.nama, .tabel-cetak td.nama { text-align: left; }

@media print {
  .kop-cetak { border-bottom-color: #000; }
  .tabel-cetak th, .tabel-cetak td { border-color: #666; }
  .tabel-cetak th { background: #E5E9F0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sel { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .logo-penanda, .logo-penanda img, .kartu-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kartu-panel { border: 0; box-shadow: none; padding: 0; page-break-inside: auto; overflow: visible !important; }
  .tabel-scroll, .matriks-wrap { overflow: visible !important; }
  .grid, .stack { display: block !important; }
  .grid > * { margin-bottom: 16px; }
  .stat, .cetak-stat .kotak { border-color: #666; }
  .no-print { display: none !important; }
  .cetak-saja { display: inline !important; }
  .page-break { page-break-before: always; }
}


/* ============================================================
   Logo sekolah
   ============================================================ */
/* Pengaman: gambar di dalam penanda mana pun tidak boleh melebihi wadahnya,
   walau aturan .logo-penanda gagal dimuat (mis. CSS lama dari cache browser). */
.brand-mark, .login-logo, .kop-logo { overflow: hidden; }
.brand-mark img, .login-logo img, .kop-logo img {
  max-width: 100% !important; max-height: 100% !important;
  object-fit: contain; display: block;
}

.logo-penanda {
  display: grid; place-items: center;
  background: #fff; overflow: hidden;
  padding: 4px;
}
.logo-penanda img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* pratinjau di halaman pengaturan */
.pratinjau-logo { border: 1px solid var(--line); border-radius: var(--r); background: #F9FAFB; padding: 16px; }
.pratinjau-baris { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.pratinjau-baris:last-child { border-bottom: 0; }
.pratinjau-label { flex: 0 0 132px; font-size: 12.5px; color: var(--muted); }
.pratinjau-nilai { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pratinjau-teks { font-weight: 700; color: var(--navy-900); font-size: 14px; }
.pratinjau-kartu-head { display: flex; align-items: center; gap: 8px; background: linear-gradient(90deg, var(--navy-900), var(--navy-700));
  color: #fff; border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.pratinjau-kartu-head img { width: 20px; height: 20px; object-fit: contain; background: #fff; border-radius: 3px; padding: 1px; }
.pratinjau-tanda { font-size: 10.5px; font-weight: 500; opacity: .75; }
.k-mark-pratinjau {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center; overflow: hidden; padding: 4px;
  background: #fff; color: var(--navy-800); font-weight: 800;
}
.k-mark-pratinjau img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* logo pada kartu QR cetak */
.kartu-head .kartu-logo {
  width: 8mm; height: 8mm; flex: 0 0 8mm;
  object-fit: contain; background: #fff; border-radius: 2px; padding: 1px;
}


/* ============================================================
   Halaman panduan
   ============================================================ */
.panduan-isi { max-width: 900px; }
.panduan-isi p { color: var(--ink-2); line-height: 1.75; margin: 0 0 14px; }
.panduan-isi .panduan-h1 { font-size: 23px; margin: 0 0 16px; }
.panduan-isi .panduan-h2 {
  font-size: 18px; margin: 30px 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.panduan-isi .panduan-h3 { font-size: 15.5px; margin: 22px 0 10px; color: var(--navy-800); }
.panduan-isi .panduan-h4 { font-size: 14px; margin: 18px 0 8px; }
.panduan-isi .panduan-daftar { margin: 0 0 16px; padding-left: 22px; color: var(--ink-2); line-height: 1.8; }
.panduan-isi .panduan-daftar li { margin-bottom: 5px; }
.panduan-isi code {
  background: #F2F4F7; border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 12.8px; color: var(--navy-800);
  /* Teks panjang seperti alamat situs atau nama berkas tidak boleh melebarkan halaman. */
  word-break: break-word; overflow-wrap: anywhere;
}
.panduan-isi .panduan-kode {
  background: var(--navy-900); color: #E6EDF7; border-radius: var(--r);
  padding: 13px 15px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 0 0 16px;
}
.panduan-isi .panduan-kode code { background: none; border: 0; color: inherit; padding: 0; font-size: inherit; }
.panduan-isi table.tabel { margin-bottom: 18px; }
.panduan-isi table.tabel th { background: #EEF2F9; }
.panduan-isi hr { border: 0; border-top: 1px dashed var(--line); margin: 26px 0; }

@media print {
  .panduan-isi { max-width: none; }
  .panduan-isi .panduan-kode { background: #F2F4F7 !important; color: #101828 !important; border: 1px solid #999; }
}


/* ============================================================
   Mode edit massal pada Data Warga
   ============================================================ */
.tabel-edit th { white-space: nowrap; }
.tabel-edit td { padding: 8px 10px; vertical-align: middle; }
.tabel-edit input[type="text"],
.tabel-edit select {
  width: 100%; min-width: 96px; padding: 6px 8px; font-size: 13px;
}
.tabel-edit input[type="checkbox"] { width: auto; }
.tabel-edit tr.berubah td { background: #FFFAEB; }
.tabel-edit tr.berubah td:first-child { box-shadow: inset 3px 0 0 #DC6803; }
.tabel-edit tr.nis-dobel td { background: #FEF3F2; }
.tabel-edit tr.nis-dobel td:first-child { box-shadow: inset 3px 0 0 #B42318; }
.tabel-edit tr.tanpa-nomor input[name^="wa_ortu"],
.tabel-edit tr.tanpa-nomor input[name^="telepon"] { border-color: #FEDF89; background: #FFFCF5; }

.simpan-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); position: sticky; bottom: 12px; z-index: 5;
}
.simpan-info { font-size: 14px; color: var(--ink-2); }

@media (max-width: 900px) {
  .simpan-bar { position: static; }
}
