/* ==========================================================
   Kelas Khadimus Sunnah — gaya bersama
   Tinta biru tua, hijau masjid, aksen kuningan.
   ========================================================== */
:root {
  --ink: #15223b;
  --ink-2: #3a4862;
  --muted: #6a768b;
  --paper: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --line: #dde3dc;
  --line-2: #c9d2c8;

  --hijau: #0e6b55;
  --hijau-dark: #0a5141;
  --hijau-soft: #e2f0ea;
  --kuningan: #b8862b;
  --kuningan-soft: #f6eedb;

  --st-H: #1d8657; --st-H-soft: #e1f3e9;
  --st-T: #a96f05; --st-T-soft: #fbf0d4;
  --st-I: #2c64a3; --st-I-soft: #e2ebf7;
  --st-A: #bb3a35; --st-A-soft: #f8e2e0;

  --danger: #bb3a35;
  --focus: 0 0 0 3px rgba(14, 107, 85, .28);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --arab: "Amiri", "Traditional Arabic", serif;

  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23d5ad5b' stroke-width='1.1' stroke-opacity='.42'%3E%3Crect x='19' y='19' width='26' height='26'/%3E%3Crect x='19' y='19' width='26' height='26' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3Cpath d='M0 0l13.6 13.6M64 0L50.4 13.6M0 64l13.6-13.6M64 64L50.4 50.4M32 0v5.6M32 64v-5.6M0 32h5.6M64 32h-5.6'/%3E%3C/g%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--hijau); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.arab { font-family: var(--arab); direction: rtl; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 38px; padding: .45rem .95rem;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .9rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.btn-primary:hover { background: var(--hijau-dark); border-color: var(--hijau-dark); }
.btn-danger { color: var(--danger); border-color: #e6c2bf; }
.btn-danger:hover { background: var(--st-A-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #9e2f2b; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(21, 34, 59, .06); border-color: transparent; }
.btn-sm { min-height: 32px; padding: .3rem .65rem; font-size: .84rem; }
.btn-icon { width: 34px; min-height: 34px; padding: 0; }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- Formulir ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field > label, .label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.hint { font-size: .8rem; color: var(--muted); }
.input, .select, textarea.input {
  width: 100%; min-height: 40px; padding: .5rem .7rem;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface);
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus, .select:focus { border-color: var(--hijau); box-shadow: var(--focus); outline: none; }
.select { appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a768b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; }
.row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: .15rem 0 0; accent-color: var(--hijau); flex: none; }
.input-group { display: flex; gap: .4rem; }
.input-group .input { flex: 1; }

/* ---------- Status absensi ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip.st-H { background: var(--st-H-soft); color: var(--st-H); border-color: transparent; }
.chip.st-T { background: var(--st-T-soft); color: var(--st-T); border-color: transparent; }
.chip.st-I { background: var(--st-I-soft); color: var(--st-I); border-color: transparent; }
.chip.st-A { background: var(--st-A-soft); color: var(--st-A); border-color: transparent; }
.chip.open { background: var(--hijau-soft); color: var(--hijau); border-color: transparent; }
.chip.closed { background: #eceeee; color: var(--muted); border-color: transparent; }
.chip.dummy { background: var(--kuningan-soft); color: #8a6115; border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.tally { display: inline-flex; gap: .25rem; flex-wrap: wrap; }
.tally span { min-width: 30px; text-align: center; padding: .1rem .35rem; border-radius: var(--r-sm); font-size: .78rem; font-weight: 700; }
.tally .H { background: var(--st-H-soft); color: var(--st-H); }
.tally .T { background: var(--st-T-soft); color: var(--st-T); }
.tally .I { background: var(--st-I-soft); color: var(--st-I); }
.tally .A { background: var(--st-A-soft); color: var(--st-A); }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: #e8ece7; min-width: 80px; }
.bar i { display: block; height: 100%; }
.bar .H { background: var(--st-H); } .bar .T { background: var(--st-T); }
.bar .I { background: var(--st-I); } .bar .A { background: var(--st-A); }

/* ---------- Kartu, tabel, kosong ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 1.1rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .78rem; font-weight: 700; color: var(--muted); padding: .65rem .8rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbf9; }
.table .actions { display: flex; gap: .25rem; justify-content: flex-end; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .sub { display: block; font-size: .8rem; color: var(--muted); }
.empty { padding: 2.4rem 1.2rem; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: .35rem; }
.empty .btn { margin-top: 1rem; }

/* ---------- Toast & modal ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: .5rem; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: .75rem 1rem; border-radius: var(--r); font-size: .9rem; box-shadow: 0 10px 30px rgba(21, 34, 59, .25); display: flex; gap: .6rem; align-items: flex-start; animation: toast-in .2s ease-out; }
.toast.error { background: #8f2622; }
.toast.ok { background: var(--hijau-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(21, 34, 59, .45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(21, 34, 59, .3); animation: modal-in .18s ease-out; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.25rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }

.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r); background: var(--kuningan-soft); color: #6f4e10; font-size: .9rem; border: 1px solid #ecd9ae; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert.danger { background: var(--st-A-soft); color: #7f2420; border-color: #eec4c0; }
.alert.info { background: var(--st-I-soft); color: #1f4877; border-color: #c6d7ee; }
.alert .grow { flex: 1; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--hijau); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; justify-content: center; padding: 3rem; }

/* ==========================================================
   Halaman login
   ========================================================== */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: 3rem; color: #f3ead6; overflow: hidden;
  background-color: var(--hijau-dark); background-image: var(--pattern);
}
.login-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 81, 65, 0) 30%, rgba(8, 52, 43, .85)); pointer-events: none; }
.login-art > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--kuningan); color: #fff; }
.brand-mark svg { width: 24px; height: 24px; }
.login-art .salam { font-size: 2.6rem; line-height: 1.6; color: #fff; }
.login-art h1 { font-size: clamp(1.9rem, 3.4vw, 2.8rem); color: #fff; max-width: 14ch; letter-spacing: -.02em; }
.login-art .lead { margin-top: .9rem; max-width: 40ch; color: #d9e8e1; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 1.5rem; margin-bottom: .3rem; }
.login-form .muted { margin-bottom: 1.6rem; }
.login-form .btn-primary { min-height: 46px; font-size: 1rem; margin-top: .4rem; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 2.8rem; }
.pass-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-error { color: var(--danger); font-size: .88rem; min-height: 1.3em; margin-top: .6rem; }

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 1.6rem 1.4rem 2rem; min-height: auto; }
  .login-art .salam { font-size: 1.8rem; }
  .login-art h1 { font-size: 1.7rem; margin-top: 1.4rem; }
  .login-art .lead { display: none; }
  .login-art .art-foot { display: none; }
}

/* ==========================================================
   Dashboard admin
   ========================================================== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.nav-scrim { display: none; }
.sidebar { background: var(--ink); color: #c9d1de; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.1rem .8rem; z-index: 60; }
.sidebar .brand { color: #fff; padding: .3rem .5rem 1.4rem; font-size: .95rem; line-height: 1.25; }
.sidebar .brand small { display: block; font-weight: 500; color: #8f9bb1; font-size: .76rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: var(--r-sm); color: #c9d1de; text-decoration: none; font-weight: 550; font-size: .92rem; }
.nav a svg { width: 19px; height: 19px; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: rgba(213, 173, 91, .16); color: #f3d79a; }
.nav a.active svg { opacity: 1; }
.nav .nav-sep { height: 1px; background: rgba(255, 255, 255, .08); margin: .7rem .4rem; }
.sidebar-foot { margin-top: auto; padding: .8rem .5rem 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .84rem; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot button { margin-top: .6rem; color: #c9d1de; border-color: rgba(255, 255, 255, .18); background: transparent; width: 100%; }
.sidebar-foot button:hover { background: rgba(255, 255, 255, .07); color: #fff; border-color: rgba(255, 255, 255, .3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 2rem; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 40; }
.topbar h1 { font-size: 1.25rem; }
.topbar .crumb { color: var(--muted); font-size: .85rem; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.view { padding: 1.6rem 2rem 3rem; max-width: 1280px; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 1.2rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search { position: relative; }
.search svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.search .input { padding-left: 2.2rem; }

/* Angka ringkas */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.figure { padding: 1.1rem 1.3rem; border-left: 1px solid var(--line); text-decoration: none; color: inherit; }
.figure:first-child { border-left: 0; }
.figure:hover { background: var(--surface-2); }
.figure b { display: block; font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.figure span { color: var(--muted); font-size: .88rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: .84rem; }
.time-box { width: 58px; flex: none; text-align: center; font-variant-numeric: tabular-nums; }
.time-box b { display: block; font-size: 1rem; }
.time-box span { font-size: .76rem; color: var(--muted); }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.steps li { counter-increment: s; display: flex; gap: .9rem; align-items: flex-start; }
.steps li::before { content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--hijau-soft); color: var(--hijau); }
.steps li.done::before { content: "✓"; background: var(--hijau); color: #fff; }

/* Kelas & mapel */
.kelas-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--muted); text-decoration: none; margin-bottom: .6rem; }
.back:hover { color: var(--ink); }
.back svg { width: 16px; height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.jadwal-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pick-list label { display: flex; gap: .6rem; align-items: center; padding: .55rem .8rem; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .9rem; }
.pick-list label:last-child { border-bottom: 0; }
.pick-list label:hover { background: var(--surface-2); }
.pick-list input { accent-color: var(--hijau); width: 17px; height: 17px; }

/* Detail pertemuan: tombol status per santri */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; border-left: 1px solid var(--line-2); background: var(--surface); padding: .32rem .6rem; font-size: .8rem; font-weight: 700; cursor: pointer; color: var(--muted); min-width: 36px; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button.on.H { background: var(--st-H); color: #fff; }
.seg button.on.T { background: var(--st-T); color: #fff; }
.seg button.on.I { background: var(--st-I); color: #fff; }
.seg button.on.A { background: var(--st-A); color: #fff; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); }
.legend span { display: inline-flex; gap: .35rem; align-items: center; }
.legend b { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; font-size: .72rem; color: #fff; }

.sesi-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; }
.counts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.counts div { padding: .8rem 1rem; border-left: 1px solid var(--line); }
.counts div:first-child { border-left: 0; }
.counts b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.counts span { font-size: .82rem; color: var(--muted); }
.counts .H b { color: var(--st-H); } .counts .T b { color: var(--st-T); }
.counts .I b { color: var(--st-I); } .counts .A b { color: var(--st-A); }

/* Rekap */
.rekap td.cell, .rekap th.cell { text-align: center; padding: .45rem .3rem; min-width: 38px; font-weight: 700; font-size: .8rem; }
.rekap th.cell { font-size: .72rem; line-height: 1.2; }
.rekap td.cell.H { color: var(--st-H); background: var(--st-H-soft); }
.rekap td.cell.T { color: var(--st-T); background: var(--st-T-soft); }
.rekap td.cell.I { color: var(--st-I); background: var(--st-I-soft); }
.rekap td.cell.A { color: var(--st-A); background: var(--st-A-soft); }
.rekap td.cell.x { color: #b5bdc8; }
.rekap td.sticky, .rekap th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 180px; box-shadow: 1px 0 0 var(--line); }
.rekap th.sticky { background: var(--surface-2); }
.pct { font-weight: 700; font-variant-numeric: tabular-nums; }

.preview-table { font-size: .82rem; }
.preview-table td, .preview-table th { padding: .4rem .55rem; }
.err-list { max-height: 180px; overflow-y: auto; font-size: .84rem; color: var(--danger); margin: .5rem 0 0; padding-left: 1.1rem; }
.progress { height: 8px; background: #e8ece7; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--hijau); width: 0; transition: width .2s; }
.cred { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r); padding: 1rem; font-size: .95rem; }
.cred b { font-variant-numeric: tabular-nums; }

@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease-out, visibility .2s; }
  .app.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(21, 34, 59, .4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: .8rem 1rem; }
  .view { padding: 1rem 1rem 3rem; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .counts div:nth-child(4) { border-left: 0; }
  .counts div:nth-child(n+4) { border-top: 1px solid var(--line); }
  .sesi-head { grid-template-columns: 1fr; }
  .jadwal-row { grid-template-columns: 1fr 1fr; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 0; }
  .table.responsive td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; font-weight: 600; flex: none; }
  .table.responsive td.lead-cell { display: block; font-size: 1rem; }
  .table.responsive td.lead-cell::before { display: none; }
  .table.responsive .actions { justify-content: flex-start; padding-top: .4rem; }
  .table.responsive tbody tr:hover td { background: transparent; }
}

/* ==========================================================
   Halaman santri (mobile-first)
   ========================================================== */
.santri-page { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 3rem; }
.santri-hero {
  position: relative; color: #fff; padding: 1rem 1.1rem 4.2rem;
  background-color: var(--hijau-dark); background-image: var(--pattern);
}
@media (min-width: 641px) { .santri-hero { border-radius: 0 0 var(--r-lg) var(--r-lg); } }
.santri-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 81, 65, .2), rgba(8, 52, 43, .88)); pointer-events: none; }
@media (min-width: 641px) { .santri-hero::after { border-radius: 0 0 var(--r-lg) var(--r-lg); } }
.santri-hero > * { position: relative; z-index: 1; }
.santri-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.santri-top .brand { font-size: .88rem; }
.santri-top .brand-mark { width: 34px; height: 34px; }
.santri-top .btn-ghost { color: #fff; }
.santri-top .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.santri-hero .salam { font-size: 1.55rem; margin-top: 1.1rem; color: #f3d79a; }
.santri-hero h1 { font-size: 1.45rem; margin-top: .1rem; }
.santri-hero .tgl { color: #d2e3dc; font-size: .9rem; margin-top: .2rem; }
.santri-body { padding: 0 1rem; margin-top: -3rem; position: relative; z-index: 2; display: flex; flex-direction: column; gap: 1.4rem; }
.sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.sec-title h2 { font-size: 1.05rem; }
.santri-body > section:first-child .sec-title h2, .santri-body > section:first-child .sec-title .btn { color: #fff; }

.sesi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem; box-shadow: 0 6px 24px rgba(21, 34, 59, .08); }
.sesi-card + .sesi-card { margin-top: .8rem; }
.sesi-card .top { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; }
.sesi-card h3 { font-size: 1.08rem; }
.sesi-card .meta { color: var(--muted); font-size: .86rem; margin-top: .1rem; }
.sesi-card .topik { margin-top: .5rem; font-size: .9rem; color: var(--ink-2); }
.pilih { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .9rem; }
.pilih button {
  display: flex; flex-direction: column; align-items: flex-start; gap: .35rem;
  padding: .75rem .8rem; border-radius: var(--r); border: 1.5px solid var(--line-2);
  background: var(--surface); text-align: left; cursor: pointer; font-weight: 650; font-size: .92rem; line-height: 1.25; min-height: 76px;
}
.pilih button svg { width: 22px; height: 22px; }
.pilih button.H { color: var(--st-H); } .pilih button.T { color: var(--st-T); }
.pilih button.I { color: var(--st-I); } .pilih button.A { color: var(--st-A); }
.pilih button:hover { border-color: currentColor; }
.pilih button.on.H { background: var(--st-H); border-color: var(--st-H); color: #fff; }
.pilih button.on.T { background: var(--st-T); border-color: var(--st-T); color: #fff; }
.pilih button.on.I { background: var(--st-I); border-color: var(--st-I); color: #fff; }
.pilih button.on.A { background: var(--st-A); border-color: var(--st-A); color: #fff; }
.pilih button[disabled] { opacity: .4; cursor: not-allowed; border-color: var(--line); }
.pilih button small { font-weight: 500; font-size: .74rem; opacity: .85; }
.done-box { margin-top: .9rem; display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; border-radius: var(--r); }
.done-box svg { width: 26px; height: 26px; flex: none; }
.done-box.H { background: var(--st-H-soft); color: var(--st-H); }
.done-box.T { background: var(--st-T-soft); color: var(--st-T); }
.done-box.I { background: var(--st-I-soft); color: var(--st-I); }
.done-box.A { background: var(--st-A-soft); color: var(--st-A); }
.done-box b { display: block; }
.done-box span { font-size: .82rem; color: var(--ink-2); }
.done-box .btn { margin-left: auto; }
.locked { margin-top: .8rem; font-size: .86rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.locked svg { width: 16px; height: 16px; }
.empty-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.4rem 1.1rem; text-align: center; color: var(--muted); box-shadow: 0 6px 24px rgba(21, 34, 59, .08); }
.empty-card h3 { color: var(--ink); margin-bottom: .3rem; }

.kelas-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.kelas-block + .kelas-block { margin-top: .8rem; }
.kelas-block > header { padding: .85rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mapel-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.mapel-row:last-child { border-bottom: 0; }
.mapel-row:hover { background: #fafbf9; }
.mapel-row .grow { flex: 1; min-width: 0; }
.mapel-row .title { font-weight: 650; }
.mapel-row .meta { font-size: .8rem; color: var(--muted); }
.mapel-row .pct { font-size: 1.05rem; }
.mapel-row svg.chev { width: 18px; height: 18px; color: var(--muted); }
.riwayat li { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.riwayat li:last-child { border-bottom: 0; }

@media print {
  .sidebar, .topbar, .toolbar, .no-print, #toasts { display: none !important; }
  .app { display: block; }
  .view { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11px; }
  .panel { border: 0; }
  .rekap td.sticky, .rekap th.sticky { position: static; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Ringkasan 4 kolom (riwayat santri) */
.counts.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.counts.c4 > div { border-top: 0; border-left: 1px solid var(--line); padding: .7rem .65rem; }
.counts.c4 > div:first-child { border-left: 0; }
.counts.c4 b { font-size: 1.3rem; }
.salam { text-align: left; }

/* ==========================================================
   Pembaruan: guru, detail mata pelajaran, ubah absensi
   ========================================================== */
.pick-group { padding: .45rem .8rem; font-size: .76rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }

.md-hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.1rem 1.2rem; border-radius: var(--r); color: #fff;
  background-color: var(--hijau-dark); background-image: linear-gradient(90deg, rgba(10, 81, 65, .96) 35%, rgba(10, 81, 65, .55)), var(--pattern); }
.md-hero-main { display: flex; gap: .9rem; align-items: center; min-width: 0; }
.md-hero h2 { font-size: 1.3rem; color: #fff; }
.md-hero .muted { color: #cfe2da; font-size: .88rem; }
.md-badge { width: 52px; height: 52px; border-radius: 12px; background: var(--kuningan); display: grid; place-items: center; font-weight: 700; letter-spacing: .02em; flex: none; }
.md-hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.md-hero-actions .btn:not(.btn-primary) { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .28); color: #fff; }
.md-hero-actions .btn:not(.btn-primary):hover { background: rgba(255, 255, 255, .2); }
.md-hero-actions .btn-primary { background: var(--kuningan); border-color: var(--kuningan); }
.md-hero-actions .btn-primary:hover { background: #9c7224; border-color: #9c7224; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: none; padding: .7rem .9rem; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab span { display: inline-block; min-width: 22px; padding: 0 .4rem; margin-left: .25rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: .76rem; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--hijau); border-bottom-color: var(--hijau); }
.tab.on span { background: var(--hijau-soft); border-color: transparent; color: var(--hijau); }
#mdBody { display: flex; flex-direction: column; gap: 1.2rem; }

.pt-item { align-items: flex-start !important; }
.date-tile { width: 52px; flex: none; text-align: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); padding: .3rem 0; }
.date-tile b { display: block; font-size: 1.25rem; line-height: 1.1; }
.date-tile span { font-size: .74rem; color: var(--muted); }
.date-tile.today { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.date-tile.today span { color: #d5ebe3; }
.pt-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.note-box { display: flex; gap: .55rem; align-items: flex-start; margin-top: .5rem; padding: .6rem .75rem; border-radius: var(--r-sm); background: var(--kuningan-soft); color: #5e4512; font-size: .88rem; }
.zoom-row { display: flex; align-items: center; gap: .7rem; word-break: break-all; }
.zoom-row svg { width: 20px; height: 20px; flex: none; color: var(--st-I); }

.materi-item { align-items: flex-start !important; }
.file-tag { width: 46px; height: 46px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: .72rem; font-weight: 700; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.file-tag.t-pdf { background: #fbe4e1; color: #a5322c; border-color: transparent; }
.file-tag.t-doc { background: #e2ebf7; color: #2c64a3; border-color: transparent; }
.file-tag.t-ppt { background: #fbecdc; color: #a8561a; border-color: transparent; }
.file-tag.t-xls { background: #e1f3e9; color: #1d8657; border-color: transparent; }
.file-tag.t-img, .file-tag.t-vid, .file-tag.t-aud { background: #efe6f5; color: #6c3b8c; border-color: transparent; }
.file-tag.t-link { background: var(--hijau-soft); color: var(--hijau); border-color: transparent; }

.tg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .3rem; }
.tg-box { border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; background: var(--surface-2); }
.tg-box h3 { font-size: .95rem; }
.day-pick { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .6rem; }
.day-pick label { cursor: pointer; }
.day-pick input { position: absolute; opacity: 0; pointer-events: none; }
.day-pick span { display: inline-block; padding: .3rem .6rem; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: .82rem; font-weight: 600; }
.day-pick input:checked + span { background: var(--hijau); border-color: var(--hijau); color: #fff; }
.day-pick input:focus-visible + span { box-shadow: var(--focus); }
.date-chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem; border: 1px dashed var(--line-2); border-radius: var(--r-sm); min-height: 46px; max-height: 160px; overflow-y: auto; }
.date-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .3rem .2rem .6rem; border-radius: 99px; background: var(--hijau-soft); color: var(--hijau-dark); font-size: .82rem; font-weight: 600; }
.date-chip button { border: 0; background: none; padding: 2px; cursor: pointer; color: inherit; border-radius: 50%; display: grid; place-items: center; }
.date-chip button:hover { background: rgba(14, 107, 85, .15); }
.date-chip svg { width: 13px; height: 13px; }

.seg-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.seg-choice input, .status-pick input { position: absolute; opacity: 0; pointer-events: none; }
.seg-choice span { display: flex; gap: .45rem; align-items: center; justify-content: center; padding: .6rem; border: 1.5px solid var(--line-2); border-radius: var(--r-sm); font-weight: 600; font-size: .88rem; cursor: pointer; }
.seg-choice svg { width: 17px; height: 17px; }
.seg-choice input:checked + span { border-color: var(--hijau); background: var(--hijau-soft); color: var(--hijau-dark); }
.seg-choice input:focus-visible + span, .status-pick input:focus-visible + span { box-shadow: var(--focus); }

.status-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.status-pick span { display: flex; gap: .45rem; align-items: center; padding: .6rem .7rem; border: 1.5px solid var(--line-2); border-radius: var(--r-sm); font-weight: 600; font-size: .88rem; cursor: pointer; }
.status-pick svg { width: 18px; height: 18px; flex: none; }
.status-pick .H span { color: var(--st-H); } .status-pick .T span { color: var(--st-T); }
.status-pick .I span { color: var(--st-I); } .status-pick .A span { color: var(--st-A); }
.status-pick .none span { color: var(--muted); }
.status-pick .H input:checked + span { background: var(--st-H); border-color: var(--st-H); color: #fff; }
.status-pick .T input:checked + span { background: var(--st-T); border-color: var(--st-T); color: #fff; }
.status-pick .I input:checked + span { background: var(--st-I); border-color: var(--st-I); color: #fff; }
.status-pick .A input:checked + span { background: var(--st-A); border-color: var(--st-A); color: #fff; }
.status-pick .none input:checked + span { background: #e8ebee; border-color: var(--muted); color: var(--ink); }

.rekap td.cell.editable { cursor: pointer; }
.rekap td.cell.editable:hover { outline: 2px solid var(--ink-2); outline-offset: -2px; }

@media (max-width: 700px) {
  .tg-grid { grid-template-columns: 1fr; }
  .pt-item { flex-wrap: wrap; }
  .pt-actions { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; padding-left: calc(52px + .9rem); }
  .md-hero-actions { width: 100%; }
}

/* ==========================================================
   Pembaruan: halaman santri lebih hidup
   ========================================================== */
.santri-hero { padding-bottom: 4.6rem; }
.hero-stats { display: grid; grid-template-columns: auto 1fr; gap: .9rem 1rem; align-items: center; margin-top: 1.1rem; padding: .9rem; border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.hs-ring { --p: 0; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#f3d79a calc(var(--p) * 1%), rgba(255, 255, 255, .16) 0); position: relative; }
.hs-ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #0c4a3c; }
.hs-ring b { position: relative; font-size: 1.05rem; color: #fff; }
.hs-main b { display: block; font-size: 1rem; }
.hs-main span { display: block; font-size: .84rem; color: #d2e3dc; }
.hs-next { grid-column: 1 / -1; display: flex; gap: .6rem; align-items: center; padding-top: .8rem; border-top: 1px solid rgba(255, 255, 255, .16); }
.hs-next svg { width: 22px; height: 22px; color: #f3d79a; flex: none; }
.hs-next small { display: block; font-size: .74rem; color: #b9d3c8; }
.hs-next b { display: block; }
.hs-next span { font-size: .84rem; color: #d2e3dc; }

.sesi-card { position: relative; overflow: hidden; padding-left: 1.15rem; }
.sesi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--hijau)); }
.sesi-card .note-box { margin-top: .7rem; }
.zoom-btn { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .8rem; padding: .7rem; border-radius: var(--r);
  background: #2d6be0; color: #fff; font-weight: 700; text-decoration: none; }
.zoom-btn:hover { background: #2356b8; }
.zoom-btn svg { width: 20px; height: 20px; }

.up-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.up-day { display: flex; gap: .9rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.up-day:last-child { border-bottom: 0; }
.up-date { width: 46px; flex: none; text-align: center; line-height: 1.15; }
.up-date b { display: block; font-size: 1.35rem; }
.up-date span { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.up-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.up-item { border-left: 3px solid var(--c); padding: .15rem 0 .15rem .65rem; }
.up-item b { display: block; font-size: .95rem; }
.up-item span { font-size: .82rem; color: var(--muted); }

.mp-tile { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--c, var(--hijau)); color: #fff; font-weight: 700; font-size: .82rem; letter-spacing: .02em; }
.mp-bar { height: 6px; border-radius: 99px; background: #e8ece7; overflow: hidden; margin-top: .45rem; max-width: 220px; }
.mp-bar i { display: block; height: 100%; border-radius: 99px; }
.mp-tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .45rem; }
.mp-tags span { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.mp-tags svg { width: 12px; height: 12px; }
.mp-modal-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.tabs.mini { margin-bottom: 0; }
.tabs.mini .tab { padding: .55rem .7rem; font-size: .9rem; }
.riwayat .note-box { margin-top: .4rem; padding: .45rem .6rem; }

/* Peringatan versi file tidak seragam */
.ver-warn { margin: 1rem 2rem 0; max-width: 1216px; }
@media (max-width: 900px) { .ver-warn { margin: .8rem 1rem 0; } }
