/* =========================================================
   SIM SARPRAS MADRASAH
   Palet: hijau tua khas institusi pendidikan Islam + emas pupus
   sebagai aksen, di atas latar netral hangat. Tipografi tunggal
   (Plus Jakarta Sans) dengan skala berat yang jelas.
========================================================= */

:root {
  --ink: #1B211C;
  --ink-soft: #566056;
  --line: #DDD9CE;
  --surface: #FFFFFF;
  --bg: #F6F4EE;
  --deep: #163C2C;      /* hijau tua utama */
  --deep-2: #0E2A1E;    /* hijau lebih gelap, untuk sidebar */
  --gold: #B08A2E;      /* aksen emas pupus, dipakai terbatas */
  --gold-soft: #F3E9CE;
  --ok: #2F7D4F;
  --warn: #B7791F;
  --bad: #B33A3A;
  --ok-bg: #E7F3EB;
  --warn-bg: #FBF0DE;
  --bad-bg: #FAEAE8;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(14, 42, 30, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--deep-2);
  color: #EFEDE3;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px 8px;
  border-bottom: 1px solid rgba(239,237,227,0.12);
  margin-bottom: 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(160deg, var(--gold) 0%, #8C6C1E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--deep-2);
  font-size: 15px;
  flex-shrink: 0;
}

.brand-text { line-height: 1.25; }
.brand-text strong { display: block; font-size: 14.5px; font-weight: 700; color: #fff; }
.brand-text span { font-size: 11.5px; color: #B9C4B9; }

.nav-group-label {
  font-size: 11px;
  color: #7E9186;
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 13.8px;
  font-weight: 500;
  color: #D7DED6;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.nav-link:hover { background: rgba(239,237,227,0.08); color: #fff; }

.nav-link.active {
  background: rgba(176, 138, 46, 0.18);
  color: #F3E9CE;
}
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(239,237,227,0.12);
  font-size: 12px;
  color: #7E9186;
}

/* ---------- Main ---------- */
.main {
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar .subtitle {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.user-chip .meta { line-height: 1.2; }
.user-chip .meta strong { display: block; font-size: 13.5px; }
.user-chip .meta span { font-size: 11.5px; color: var(--ink-soft); }

.content { padding: 26px 28px 48px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}

.card-pad { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; }

/* ---------- Stat cards (bar aksen kiri, bukan shadow seragam) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--deep);
  border-radius: var(--radius-s);
  padding: 16px 18px;
}

.stat-card.accent-gold { border-left-color: var(--gold); }
.stat-card.accent-ok { border-left-color: var(--ok); }
.stat-card.accent-bad { border-left-color: var(--bad); }

.stat-card .label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-card .foot { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-s);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.12s ease, background 0.12s ease;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--deep); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { filter: brightness(1.08); }

.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { background: #F1EFE7; }

.btn-danger-outline { background: transparent; border-color: #E7C6C1; color: var(--bad); }
.btn-danger-outline:hover { background: var(--bad-bg); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

/* ---------- Forms ---------- */
.form-label {
  display: block;
  font-size: 12.8px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.form-label .req { color: var(--bad); }

.form-control, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font-size: 13.8px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--deep);
  box-shadow: 0 0 0 3px rgba(22, 60, 44, 0.12);
}

.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11.8px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
  text-align: left;
  padding: 11px 14px;
  background: #F1EFE7;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #FBFAF6; }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Badge / kondisi ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11.8px;
  font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #FBFAF6;
}
.filter-field { min-width: 160px; }
.filter-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.filter-field.grow { flex: 1; min-width: 220px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 20px; }
.tab-btn {
  padding: 13px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-left: none; border-right: none; border-top: none;
}
.tab-btn.active { color: var(--deep); border-bottom-color: var(--deep); }

/* ---------- Modal ---------- */
.modal-backdrop-custom {
  position: fixed; inset: 0; background: rgba(14, 42, 30, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop-custom.show { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-m); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(14,42,30,0.25);
}
.modal-box-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-box-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; background: none; border: none; font-size: 20px; color: var(--ink-soft); line-height: 1; }
.modal-box-body { padding: 22px; }
.modal-box-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-soft); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { margin: 0 0 4px; font-size: 13.8px; }
.empty-state small { font-size: 12px; }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-visual {
  background: var(--deep-2);
  color: #EFEDE3;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-visual::after {
  content: '';
  position: absolute;
  right: -80px; bottom: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(176,138,46,0.25) 0%, transparent 70%);
}
.login-visual h1 { font-size: 30px; line-height: 1.3; max-width: 380px; font-weight: 700; }
.login-visual .quote { font-size: 13.5px; color: #B9C4B9; max-width: 360px; }
.login-form-side {
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-card p.sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 26px; }
.login-error {
  background: var(--bad-bg); color: var(--bad); font-size: 13px; padding: 10px 14px;
  border-radius: var(--radius-s); margin-bottom: 16px;
}

/* ---------- Mobile menu toggle ---------- */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
}
.menu-toggle svg { width: 19px; height: 19px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 42, 30, 0.45);
  z-index: 39;
}
.sidebar-overlay.show { display: block; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: #EFEDE3;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 264px;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 40px rgba(14,42,30,0.25);
  }
  .sidebar-close { display: block; }

  .menu-toggle { display: flex; }

  .topbar { padding: 14px 16px; gap: 12px; }
  .topbar h1 { font-size: 16.5px; }
  .topbar .subtitle { display: none; }
  .user-chip .meta { display: none; }

  .content { padding: 18px 16px 40px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }

  div[style*="grid-template-columns: 1.1fr 1fr"] { grid-template-columns: 1fr !important; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-field, .filter-field.grow { min-width: 0; width: 100%; }
  .toolbar-actions { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- Autocomplete dropdown (katalog barang) ---------- */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: 0 10px 24px rgba(14, 42, 30, 0.14);
  max-height: 240px;
  overflow-y: auto;
  z-index: 60;
  display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
  padding: 10px 12px;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #F1EFE7; }
.autocomplete-item .cat-tag {
  font-size: 10.5px;
  color: var(--ink-soft);
  background: #F1EFE7;
  padding: 2px 9px;
  border-radius: 100px;
  flex-shrink: 0;
  white-space: nowrap;
}
.autocomplete-empty { padding: 12px; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- User dropdown (topbar) ---------- */
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: 0 14px 30px rgba(14, 42, 30, 0.16);
  min-width: 190px;
  z-index: 70;
  overflow: hidden;
  display: none;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  font-size: 13.3px;
  color: var(--ink);
}
.user-dropdown a:hover { background: #F1EFE7; }
.user-dropdown-divider { height: 1px; background: var(--line); margin: 0; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.mb-0 { margin-bottom: 0; }
.text-soft { color: var(--ink-soft); }
.mt-16 { margin-top: 16px; }

.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--deep); color: #fff; padding: 12px 18px; border-radius: var(--radius-s);
  font-size: 13.5px; box-shadow: 0 10px 24px rgba(14,42,30,0.25); animation: toast-in 0.2s ease;
}
.toast.error { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
