:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --card-soft: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #06b6d4;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 55%, #06b6d4 100%);
  padding: 20px;
}
.login-card {
  background: #fff; width: 100%; max-width: 400px; border-radius: 18px;
  padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { margin: 12px 0 4px; font-size: 22px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary);
  color: #fff; font-weight: 800; font-size: 26px; display: flex;
  align-items: center; justify-content: center; margin: 0 auto;
}
.logo.small { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; margin: 0; }
.login-card form label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px;
}
.demo-hint {
  margin-top: 18px; padding: 12px; background: var(--card-soft); border-radius: 10px;
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
}

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg); color: #cbd5e1; display: flex;
  flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: #fff; font-weight: 700; }
nav { flex: 1; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px;
  cursor: pointer; color: #cbd5e1; font-size: 14.5px; margin-bottom: 3px;
  transition: background .15s;
}
.nav-item:hover { background: var(--bg-soft); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ico { width: 20px; text-align: center; }
.side-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
#side-user { font-size: 13.5px; margin-bottom: 10px; color: #e2e8f0; }
#side-user .muted { color: #94a3b8; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; padding: 16px 28px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.content { padding: 26px 28px; max-width: 1200px; width: 100%; }

/* ===== CARDS / GRID ===== */
.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.charts { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 15.5px; }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon.i1 { background: #eef2ff; }
.stat-icon.i2 { background: #ecfeff; }
.stat-icon.i3 { background: #ecfdf5; }
.stat-icon.i4 { background: #fff7ed; }
.stat-val { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #f8fafc; }
.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.baru { background: #eef2ff; color: var(--primary); }
.badge.terdaftar { background: #ecfdf5; color: var(--success); }
.badge.followup { background: #fff7ed; color: var(--warning); }
.badge.admin { background: #fdf2f8; color: #db2777; }
.badge.staff { background: #ecfeff; color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
  border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .05s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: #cbd5e1; border: 1px solid rgba(255,255,255,.15); }
.btn-ghost:hover { background: var(--bg-soft); color: #fff; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 4px 7px; border-radius: 8px; }
.icon-btn:hover { background: #e2e8f0; color: var(--text); }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

/* ===== FORMS / MODAL ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.modal-card {
  position: relative; background: #fff; border-radius: 16px; width: 100%;
  max-width: 520px; max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
#modal-form { padding: 20px 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14.5px; font-family: inherit;
}
.field textarea { min-height: 76px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ===== TOAST / ERROR ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #0f172a; color: #fff;
  padding: 13px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 100;
}
.toast.error { background: var(--danger); }
.error { color: var(--danger); font-size: 13px; margin: 6px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .grid.charts, .grid.three { grid-template-columns: 1fr; }
  .sidebar { width: 70px; }
  .side-brand span, .nav-item span, .side-footer #side-user { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px; }
}
@media (max-width: 560px) {
  .topbar-user div { display: none; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
}
