/* TPQ Madin PWA - gaya Alma Ata: gradien biru royal ke ungu, latar lavender, kartu putih timbul */
:root {
  --blue: #3b4ed8;
  --blue2: #4a5cff;
  --purple: #6a5ae0;
  --bg: #edeffb;
  --card: #ffffff;
  --ink: #1e2235;
  --muted: #5f6584;
  --line: #e3e6f5;
  --green: #15803d;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 24px;
  /* Bayangan lembut berlapis ala soft-UI mockup v3: lapisan dekat tipis + lapisan jauh besar.
     Satu token dipakai semua kartu timbul, jadi elevasi konsisten di semua layar. */
  --shadow: 0 2px 8px rgba(59, 78, 216, .06), 0 16px 40px rgba(59, 78, 216, .14);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; cursor: pointer; }
input, select, textarea {
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue2); border-color: var(--blue2); }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
textarea { min-height: 88px; resize: vertical; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex: 0 0 264px;
  background: linear-gradient(180deg, var(--blue), var(--purple));
  color: #fff; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: none;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand img { width: 52px; height: 52px; border-radius: 16px; background: #fff; }
.brand b { font-size: 20px; display: block; }
.brand span { font-size: 13px; opacity: .85; }
.nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .95; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0; color: #fff; text-align: left;
  padding: 10px 12px; border-radius: 14px; font-size: 15px; min-height: 44px;
}
.nav-item:hover { background: rgba(255,255,255,.14); }
.nav-item.active { background: #fff; color: var(--blue); font-weight: 700; }
.nav-item .ico { font-size: 18px; width: 24px; text-align: center; }
.main { flex: 1; min-width: 0; padding: 20px 22px 120px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.topbar .logo-m { display: flex; align-items: center; gap: 10px; }
.topbar .logo-m img { width: 44px; height: 44px; border-radius: 12px; }
.topbar .logo-m b { font-size: 18px; }
.badge-contoh {
  display: inline-block; background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d; border-radius: 999px; padding: 4px 12px;
  font-size: 13px; font-weight: 700;
}
.content { max-width: 1060px; margin: 0 auto; }

/* ---------- Cards, grid, stats ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.profile-card {
  background: linear-gradient(135deg, var(--blue), var(--blue2) 55%, var(--purple));
  color: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.profile-card h1 { color: #fff; }
.profile-card p { opacity: 1; }
/* Chip di kartu profil dibuat badge putih (sesuai mockup Alma Ata) supaya teks biru di atasnya kontras 6.43:1. */
.profile-card .chip { background: #fff; color: var(--blue); border-color: transparent; }
.profile-card .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.stat .lbl { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .sub { font-size: 13px; color: var(--muted); }
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.menu-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; text-align: left; min-height: 84px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.menu-tile .ico { font-size: 26px; }
.menu-tile b { font-size: 15px; }
.menu-tile span { font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font-weight: 700; min-height: 44px; text-decoration: none;
}
.btn:hover { background: var(--blue2); }
.btn.secondary { background: #eef0fd; color: var(--blue); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn.success { background: #dcfce7; color: #15803d; }
.btn.warn { background: #fef3c7; color: #92400e; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }

/* ---------- Badges, bars, misc ---------- */
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.b-green { background: #dcfce7; color: #15803d; }
.b-amber { background: #fef3c7; color: #92400e; }
.b-red { background: #fee2e2; color: #b91c1c; }
.b-blue { background: #e0e7ff; color: #3730a3; }
.b-grey { background: #e5e7eb; color: #374151; }
.progress { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue2), var(--purple)); border-radius: 999px; }
.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 12px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-col .bar {
  width: 100%; max-width: 64px; border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--blue2), var(--purple));
  min-height: 4px;
}
.bar-col .val { font-weight: 800; font-size: 14px; }
.bar-col .cat { font-size: 12px; color: var(--muted); text-align: center; word-break: break-word; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 16px; font-weight: 700; min-height: 44px; color: var(--ink);
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar > * { flex: 1 1 160px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, var(--blue2), var(--purple));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; flex: 0 0 56px; border: 2px solid #fff;
  box-shadow: var(--shadow);
}
.row-flex { display: flex; align-items: center; gap: 12px; }
.row-flex .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.money { font-weight: 800; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.big-attend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.big-attend button { border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 700; padding: 12px 4px; min-height: 52px; }
.big-attend button.on-hadir { background: #dcfce7; border-color: var(--green); color: #15803d; }
.big-attend button.on-izin { background: #dbeafe; border-color: var(--blue); color: var(--blue); }
.big-attend button.on-sakit { background: #fef3c7; border-color: var(--amber); color: #92400e; }
.big-attend button.on-alpa { background: #fee2e2; border-color: var(--red); color: #b91c1c; }
.notice {
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 16px;
  padding: 14px 16px; margin-bottom: 14px;
}
.notice .close-x { float: right; background: none; border: 0; font-size: 20px; min-height: 44px; min-width: 44px; padding: 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #1e2235; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  max-width: 92vw; text-align: center;
}
/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 60, .55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 24px 24px 0 0; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto; padding: 22px;
}
.modal h2 { margin-bottom: 4px; }
/* Bottom nav (mobile) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  /* Kaca buram ala mockup v3: konten mengalir di bawah tab bar. Satu-satunya elemen blur
     di aplikasi (dose cap anti-slop R-10), opacity 86% supaya label abu tetap kontras. */
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(59, 78, 216, .08);
}
.bottomnav button {
  flex: 1; background: none; border: 0; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0;
}
.bottomnav button .ico { font-size: 21px; }
.bottomnav button.active { color: var(--blue); }
/* Home indicator ala mockup v3: bilah kecil di bawah tab bar (elemen di index.html). */
.home-indicator {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 91;
  width: 134px; height: 5px; border-radius: 999px; background: #111827;
  pointer-events: none;
}

/* ---------- Onboarding layar 1 (mockup v3) ---------- */
/* Tersembunyi sampai patch app.js menampilkannya di kunjungan pertama
   (cek localStorage, tombol Mulai/Lewati menutupnya). Ilustrasi HP di bawah
   ini digambar CSS sebagai miniatur produk sendiri; ilustrasi 3D tangan
   memegang HP dari mockup butuh aset gambar asli yang disetujui Mas. */
.onboarding {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue2) 48%, var(--purple) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 24px calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.onboarding[hidden] { display: none; }
.onb-inner { max-width: 340px; width: 100%; text-align: center; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.onb-phone { width: 188px; height: 320px; border-radius: 36px; background: #fff; padding: 12px; box-shadow: 0 24px 60px rgba(10, 16, 60, .35); flex: 0 0 auto; }
.onb-screen { height: 100%; border-radius: 26px; background: linear-gradient(160deg, #eef0fd, #e2e6ff); padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.onb-screen-bar { height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--blue), var(--purple)); }
.onb-screen-card { height: 46px; border-radius: 12px; background: #fff; box-shadow: 0 4px 12px rgba(59, 78, 216, .12); }
.onboarding h1 { color: #fff; font-size: 26px; font-weight: 800; line-height: 1.3; margin: 6px 0 0; text-wrap: balance; }
.onb-btn { display: inline-flex; align-items: center; justify-content: center; background: #fff; color: var(--blue); border-radius: 999px; min-height: 52px; padding: 12px 48px; font-weight: 800; font-size: 17px; text-decoration: none; box-shadow: 0 10px 24px rgba(10, 16, 60, .25); }
.onb-btn:hover { background: #eef0fd; }
.onb-skip { color: #fff; font-size: 15px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; }
/* Lainnya sheet */
.sheet {
  position: fixed; inset: 0; z-index: 95; background: rgba(20,24,60,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .panel {
  background: #fff; border-radius: 24px 24px 0 0; width: 100%; max-width: 560px;
  max-height: 80vh; overflow-y: auto; padding: 18px 18px 30px;
}
.sheet .panel button.item {
  display: flex; gap: 12px; align-items: center; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 12px 6px; text-align: left; font-size: 16px; font-weight: 600;
}
.sheet .panel button.item .ico { font-size: 22px; width: 30px; }
.hidden { display: none !important; }

/* ---------- Desktop >= 900px ---------- */
@media (min-width: 900px) {
  .sidebar { display: block; }
  .main { padding: 28px 32px 48px; }
  .bottomnav { display: none; }
  .home-indicator { display: none; }
  .topbar .logo-m { display: none; }
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 24px; }
  .toast { bottom: 32px; }
}
@media (max-width: 899px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat .num { font-size: 24px; }
}
@media (max-width: 520px) {
  .main { padding: 14px 14px 120px; }
  /* Layar 2 dan 3 mockup v3 berlatar putih; lavender hanya latar luar gambar referensi. */
  body { background: #fff; }
  /* Kartu profil: padding lebih ringkas dan teks info lebih kecil supaya kartu tidak terlalu tinggi di HP. */
  .profile-card { padding: 20px; }
  .profile-card p { font-size: 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
  .big-attend { grid-template-columns: repeat(2, 1fr); }
  /* Menu Beranda persis mockup Alma Ata: 4 kolom, tile hanya ikon + label.
     Sub-angka disembunyikan di HP karena angkanya sudah ada di 4 kartu statistik di atas. */
  .menu-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .menu-tile { padding: 12px 6px; min-height: 104px; align-items: center; text-align: center; border: 0; }
  /* Ikon 48px: aturan ronde 1 (36px) ternyata kalah spesifik dari aturan monogram di bawah
     file ini, jadi tidak pernah berlaku. Selektor .menu-grid di depan menaikkan spesifisitas. */
  .menu-grid .menu-tile .ico { width: 48px; height: 48px; border-radius: 16px; font-size: 15px; }
  /* Ikon warna-warni di atas pastel, mengikuti grid menu mockup v3. Urutan tile tetap
     dari app.js, jadi warna melekat ke posisi (8 warna berulang untuk 12 tile).
     Semua pasangan dihitung kontrasnya >= 4.5:1 (terendah hijau 4.57:1). */
  .menu-grid .menu-tile:nth-child(8n+1) .ico { background: #dbeafe; color: #1d4ed8; }
  .menu-grid .menu-tile:nth-child(8n+2) .ico { background: #dcfce7; color: #15803d; }
  .menu-grid .menu-tile:nth-child(8n+3) .ico { background: #fef3c7; color: #92400e; }
  .menu-grid .menu-tile:nth-child(8n+4) .ico { background: #fce7f3; color: #be185d; }
  .menu-grid .menu-tile:nth-child(8n+5) .ico { background: #ede9fe; color: #6d28d9; }
  .menu-grid .menu-tile:nth-child(8n+6) .ico { background: #fee2e2; color: #b91c1c; }
  .menu-grid .menu-tile:nth-child(8n+7) .ico { background: #cffafe; color: #0e7490; }
  .menu-grid .menu-tile:nth-child(8n+8) .ico { background: #ffedd5; color: #9a3412; }
  .menu-tile b { font-size: 13px; }
  .menu-tile > span:last-child { display: none; }
  /* Baris fleksibel boleh membungkus supaya tidak terjepit di layar sempit:
     bar jenjang, baris santri/nilai, dan chip murid terpilih. */
  .row-flex { flex-wrap: wrap; }
  .selected-chip { flex-wrap: wrap; }
  .topbar { flex-wrap: wrap; }
  /* Angka rupiah "Rp2.900.000" (11 karakter) harus muat di kartu statistik setengah lebar. */
  .stat .num { font-size: 20px; }
  /* Label kategori grafik 9 kelas membungkus 2 baris; beri ruang supaya tidak meluber. */
  .bar-chart { height: 212px; gap: 6px; }
  /* Pengumuman tampil sebagai kartu notifikasi putih ala mockup v3, bukan banner kuning. */
  .notice { background: #fff; border: 0; border-radius: 24px; box-shadow: var(--shadow); padding: 16px 18px; }
  /* Tombol export di Penilaian jadi tombol biru penuh ala layar 3 mockup v3.
     Tanpa ubah app.js: selektor atribut menarget tombol export rapor dan export nilai.
     Label tombol tetap dari app.js ("Export rapor (CSV)" / "Export CSV nilai"). */
  .btn-row button[onclick^="exportRaporCSV"], .btn-row button[onclick^="exportNilaiCSV"] {
    background: var(--blue); color: #fff; flex: 1 1 100%; min-height: 48px;
  }
  .btn-row button[onclick^="exportRaporCSV"]:hover, .btn-row button[onclick^="exportNilaiCSV"]:hover { background: var(--blue2); }
  /* Ronde Kirana R3: utilitas tampil mobile saja / desktop saja (struktur
     Beranda mockup v3). .only-mobile tampil sebagai block di HP; baris judul
     Notifikasi butuh flex, jadi ada aturan khususnya di bawah. */
  .only-mobile { display: block !important; }
  .only-mobile.dash-sec-row { display: flex !important; }
  .only-desktop { display: none !important; }
  /* Grid Menu Informasi mobile hanya 8 tile (7 modul + Lainnya); tile ke-9
     sampai ke-12 (KBM, Kemuridan, Sahabat Khidmah, Grafik, Laporan) tetap
     bisa dijangkau lewat sheet Lainnya. */
  .menu-extra { display: none !important; }
}

/* ---------- Mode tampilan: Desktop / Mobile (sakelar manual di Pengaturan) ---------- */
/* Mode desktop dipaksa lewat body.mode-desktop, mode mobile lewat body.mode-mobile.
   Tanpa kelas itu, tampilan ikut lebar layar (otomatis): >=900px desktop, <900px mobile. */
body.mode-desktop .sidebar { display: block; }
body.mode-desktop .bottomnav { display: none; }
body.mode-desktop .home-indicator { display: none; }
body.mode-desktop { background: var(--bg); }
body.mode-desktop .topbar .logo-m { display: none; }
body.mode-desktop .main { padding: 28px 32px 48px; }
body.mode-desktop .menu-grid { grid-template-columns: repeat(4, 1fr); }
body.mode-desktop .modal-backdrop { align-items: center; }
body.mode-desktop .modal { border-radius: 24px; }
body.mode-desktop .toast { bottom: 32px; }
body.mode-mobile .sidebar { display: none; }
body.mode-mobile .bottomnav { display: flex; }
body.mode-mobile .topbar .logo-m { display: flex; }
body.mode-mobile { background: #fff; }
body.mode-mobile .main { padding: 14px 14px 120px; }
/* Mode Mobile paksa juga memakai grid menu 4 kolom seperti mockup, bukan 2 kolom. */
body.mode-mobile .menu-grid { grid-template-columns: repeat(4, 1fr); }
body.mode-mobile .grid-4 { grid-template-columns: repeat(2, 1fr); }
/* Mode Mobile paksa memakai aturan mobile yang sama seperti <=520px di atas. */
body.mode-mobile .profile-card { padding: 20px; }
body.mode-mobile .profile-card p { font-size: 14px; }
body.mode-mobile .menu-tile { border: 0; min-height: 104px; }
body.mode-mobile .menu-grid .menu-tile .ico { width: 48px; height: 48px; border-radius: 16px; font-size: 15px; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+1) .ico { background: #dbeafe; color: #1d4ed8; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+2) .ico { background: #dcfce7; color: #15803d; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+3) .ico { background: #fef3c7; color: #92400e; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+4) .ico { background: #fce7f3; color: #be185d; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+5) .ico { background: #ede9fe; color: #6d28d9; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+6) .ico { background: #fee2e2; color: #b91c1c; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+7) .ico { background: #cffafe; color: #0e7490; }
body.mode-mobile .menu-grid .menu-tile:nth-child(8n+8) .ico { background: #ffedd5; color: #9a3412; }
body.mode-mobile .notice { background: #fff; border: 0; border-radius: 24px; box-shadow: var(--shadow); padding: 16px 18px; }
body.mode-mobile .btn-row button[onclick^="exportRaporCSV"], body.mode-mobile .btn-row button[onclick^="exportNilaiCSV"] {
  background: var(--blue); color: #fff; flex: 1 1 100%; min-height: 48px;
}
/* Ronde Kirana R3: cermin aturan <=520px untuk mode Mobile paksa. */
body.mode-mobile .only-mobile { display: block !important; }
body.mode-mobile .only-mobile.dash-sec-row { display: flex !important; }
body.mode-mobile .only-desktop { display: none !important; }
body.mode-mobile .menu-extra { display: none !important; }

/* Monogram huruf pengganti ikon (tanpa emoji dekoratif, sesuai anti-slop R-04) */
.nav-item .ico, .bottomnav button .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: 13px; font-weight: 800; font-style: normal;
}
.nav-item.active .ico { background: #eef0fd; color: var(--blue); }
.bottomnav button .ico { background: #eef0fd; color: var(--blue); width: 28px; height: 28px; flex-basis: 28px; font-size: 12px; }
.bottomnav button.active .ico { background: var(--blue); color: #fff; }
.menu-tile .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--blue2), var(--purple)); color: #fff;
  font-size: 15px; font-weight: 800; font-style: normal;
}

/* ---------- Indikator status sinkron (selalu terlihat di header) ---------- */
.sync-status {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700;
  background: #eef0fd; color: var(--blue); border: 1px solid #dbe2fb;
  white-space: nowrap;
}
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue2); flex: 0 0 10px; }
.sync-status.offline { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.sync-status.offline .sync-dot { background: #d97706; }
.sync-status.pending { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.sync-status.pending .sync-dot { background: #ea580c; }
.sync-status.ok { background: #dcfce7; color: #15803d; border-color: #86efac; }
.sync-status.ok .sync-dot { background: #16a34a; }
.sync-status.idle { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.sync-status.idle .sync-dot { background: #6b7280; }

/* ---------- Pesan sukses / gagal yang jelas (bukan toast samar) ---------- */
.alert { border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; font-size: 15px; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
.alert-error { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
.alert-info { background: #dbeafe; border: 1px solid #93c5fd; color: #1e3a8a; }
.alert b { display: block; margin-bottom: 4px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Picker: cari + chip filter + tampil bertahap ---------- */
.chip-filter {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; min-height: 44px; color: var(--ink);
}
.chip-filter.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.picker-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 12px; margin-bottom: 8px; text-align: left; min-height: 64px;
}
.picker-row:hover { border-color: var(--blue2); }
.picker-row .nm { font-weight: 700; }
.picker-row .sb { font-size: 13px; color: var(--muted); }
.selected-chip {
  display: flex; align-items: center; gap: 10px;
  background: #eef0fd; border: 1.5px solid var(--blue2); border-radius: 16px;
  padding: 10px 12px; margin: 10px 0;
}
.selected-chip .nm { font-weight: 700; }
.picker-count { font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---------- Detail dan lain-lain ---------- */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.kv td:first-child { color: var(--muted); width: 42%; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue2); outline-offset: 2px;
}
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--blue); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 14px; flex: 0 0 28px;
}
.howto { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-start; }
.howto p { margin: 0; }
.file-drop {
  border: 2px dashed var(--blue2); border-radius: 16px; padding: 18px; text-align: center;
  background: #f5f6ff; margin: 10px 0;
}
pre.code {
  background: #1e2235; color: #e5e7eb; border-radius: 16px; padding: 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; white-space: pre;
}

/* ================= DESKTOP 1280px: tata letak mockup (ronde Kirana) ================= */
/* Arah: mockup desktop TPQ Al-Muttaqin yang disetujui Mas (15 Nov), sistem visual Alma Ata
   yang sama dengan mobile: gradien #3B4ED8 ke #6A5AE0, latar lavender #EDEFFB, kartu putih
   radius 24px dengan token bayangan --shadow. Aturan di sini hanya berlaku di desktop
   (lebar >= 900px atau body.mode-desktop), jadi tampilan mobile tidak berubah.
   Aritmetika lebar di 1280px: sidebar 272 + padding main 32 + konten 944 + padding main 32 = 1280.
   Nilai visual dari ui-ux-pro-max (sidebar dashboard, tabel data, grafik batang) dan
   Addy Osmani (skala spasi kelipatan 4px, kontras AA, target sentuh 44px, tanpa font eksternal).
   Design Read: dashboard admin untuk pengurus TPQ dan Ibtidaiyah, bahasa visual Alma Ata,
   dial ENERGY 2 / RHYTHM 2 / MOTION 1 (hover saja, transisi 0.15s, tanpa animasi berulang).
   Alasan gradien (anti-slop R-01): gradien hanya menandai yang aktif, yaitu menu sidebar yang
   sedang dibuka dan chip jenjang yang sedang dipilih, bukan hiasan halaman. Bayangan (R-12)
   hanya penanda elevasi: kartu timbul dan sidebar di atas bidang konten. */

/* ---- Mode otomatis: lebar >= 900px ---- */
@media (min-width: 900px) {
  /* Shell: sidebar putih 272px, konten 944px (272 + 32 + 944 + 32 = 1280). */
  .sidebar {
    width: 272px; flex-basis: 272px;
    background: #fff; color: var(--ink);
    border-right: 1px solid var(--line);
    box-shadow: 6px 0 24px rgba(59, 78, 216, .07);
    padding: 20px 16px;
  }
  .content { max-width: 944px; }
  .topbar { margin-bottom: 20px; }
  /* Brand: logo di atas pastel, nama lembaga warna tinta, subjudul abu. */
  .brand { padding: 4px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .brand img { background: #eef0fd; border: 1px solid var(--line); }
  .brand b { color: var(--ink); font-size: 19px; }
  .brand span { color: var(--muted); opacity: 1; }
  /* Menu: label kelompok abu tebal, item tinta, hover biru muda, aktif gradien putih. */
  .nav-group { color: var(--muted); font-weight: 700; opacity: 1; padding: 16px 12px 6px; }
  .nav-item { color: var(--ink); font-weight: 600; border-radius: 12px; }
  .nav-item:hover { background: #eef0fd; }
  .nav-item.active {
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff; font-weight: 800;
    box-shadow: 0 6px 16px rgba(59, 78, 216, .35);
  }
  .nav-item .ico { background: #eef0fd; color: var(--blue); }
  .nav-item.active .ico { background: rgba(255, 255, 255, .25); color: #fff; }
  /* Pemilih jenjang: kontrol tersegmentasi di atas konten, yang aktif bergradien.
     Bar jenjang selalu anak pertama #view (render() menaruh jenjangBarHtml di depan),
     jadi selektor ini hanya kena bar itu, bukan chip picker di modal. */
  #view > .card:first-child .chip-row { background: #eef0fd; border-radius: 999px; padding: 4px; }
  #view > .card:first-child .chip-filter { border-color: transparent; background: transparent; color: var(--muted); padding: 8px 18px; }
  #view > .card:first-child .chip-filter:hover { color: var(--blue); }
  #view > .card:first-child .chip-filter.active {
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #fff; border-color: transparent;
    box-shadow: 0 4px 12px rgba(59, 78, 216, .35);
  }
  /* Statistik: 4 kartu, angka besar tebal dengan clamp supaya rupiah muat sampai 1100px. */
  .grid-4 { gap: 16px; }
  .stat { padding: 20px; }
  .stat .num { font-size: clamp(19px, 2vw, 26px); white-space: nowrap; }
  /* Tabel: baris lebih lega, hover halus, avatar inisial 40px, kolom cari lebih lebar. */
  th { padding: 12px; white-space: nowrap; }
  td { padding: 12px; }
  tbody tr { transition: background-color .15s ease; }
  tbody tr:hover td { background: #f5f6ff; }
  .table-wrap .avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 15px; }
  .toolbar { gap: 12px; }
  .toolbar input[type="search"] { flex: 2 1 300px; }
  .toolbar select { flex: 1 1 150px; }
  /* Grafik batang: lebih tinggi, batang lebih lebar, hover memperterang batang. */
  .bar-chart { height: 220px; gap: 18px; }
  .bar-col .bar { max-width: 72px; transition: filter .15s ease; }
  .bar-col:hover .bar { filter: brightness(1.12); }
  .bar-col .val { font-size: 15px; }
  /* Tile menu Beranda: hover menandai batas biru, tanpa mengubah isi. */
  .menu-tile { transition: border-color .15s ease, box-shadow .15s ease; }
  .menu-tile:hover { border-color: var(--blue2); }
}

/* ---- Mode paksa: body.mode-desktop (sakelar di Pengaturan) ---- */
body.mode-desktop .sidebar {
  width: 272px; flex-basis: 272px;
  background: #fff; color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 6px 0 24px rgba(59, 78, 216, .07);
  padding: 20px 16px;
}
body.mode-desktop .content { max-width: 944px; }
body.mode-desktop .topbar { margin-bottom: 20px; }
body.mode-desktop .brand { padding: 4px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
body.mode-desktop .brand img { background: #eef0fd; border: 1px solid var(--line); }
body.mode-desktop .brand b { color: var(--ink); font-size: 19px; }
body.mode-desktop .brand span { color: var(--muted); opacity: 1; }
body.mode-desktop .nav-group { color: var(--muted); font-weight: 700; opacity: 1; padding: 16px 12px 6px; }
body.mode-desktop .nav-item { color: var(--ink); font-weight: 600; border-radius: 12px; }
body.mode-desktop .nav-item:hover { background: #eef0fd; }
body.mode-desktop .nav-item.active {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff; font-weight: 800;
  box-shadow: 0 6px 16px rgba(59, 78, 216, .35);
}
body.mode-desktop .nav-item .ico { background: #eef0fd; color: var(--blue); }
body.mode-desktop .nav-item.active .ico { background: rgba(255, 255, 255, .25); color: #fff; }
body.mode-desktop #view > .card:first-child .chip-row { background: #eef0fd; border-radius: 999px; padding: 4px; }
body.mode-desktop #view > .card:first-child .chip-filter { border-color: transparent; background: transparent; color: var(--muted); padding: 8px 18px; }
body.mode-desktop #view > .card:first-child .chip-filter:hover { color: var(--blue); }
body.mode-desktop #view > .card:first-child .chip-filter.active {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(59, 78, 216, .35);
}
body.mode-desktop .grid-4 { gap: 16px; }
body.mode-desktop .stat { padding: 20px; }
body.mode-desktop .stat .num { font-size: clamp(19px, 2vw, 26px); white-space: nowrap; }
body.mode-desktop th { padding: 12px; white-space: nowrap; }
body.mode-desktop td { padding: 12px; }
body.mode-desktop tbody tr { transition: background-color .15s ease; }
body.mode-desktop tbody tr:hover td { background: #f5f6ff; }
body.mode-desktop .table-wrap .avatar { width: 40px; height: 40px; flex-basis: 40px; font-size: 15px; }
body.mode-desktop .toolbar { gap: 12px; }
body.mode-desktop .toolbar input[type="search"] { flex: 2 1 300px; }
body.mode-desktop .toolbar select { flex: 1 1 150px; }
body.mode-desktop .bar-chart { height: 220px; gap: 18px; }
body.mode-desktop .bar-col .bar { max-width: 72px; transition: filter .15s ease; }
body.mode-desktop .bar-col:hover .bar { filter: brightness(1.12); }
body.mode-desktop .bar-col .val { font-size: 15px; }
body.mode-desktop .menu-tile { transition: border-color .15s ease, box-shadow .15s ease; }
body.mode-desktop .menu-tile:hover { border-color: var(--blue2); }

/* ---- Statistik 4 kolom tidak muat di bawah 1100px (rupiah 11 karakter meluber),
   jadi 2 kolom dulu. Berlaku untuk mode otomatis dan mode desktop paksa. ---- */
@media (min-width: 900px) and (max-width: 1099px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}
@media (max-width: 1099px) {
  body.mode-desktop .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}

/* ================= Ronde Kirana R3: struktur dashboard mobile mockup v3 ================= */
/* Aturan dasar (berlaku di semua lebar; visibilitas diatur .only-mobile /
   .only-desktop di media query <=520px dan mode-mobile di atas). Palet dan
   radius mengikuti DESIGN.md: gradien #3B4ED8 ke #6A5AE0, kartu radius 24px,
   bayangan token --shadow. Alasan anti-slop: gradien hanya pada kartu profil
   (satu elemen penanda identitas, R-01) dan blur hanya pada tab bar (R-10,
   sudah ada sebelumnya); tidak ada dekorasi baru. */
/* Utilitas tampil: mobile saja sembunyi di desktop, desktop saja tampil biasa. */
.only-mobile { display: none !important; }
/* Sapaan Beranda mobile: baris kecil abu + nama lembaga tebal (mockup layar 2). */
.dash-greet { font-size: 13px; color: var(--muted); font-weight: 500; margin: 4px 0 2px; }
.dash-inst { font-size: 24px; font-weight: 800; letter-spacing: -.3px; line-height: 1.2; margin: 0 0 14px; }
/* Kartu profil santri: gradien, badge putih kanan atas berisi kelas, NIS,
   nama, kelas + hafalan. Tombol utuh, ketuk membuka Hasil Belajar santri itu. */
.profile-card-santri {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer; font-family: inherit;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--blue2) 55%, var(--purple));
  color: #fff; border-radius: 24px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.profile-card-santri .pc-nis { display: block; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .78); letter-spacing: .5px; }
.profile-card-santri .pc-name { display: block; font-size: 20px; font-weight: 700; margin-top: 4px; }
.profile-card-santri .pc-meta { display: block; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .92); margin-top: 8px; line-height: 1.6; }
.profile-card-santri .pc-badge {
  position: absolute; top: 16px; right: 16px;
  background: #fff; color: var(--blue); font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; box-shadow: 0 6px 14px rgba(10, 16, 60, .25);
}
.profile-card-santri .contoh-chip {
  display: inline-block; margin-top: 12px; background: rgba(255, 255, 255, .22); color: #fff;
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
/* Judul bagian Beranda mobile + baris judul Notifikasi dengan Lihat semua. */
.dash-sec { font-size: 17px; font-weight: 700; margin: 20px 0 12px; }
.dash-sec-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 12px; }
.dash-sec-row h2 { margin: 0; font-size: 17px; font-weight: 700; }
.link-btn { border: 0; background: none; color: var(--blue); font-size: 13px; font-weight: 700; padding: 4px 0; min-height: 32px; }
/* Tab bar bawah: ikon SVG garis + label kata utuh. Aturan ini ditaruh di akhir
   file supaya menang atas aturan monogram (.nav-item .ico, .bottomnav button
   .ico) di atas: ikon tidak lagi kotak berisi dua huruf, label 10px nowrap
   supaya Beranda, Santri, Tabungan, Keuangan, Kelas muat utuh di 390px
   (6 tombol x 65px; label terpanjang Keuangan sekitar 48px pada 10px). */
.bottomnav button { min-height: 54px; padding: 5px 2px; gap: 3px; }
.bottomnav button .ico { background: none; width: 24px; height: 24px; flex-basis: 24px; border-radius: 0; }
.bottomnav button .ico svg { width: 22px; height: 22px; display: block; }
.bottomnav button.active .ico { background: none; color: var(--blue); }
.bottomnav button .bn-label { font-size: 10px; line-height: 1.3; white-space: nowrap; }
