/* ==================================================================
   Academy Management System — Design System
   Premium SaaS UI · light/dark · fully responsive
   ================================================================== */

:root {
  --font: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "Noto Sans Arabic", var(--font);

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff4ff;
  --primary-100: #dbe6fe;
  --primary-rgb: 37, 99, 235;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f9;
  --border: #e6eaf2;
  --border-strong: #d5dbe7;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8591a7;

  --side-bg: #0d1633;
  --side-bg-2: #131e42;
  --side-text: #a9b4d0;
  --side-text-hi: #ffffff;
  --side-active: #2563eb;

  --green: #16a34a;  --green-bg: #e8f8ee;
  --red: #dc2626;    --red-bg: #fdecec;
  --amber: #d97706;  --amber-bg: #fef4e2;
  --blue: #2563eb;   --blue-bg: #e8effe;
  --purple: #7c3aed; --purple-bg: #f1eafe;
  --teal: #0d9488;   --teal-bg: #e2f6f4;
  --pink: #db2777;   --pink-bg: #fde8f2;
  --orange: #ea580c; --orange-bg: #fdefe6;
  --gray: #64748b;   --gray-bg: #eef1f6;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 6px 24px -6px rgba(15, 23, 42, .10), 0 2px 6px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);
  --ring: 0 0 0 4px rgba(var(--primary-rgb), .14);

  --side-w: 256px;
  --top-h: 68px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

[data-theme="dark"] {
  --bg: #0a0f1f;
  --surface: #111a2e;
  --surface-2: #0f172a;
  --surface-3: #16213a;
  --border: #1f2a44;
  --border-strong: #2a3756;
  --text: #e8edf7;
  --text-2: #aeb9cf;
  --muted: #74819c;
  --primary-50: #13234a;
  --primary-100: #1a2f5f;
  --side-bg: #080d1c;
  --side-bg-2: #0e1528;
  --green-bg: #0f2a1c; --red-bg: #2e1216; --amber-bg: #2c2010; --blue-bg: #13234a;
  --purple-bg: #231a3f; --teal-bg: #0d2a28; --pink-bg: #2d1223; --orange-bg: #2d1a0f; --gray-bg: #1a2338;
  --shadow: 0 6px 24px -6px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
[dir="rtl"] body { font-family: var(--font-ar); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.25; letter-spacing: -.015em; font-weight: 700; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
[x-cloak] { display: none !important; }
::selection { background: rgba(var(--primary-rgb), .18); }

/* icons (lucide) */
.ic, i[data-lucide] { display: inline-block; width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; vertical-align: middle; }
svg.ic { width: 18px; height: 18px; }
.ic-sm, svg.ic-sm { width: 15px !important; height: 15px !important; }
.ic-lg, svg.ic-lg { width: 22px !important; height: 22px !important; }
.ic-xl, svg.ic-xl { width: 28px !important; height: 28px !important; }

/* ------------------------------------------------------------------
   App shell
   ------------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
/* Fixed shell: sidebar + topbar stay still, only the page area (.main-scroll) scrolls. */
body.shell { overflow: hidden; }
body.shell .app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.shell .main { height: 100%; overflow: hidden; }
body.shell .topbar { position: relative; flex-shrink: 0; }
.main-scroll { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: none; scroll-padding-top: 16px; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; }
.main-scroll > .footer { margin-top: auto; border-top: 1px solid var(--border); }
.main-scroll::-webkit-scrollbar { display: none; width: 0; }

/* Slim, modern scrollbars (no arrow buttons). Chromium/Edge/Safari use ::-webkit-scrollbar, Firefox the standard properties. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .32); border-radius: 99px; border: 2.5px solid transparent; background-clip: padding-box; min-height: 40px; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(100, 116, 139, .55); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background-color: rgba(148, 163, 184, .28); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, .5); }
@supports (-moz-appearance: none) {
  * { scrollbar-width: thin; scrollbar-color: rgba(100, 116, 139, .4) transparent; }
  .sidebar-nav { scrollbar-color: transparent transparent; }
  .sidebar-nav:hover { scrollbar-color: rgba(255, 255, 255, .18) transparent; }
}

/* back-to-top */
.to-top { position: fixed; right: 26px; bottom: 26px; z-index: 45; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer; opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; transition: opacity .2s, transform .2s var(--ease), background .15s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
[dir="rtl"] .to-top { right: auto; left: 26px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60; width: var(--side-w);
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text); display: flex; flex-direction: column;
  transition: transform .28s var(--ease), width .28s var(--ease);
}
[dir="rtl"] .sidebar { inset: 0 0 0 auto; }
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 18px 20px; height: var(--top-h);
  border-bottom: 1px solid rgba(255, 255, 255, .06); color: #fff;
}
.sidebar-brand img, .brand-mark { width: 38px; height: 38px; border-radius: 11px; object-fit: contain; flex-shrink: 0; }
.brand-mark { display: grid; place-items: center; background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 6px 16px -4px rgba(37, 99, 235, .6); }
.brand-mark svg { width: 22px; height: 22px; color: #fff; }
.sidebar-brand .brand-text { min-width: 0; }
.sidebar-brand strong { display: block; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand small { display: block; font-size: 11px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px 24px; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%); mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%); }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background-color: transparent; border-width: 1px; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, .16); }
.nav-section { margin: 18px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #5f6b8c; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9.5px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--side-text); font-weight: 500; font-size: 13.5px; position: relative;
  transition: background .18s, color .18s;
}
.nav-link .ic { width: 18px; height: 18px; opacity: .9; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: var(--side-active); color: #fff; box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .8); }
.nav-link .nav-badge { margin-left: auto; font-size: 11px; background: rgba(255, 255, 255, .12); color: #fff; padding: 1px 8px; border-radius: 99px; }
[dir="rtl"] .nav-link .nav-badge { margin-left: 0; margin-right: auto; }

.sidebar-foot { padding: 12px 14px 14px; border-top: 1px solid rgba(255, 255, 255, .06); flex-shrink: 0; }
.sidebar-card {
  border-radius: 14px; padding: 14px; color: #fff;
  background: radial-gradient(120% 120% at 0% 0%, rgba(59, 130, 246, .35), rgba(59, 130, 246, .05) 60%), rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-card p { font-size: 12px; color: var(--side-text); margin-top: 3px; }

.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; transition: margin .28s var(--ease); }
[dir="rtl"] .main { margin-left: 0; margin-right: var(--side-w); }

body.side-collapsed { --side-w: 78px; }
body.side-collapsed .sidebar-brand .brand-text, body.side-collapsed .nav-section, body.side-collapsed .nav-link span,
body.side-collapsed .nav-badge, body.side-collapsed .sidebar-foot { display: none; }
body.side-collapsed .nav-link { justify-content: center; padding: 11px; }
body.side-collapsed .sidebar-brand { justify-content: center; padding: 16px 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: rgba(255, 255, 255, .82); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .topbar { background: rgba(17, 26, 46, .82); }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { padding-left: 40px; background: var(--surface-2); border-color: transparent; height: 42px; }
.topbar .search input:focus { background: var(--surface); }
.topbar .search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
[dir="rtl"] .topbar-actions { margin-left: 0; margin-right: auto; }
.icon-btn {
  position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 11px;
  color: var(--text-2); background: transparent; border: 0; cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 8px 5px 5px; border-radius: 12px; cursor: pointer; border: 0; background: transparent; color: var(--text); font: inherit; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .meta { text-align: left; line-height: 1.2; }
.user-chip .meta strong { display: block; font-size: 13px; }
.user-chip .meta small { color: var(--muted); font-size: 11.5px; }
.menu-toggle { display: none; }

.content { padding: 26px 28px 40px; flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; animation: fadeUp .35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.footer { padding: 16px 28px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .ic { width: 13px; height: 13px; }

/* ------------------------------------------------------------------
   Cards / KPI
   ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; font-weight: 700; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card.pad { padding: 20px; }
.card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50) !important; }
.card-hover { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }

.kpi { display: flex; align-items: center; gap: 14px; padding: 18px; }
.kpi-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-icon .ic { width: 22px; height: 22px; }
.kpi-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.kpi-sub.up { color: var(--green); }
.kpi-sub.down { color: var(--red); }

.tone-blue { background: var(--blue-bg); color: var(--blue); }
.tone-green { background: var(--green-bg); color: var(--green); }
.tone-purple { background: var(--purple-bg); color: var(--purple); }
.tone-amber { background: var(--amber-bg); color: var(--amber); }
.tone-red { background: var(--red-bg); color: var(--red); }
.tone-teal { background: var(--teal-bg); color: var(--teal); }
.tone-pink { background: var(--pink-bg); color: var(--pink); }
.tone-orange { background: var(--orange-bg); color: var(--orange); }
.tone-gray { background: var(--gray-bg); color: var(--gray); }

.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-xl); padding: 26px 28px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #3b82f6 0%, #1d4ed8 45%, #172554 100%);
  box-shadow: 0 20px 40px -18px rgba(29, 78, 216, .6);
}
.hero h2 { font-size: 22px; font-weight: 800; }
.hero p { opacity: .85; margin-top: 4px; }
.hero .hero-art { position: absolute; right: -10px; bottom: -14px; width: 250px; opacity: .95; pointer-events: none; }
.hero::after { content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%; right: -90px; top: -150px; background: rgba(255, 255, 255, .08); }
.hero .btn-white { background: #fff; color: var(--primary-600); }
.hero-stats { display: flex; gap: 28px; margin-top: 18px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-stats div strong { display: block; font-size: 20px; }
.hero-stats div span { font-size: 12px; opacity: .8; }

/* ------------------------------------------------------------------
   Grid & utilities
   ------------------------------------------------------------------ */
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-side { grid-template-columns: 320px minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.flex { display: flex; } .inline-flex { display: inline-flex; }
.col { flex-direction: column; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 22px; }
.flex-1 { flex: 1; min-width: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; } .mt-5 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 18px; } .mb-5 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0 !important; }
.w-full { width: 100%; }
.text-right { text-align: right; } .text-center { text-align: center; }
.muted { color: var(--muted); } .text-2 { color: var(--text-2); }
.small { font-size: 12.5px; } .xs { font-size: 11.5px; } .lg { font-size: 16px; }
.bold { font-weight: 700; } .semibold { font-weight: 600; } .fw-800 { font-weight: 800; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-blue { color: var(--blue); } .text-purple { color: var(--purple); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.hide { display: none !important; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; user-select: none; text-decoration: none;
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 14px -6px rgba(var(--primary-rgb), .7); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-light:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-600); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-danger-soft { background: var(--red-bg); color: var(--red); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field label .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s; outline: none;
}
textarea.input { height: auto; min-height: 96px; padding: 11px 13px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238591a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
[dir="rtl"] select.input { background-position: left 12px center; padding-right: 13px; padding-left: 36px; }
.input::placeholder { color: #a3adc0; }
.input:hover { border-color: #c3cbdb; }
.input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--red); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); }
.input-sm { height: 34px !important; font-size: 12.5px !important; border-radius: 8px !important; }
.field-error { color: var(--red); font-size: 12px; margin-top: 5px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.input-group { position: relative; }
.input-group > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-group > .input { padding-left: 40px; }
.input-group .suffix { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.switch { position: relative; width: 40px; height: 22px; appearance: none; background: var(--border-strong); border-radius: 99px; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: var(--shadow-sm); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
.form-section { padding: 22px 0; border-bottom: 1px dashed var(--border); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: 0; padding-bottom: 0; }
.form-section h4 { font-size: 14px; margin-bottom: 4px; }
.form-section > p { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }

.upload-box { display: flex; align-items: center; gap: 16px; }
.upload-preview { width: 92px; height: 92px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); color: var(--muted); flex-shrink: 0; }
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; }
.filters .input-group { flex: 1; min-width: 220px; }
.filters select.input { width: auto; min-width: 140px; }

/* ------------------------------------------------------------------
   Tables  (→ cards on mobile via data-label)
   ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
[dir="rtl"] .table th { text-align: right; }
.table th:first-child { border-top-left-radius: 10px; } .table th:last-child { border-top-right-radius: 10px; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table-compact td { padding: 9px 14px; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person .name { font-weight: 600; color: var(--text); display: block; }
.person a.name:hover { color: var(--primary); }
.person small { color: var(--muted); font-size: 12px; display: block; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--primary-50); color: var(--primary); white-space: nowrap; }
.tag-gray { background: var(--gray-bg); color: var(--text-2); }
.grade { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-weight: 800; font-size: 13px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* Tabs / pills */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; padding: 0 20px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 13px 12px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 1px 7px; border-radius: 99px; }
.tab.active .count { background: var(--primary-50); color: var(--primary); }
.pills { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 11px; flex-wrap: wrap; }
.pill { padding: 6px 13px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--text-2); white-space: nowrap; border: 0; background: none; cursor: pointer; font-family: inherit; }
.pill:hover { color: var(--text); }
.pill.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.pill .count { opacity: .7; margin-left: 3px; }

/* Avatars */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex-shrink: 0; font-weight: 700; color: #fff; background: var(--av, var(--primary)); background-image: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(0, 0, 0, .05)); }
.avatar-xs { width: 26px; height: 26px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 104px; height: 104px; font-size: 34px; border: 4px solid var(--surface); box-shadow: 0 8px 24px -8px rgba(15, 23, 42, .3); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* Progress */
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .6s var(--ease); }
.progress.green > span { background: var(--green); } .progress.amber > span { background: var(--amber); } .progress.red > span { background: var(--red); } .progress.purple > span { background: var(--purple); }
.progress.thin { height: 6px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.list-icon .ic { width: 18px; height: 18px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 12px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }

.stat-inline { display: flex; gap: 0; }
.stat-inline > div { flex: 1; padding: 14px 16px; border-right: 1px solid var(--border); }
.stat-inline > div:last-child { border-right: 0; }
.stat-inline strong { display: block; font-size: 19px; font-weight: 800; }
.stat-inline span { font-size: 12px; color: var(--muted); }

/* Timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before { content: ""; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline-item:last-child { padding-bottom: 0; }

/* Schedule rows */
.sched { display: flex; gap: 14px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); align-items: center; }
.sched + .sched { margin-top: 10px; }
.sched-time { text-align: center; min-width: 64px; padding-right: 14px; border-right: 2px solid var(--primary-100); }
.sched-time strong { display: block; font-size: 13.5px; }
.sched-time span { font-size: 11px; color: var(--muted); }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; }
.empty-art { width: 150px; margin: 0 auto 16px; opacity: .95; }
.empty h4 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 360px; margin: 0 auto 18px; }

/* Alerts & toasts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; font-size: 13.5px; border: 1px solid transparent; }
.alert .ic { margin-top: 1px; }
.alert-info { background: var(--blue-bg); color: #1e3a8a; border-color: #cfdcfb; }
.alert-success { background: var(--green-bg); color: #14532d; border-color: #c4ecd2; }
.alert-warning { background: var(--amber-bg); color: #78350f; border-color: #f7ddb0; }
.alert-error { background: var(--red-bg); color: #7f1d1d; border-color: #f6caca; }
[data-theme="dark"] .alert { color: var(--text); border-color: var(--border); }

.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toastIn .35s var(--ease);
}
.toast .toast-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.toast strong { display: block; font-size: 13.5px; }
.toast p { color: var(--text-2); font-size: 13px; }
.toast.leaving { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  transform-origin: top right; max-height: min(70vh, 480px); overflow-y: auto; overscroll-behavior: contain;
}
[dir="rtl"] .dropdown-menu { right: auto; left: 0; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border-radius: 9px; color: var(--text); font-size: 13.5px; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item .ic { width: 16px; height: 16px; color: var(--muted); }
.dropdown-item.danger { color: var(--red); } .dropdown-item.danger .ic { color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-head { padding: 10px 12px 8px; }
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; }
.notif-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-item:hover { background: var(--surface-2); color: var(--text); }
.notif-item.unread { background: var(--primary-50); }
.fade-enter { transition: opacity .15s ease, transform .15s var(--ease); }
.fade-start { opacity: 0; transform: translateY(-4px) scale(.98); }
.fade-end { opacity: 1; transform: none; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(9, 14, 30, .55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; overflow: hidden; overscroll-behavior: contain; }
/* The modal itself is the only scroll area: header and footer stay fixed (sticky), the body scrolls. */
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 36px); max-height: calc(100dvh - 36px); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain; outline: 0; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1040px; }
.modal-sm { max-width: 420px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; position: sticky; top: 0; z-index: 5; background: var(--surface); }
.modal-head h3 { font-size: 17px; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.modal-head p:empty { display: none; }
.modal-body { padding: 6px 22px 18px; }
.modal-foot { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-top: 1px solid var(--border); position: sticky; bottom: 0; z-index: 5; }
.cf-msg { white-space: pre-line; }
.confirm-backdrop { z-index: 130; }
.confirm-modal .modal-head { padding-bottom: 18px; }
.confirm-modal .list-icon { width: 40px; height: 40px; }
/* Popup forms loaded from a page (Modal in app.js) */
body.modal-open .to-top { display: none; }
.ajax-backdrop { z-index: 110; }
.ajax-modal .modal-head { border-bottom: 1px solid var(--border); }
.ajax-modal.is-loading .am-body { opacity: .55; pointer-events: none; transition: opacity .15s; }
.am-skeleton { padding: 22px; display: grid; gap: 20px; }
.ajax-modal .page-head { padding: 14px 22px 0; margin: 0; }
.ajax-modal .page-head > div:first-child { display: none; }
.ajax-modal .page-head:not(:has(.actions)) { display: none; }
.ajax-modal .am-body > .modal-page > :not(form):not(.page-head):not(script), .ajax-modal .am-body > .modal-page > form:not(.card) { margin: 16px 22px; }
.ajax-modal form.card { max-width: none !important; border: 0; box-shadow: none; border-radius: 0; background: transparent; margin: 0; }
.ajax-modal form.card > .card-body { padding: 18px 22px 22px !important; }
.ajax-modal .card-foot, .ajax-modal .form-actions { position: sticky; bottom: 0; z-index: 4; background: var(--surface-2); border-radius: 0; margin: 0; }
.ajax-modal .card .card-foot { border-radius: 0 0 var(--radius) var(--radius); }
.ajax-modal form.card > .card-foot { padding: 14px 22px; border-radius: 0; }
.ajax-modal .grid.cols-main { grid-template-columns: 1fr; }
@media (min-width: 1100px) { .ajax-modal.modal-xl .grid.cols-main { grid-template-columns: minmax(0, 1fr) 340px; } }
.ajax-modal .stepper { position: sticky; top: 0; z-index: 3; background: var(--surface); }

/* Stepper (registration wizard) */
.stepper { display: flex; gap: 0; padding: 18px 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.step { display: flex; align-items: center; gap: 10px; flex: 1; min-width: max-content; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.step .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 12.5px; transition: all .2s; flex-shrink: 0; }
.step::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 12px; min-width: 20px; border-radius: 2px; }
.step:last-child::after { display: none; }
.step.active { color: var(--primary); }
.step.active .num { background: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-50); }
.step.done .num { background: var(--green); color: #fff; }
.step.done { color: var(--text); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .info { color: var(--muted); font-size: 12.5px; }
.pg-left { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; }
.pg-per, .pg-jump label { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pg-per select { width: auto; min-width: 76px; padding-right: 28px; }
.pg-jump { display: flex; align-items: center; gap: 6px; }
.pg-jump input { width: 72px; text-align: center; }
.page-link.pg-step { display: inline-flex; gap: 4px; padding: 0 10px; }
.pg-cap { margin: 0 20px 12px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.th-sort:hover, .th-sort.active { color: var(--text); }
.col-chooser .dropdown-menu { max-height: 340px; overflow-y: auto; overscroll-behavior: contain; }
.col-chooser .dropdown-item input { width: 16px; height: 16px; accent-color: var(--primary); }
.col-bar { display: flex; justify-content: flex-end; padding: 0 20px 12px; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--text-2); border: 1px solid transparent; }
.page-link:hover { background: var(--surface-3); color: var(--text); }
.page-link.active { background: var(--primary); color: #fff; box-shadow: 0 6px 14px -6px rgba(var(--primary-rgb), .7); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* Parents & Guardians (PRD §56) */
.locked { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); }
.locked p { margin-top: 3px; }
.locked-sm { padding: 10px 12px; }
.dup-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.dup-box.is-strong { border-color: #f5c77e; background: var(--amber-bg); }
.dup-box > .flex .ic { color: var(--amber); }
.dup-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--border); }
.dup-item:first-of-type { border-top: 0; }
.gs-found { border: 1px solid #b7e4c7; background: var(--green-bg); border-radius: 14px; padding: 14px 16px; max-width: 560px; margin-top: 12px; }
[data-theme="dark"] .gs-found { border-color: var(--border); }
.gs-list { max-width: 560px; margin-top: 12px; display: grid; gap: 6px; }
.gs-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.gs-row:hover { border-color: var(--primary); }
.gs-none { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.gs-tree { list-style: none; margin: 12px 0 0; padding: 0 0 0 14px; border-left: 2px solid #b7e4c7; display: grid; gap: 6px; font-size: 13px; }
.gs-tree li { position: relative; padding-left: 12px; }
.gs-tree li::before { content: ""; position: absolute; left: -14px; top: 9px; width: 18px; border-top: 2px solid #b7e4c7; }
.gs-tree li.is-new strong { color: var(--green); }
.pr-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 22px 24px; }
.pr-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pr-contacts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; }
.pr-contacts a, .pr-contacts span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.pr-contacts a:hover { color: var(--primary); }
.mini-stat { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.perm { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--muted); opacity: .55; }
.perm.on { background: var(--primary-50); color: var(--primary); opacity: 1; }
@media (max-width: 768px) {
  .pr-head { padding: 18px 16px; flex-direction: column; align-items: stretch; gap: 12px; }
  .pr-head > .avatar { width: 64px; height: 64px; font-size: 22px; }
  .pr-head h1 { font-size: 19px !important; }
  .pr-contacts a, .pr-contacts span { min-width: 0; overflow-wrap: anywhere; }
  .pr-head .actions { width: 100%; } .pr-head .actions .btn, .pr-head .actions form { flex: 1; } .pr-head .actions form .btn { width: 100%; }
}

/* Row selection + output dialog (PRD §55.29–55.31) */
[data-bulk-bar], .sel-bar { flex-wrap: wrap; row-gap: 8px; }
[data-bulk-bar] > .flex-1, .sel-bar > .flex-1 { min-width: 110px; white-space: nowrap; }
.bulk-form { display: inline-flex; gap: 6px; align-items: center; }
.bulk-form select, [data-bulk-bar] select { width: auto; }
.bulk-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
@media (max-width: 768px) { .sel-bar, [data-bulk-bar] { gap: 8px; } .bulk-sep { display: none; } .bulk-form { flex: 1 1 100%; } .bulk-form select { flex: 1; } }
.cell-check input, .row-check-all { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; }
.table tbody tr.is-selected { background: var(--primary-50); }
.sel-bar { margin: 0 20px 14px; align-items: center; flex-wrap: wrap; }
.sel-bar .btn { flex-shrink: 0; }
.out-opts { display: grid; gap: 8px; margin-top: 6px; }
.out-opt { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 600; transition: border-color .15s, background .15s; }
.out-opt:hover { border-color: var(--primary); }
.out-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.out-opt input { width: 16px; height: 16px; accent-color: var(--primary); }
.out-opt.disabled { opacity: .45; cursor: not-allowed; }
.out-opt.disabled:hover { border-color: var(--border); }
.pc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 99px; background: var(--primary-50); color: var(--primary); font-size: 12.5px; font-weight: 600; }
.pc-chip .icon-btn { width: 26px; height: 26px; }

/* Print Center: the preview fills the page; options are dropdowns in the toolbar above it */
.pc-head { margin-bottom: 14px; }
.pc-work { display: flex; flex-direction: column; gap: 12px; }
.pc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: relative; z-index: 20; }
.pc-bar .btn.is-open { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.pc-bar .tag { padding: 1px 7px; font-size: 11px; }
.pc-menu { width: 460px; max-width: calc(100vw - 32px); padding: 16px; max-height: min(64vh, 520px); }
.pc-hint { margin-left: auto; color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
[dir="rtl"] .pc-hint { margin-left: 0; margin-right: auto; }
.pc-preview { overflow: hidden; padding: 0; }
.pc-preview iframe { display: block; width: 100%; height: calc(100vh - 230px); height: calc(100dvh - 230px); min-height: 360px; border: 0; background: #eef1f6; }
body.pc-page .main-scroll > .footer { display: none; }
body.pc-page .content { padding-bottom: 20px; }
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .pc-head .actions { width: 100%; }
  .pc-head .actions .btn-primary { flex: 1; }
  .pc-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .pc-bar::-webkit-scrollbar { display: none; }
  .pc-bar .btn { flex-shrink: 0; }
  /* dropdowns become a sheet under the toolbar so they are never cut off */
  .pc-bar .dropdown { position: static; }
  .pc-menu { position: fixed; left: 12px !important; right: 12px !important; top: auto; width: auto; max-width: none; margin-top: 8px; max-height: 52dvh; }
}
/* Profile header */
.profile-cover { height: 120px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: radial-gradient(120% 180% at 0% 0%, #60a5fa 0%, #2563eb 40%, #1e3a8a 100%); position: relative; overflow: hidden; }
.profile-cover::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px); background-size: 18px 18px; }
.profile-main { display: flex; gap: 20px; align-items: flex-end; padding: 0 24px 20px; margin-top: -48px; position: relative; flex-wrap: wrap; }
.profile-main h2 { font-size: 22px; font-weight: 800; }
.profile-info { min-width: 220px; padding-top: 52px; }
.profile-actions { padding-top: 52px; }
.profile-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-top: 6px; }
.profile-meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-meta .ic { width: 15px; height: 15px; color: var(--muted); }

/* Class tile */
.class-tile { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.class-tile .top { display: flex; gap: 12px; align-items: flex-start; }
.course-dot { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }

/* Attendance toggles */
.att-toggle { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 11px; }
.att-toggle input { display: none; }
.att-toggle label { padding: 6px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-2); transition: all .15s; user-select: none; }
.att-toggle input:checked + label.p { background: var(--green); color: #fff; }
.att-toggle input:checked + label.a { background: var(--red); color: #fff; }
.att-toggle input:checked + label.l { background: var(--amber); color: #fff; }
.att-toggle input:checked + label.e { background: var(--blue); color: #fff; }

.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 4px; }
.heat span { aspect-ratio: 1; border-radius: 4px; background: var(--surface-3); }
.heat .present { background: #4ade80; } .heat .late { background: #fbbf24; } .heat .absent { background: #f87171; } .heat .excused { background: #93c5fd; }

.kbd, kbd { font-family: inherit; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--muted); }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.donut-center strong { display: block; font-size: 22px; font-weight: 800; }
.donut-center span { font-size: 12px; color: var(--muted); }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend i.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { margin-left: auto; font-weight: 700; }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Top progress bar (page transitions) */
#nprogress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 300; background: linear-gradient(90deg, #60a5fa, var(--primary)); box-shadow: 0 0 10px rgba(var(--primary-rgb), .6); transition: width .4s var(--ease), opacity .3s; }

/* ------------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); background: var(--surface); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 96px); }
.auth-inner { width: 100%; max-width: 420px; margin: 0 auto; }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px; display: grid; place-items: center; }
.auth-logo img { width: 64px; height: 64px; object-fit: contain; }
.auth h1 { font-size: 28px; font-weight: 800; text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin: 6px 0 28px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-visual { position: relative; overflow: hidden; margin: 14px; border-radius: 28px; background: #0b1533; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: 48px; min-height: 520px; }
.auth-visual .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.auth-visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11, 21, 51, 0) 30%, rgba(11, 21, 51, .88) 100%); }
.auth-visual .cap { position: relative; z-index: 1; }
.auth-visual .cap span { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #93c5fd; font-weight: 700; }
.auth-visual h2 { font-size: clamp(28px, 3vw, 40px); font-weight: 800; line-height: 1.12; margin: 10px 0 12px; }
.auth-visual p { color: #c7d2fe; max-width: 460px; }
.auth-dots { display: flex; gap: 6px; margin-top: 22px; }
.auth-dots i { width: 8px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .35); }
.auth-dots i.on { width: 26px; background: #fff; }
.demo-accounts { margin-top: 22px; border: 1px dashed var(--border-strong); border-radius: 14px; padding: 12px; }
.demo-accounts button { font-size: 12px; }

/* Certificate — sizes use container units so it scales perfectly at any width */
.certificate {
  position: relative; width: 100%; max-width: 1000px; aspect-ratio: 1.414; margin: 0 auto; background: #fffdf7; color: #1e293b;
  box-shadow: var(--shadow-lg); border-radius: 6px; overflow: hidden; container-type: inline-size;
  background-image: radial-gradient(circle at 50% 45%, rgba(201, 162, 39, .07), transparent 60%);
}
.certificate .frame { position: absolute; inset: 2.2%; border: .35cqw solid #1e3a8a; outline: .12cqw solid #c9a227; outline-offset: -1.1cqw; pointer-events: none; }
.certificate .corner { position: absolute; width: 14%; aspect-ratio: 1; opacity: .95; }
.certificate .inner { position: absolute; inset: 7% 9% 25%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.certificate .c-logo { width: 7.5cqw; }
.certificate .c-academy { font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: #1e3a8a; font-size: 1.5cqw; margin-top: .8cqw; }
.certificate .c-title { font-family: Georgia, "Times New Roman", serif; font-size: 4.1cqw; font-weight: 700; color: #0f172a; letter-spacing: .05em; margin-top: 1.6cqw; white-space: nowrap; line-height: 1.1; }
.certificate .c-sub { color: #b08d1e; letter-spacing: .3em; text-transform: uppercase; font-size: 1.15cqw; font-weight: 700; margin-top: 1cqw; }
.certificate .c-text { color: #475569; font-size: 1.45cqw; margin-top: 1.4cqw; }
.certificate .c-name { font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 5.6cqw; color: #1e3a8a; line-height: 1.15; margin-top: .6cqw; border-bottom: .15cqw solid #c9a227; padding: 0 4cqw .3cqw; }
.certificate .c-course { font-size: 2.4cqw; font-weight: 800; color: #0f172a; margin-top: .5cqw; }
.certificate .c-meta { font-size: 1.05cqw; color: #64748b; margin-top: 1cqw; }
.certificate .c-foot { position: absolute; left: 8%; right: 8%; bottom: 7%; display: flex; align-items: flex-end; justify-content: space-between; gap: 2cqw; }
.certificate .sig { text-align: center; width: 24%; font-size: 1.15cqw; color: #475569; }
.certificate .sig .line { border-top: .15cqw solid #334155; margin: .3cqw 0 .4cqw; }
.certificate .sig .script { font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 2.3cqw; color: #1e3a8a; white-space: nowrap; }
.certificate .seal { width: 11cqw; }
.certificate .qr { width: 10cqw; background: #fff; padding: .5cqw; border: .1cqw solid #e2e8f0; }
.certificate .qr img, .certificate .qr canvas { width: 100% !important; height: auto !important; display: block; }
.certificate .revoked { font-size: 9cqw; }
/* Receipt / print docs */
.doc { max-width: 820px; margin: 0 auto; background: #fff; color: #0f172a; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 28px 32px; background: linear-gradient(135deg, #eff4ff, #fff); border-bottom: 1px solid #e6eaf2; }
.doc-head img { width: 56px; height: 56px; object-fit: contain; }
.doc-body { padding: 26px 32px; }
.doc .table th { background: #f8fafc; }
.doc-foot { padding: 18px 32px 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.paid-stamp { border: 3px solid var(--green); color: var(--green); font-weight: 900; letter-spacing: .2em; padding: 6px 16px; border-radius: 10px; transform: rotate(-8deg); display: inline-block; font-size: 18px; }

.id-card { width: 340px; height: 214px; border-radius: 16px; overflow: hidden; position: relative; color: #fff; background: linear-gradient(135deg, #1e3a8a, #2563eb 60%, #3b82f6); box-shadow: var(--shadow-lg); font-size: 11px; }
.id-card .band { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: rgba(0, 0, 0, .15); }
.id-card .band img { width: 28px; height: 28px; background: #fff; border-radius: 7px; padding: 2px; }
.id-card .body { display: flex; gap: 12px; padding: 12px 14px; }
.id-card .photo { width: 78px; height: 92px; border-radius: 10px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.id-card .photo img, .id-card .photo .avatar { width: 100%; height: 100%; border-radius: 0; font-size: 26px; }
.id-card .back { background: #fff; color: #0f172a; }

/* RTL (Arabic) refinements */
[dir="rtl"] .input-group > .ic, [dir="rtl"] .topbar .search .ic { left: auto; right: 13px; }
[dir="rtl"] .input-group > .input, [dir="rtl"] .topbar .search input { padding-left: 13px; padding-right: 40px; }
[dir="rtl"] .input-group .suffix { right: auto; left: 6px; }
[dir="rtl"] .topbar .search kbd { right: auto; left: 10px; }
[dir="rtl"] .user-chip { padding: 5px 5px 5px 8px; }
[dir="rtl"] .user-chip .meta, [dir="rtl"] .dropdown-item { text-align: right; }
[dir="rtl"] .table .num, [dir="rtl"] .text-right { text-align: left; }
[dir="rtl"] .dl dd, [dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .sched-time { padding-right: 0; padding-left: 14px; border-right: 0; border-left: 2px solid var(--primary-100); }
[dir="rtl"] .stat-inline > div { border-right: 0; border-left: 1px solid var(--border); }
[dir="rtl"] .stat-inline > div:last-child { border-left: 0; }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 22px; }
[dir="rtl"] .timeline::before { left: auto; right: 6px; }
[dir="rtl"] .timeline-item::before { left: auto; right: -21px; }
[dir="rtl"] .legend b { margin-left: 0; margin-right: auto; }
[dir="rtl"] .avatar-stack .avatar { margin-left: 0; margin-right: -8px; }
[dir="rtl"] .avatar-stack .avatar:first-child { margin-right: 0; }
[dir="rtl"] .toasts { right: auto; left: 18px; }
[dir="rtl"] .ml-auto { margin-left: 0; margin-right: auto; }
[dir="rtl"] .icon-btn .dot { right: auto; left: 9px; }
[dir="rtl"] .hero .hero-art { right: auto; left: -10px; transform: scaleX(-1); }
[dir="rtl"] .crumbs .ic, [dir="rtl"] .btn .ic[data-lucide^="arrow-"], [dir="rtl"] svg.lucide-chevron-right, [dir="rtl"] svg.lucide-chevron-left,
[dir="rtl"] svg.lucide-arrow-right, [dir="rtl"] svg.lucide-arrow-left { transform: scaleX(-1); }
[dir="rtl"] .table.responsive td { text-align: left; }
[dir="rtl"] .table.responsive td::before { text-align: right; }

/* Bottom navigation (mobile) */
.bottom-nav { display: none; }
.mobile-only { display: none; }

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1280px) {
  .cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .cols-main, .cols-side { grid-template-columns: minmax(0, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); width: 280px; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.side-open .sidebar { transform: none; }
  body.side-collapsed { --side-w: 256px; }
  .main, [dir="rtl"] .main { margin: 0; }
  .menu-toggle { display: inline-grid; }
  .side-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(9, 14, 30, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.side-open .side-overlay { opacity: 1; pointer-events: auto; }
  .collapse-btn { display: none !important; }
}
@media (max-width: 768px) {
  body { font-size: 14px; }
  .topbar { padding: 0 14px; gap: 8px; height: 60px; }
  .topbar .search { display: none; }
  .user-chip .meta, .user-chip > .ic { display: none; }
  .content { padding: 18px 16px 96px; }
  .footer { display: none; }
  .to-top { bottom: 84px; right: 16px; }
  [dir="rtl"] .to-top { left: 16px; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head h1 { font-size: 20px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .grid { gap: 12px; }
  .cols-2, .cols-3, .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-4, .cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
  .kpi { padding: 14px; gap: 11px; flex-direction: column; align-items: flex-start; }
  .kpi-icon { width: 40px; height: 40px; border-radius: 12px; }
  .kpi-value { font-size: 20px; }
  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 16px; }
  .filters { padding: 14px 16px; }
  .filters .input-group, .filters select.input, .filters .btn { flex: 1 1 calc(50% - 10px); min-width: 0; width: auto; }
  .filters .input-group { flex-basis: 100%; }
  .tabs { padding: 0 12px; }
  .hero { padding: 22px 20px; }
  .hero h2 { font-size: 18px; }
  .hero p { font-size: 12.5px; }
  .hero-stats { gap: 18px; }
  .hero .hero-art { width: 150px; opacity: .35; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 10px; font-size: 12px; }
  .profile-main { padding: 0 16px 18px; gap: 12px; flex-direction: column; align-items: flex-start; }
  .profile-main .actions { width: 100%; }
  .profile-info, .profile-actions { padding-top: 0; min-width: 0; width: 100%; }
  .profile-actions .btn { flex: 1; }
  .profile-cover { height: 96px; }
  .profile-meta { gap: 6px 14px; }
  .stat-inline { flex-wrap: wrap; }
  .stat-inline > div { flex: 1 1 50%; border-bottom: 1px solid var(--border); }
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }

  /* Responsive tables → cards */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 14px 16px; border-bottom: 1px solid var(--border); position: relative; }
  .table.responsive tbody tr:hover { background: transparent; }
  .table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; flex-shrink: 0; }
  .table.responsive td.cell-main { padding-bottom: 8px; justify-content: flex-start; text-align: left; }
  .table.responsive td.cell-main::before, .table.responsive td[data-label=""]::before { display: none; }
  .table.responsive td.cell-check { position: absolute; right: 16px; top: 16px; width: auto; padding: 0; }
  .table.responsive td.cell-actions { justify-content: flex-end; padding-top: 10px; }
  .table.responsive td.cell-actions::before { display: none; }
  .table.responsive tfoot { display: block; }
  .table.responsive tfoot tr { display: block; }
  .table.responsive td.num { text-align: right; }

  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: 66px;
    padding: 0 6px env(safe-area-inset-bottom); background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, .15);
  }
  [data-theme="dark"] .bottom-nav { background: rgba(17, 26, 46, .94); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); background: none; border: 0; font-family: inherit; cursor: pointer; }
  .bottom-nav .ic { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .fab { width: 50px; height: 50px; border-radius: 16px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-top: -26px; box-shadow: 0 10px 22px -8px rgba(var(--primary-rgb), .9); }
  .toasts { top: auto; bottom: 80px; right: 12px; left: 12px; width: auto; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; animation: sheetUp .3s var(--ease); }
  .ajax-modal { height: 94dvh; max-height: 94dvh; }
  .pagination { padding: 12px 16px; }
  .pg-step span, .pg-jump label span { display: none; }
  .pg-jump { display: none; }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .auth-form { padding: 32px 20px; }
  .step { font-size: 0; gap: 0; } .step .num { font-size: 12.5px; }
}
@media (max-width: 400px) {
  .cols-4, .cols-5 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi-value { font-size: 18px; }
}

/* ------------------------------------------------------------------
   Print
   ------------------------------------------------------------------ */
@media (max-height: 760px) {
  .sidebar-card p { display: none; }
  .sidebar-card { padding: 10px 12px; }
  .nav-section { margin-top: 14px; }
}
@media print {
  .to-top { display: none !important; }
  @page { margin: 12mm; }
  body { background: #fff !important; color: #000; font-size: 12px; }
  .sidebar, .topbar, .bottom-nav, .footer, .no-print, .toasts, .side-overlay, .page-head .actions, .filters, .pagination .pages { display: none !important; }
  .main { margin: 0 !important; }
  body.shell { overflow: visible !important; }
  body.shell .app, body.shell .main, .main-scroll { display: block !important; height: auto !important; overflow: visible !important; }
  .content { padding: 0 !important; max-width: none; animation: none; }
  .card, .doc { box-shadow: none !important; border: 1px solid #ddd; }
  .table th { background: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge, .tag, .grade, .kpi-icon, .hero, .id-card, .certificate, .profile-cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block !important; }
  a { color: inherit; }
}
.print-only { display: none; }

/* ======================================================================
   Online Examination (PRD §53) — builder, question editor, exam interface
   ====================================================================== */
.oe-steps { display: flex; gap: 0; align-items: center; padding: 16px 20px; overflow-x: auto; scrollbar-width: none; }
.oe-steps .step { cursor: pointer; text-decoration: none; }
.oe-steps .step.active .num { background: var(--primary); color: #fff; }
.oe-steps .step.done .num { background: var(--green); color: #fff; }
.oe-steps .step.active { color: var(--primary); }
.oe-steps .step.done { color: var(--text); }
.oe-steps .step.disabled { pointer-events: none; opacity: .55; }
.qe-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.qe-types { padding: 10px; position: sticky; top: 14px; }
.qe-types h4 { font-size: 13px; font-weight: 700; padding: 6px 8px 10px; }
.qe-type { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: start; }
.qe-type:hover { background: var(--surface-2); color: var(--text); }
.qe-type.active { background: var(--primary-50); color: var(--primary); border-color: rgba(var(--primary-rgb), .25); }
.qe-type .ic { width: 17px; height: 17px; }
.rte-wrap { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); overflow: hidden; }
.rte-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rte-bar button { width: 30px; height: 30px; border: 0; background: none; border-radius: 7px; color: var(--text-2); cursor: pointer; display: grid; place-items: center; font: 700 13px var(--font); }
.rte-bar button:hover { background: var(--surface-3); color: var(--text); }
.rte-bar .sep { width: 1px; background: var(--border); margin: 4px 3px; }
.rte { min-height: 96px; padding: 12px 14px; outline: none; font-size: 14.5px; line-height: 1.6; }
.rte.sm { min-height: 64px; }
.rte:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich p { margin: 0 0 6px; }
.rich ul, .rich ol { padding-inline-start: 22px; margin: 4px 0 8px; }
.rich table, .rte table { border-collapse: collapse; margin: 6px 0; }
.rich td, .rich th, .rte td, .rte th { border: 1px solid var(--border-strong); padding: 5px 10px; min-width: 50px; }
.rich pre, .rte pre { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px; overflow-x: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 8px 0; direction: ltr; text-align: left; }
.rich code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.rich a { color: var(--primary); text-decoration: underline; }
.q-opt { display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.q-opt + .q-opt { margin-top: 8px; }
.q-opt.correct { border-color: var(--green); background: var(--green-bg); }
.q-opt .letter { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; font-weight: 800; font-size: 12.5px; flex-shrink: 0; }
.q-opt.correct .letter { background: var(--green); color: #fff; }
.q-opt .input { border: 0; box-shadow: none; height: 34px; background: transparent; }
.q-opt .pick { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; margin-inline-start: 6px; cursor: pointer; }
.tf-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-pick label { border: 2px solid var(--border); border-radius: 14px; padding: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; cursor: pointer; }
.tf-pick input { accent-color: var(--green); width: 18px; height: 18px; }
.tf-pick label.on { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.pair-row { display: grid; grid-template-columns: 1fr 24px 1fr 34px; gap: 8px; align-items: center; }
.pair-row + .pair-row { margin-top: 8px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: var(--surface); }
.chip-check.on { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.chip-check input { accent-color: var(--primary); }
.diff { display: inline-flex; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.diff-easy { background: var(--green-bg); color: var(--green); } .diff-medium { background: var(--amber-bg); color: var(--amber); } .diff-hard { background: var(--red-bg); color: var(--red); }
.eq-item { display: flex; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); align-items: flex-start; }
.eq-item .n { width: 30px; height: 30px; border-radius: 9px; background: var(--primary-50); color: var(--primary); font-weight: 800; display: grid; place-items: center; flex-shrink: 0; font-size: 12.5px; }
.eq-item .body { flex: 1; min-width: 0; }
.eq-item .body .rich { font-size: 14px; }
.eq-item .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.eq-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.eq-opts .ok { color: var(--green); font-weight: 700; }
.sec-head { padding: 10px 16px; background: var(--surface-2); border-top: 1px solid var(--border); font-weight: 800; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; }
.dist-card { text-align: center; border: 1px solid var(--border); border-radius: 14px; padding: 12px 8px; }
.dist-card .v { font-size: 22px; font-weight: 800; }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pick-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.pick-row:first-child { border-top: 0; }
.pick-row:hover { background: var(--surface-2); }
.pick-row.sel { background: var(--primary-50); }
.pick-list { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--border); font-size: 13.5px; }
.check-row:first-child { border-top: 0; }
.check-row .ic { flex-shrink: 0; }
.opt-list label { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; cursor: pointer; }
.opt-list input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); flex-shrink: 0; }
.ans-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.grade-q { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); }
.grade-q + .grade-q { margin-top: 14px; }
.grade-q .gq-head { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.grade-q .gq-body { padding: 14px 16px; }
.mark-ok { color: var(--green); } .mark-bad { color: var(--red); } .mark-part { color: var(--amber); }

/* ---- student exam interface (distraction-free) ---- */
body.exam-mode { background: var(--bg); }
.xq-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.xq-top .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.xq-top .brand img { width: 34px; height: 34px; object-fit: contain; }
.xq-top .brand strong { font-size: 15px; display: block; }
.xq-timer { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; background: var(--green-bg); color: var(--green); font: 800 20px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .03em; }
.xq-timer.low { background: var(--red-bg); color: var(--red); animation: xq-pulse 1.2s infinite; }
@keyframes xq-pulse { 50% { opacity: .65; } }
.xq-wrap { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; max-width: 1240px; margin: 20px auto; padding: 0 18px 90px; align-items: start; }
.xq-side { position: sticky; top: 84px; }
.xq-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.xq-grid button { height: 40px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font: 700 13px var(--font); cursor: pointer; color: var(--text); }
.xq-grid button.answered { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.xq-grid button.flagged { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.xq-grid button.current { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--ring); }
.xq-legend { display: grid; gap: 7px; margin-top: 16px; font-size: 12.5px; color: var(--text-2); }
.xq-legend span { display: inline-flex; align-items: center; gap: 8px; }
.xq-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--border-strong); }
.xq-main { min-width: 0; }
.xq-card { padding: 26px 28px; }
.xq-qtext { font-size: 17px; font-weight: 600; line-height: 1.55; margin: 10px 0 18px; }
.xq-img { max-width: 100%; max-height: 340px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 16px; }
.xq-choice { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 14px; cursor: pointer; font-size: 15px; transition: border-color .15s, background .15s; }
.xq-choice + .xq-choice { margin-top: 10px; }
.xq-choice:hover { border-color: rgba(var(--primary-rgb), .45); }
.xq-choice.on { border-color: var(--primary); background: var(--primary-50); }
.xq-choice input { width: 19px; height: 19px; accent-color: var(--primary); flex-shrink: 0; }
.xq-choice .letter { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex-shrink: 0; }
.xq-choice.on .letter { background: var(--primary); color: #fff; }
.xq-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.xq-save { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.xq-save.ok { color: var(--green); } .xq-save.off { color: var(--red); }
.xq-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.xq-sum .kpi { border: 1px solid var(--border); border-radius: 14px; }
.xq-banner { padding: 10px 22px; background: var(--amber-bg); color: var(--amber); font-weight: 700; font-size: 13px; text-align: center; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1.2fr); gap: 10px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--border); }
.match-row:first-child { border-top: 0; }
.match-row .term { font-weight: 700; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.result-hero { text-align: center; padding: 30px 20px; }
.result-ring { width: 150px; height: 150px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; background: conic-gradient(var(--c, var(--green)) calc(var(--p) * 1%), var(--surface-3) 0); }
.result-ring > div { width: 118px; height: 118px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 30px; font-weight: 800; }
.rv-q { padding: 16px 18px; border-top: 1px solid var(--border); }
.rv-q:first-child { border-top: 0; }
.rv-ans { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 4px 12px; font-size: 13.5px; margin-top: 8px; }
.rv-ans dt { color: var(--muted); }
.rv-ans dd { margin: 0; }
.exam-tile { display: flex; gap: 14px; align-items: center; padding: 16px 18px; flex-wrap: wrap; }
.exam-tile + .exam-tile { border-top: 1px solid var(--border); }
.exam-tile .kpi-icon { width: 46px; height: 46px; }
.bar-h { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-h > span { display: block; height: 100%; border-radius: 99px; }
@media (max-width: 1024px) {
  .qe-grid { grid-template-columns: 1fr; }
  .qe-types { position: static; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .qe-types h4 { display: none; }
  .qe-type { width: auto; white-space: nowrap; flex-shrink: 0; }
  .xq-wrap { grid-template-columns: 1fr; }
  .xq-side { position: static; order: 2; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .xq-top { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .xq-top .brand { flex: 1 1 100%; }
  .xq-top .xq-save { flex: 1; }
  .xq-timer { font-size: 17px; padding: 7px 11px; }
  .xq-card { padding: 18px 16px; }
  .xq-wrap { padding: 0 12px 90px; margin-top: 14px; }
  .xq-grid { grid-template-columns: repeat(6, 1fr); }
  .xq-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eq-opts { grid-template-columns: 1fr; }
  .pair-row { grid-template-columns: 1fr 34px; }
  .pair-row .arrow { display: none; }
  .match-row { grid-template-columns: 1fr; }
  .match-row > .ic { display: none; }
  .rv-ans { grid-template-columns: 1fr; }
}
/* Large dropzone (AI generator, imports, exam file answers) */
label.upload-box { flex-direction: column; justify-content: center; gap: 8px; text-align: center; padding: 30px 20px; border: 2px dashed var(--border-strong); border-radius: 16px; background: var(--surface-2); transition: border-color .15s, background .15s; }
label.upload-box:hover { border-color: var(--primary); background: var(--primary-50); }
label.upload-box .ic-xl { color: var(--primary); }

/* Parent profile: communication log (PRD §56.18) */
.comm-log { display: grid; gap: 4px; }
.comm-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.comm-item:last-child { border-bottom: 0; }
.comm-item .list-icon { width: 34px; height: 34px; }
.comm-body { margin: 6px 0; color: var(--text-2); white-space: normal; }
