/* ─── Reset & Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --hijau: #2e7d32;
  --hijau-muda: #43a047;
  --hijau-pale: #e8f5e9;
  --kuning: #f9a825;
  --merah: #c62828;
  --abu: #757575;
  --abu-muda: #f5f5f5;
  --putih: #ffffff;
  --teks: #212121;
  --sidebar-w: 240px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
}
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f4f0;
  color: var(--teks);
  font-size: 14px;
}

/* ─── Layout ────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w);
  background: var(--hijau);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}
#sidebar.hidden { transform: translateX(-100%); }
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s;
}
#main-content.full { margin-left: 0; }

/* ─── Sidebar ───────────────────────────────── */
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-header .logo { font-size: 18px; font-weight: 700; line-height: 1.3; }
.sidebar-header .sub  { font-size: 11px; opacity: 0.75; margin-top: 2px; }
nav { flex: 1; padding: 8px 0; overflow-y: auto; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
nav a:hover, nav a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
nav a .icon { font-size: 18px; width: 22px; text-align: center; }
nav .nav-section {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: rgba(255,255,255,0.45);
  padding: 12px 18px 4px;
  text-transform: uppercase;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 12px;
}
.sidebar-footer .user-info { opacity: 0.8; margin-bottom: 6px; }
#btn-logout {
  background: rgba(255,255,255,0.15);
  border: none; color: #fff;
  padding: 6px 12px; border-radius: 4px;
  cursor: pointer; width: 100%; font-size: 13px;
}
#btn-logout:hover { background: rgba(255,255,255,0.3); }

/* ─── Topbar ────────────────────────────────── */
#topbar {
  background: var(--putih);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  position: sticky; top: 0; z-index: 50;
}
#topbar h1 { font-size: 17px; font-weight: 600; flex: 1; }
#btn-menu {
  background: none; border: none; font-size: 22px;
  cursor: pointer; display: none; padding: 2px 6px;
}

/* ─── Page ──────────────────────────────────── */
.page { padding: 20px; display: none; }
.page.active { display: block; }

/* ─── Cards / Stats ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--putih);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .label { font-size: 11px; color: var(--abu); font-weight: 600; text-transform: uppercase; }
.stat-card .value { font-size: 22px; font-weight: 700; color: var(--hijau); }
.stat-card .sub   { font-size: 11px; color: var(--abu); }

/* ─── Card container ────────────────────────── */
.card {
  background: var(--putih);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 18px; }

/* ─── Tombol ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 5px; font-size: 13px;
  cursor: pointer; border: none; font-weight: 500;
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn-primary   { background: var(--hijau); color: #fff; }
.btn-secondary { background: var(--abu-muda); color: var(--teks); border: 1px solid #ddd; }
.btn-danger    { background: var(--merah); color: #fff; }
.btn-warning   { background: var(--kuning); color: #fff; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-icon      { padding: 5px 8px; }

/* ─── Tabel ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--hijau-pale);
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--hijau);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f0f0f0; transition: background 0.1s; }
tbody tr:hover { background: #fafafa; }
tbody td { padding: 9px 12px; vertical-align: middle; }
.td-actions { white-space: nowrap; display: flex; gap: 4px; }

/* ─── Badge ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: #c8e6c9; color: #2e7d32; }
.badge-red    { background: #ffcdd2; color: #c62828; }
.badge-yellow { background: #fff9c4; color: #f57f17; }
.badge-blue   { background: #bbdefb; color: #1565c0; }
.badge-grey   { background: #e0e0e0; color: #616161; }

/* ─── Form / Modal ──────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--putih);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 94%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--abu); }
.modal-body { padding: 16px 18px; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #eee;
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--abu); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid #ccc; border-radius: 5px;
  font-size: 13px; font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--hijau-muda);
}

/* ─── Login ─────────────────────────────────── */
#login-screen {
  display: none;
  position: fixed; inset: 0;
  background: var(--hijau);
  z-index: 999;
  align-items: center; justify-content: center;
}
#login-screen.show { display: flex; }
.login-box {
  background: var(--putih);
  border-radius: 12px;
  padding: 36px 32px;
  width: 94%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}
.login-box .logo { font-size: 22px; font-weight: 700; color: var(--hijau); margin-bottom: 4px; }
.login-box .sub  { font-size: 12px; color: var(--abu); margin-bottom: 24px; }
.login-box .form-group label { text-align: left; }
.login-err { color: var(--merah); font-size: 12px; margin-top: -8px; margin-bottom: 10px; }
#btn-login { width: 100%; padding: 10px; font-size: 15px; border-radius: 6px; }

/* ─── Checklist Iuran ───────────────────────── */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.check-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid #ddd; border-radius: 6px;
  cursor: pointer; transition: background 0.1s;
}
.check-item.lunas { background: #e8f5e9; border-color: #a5d6a7; }
.check-item input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.check-item .nama { font-size: 13px; flex: 1; }
.check-item .status { font-size: 11px; }

/* ─── Info pinjaman ─────────────────────────── */
.info-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row .lbl { color: var(--abu); }
.info-row .val { font-weight: 600; }

/* ─── Progress bar ──────────────────────────── */
.progress-wrap { background: #e0e0e0; border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar  { height: 100%; background: var(--hijau-muda); border-radius: 20px; transition: width 0.4s; }

/* ─── Toast ─────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #323232; color: #fff;
  padding: 10px 16px; border-radius: 6px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}
.toast.success { background: var(--hijau); }
.toast.error   { background: var(--merah); }
@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 700px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
  #btn-menu { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Nomor format rupiah ───────────────────── */
.rp::before { content: 'Rp '; font-weight: 400; }

/* ─── Empty state ───────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--abu);
}
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }

/* ─── Tabs ──────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
  padding: 7px 16px; border-radius: 5px; font-size: 13px;
  background: var(--abu-muda); border: 1px solid #ddd;
  cursor: pointer; font-weight: 500;
}
.tab-btn.active { background: var(--hijau); color: #fff; border-color: var(--hijau); }

/* ─── Filter bar ────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar input, .filter-bar select {
  padding: 7px 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 13px;
}
