:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --teal: #0d9488;
  --green: #16a34a;
  --blue: #0284c7;
  --red: #dc2626;
  --amber: #d97706;
  --violet: #7c3aed;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 30px -12px rgba(15, 23, 42, .2);
  --radius: 14px;
  --radius-sm: 9px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ================= LOGIN ================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 55%, #0ea5e9 120%);
  padding: 24px;
}
.login-wrap::before, .login-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
}
.login-wrap::before { width: 420px; height: 420px; background: #22d3ee; top: -120px; right: -80px; }
.login-wrap::after { width: 380px; height: 380px; background: #f59e0b; bottom: -140px; left: -100px; }
.login-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
}
.login-logo svg { width: 32px; height: 32px; fill: #fff; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 2px; }
.login-card .sub { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 24px; }

/* ================= LAYOUT ================= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}
.brand-icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg { width: 22px; height: 22px; fill: #fff; }
.sidebar .brand .brand-text { line-height: 1.25; }
.sidebar .brand .brand-text b { display: block; color: #fff; font-size: 14px; }
.sidebar .brand .brand-text span { font-size: 11px; color: #94a3b8; }

.sidebar nav { flex: 1; padding: 10px 0 10px; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(79, 70, 229, .25), rgba(79, 70, 229, .05));
  color: #fff;
  border-left-color: #818cf8;
  font-weight: 600;
}
.sidebar nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; flex-shrink: 0; }
.sidebar nav .group {
  padding: 16px 18px 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #64748b;
}

.sidebar .user-box {
  padding: 14px 18px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  display: flex;
  align-items: center;
  gap: 11px;
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #22d3ee);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar .user-box .name { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; }
.sidebar .user-box .role { color: #94a3b8; font-size: 11px; }
.sidebar .logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  color: #fca5a5;
  border-top: 1px solid rgba(148, 163, 184, .12);
  font-size: 14px;
}
.sidebar .logout svg { width: 18px; height: 18px; fill: currentColor; }
.sidebar .logout:hover { background: var(--sidebar-hover); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .title { font-size: 19px; font-weight: 800; }
.topbar .title small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.school-chip {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
}

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

/* ================= CARDS & GRID ================= */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 210px; }
}
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.menu-toggle svg { width: 22px; height: 22px; fill: var(--text); }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease;
  z-index: 25;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 248px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .title { font-size: 16px; }
  .topbar .right { gap: 8px; }
  .school-chip { display: none; }
}
@media (max-width: 480px) {
  .topbar .right span:not(.school-chip) { display: none; }
  .form-row > div { min-width: 100%; }
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, .6);
}
.card h3 { font-size: 15px; font-weight: 700; }
.card > h3:first-child { margin-bottom: 4px; }

.stat { display: flex; align-items: center; gap: 16px; padding: 18px 20px; }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; fill: #fff; }
.stat-icon.teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-icon.green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-icon.blue { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.stat-icon.red { background: linear-gradient(135deg, #f87171, #dc2626); }
.stat-icon.indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); }
.stat-icon.amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-icon.violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 2px; letter-spacing: -.3px; }
.stat .value.small { font-size: 15px; line-height: 1.4; }

/* ================= TABLES ================= */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
table.data th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover td { background: #f8fafc; }
table.data tfoot td { background: #f8fafc; font-weight: 700; }
.card > .table-wrap:not(:first-child) { margin-top: 14px; }

/* ================= FORMS ================= */
.form-card { max-width: 760px; }
.form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.form-row > div { flex: 1; min-width: 180px; }
label { display: block; font-size: 12px; color: #475569; margin-bottom: 6px; font-weight: 700; }
label.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #1e293b; font-weight: 500; margin: 8px 0; cursor: pointer; }
label.checkbox input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary, #2563eb); margin: 0; }
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="month"], input[type="file"], select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #eef2f7;
  color: #334155;
  transition: filter .15s, transform .05s, background .15s;
  line-height: 1.2;
}
.btn svg { width: 15px; height: 15px; fill: currentColor; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { background: var(--red); color: #fff; }
.btn-warning { background: var(--amber); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ================= TOAST / FLASH ================= */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 11px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid #94a3b8;
  font-size: 13px;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.success { border-left-color: var(--green); }
.toast.danger { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--amber); }
.toast.info { border-left-color: var(--blue); }
.toast-icon { flex-shrink: 0; width: 22px; height: 22px; }
.toast.success .toast-icon { fill: var(--green); }
.toast.danger .toast-icon { fill: var(--red); }
.toast.warning .toast-icon { fill: var(--amber); }
.toast.info .toast-icon { fill: var(--blue); }
.toast .close { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }

/* ================= MISC ================= */
.saldo-big { font-size: 26px; font-weight: 800; color: var(--teal); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-setor { background: #dcfce7; color: #166534; }
.badge-tarik { background: #fee2e2; color: #991b1b; }
.badge-aktif { background: #dcfce7; color: #166534; }
.badge-nonaktif { background: #f1f5f9; color: #64748b; }
.badge-role { background: var(--primary-soft); color: var(--primary-dark); }
.muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-24 { margin-bottom: 24px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .spacer { flex: 1; }

.chart-box { position: relative; height: 290px; }

/* ================= SEARCH COMBOBOX ================= */
.search-combo { position: relative; }
.search-combo input[type="text"].selected { border-color: var(--green); background: #f0fdf4; }
.search-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.search-list li {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.search-list li:last-child { border-bottom: none; }
.search-list li:hover { background: var(--primary-soft); }
.search-list li.no-match { cursor: default; color: var(--muted); }

/* pagination */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--border);
  color: #334155;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .cur { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pagination .info { border: none; background: none; color: var(--muted); }

/* action icon buttons */
.act { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; }
.act:hover { background: var(--primary-soft); }
.act svg { width: 16px; height: 16px; fill: var(--primary); }
.act.danger:hover { background: #fee2e2; }
.act.danger svg { fill: var(--red); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty svg { width: 48px; height: 48px; fill: #cbd5e1; margin-bottom: 10px; }

/* responsive table with row cards on mobile kept simple */
@media (max-width: 760px) {
  .content { padding: 18px 14px 30px; }
  .topbar { padding: 12px 16px; }
}
