:root {
  --em-900: #064e3b;
  --em-800: #065f46;
  --em-700: #047857;
  --em-600: #059669;
  --em-100: #d1fae5;
  --em-50:  #ecfdf5;
  --gold:   #c9a227;
  --gold-soft: #f6e9b8;
  --ink: #17332a;
  --line: #e3ece8;
  --bg: #f5f8f6;
  --sidebar-w: 264px;
}
html { scroll-padding-top: 72px; }
body { font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--em-700); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn-emerald { background: var(--em-700); border-color: var(--em-700); color: #fff; }
.btn-emerald:hover, .btn-emerald:focus { background: var(--em-800); border-color: var(--em-800); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #2b2200; font-weight: 600; }
.btn-gold:hover { background: #b38f1d; border-color: #b38f1d; color: #2b2200; }
.btn-icon { border: 0; font-size: 1.2rem; color: var(--em-900); }

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  background: linear-gradient(180deg, var(--em-900), var(--em-800));
  color: #d7efe5; display: flex; flex-direction: column; overflow-y: auto;
  transition: transform .2s ease;
}
.sidebar-brand { display: flex; gap: .75rem; align-items: center; padding: 1.25rem 1.25rem 1rem; border-bottom: 3px solid var(--gold); color: #fff; }
.sidebar-brand small { color: var(--gold-soft); }
.brand-logo { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; flex: none; }
.brand-logo-fallback { display: grid; place-items: center; color: var(--em-800); font-size: 1.25rem; }
.sidebar-nav { padding: .75rem; display: flex; flex-direction: column; gap: 2px; }
.nav-link-app { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border-radius: 8px; color: #d7efe5; text-decoration: none; font-weight: 500; }
.nav-link-app i { width: 1.25rem; text-align: center; }
.nav-link-app:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link-app.active { background: #fff; color: var(--em-800); box-shadow: inset 4px 0 0 var(--gold); }
.nav-link-app.disabled { opacity: .5; cursor: not-allowed; }
.nav-link-app.disabled:hover { background: none; color: #d7efe5; }
.nav-link-app em { margin-left: auto; font-size: .7rem; font-style: normal; background: rgba(255,255,255,.14); padding: 1px 8px; border-radius: 99px; }
.sidebar-backdrop { display: none; }

.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title strong { font-size: 1.05rem; color: var(--em-900); }
.btn-user { display: flex; align-items: center; gap: .6rem; border: 0; background: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: #2b2200; display: grid; place-items: center; font-weight: 700; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem; font-size: .85rem; color: #6b8379; border-top: 1px solid var(--line); background: #fff; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1030; }
  .app-main { margin-left: 0; }
  .topbar { padding: .6rem 1rem; }
  .content { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Kartu & tabel ---------- */
.card-app { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.card-app .card-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--em-900); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-app .card-body-pad { padding: 1.1rem; }

.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: flex; gap: .8rem; align-items: center; height: 100%; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: var(--em-50); color: var(--em-700); flex: none; }
.stat-card.is-gold .stat-icon { background: var(--gold-soft); color: #7a5f00; }
.stat-card.is-warn .stat-icon { background: #fde8e8; color: #b42318; }
.stat-label { color: #5d786c; font-size: .85rem; }
.stat-value { font-size: 1.2rem; font-weight: 700; line-height: 1.15; color: var(--em-900); word-break: break-word; }

.table-app thead th { background: var(--em-50); color: var(--em-900); font-weight: 600; border-bottom: 2px solid var(--em-100); white-space: nowrap; }
.table-app td, .table-app th { vertical-align: middle; }
.badge-lunas { background: var(--em-100); color: var(--em-800); }
.badge-cicilan { background: var(--gold-soft); color: #7a5f00; }
.badge-belum { background: #fde8e8; color: #b42318; }
.chart-box { position: relative; height: 280px; }

.print-only { display: none; }
/* Kop laporan cetak/PDF: logo kiri, tiga baris teks biru tua di tengah, garis tebal + garis tipis di bawah. */
.kop-lap { position: relative; text-align: center; min-height: 96px; padding: 0 110px .55rem; margin-bottom: 1.5rem; border-bottom: 3px solid #1f3a6e; font-family: Arial, Helvetica, sans-serif; color: #1f3a6e; }
.kop-lap::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; border-top: 1px solid #1f3a6e; }
.kop-lap .kop-logo { position: absolute; left: 0; top: 0; width: 96px; height: 96px; object-fit: contain; }
.kop-lap .kop-kemenag, .kop-lap .kop-induk { font-size: 1.02rem; font-weight: 700; text-transform: uppercase; line-height: 1.3; }
.kop-lap .kop-nama { font-size: 1.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; line-height: 1.25; }
.kop-lap .kop-alamat { font-size: .85rem; color: #000; }
.kwitansi { max-width: 720px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem; }
.kwitansi-kop { position: relative; text-align: center; border-bottom: 3px double var(--em-900); padding-bottom: .75rem; margin-bottom: 1rem; }
.kwitansi-kop.ada-logo { min-height: 72px; padding-left: 84px; padding-right: 84px; }
.kwitansi-logo { position: absolute; left: 0; top: 0; width: 72px; height: 72px; object-fit: contain; }
.ttd-box { min-height: 72px; }
/* Tanda tangan laporan keuangan: satu baris tiga kolom (Kepala Madrasah, Kepala Pesmad, Bendahara). */
.ttd-lap { display: flex; justify-content: space-between; font-family: "Times New Roman", Times, serif; font-size: 1rem; line-height: 1.5; break-inside: avoid; page-break-inside: avoid; }
.ttd-lap .kol { width: 33.33%; text-align: center; }
.ttd-lap .ruang { height: 64px; }
.ttd-lap .nama { font-weight: 700; text-decoration: underline; }
@media print {
  .print-only { display: block !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .kwitansi, .card-app { border: 0; box-shadow: none; }
  .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
  .app-main { margin: 0; }
}
