/* ==========================================================================
   StudentHub — stylesheet
   Tokens → base → layout → components → pages → responsive
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f3f4f8;
  --border: #e6e8ef;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;
  --on-primary: #ffffff;

  --success: #079455;
  --success-soft: #ecfdf3;
  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: #fef3f2;
  --danger-text: #b42318;
  --info: #0086c9;
  --info-soft: #f0f9ff;

  --mark: #fef08a;
  --mark-text: #101828;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.22);
  --ring: 0 0 0 4px rgb(79 70 229 / 0.16);
  --ring-danger: 0 0 0 4px rgb(217 45 32 / 0.14);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-h: 64px;
  --gutter: 24px;

  /* Tones: avatars, stat icons */
  --indigo-bg: #eef2ff;  --indigo-fg: #4338ca;
  --emerald-bg: #ecfdf3; --emerald-fg: #067647;
  --amber-bg: #fffaeb;   --amber-fg: #b54708;
  --rose-bg: #fff1f3;    --rose-fg: #c01048;
  --sky-bg: #f0f9ff;     --sky-fg: #026aa2;
  --violet-bg: #f4f3ff;  --violet-fg: #5925dc;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #121826;
    --surface-2: #0f1522;
    --surface-hover: #1a2233;
    --border: #232c3d;
    --border-strong: #344054;
    --text: #f2f4f7;
    --text-2: #cdd3dd;
    --text-3: #98a2b3;

    --primary: #6366f1;
    --primary-hover: #7c7ff5;
    --primary-soft: rgb(99 102 241 / 0.16);
    --primary-text: #a5b4fc;

    --success: #32d583;
    --success-soft: rgb(50 213 131 / 0.12);
    --danger: #e5484d;
    --danger-hover: #f16a6e;
    --danger-soft: rgb(229 72 77 / 0.14);
    --danger-text: #fda29b;
    --info: #36bffa;
    --info-soft: rgb(54 191 250 / 0.12);

    --mark: rgb(250 204 21 / 0.35);
    --mark-text: #fef9c3;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.6);
    --ring: 0 0 0 4px rgb(99 102 241 / 0.3);

    --indigo-bg: rgb(99 102 241 / 0.16);  --indigo-fg: #a5b4fc;
    --emerald-bg: rgb(16 185 129 / 0.15); --emerald-fg: #6ee7b7;
    --amber-bg: rgb(245 158 11 / 0.15);   --amber-fg: #fcd34d;
    --rose-bg: rgb(244 63 94 / 0.15);     --rose-fg: #fda4af;
    --sky-bg: rgb(14 165 233 / 0.15);     --sky-fg: #7dd3fc;
    --violet-bg: rgb(139 92 246 / 0.16);  --violet-fg: #c4b5fd;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input { font: inherit; color: inherit; }
mark { background: var(--mark); color: var(--mark-text); border-radius: 3px; padding: 0 1px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.text-muted { color: var(--text-3); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.main { flex: 1; padding-block: 32px 56px; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 4px 12px -2px rgb(99 102 241 / 0.45);
}
.brand__mark .icon { width: 20px; height: 20px; }

.navbar__menu { display: flex; align-items: center; gap: 4px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  transition: background-color .15s, color .15s;
}
.nav-link .icon { width: 17px; height: 17px; }
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary-text); }

.navbar__cta { margin-left: 8px; }

.navbar__toggle {
  display: none;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }

.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-hover); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn--secondary:hover { background: var(--surface-hover); }

.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn--danger:hover { background: var(--danger-hover); }

.btn--danger-soft { background: var(--danger-soft); color: var(--danger-text); }
.btn--danger-soft:hover { background: var(--danger); color: #fff; }

.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); gap: 6px; }
.btn--sm .icon { width: 15px; height: 15px; }
.btn--block { width: 100%; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.link-arrow .icon { width: 16px; height: 16px; transition: transform .15s; }
.link-arrow:hover { text-decoration: none; }
.link-arrow:hover .icon { transform: translateX(3px); }

.muted-link { color: var(--text-2); }
.muted-link:hover { color: var(--primary-text); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
}
.back-link .icon { width: 16px; height: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.page-title { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { margin-top: 6px; color: var(--text-3); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 16px; font-weight: 650; }
.card__subtitle { margin-top: 2px; font-size: 13px; color: var(--text-3); }

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat-card__label { color: var(--text-2); font-size: 14px; font-weight: 500; }
.stat-card__icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--tone-bg);
  color: var(--tone-fg);
}
.stat-card__icon .icon { width: 20px; height: 20px; }
.stat-card__value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card__hint { margin-top: 6px; color: var(--text-3); font-size: 13px; }

/* ---------- Tones ---------- */
.tone-indigo  { --tone-bg: var(--indigo-bg);  --tone-fg: var(--indigo-fg); }
.tone-emerald { --tone-bg: var(--emerald-bg); --tone-fg: var(--emerald-fg); }
.tone-amber   { --tone-bg: var(--amber-bg);   --tone-fg: var(--amber-fg); }
.tone-rose    { --tone-bg: var(--rose-bg);    --tone-fg: var(--rose-fg); }
.tone-sky     { --tone-bg: var(--sky-bg);     --tone-fg: var(--sky-fg); }
.tone-violet  { --tone-bg: var(--violet-bg);  --tone-fg: var(--violet-fg); }

/* ---------- Avatar & badge ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--tone-bg);
  color: var(--tone-fg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.recent-list { list-style: none; margin: 0; padding: 6px 0; }

.recent-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
}
.recent-item + .recent-item { border-top: 1px solid var(--border); }
.recent-item:hover { background: var(--surface-2); }

.recent-item__main { display: flex; flex-direction: column; min-width: 0; }
.recent-item__name { color: var(--text); font-weight: 600; font-size: 14.5px; }
.recent-item__email,
.recent-item__time { color: var(--text-3); font-size: 13px; }
.recent-item__email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item__time { white-space: nowrap; min-width: 84px; text-align: right; }
.recent-item__course { max-width: 190px; }

.bar-list { list-style: none; margin: 0; padding: 18px 22px 22px; display: grid; gap: 18px; }
.bar-list__row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 14px; }
.bar-list__label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list__value { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-list__track { height: 8px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.bar-list__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

/* ---------- Toolbar & search ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar__meta { color: var(--text-3); font-size: 14px; }
.toolbar__meta strong { color: var(--text); font-weight: 600; }

.search { display: flex; flex: 1 1 420px; max-width: 560px; gap: 8px; }
.search__field { position: relative; flex: 1; min-width: 0; }
.search__icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.input.search__input { padding-left: 40px; padding-right: 38px; }
.search__input::-webkit-search-cancel-button { display: none; }
.search__kbd {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-3);
  font: 12px/1.5 var(--mono);
  pointer-events: none;
}
.search__input:focus + .search__kbd,
.search__input:not(:placeholder-shown) + .search__kbd { display: none; }

/* ---------- Forms ---------- */
.input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); opacity: .8; }
.input:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.form-layout { display: grid; gap: 24px; max-width: 760px; align-items: start; }
.form-layout--with-aside { max-width: none; grid-template-columns: minmax(0, 1fr) 320px; }

.form-card { padding: 28px; overflow: visible; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 20px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 14px; font-weight: 600; color: var(--text); }
.field__req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 13px; color: var(--text-3); }
.field__error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger-text);
}
.field__error .icon { width: 15px; height: 15px; }
.field--invalid .input { border-color: var(--danger); }
.field--invalid .input:focus { box-shadow: var(--ring-danger); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.meta-card { padding: 22px; overflow: visible; }
.meta-card__head { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.meta-card__head > div { min-width: 0; }
.meta-card__name { font-weight: 650; }
.meta-card__email { color: var(--text-3); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-list { margin: 0; padding: 16px 0 20px; display: grid; gap: 12px; }
.meta-list > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.meta-list dt { color: var(--text-3); }
.meta-list dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- Alerts (inline) ---------- */
.alert {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.alert > .icon { margin-top: 1px; width: 20px; height: 20px; }
.alert--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger-text); }
.alert__title { font-weight: 600; font-size: 14px; }
.alert__text { font-size: 13.5px; opacity: .9; }

/* ---------- Toasts (flash messages) ---------- */
.toast-stack {
  position: fixed;
  top: calc(var(--nav-h) + 16px);
  right: 24px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(400px, calc(100vw - 32px));
}

.toast {
  --accent: var(--success);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s cubic-bezier(.2, .8, .2, 1);
}
.toast--error { --accent: var(--danger); }
.toast--info { --accent: var(--info); }
.toast.is-leaving { animation: toast-out .2s ease forwards; }

.toast__icon { color: var(--accent); padding-top: 1px; }
.toast__icon .icon { width: 20px; height: 20px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 650; font-size: 14px; }
.toast__text { color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.toast__close {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  margin: -4px -4px 0 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.toast__close:hover { background: var(--surface-hover); color: var(--text); }
.toast__close .icon { width: 16px; height: 16px; }

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 11px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

.table .col-sn { width: 72px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.table .col-num { font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }

.person { display: flex; align-items: center; gap: 12px; }
.person__name { font-weight: 600; color: var(--text); }

.row-actions { display: inline-flex; gap: 8px; }
.row-actions form { margin: 0; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.pagination__meta { color: var(--text-3); font-size: 14px; }
.pagination__pages { display: flex; align-items: center; gap: 4px; }

.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 36px; height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.page-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.page-btn.is-current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.page-btn.is-disabled { opacity: .45; }
.page-btn .icon { width: 16px; height: 16px; }
.page-gap { padding: 0 4px; color: var(--text-3); }

/* ---------- Empty state ---------- */
.empty-state { padding: 56px 24px; text-align: center; }
.empty-state__icon {
  display: inline-grid;
  place-items: center;
  width: 56px; height: 56px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary-soft) 45%, transparent);
}
.empty-state__icon .icon { width: 26px; height: 26px; }
.empty-state__title { font-size: 16px; font-weight: 650; }
.empty-state__text { margin: 6px auto 0; max-width: 360px; color: var(--text-3); font-size: 14px; }
.empty-state__actions { margin-top: 20px; display: flex; justify-content: center; gap: 10px; }

/* ---------- Modal ---------- */
.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in .2s cubic-bezier(.2, .8, .2, 1); }
.modal::backdrop { background: rgb(15 23 42 / 0.55); backdrop-filter: blur(2px); }

.modal__panel { padding: 24px; }
.modal__body { display: flex; gap: 16px; }
.modal__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger-text);
}
.modal__icon .icon { width: 22px; height: 22px; }
.modal__title { font-size: 17px; font-weight: 650; margin-bottom: 6px; }
.modal__text { color: var(--text-2); font-size: 14.5px; }
.modal__text strong { color: var(--text); }
.modal__footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- Error page ---------- */
.error-page { padding: 72px 0; text-align: center; }
.error-page__code {
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.error-page__title { margin-top: 16px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.error-page__text { margin: 10px auto 0; max-width: 460px; color: var(--text-3); }
.error-page__actions { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding-block: 20px; color: var(--text-3); font-size: 13px; }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .dashboard-grid,
  .form-layout--with-aside { grid-template-columns: minmax(0, 1fr); }
  .meta-card { max-width: 760px; }
}

@media (max-width: 768px) {
  :root { --gutter: 16px; }

  .main { padding-block: 24px 40px; }
  .page-title { font-size: 24px; }
  .page-header { margin-bottom: 20px; }
  .page-actions, .page-actions .btn { flex: 1 1 auto; }

  /* Collapsible nav */
  .navbar__toggle { display: grid; }
  .navbar__menu {
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px var(--gutter) 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .navbar__menu.is-open { display: flex; }
  .nav-link { height: 44px; }
  .navbar__cta { margin: 8px 0 0; height: 44px; }

  .toast-stack { right: 16px; }

  .search { flex-basis: 100%; max-width: none; }
  .search__kbd { display: none; }

  .form-card { padding: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { flex: 1; }

  .recent-item { grid-template-columns: auto minmax(0, 1fr) auto; padding: 12px 16px; }
  .recent-item__course { display: none; }

  /* Table → stacked cards */
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody { padding: 12px; display: grid; gap: 12px; }
  .table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 6px 14px;
  }
  .table tbody tr:hover { background: var(--surface); }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .table tbody tr:last-child td { border-bottom: 1px dashed var(--border); }
  .table td::before {
    content: attr(data-label);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
    flex-shrink: 0;
  }
  .table .col-sn, .table .col-actions { width: 100%; }
  .table td.col-actions { border-bottom: 0 !important; padding-top: 12px; }
  .table td.col-actions::before { content: none; }
  .row-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .row-actions .btn { width: 100%; }

  .pagination { justify-content: center; }
  .pagination__meta { width: 100%; text-align: center; }
}

@media (max-width: 420px) {
  .modal__body { flex-direction: column; }
  .modal__footer .btn { flex: 1; }
  .error-page__code { font-size: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
