:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --brand: #0f766e;
  --brand-d: #0b5d56;
  --line: #e2e8f0;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 360px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card label { display: block; margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; }

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 230px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-size: 18px; font-weight: 700; padding: 6px 10px 18px; }
.brand small { color: #5eead4; margin-left: 6px; }
#menu { flex: 1; }
#menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14.5px;
  margin-bottom: 2px;
}
#menu button:hover { background: #1e293b; }
#menu button.active { background: var(--brand); color: #fff; font-weight: 600; }
.side-foot { border-top: 1px solid #1e293b; padding-top: 12px; }
#userBox { padding: 4px 12px 8px; }
#btnLogout { width: 100%; }
#main { flex: 1; padding: 24px; min-width: 0; }
#view { max-width: 980px; margin: 0 auto; }
#view h2 { margin: 0 0 14px; font-size: 20px; }

/* ---------- komponen ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #99f6e4; border-color: var(--brand); }
textarea { min-height: 72px; resize: vertical; }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 13.5px; }
.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 13.5px; }

/* ---------- tabel ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: #f8fafc; }
.tbl .empty td { text-align: center; color: var(--muted); padding: 24px; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge.lunas { background: #dcfce7; color: #15803d; }
.badge.belum { background: #fef3c7; color: #b45309; }
.badge.owner { background: #fee2e2; color: #b91c1c; }
.badge.guru { background: #dbeafe; color: #1d4ed8; }
.badge.ortu { background: #f3e8ff; color: #7e22ce; }
.tag { display: inline-block; background: #f1f5f9; color: #475569; border-radius: 6px; padding: 2px 8px; font-size: 12.5px; margin: 1px 3px 1px 0; }

/* ---------- dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--brand); }
.stat .lbl { font-size: 13px; color: var(--muted); }

/* ---------- statistik page view ---------- */
.pv-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 8px; }
.pv-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.pv-bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #14b8a6, #0f766e); border-radius: 5px 5px 0 0; }
.pv-day { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal-box { width: 100%; max-width: 480px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
video.thumb { width: 96px; height: 64px; object-fit: cover; border-radius: 8px; }

@media (max-width: 720px) {
  #sidebar { width: 64px; padding: 12px 6px; }
  .brand { font-size: 0; padding: 6px 0 14px; }
  .brand::after { content: "📚"; font-size: 20px; }
  #menu button { font-size: 0; text-align: center; padding: 10px 0; }
  #menu button::first-letter { font-size: 16px; }
  #main { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
