/* Hadira — CSS mandiri (tanpa Node/CDN agar jalan offline di server sekolah). Gaya mengikuti Kabar Warga (Rakit App). */
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/source-sans-3-latin-400.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/source-sans-3-latin-600.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/source-sans-3-latin-700.woff2) format('woff2'); }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 800; font-display: swap; src: url(../fonts/source-sans-3-latin-800.woff2) format('woff2'); }
:root {
  --primary: #16a34a;
  --primary-dark: color-mix(in srgb, var(--primary) 78%, #000);
  --primary-soft: color-mix(in srgb, var(--primary) 12%, #fff);
  --hadir: #15803d; --hadir-bg: #dcfce7;
  --sakit: #1d4ed8; --sakit-bg: #dbeafe;
  --izin: #b45309; --izin-bg: #fef3c7;
  --alpha: #b91c1c; --alpha-bg: #fee2e2;
  --bg: #f8fafc; --surface: #fff; --line: #e2e8f0;
  --text: #0f172a; --muted: #64748b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15,23,42,.05);
  /* Token yang berbeda antara tema terang dan gelap */
  --aksen: var(--primary-dark);     /* teks tautan, garis tombol sekunder, batang grafik */
  --topbar: rgba(255,255,255,.95); --topbar-fg: #0f172a;
  --nav-bg: var(--primary-soft); --nav-fg: var(--primary-dark);
  --input-line: #cbd5e1;
  --pesan-garis: 40%;
  color-scheme: light;
}
/* Tema gelap: dipakai otomatis mengikuti perangkat, atau dipaksa lewat tombol Tema */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="terang"]):not([data-tema="gelap"]) {
    --bg: #0b1220; --surface: #141e33; --line: #2e3b57; --text: #eef3fb; --muted: #aab9d0;
    --primary-soft: color-mix(in srgb, var(--primary) 26%, #141e33);
    --aksen: color-mix(in srgb, var(--primary) 40%, #fff);
    --topbar: rgba(11,18,32,.92); --topbar-fg: #eef3fb;
    --nav-bg: var(--primary-soft); --nav-fg: var(--aksen);
    --input-line: #52627f;
    --hadir-bg: #11361f; --sakit-bg: #15294f; --izin-bg: #40290a; --alpha-bg: #4d1717;
    --hadir: #6ee7a0; --sakit: #9cc4ff; --izin: #fcd34d; --alpha: #ffb4b4;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-tema="gelap"] {
  --bg: #0b1220; --surface: #141e33; --line: #2e3b57; --text: #eef3fb; --muted: #aab9d0;
  --primary-soft: color-mix(in srgb, var(--primary) 26%, #141e33);
  --aksen: color-mix(in srgb, var(--primary) 40%, #fff);
  --topbar: rgba(11,18,32,.92); --topbar-fg: #eef3fb;
  --nav-bg: var(--primary-soft); --nav-fg: var(--aksen);
  --input-line: #52627f;
  --hadir-bg: #11361f; --sakit-bg: #15294f; --izin-bg: #40290a; --alpha-bg: #4d1717;
  --hadir: #6ee7a0; --sakit: #9cc4ff; --izin: #fcd34d; --alpha: #ffb4b4;
  --shadow: 0 1px 2px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 'Source Sans 3', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--text); }
a { color: var(--aksen); }
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, #fff); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Rangka */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; height: 64px; padding: 0 1rem; background: var(--topbar); color: var(--topbar-fg); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.topbar .merek { display: flex; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; text-decoration: none; color: var(--topbar-fg); min-width: 0; }
.topbar .merek img { width: 40px; height: 40px; border-radius: 12px; background: #fff; object-fit: contain; border: 1px solid var(--line); flex-shrink: 0; }
.topbar .merek span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-tombol { display: none; }
.layout { display: block; }
.sidebar { display: none; }
.sidebar a.nav { display: flex; align-items: center; padding: .6rem .9rem; border-radius: 12px; color: var(--muted); text-decoration: none; min-height: 44px; font-weight: 600; }
.sidebar a.nav:hover { background: var(--primary-soft); color: var(--text); }
.sidebar a.nav[aria-current="page"] { background: var(--nav-bg); color: var(--nav-fg); font-weight: 700; }
.sidebar .grup { margin: 1rem .9rem .3rem; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar .akun { border-top: 1px solid var(--line); margin-top: .8rem; padding: .9rem .9rem 0; font-size: .9rem; }
.konten { padding: 1rem; max-width: 1100px; margin: 0 auto; }
body { padding-bottom: 76px; }

/* Menu lengkap di HP: lembar dari bawah, dibuka lewat tombol "Menu" di bilah bawah */
.sidebar.buka { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; max-height: 80vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(15,23,42,.18); padding: 1rem .75rem calc(5.5rem + env(safe-area-inset-bottom)); }
.scrim { display: none; }
.scrim.buka { display: block; position: fixed; inset: 0; z-index: 34; background: rgba(15,23,42,.45); }
.bawah { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--topbar); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(15,23,42,.06); padding: .25rem .5rem calc(.4rem + env(safe-area-inset-bottom)); }
.bawah a, .bawah button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; min-height: 52px; padding: .2rem 0; border: 0; background: transparent; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 12px; cursor: pointer; position: relative; }
.bawah svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bawah [aria-current="page"], .bawah button[aria-expanded="true"] { color: var(--aksen); font-weight: 700; }
.bawah [aria-current="page"] svg { stroke-width: 2.4; }
.bawah [aria-current="page"]::after { content: ""; position: absolute; bottom: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bawah, .scrim, .scrim.buka { display: none; }
  .layout { display: grid; grid-template-columns: 252px 1fr; min-height: calc(100vh - 64px); }
  .sidebar, .sidebar.buka { display: block; position: sticky; top: 64px; height: calc(100vh - 64px); max-height: none; overflow-y: auto; background: var(--surface); border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: 1rem .75rem; z-index: auto; }
  .konten { padding: 1.75rem 2rem; width: 100%; }
}

/* Komponen */
.kartu { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.kepala { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.kepala > div:first-child { min-width: 0; }
.aksi { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
[hidden] { display: none !important; }
.foto-modal { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(92vw, 520px); background: var(--surface); color: var(--text); overflow: hidden; }
.foto-modal::backdrop { background: rgba(0, 0, 0, .72); }
.foto-modal img { display: block; width: 100%; max-height: 68vh; object-fit: contain; background: #000; }
.foto-modal .isi { padding: .8rem 1rem .4rem; }
.foto-modal .bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 1rem 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: .55rem 1.1rem; border-radius: 12px; border: 1px solid var(--primary-dark); background: var(--primary-dark); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; box-shadow: var(--shadow); transition: background .15s, transform .1s; }
.btn:hover { background: color-mix(in srgb, var(--primary) 66%, #000); }
.btn:active { transform: scale(.98); }
.btn.sekunder { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: none; }
.btn.sekunder:hover { background: var(--primary-soft); border-color: var(--input-line); }
.btn.bahaya { background: var(--surface); color: #c2410c; border-color: rgba(234,88,12,.4); }
.btn.bahaya:hover { background: #ffedd5; }
.btn.hijau { background: #15803d; border-color: #15803d; }
.btn.kecil { min-height: 36px; padding: .3rem .75rem; font-size: .9rem; border-radius: 10px; }
.btn[disabled], .btn.mati { opacity: .5; pointer-events: none; }
label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
input[type=text], input[type=password], input[type=date], input[type=month], input[type=number], input[type=color], input[type=file], select, textarea {
  width: 100%; min-height: 48px; padding: .55rem .85rem; border: 1px solid var(--input-line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; }
::placeholder { color: var(--muted); opacity: 1; }
input[type=color] { padding: .2rem; width: 80px; }
textarea { min-height: 120px; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid > .kartu { margin-bottom: 0; }
.grid.dua { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.empat { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid.empat { grid-template-columns: repeat(4, 1fr); } }
.bidang { margin-bottom: 1rem; }
.bantuan { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.galat-teks { color: var(--alpha); font-size: .9rem; margin-top: .25rem; }
.centang { display: flex; align-items: center; gap: .6rem; font-weight: 500; min-height: 44px; }
.centang input { width: 22px; height: 22px; }
.filter { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filter > div { flex: 1 1 160px; }

.pasang-banner { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; padding: .9rem 1rem; margin-bottom: 1rem; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--line)); background: var(--primary-soft); }
.pasang-banner .muted { font-size: .85rem; }
.pasang-banner[hidden] { display: none; }
.pesan { padding: .8rem 1rem; border-radius: 16px; font-weight: 600; margin-bottom: 1rem; border: 1px solid color-mix(in srgb, currentColor var(--pesan-garis), transparent); }
.pesan.sukses { background: var(--hadir-bg); color: var(--hadir); }
.pesan.galat { background: var(--alpha-bg); color: var(--alpha); }
.pesan.info { background: var(--sakit-bg); color: var(--sakit); }
.pesan.peringatan { background: var(--izin-bg); color: var(--izin); }
.pesan ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* Statistik */
.stat { text-align: center; }
.stat .angka { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat .label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat.hadir .angka { color: var(--hadir); } .stat.sakit .angka { color: var(--sakit); }
.stat.izin .angka { color: var(--izin); } .stat.alpha .angka { color: var(--alpha); }
.lencana { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.lencana.hadir { background: var(--hadir-bg); color: var(--hadir); } .lencana.sakit { background: var(--sakit-bg); color: var(--sakit); }
.lencana.izin { background: var(--izin-bg); color: var(--izin); } .lencana.alpha { background: var(--alpha-bg); color: var(--alpha); }
.lencana.abu { background: var(--line); color: var(--muted); }
.batang { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 80px; }
.batang > i { display: block; height: 100%; background: var(--hadir); }
.batang.rendah > i { background: var(--alpha); } .batang.sedang > i { background: var(--izin); }

/* Tabel */
.tabel-bungkus { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
td.tengah, th.tengah { text-align: center; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.rekap td, .rekap th { padding: .35rem .3rem; text-align: center; font-size: .8rem; }
.rekap td.nama, .rekap th.nama { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--surface); }
.sel-H { color: var(--hadir); } .sel-S { color: var(--sakit); font-weight: 700; } .sel-I { color: var(--izin); font-weight: 700; } .sel-A { color: var(--alpha); font-weight: 800; background: var(--alpha-bg); }

/* Form absensi: satu baris per siswa, tombol status besar */
.baris-siswa { display: grid; grid-template-columns: 1fr; gap: .5rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.baris-siswa .nama { font-weight: 600; }
.pilihan { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.pilihan input { position: absolute; opacity: 0; pointer-events: none; }
.pilihan label { margin: 0; display: flex; align-items: center; justify-content: center; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; background: var(--surface); text-align: center; font-size: .95rem; }
.pilihan label .h { display: none; }
.pilihan input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }
.pilihan input[value=hadir]:checked + label { background: var(--hadir-bg); border-color: var(--hadir); color: var(--hadir); }
.pilihan input[value=sakit]:checked + label { background: var(--sakit-bg); border-color: var(--sakit); color: var(--sakit); }
.pilihan input[value=izin]:checked + label { background: var(--izin-bg); border-color: var(--izin); color: var(--izin); }
.pilihan input[value=alpha]:checked + label { background: var(--alpha-bg); border-color: var(--alpha); color: var(--alpha); }
.pilihan input:checked + label::before { content: "✓ "; }
.ket { display: none; }
.ket.tampil { display: block; }
.bar-simpan { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: .75rem 1rem; margin: 1rem -1rem -1rem; display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; justify-content: space-between; border-radius: 0 0 var(--radius) var(--radius); }
@media (min-width: 760px) {
  .baris-siswa { grid-template-columns: 1fr 340px; align-items: center; }
  .baris-siswa .ket { grid-column: 1 / -1; }
}

/* Tren */
.tren { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 1rem; }
.tren .tiang { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.tren .isi { width: 100%; background: var(--aksen); border-radius: 5px 5px 0 0; min-height: 3px; }
.tren .nilai { font-size: .65rem; color: var(--muted); }
.tren .tgl { font-size: .65rem; color: var(--muted); margin-top: 2px; }

/* Login */
.tamu { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(900px 400px at 50% -10%, var(--primary-soft), transparent), var(--bg); }
.tamu .kotak { width: 100%; max-width: 400px; }
.tamu .logo { text-align: center; margin-bottom: 1rem; }
.tamu .logo img { width: 72px; height: 72px; object-fit: contain; border-radius: 20px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.kosong { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.paginasi nav { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.paginasi svg { width: 1rem; height: 1rem; }
.paginasi a, .paginasi span[aria-current] > span { padding: .3rem .7rem; }
.paginasi p.text-sm { font-size: .85rem; color: var(--muted); }

@media print {
  .topbar, .sidebar, .bawah, .scrim, .tanpa-cetak, .menu-tombol { display: none !important; }
  body { padding-bottom: 0 !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
  .kartu { box-shadow: none; border: 0; padding: 0; }
  .konten { max-width: none; padding: 0; }
  .sel-A { background: #eee; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Cetak laporan: kop sekolah dan tanda tangan (hanya tampil saat dicetak) */
.cetak-saja { display: none; }
@media print {
  .cetak-saja { display: block; }
  .kop { display: flex !important; align-items: center; gap: 12px; border-bottom: 3px double #000; padding-bottom: 8px; margin-bottom: 10px; }
  .kop img { width: 56px; height: 56px; object-fit: contain; }
  .kop strong { font-size: 1.15rem; }
  .judul-cetak { text-align: center; font-weight: 700; margin: 8px 0 12px; }
  .tanda-tangan { display: flex !important; justify-content: space-between; margin-top: 28px; padding: 0 40px; break-inside: avoid; }
  .tanda-tangan p { margin: 0 0 4px; text-align: center; }
  .tanda-tangan .nama-ttd { margin-top: 64px; font-weight: 700; text-decoration: underline; }
  /* Paksa tampilan terang saat cetak, walau layar sedang mode gelap */
  html, body, .kartu, table, th, td, .rekap td.nama, .rekap th.nama { background: #fff !important; color: #000 !important; }
  th, td { border-color: #999 !important; }
  .sel-A { background: #ddd !important; }
  .sel-H, .sel-S, .sel-I, .sel-A { color: #000 !important; }
  @page { size: A4 landscape; margin: 12mm; }
}
.bar-simpan .btn[type=submit] { flex: 1 1 160px; }
