:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-strong: #1e40af;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --sidebar: #1e3a8a;
  --sidebar-2: #1d4ed8;
  --shadow: 0 4px 24px rgb(15 23 42 / 0.06);
  --radius: 10px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Inter", "Segoe UI", sans-serif;
  --display: "Poppins", "Inter", sans-serif;
  --blue: #1d4ed8;
  --red: #dc2626;
  --yellow: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 10% -10%, rgb(29 78 216 / 0.12), transparent 60%),
    radial-gradient(700px 360px at 100% 0%, rgb(220 38 38 / 0.08), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 50%, #fef3c7 100%);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: var(--accent); }
.admin-app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #eef7fb;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 16px;
}
.sidebar-brand img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
}
.sidebar-brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.sidebar-brand span {
  display: block;
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}
.role-pill {
  display: inline-flex;
  margin: 0 8px 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
  margin: 14px 8px 8px;
  font-weight: 700;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.84);
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 4px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active {
  background: #fff;
  color: var(--sidebar);
}
.sidebar-foot {
  margin-top: 24px;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.sidebar-foot a {
  display: block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-weight: 650;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
}
.sidebar-foot a:hover { background: rgba(255,255,255,0.08); color: #fff; }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.wrap {
  padding: 22px 24px 40px;
  max-width: 1280px;
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  letter-spacing: -0.02em;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card .value {
  font-family: var(--display);
  font-size: 32px;
  margin-top: 8px;
  letter-spacing: -0.03em;
}
.stat-card .meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

label { display: block; margin: 10px 0 4px; font-weight: 700; font-size: 13px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(14, 111, 143, 0.25);
  border-color: var(--accent);
}
button, .actions a, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  padding: 9px 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
button:hover, .btn:hover, .actions a:hover { background: var(--accent-strong); }
button.danger, .btn-danger { background: var(--danger-soft); color: var(--danger); }
button.danger:hover { background: #f3d0cb; }
button.ok { background: var(--ok-soft); color: var(--ok); }
button.muted-btn, .btn-ghost {
  background: var(--bg-soft);
  color: var(--muted);
}
.btn-ghost { margin-top: 0; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f8fbfc;
}
tr:hover td { background: #f9fcfd; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 6px;
}

.flash {
  background: var(--ok-soft);
  color: var(--ok);
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid #c9ebcf;
  font-weight: 650;
}
.flash.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efc5bf;
}
.hint { color: var(--muted); font-size: 14px; line-height: 1.45; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 650; color: var(--text); }

.filters { padding: 14px 16px; }
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filters-row input,
.filters-row select { width: auto; min-width: 140px; flex: 1; margin: 0; }
.button-link {
  display: inline-flex;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent) !important;
  font-weight: 750;
  text-decoration: none;
}
.inline-form, .inline-edit {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 4px 0;
}
.inline-edit input, .inline-edit select { width: auto; margin: 0; }
.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.plain-list { padding-left: 18px; }
.plain-list li { margin: 6px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions form { margin: 0; }
.actions button, .actions a { margin-top: 0; }

.perm-matrix {
  width: 100%;
}
.perm-matrix td:nth-child(2),
.perm-matrix td:nth-child(3) { text-align: center; font-weight: 750; }
.yes { color: var(--ok); }
.no { color: var(--danger); }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}
.badge-admin { background: #e8f0ff; color: #234a9a; }
.badge-teacher { background: var(--accent-soft); color: var(--accent); }
.badge-student { background: #eef4e8; color: #3d6b28; }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(145deg, rgba(29, 78, 216, 0.88), rgba(220, 38, 38, 0.72)),
    url("../ASSETS/17862735135936.png") center/cover;
}
.login-card {
  width: min(440px, 94vw);
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  border: 0;
}
.login-card h1 {
  font-family: var(--display);
  margin: 0 0 8px;
  font-size: 30px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.login-brand img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #fff;
}
.access-note {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  text-align: center;
  padding: 36px 18px;
  color: var(--muted);
}
.empty-state-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}
.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--display);
}
.empty-state p {
  margin: 0 auto 16px;
  max-width: 420px;
  line-height: 1.5;
}
.empty-state-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.empty-state-actions .btn { margin-top: 0; }

.bulk-card { margin-bottom: 16px; }
.bulk-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.bulk-head h2 { margin-bottom: 4px; }
.bulk-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.bulk-controls select { width: auto; min-width: 200px; margin: 0; }
.bulk-controls button { margin-top: 0; }

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
}
.toast {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(12, 61, 82, 0.18);
  animation: toast-in 0.22s ease;
  font-weight: 650;
  font-size: 14px;
  line-height: 1.4;
}
.toast--ok {
  background: #123526;
  color: #e8fff0;
  border: 1px solid #2f7a4a;
}
.toast--error {
  background: #4a1512;
  color: #ffe8e6;
  border: 1px solid #a84a42;
}
.toast-close {
  margin: 0;
  padding: 0 4px;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  border: 0;
  cursor: pointer;
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: 0.2s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.nav-toggle,
.nav-close {
  display: none;
  border: 0;
  background: var(--bg-soft);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
.nav-close {
  margin-left: auto;
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-backdrop {
  display: none;
}
body.nav-locked { overflow: hidden; }

@media (max-width: 980px) {
  .admin-app { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-grid; place-items: center; }
  .nav-close { display: inline-grid; place-items: center; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    height: 100vh;
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .admin-app.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 18px 0 40px rgba(8, 30, 42, 0.28);
  }
  .sidebar-backdrop[hidden] { display: none !important; }
  .admin-app.sidebar-open + .sidebar-backdrop,
  .admin-app.sidebar-open ~ .sidebar-backdrop,
  body:has(.admin-app.sidebar-open) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 30, 42, 0.45);
    z-index: 50;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 30, 42, 0.45);
    z-index: 50;
    border: 0;
  }
  body:has(.admin-app.sidebar-open) .sidebar-backdrop,
  .sidebar-backdrop.is-visible {
    display: block;
  }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .workspace-head, .bulk-head { flex-direction: column; align-items: stretch; }
  .topbar { flex-direction: row; align-items: flex-start; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.subtab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
  line-height: 1.2;
}
.subtab:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.subtab.active {
  background: var(--accent);
  color: #fff;
}
.subtab.active:hover {
  background: var(--accent-strong);
  color: #fff;
}
.desk-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table {
  min-width: 560px;
}

/* Mobile readability pass — larger controls without changing dashboard grids. */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    font-size: 15px;
    line-height: 1.5;
  }

  .admin-app {
    font-size: 15px;
  }

  .topbar h1 {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
  }

  .topbar p,
  .hint,
  label {
    font-size: 14px;
  }

  input,
  textarea,
  select,
  button,
  .btn {
    font-size: 15px !important;
    min-height: 42px;
  }

  .subtab,
  .desk-tabs button {
    font-size: 14px;
  }

  table {
    font-size: 14px;
  }

  th {
    font-size: 13px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

