:root {
  --green-900: #0d3320;
  --green-800: #145228;
  --green-700: #1a6b35;
  --green-600: #22883f;
  --green-500: #2baa50;
  --green-100: #d6f0df;
  --green-50:  #edf8f1;
  --gold:      #c8a84b;
  --gold-light:#f0d98a;
  --text-dark: #1a2332;
  --text-mid:  #4a5568;
  --text-light:#718096;
  --border:    #e2e8f0;
  --bg-main:   #f4f7f5;
  --bg-card:   #ffffff;
  --red:       #e53e3e;
  --red-light: #fff5f5;
  --blue:      #3182ce;
  --blue-light:#ebf8ff;
  --orange:    #dd6b20;
  --sidebar-w: 260px;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
}

/* ───── PRINT (Task 10 — Skenario Tabel 3.7: cetak/ekspor laporan) ───── */
@media print {
  /* Reset layout agar konten cetak penuh lebar halaman */
  body, html { background: white !important; margin: 0 !important; }
  .main      { margin-left: 0 !important; padding: 0 !important; }
  .page      { padding: 16px !important; }

  /* Sembunyikan elemen UI yang tidak relevan saat cetak */
  .sidebar,
  .search-row,
  .filter-select,
  .search-input,
  .btn,
  button,
  .form-actions,
  #step-indicator,
  #toast-container,
  .modal-overlay,
  .sidebar-footer,
  #bayar-step1,
  #bayar-step2,
  #bayar-step3 { display: none !important; }

  /* Sembunyikan halaman yang tidak aktif */
  .page:not(.active) { display: none !important; }

  /* Tambahkan header institusi sebelum judul laporan */
  .page-header h1::before {
    content: "SMA Swasta Al Hikmah Medan — ";
    font-weight: normal;
    font-size: 0.85em;
    color: #555;
  }

  /* Card: hilangkan shadow, tambahkan border cetak */
  .card,
  .report-sum-card,
  .stat-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }
  .card-header { background: #f5f5f5 !important; }

  /* Summary cards: jangan page-break di tengah */
  .report-summary,
  .stats-grid { break-inside: avoid; }

  /* Tabel: border jelas untuk cetakan */
  table { border-collapse: collapse !important; width: 100% !important; font-size: 10pt; }
  th, td {
    border: 1px solid #999 !important;
    padding: 5px 8px !important;
  }
  h1 { font-size: 18pt; }

  /* Pastikan warna penting tetap tercetak (badge, background summary) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Sembunyikan chart (tidak relevan saat cetak laporan tabel) */
  .chart-container { display: none !important; }

  /* Modal nota: tampilkan dengan layout statis agar bisa dicetak */
  #modal-nota.open {
    display: block !important;
    position: static !important;
    background: white !important;
    padding: 0 !important;
  }
  #modal-nota.open .modal-box {
    box-shadow: none !important;
    max-width: 100% !important;
    border: none !important;
  }
  #modal-nota.open .modal-header,
  #modal-nota.open .modal-footer { display: none !important; }
  #modal-nota.open .modal-body   { padding: 0 !important; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg-main); color: var(--text-dark); min-height: 100vh; }
h1,h2,h3,h4 { font-family: 'Playfair Display', serif; }

/* ───── LOGIN ───── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 60%, var(--green-600) 100%);
  position: relative;
  overflow: hidden;
}
#login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(60deg, transparent, transparent 40px, rgba(255,255,255,.03) 40px, rgba(255,255,255,.03) 41px);
}
.login-box {
  background: white;
  border-radius: 20px;
  padding: 48px 44px;
  width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .school-badge {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.login-logo h2 { color: var(--green-800); font-size: 1.35rem; line-height: 1.3; }
.login-logo p  { color: var(--text-light); font-size: .82rem; margin-top: 4px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: .83rem; font-weight: 600; color: var(--text-mid); margin-bottom: 8px; letter-spacing: .3px; }
.form-group input {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: .95rem;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(34,136,63,.12); }
.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--green-700), var(--green-800));
  color: white; border: none; border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: transform .15s, box-shadow .15s; margin-top: 8px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,107,53,.35); }
.error-msg {
  background: var(--red-light); color: var(--red);
  border-radius: 8px; padding: 10px 14px;
  font-size: .85rem; margin-bottom: 16px; display: none;
}

/* ───── LAYOUT ───── */
#app { display: none; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--green-900);
  display: flex; flex-direction: column;
  z-index: 100; overflow: hidden;
}
.sidebar::before {
  content: ''; position: absolute; top: -50px; right: -50px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(200,168,75,.08); pointer-events: none;
}
.sidebar-header { padding: 28px 24px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo .badge {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo .info h3 { color: white; font-size: .88rem; line-height: 1.3; }
.sidebar-logo .info p  { color: var(--gold); font-size: .7rem; font-weight: 500; margin-top: 2px; }
.sidebar-user { padding: 16px 24px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-user .user-name { color: white; font-size: .9rem; font-weight: 600; }
.sidebar-user .user-role {
  display: inline-block; background: rgba(200,168,75,.2); color: var(--gold-light);
  font-size: .7rem; padding: 2px 10px; border-radius: 20px; margin-top: 4px; font-weight: 500;
}
.sidebar-nav { flex: 1; padding: 16px 14px; overflow-y: auto; }
.nav-section { font-size: .67rem; color: rgba(255,255,255,.35); letter-spacing: 1px; font-weight: 600; text-transform: uppercase; padding: 12px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,.7); cursor: pointer;
  transition: all .18s; font-size: .88rem; font-weight: 500;
  margin-bottom: 2px; user-select: none;
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: rgba(200,168,75,.18); color: var(--gold-light); }
.nav-item.active .icon { filter: drop-shadow(0 0 4px rgba(200,168,75,.5)); }
.sidebar-footer { padding: 16px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.btn-logout {
  width: 100%; padding: 11px;
  background: rgba(229,62,62,.12); color: #fc8181;
  border: 1px solid rgba(229,62,62,.2); border-radius: 10px;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  font-size: .88rem; font-weight: 600; transition: all .18s;
}
.btn-logout:hover { background: rgba(229,62,62,.22); color: #fff; }

/* ───── MAIN ───── */
.main { margin-left: var(--sidebar-w); padding: 32px; min-height: 100vh; }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.75rem; color: var(--green-900); }
.page-header p  { color: var(--text-light); font-size: .88rem; margin-top: 4px; }

/* ───── STAT CARDS ───── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  display: flex; align-items: center; gap: 18px;
  transition: transform .18s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.green { border-left-color: var(--green-600); }
.stat-card.red   { border-left-color: var(--red); }
.stat-card.blue  { border-left-color: var(--blue); }
.stat-card.gold  { border-left-color: var(--gold); }
.stat-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-card.green .stat-icon { background: var(--green-50); }
.stat-card.red   .stat-icon { background: var(--red-light); }
.stat-card.blue  .stat-icon { background: var(--blue-light); }
.stat-card.gold  .stat-icon { background: #fffbeb; }
.stat-info p  { font-size: .78rem; color: var(--text-light); font-weight: 500; margin-bottom: 4px; }
.stat-info h3 { font-size: 1.4rem; color: var(--text-dark); font-family: 'DM Sans', sans-serif; font-weight: 700; }

/* ───── CARDS ───── */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 24px; }
.card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 1rem; color: var(--text-dark); }
.card-body { padding: 24px; }

/* ───── TABLES ───── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--green-50); padding: 11px 14px; text-align: left;
  font-weight: 600; font-size: .78rem; color: var(--green-800);
  letter-spacing: .3px; border-bottom: 2px solid var(--green-100);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-mid); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--green-50); }

/* ───── BADGES ───── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-green { background: var(--green-100); color: var(--green-800); }
.badge-red   { background: var(--red-light); color: var(--red); }
.badge-blue  { background: var(--blue-light); color: var(--blue); }
.badge-gold  { background: #fef3c7; color: #92400e; }
.badge-gray  { background: #f7fafc; color: var(--text-light); border: 1px solid var(--border); }

/* ───── BUTTONS ───── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: .875rem; font-weight: 600; transition: all .18s; }
.btn-primary   { background: var(--green-700); color: white; }
.btn-primary:hover { background: var(--green-800); }
.btn-danger    { background: var(--red-light); color: var(--red); border: 1px solid rgba(229,62,62,.2); }
.btn-danger:hover  { background: var(--red); color: white; }
.btn-secondary { background: #f7fafc; color: var(--text-mid); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #b8942a); color: white; }
.btn-sm { padding: 5px 12px; font-size: .78rem; }

/* ───── FORMS ───── */
.form-row { display: grid; gap: 18px; margin-bottom: 18px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-mid); margin-bottom: 7px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: .9rem;
  outline: none; transition: border-color .18s, box-shadow .18s; background: white;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(34,136,63,.1);
}
.form-field input:disabled {
  background: var(--border); color: var(--text-light); cursor: not-allowed;
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 12px; margin-top: 22px; }

/* ───── SEARCH ───── */
.search-row { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 200px; padding: 9px 14px 9px 40px;
  border: 2px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: .88rem; outline: none; background: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23718096' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center;
  transition: border-color .18s;
}
.search-input:focus { border-color: var(--green-600); }
.filter-select { padding: 9px 14px; border: 2px solid var(--border); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: .88rem; outline: none; background: white; transition: border-color .18s; }
.filter-select:focus { border-color: var(--green-600); }

/* ───── MODAL ───── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: white; border-radius: 16px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; color: var(--text-dark); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* ───── TOAST ───── */
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 500; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: white; border-radius: 10px; padding: 14px 18px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px;
  min-width: 280px; animation: slideIn .3s ease; border-left: 4px solid var(--green-600);
}
.toast.error { border-left-color: var(--red); }
.toast .toast-icon { font-size: 18px; }
.toast .toast-msg  { font-size: .88rem; font-weight: 500; color: var(--text-dark); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ───── GRID ───── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chart-container { height: 280px; position: relative; }

/* ───── STEP INDICATOR ───── */
.step-indicator { display: flex; align-items: center; margin-bottom: 28px; }
.step-item { display: flex; align-items: center; gap: 8px; flex: 1; }
.step-num { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; transition: all .2s; }
.step-item.done   .step-num { background: var(--green-700); color: white; }
.step-item.active .step-num { background: var(--gold); color: white; }
.step-item.pending .step-num { background: var(--border); color: var(--text-light); }
.step-label { font-size: .8rem; font-weight: 600; color: var(--text-light); }
.step-item.active .step-label { color: var(--text-dark); }
.step-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; }
.step-line.done { background: var(--green-600); }

/* ───── SISWA RESULT ───── */
.siswa-result-card { background: var(--green-50); border: 2px solid var(--green-100); border-radius: 10px; padding: 16px 20px; display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.siswa-avatar { width: 48px; height: 48px; background: var(--green-700); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px; font-weight: 700; font-family: 'Playfair Display', serif; flex-shrink: 0; }
.siswa-result-card .info h4 { font-size: .95rem; color: var(--text-dark); font-family: 'DM Sans', sans-serif; font-weight: 700; }
.siswa-result-card .info p  { font-size: .8rem; color: var(--text-light); margin-top: 2px; }

/* ───── NOTA ───── */
.nota-preview { background: white; border: 2px solid var(--border); border-radius: 12px; padding: 28px; font-family: 'Courier New', monospace; font-size: .82rem; line-height: 1.8; }
.nota-preview .separator { border-top: 1px dashed #aaa; margin: 10px 0; }
.nota-preview .center  { text-align: center; }
.nota-preview .bold    { font-weight: 700; }
.nota-preview .row     { display: flex; justify-content: space-between; }

/* ───── LAPORAN SUMMARY ───── */
.report-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 24px; }
.report-sum-card { background: white; border-radius: 10px; padding: 18px 20px; text-align: center; box-shadow: var(--shadow); }
.report-sum-card .label { font-size: .78rem; color: var(--text-light); font-weight: 600; margin-bottom: 6px; }
.report-sum-card .value { font-size: 1.3rem; font-weight: 700; font-family: 'DM Sans', sans-serif; }
.report-sum-card.income  .value { color: var(--green-700); }
.report-sum-card.expense .value { color: var(--red); }
.report-sum-card.saldo   .value { color: var(--blue); }

/* ───── EMPTY STATE ───── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-light); }
.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: .88rem; }

/* ───── LOADING ───── */
.loading-row td { text-align: center; padding: 32px; color: var(--text-light); font-size: .88rem; }

/* ───── SCROLLBAR ───── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--green-100); border-radius: 3px; }

/* ───── MASTER BIAYA ───── */
#page-master-biaya .tarif-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; background: var(--green-50); color: var(--green-700); }

/* ───── INPUT PEMBAYARAN — MASTER INFO & CICILAN ───── */
.master-info-card { background: var(--green-50); border: 1px solid var(--green-100); border-radius: 10px; padding: 14px 18px; margin-bottom: 12px; }
.master-info-card .mi-label { font-size: .75rem; color: var(--text-light); font-weight: 600; margin-bottom: 2px; }
.master-info-card .mi-value { font-size: 1rem; font-weight: 700; color: var(--green-700); }
.cicilan-history { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; font-size: .8rem; }
.cicilan-history table { width: 100%; border-collapse: collapse; }
.cicilan-history td { padding: 3px 6px; }
.sisa-tagihan-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 6px 10px; background: #fff3cd; border-radius: 6px; font-size: .82rem; font-weight: 600; color: #856404; }
.bukti-preview { margin-top: 6px; font-size: .8rem; }
.bukti-preview a { color: var(--green-700); text-decoration: underline; }

/* ───── STATUS TAGIHAN ───── */
.tagihan-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagihan-sisa { font-size: .82rem; font-weight: 700; color: var(--red); }
.tagihan-lunas { font-size: .82rem; font-weight: 700; color: var(--green-700); }
