:root {
  --g-900: #07412d; --g-700: #0b6b4a; --g-600: #108258; --g-100: #e1f0e8; --g-50: #f3f7f4;
  --ink: #17231d; --muted: #5d6d64; --line: #d8e2dc; --card: #ffffff; --bg: #f3f7f4;
  --warn: #9a5b00; --warn-bg: #fff3d6; --danger: #b3261e; --danger-bg: #fde8e6; --ok: #0b6b4a;
  --r: 14px; --nav-h: 62px; --top-h: 56px;
  --shadow: 0 1px 2px rgba(10, 40, 28, .06), 0 4px 14px rgba(10, 40, 28, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1713; --card: #16221c; --ink: #e6efe9; --muted: #9fb2a8; --line: #2a3a31; --g-100: #17382a; --g-50: #12201a;
    --warn-bg: #3a2c0c; --warn: #f1c26b; --danger-bg: #3b1714; --danger: #ff9b92; --ok: #5fd3a0;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; } h3 { font-size: 1.1rem; }
p { margin: .4em 0; }
a { color: var(--g-700); text-decoration: none; }
.muted { color: var(--muted); } .center { text-align: center; }
small { font-size: .82rem; color: var(--muted); }
[hidden] { display: none !important; }
.ico { display: inline-flex; vertical-align: -4px; }

/* ---------- kerangka ---------- */
#topbar { position: sticky; top: 0; z-index: 20; background: var(--g-700); color: #fff; padding-top: env(safe-area-inset-top); }
.tb-in { max-width: 920px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: #bfe3d1; font-size: .72rem; }
.logo-dot { width: 34px; height: 34px; border-radius: 10px; background: #fff; color: var(--g-700); display: grid; place-items: center; font-weight: 800; }
.tb-user { color: #fff; display: flex; align-items: center; gap: 8px; font-size: .9rem; max-width: 50%; }
.tb-user span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view { max-width: 920px; margin: 0 auto; padding: 16px; outline: none; min-height: 60vh; }
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
#nav a { flex: 1; max-width: 200px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; }
#nav a.on { color: var(--g-700); font-weight: 700; }
@media (prefers-color-scheme: dark) { #nav a.on { color: var(--ok); } a { color: var(--ok); } }

.loading, .empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty .btn { margin-top: 10px; }

/* ---------- komponen ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; }
.ph-text p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards .card { margin: 0; }
.kelas-card { display: block; color: var(--ink); }
.kc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kc-foot { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.bar { height: 8px; background: var(--g-100); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--g-600); border-radius: 99px; transition: width .3s; }
.summary .sum-row { display: flex; gap: 8px; }
.summary .sum-row div { flex: 1; display: flex; flex-direction: column; }
.summary b { font-size: 1.4rem; }
.lock-note { color: var(--warn); font-size: .88rem; display: flex; gap: 6px; align-items: center; margin: 10px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--g-700); border-color: var(--g-700); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn.icon { width: 44px; padding: 0; flex: 0 0 auto; }
.btn.block { display: flex; width: 100%; margin-top: 10px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #7fc9a8; outline-offset: 2px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; background: var(--g-100); color: var(--ink); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.chip.ok { background: var(--g-700); color: #fff; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--g-100); margin-bottom: 12px; font-size: .92rem; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.bad, .form-err { color: var(--danger); }
.form-err { min-height: 1.2em; font-size: .9rem; margin-top: 6px; }

/* ---------- daftar siswa ---------- */
.searchbox input { width: 100%; }
.searchbox { margin-bottom: 10px; }
.slist { display: flex; flex-direction: column; gap: 8px; }
.srow { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.srow-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--ink); }
.srow .no { width: 26px; text-align: center; color: var(--muted); font-size: .85rem; flex: 0 0 auto; }
.srow .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.srow .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow-act { display: flex; gap: 2px; padding-right: 6px; }
.srow-act .btn { border: 0; background: transparent; color: var(--g-700); }
@media (prefers-color-scheme: dark) { .srow-act .btn { color: var(--ok); } }

/* ---------- formulir ---------- */
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input[type="checkbox"] { width: 20px; min-height: 20px; vertical-align: -4px; }
input:disabled, select:disabled, textarea:disabled { background: var(--g-50); color: var(--muted); }
.field { display: block; margin: 12px 0 0; }
.field:first-of-type { margin-top: 8px; }
.field .lbl { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 4px; }
.field .hint { display: block; font-size: .78rem; color: var(--muted); margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .field { margin-top: 12px; }
.fs h2 { margin-bottom: 2px; }
.job { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.sticky-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 10;
  display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 24px rgba(10, 40, 28, .18); margin-top: 14px;
}
.sticky-bar .chip { margin-right: auto; }
.foto-row { display: flex; gap: 14px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; }
.foto-prev, .img-prev { width: 108px; min-height: 130px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; text-align: center; font-size: .78rem; color: var(--muted); overflow: hidden; background: var(--g-50); }
.foto-prev img { width: 100%; display: block; }
.img-prev { width: 100%; min-height: 110px; margin: 10px 0; }
.img-prev img { max-width: 100%; max-height: 160px; }
.foto-act { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; flex: 1; min-width: 160px; }
.danger-zone { text-align: center; margin: 4px 0 8px; }

/* ---------- daftar admin ---------- */
.menu-list { display: grid; gap: 10px; }
.menu-item { display: flex; align-items: center; gap: 14px; color: var(--ink); margin: 0; }
.mi-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--g-100); color: var(--g-700); display: grid; place-items: center; flex: 0 0 auto; }
.mi-t { display: flex; flex-direction: column; }
.tlist { display: flex; flex-direction: column; gap: 0; }
.trow { display: flex; flex-direction: column; gap: 10px; }
.tr-main { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.tr-act { display: flex; flex-wrap: wrap; gap: 6px; }
.logrow { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; }
.pwbox { font: 700 1.5rem/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; padding: 14px; text-align: center; background: var(--g-100); border-radius: 12px; user-select: all; }
table.mini { border-collapse: collapse; width: 100%; font-size: .82rem; margin: 8px 0; }
table.mini th, table.mini td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }

/* ---------- login ---------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); text-align: center; }
.login-card .field { text-align: left; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 18px; background: var(--g-700); color: #fff; font: 800 1.9rem/64px system-ui; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(5, 25, 17, .55); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 18px; padding: 18px; width: min(460px, 100%); max-height: 88vh; overflow: auto; }
.modal-body { margin: 8px 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.progress { height: 10px; border-radius: 99px; background: var(--g-100); overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; width: 0; background: var(--g-600); transition: width .2s; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 76px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #17231d; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .92rem; max-width: 460px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); transition: opacity .35s, transform .35s; }
.toast.err { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- preview ---------- */
.preview { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #3b4440; }
.pv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.pv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.pv-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-zoom { min-width: 44px; text-align: center; font-size: .82rem; color: var(--muted); }
.pv-scroll { flex: 1; overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.pv-canvas { width: max-content; min-width: 100%; display: flex; justify-content: center; }
.pv-canvas canvas { background: #fff; box-shadow: 0 4px 24px rgba(0, 0, 0, .45); }
.pv-status { position: absolute; top: 50%; left: 0; right: 0; text-align: center; color: #fff; }
.pv-note { padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); font-size: .74rem; text-align: center; color: #cfdad4; background: #2c3430; }
@media (max-width: 520px) { .pv-bar .btn.primary { padding: 0 12px; } .tb-user span:first-child { display: none; } .pv-title { display: none; } .pv-zoom { flex: 1; } }
@media (min-width: 760px) { #nav a { max-width: 140px; } .trow { flex-direction: row; align-items: center; justify-content: space-between; } }
@media print { #topbar, #nav, .sticky-bar, #toasts { display: none !important; } }
