/* ═══════════════════════════════════════════════════════════════
   Learn Edara — Design System
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* Brand */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --primary-mid:    #bfdbfe;

  /* Status */
  --success:        #16a34a;
  --success-light:  #f0fdf4;
  --warning:        #d97706;
  --warning-light:  #fffbeb;
  --danger:         #dc2626;
  --danger-light:   #fef2f2;
  --info:           #0891b2;
  --info-light:     #ecfeff;

  /* Neutrals */
  --text:           #0f172a;
  --text-muted:     #64748b;
  --text-subtle:    #94a3b8;
  --border:         #e2e8f0;
  --border-hover:   #cbd5e1;
  --bg:             #f8fafc;
  --bg-subtle:      #f1f5f9;
  --card:           #ffffff;

  /* Shape */
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  /* Elevation */
  --shadow-sm:      0 1px 2px rgba(0,0,0,.06);
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-xl:      0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);

  /* Transitions */
  --transition:     150ms ease;

  /* Surface (alias for card) */
  --surface:        #ffffff;

  /* Sidebar width */
  --sidebar-w:      240px;

  /* Tag palette (deterministic per-tag colors, view mode) */
  --tag-0-bg: #eff6ff; --tag-0-text: #2563eb;
  --tag-1-bg: #f0fdfa; --tag-1-text: #0f766e;
  --tag-2-bg: #f5f3ff; --tag-2-text: #7c3aed;
  --tag-3-bg: #fdf2f8; --tag-3-text: #be185d;
  --tag-4-bg: #eef2ff; --tag-4-text: #4338ca;
  --tag-5-bg: #fff7ed; --tag-5-text: #c2410c;
  --tag-6-bg: #ecfeff; --tag-6-text: #0e7490;
  --tag-7-bg: #fff1f2; --tag-7-text: #be123c;
}

/* ── Dark mode ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --text:           #f1f5f9;
  --text-muted:     #94a3b8;
  --text-subtle:    #64748b;
  --border:         #334155;
  --border-hover:   #475569;
  --bg:             #0f172a;
  --bg-subtle:      #1e293b;
  --card:           #1e293b;
  --surface:        #1e293b;
  --primary-light:  rgba(37,99,235,.18);
  --primary-mid:    rgba(37,99,235,.3);
  --success-light:  rgba(22,163,74,.18);
  --warning-light:  rgba(217,119,6,.18);
  --danger-light:   rgba(220,38,38,.18);
  --info-light:     rgba(8,145,178,.18);
  --tag-0-bg: rgba(37,99,235,.18);  --tag-0-text: #93c5fd;
  --tag-1-bg: rgba(15,118,110,.22); --tag-1-text: #5eead4;
  --tag-2-bg: rgba(124,58,237,.22); --tag-2-text: #c4b5fd;
  --tag-3-bg: rgba(190,24,101,.22); --tag-3-text: #f9a8d4;
  --tag-4-bg: rgba(67,56,202,.22);  --tag-4-text: #a5b4fc;
  --tag-5-bg: rgba(194,65,12,.22);  --tag-5-text: #fdba74;
  --tag-6-bg: rgba(14,116,144,.22); --tag-6-text: #67e8f9;
  --tag-7-bg: rgba(190,18,60,.22);  --tag-7-text: #fda4af;
  --shadow-sm:      0 1px 2px rgba(0,0,0,.4);
  --shadow:         0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,.5);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.5);
  --shadow-xl:      0 20px 25px -5px rgba(0,0,0,.6);
}

/* ── Reset ───────────────────────────────────────────────────── */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; line-height: 1.25; }
p { margin: 0; }

/* ── Scrollbars ──────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(37,99,235,.45) var(--bg-subtle);
}
*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
*::-webkit-scrollbar-track {
  background: var(--bg-subtle);
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb {
  background-color: rgba(37,99,235,.45);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 10px;
  transition: background-color .2s ease;
}
*::-webkit-scrollbar-thumb:hover  { background-color: rgba(37,99,235,.7); }
*::-webkit-scrollbar-thumb:active { background-color: rgba(37,99,235,.9); }
*::-webkit-scrollbar-corner { background: transparent; }

/* ── Loading ─────────────────────────────────────────────────── */
#loading-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; flex-direction: column; gap: 16px; color: var(--text-muted);
}
.spinner {
  position: relative;
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  animation: spinner-bounce 1.2s ease-in-out infinite;
  animation-delay: -.12s;
}
.spinner::before, .spinner::after {
  content: "";
  position: absolute;
  top: 0;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  animation: spinner-bounce 1.2s ease-in-out infinite;
}
.spinner::before { left: -15px; animation-delay: -.24s; }
.spinner::after  { left: 15px;  animation-delay: 0s; }
@keyframes spinner-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1; }
}
/* Full-page loading state: centers the spinner on the middle of the screen.
   An element whose top edge sits --pl-top below the viewport top is centered
   on the viewport midpoint when it is (100vh − 2 × --pl-top) tall, so each
   context declares how far down it starts. The 150px default suits a spinner
   under a page header; the floor keeps it from collapsing on short screens. */
.page-loading {
  --pl-top: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: max(240px, calc(100vh - 2 * var(--pl-top)));
}
/* Only when the spinner is the first thing in its container — with a header
   above it the offset is larger, so it keeps the default. */
#page > .page-loading:first-child { --pl-top: 0px; }
.page > .page-loading:first-child,
.page-wide > .page-loading:first-child,
.page-fluid > .page-loading:first-child { --pl-top: 32px; }
.md-page > .page-loading:first-child { --pl-top: 28px; }
/* Loading inside a modal or a small panel: not tied to the screen middle. */
.page-loading.compact            { min-height: 160px; }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════ */
/* Shell — stacks the page grid above the footer and pins the footer to
   the bottom of the viewport (or below the fold if content overflows it). */
.login-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
}
.login-page {
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: 45fr 55fr;
  align-self: stretch;
}

/* Left panel — branding */
.login-left {
  background: linear-gradient(145deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vh, 60px) 48px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.06) 0%, transparent 50%);
}
.login-brand {
  position: relative;
  text-align: center;
  margin-bottom: clamp(20px, 4vh, 48px);
}
/* Brand row: Edara logo · divider · learning icon */
.login-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 auto 20px;
}
/* Edara ERP logo tile (white so the blue mark reads on the gradient) */
.login-brand-edara {
  width: 72px; height: 72px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 10px;
  object-fit: contain;
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}
/* Subtle vertical separator between the two brands */
.login-brand-divider {
  width: 1px;
  height: 46px;
  background: rgba(255,255,255,.28);
  flex-shrink: 0;
}
/* Learning icon (📚) tile — keeps the original frosted-glass look */
.login-brand-icon {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}

/* Smaller, tighter on narrow viewports */
@media (max-width: 480px) {
  .login-brand-row { gap: 12px; }
  .login-brand-edara,
  .login-brand-icon { width: 60px; height: 60px; }
  .login-brand-icon { font-size: 30px; }
  .login-brand-divider { height: 38px; }
}
.login-brand h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  margin-bottom: 8px;
}
.login-brand p {
  color: rgba(255,255,255,.75);
  font-size: 15px;
  line-height: 1.5;
}
.login-features {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6vh, 16px);
  width: 100%;
  max-width: 340px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  padding: clamp(8px, 1.6vh, 14px) 18px;
  backdrop-filter: blur(4px);
}
.login-feature-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.login-feature-text strong { display: block; color: #fff; font-size: 14px; }
.login-feature-text span  { color: rgba(255,255,255,.65); font-size: 12px; }

/* Right panel — form */
.login-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vh, 60px) 48px;
  background: var(--card);
}
.login-form-wrap {
  width: 100%;
  max-width: 380px;
}
.login-form-wrap h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.login-form-wrap > p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0;
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.login-divider::before,
.login-divider::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}
.login-quick {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}
.login-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.login-quick-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.login-quick-btn .icon { font-size: 20px; }
.login-quick-btn .label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.login-dev-note {
  margin-top: 24px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.login-dev-note code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* Email one-time-code sign-in */
.le-trust {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 14px;
  font-size: 14px; color: var(--text-muted);
  cursor: pointer;
}
.le-trust input { width: 16px; height: 16px; }
.le-sent { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }
#le-code {
  letter-spacing: 8px; text-align: center;
  font-size: 20px; font-weight: 600;
}

/* Security → devices/sessions list */
.sec-list { display: flex; flex-direction: column; }
.sec-device {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px; border-bottom: 1px solid var(--border);
}
.sec-device:last-child { border-bottom: none; }
.sec-device-icon { font-size: 24px; line-height: 1; flex-shrink: 0; }
.sec-device-info { flex: 1; min-width: 0; }
.sec-device-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec-device-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.sec-empty { color: var(--text-muted); margin: 8px 0; }
.sec-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.sec-actions-hint { font-size: 13px; color: var(--text-muted); }

/* Login footer — copyright + social links */
.login-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(10px, 2vh, 18px) 48px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.login-footer-copy {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.login-footer-social {
  display: flex;
  align-items: center;
  gap: 18px;
}
.login-footer-social a {
  display: flex;
  color: var(--text-muted);
  transition: color var(--transition), transform var(--transition), opacity var(--transition);
}
.login-footer-social a:hover {
  color: var(--primary);
  opacity: .85;
  transform: translateY(-2px);
}
.login-footer-social svg { width: 19px; height: 19px; }

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  /* Full branding panel is too tall for mobile — collapse it to a compact
     logo header instead of hiding the brand entirely. */
  .login-left {
    padding: 28px 24px 22px;
    min-height: 0;
  }
  .login-left::before { display: none; }
  .login-brand { margin-bottom: 0; }
  .login-brand-row { margin-bottom: 0; gap: 12px; }
  .login-brand-edara,
  .login-brand-icon { width: 48px; height: 48px; }
  .login-brand-icon { font-size: 22px; }
  .login-brand-divider { height: 30px; }
  .login-brand h1 {
    font-size: 20px;
    margin-bottom: 0;
  }
  .login-brand p,
  .login-features { display: none; }
  .login-right { padding: 32px 24px 40px; }
  .login-footer {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 16px 24px;
    gap: 14px;
  }
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR NAVIGATION
   ══════════════════════════════════════════════════════════════ */
/* ── Sidebar: permanent dark navigation rail (modern admin pattern) ── */
.sidebar {
  /* scoped dark palette — stays dark in both light & dark app themes */
  --sb-text:      #cbd5e1;
  --sb-muted:     #94a3b8;
  --sb-hover:     rgba(255,255,255,.06);
  --sb-active-bg: rgba(59,130,246,.16);
  --sb-active:    #93c5fd;
  --sb-border:    rgba(255,255,255,.08);

  width: var(--sidebar-w);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(180deg, #111a2e 0%, #0b1220 100%);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: 2px 0 18px rgba(2,6,23,.25);
  transition: transform .25s ease;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--sb-border);
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}
.sidebar-logo img {
  width: 28px; height: 28px; display: block; object-fit: contain;
}
.sidebar-brand-name {
  font-weight: 800; font-size: 16px; color: #fff; letter-spacing: -0.3px;
}
.sidebar-brand-name span { color: #60a5fa; }

/* Links */
.sidebar-links {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(96,165,250,.35) transparent;
}
.sidebar-links::-webkit-scrollbar-track { background: transparent; }
.sidebar-links::-webkit-scrollbar-thumb {
  background-color: rgba(96,165,250,.35);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 10px;
}
.sidebar-links::-webkit-scrollbar-thumb:hover  { background-color: rgba(96,165,250,.55); }
.sidebar-links::-webkit-scrollbar-thumb:active { background-color: rgba(96,165,250,.75); }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  color: var(--sb-muted);
  cursor: pointer;
  border: none; background: none;
  font-family: inherit;
  width: 100%; text-align: start;
  text-decoration: none;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-link:hover  { background: var(--sb-hover); color: #fff; text-decoration: none; }
.sidebar-link:hover .sidebar-link-icon { transform: scale(1.08); }
.sidebar-link.active {
  background: var(--sb-active-bg); color: var(--sb-active); font-weight: 600;
}
/* left accent bar on the active item */
.sidebar-link.active::before {
  content: ""; position: absolute;
  inset-inline-start: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: #60a5fa;
}
html[dir="rtl"] .sidebar-link.active::before { border-radius: 3px 0 0 3px; }
.sidebar-link-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; transition: transform .15s ease; }

/* Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

/* Quick toggles: dark mode + language, icon-only, side by side */
.sidebar-quick-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.sidebar-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 0;
  border-radius: 10px;
  color: var(--sb-muted);
  cursor: pointer;
  border: none; background: rgba(255,255,255,.04);
  font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.sidebar-quick-btn svg { width: 19px; height: 19px; display: block; }
.sidebar-quick-btn:hover { background: var(--sb-hover); color: #fff; }
/* WhatsApp Channel shortcut — always in WhatsApp green */
.sidebar-wa-btn, .sidebar-wa-btn:hover { color: #25D366; }

/* User row (avatar + name/role + inline sign-out) */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 9px 9px 13px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  margin: 0;
}
html[dir="rtl"] .sidebar-user { padding: 9px 13px 9px 9px; }
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.sidebar-user-role.admin      { color: #fbbf24; }
.sidebar-user-role.instructor { color: #c4b5fd; }
.sidebar-user-role.trainee    { color: #60a5fa; }

/* Sign out — compact icon button inline with the user row */
.sidebar-signout-btn {
  width: 30px; height: 30px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: none; background: none;
  color: var(--sb-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-signout-btn svg {
  width: 16px; height: 16px; display: block;
}
.sidebar-signout-btn:hover { background: var(--sb-hover); color: #fff; transform: translateX(1px); }
html[dir="rtl"] .sidebar-signout-btn:hover { transform: translateX(-1px); }

/* Notification bell */
.notif-bell-btn { position: relative; }
.notif-bell-btn svg { width: 19px; height: 19px; display: block; }
.notif-badge {
  position: absolute; top: 3px; inset-inline-end: 3px;
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 600; line-height: 15px; text-align: center;
  border: 2px solid #0b1220;
}
.notif-panel {
  position: fixed; z-index: 210;
  inset-inline-start: calc(var(--sidebar-w) + 10px); bottom: 68px;
  width: 320px; max-width: calc(100vw - var(--sidebar-w) - 20px);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(6px) scale(.98); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  overflow: hidden;
}
.notif-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.notif-mark-read {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 500; color: var(--primary); padding: 0;
}
.notif-mark-read:disabled { color: var(--text-subtle); cursor: default; }
.notif-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.notif-list::-webkit-scrollbar { width: 6px; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 6px; }
.notif-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-subtle); padding: 8px 8px 4px;
}
.notif-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s ease;
}
.notif-item:hover { background: var(--bg-subtle); }
.notif-dot, .notif-dot-spacer { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.notif-dot { background: var(--primary); }
.notif-item-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.notif-item-icon svg { width: 15px; height: 15px; }
.notif-icon-lesson { background: var(--primary-light); color: var(--primary); }
.notif-icon-quiz   { background: var(--success-light); color: var(--success); }
.notif-icon-nudge  { background: var(--warning-light); color: var(--warning); }
.notif-item.read .notif-item-icon { background: var(--bg-subtle); color: var(--text-muted); }
.notif-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.notif-item-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.notif-item-subtitle {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item.read .notif-item-title { font-weight: 500; color: var(--text-muted); }
.notif-item.read .notif-item-subtitle { color: var(--text-subtle); }
.notif-item-time { font-size: 10.5px; color: var(--text-subtle); flex-shrink: 0; padding-top: 1px; }
.notif-empty { padding: 28px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* Bell tabs (Activity / What's new) */
.notif-tabs { display: flex; gap: 4px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); }
.notif-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 4px 8px; background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
}
.notif-tab:hover { color: var(--text); }
.notif-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.notif-tab-count {
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 10px; line-height: 16px; text-align: center;
}

/* What's new — announcement cards */
.notif-icon-feature { background: var(--primary-light); font-size: 15px; }
.notif-item.read .notif-icon-feature { background: var(--bg-subtle); }
.feat-desc { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); margin-top: 2px; }
.feat-cta { font-size: 11.5px; font-weight: 600; color: var(--primary); margin-top: 5px; }
html[dir="rtl"] .feat-cta { direction: rtl; }
.feat-new-pill {
  display: inline-block; margin-inline-start: 6px; padding: 0 6px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 9.5px; font-weight: 700; line-height: 15px;
  text-transform: uppercase; letter-spacing: .3px; vertical-align: 1px;
}

/* "New" tag on a sidebar link */
.sidebar-new-badge {
  margin-inline-start: auto; padding: 0 6px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 9.5px; font-weight: 700; line-height: 16px;
  text-transform: uppercase; letter-spacing: .3px; flex-shrink: 0;
}

/* Mobile hamburger */
.sidebar-hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 300;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  box-shadow: var(--shadow-sm);
}
.sidebar-hamburger span {
  display: block;
  width: 18px; height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.sidebar-hamburger.hidden { display: none !important; }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 190;
}
.sidebar-overlay.open { display: block; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════ */
#app    { min-height: 100vh; display: flex; width: 100%; }
#nav    { flex-shrink: 0; }
#page-wrap { margin-left: var(--sidebar-w); flex: 1; min-width: 0; min-height: 100vh; background: var(--bg); }

.page      { max-width: 980px;  margin: 0 auto; padding: 32px 24px; }
.page-wide { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
/* Fluid container for data-dense admin views — uses the full desktop width
   (capped for very large screens) with comfortable side gutters. */
.page-fluid { width: 100%; max-width: 1440px; margin: 0 auto; padding: 32px clamp(24px, 4vw, 48px); }

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 26px; margin-bottom: 6px; }
.page-header p  { color: var(--text-muted); font-size: 14px; }

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-sm { padding: 16px; }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  line-height: 1;
}
.btn:hover  { opacity: .9; transform: translateY(-1px); }
.btn:active { opacity: 1;  transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary);   color: #fff; box-shadow: 0 1px 3px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success);   color: #fff; }
.btn-danger  { background: var(--danger);    color: #fff; }
.btn-warning { background: var(--warning);   color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); opacity:1; transform:none; }
.btn-sm  { padding: 6px 12px; font-size: 12.5px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-xl  { padding: 14px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-block { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════ */
label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group { margin-bottom: 18px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 11px 16px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ── Quizzes management table — efficient column distribution ─────────── */
/* Wide enough that no column gets squeezed; narrower screens (14" laptops) scroll
   sideways while the title column stays pinned. `separate` keeps the pinned
   cell's borders painted while it slides over the others. */
.ql-table { min-width: 1030px; border-collapse: separate; border-spacing: 0; }
.ql-table th, .ql-table td { white-space: nowrap; }
.ql-table .ql-col-title {
  white-space: normal; font-weight: 600; min-width: 240px;          /* Title takes the slack + may wrap */
  position: sticky; inset-inline-start: 0; z-index: 2;
  background: var(--card); border-inline-end: 1px solid var(--border);
}
.ql-table thead th.ql-col-title { background: var(--bg); }
.ql-table tbody tr:hover td.ql-col-title { background: var(--bg); }
.ql-id { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-inline-end: 4px; }  /* quiz #id before its title */.ql-table tbody td { padding-top: 15px; padding-bottom: 15px; }     /* a touch more air on the wider layout */
.ql-status-date { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }  /* publish/end date under the status pill */
.ql-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
.ql-icon-btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ql-icon-btn svg { width: 18px; height: 18px; }

/* ══════════════════════════════════════════════════════════════
   ROW OVERFLOW MENU — the shared "⋮ more actions" popover
   Built once on <body> and positioned with position:fixed by
   components/row-menu.js, so it escapes both the card's
   overflow:hidden and .table-wrap's scroll clipping.
   z-index sits above the sidebar (200) and the notifications
   panel (210), but below modal overlays (300) so confirmModal
   still covers it.
   ══════════════════════════════════════════════════════════════ */
.row-menu {
  position: fixed; z-index: 250;
  min-width: 176px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px;
  opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.row-menu.drop-up { transform: translateY(4px) scale(.98); }
.row-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.row-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: start; background: none; border: none;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.row-menu-item svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-muted); }
.row-menu-item:hover,
.row-menu-item:focus-visible { background: var(--bg-subtle); outline: none; }
/* In dark mode --bg-subtle collapses onto --card, so the hover/focus row would
   be invisible; step up to --border instead. */
[data-theme="dark"] .row-menu-item:hover,
[data-theme="dark"] .row-menu-item:focus-visible { background: var(--border); }
.row-menu-item.danger,
.row-menu-item.danger svg { color: var(--danger); }
.row-menu-item.danger:hover,
.row-menu-item.danger:focus-visible { background: var(--danger-light); }
/* --danger holds at #dc2626 in dark mode, too dim for a text label on --card
   (2.4:1) — lift it the way the palette lifts its other dark reds, cf.
   --tag-7-text. */
[data-theme="dark"] .row-menu-item.danger,
[data-theme="dark"] .row-menu-item.danger svg { color: #f87171; }
.row-menu-sep { height: 1px; margin: 5px 6px; background: var(--border); }

/* ══════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red    { background: var(--danger-light);  color: var(--danger); }
.badge-gray   { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* Per-tag colors (view mode) — deterministic by tag text, see tagColorClass() */
.tag-c0 { background: var(--tag-0-bg); color: var(--tag-0-text); }
.tag-c1 { background: var(--tag-1-bg); color: var(--tag-1-text); }
.tag-c2 { background: var(--tag-2-bg); color: var(--tag-2-text); }
.tag-c3 { background: var(--tag-3-bg); color: var(--tag-3-text); }
.tag-c4 { background: var(--tag-4-bg); color: var(--tag-4-text); }
.tag-c5 { background: var(--tag-5-bg); color: var(--tag-5-text); }
.tag-c6 { background: var(--tag-6-bg); color: var(--tag-6-text); }
.tag-c7 { background: var(--tag-7-bg); color: var(--tag-7-text); }

/* ══════════════════════════════════════════════════════════════
   QUIZ LEADERBOARD — rank medals (see quiz-leaderboard.js)
   ══════════════════════════════════════════════════════════════ */
.lb-rank-cell { display:flex; align-items:center; justify-content:center; gap:6px; font-weight:700; }
.lb-medal { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; font-size:14px; }
.lb-rank-num { color:var(--text-muted); font-weight:700; }
.lb-row-1 { background: var(--warning-light); }
.lb-row-2 { background: var(--bg-subtle); }
.lb-row-3 { background: rgba(217,119,6,.06); }
.lb-best-quiz { display:flex; flex-direction:column; gap:2px; }
.lb-best-quiz-title { font-size:12px; color:var(--text-muted); }

/* Custom quiz picker (replaces a plain <select> so status/type can render as
   colored pills instead of parenthetical text) */
.lb-quiz-picker { position: relative; display: inline-block; min-width: 320px; max-width: 100%; }
.lb-quiz-picker-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card); color: var(--text);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left; outline: none;
}
.lb-quiz-picker-btn:hover { border-color: var(--primary); }
.lb-quiz-picker-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-quiz-picker-caret { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.lb-quiz-picker-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 100%; width: max-content; max-width: 480px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 6px; max-height: 320px; overflow-y: auto;
}
.lb-quiz-picker-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.lb-quiz-picker-row:hover { background: var(--bg-subtle); }
.lb-quiz-picker-row.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.lb-quiz-picker-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-quiz-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Type pill (targeted) — pairs with .cb-status-pill (draft/published) */
.cb-type-pill {
  display: inline-flex; align-items: center;
  border-radius: 20px; padding: 2px 9px; font-size: 10px; font-weight: 700;
  letter-spacing: .02em; flex-shrink: 0; white-space: nowrap;
}
.cb-type-pill.targeted { background: #dbeafe; color: #1d4ed8; }
[data-theme="dark"] .cb-type-pill.targeted { background: rgba(59,130,246,.22); color: #93c5fd; }

/* ══════════════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════════════ */
.alert {
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-info    { background: var(--info-light);    color: var(--info);    border: 1px solid #a5f3fc; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid #fecaca; }

/* ══════════════════════════════════════════════════════════════
   PROGRESS RING  (SVG)
   ══════════════════════════════════════════════════════════════ */
.progress-ring circle { fill: none; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-track { fill: none; stroke: var(--border); }
.ring-fill  { fill: none; stroke: var(--primary); }
.ring-label { font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: var(--text); }
.ring-sub   { font-size: 10px; fill: var(--text-muted); text-anchor: middle; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════ */
.dashboard-hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  margin-bottom: 32px;
  display: flex; align-items: center; gap: 32px;
  position: relative; overflow: hidden;
}
.dashboard-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 50%, rgba(255,255,255,.08) 0%, transparent 60%);
  pointer-events: none;
}
.dashboard-hero-text { flex: 1; position: relative; }
.dashboard-hero-text h2 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.dashboard-hero-text p  { opacity: .85; font-size: 14px; }
.dashboard-hero-text .level-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 12px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.dashboard-hero-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; position: relative; }

.hero-ring circle { fill: none; stroke-linecap: round; }
.hero-ring .track { stroke: rgba(255,255,255,.2); }
.hero-ring .fill  { stroke: #fff; transition: stroke-dashoffset .6s ease; }
.hero-ring text   { fill: #fff; font-weight: 700; text-anchor: middle; dominant-baseline: central; }

/* ── Dashboard overview blocks ────────────────────────────────────── */
@keyframes dashIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* KPI card grid — responsive, interactive */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 920px) { .dash-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .dash-kpis { grid-template-columns: 1fr; } }

.dash-kpi {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  padding: 18px 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: start; font: inherit; color: var(--text);
  position: relative; overflow: hidden;
  cursor: default;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  animation: dashIn .4s ease both;
}
.dash-kpi:nth-child(2) { animation-delay: .05s; }
.dash-kpi:nth-child(3) { animation-delay: .10s; }
.dash-kpi:nth-child(4) { animation-delay: .15s; }
/* coloured top accent line */
.dash-kpi::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px; background: var(--kpi, var(--primary)); opacity: .9; }
button.dash-kpi { cursor: pointer; }
button.dash-kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--kpi, var(--primary)); }
button.dash-kpi:active { transform: translateY(-1px); }

.dash-kpi-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 21px;
  background: var(--bg-subtle);
}
.dash-kpi-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.dash-kpi-value { font-size: 27px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.dash-kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-muted); }

.dash-kpi.accent-blue   { --kpi: #2563eb; }
.dash-kpi.accent-green  { --kpi: #16a34a; }
.dash-kpi.accent-orange { --kpi: #d97706; }
.dash-kpi.accent-purple { --kpi: #8b5cf6; }
.dash-kpi.accent-blue   .dash-kpi-icon { background: rgba(37, 99, 235, .12); }
.dash-kpi.accent-green  .dash-kpi-icon { background: rgba(22, 163, 74, .12); }
.dash-kpi.accent-orange .dash-kpi-icon { background: rgba(217, 119, 6, .14); }
.dash-kpi.accent-purple .dash-kpi-icon { background: rgba(139, 92, 246, .14); }
.dash-kpi.accent-teal   { --kpi: #0891b2; }
.dash-kpi.accent-teal   .dash-kpi-icon { background: rgba(8, 145, 178, .12); }

/* Continue-where-you-left-off card */
.dash-continue {
  padding: 18px 20px; margin-bottom: 16px;
  border-inline-start: 4px solid var(--primary);
  animation: dashIn .4s ease .18s both;
}
.dash-continue-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 10px; }
.dash-continue-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-continue-module { font-weight: 700; font-size: 15px; }
.dash-continue-next { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.dash-nudge { font-size: 12px; color: var(--warning, #d97706); margin-top: 7px; font-weight: 600; }

/* Engagement nudges */
.dash-nudges { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-nudge-card {
  flex: 1; min-width: 220px; padding: 15px 18px;
  text-align: start; font: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  animation: dashIn .4s ease .22s both;
}
.dash-nudge-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.dash-progress-link { text-align: center; margin-top: 8px; }

/* ── Growth dashboard (Phase 14) ──────────────────────────────────── */
:root { --purple: #8b5cf6; }
.dash-greet { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-greet h1 { font-size: 24px; margin: 0 0 4px; }
.dash-greet p { margin: 0; color: var(--text-muted); font-size: 14px; }
.dash-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dash-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-sm); }
.dash-chip.level  { background: #eef2ff; color: #4338ca; border-color: #e0e7ff; }
.dash-chip.skill  { background: #dcfce7; color: #16a34a; border-color: #bbf7d0; }
.dash-chip.streak { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
[data-theme="dark"] .dash-chip.level  { background: rgba(99,102,241,.18); border-color: transparent; color: #c7d2fe; }
[data-theme="dark"] .dash-chip.skill  { background: rgba(22,163,74,.18); border-color: transparent; color: #bbf7d0; }
[data-theme="dark"] .dash-chip.streak { background: rgba(217,119,6,.20); border-color: transparent; color: #fed7aa; }

/* Resume band */
.dash-resume { background: linear-gradient(135deg, var(--primary-dark, #1d4ed8) 0%, var(--primary, #3b82f6) 100%);
  color: #fff; border-radius: var(--radius-lg); padding: 24px 26px; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden; animation: dashIn .4s ease both; }
.dash-resume::after { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.08); }
.dash-resume-main { position: relative; z-index: 1; }
.dash-resume-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; opacity: .85; font-weight: 700; }
.dash-resume-title { margin: 6px 0 4px; font-size: 22px; }
.dash-resume-meta { font-size: 13px; opacity: .92; }
.dash-xp { margin-top: 14px; max-width: 440px; }
.dash-xp-bar { height: 9px; border-radius: 6px; background: rgba(255,255,255,.25); overflow: hidden; }
.dash-xp-bar > i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width .6s ease; }
.dash-xp-text { font-size: 12px; opacity: .9; margin-top: 6px; }
.dash-resume-btn { position: relative; z-index: 1; background: #fff; color: var(--primary-dark, #1d4ed8); font-weight: 700; }
.dash-resume-btn:hover { opacity: .92; }

/* Current quiz card (above the onboarding widget) */
.dash-quiz { background: var(--card); border: 1px solid var(--gift-border); border-inline-start: 5px solid var(--gift);
  border-radius: var(--radius-lg); padding: 18px 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; animation: dashIn .4s ease both; }
.dash-quiz-label { font-size: 12px; font-weight: 700; letter-spacing: .4px; color: var(--gift); }
.dash-quiz-title { margin: 6px 0 6px; font-size: 19px; }
.dash-quiz-meta { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dash-chip.reward { background: var(--gift-light); color: var(--gift); border-color: var(--gift-border); text-decoration: none; }

/* Onboarding Journey widget (between resume band & KPI cards) */
.dash-onboard { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm); animation: dashIn .4s ease .06s both; }
.ob-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1;
  border: 1px solid var(--border); background: var(--bg-subtle); color: var(--text-muted); cursor: pointer; }
.ob-close:hover, .ob-close:focus-visible { background: var(--danger, #dc2626); border-color: var(--danger, #dc2626); color: #fff; }
.ob-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-inline-end: 34px; }
.ob-head-txt h3 { margin: 0 0 3px; font-size: 16px; }
.ob-head-txt p { margin: 0; font-size: 13px; color: var(--text-muted); max-width: 520px; }
.ob-prog { text-align: end; flex-shrink: 0; }
.ob-prog-pct { display: block; font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.ob-prog-steps { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ob-bar { height: 8px; border-radius: 6px; background: var(--bg-subtle); overflow: hidden; margin: 14px 0 16px; }
.ob-bar > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width .6s ease; }

.ob-stepper { display: flex; align-items: flex-start; gap: 4px; flex-wrap: wrap; }
.ob-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; width: 84px; }
.ob-step-line { flex: 1 1 12px; min-width: 8px; height: 2px; margin-top: 15px; background: var(--border); border-radius: 2px; }
.ob-step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border: 2px solid var(--border); background: var(--card); color: var(--text-muted); }
.ob-step-lbl { font-size: 11px; line-height: 1.25; text-align: center; color: var(--text-muted);
  max-width: 80px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* states */
.ob-step.ob-completed .ob-step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.ob-step.ob-completed .ob-step-lbl { color: var(--text); }
.ob-step.ob-current .ob-step-dot { background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,.18); }
.ob-step.ob-current .ob-step-lbl { color: var(--primary); font-weight: 700; }
.ob-step.ob-locked .ob-step-dot { background: var(--bg-subtle); border-color: var(--border); color: var(--text-subtle); }

.ob-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.ob-footer-info { min-width: 0; }
.ob-footer-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
.ob-footer-title { display: block; font-size: 15px; margin: 2px 0; }
.ob-meta { font-size: 12.5px; color: var(--text-muted); }
.ob-footer-done { justify-content: center; text-align: center; color: var(--success); }

/* Interactive stepper: clickable dots lift on hover/focus */
.ob-viewplan { margin-top: 6px; padding: 2px 8px; font-size: 12px; }

/* Collapsed state: a slim reopen bar instead of the full card */
.dash-onboard-collapsed { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600; }
.dash-onboard-collapsed:hover { border-color: var(--primary); }
.ob-collapsed-hint { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.ob-step-clickable { cursor: pointer; }
.ob-step-clickable .ob-step-dot { transition: transform .15s ease, box-shadow .15s ease; }
.ob-step-clickable:hover .ob-step-dot { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ob-step-clickable:hover .ob-step-lbl { color: var(--text); }
.ob-step-clickable:focus-visible { outline: none; }
.ob-step-clickable:focus-visible .ob-step-dot { box-shadow: 0 0 0 3px rgba(37,99,235,.35); }

/* Onboarding plan popup (modal) */
.ob-plan-summary { margin-bottom: 14px; }
.ob-plan-summary-txt { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.ob-plan-list { display: flex; flex-direction: column; gap: 8px; }
.ob-plan-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.ob-plan-row.ob-current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.ob-plan-row.ob-locked { opacity: .65; }
.ob-plan-row-clickable { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.ob-plan-row-clickable:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.ob-plan-row-clickable:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.35); }
.ob-plan-dot { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700;
  border: 2px solid var(--border); background: var(--bg-subtle); color: var(--text-muted); }
.ob-plan-row.ob-completed .ob-plan-dot { background: var(--success); border-color: var(--success); color: #fff; }
.ob-plan-row.ob-current .ob-plan-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.ob-plan-main { min-width: 0; }
.ob-plan-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.ob-plan-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.ob-plan-type { text-transform: capitalize; }

/* KPI extras (build on .dash-kpi from above) */
.dash-kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.dash-kpi-mini { height: 5px; border-radius: 4px; background: var(--bg-subtle); overflow: hidden; margin-top: 9px; width: 100%; }
.dash-kpi-mini > i { display: block; height: 100%; border-radius: 4px; }
.wkdots { display: flex; gap: 5px; margin-top: 9px; }
.wkdot { width: 13px; height: 13px; border-radius: 50%; background: #fbbf24; border: 1.5px solid #f59e0b; }
.wkdot.off { background: var(--bg-subtle); border-color: var(--border); }
.up { color: var(--success); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }
.dash-kpi-goal { cursor: pointer; }
.dash-goal-ring { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

/* Two-column: Up Next + Keep Growing */
.dash-cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; margin-bottom: 22px; }
@media (max-width: 860px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); animation: dashIn .4s ease .1s both; }
.dash-panel h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.dash-empty { color: var(--text-muted); font-size: 13.5px; padding: 6px 0; }
.dash-un { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.dash-un:first-of-type { border-top: none; }
.dash-un-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.dash-un-txt { flex: 1; min-width: 0; }
.dash-un-txt b { font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-un-txt span { display: block; font-size: 12px; color: var(--text-muted); }

.dash-grow-item { padding: 13px 0; border-top: 1px solid var(--border); }
.dash-grow-item:first-of-type { border-top: none; }
.dash-grow-t { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.dash-mbar { height: 7px; border-radius: 5px; background: var(--bg-subtle); overflow: hidden; }
.dash-mbar > i { display: block; height: 100%; background: var(--success); border-radius: 5px; }
.dash-ach { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.dash-medal { width: 34px; height: 34px; border-radius: 9px; background: #fef3c7; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.dash-ach-sub { font-size: 12px; color: var(--text-muted); }
.dash-challenge { background: linear-gradient(135deg, #faf5ff, #f5f3ff); border: 1px solid #ede9fe; border-radius: 12px; padding: 13px 14px; display: flex; align-items: center; gap: 12px; }
[data-theme="dark"] .dash-challenge { background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.3); }
.dash-challenge-ic { width: 36px; height: 36px; border-radius: 9px; background: #ede9fe; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.dash-challenge-t { font-size: 13px; font-weight: 700; }
.dash-challenge-s { font-size: 12px; color: var(--text-muted); }
.dash-xp-tag { color: var(--purple); font-weight: 700; }

/* Skill chips */
.dash-skills { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px; animation: dashIn .4s ease .14s both; }
.dash-skills h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
/* Header row carries the latest badge, so mastery news sits on the mastery card
   instead of in a panel of its own. */
.dash-skills-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-skills-head .dash-ach { font-size: 13px; }
.dash-skills-head .dash-medal { width: 30px; height: 30px; font-size: 16px; }
.dash-skills .dash-grow-item { padding: 0 0 14px; border-top: none; }
.dash-skill-row { display: flex; gap: 14px; flex-wrap: wrap; }
.dash-skill { flex: 1; min-width: 170px; border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; background: var(--bg-subtle); }
.dash-skill-n { font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tier { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.tier-novice     { background: var(--bg-subtle); color: var(--text-muted); }
.tier-beginner   { background: #dbeafe; color: #2563eb; }
.tier-proficient { background: #dcfce7; color: #16a34a; }
.tier-advanced   { background: #ede9fe; color: #7c3aed; }
.tier-expert     { background: #fef3c7; color: #b45309; }
.dash-sbar { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 10px; }
.dash-sbar > i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.dash-sbar.tier-novice > i     { background: #94a3b8; }
.dash-sbar.tier-proficient > i { background: #16a34a; }
.dash-sbar.tier-advanced > i   { background: #7c3aed; }
.dash-sbar.tier-expert > i     { background: #d97706; }

/* ═══ COACHING NUDGES + PERSONAL TASKS ═══════════════════════════ */
.dash-coach-panel { margin-bottom: 22px; }
.dash-coach { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.dash-coach:first-of-type { border-top: none; padding-top: 2px; }
.dash-coach-ic {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-subtle); color: var(--text-muted);
}
.dash-coach.sev-critical .dash-coach-ic { background: var(--danger-light);  color: var(--danger); }
.dash-coach.sev-warning  .dash-coach-ic { background: var(--warning-light); color: var(--warning); }
.dash-coach.sev-info     .dash-coach-ic { background: var(--primary-light); color: var(--primary); }
.dash-coach.sev-positive .dash-coach-ic { background: var(--success-light); color: var(--success); }
.dash-coach-txt { flex: 1; min-width: 0; }
.dash-coach-txt b { display: block; font-size: 14.5px; font-weight: 600; }
.dash-coach-txt span { display: block; font-size: 13px; color: var(--text-muted); }
.dash-coach > .btn { flex-shrink: 0; align-self: center; }
.dash-coach-x {
  flex-shrink: 0; align-self: center; background: none; border: none; cursor: pointer;
  color: var(--text-subtle); font-size: 13px; line-height: 1; padding: 6px;
  border-radius: var(--radius-sm); transition: var(--transition);
}
.dash-coach-x:hover { background: var(--bg-subtle); color: var(--text); }

.dash-task-badge {
  margin-inline-start: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0;
  text-transform: none; padding: 2px 8px; border-radius: 20px;
  background: var(--danger-light); color: var(--danger);
}
.dash-task .dash-un-txt span:empty { display: none; }

/* `input { width: 100% }` further up stretches checkboxes too — every checkbox
   in the app has to opt out explicitly. */
.task-check { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; cursor: pointer; accent-color: var(--primary); }

.task-add { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.task-add-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.task-add-due { flex: 0 0 auto; width: 165px; }
.task-add-ref { flex: 1 1 220px; min-width: 0; }
.task-add-row .btn { flex: 0 0 auto; }

.task-group-label {
  font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-subtle); margin: 0 2px 8px;
}
.task-list { margin-bottom: 22px; padding-block: 4px; }
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.task-row:first-of-type { border-top: none; }
.task-row .task-check { margin-top: 3px; }
.task-txt { flex: 1; min-width: 0; }
.task-txt b { display: block; font-size: 14.5px; font-weight: 500; }
.task-row.is-done .task-txt b { color: var(--text-subtle); text-decoration: line-through; }
.task-note { display: block; font-size: 13px; color: var(--text-muted); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.task-overdue { color: var(--danger); font-weight: 600; }
.task-auto { color: var(--success); }
.task-ref { padding: 1px 8px; border-radius: 20px; background: var(--primary-light); color: var(--primary); }
.task-ref-quiz { background: var(--info-light); color: var(--info); }
.task-row > .btn { flex-shrink: 0; }
.task-del {
  flex-shrink: 0; background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--text-subtle); padding: 5px 6px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.task-del:hover { background: var(--danger-light); color: var(--danger); }

@media (max-width: 560px) {
  .task-add-due, .task-add-ref { flex: 1 1 100%; width: auto; }
}

.btn-hero {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  font-size: 14px;
}
.btn-hero:hover { background: rgba(255,255,255,.28); opacity:1; transform: none; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-icon  { font-size: 24px; margin-bottom: 10px; }
.stat-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ══════════════════════════════════════════════════════════════
   MODULE GRID
   ══════════════════════════════════════════════════════════════ */
/* Four cards per row on desktop, stepping down with the viewport. A fixed
   column count (rather than auto-fill) keeps the row even now that the grid
   sits in the full-width .page-fluid container. */
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 1280px) { .module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px)  { .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.module-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  display: flex; flex-direction: column; gap: 14px;
}
.module-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-mid);
  transform: translateY(-3px);
}
/* Draft modules (staff preview only): faded + dashed border */
.module-card-draft {
  opacity: 0.6;
  border-style: dashed;
}
.module-card-draft:hover { opacity: 1; }
.module-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; }
.module-card-top > .btn { flex-shrink: 0; }
.module-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* The icon is meant to be a single emoji; a module saved with a longer string
   in that field must still not push the card past its grid column. */
.module-icon {
  font-size: 38px; line-height: 1;
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.module-pct-ring { flex-shrink: 0; }
.module-title { font-size: 16px; font-weight: 700; color: var(--text); }
/* Clamped so one long description can't stretch every card in its row. */
.module-desc  {
  font-size: 13px; color: var(--text-muted); line-height: 1.5; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}
.module-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.module-courses-text { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Cards / list view toggle */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: var(--card); color: var(--text-muted); border: none; cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.view-toggle-btn svg { width: 17px; height: 17px; }
.view-toggle-btn + .view-toggle-btn { border-inline-start: 1px solid var(--border); }
.view-toggle-btn:hover { background: var(--bg-subtle); color: var(--text); }
.view-toggle-btn.active { background: var(--primary); color: #fff; }

/* Module list (row) layout */
.module-list { display: flex; flex-direction: column; gap: 10px; }
.module-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 18px; cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.module-row:hover { box-shadow: var(--shadow-sm); border-color: var(--primary-mid); }
.module-row-draft { opacity: 0.6; border-style: dashed; }
.module-row-draft:hover { opacity: 1; }
.module-row-icon { font-size: 26px; line-height: 1; flex-shrink: 0; }
.module-row-body { flex: 1; min-width: 0; }
.module-row-title { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.module-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.module-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════
   MODULE DETAIL / LESSONS
   ══════════════════════════════════════════════════════════════ */
.course-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.course-block-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.course-block-title { font-size: 15px; font-weight: 700; }
.course-block-meta  { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.course-block-pct   { font-size: 20px; font-weight: 800; color: var(--primary); flex-shrink: 0; }

.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item:hover { background: var(--primary-light); }

.lesson-status-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
  transition: all var(--transition);
  background: var(--card);
}
.lesson-status-dot.done { background: var(--success); border-color: var(--success); color: #fff; }
.lesson-status-dot.current { border-color: var(--primary); color: var(--primary); }

.lesson-info { flex: 1; }
.lesson-name  { font-size: 14px; font-weight: 500; color: var(--text); }
.lesson-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.lesson-score-pill {
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  flex-shrink: 0;
}
.lesson-score-pill.pass { background: var(--success-light); color: var(--success); }
.lesson-score-pill.fail { background: var(--danger-light);  color: var(--danger); }

.lesson-arrow { color: var(--text-subtle); font-size: 16px; }

/* ══════════════════════════════════════════════════════════════
   MODULE DETAIL — REDESIGN  (chapter cards + progress)
   ══════════════════════════════════════════════════════════════ */
.md-page { max-width: 1280px; margin: 0 auto; padding: 28px clamp(20px, 3vw, 40px); }

.md-back { margin-bottom: 18px; }

/* ── Module hero ─────────────────────────────────────────────── */
.md-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.md-hero-icon {
  width: 60px; height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; line-height: 1;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.md-hero-text { min-width: 0; }
.md-hero-text h1 { font-size: 28px; letter-spacing: -.4px; }
.md-hero-text p { color: var(--text-muted); font-size: 14.5px; margin-top: 5px; }
.md-hero-share { margin-inline-start: auto; flex-shrink: 0; align-self: center; }

/* Share buttons — module hero, chapter header, lesson topline */
.md-hero-share svg, .md-ch-share svg, .lv-share svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Chapter a shared link pointed at — flag it, then let the ring fade out. */
.md-chapter--highlight { box-shadow: 0 0 0 2px var(--primary); animation: md-ch-flash 2.2s ease forwards; }
@keyframes md-ch-flash {
  0%, 60% { box-shadow: 0 0 0 2px var(--primary); }
  100%    { box-shadow: var(--shadow-sm); }
}

/* ── Summary / continue band ─────────────────────────────────── */
.md-summary {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 24px 28px; margin-bottom: 26px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.md-summary::after {
  content: ""; position: absolute; inset-inline-end: -50px; top: -60px;
  width: 230px; height: 230px; border-radius: 50%;
  background: rgba(255,255,255,.08); pointer-events: none;
}
.md-summary-main { position: relative; z-index: 1; flex: 1; min-width: 240px; }
.md-summary-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; opacity: .85; }
.md-summary-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,.25); overflow: hidden; margin: 12px 0 14px; max-width: 520px; }
.md-summary-bar > i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width .6s ease; }
.md-summary-stats { display: flex; flex-wrap: wrap; gap: 22px; font-size: 13.5px; }
.md-summary-stats .st { display: inline-flex; align-items: baseline; gap: 6px; opacity: .92; }
.md-summary-stats .st b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.md-summary-stats .st.done b   { color: #bbf7d0; }
.md-summary-side { position: relative; z-index: 1; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.md-summary-pct { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.md-summary-pct span { font-size: 22px; font-weight: 700; opacity: .8; }
.md-continue-btn { background: #fff; color: var(--primary-dark); font-weight: 700; box-shadow: var(--shadow-md); }
.md-continue-btn:hover { background: #fff; opacity: .92; }
.md-summary.done { background: linear-gradient(135deg, #15803d 0%, var(--success) 100%); }
.md-summary-donetext h2 { font-size: 20px; margin-bottom: 3px; }
.md-summary-donetext p { font-size: 13.5px; opacity: .9; }
.md-review-btn { background: rgba(255,255,255,.18); border: 1.5px solid rgba(255,255,255,.35); color: #fff; }
.md-review-btn:hover { background: rgba(255,255,255,.28); opacity: 1; }

@media (max-width: 640px) {
  .md-summary { flex-direction: column; align-items: stretch; }
  .md-summary-side { justify-content: space-between; }
  .md-continue-btn, .md-review-btn { flex: 1; justify-content: center; }
}

/* ── Chapter cards ───────────────────────────────────────────── */
.md-chapters { display: flex; flex-direction: column; gap: 16px; }
.md-section-group { display: flex; flex-direction: column; gap: 16px; }
.md-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 8px 2px 0;
}
.md-section-group:first-child .md-section-title { margin-top: 0; }
.md-chapter {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.md-chapter:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); }

.md-ch-head {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px; cursor: pointer;
  user-select: none; background: none; border: none; width: 100%;
  font-family: inherit; text-align: start; color: var(--text);
  transition: background var(--transition);
}
.md-ch-head:hover { background: var(--bg); }
.md-ch-chevron {
  display: inline-block; width: 8px; height: 8px; flex-shrink: 0;
  border-top: 2px solid var(--text-muted); border-right: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform .25s ease;
}
.md-chapter--open .md-ch-chevron { transform: rotate(135deg); }
html[dir="rtl"] .md-ch-chevron { transform: rotate(-135deg); }
html[dir="rtl"] .md-chapter--open .md-ch-chevron { transform: rotate(135deg); }

/* The head is a full-width <button>, so the chapter's Share control sits beside
   it rather than inside it (a nested button would be invalid HTML). */
.md-ch-headrow { display: flex; align-items: center; }
.md-ch-headrow .md-ch-head { flex: 1; min-width: 0; }
.md-ch-share { flex-shrink: 0; margin-inline-end: 14px; }

.md-ch-titlewrap { flex: 1; min-width: 0; }
.md-ch-title { font-size: 16px; font-weight: 700; line-height: 1.35; }
.md-ch-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; display: inline-flex; align-items: center; gap: 8px; }
.md-ch-donechip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px;
  background: var(--success-light); color: var(--success);
}
.md-ch-progress { display: flex; align-items: center; gap: 12px; flex-shrink: 0; width: clamp(120px, 22vw, 220px); }
.md-ch-bar { flex: 1; height: 8px; border-radius: 6px; background: var(--bg-subtle); overflow: hidden; }
.md-ch-bar > i { display: block; height: 100%; border-radius: 6px; transition: width .6s ease; }
.md-ch-pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 38px; text-align: end; }
.md-state-done > i    { background: var(--success); }
.md-state-progress > i{ background: var(--primary); }
.md-state-idle > i    { background: var(--text-subtle); }
.md-ch-progress.is-done    .md-ch-pct { color: var(--success); }
.md-ch-progress.is-progress .md-ch-pct { color: var(--primary); }
.md-ch-progress.is-idle    .md-ch-pct { color: var(--text-muted); }

@media (max-width: 560px) {
  .md-ch-progress { width: 96px; }
  .md-ch-pct { min-width: 32px; }
  /* Icon-only on phones so the progress bar keeps its width. */
  .md-ch-share .share-label { display: none; }
  .md-ch-share { padding: 6px 8px; margin-inline-end: 10px; }
}

/* Collapsible body — animates without knowing content height */
.md-ch-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s ease; }
.md-chapter--open .md-ch-body { grid-template-rows: 1fr; }
.md-ch-bodyinner { overflow: hidden; min-height: 0; border-top: 1px solid var(--border); }

/* ── Lesson rows ─────────────────────────────────────────────── */
.md-lesson {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 22px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  position: relative;
}
.md-lesson:last-child { border-bottom: none; }
.md-lesson:hover { background: var(--primary-light); }
.md-lesson--done { background: var(--bg); }
.md-lesson--done:hover { background: var(--bg-subtle); }
.md-lesson--current { background: var(--primary-light); }
.md-lesson--current::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 3px; background: var(--primary);
}

.md-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-subtle);
  transition: all var(--transition);
}
.md-dot--done { background: var(--success); border-color: var(--success); color: #fff; }
.md-dot--current { border-color: var(--primary); color: var(--primary); }

.md-lesson-main { flex: 1; min-width: 0; }
.md-lesson-title { font-size: 14px; font-weight: 600; color: var(--text); }
.md-lesson--done .md-lesson-title { color: var(--text-muted); font-weight: 500; }
.md-lesson--current .md-lesson-title { color: var(--primary-dark); font-weight: 700; }
.md-lesson-meta { display: flex; align-items: center; gap: 10px; margin-top: 3px; }
.md-kind { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }

.md-lesson-badge { flex-shrink: 0; }
.md-pill {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}
.md-pill.current { background: var(--primary-light); color: var(--primary); }
.md-lesson-score { flex-shrink: 0; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.md-lesson-score.pass { background: var(--success-light); color: var(--success); }
.md-lesson-score.fail { background: var(--danger-light);  color: var(--danger); }
.md-lesson-chev {
  width: 7px; height: 7px; flex-shrink: 0;
  border-top: 2px solid var(--text-subtle); border-right: 2px solid var(--text-subtle);
  transform: rotate(45deg);
}
html[dir="rtl"] .md-lesson-chev { transform: rotate(-135deg); }

/* Collapsed "completed" group within a chapter */
.md-completed-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 11px 22px; cursor: pointer;
  background: var(--bg); border: none; border-bottom: 1px solid var(--border);
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  text-align: start; transition: background var(--transition);
}
.md-completed-toggle:hover { background: var(--bg-subtle); color: var(--text); }
.md-completed-toggle .md-ch-chevron { width: 7px; height: 7px; border-color: var(--text-muted); }
.md-completed-group.collapsed { display: none; }

/* ══════════════════════════════════════════════════════════════
   LESSON VIEWER
   ══════════════════════════════════════════════════════════════ */
.lesson-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 28px; align-items: start; }
@media (max-width: 1080px) { .lesson-layout { grid-template-columns: minmax(0,1fr) 300px; gap: 22px; } }
@media (max-width: 920px)  { .lesson-layout { grid-template-columns: 1fr; } }
.lesson-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  line-height: 1.85;
  box-shadow: var(--shadow-sm);
}
.lesson-content h2 { font-size: 22px; margin: 32px 0 12px; color: var(--text); }
.lesson-content h2:first-child { margin-top: 0; }
.lesson-content h3 { font-size: 17px; margin: 24px 0 10px; color: var(--primary); }
.lesson-content p  { margin-bottom: 14px; color: var(--text); }
.lesson-content ul, .lesson-content ol { padding-left: 22px; margin-bottom: 14px; }
.lesson-content li { margin-bottom: 6px; color: var(--text); }
.lesson-content strong { color: var(--text); }
.lesson-content code {
  background: var(--bg-subtle); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px; font-size: 13px; font-family: monospace;
}
.lesson-content blockquote {
  border-left: 3px solid var(--primary); margin: 16px 0;
  padding: 10px 18px; background: var(--primary-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--primary-dark);
}
/* ── Rich-text authored content (HTML from the Quill editor) ──────────────── */
.lesson-content h1 { font-size: 27px; margin: 32px 0 14px; color: var(--text); }
.lesson-content h1:first-child { margin-top: 0; }
.lesson-content a { color: var(--primary); text-decoration: underline; }
.lesson-content u { text-decoration: underline; }
/* Embedded images / GIFs: scale down to the column, never crop or stretch */
.lesson-content img {
  max-width: 100%; height: auto; display: inline-block;
  border-radius: var(--radius-sm); margin: 4px 0;
}
/* Nested-list markers (semantic <ul>/<ol> produced by normalizeQuillHtml) */
.lesson-content ul { list-style: disc; }
.lesson-content ul ul { list-style: circle; }
.lesson-content ul ul ul { list-style: square; }
.lesson-content ol { list-style: decimal; }
.lesson-content ol ol { list-style: lower-alpha; }
.lesson-content ol ol ol { list-style: lower-roman; }
.lesson-content li > ul, .lesson-content li > ol { margin: 6px 0 0; }
/* RTL paragraphs/blocks: mirror list padding so markers sit on the right */
.lesson-content [dir="rtl"] { text-align: right; }
.lesson-content ul[dir="rtl"], .lesson-content ol[dir="rtl"],
[dir="rtl"] .lesson-content ul, [dir="rtl"] .lesson-content ol {
  padding-left: 0; padding-right: 22px;
}

/* ── Lesson editor (Quill, themed to the app + dark mode via CSS vars) ────── */
.rte-host { display: block; }
.rte-host .ql-toolbar.ql-snow,
.rte-host .ql-container.ql-snow { border-color: var(--border); }
.rte-host .ql-toolbar.ql-snow {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.rte-host .ql-container.ql-snow {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: inherit; font-size: 15px;
}
.rte-host .ql-editor {
  min-height: 180px; color: var(--text); line-height: 1.7;
  unicode-bidi: plaintext;   /* correct caret/order for mixed AR/EN text */
}
.rte-host .ql-editor.ql-blank::before { color: var(--text-muted); font-style: normal; }
/* Toolbar icon colours follow the theme */
.rte-host .ql-snow .ql-stroke { stroke: var(--text-muted); }
.rte-host .ql-snow .ql-fill   { fill: var(--text-muted); }
.rte-host .ql-snow .ql-picker { color: var(--text); }
.rte-host .ql-snow .ql-picker-options {
  background: var(--card); border-color: var(--border);
}
.rte-host .ql-snow button:hover .ql-stroke,
.rte-host .ql-snow button.ql-active .ql-stroke,
.rte-host .ql-snow button.rte-painter-active .ql-stroke,
.rte-host .ql-snow .ql-picker-label:hover .ql-stroke { stroke: var(--primary); }
.rte-host .ql-snow button:hover .ql-fill,
.rte-host .ql-snow button.ql-active .ql-fill,
.rte-host .ql-snow button.rte-painter-active .ql-fill { fill: var(--primary); }
/* Paint-format button: pinned "picked up a format, pick a target" indicator that Quill's
   own toolbar refresh (which only knows about `ql-active`) can't stomp on every selection change. */
.rte-host .ql-snow button.rte-painter-active { background: var(--primary-light); border-radius: var(--radius-sm); }
.rte-host .ql-snow .ql-picker-label:hover,
.rte-host .ql-snow .ql-picker-item:hover,
.rte-host .ql-snow .ql-picker-item.ql-selected { color: var(--primary); }
/* Label the custom px-size and line-height pickers by their value */
.rte-host .ql-snow .ql-picker.ql-size .ql-picker-label::before,
.rte-host .ql-snow .ql-picker.ql-size .ql-picker-item::before,
.rte-host .ql-snow .ql-picker.ql-lineheight .ql-picker-label::before,
.rte-host .ql-snow .ql-picker.ql-lineheight .ql-picker-item::before { content: attr(data-value); }
.rte-host .ql-snow .ql-picker.ql-size  { width: 64px; }
.rte-host .ql-snow .ql-picker.ql-size  .ql-picker-label:not([data-value])::before { content: '16px'; }
.rte-host .ql-snow .ql-picker.ql-lineheight { width: 52px; }
.rte-host .ql-snow .ql-picker.ql-lineheight .ql-picker-label:not([data-value])::before { content: '↕'; }
/* Embedded images (incl. animated GIFs) never overflow the editor column */
.rte-host .ql-editor img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
/* Upload progress / failure line under the editor */
.rte-status {
  margin-top: 6px; font-size: 13px; color: var(--text-muted);
}
.rte-status.rte-status-error { color: var(--danger); }

.lesson-sidebar { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 920px) { .lesson-sidebar { position: static; } }

.lv-main { min-width: 0; }

/* ── Lesson viewer — top line (back + breadcrumb) ── */
.lv-topline { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.lv-back { flex-shrink: 0; }
.lv-share { flex-shrink: 0; margin-inline-start: auto; }
.lv-topline-div { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; }
.lv-crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-subtle); flex-wrap: wrap; min-width: 0; }
.lv-crumbs a { color: var(--text-muted); cursor: pointer; font-weight: 500; white-space: nowrap; transition: color var(--transition); }
.lv-crumbs a:hover { color: var(--primary); text-decoration: none; }
.lv-crumbs .sep { color: var(--text-subtle); opacity: .5; font-size: 12px; }
.lv-crumbs .crumb-current { color: var(--text); font-weight: 600; white-space: nowrap; }

/* ── Lesson viewer — hero header ── */
.lv-hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding-bottom: 24px; margin-bottom: 30px; border-bottom: 1px solid var(--border);
}
.lv-hero-text { min-width: 0; }
.lv-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--primary); margin-bottom: 10px;
}
.lv-eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.lv-hero h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.5px; margin: 0; font-weight: 800; color: var(--text); }
.lv-meta { display: flex; align-items: center; flex-wrap: wrap; row-gap: 4px; margin-top: 14px; }
.lv-meta-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; color: var(--text-muted); }
.lv-meta-item:not(:last-child)::after { content: "•"; margin: 0 12px; color: var(--text-subtle); opacity: .6; font-size: 11px; }
.lv-meta-xp { color: var(--warning); font-weight: 600; }

@media (max-width: 560px) {
  .lv-hero { flex-direction: column; gap: 14px; }
  .lv-hero h1 { font-size: 24px; }
}

/* ── Lesson viewer — section divider heading ── */
.lv-sec { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-subtle); margin: 28px 0 14px; }
.lv-sec .line { flex: 1; height: 1px; background: var(--border); }

/* ── Lesson viewer — knowledge-check banner ── */
.lv-kcheck {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--primary-light), var(--card) 70%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 6px; box-shadow: var(--shadow-sm);
}
.lv-kcheck .kico { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.lv-kcheck .ktext { flex: 1; min-width: 180px; }
.lv-kcheck h3 { font-size: 17px; margin-bottom: 3px; }
.lv-kcheck p { font-size: 13.5px; color: var(--text-muted); }

/* ── Lesson viewer — linked (gating) quizzes ── */
.lv-linked-quizzes { display: flex; flex-direction: column; gap: 10px; }
.lv-linked-quiz {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.lv-linked-quiz .lv-lq-body { flex: 1; min-width: 0; }
.lv-linked-quiz .lv-lq-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lv-linked-quiz .lv-lq-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv-lq-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.lv-lq-tag.req { background: rgba(220, 38, 38, .12); color: var(--danger); }
.lv-lq-tag.opt { background: var(--border); color: var(--text-muted); }
.lv-gate-hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* ── Lesson viewer — prev / next navigation cards ── */
.lv-navcards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 26px; }
.lv-navcards.single { grid-template-columns: 1fr; }
@media (max-width: 560px) { .lv-navcards { grid-template-columns: 1fr; } }
.lv-navcard {
  display: flex; flex-direction: column; gap: 5px; padding: 16px 18px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.lv-navcard:hover { border-color: var(--primary-mid); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lv-navcard .dir { font-size: 12px; color: var(--text-subtle); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.lv-navcard .ttl { font-size: 14.5px; font-weight: 600; color: var(--text); }
.lv-navcard.next { text-align: end; align-items: flex-end; }
.lv-navcard.disabled { opacity: .45; pointer-events: none; }

/* ── Lesson viewer — sidebar: course progress card ── */
.lv-progress { padding: 20px; }
.lv-progress .pc-head { display: flex; align-items: center; gap: 16px; }
.lv-progress .pc-meta { flex: 1; min-width: 0; }
.lv-progress .pc-meta .mod { font-size: 12px; color: var(--text-subtle); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.lv-progress .pc-meta .crs { font-size: 16px; font-weight: 700; margin: 2px 0; line-height: 1.3; }
.lv-progress .pc-meta .cnt { font-size: 13px; color: var(--text-muted); }
.lv-pcbar { height: 8px; background: var(--bg-subtle); border-radius: 5px; overflow: hidden; margin-top: 16px; }
.lv-pcbar > div { height: 100%; background: linear-gradient(90deg, var(--success), #4ade80); border-radius: 5px; transition: width .5s ease; }

/* ── Lesson viewer — sidebar: course outline ── */
.lv-outline { overflow: hidden; }
.lv-outline-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-subtle); display: flex; justify-content: space-between; align-items: center;
}
.lv-outline-head .cnt { color: var(--text-muted); }
.lv-oitem {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: var(--transition); position: relative;
}
.lv-oitem:last-child { border-bottom: none; }
.lv-oitem:hover { background: var(--bg); }
.lv-oitem.current { background: var(--primary-light); cursor: default; }
.lv-oitem.current::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.lv-omark {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  border: 2px solid var(--border); color: var(--text-subtle); background: var(--card);
}
.lv-omark.done { background: var(--success); border-color: var(--success); color: #fff; }
.lv-omark.current { border-color: var(--primary); color: var(--primary); }
.lv-obody { flex: 1; min-width: 0; }
.lv-otitle { font-size: 13.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-oitem.current .lv-otitle { font-weight: 700; color: var(--primary-dark); }
.lv-osub { font-size: 11.5px; color: var(--text-subtle); display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.lv-oscore { font-size: 11px; font-weight: 700; color: var(--success); background: var(--success-light); border-radius: 20px; padding: 1px 7px; }

/* ── Lesson viewer — sidebar: up-next card ── */
.lv-upnext { padding: 18px; }
.lv-upnext .un-lbl { font-size: 12px; color: var(--text-subtle); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; }
.lv-upnext .un-ttl { font-size: 15px; font-weight: 700; margin-bottom: 4px; line-height: 1.35; }
.lv-upnext .un-meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }

/* Lesson completion */
.lesson-completed-badge {
  flex-shrink: 0; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--success-light); color: var(--success);
  border: 1px solid #bbf7d0; border-radius: 30px;
  padding: 6px 14px; font-size: 13px; font-weight: 700;
  white-space: nowrap;
}
.lesson-complete-wrap { margin-top: 32px; }
.lesson-complete-cta {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 32px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: var(--shadow-sm);
}
.lesson-complete-cta p {
  flex: 1; margin: 0; color: var(--text-muted); font-size: 14px;
}
.lesson-complete-cta .btn { flex-shrink: 0; }
@media (max-width: 600px) {
  .lesson-complete-cta { flex-direction: column; align-items: stretch; gap: 14px; }
}

/* ── Lesson viewer — completion / next-step panel ── */
.lv-done {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; box-shadow: var(--shadow-sm);
}
.lv-done.celebrate {
  background: linear-gradient(120deg, var(--success-light), var(--card) 78%);
  border-color: #bbf7d0;
}
.lv-done-ico {
  flex-shrink: 0; width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: var(--success-light); color: var(--success);
}
.lv-done.celebrate .lv-done-ico { background: var(--success); color: #fff; }
.lv-done-body { flex: 1; min-width: 180px; }
.lv-done-body h3 { font-size: 17px; margin: 0 0 2px; color: var(--text); }
.lv-done-body p { margin: 0; font-size: 13.5px; color: var(--text-muted); }
.lv-done .btn { flex-shrink: 0; }
@media (max-width: 600px) {
  .lv-done { flex-direction: column; align-items: stretch; text-align: center; gap: 14px; }
  .lv-done-ico { align-self: center; }
}

/* ── Lesson views (admin-only: header button opens this modal) ── */
.lv-viewsbtn { flex-shrink: 0; margin-inline-start: auto; }
.lv-viewsbtn + .lv-share { margin-inline-start: 0; }
/* Tinted so admins notice it — the plain ghost style is what got it forgotten. */
.btn.lv-viewsbtn {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-mid);
  font-weight: 600;
}
.btn.lv-viewsbtn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
/* .modal is declared further down with equal specificity, so chain the class. */
.modal.lv-views-modal { max-width: 900px; padding: 24px 26px; }
.lv-views-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal .lv-views-head h3 { margin: 0 0 2px; }
.lv-views-hint { font-size: 12.5px; color: var(--text-subtle); }
.lv-views-body { min-height: 120px; }

.lv-vkpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.lv-vkpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.lv-vkpi-num   { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
.lv-vkpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-top: 4px; }
.lv-vkpi-sub   { font-size: 11.5px; color: var(--text-subtle); margin-top: 2px; min-height: 14px; }

.lv-vfilters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.lv-vchips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.lv-vchip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.lv-vchip span { opacity: .65; margin-inline-start: 4px; }
.lv-vchip:hover  { border-color: var(--primary); color: var(--primary); }
.lv-vchip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.lv-vchip.active span { opacity: .85; }
/* Global `input { width: 100% }` would stretch this across the row. */
.lv-vsearch { width: auto; flex: 0 1 220px; font-size: 13px; padding: 7px 10px; }

.lv-vtable-wrap { overflow-x: auto; }
.lv-vtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.lv-vtable th {
  text-align: start;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-subtle);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.lv-vtable td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lv-vtable tbody tr { cursor: pointer; }
.lv-vtable tbody tr:hover { background: var(--bg); }
.lv-vname { font-weight: 600; color: var(--text); }
.lv-vmail { font-size: 11.5px; color: var(--text-subtle); }
.lv-vnum  { font-variant-numeric: tabular-nums; }
.lv-vmore { margin-top: 12px; }
.lv-vempty { padding: 24px; text-align: center; color: var(--text-subtle); font-size: 13.5px; }

/* ══════════════════════════════════════════════════════════════
   QUIZ WIDGET
   ══════════════════════════════════════════════════════════════ */
.quiz-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.quiz-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}
.quiz-header h3 { font-size: 17px; margin-bottom: 4px; }
.quiz-header p  { font-size: 13px; opacity: .85; }
.quiz-progress-bar { height: 3px; background: rgba(255,255,255,.2); margin-top: 14px; border-radius: 2px; }
.quiz-progress-fill { height: 100%; background: #fff; border-radius: 2px; transition: width .4s ease; }

.quiz-body { padding: 24px; }
.quiz-question { margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.quiz-question:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.question-num  { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 6px; }
.question-text { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; line-height: 1.5; }

/* Question-type chip — tells the trainee the answer format up front */
.q-type-row { display: flex; margin-bottom: 8px; }
.q-type-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.6;
  background: var(--primary-light); color: var(--primary);
}
.q-type-chip.multi { background: var(--warning-light); color: var(--warning); }
.q-type-chip.text  { background: var(--bg-subtle);     color: var(--text-muted); }
.q-type-chip-hint  { font-weight: 500; opacity: .85; }
@media (max-width: 520px) {
  .q-type-chip-hint { display: none; }
}

.options-list { display: flex; flex-direction: column; gap: 9px; }
.option-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-family: inherit;
  text-align: start; background: var(--card);
  transition: all var(--transition); width: 100%;
  color: var(--text);
}
.option-btn .opt-text { flex: 1 1 auto; min-width: 0; line-height: 1.45; }
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.option-btn.correct  { border-color: var(--success); background: var(--success-light); color: var(--success); }
.option-btn.wrong    { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger); }
.option-btn:disabled { cursor: default; }

.option-letter {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.explanation {
  margin-top: 12px; padding: 11px 15px;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--primary-dark); line-height: 1.5;
}

.quiz-actions { padding: 0 24px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.quiz-result-panel { text-align: center; padding: 36px 24px; }
.score-ring-wrap { margin-bottom: 20px; }
.score-ring-wrap svg circle { fill: none; stroke-linecap: round; }
.score-ring-wrap .track { stroke: var(--border); }
.score-ring-wrap .pass { stroke: var(--success); }
.score-ring-wrap .fail { stroke: var(--danger); }
.score-ring-wrap text { font-weight: 800; text-anchor: middle; dominant-baseline: central; }
.quiz-result-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.quiz-result-sub   { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* ══════════════════════════════════════════════════════════════
   ONBOARDING WIZARD
   ══════════════════════════════════════════════════════════════ */
.onboarding-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 24px 80px;
}
.onboarding-wrap { width: 100%; max-width: 680px; }
.onboarding-logo {
  text-align: center; margin-bottom: 36px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.onboarding-logo .logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
.onboarding-logo .logo-name {
  font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.3px;
}
.onboarding-logo .logo-name span { color: var(--primary); }

/* Stepper */
.stepper {
  display: flex; align-items: center; margin-bottom: 36px;
}
.step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px; left: calc(50% + 18px); right: calc(-50% + 18px);
  height: 2px; background: var(--border); z-index: 0;
}
.step.done:not(:last-child)::after { background: var(--success); }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-muted); z-index: 1;
  transition: all .25s;
}
.step.done   .step-dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.active .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.step-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-align: center; }
.step.active .step-label { color: var(--primary); }
.step.done   .step-label { color: var(--success); }

/* Card */
.onboarding-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); padding: 40px;
}
.onboarding-card h2 { font-size: 24px; margin-bottom: 6px; }
.onboarding-card > p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* Placement progress */
.placement-progress {
  height: 5px; background: var(--border); border-radius: 3px; margin-bottom: 28px; overflow: hidden;
}
.placement-progress-fill {
  height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s ease;
}
.placement-counter {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-muted); margin-bottom: 8px;
}

/* Results */
.result-score {
  font-size: 72px; font-weight: 900; line-height: 1; margin-bottom: 6px;
}
.result-score.beginner     { color: var(--warning); }
.result-score.intermediate { color: var(--primary); }
.result-score.advanced     { color: var(--success); }
.result-level {
  display: inline-block; padding: 5px 18px; border-radius: 24px;
  font-weight: 700; font-size: 14px; margin-bottom: 20px;
}
.result-level.beginner     { background: var(--warning-light); color: var(--warning); }
.result-level.intermediate { background: var(--primary-light); color: var(--primary); }
.result-level.advanced     { background: var(--success-light); color: var(--success); }
.result-path-card {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  text-align: left; margin-bottom: 28px;
}
.result-path-card h3 { font-size: 17px; margin: 8px 0 6px; }
.result-path-card p  { font-size: 13.5px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   PROGRESS PAGE
   ══════════════════════════════════════════════════════════════ */
.progress-bar-wrap { flex: 1; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .5s ease; }
.progress-bar-fill.success { background: var(--success); }

/* ── Progress page (detailed tracker) ─────────────────────────────── */
.prog-summary { display: flex; align-items: center; gap: 24px; padding: 20px 24px; flex-wrap: wrap; }
.prog-summary-stats { display: flex; gap: 28px; flex-wrap: wrap; font-size: 14px; color: var(--text-muted); }
.prog-summary-stats strong { color: var(--text); font-size: 18px; }

.prog-module { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.prog-module-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; }
.prog-module-head:hover { background: var(--bg-subtle); }
.prog-module-bar { flex: 1; min-width: 0; }
.prog-module-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.prog-module-body { padding: 4px 16px 14px; }

.prog-course { padding: 8px 0 8px; border-top: 1px solid var(--border); }
.prog-course:first-child { border-top: none; }
.prog-course-head { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 0; }
.prog-course-head:hover .prog-course-title { color: var(--primary); }
.prog-course-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.prog-course-pct { font-size: 12px; color: var(--text-muted); width: 38px; text-align: end; }

.prog-lesson { display: flex; align-items: center; gap: 10px; padding: 6px 0 6px 28px; font-size: 13px; cursor: pointer; }
.prog-lesson:hover .prog-lesson-title { color: var(--primary); }
.prog-lesson-status { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; border: 1.5px solid var(--border); color: var(--text-muted); flex-shrink: 0; }
.prog-lesson-status.done { background: var(--success); border-color: var(--success); color: #fff; }
.prog-lesson-title { flex: 1; min-width: 0; }
.prog-lesson-score { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.prog-quiz-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.prog-quiz-row:last-child { border-bottom: none; }
.prog-quiz-sub { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-top: 10px; padding-top: 6px; }
html[dir="rtl"] .prog-lesson { padding: 6px 28px 6px 0; }

/* ══════════════════════════════════════════════════════════════
   PANEL TABS (admin / instructor)
   ══════════════════════════════════════════════════════════════ */
.panel-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.panel-tab {
  padding: 10px 20px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border: none;
  background: none; font-family: inherit;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.panel-tab:hover  { color: var(--text); }
.panel-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 24px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; padding: 30px;
}
.modal h3 { font-size: 20px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

.confirm-modal { max-width: 380px; padding: 26px; }

/* ── Quiz change log popup (quiz-list.js) — a vertical timeline, newest first ── */
.modal.qh-pop { max-width: 560px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.qh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.qh-head h3 { margin: 0; font-size: 17px; }
.qh-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qh-x { flex: 0 0 auto; border: 0; background: var(--bg-subtle); color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.qh-x:hover { color: var(--text); }
.qh-body { overflow-y: auto; padding: 8px 20px 16px; }
.qh-body .page-loading { min-height: 140px; padding: 0; }
.qh-list { list-style: none; margin: 0; padding: 0; }
.qh-item { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 0 12px 22px; }
[dir="rtl"] .qh-item { padding: 12px 22px 12px 0; }
.qh-item + .qh-item { border-top: 1px dashed var(--border); }
.qh-item::before { content: ''; position: absolute; inset-inline-start: 4px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.qh-item:first-child::before { top: 18px; }
.qh-item:last-child::before  { bottom: calc(100% - 18px); }
.qh-dot { position: absolute; inset-inline-start: 0; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--primary); }
.qh-main { flex: 1; min-width: 0; }
.qh-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qh-who { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.qh-when { flex: 0 0 auto; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; padding-top: 3px; }
.qh-empty { padding: 32px 0; text-align: center; color: var(--text-muted); }
.confirm-modal-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.confirm-modal-icon svg { width: 22px; height: 22px; }
.confirm-modal-icon--primary { background: var(--primary-light); color: var(--primary); }
.confirm-modal-icon--danger  { background: var(--danger-light); color: var(--danger); }
.confirm-modal-icon--warning { background: var(--warning-light); color: var(--warning); }
.confirm-modal-title { font-size: 16px; margin-bottom: 6px; }
.confirm-modal-message { font-size: 13.5px; color: var(--text-muted); line-height: 1.5; margin: 0; }
.confirm-modal-message b { color: var(--text); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .page, .page-wide, .page-fluid { padding: 20px 16px; }
  .dashboard-hero { flex-direction: column; padding: 28px 24px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-sidebar { position: static; }
  .lesson-content { padding: 24px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: 1fr; }
  .module-row { flex-wrap: wrap; }
  .module-row-actions { width: 100%; justify-content: flex-end; }
  .onboarding-card { padding: 28px 22px; }
  .course-builder { grid-template-columns: 1fr; }
  .cb-left { border-right: none; border-bottom: 1px solid var(--border); }

  /* Sidebar collapses off-screen on mobile */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-hamburger { display: flex; }
  #page-wrap { margin-left: 0; padding-top: 60px; }
  /* Content starts below the 60px mobile top bar, so shift each loading offset. */
  #page > .page-loading:first-child { --pl-top: 60px; }
  .page > .page-loading:first-child,
  .page-wide > .page-loading:first-child,
  .page-fluid > .page-loading:first-child { --pl-top: 92px; }
  .md-page > .page-loading:first-child { --pl-top: 88px; }

  .notif-panel { inset-inline-start: 12px; inset-inline-end: 12px; width: auto; max-width: none; bottom: 78px; }
}
@media (max-width: 480px) {
  .stat-strip { grid-template-columns: 1fr; }
  .login-quick { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   Course Builder
   ══════════════════════════════════════════════════════════════ */

/* Form primitives used by the builder */
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea.form-control { resize: vertical; }
.form-label-sm {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

/* Icon button (edit / delete) */
.icon-btn {
  width: 28px; height: 28px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-subtle); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* Content-type toggle buttons */
.btn-toggle {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-toggle:hover { border-color: var(--primary-mid); color: var(--primary); }
.btn-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ── Outer layout ── */
.course-builder {
  display: grid;
  grid-template-columns: 220px 1fr;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 540px;
  box-shadow: var(--shadow);
}

/* ── Left: Module list ── */
.cb-left {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.cb-panel-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 16px 8px;
}
.cb-module-list { flex: 1; overflow-y: auto; }
.cb-module-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 8px 16px;
  flex-wrap: wrap;
  cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text);
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.cb-module-item:hover { background: var(--bg); }
.cb-module-item.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.cb-module-icon { font-size: 16px; flex-shrink: 0; }
.cb-module-name {
  flex: 1; min-width: 0; font-size: 13px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.cb-new-module-btn { margin: 12px; width: calc(100% - 24px); justify-content: center; }

/* ── Module create/edit dialog ── */
.cb-module-modal { display: flex; flex-direction: column; gap: 12px; }
.cb-module-modal h3 { font-size: 18px; margin: 0; }
.cb-module-modal .modal-actions { margin-top: 6px; }
.cb-modal-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.cb-modal-head-icon {
  font-size: 22px; line-height: 1;
  width: 38px; height: 38px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-subtle); border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; padding: 0;
  transition: border-color var(--transition), background var(--transition);
}
.cb-modal-head-icon:hover { border-color: var(--border-hover); background: var(--primary-light); }

/* Icon field: a trigger that unfolds the grid on click */
.cb-icon-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 10px; font: inherit; font-size: 13px; text-align: start;
  color: var(--text); background: var(--card); cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cb-icon-trigger:hover { border-color: var(--border-hover); }
.cb-icon-trigger.is-open {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.cb-icon-trigger-emoji { font-size: 20px; line-height: 1; }
.cb-icon-trigger-label { flex: 1; color: var(--text-muted); }
.cb-icon-trigger-caret {
  color: var(--text-muted); font-size: 11px;
  transition: transform var(--transition);
}
.cb-icon-trigger.is-open .cb-icon-trigger-caret { transform: rotate(180deg); }
.cb-modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cb-modal-icon-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px;
  max-height: 168px; overflow-y: auto;
  margin-top: 4px; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.cb-modal-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
/* app.css sets input{width:100%} — checkboxes need to opt out */
.cb-modal-check input[type="checkbox"] {
  flex: 0 0 auto; width: 16px; height: 16px; margin: 0; cursor: pointer;
}
@media (max-width: 480px) {
  .cb-modal-row { grid-template-columns: 1fr; }
  .cb-modal-icon-grid { grid-template-columns: repeat(8, 1fr); }
}

.cb-field { display: flex; flex-direction: column; gap: 5px; }
.cb-field-label {
  font-size: 12px; font-weight: 600; color: var(--text);
  text-align: start;
}
.cb-input {
  width: 100%; font: inherit; font-size: 13px;
  color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; transition: border-color var(--transition), box-shadow var(--transition);
}
.cb-input::placeholder { color: var(--text-subtle); }
.cb-input:hover { border-color: var(--border-hover); }
.cb-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.cb-textarea { resize: vertical; min-height: 64px; line-height: 1.5; }

/* Slug: distinct from Title — prefixed, monospace */
.cb-slug-wrap {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cb-slug-wrap:hover { border-color: var(--border-hover); }
.cb-slug-wrap:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.cb-slug-prefix {
  display: flex; align-items: center; padding-inline: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; color: var(--text-muted);
  border-inline-end: 1px solid var(--border); background: var(--bg-subtle);
}
.cb-input-slug {
  border: none; border-radius: 0; background: var(--card);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cb-input-slug:focus { box-shadow: none; }

.cb-field-help { font-size: 11px; color: var(--text-muted); margin: 0; text-align: start; }
.cb-field-help.is-error { color: var(--danger); }

.cb-edit-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 4px;
}

/* ── Right: Courses panel ── */
.cb-right { display: flex; flex-direction: column; overflow: hidden; }
.cb-right-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
  background: var(--card);
  flex-shrink: 0;
}
.cb-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center;
}
.cb-course-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.cb-empty-courses {
  padding: 32px 24px; color: var(--text-muted);
  font-size: 14px; text-align: center;
}

/* ── Onboarding builder (admin) ── */
.ob-adm-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }
.ob-adm-section {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--card);
}
.ob-adm-section-head { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ob-adm-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.ob-adm-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ob-adm-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.ob-adm-check input { width: 15px; height: 15px; accent-color: var(--primary); }
.ob-adm-danger { color: var(--danger); }
.ob-adm-danger:hover { background: var(--danger-light, rgba(220,38,38,.1)); }

.ob-adm-steps { display: flex; flex-direction: column; gap: 8px; }
.ob-adm-step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-subtle);
}
.ob-adm-step-num {
  flex-shrink: 0; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--primary-light); color: var(--primary-dark);
  font-size: 12px; font-weight: 700;
}
.ob-adm-step-ic { font-size: 16px; flex-shrink: 0; }
.ob-adm-step-main { flex: 1; min-width: 0; }
.ob-adm-step-title { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ob-adm-step-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.ob-adm-step-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.ob-adm-form {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid var(--primary);
  border-radius: var(--radius-sm); background: var(--card);
}
.ob-adm-form-title { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.ob-adm-prereqs { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }

.ob-adm-assign-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-adm-assign-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 12.5px; font-weight: 600;
}
.ob-adm-assign-chip button {
  border: none; background: transparent; color: inherit;
  cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.ob-adm-assign-chip button:hover { background: rgba(0,0,0,.08); }
.ob-adm-assign-select { max-width: 280px; }

/* ── Generic collapsible section (Admin > XP & Rewards) ── */
.adm-collapse-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  cursor: pointer; user-select: none;
  transition: background var(--transition);
}
.adm-collapse-header:hover { background: var(--bg-subtle); }
.adm-collapse-title-wrap { display: flex; align-items: baseline; gap: 10px; flex: 1; }
.adm-collapse-title    { font-weight: 600; font-size: 15px; }
.adm-collapse-subtitle { font-size: 12.5px; color: var(--text-muted); }
.adm-collapse-body     { padding: 0 20px 20px; border-top: 1px solid var(--border); }
.adm-collapse-body > p:first-child { margin-top: 16px; }

/* ── Course accordion ── */
.cb-course { border-bottom: 1px solid var(--border); }
.cb-course:last-child { border-bottom: none; }
.cb-course-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  cursor: pointer; user-select: none;
  transition: background var(--transition);
}
.cb-course-header:hover { background: var(--bg-subtle); }
.cb-expand-icon { color: var(--text-muted); font-size: 11px; width: 14px; flex-shrink: 0; }
.cb-course-title { flex: 1; font-weight: 600; font-size: 14px; }
.cb-course-title-input {
  flex: 1; font-weight: 600; font-size: 14px;
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 4px 8px; outline: none;
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
.cb-lesson-count { font-size: 11px; }

/* ── Lessons inside a course ── */
.cb-lessons {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 4px 0 8px;
}
.cb-lesson-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px 8px 44px;
  font-size: 14px;
  transition: background var(--transition);
}
.cb-lesson-row:hover { background: var(--bg-subtle); }
.cb-lesson-row.editing { background: var(--primary-light); }
.cb-lesson-icon { flex-shrink: 0; font-size: 15px; }
.cb-lesson-title { flex: 1; }
.cb-lesson-duration {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cb-lesson-duration.missing { opacity: .5; }

/* WhatsApp Channel posts (components/whatsapp-share.js) */
.cb-wa-badge {
  flex-shrink: 0; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
}
.cb-wa-badge.posted     { background: var(--success-light); color: var(--success); }
.cb-wa-badge.not-posted { background: var(--bg-subtle); color: var(--text-muted); }
.cb-wa-btn { color: #25d366; }
.cb-wa-btn svg { width: 16px; height: 16px; }
.qb-wa-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin: -4px 0 12px; }
.cb-wa-counter {
  display: inline-flex; align-items: center; gap: 6px;
  margin-inline-start: auto; margin-inline-end: 10px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-secondary);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.cb-wa-counter svg { width: 14px; height: 14px; color: #25d366; }
.cb-wa-counter:hover, .cb-wa-counter.active { border-color: #25d366; color: var(--text); }
.cb-wa-counter.active { background: rgba(37,211,102,.12); }
.cb-wa-counter.all-posted { cursor: default; color: var(--success); border-color: transparent; }
.wa-modal { max-width: 460px; }
.wa-modal .modal-actions { flex-wrap: wrap; }
.wa-modal-icon { background: rgba(37,211,102,.14); color: #25d366; }
.wa-post-text {
  width: 100%; margin-top: 14px; resize: vertical; min-height: 140px;
  font: inherit; font-size: 14px; line-height: 1.6; text-align: right;
}
.wa-btn { display: inline-flex; align-items: center; gap: 6px; background: #25d366; color: #fff; border-color: #25d366; }
.wa-btn:hover { background: #1ebe5b; border-color: #1ebe5b; }
.wa-btn svg { width: 16px; height: 16px; }
.wa-btn:disabled { opacity: .6; cursor: default; }
.wa-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }
/* WhatsApp-style preview of the post */
.wa-preview {
  margin-top: 14px; padding: 14px 12px; border-radius: 12px;
  background: #efeae2; max-height: min(62vh, 560px); overflow-y: auto;
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px;
}
.wa-bubble {
  position: relative; max-width: 94%; margin: 0 auto;
  background: #fff; color: #111b21; border-radius: 10px;
  padding: 8px 10px 20px; box-shadow: 0 1px .5px rgba(11,20,26,.13);
  font-size: 14px; line-height: 1.55; word-break: break-word;
}
.wa-bubble-time { position: absolute; bottom: 4px; inset-inline-start: 10px; font-size: 11px; color: #667781; }
.wa-bubble-body > div { text-align: start; }
.wa-quote { border-inline-start: 3px solid #25d366; background: #f5f6f6; padding: 4px 8px; border-radius: 4px; color: #3b4a54; margin: 2px 0; }
.wa-link { color: #027eb5; direction: ltr; unicode-bidi: embed; }
/* Admin Panel → Integrations */
.int-card { max-width: 720px; padding: 22px; }
.int-card-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.int-card-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(37,211,102,.14); color: #25d366; }
.int-card-icon svg { width: 22px; height: 22px; }
.int-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.int-row { display: flex; gap: 8px; flex-wrap: wrap; }
.int-row input { flex: 1 1 280px; min-width: 0; }
.int-error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.int-note { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }
.int-note code { font-size: 12px; }
.int-help { margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.int-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.int-help ol { margin: 8px 0 0; padding-inline-start: 20px; line-height: 1.7; }
.int-meta { font-size: 12px; color: var(--text-muted); margin-top: 14px; }
.wa-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.wa-image-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.wa-image-toggle input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: #25d366; }
.wa-card-slot canvas { display: block; width: 100%; height: auto; border-radius: 6px; margin: -2px 0 8px; }
.wa-steps { margin: 4px 0 12px; padding-inline-start: 20px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }
.wa-steps li + li { margin-top: 6px; }
.wa-steps .btn { margin-inline-start: 6px; vertical-align: middle; }
.wa-copy-row { display: flex; gap: 8px; margin: 0 0 14px; }
.wa-copy-row .btn { flex: 1; justify-content: center; }
.wa-post-text[hidden], .wa-preview[hidden] { display: none; }
:root[data-theme="dark"] .wa-preview { background-color: #0b141a; background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px); }
:root[data-theme="dark"] .wa-bubble { background: #1f2c34; color: #e9edef; }
:root[data-theme="dark"] .wa-quote { background: #182229; color: #d1d7db; }
.cb-lesson-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.cb-lesson-row:hover .cb-lesson-actions,
.cb-lesson-row.editing .cb-lesson-actions { opacity: 1; }

.cb-add-lesson-btn {
  padding: 8px 20px 8px 44px;
  font-size: 13px; font-weight: 500;
  color: var(--primary); cursor: pointer;
  transition: background var(--transition);
}
.cb-add-lesson-btn:hover { background: var(--primary-light); }

/* ── Inline lesson editor ── */
.cb-lesson-editor {
  margin: 4px 20px 12px 44px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.cb-type-toggle { display: flex; gap: 6px; }
.cb-video-preview { margin-top: 12px; border-radius: 8px; overflow: hidden; background: #000; }
.cb-editor-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── Lesson editor: linked-quiz manager ── */
.cb-lq-section { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.cb-lq-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.cb-lq-row .cb-lq-title { flex: 1; min-width: 140px; font-weight: 600; font-size: 14px; }
.cb-lq-pass { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.cb-lq-pass-input { width: 64px; }
.cb-lq-req { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.cb-lq-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.cb-lq-add select { flex: 1; }

/* ── Drag handle ── */
.cb-drag-handle {
  color: var(--text-subtle);
  font-size: 14px;
  cursor: grab;
  flex-shrink: 0;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
}
.cb-drag-handle:active { cursor: grabbing; }

/* ── Drag states ── */
.cb-module-item.cb-dragging { opacity: 0.35; }
.cb-module-item.cb-drag-over {
  background: var(--primary-light) !important;
  border-left-color: var(--primary) !important;
}

/* ── Module actions (edit + status pill) ── */
.cb-module-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.cb-module-item:hover .cb-module-actions,
.cb-module-item.active .cb-module-actions { opacity: 1; }

/* ── Module icon button (clickable to open picker) ── */
.cb-icon-picker-wrap { position: relative; flex-shrink: 0; }
.cb-module-icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 4px;
  line-height: 1;
  transition: border-color var(--transition), background var(--transition);
}
.cb-module-icon-btn:hover {
  border-color: var(--border);
  background: var(--bg-subtle);
}

/* ── Icon picker grid ── */
.cb-icon-picker {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 300;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  width: 248px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.cb-icon-option {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
  transition: background var(--transition), border-color var(--transition);
}
.cb-icon-option:hover { background: var(--bg-subtle); border-color: var(--border); }
.cb-icon-option.selected {
  background: var(--primary-light);
  border-color: var(--primary-mid);
}

/* ── Order buttons (↑↓) ── */
.cb-order-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.cb-order-btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.cb-order-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Move-to-section control (unsorted courses) ── */
.cb-move-label {
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
}
.cb-move-select {
  font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); padding: 2px 6px;
  cursor: pointer; max-width: 160px;
}
.cb-move-select:focus { outline: none; border-color: var(--primary); }

/* ── Status pill (draft / published) ── */
.cb-status-pill {
  border: none;
  border-radius: 20px;
  padding: 2px 9px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.cb-status-pill.draft {
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.cb-status-pill.published {
  background: #dcfce7;
  color: #15803d;
}
[data-theme="dark"] .cb-status-pill.published {
  background: rgba(22,163,74,.22);
  color: #4ade80;
}
.cb-status-pill.completed,
.cb-status-pill.ended { cursor: default; }   /* info only — not a toggle */
.cb-status-pill.completed { background: #dbeafe; color: #1d4ed8; }
[data-theme="dark"] .cb-status-pill.completed { background: rgba(59,130,246,.22); color: #93c5fd; }
.cb-status-pill.ended { background: #e2e8f0; color: #475569; }
[data-theme="dark"] .cb-status-pill.ended { background: rgba(148,163,184,.2); color: #cbd5e1; }

/* ── Section container ── */
.cb-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.cb-section-unsorted {
  opacity: 0.75;
  border-style: dashed;
}
.cb-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  background: var(--card);
}
.cb-section-header:hover { background: var(--bg-subtle); }
.cb-section-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.cb-section-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}
.cb-section-header:hover .cb-section-actions { opacity: 1; }
.cb-course-header:hover .cb-section-actions  { opacity: 1; }
.cb-section-body {
  padding: 4px 14px 12px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* ── Video embed (lesson viewer) ── */
.video-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}
.video-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Onboarding registration form ── */
.onboarding-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 60px;
  background: var(--bg);
}
.onboarding-card {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 48px;
}
@media (max-width: 640px) {
  .onboarding-card { padding: 28px 20px; }
}
.onboarding-header {
  text-align: center;
  margin-bottom: 36px;
}
.onboarding-logo {
  font-size: 48px;
  margin-bottom: 12px;
}
.onboarding-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}
.onboarding-header p {
  color: var(--text-muted);
  margin: 0;
}
.form-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}
.form-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 4px;
}
.required {
  color: var(--danger);
}

/* Phone number input group */
.phone-input-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.phone-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.phone-input-group.phone-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
.phone-input-group.phone-ok {
  border-color: var(--success);
}
.phone-number-input {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  flex: 1;
  min-width: 0;
  outline: none;
}
.phone-number-input::placeholder { color: var(--text-muted); }
.phone-hint { min-height: 20px; margin-top: 4px; font-size: 12px; }
.phone-hint-err { color: var(--danger); }
.phone-hint-ok  { color: var(--success); }

/* Custom country-code dropdown with real flag images */
.phone-input-group { overflow: visible; }   /* allow the flag menu to escape the group */
.phone-code-combo { position: relative; display: flex; flex: 0 0 auto; }
.phone-code-btn {
  display: flex; align-items: center; gap: 6px;
  border: none; border-right: 1px solid var(--border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--bg-subtle); color: var(--text);
  padding: 9px 10px; font-size: 14px; font-family: inherit;
  cursor: pointer; white-space: nowrap; outline: none;
}
.phone-code-btn:hover { background: var(--border); }
.phone-flag {
  width: 22px; height: 16px; border-radius: 2px; object-fit: cover;
  flex-shrink: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  background: var(--border);
}
.phone-caret { font-size: 10px; color: var(--text-muted); }
.phone-code-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  width: 300px; max-width: 86vw;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 8px;
}
.phone-code-search {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-subtle); color: var(--text); font-size: 13px; outline: none;
}
.phone-code-search:focus { border-color: var(--primary); }
.phone-code-list { max-height: 244px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.phone-code-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; background: none; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; color: var(--text); font-size: 14px; font-family: inherit;
}
.phone-code-row:hover { background: var(--bg-subtle); }
.phone-code-row.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.phone-code-row-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-code-row-dial { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.phone-code-row.active .phone-code-row-dial { color: var(--primary); }

/* Age badge in trainees table */
.age-badge {
  display: inline-block;
  background: var(--info-light);
  color: var(--info);
  border: 1px solid var(--info-light);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
[data-theme="dark"] .age-badge {
  color: #67e8f9;
  border-color: rgba(8,145,178,.35);
}

/* File upload styled button */
.file-upload-wrap {
  position: relative;
}
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-upload-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.file-upload-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.file-upload-icon { font-size: 18px; }

/* ── Standalone Quiz Builder ──────────────────────────────────────── */
/* Two-column builder: fixed settings rail + flexible questions area.
   The settings rail sticks while the (taller) questions list scrolls. */
/* The builder uses the full width: a wider settings column (so the reward
   fields and category/time-limit sit side by side) next to the questions. */
.qb-page, .qr-page, .ql-page, .qlb-page { max-width: none; }
.qb-layout {
  display: grid;
  grid-template-columns: clamp(360px, 38%, 600px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.qb-left {
  position: sticky; top: 16px;
  max-height: calc(100vh - 32px); overflow-y: auto;
  scrollbar-width: thin; border-radius: var(--radius);
}
.qb-settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  column-gap: 12px; align-items: start;
}
@media (max-width: 900px) {
  .qb-layout { grid-template-columns: 1fr; }
  .qb-left { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 1024px) and (min-width: 901px) {
  .qb-layout { gap: 20px; }
}
/* Question title wraps up to 2 lines when collapsed; unclamped when the card is open */
.qb-q-preview {
  flex: 1; min-width: 0; font-size: 14px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal;
}
.qb-card--open .qb-q-preview { -webkit-line-clamp: unset; overflow: visible; }

.qb-question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--card);
  overflow: hidden;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.qb-question-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-hover); }
.qb-q-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.qb-q-header:hover { background: var(--bg-subtle); }
.qb-q-header:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); outline: none; }
.qb-q-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qb-q-header-actions .btn-sm { transition: transform .15s ease, background .15s ease, color .15s ease; }
.qb-q-header-actions .btn-sm:hover { transform: scale(1.08); }
.qb-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Validity indicator */
.qb-validity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.qb-validity-dot.ok   { background: var(--success); }
.qb-validity-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-light); }

/* Expand/collapse chevron */
.qb-chevron {
  display: inline-block; width: 8px; height: 8px; margin-inline-start: 4px;
  border-top: 2px solid var(--text-muted); border-right: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform .25s ease;
}
.qb-card--open > .qb-q-header .qb-chevron { transform: rotate(135deg); }
html[dir="rtl"] .qb-chevron { transform: rotate(-135deg); }
html[dir="rtl"] .qb-card--open > .qb-q-header .qb-chevron { transform: rotate(135deg); }

/* Animated body — content is always rendered; grid-rows 0fr→1fr drives the height */
.qb-q-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.qb-card--open .qb-q-body { grid-template-rows: 1fr; }
.qb-q-bodyinner { overflow: hidden; min-height: 0; }
.qb-q-bodyinner > .qb-preview { padding: 0 16px 16px; opacity: 0; transition: opacity .2s ease .05s; }
.qb-card--open .qb-q-bodyinner > .qb-preview { opacity: 1; }

/* Read-only preview: options list + explanation */
.qb-preview-opts { display: flex; flex-direction: column; gap: 6px; }
.qb-preview-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 13.5px;
}
.qb-preview-opt.is-correct {
  border-color: var(--success); background: var(--success-light);
  color: var(--success); font-weight: 600;
}
.qb-preview-opt-mark { width: 14px; flex-shrink: 0; font-weight: 700; }
.qb-preview-expl {
  margin-top: 10px; font-size: 13px; color: var(--text-muted);
  background: var(--bg-subtle); border-radius: var(--radius-sm); padding: 8px 12px;
}
.qb-preview-textnote { font-size: 13px; color: var(--text-muted); font-style: italic; }

.qb-q-editor {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.qb-option-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.qb-option-input {
  flex: 1; min-width: 0;
  resize: none; overflow: hidden;
  line-height: 1.4; font-family: inherit;
}
.quiz-question-img {
  max-width: 100%;
  max-height: 260px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  margin-bottom: 12px;
  display: block;
}
.multi-checkbox {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.multi-checkbox label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s, background 0.15s;
  text-align: start;
}
/* Checkbox sits at the reading-start edge and never shrinks */
.multi-checkbox label > input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
/* Text fills the row so it stays next to the checkbox (no stranded gap) */
.multi-checkbox .multi-opt-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
}
.multi-checkbox label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
/* ── Assign to Trainees (targeted quiz) ───────────────────────────── */
.qb-assign-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
}
.qb-assign-count { font-size: 13px; font-weight: 600; color: var(--text); }
.qb-assign-clear {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.qb-assign-clear:hover:not(:disabled) { text-decoration: underline; }
.qb-assign-clear:disabled { color: var(--text-muted); cursor: default; opacity: .6; }
.qb-assign-divider { border-top: 1px solid var(--border); margin: 10px 0; }

.qb-trainee-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qb-trainee-chips-empty { font-size: 12.5px; color: var(--text-muted); padding: 2px 0; }
.qb-trainee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 12.5px;
  font-weight: 600;
}
.qb-trainee-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-trainee-chip button {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
}
.qb-trainee-chip button:hover { background: rgba(0,0,0,.08); }
.qb-trainee-chip-more {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.qb-trainee-chip-more:hover { background: var(--primary-light); }

.qb-trainee-search { margin: 10px 0 8px; }

/* Fixed-height virtualized viewport — only the visible row slice is ever
   in the DOM, so selecting a trainee never remounts the list or resets scroll. */
.qb-trainee-viewport {
  position: relative;
  height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.qb-trainee-spacer { position: relative; width: 100%; }
.qb-trainee-rows { position: absolute; top: 0; left: 0; right: 0; }
.qb-trainee-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.qb-trainee-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  box-sizing: border-box;
  padding: 6px 12px;
  cursor: pointer;
}
.qb-trainee-row:hover { background: var(--bg-subtle); }
.qb-trainee-row:has(input:checked) { background: var(--primary-light); }
.qb-trainee-row:focus-within { box-shadow: inset 0 0 0 2px var(--primary); }
/* Override the global input width:100% — keep the checkbox at its natural size */
.qb-trainee-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
.qb-trainee-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.qb-trainee-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.qb-trainee-name-row .badge {
  flex-shrink: 0;
}
.qb-trainee-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qb-trainee-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Admin Users toolbar (filter + search) ────────────────────────── */
.users-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.users-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.users-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.users-filter-pill:hover { background: var(--bg-subtle); color: var(--text); }
.users-filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.users-filter-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.users-filter-pill.active .users-filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.users-search {
  width: 280px;
  max-width: 100%;
  padding: 8px 12px;
}

/* ── Trainee Progress — dashboard ─────────────────────────────────── */
@keyframes tpFadeIn  { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes tpToastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* KPI summary cards — reuse .dash-kpi look, 5-up grid */
.tp-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .tp-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .tp-kpis { grid-template-columns: repeat(2, 1fr); } }
.tp-kpi { padding: 15px 16px 16px; animation: tpFadeIn .18s ease both; }
.tp-kpi .dash-kpi-icon { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
.tp-kpi .dash-kpi-value { font-size: 22px; }

/* Period presets */
.tp-period-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tp-period-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.tp-period-group { display: flex; gap: 6px; flex-wrap: wrap; }
.tp-auto-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px;
}

/* Toolbar */
.tp-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.tp-search { width: 240px; max-width: 100%; padding: 8px 12px; }
.tp-filter-select { width: auto; min-width: 140px; padding: 8px 30px 8px 12px; font-size: 13px; }
.tp-colmenu-wrap { position: relative; margin-inline-start: auto; }

/* Table wrap + sticky header */
.tp-table-wrap { overflow: auto; max-height: 66vh; border-radius: var(--radius); }
.tp-table-wrap thead th { position: sticky; top: 0; z-index: 5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-table-wrap table { width: 100%; table-layout: fixed; font-size: 13px; min-width: 1080px; }
.tp-table-wrap td { padding: 9px 16px; overflow: hidden; }
.tp-col-expand { width: 36px; padding-inline-end: 0 !important; }
.tp-col-actions { width: 56px; }

.tp-th-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: inherit; font-family: inherit;
}
.tp-th-btn:hover { color: var(--text); }
.tp-sort-arrow { font-size: 9px; color: var(--primary); min-width: 8px; display: inline-block; }

/* Row + expand control */
.tp-row { transition: background .12s ease; }
.tp-row:hover td { background: var(--bg-subtle); }
.tp-row-open td { background: var(--bg-subtle); }
.tp-expand-btn {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: none; background: none; color: var(--text-muted); cursor: pointer;
  transition: background .12s ease, transform .18s ease;
}
.tp-expand-btn:hover { background: var(--bg); color: var(--text); }
.tp-caret { display: inline-block; font-size: 11px; transition: transform .18s ease; }

/* Group-by-tag section header */
.tp-group-row td {
  padding: 8px 16px; background: var(--bg-subtle); font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}

/* Trainee cell */
.tp-trainee { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tp-avatar { width: 32px; height: 32px; font-size: 13px; flex: none; }
.tp-trainee-info { min-width: 0; }
.tp-trainee-name { font-weight: 600; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-trainee-email { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Progress bar w/ threshold colors */
.tp-bar {
  display: inline-block; width: 100px; height: 7px; border-radius: 999px;
  background: var(--bg-subtle); overflow: hidden; vertical-align: middle;
}
.tp-bar--wide { width: 100%; }
.tp-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .2s ease-out; }
.tp-bar--red    .tp-bar-fill { background: var(--danger); }
.tp-bar--orange .tp-bar-fill { background: var(--warning); }
.tp-bar--blue   .tp-bar-fill { background: var(--primary); }
.tp-bar--green  .tp-bar-fill { background: var(--success); }
.tp-bar-label { margin-inline-start: 8px; font-size: 12px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tp-xp-sub { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

/* Expanded detail — tabs */
.tp-detail-row > td { background: var(--bg-subtle); padding: 0; }
.tp-detail { padding: 16px 20px 20px; animation: tpFadeIn .18s ease both; }
.tp-detail-loading { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: var(--text-muted); font-size: 13px; }
.tp-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tp-tab {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 9px 14px; margin-bottom: -1px;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.tp-tab:hover { color: var(--text); background: var(--bg-subtle); }
.tp-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.tp-detail-body > * { animation: tpFadeIn .15s ease both; }

/* Level badge, streak flame, plain colored percentage (no bar) */
.tp-level-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: var(--primary-light); color: var(--primary-dark); font-size: 11px; font-weight: 800;
}
.tp-streak { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--warning); }
.tp-pctnum { font-size: 14.5px; font-weight: 800; }
.tp-pctnum--red    { color: var(--danger); }
.tp-pctnum--orange { color: var(--warning); }
.tp-pctnum--blue   { color: var(--primary); }
.tp-pctnum--green  { color: var(--success); }

/* Last-quiz-score cell */
.tp-lastq { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.tp-lastq-title { font-size: 10.5px; color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Last-active cell */
.tp-activity { display: flex; align-items: center; gap: 7px; }
.tp-act-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.tp-act-dot--good  { background: var(--success); }
.tp-act-dot--warn  { background: var(--warning); }
.tp-act-dot--bad   { background: var(--danger); }
.tp-act-dot--muted { background: var(--text-subtle); }
.tp-act-label { font-size: 12.5px; font-weight: 600; }
.tp-act-label--good  { color: var(--success); }
.tp-act-label--warn  { color: var(--warning); }
.tp-act-label--bad   { color: var(--danger); }
.tp-act-label--muted { color: var(--text-subtle); }
.tp-notify-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: var(--radius-sm);
  opacity: .7;
}
.tp-notify-btn:hover { opacity: 1; background: var(--bg); }

/* Overview tab — stat cards */
.tp-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tp-stat {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px;
}
.tp-stat-icon { font-size: 18px; flex: none; }
.tp-stat-value { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; }
.tp-stat-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.tp-stat-sub { font-size: 11px; color: var(--text-subtle); margin-top: 1px; }

/* Module progress tab */
.tp-mods { display: flex; flex-direction: column; gap: 10px; }
.tp-mod { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.tp-mod-title { flex: 0 0 200px; width: 200px; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-mod-bar { flex: 0 0 auto; display: flex; align-items: center; }
.tp-mod-count { flex: 0 0 auto; color: var(--text-muted); font-size: 12px; }
@media (max-width: 640px) { .tp-mod { flex-wrap: wrap; } .tp-mod-title { flex: 1 1 100%; width: auto; } }

/* Quiz lists (lesson / standalone) — flex rows, not a <table>, so the title
   column can't stretch and separate the score from the count (real tables
   distribute leftover width onto the widest column, pushing them apart). */
.tp-qrow { display: flex; align-items: center; gap: 14px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.tp-qrow:last-child { border-bottom: none; }
.tp-qtitle { flex: 0 0 240px; width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-qscore { flex: 0 0 auto; font-weight: 700; color: var(--text); }
.tp-qmeta { flex: 0 0 auto; }
@media (max-width: 640px) { .tp-qrow { flex-wrap: wrap; } .tp-qtitle { flex: 1 1 100%; width: auto; } }

/* Empty states */
.tp-empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 20px; gap: 4px; }
.tp-empty-icon { font-size: 30px; margin-bottom: 6px; opacity: .8; }
.tp-empty-title { font-size: 14px; font-weight: 700; color: var(--text); }
.tp-empty-body { font-size: 12.5px; color: var(--text-muted); max-width: 280px; }

/* Pagination */
.tp-pagination {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.tp-pg-size { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.tp-pg-size label { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.tp-pg-size select { width: auto; padding: 5px 26px 5px 10px; font-size: 12.5px; }
.tp-pg-range { font-size: 12.5px; color: var(--text-muted); }
.tp-pg-nav { display: flex; align-items: center; gap: 10px; }
.tp-pg-page { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* Toast (copy-email feedback) */
.tp-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 8px);
  background: var(--text); color: var(--card); font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  opacity: 0; z-index: 100; transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.tp-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .tp-search { width: 100%; }
  .tp-colmenu-wrap { margin-inline-start: 0; }
}

/* ── Analytics dashboard ──────────────────────────────────────────── */
.anx .anx-header { margin-bottom: 18px; }
.anx .anx-header h1 { margin: 0; font-size: 24px; }
.anx .anx-header p { margin: 2px 0 0; color: var(--text-muted); font-size: 13.5px; }

/* Tint chips shared by KPI icons, insights, avatars, chips */
.anx-tint-blue   { background: var(--primary-light); color: var(--primary); }
.anx-tint-green  { background: var(--success-light); color: var(--success); }
.anx-tint-amber  { background: var(--warning-light); color: var(--warning); }
.anx-tint-red    { background: var(--danger-light);  color: var(--danger); }
.anx-tint-violet { background: var(--info-light);    color: var(--info); }

/* KPI row */
.anx-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.anx-kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.anx-kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.anx-kpi-icon {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 20px;
}
.anx-kpi-body { min-width: 0; }
.anx-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.anx-kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
}
.anx-kpi-trend { font-size: 11.5px; color: var(--text-muted); }

/* Middle + bottom grids */
.anx-mid, .anx-bottom {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.anx-panel { padding: 16px 18px; border-radius: var(--radius-lg); }
.anx-card-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}

/* Distribution bars */
.anx-dist-row {
  display: grid;
  grid-template-columns: 92px 1fr 70px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.anx-dist-label { color: var(--text); }
.anx-dist-count { text-align: end; font-weight: 700; color: var(--text); white-space: nowrap; }
.anx-dist-count em { font-style: normal; font-weight: 500; color: var(--text-subtle); font-size: 12px; }
.anx-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.anx-bar-lg { height: 12px; }
.anx-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  min-width: 0;
}
.anx-bar-gray { background: var(--text-subtle); opacity: .45; }

/* Onboarding progress widget */
.anx-onboard-pct { font-size: 34px; font-weight: 800; color: var(--text); margin-bottom: 8px; line-height: 1; }
.anx-onboard-stats {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.anx-onboard-stats strong { color: var(--text); margin-inline-start: 2px; }
.anx-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-inline-end: 6px;
  vertical-align: 1px;
}
.anx-dot-blue { background: var(--primary); }
.anx-dot-gray { background: var(--text-subtle); }

/* Quick insights */
.anx-insight {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}
.anx-insight-icon {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 14px;
}
.anx-insight-text strong { color: var(--text); font-size: 15px; margin-inline-end: 4px; }

/* Hover/focus tooltip (insight rows) */
.anx-tip { position: relative; }
.anx-tip .anx-insight-text {
  cursor: help;
  text-decoration: underline dotted var(--border-hover);
  text-underline-offset: 3px;
}
.anx-tip-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 36px;
  min-width: 190px;
  max-width: 260px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px 12px;
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  pointer-events: none;
}
.anx-tip:hover .anx-tip-pop,
.anx-tip:focus-within .anx-tip-pop { opacity: 1; visibility: visible; transform: none; }
.anx-tip-row {
  font-size: 12.5px;
  color: var(--text);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anx-tip-row:last-of-type { border-bottom: none; }
.anx-tip-more { font-size: 12px; color: var(--text-subtle); padding-top: 5px; }

/* Trainee list cards */
.anx-list-card { padding: 16px 18px; border-radius: var(--radius-lg); }
.anx-list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.anx-list-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}
.anx-list-sub { font-size: 11px; color: var(--text-subtle); }
.anx-count-pill {
  margin-inline-start: auto;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11.5px;
  font-weight: 700;
}
.anx-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.anx-person:last-child { border-bottom: none; }
.anx-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}
/* Photo variant of the same circle (components/avatar.js). object-fit keeps a
   non-square upload from stretching; the global `input{width:100%}`-style
   reset doesn't reach img, but the explicit size guards against table cells
   trying to size it themselves. */
.anx-avatar-img {
  object-fit: cover;
  background: var(--bg-subtle, rgba(127, 127, 127, .1));
}

/* Avatar + name on one line, for table cells that show a person. */
.anx-ident {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.anx-ident > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.anx-person-info { min-width: 0; flex: 1; }
.anx-person-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anx-person-sub {
  font-size: 11.5px;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anx-person-end { flex: none; }
.anx-chip {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
}
.anx-empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.anx-empty-good { color: var(--success); font-weight: 600; }

/* ── Analytics: toolbar, tabs, card grid ──────────────────────────────────── */
.anx-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.anx-toolbar .anx-header { margin-bottom: 0; }
.anx-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.anx-period { display: flex; gap: 6px; }
.anx-period button,
.anx-editbtn {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.anx-period button:hover,
.anx-editbtn:hover { border-color: var(--border-hover); color: var(--text); }
.anx-period button.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary-mid); }
.anx-editbtn.on { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }

/* 6-column grid so thirds and halves both land cleanly */
/* Cards sharing a row stretch to the tallest one; the body takes the spare
   height so charts that opt in (.anx-fill) can grow into it instead of
   leaving a blank band under a short card. */
.anx-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: stretch; }
.anx-grid > .anx-panel { display: flex; flex-direction: column; min-width: 0; }
.anx-grid > .anx-panel > .anx-card-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.anx-fill { flex: 1; }
.anx-w-third { grid-column: span 2; }
.anx-w-half  { grid-column: span 3; }
.anx-w-full  { grid-column: span 6; }

.anx-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.anx-card-head .anx-card-title { margin: 0; }
.anx-card-head-bare { margin-bottom: 0; min-height: 0; }
.anx-card-body > .anx-kpis { margin-bottom: 0; }

/* ── Analytics: edit mode ─────────────────────────────────────────────────── */
.anx-drag-handle,
.anx-cardtools { display: none; }
.anx-editing .anx-drag-handle { display: inline-block; cursor: grab; color: var(--text-subtle); letter-spacing: -2px; }
.anx-editing .anx-drag-handle:active { cursor: grabbing; }
.anx-editing .anx-cardtools { display: flex; gap: 4px; margin-inline-start: auto; }
.anx-editing .anx-panel { outline: 1px dashed var(--border-hover); outline-offset: 3px; }
.anx-editing .anx-panel:hover { outline-color: var(--primary); }
.anx-tool {
  font-family: inherit; font-size: 12px; line-height: 1; padding: 4px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); color: var(--text-muted); cursor: pointer;
}
.anx-tool:hover { border-color: var(--primary); color: var(--primary); }
.anx-tool.sel { background: var(--primary-light); color: var(--primary); border-color: var(--primary-mid); font-weight: 700; }
.anx-dragging { opacity: .4; }
.anx-drag-over { outline: 2px solid var(--primary) !important; outline-offset: 3px; }

.anx-editbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--warning-light); border: 1px solid var(--warning);
  border-radius: var(--radius); padding: 9px 14px; margin-bottom: 14px;
  font-size: 12.5px; color: var(--warning);
}
.anx-editbar-actions { margin-inline-start: auto; display: flex; gap: 7px; }
.anx-editbar button {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 14px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
}
.anx-save   { background: var(--primary); color: #fff; }
.anx-cancel { background: var(--card); color: var(--text-muted); border-color: var(--border); }
.anx-reset  { background: transparent; color: var(--warning); text-decoration: underline; }

.anx-tray {
  border: 1px dashed var(--border-hover); border-radius: var(--radius-lg);
  padding: 12px 16px; margin-bottom: 14px; background: var(--bg-subtle);
}
.anx-tray-t {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted); margin-bottom: 8px;
}
.anx-tray-empty { font-size: 12.5px; color: var(--text-subtle); }
.anx-tray .anx-chip {
  display: inline-flex; align-items: center; gap: 6px; width: auto; height: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; margin: 0 0 6px 6px; font-family: inherit;
}
.anx-tray .anx-chip:hover { border-color: var(--primary); color: var(--primary); }

/* ── Analytics: alerts, notes, callouts ───────────────────────────────────── */
.anx-alert {
  border-inline-start: 3px solid var(--danger); background: var(--danger-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 13px; margin-bottom: 12px; font-size: 12.5px; color: var(--text);
}
.anx-alert b { color: var(--danger); }
.anx-alert-amber { border-inline-start-color: var(--warning); background: var(--warning-light); }
.anx-alert-amber b { color: var(--warning); }
.anx-note {
  display: flex; gap: 7px; align-items: flex-start;
  font-size: 11.5px; color: var(--text-muted); margin-top: 11px; line-height: 1.55;
}
.anx-note b { color: var(--text); font-weight: 600; }
.anx-num   { font-variant-numeric: tabular-nums; }
.anx-big   { font-size: 40px; font-weight: 800; line-height: 1; color: var(--text); }
.anx-big-sm { font-size: 30px; }
.anx-sub   { font-size: 12.5px; color: var(--text-muted); }

/* ── Analytics: tables ────────────────────────────────────────────────────── */
.anx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.anx-table th {
  text-align: start; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted);
  padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.anx-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.anx-table tbody tr:last-child td { border-bottom: none; }
.anx-table tbody tr:hover { background: var(--bg-subtle); }

/* ── Analytics: trend + hours ─────────────────────────────────────────────── */
.anx-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.anx-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }
.anx-trend { display: flex; align-items: flex-end; gap: 6px; height: 128px; }
.anx-trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.anx-trend-stack { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; justify-content: center; }
/* Growable variant: the columns size to the chart and the bars are % of it. */
.anx-trend.anx-fill { height: auto; min-height: 128px; align-items: stretch; }
.anx-trend.anx-fill .anx-trend-col { height: auto; }
.anx-trend.anx-fill .anx-trend-stack { flex: 1; height: auto; min-height: 0; }
.anx-trend-bar { width: 42%; border-radius: 4px 4px 0 0; background: var(--primary); min-height: 3px; }
.anx-trend-bar.q { background: var(--info); }
.anx-trend-bar.zero { background: var(--bg-subtle); }
.anx-trend-col:hover .anx-trend-bar { opacity: .75; }
.anx-trend-x { font-size: 10.5px; color: var(--text-subtle); white-space: nowrap; }

/* Visitors card — grain toggle, stat row and stacked new/returning columns */
.anx-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.anx-seg button {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 5px 14px;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.anx-seg button + button { border-inline-start: 1px solid var(--border); }
.anx-seg button:hover { color: var(--text); }
.anx-seg button.active { background: var(--primary-light); color: var(--primary); }
.anx-vstats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 12px; }
.anx-vstats b { display: block; font-size: 20px; font-weight: 700; color: var(--text); }
.anx-vstats span { font-size: 12px; color: var(--text-muted); }
.anx-visitors { gap: 3px; height: 165px; }
.anx-visitors .anx-trend-col { min-width: 0; gap: 3px; }
.anx-vstack { position: relative; display: flex; flex-direction: column; justify-content: flex-end; width: 100%; max-width: 34px; }
.anx-vcount { font-size: 10.5px; font-weight: 600; color: var(--text-muted); line-height: 1; min-height: 11px; white-space: nowrap; }
/* Hover / focus card with the new vs returning breakdown for one bar */
/* Anchored to the bar (inside .anx-vstack), clearing the count label above it. */
.anx-vcol { outline: none; }
.anx-vpop {
  position: absolute; bottom: calc(100% + 16px); left: 50%;
  transform: translate(-50%, 4px);
  min-width: 170px; padding: 9px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 40; text-align: start;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.anx-vcol.edge-start .anx-vpop { left: auto; inset-inline-start: 0; transform: translate(0, 4px); }
.anx-vcol.edge-end .anx-vpop   { left: auto; inset-inline-end: 0;   transform: translate(0, 4px); }
.anx-vcol:hover .anx-vpop,
.anx-vcol:focus .anx-vpop { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.anx-vcol.edge-start:hover .anx-vpop, .anx-vcol.edge-start:focus .anx-vpop,
.anx-vcol.edge-end:hover .anx-vpop,   .anx-vcol.edge-end:focus .anx-vpop { transform: none; }
.anx-vpop-h { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px; white-space: nowrap; }
.anx-vpop-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--text-muted); padding: 2px 0; }
.anx-vpop-row b { color: var(--text); font-size: 14px; }
.anx-vpop-row i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; background: var(--primary); }
.anx-vpop-row i.new { background: var(--warning); }
.anx-vpop-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
.anx-vcol:hover .anx-vbar, .anx-vcol:focus .anx-vbar { opacity: .75; }
/* Too many bars for horizontal labels (e.g. 90 days) — stand the counts upright */
.anx-visitors.dense .anx-vcount { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 9px; }
.anx-vbar { width: 100%; background: var(--primary); }
.anx-vbar:first-child { border-radius: 4px 4px 0 0; }
.anx-vbar.new { background: var(--warning); }
.anx-vbar.zero { height: 3px; background: var(--bg-subtle); }
.anx-trend-col:hover .anx-vstack { opacity: .75; }
.anx-visitors .anx-trend-x { overflow: hidden; max-width: 100%; }

.anx-peak-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.anx-dayparts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 18px; }
.anx-daypart {
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-subtle); border: 1px solid transparent;
}
.anx-daypart.top { background: var(--primary-light); border-color: var(--primary-mid); }
.anx-daypart-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.anx-daypart-range { font-size: 11px; color: var(--text-subtle); }
.anx-daypart b { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 4px; font-variant-numeric: tabular-nums; }
.anx-daypart.top b { color: var(--primary); }
.anx-daypart-n { font-size: 11px; color: var(--text-muted); }
/* Half/third width: tighter blocks so the card sits level with its row-mate. */
.anx-w-half .anx-dayparts, .anx-w-third .anx-dayparts { gap: 6px; margin-bottom: 12px; }
.anx-w-half .anx-daypart, .anx-w-third .anx-daypart { padding: 7px 9px; }
.anx-w-half .anx-daypart b, .anx-w-third .anx-daypart b { font-size: 17px; margin-top: 2px; }
.anx-w-half .anx-hours, .anx-w-third .anx-hours { height: 96px; }
.anx-w-half .anx-peak-head .anx-big-sm, .anx-w-third .anx-peak-head .anx-big-sm { font-size: 24px; }

/* Pinned LTR in both languages: a clock axis reads left-to-right like the digits on it. */
.anx-hours {
  display: flex; align-items: flex-end; gap: 4px; height: 118px;
  direction: ltr; border-bottom: 1px solid var(--border);
}
.anx-hour { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; min-width: 0; }
.anx-hour-n { font-size: 10.5px; font-weight: 600; color: var(--text-muted); line-height: 1; font-variant-numeric: tabular-nums; }
.anx-hour.peak .anx-hour-n { color: var(--primary); font-weight: 800; }
.anx-hour-bar { width: 100%; border-radius: 3px 3px 0 0; background: var(--primary-mid); }
.anx-hour.peak .anx-hour-bar { background: var(--primary); }
.anx-hour.dead .anx-hour-bar { background: transparent; }
.anx-hour:hover .anx-hour-bar { background: var(--primary-dark); }
.anx-hours-x { display: flex; gap: 4px; direction: ltr; margin-top: 5px; }
.anx-hours-x span { flex: 1; min-width: 0; font-size: 10.5px; color: var(--text-subtle); white-space: nowrap; overflow: visible; font-variant-numeric: tabular-nums; }

@media (max-width: 620px) {
  .anx-dayparts { grid-template-columns: repeat(2, 1fr); }
  .anx-hour-n { display: none; }
}

.anx-cellsub  { font-size: 11px; color: var(--text-subtle); }

@media (max-width: 1100px) {
  .anx-kpis { grid-template-columns: repeat(2, 1fr); }
  .anx-mid, .anx-bottom { grid-template-columns: 1fr 1fr; }
  .anx-w-third { grid-column: span 3; }
}
@media (max-width: 768px) {
  .anx-kpis, .anx-mid, .anx-bottom { grid-template-columns: 1fr; }
  .anx-w-third, .anx-w-half, .anx-w-full { grid-column: span 6; }
}

/* XP rules table — editable value */
.xp-val { width: 74px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--text); font: inherit; font-weight: 700; }
.xp-val:focus { border-color: var(--primary); outline: none; }
/* How-XP-works modal rows */
.xp-info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.xp-info-row:last-child { border-bottom: none; }
.xp-info-row .xp-info-xp { font-weight: 800; color: var(--success); white-space: nowrap; }
.xp-info-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin: 14px 0 2px; }

/* ── My Quizzes cards ─────────────────────────────────────────────── */
.mq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  align-items: stretch;   /* equal-height cards per row */
}
.mq-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Left status accent */
.mq-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.mq-card.in_progress::before { background: var(--warning, #d97706); }
.mq-card.submitted::before   { background: var(--success, #16a34a); }
.mq-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mq-title { margin: 0; font-size: 16px; line-height: 1.3; }
.mq-desc {
  margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mq-date { font-size: 13px; color: var(--text-muted); }
.mq-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.mq-foot {
  margin-top: auto;            /* pin action row to the bottom → aligned across cards */
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 8px;
}
.mq-foot-left { font-size: 13px; }
.mq-foot .btn { white-space: nowrap; }
.mq-score { color: var(--text-muted); }

/* ── Quiz autosave / resume indicators ────────────────────────────── */
.qt-save-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.2s;
}
.qt-save-status.is-saved { color: var(--success, #16a34a); }
.qt-save-status.is-error { color: var(--danger, #dc2626); }
.qt-resumed-note {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-light, #fffbeb);
  color: var(--warning, #d97706);
  font-size: 13px;
}
.qt-timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Quiz time-spent stats (score panel) ──────────────────────────── */
.quiz-time-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.quiz-time-stat {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  min-width: 110px;
  text-align: center;
}
.quiz-time-stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.quiz-time-stat-value { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── Toast notifications ──────────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 360px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.app-toast.show { opacity: 1; transform: translateY(0); }
.app-toast-success { background: var(--success, #16a34a); }
.app-toast-error   { background: var(--danger, #dc2626); }

/* Bottom-center variant — used where a bottom-right toast could be covered
   by nearby controls (e.g. the last row of a long list). */
.app-toast-bottom {
  top: auto;
  left: 50%;
  bottom: 24px;
  right: auto;
  transform: translateX(-50%) translateY(12px);
}
.app-toast-bottom.show { transform: translateX(-50%) translateY(0); }

/* Save button success flash */
.btn.btn-saved-flash {
  background: var(--success, #16a34a) !important;
  border-color: var(--success, #16a34a) !important;
}

/* ── Toggle switch (page permissions, etc.) ──────────────────────────────── */
.toggle-switch {
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border: none;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  padding: 0;
  background: var(--border);
  transition: background 0.15s ease;
}
.toggle-switch .toggle-switch-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: left 0.15s ease;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch.on .toggle-switch-dot { left: 18px; }
.toggle-switch:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.is-loading { opacity: 0.85; cursor: progress; }

/* Builder note: text answers are graded manually */
.qb-manual-note {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px dashed var(--warning, #d97706);
  border-radius: var(--radius-sm);
  background: var(--warning-light, #fffbeb);
  color: var(--warning, #d97706);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Quiz Publish Toggle ──────────────────────────────────────────── */
.qb-publish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  transition: border-color 0.2s, background 0.2s;
}
.qb-publish-row:has(.qb-switch-input:checked) {
  border-color: var(--success, #16a34a);
  background: rgba(22, 163, 74, 0.06);
}
.qb-publish-info { display: flex; flex-direction: column; gap: 2px; }
.qb-publish-title { font-size: 14px; font-weight: 700; color: var(--text); }
.qb-publish-sub { font-size: 12px; color: var(--text-muted); }

/* visually-hidden native checkbox (kept for state + accessibility) */
.qb-switch-input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.qb-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.qb-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 62px;
  text-align: end;
  transition: color 0.2s;
}
.qb-switch-track {
  position: relative;
  width: 46px; height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.2s;
}
.qb-switch-track::after {
  content: "";
  position: absolute;
  top: 3px; inset-inline-start: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: inset-inline-start 0.2s;
}
/* checked (Published) state */
.qb-publish-row:has(.qb-switch-input:checked) .qb-switch-track { background: var(--success, #16a34a); }
.qb-publish-row:has(.qb-switch-input:checked) .qb-switch-track::after { inset-inline-start: 23px; }
.qb-publish-row:has(.qb-switch-input:checked) .qb-switch-label { color: var(--success, #16a34a); }
/* keyboard focus ring */
.qb-switch-input:focus-visible + .qb-switch .qb-switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* swap Draft/Published copy based on state */
.qb-pub-on { display: none; }
.qb-pub-off { display: inline; }
.qb-publish-row:has(.qb-switch-input:checked) .qb-pub-on { display: inline; }
.qb-publish-row:has(.qb-switch-input:checked) .qb-pub-off { display: none; }

/* Soft green pulse played briefly after a successful save while Published */
@keyframes qbPublishPulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,.45); }
  70%  { box-shadow: 0 0 0 10px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}
.qb-publish-row.qb-status-pulse { animation: qbPublishPulse .9s ease-out 2; }

/* ── Quiz Responses Reviewer ──────────────────────────────────────── */
.qr-attempt-row { transition: background 0.1s; }
.qr-attempt-row:hover { background: var(--bg-subtle); }
.qr-attempt-row.qr-expanded { background: var(--bg-subtle); }
.qr-detail-row td { border-bottom: 2px solid var(--border); }
.qr-detail-panel {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.qr-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
.qr-question-row { padding: 4px 0; }
.qr-question-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.qr-question-text {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}
.qr-answer-wrap { margin-top: 4px; }
.qr-text-answer {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  white-space: pre-wrap;
  max-width: 600px;
  color: var(--text);
}
/* Manual grading bar — sits at the bottom of each question */
.qr-grade-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px; max-width: 900px;
  border-top: 1px solid var(--border);
}
.qr-grade-auto { font-size: 12px; color: var(--text-muted); }
.qr-grade-seg { display: inline-flex; }
.qr-grade-seg .qr-grade-btn { border-radius: 0; margin-inline-start: -1px; }
.qr-grade-seg .qr-grade-btn:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); margin-inline-start: 0; }
.qr-grade-seg .qr-grade-btn:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.qr-grade-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.qr-grade-btn {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.qr-grade-btn:hover { background: var(--bg-subtle); }
.qr-grade-btn.is-correct { background: var(--success, #16a34a); border-color: var(--success, #16a34a); color: #fff; }
.qr-grade-btn.is-half    { background: var(--warning, #d97706);  border-color: var(--warning, #d97706);  color: #fff; }
.qr-grade-btn.is-wrong   { background: var(--danger, #dc2626);  border-color: var(--danger, #dc2626);  color: #fff; }

/* Grader note (internal — never shown to trainees) */
.qr-grade-note {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 10px; max-width: 600px;
}
.qr-grade-note textarea {
  width: 100%; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  background: var(--card); color: var(--text);
}
.qr-grade-note .btn-sm { align-self: flex-start; }
.qr-note-flag { cursor: help; font-size: 13px; }
.badge-half { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(217,119,6,.2); }

/* Choice answers: every option as a row. Filled = picked, green = correct. */
.qr-opts { display: flex; flex-direction: column; gap: 6px; max-width: 900px; }
.qr-opt {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 10px; align-items: start;
  padding: 8px 12px; font-size: 14px; line-height: 1.5;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); color: var(--text);
}
.qr-opt-letter {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--bg-subtle); color: var(--text-muted);
  border: 1.5px solid transparent;
}
.qr-opt-tag {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 2px 8px; border-radius: var(--radius-sm); color: var(--text-muted);
}
/* Both language lines share one edge (the page's), whatever their own direction */
.qr-opt-text > div, .qr-question-text > div { text-align: left; }
[dir="rtl"] .qr-opt-text > div, [dir="rtl"] .qr-question-text > div { text-align: right; }
.qr-bi-alt { color: var(--text-muted); }
.qr-question-text .qr-bi-alt { font-weight: 500; }
.qr-opt.is-ok { background: rgba(34,197,94,.12); border-color: var(--success); }
.qr-opt.is-ok .qr-opt-letter { background: var(--success); color: #fff; }
.qr-opt.is-ok .qr-opt-tag { color: var(--success); }
.qr-opt.is-bad { background: rgba(220,38,38,.08); border-color: var(--danger); }
.qr-opt.is-bad .qr-opt-letter { background: var(--danger); color: #fff; }
.qr-opt.is-bad .qr-opt-tag { color: var(--danger); }
.qr-opt.is-missed { border: 1.5px dashed var(--success); }
.qr-opt.is-missed .qr-opt-letter { background: transparent; border-color: var(--success); color: var(--success); }
.qr-opt.is-missed .qr-opt-tag { background: var(--warning-light); color: var(--warning); }
.qr-opt.is-idle .qr-opt-text, .qr-opt.is-idle .qr-bi-alt { color: var(--text-muted); }
@media (max-width: 640px) {
  .qr-opt { grid-template-columns: 26px minmax(0, 1fr); }
  .qr-opt-tag { grid-column: 2; justify-self: start; }
}

.qr-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px;
}
.qr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.qr-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); }
.qr-swatch.is-ok { background: rgba(34,197,94,.25); border-color: var(--success); }
.qr-swatch.is-bad { background: rgba(220,38,38,.18); border-color: var(--danger); }
.qr-swatch.is-missed { border: 1.5px dashed var(--success); }

.badge-red    { background: rgba(220,38,38,.12); color: var(--danger);  border: 1px solid rgba(220,38,38,.2); }
.badge-yellow { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }

/* ════════════════════════════════════════════════════════════════════
   RTL (Arabic) — mirror the physically-positioned chrome.
   Flex/inline-text layouts flip automatically from dir="rtl"; these
   rules handle the few elements anchored with physical left/margin-left.
   ════════════════════════════════════════════════════════════════════ */
html[dir="rtl"] .sidebar { left: auto; right: 0; }
html[dir="rtl"] #page-wrap { margin-left: 0; margin-right: var(--sidebar-w); }

/* Tables: header/cells align to the start of the line */
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }


/* Absolutely-positioned dropdowns/menus anchored left → anchor right */
html[dir="rtl"] .phone-code-panel { left: auto; right: 0; }
html[dir="rtl"] .cb-icon-picker   { left: auto; right: 0; }
html[dir="rtl"] .lb-quiz-picker-panel { left: auto; right: 0; }
html[dir="rtl"] .lb-quiz-picker-btn   { text-align: right; }

/* The phone country combo button joins the number input on the start side */
html[dir="rtl"] .phone-code-btn {
  border-right: none;
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Mobile drawer slides in from the right */
@media (max-width: 767px) {
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  html[dir="rtl"] #page-wrap { margin-right: 0; }
  html[dir="rtl"] .sidebar-hamburger { left: auto; right: 16px; }
}

/* Login brand panel: diagonal gradient angle is a physical direction, so it
   doesn't flip when the grid moves this panel to the right in RTL — without
   this, the dark end of the gradient lands on the seam instead of the outer
   corner, reading as a stray shadow next to the form. */
html[dir="rtl"] .login-left { background: linear-gradient(215deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%); }

/* ══════════════════════════════════════════════════════════════
   Quiz Builder — import questions from a previous quiz
   ══════════════════════════════════════════════════════════════ */

.qi-modal {
  max-width: 760px;
  height: min(80vh, 720px);
  padding: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.qi-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.qi-title { font-size: 17px; margin: 0; flex: 1; }

.qi-tabs {
  display: flex; gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.qi-tabs .panel-tab {
  background: none; border: none; border-bottom: 2.5px solid transparent;
  font-family: inherit; cursor: pointer;
}

.qi-body { flex: 1; overflow-y: auto; padding: 16px 22px; }
.qi-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}
.qi-foot-count { flex: 1; font-size: 13px; color: var(--text-muted); }

.qi-search { margin-bottom: 12px; }
.qi-empty { padding: 34px 10px; text-align: center; font-size: 13.5px; color: var(--text-muted); }
.qi-muted { color: var(--text-muted); }
.qi-list { display: flex; flex-direction: column; }

/* Quiz rows — step 1 */
.qi-quiz-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: start;
  padding: 12px 10px;
  background: none; border: none; border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-family: inherit; font-size: 14px; color: var(--text); cursor: pointer;
  transition: background var(--transition);
}
.qi-quiz-row:last-child { border-bottom: none; }
.qi-quiz-row:hover { background: var(--bg-subtle); }
.qi-quiz-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qi-quiz-title { font-weight: 500; }
.qi-quiz-sub { font-size: 12px; color: var(--text-muted); }
.qi-chevron { color: var(--text-subtle); font-size: 18px; flex-shrink: 0; }
[dir="rtl"] .qi-chevron { transform: scaleX(-1); }

.qi-crumb { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.qi-crumb-title { font-weight: 500; font-size: 14px; min-width: 0; }

/* Question rows — step 2 and search results */
.qi-selectall {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 10px;
  font-size: 13px; color: var(--text-muted); cursor: pointer;
}
.qi-q-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.qi-q-row:last-child { border-bottom: none; }
.qi-q-row:hover { background: var(--bg-subtle); }
.qi-q-row.is-selected { background: var(--primary-light); }
.qi-q-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qi-q-text { font-size: 14px; line-height: 1.45; }
.qi-q-sub { font-size: 12px; color: var(--text-muted); }
.qi-q-row .qb-preview-opts { gap: 4px; }
.qi-q-row .qb-preview-opt { padding: 5px 10px; font-size: 12.5px; }
.qi-q-row .qb-type-badge, .qi-quiz-row .qb-type-badge { flex-shrink: 0; }

/* The global input { width:100% } rule stretches checkboxes — opt them out. */
.qi-cb {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

@media (max-width: 768px) {
  .qi-modal { height: 88vh; max-width: none; }
  .qi-quiz-row { flex-wrap: wrap; }
}

/* ── Import from Excel (excel-import-modal.js) — reuses the qi-* shell ── */
.qx-modal { max-width: 680px; height: auto; max-height: min(85vh, 760px); }
.qx-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 170px; padding: 24px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--bg-subtle);
  text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.qx-drop:hover, .qx-drop:focus-visible, .qx-drop.is-over {
  border-color: var(--primary); background: var(--primary-light); outline: none;
}
.qx-drop-icon { font-size: 30px; line-height: 1; }
.qx-drop-main { font-weight: 500; font-size: 14.5px; }
.qx-drop-sub  { font-size: 12.5px; color: var(--text-muted); }
.qx-template {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 16px; font-size: 13.5px; color: var(--text-muted);
}
.qx-howto { margin: 14px 0 0; padding-inline-start: 20px; font-size: 13px; color: var(--text-muted); line-height: 1.7; }

.qx-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.qx-file { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qx-counts { display: flex; gap: 8px; margin-bottom: 12px; }
.qx-count { font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; }
.qx-count.ok  { background: #dcfce7; color: #166534; }
.qx-count.bad { background: #fee2e2; color: #991b1b; }
.qx-errors {
  margin-bottom: 14px; padding: 10px 14px;
  border: 1px solid #fecaca; border-radius: var(--radius);
  background: #fef2f2; color: #991b1b; font-size: 13px;
}
.qx-errors-title { font-weight: 500; margin-bottom: 6px; }
.qx-errors ul { margin: 0; padding-inline-start: 18px; max-height: 150px; overflow-y: auto; line-height: 1.7; }
.qx-q-row { cursor: default; }
.qx-q-row:hover { background: none; }
.qx-rownum {
  flex: 0 0 auto; min-width: 26px; margin-top: 1px;
  font-size: 11.5px; color: var(--text-muted); text-align: center;
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 4px;
}
.qx-skip { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
[data-theme="dark"] .qx-count.ok  { background: rgba(34,197,94,.15); color: #86efac; }
[data-theme="dark"] .qx-count.bad,
[data-theme="dark"] .qx-errors   { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.35); }

/* ══════════════════════════════════════════════════════════════════════
   Portal search — sidebar box + dropdown, and the #/search results page
   The box lives inside .sidebar, so it borrows that block's scoped dark
   palette (--sb-*) and stays dark in both app themes.
   ══════════════════════════════════════════════════════════════════════ */
.sidebar-search {
  position: relative;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--sb-hover);
  border: 1px solid var(--sb-border);
  border-radius: 9px;
  padding: 0 9px;
  transition: border-color .15s ease, background .15s ease;
}
.sidebar-search-field:focus-within {
  border-color: #60a5fa;
  background: rgba(255, 255, 255, .10);
}
.sidebar-search-icon {
  display: flex;
  flex: 0 0 auto;
  color: var(--sb-muted);
}
.sidebar-search-icon svg { width: 15px; height: 15px; }
.sidebar-search-field:focus-within .sidebar-search-icon { color: #93c5fd; }

/* Beat the global input{width:100%} + app input styling inside the dark rail */
.sidebar-search-field input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  background: transparent;
  border: 0;
  outline: none;
  padding: 8px 0;
  font-size: 13px;
  color: #fff;
  box-shadow: none;
}
.sidebar-search-field input[type="search"]::placeholder { color: var(--sb-muted); }
.sidebar-search-field input[type="search"]::-webkit-search-cancel-button { display: none; }

.sidebar-search-clear {
  flex: 0 0 auto;
  display: flex;
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  color: var(--sb-muted);
}
.sidebar-search-clear:hover { color: #fff; }
.sidebar-search-clear svg { width: 14px; height: 14px; }

.sidebar-search-kbd {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--sb-muted);
  border: 1px solid var(--sb-border);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}
.sidebar-search-field:focus-within .sidebar-search-kbd { display: none; }

/* Dropdown — overlays the page area, anchored to the box */
.search-dropdown {
  position: absolute;
  z-index: 260;
  top: calc(100% - 4px);
  inset-inline-start: 12px;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
}
.search-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 7px 12px 4px;
}
.search-row {
  display: flex;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
}
.search-row.selected { background: var(--bg-subtle); }
.search-row-icon {
  flex: 0 0 auto;
  display: flex;
  padding-top: 2px;
  color: var(--text-muted);
}
.search-row-icon svg { width: 15px; height: 15px; }
.search-row-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-row-title {
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.search-row-crumb, .search-row-snippet {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-dropdown-empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
/* Sticky so "see all" stays reachable once the list starts scrolling */
.search-dropdown-footer {
  position: sticky;
  bottom: -4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 12px;
}
.search-see-all { color: var(--primary); font-weight: 600; }
.search-kbd-hint { color: var(--text-muted); font-size: 10.5px; white-space: nowrap; }

.search-dropdown mark, .search-card mark {
  background: #fde68a;
  color: #713f12;
  padding: 0 2px;
  border-radius: 2px;
}
[data-theme="dark"] .search-dropdown mark,
[data-theme="dark"] .search-card mark { background: #a16207; color: #fef3c7; }

.search-draft-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Results page ─────────────────────────────────────────────────── */
.search-page-heading { margin-bottom: 14px; }
.search-page-field {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  margin-bottom: 14px;
}
.search-page-field:focus-within { border-color: var(--primary); }
.search-page-icon { display: flex; flex: 0 0 auto; color: var(--text-muted); }
.search-page-icon svg { width: 18px; height: 18px; }
.search-page-field input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  padding: 11px 0;
  font-size: 15px;
}
.search-page-filters { margin-bottom: 12px; }
.search-page-count { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.search-page-group {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 16px 0 7px;
}
.search-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s ease, transform .12s ease;
}
.search-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.search-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-card-icon { display: flex; flex: 0 0 auto; color: var(--primary); }
.search-card-icon svg { width: 17px; height: 17px; }
.search-card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.search-card-crumb { font-size: 12px; color: var(--text-muted); margin: 4px 0 0 25px; }
.search-card-snippet { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 6px 0 0 25px; }
.search-page-empty { text-align: center; padding: 44px 16px; color: var(--text-muted); }
.search-page-empty-icon { font-size: 40px; margin-bottom: 10px; }
.search-page-empty-hint { font-size: 13px; }

html[dir="rtl"] .search-card-crumb,
html[dir="rtl"] .search-card-snippet { margin-left: 0; margin-right: 25px; }

/* ── Trainee Info (#/trainees-overview) ──────────────────────────────── */

/* Plain in-table link: reads as text until hovered, so grouped tables stay calm. */
.link-plain { color: inherit; text-decoration: none; }
.link-plain:hover { color: var(--primary); text-decoration: underline; }

.tov-groupby { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.tov-groups { display: flex; flex-direction: column; gap: 12px; }
.tov-group { padding: 0; overflow: hidden; }

.tov-group-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  width: 100%; padding: 14px 18px; cursor: pointer;
  background: none; border: none; font: inherit; color: inherit; text-align: start;
}
.tov-group-head:hover { background: var(--bg-subtle, rgba(127,127,127,.06)); }
.tov-caret { display: inline-block; transition: transform .15s ease; color: var(--text-muted); }
.tov-group-name { font-weight: 700; }
.tov-group-count {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  background: var(--bg-subtle, rgba(127,127,127,.1)); border-radius: 999px; padding: 2px 10px;
}
.tov-group-summary { font-size: 12px; color: var(--text-muted); margin-inline-start: auto; }

.tov-group-body { overflow-x: auto; border-top: 1px solid var(--border); }
.tov-group-body table { width: 100%; font-size: 13px; min-width: 940px; }

/* ── User detail (#/users/:id) ────────────────────────────────────────────── */

.ud-back {
  display: inline-block; margin-bottom: 12px; font-size: 13px;
  color: var(--text-muted); text-decoration: none;
}
.ud-back:hover { color: var(--primary); }

.ud-header { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.ud-avatar { width: 56px; height: 56px; font-size: 22px; flex: 0 0 auto; }
.ud-identity h1 { margin: 0 0 2px; font-size: 22px; }
.ud-email { font-size: 13px; color: var(--text-muted); }
.ud-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.ud-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.ud-card { margin-bottom: 16px; }
.ud-card-title { font-size: 15px; margin: 0 0 4px; }
.ud-card-hint { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }

.ud-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.ud-field-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); margin-bottom: 3px;
}
.ud-field-value { font-size: 14px; }
.ud-subtle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.ud-edit-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.ud-edit { flex: 1 1 200px; }
.ud-save-note { font-size: 12.5px; font-weight: 600; padding-bottom: 9px; }
.ud-save-note.ok  { color: var(--success); }
.ud-save-note.bad { color: var(--danger); }

.ud-overall { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ud-overall .tp-pctnum { font-size: 30px; }

.ud-journey-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ud-steps { display: flex; flex-direction: column; gap: 6px; }
.ud-step {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border);
}
.ud-step--completed { opacity: .72; }
.ud-step--current   { border-color: var(--primary); }
.ud-step--locked    { opacity: .55; }
.ud-step-index {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--bg-subtle, rgba(127,127,127,.1));
}
.ud-step-title { flex: 1 1 auto; font-size: 13.5px; }

.ud-hist { display: flex; flex-direction: column; gap: 8px; }
.ud-hist-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.ud-hist-change { flex: 1 1 auto; }
.ud-hist-row .ud-subtle { margin-top: 0; margin-inline-start: auto; }
.ud-diff s { color: var(--text-muted); }

html[dir="rtl"] .tov-caret { transform: scaleX(-1); }

/* ── My Profile (#/profile) ─────────────────────────────────────────────── */

/* Sidebar: the identity half of the user row is now a link into the profile. */
.sidebar-user-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0; margin: 0;
  border: none; background: none;
  font-family: inherit; text-align: start;
  cursor: pointer;
  border-radius: 10px;
  color: inherit; text-decoration: none;
  transition: opacity .15s ease;
}
.sidebar-user-btn:hover { opacity: .82; }
.sidebar-user-btn.active .sidebar-user-name { text-decoration: underline; text-underline-offset: 3px; }
.sidebar-avatar-img { object-fit: cover; padding: 0; }

.pf-identity {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.pf-photo-block { display: flex; align-items: center; gap: 16px; position: relative; }
.pf-photo {
  width: 96px; height: 96px; flex: 0 0 auto;
  border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  display: flex; align-items: center; justify-content: center;
}
.pf-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-photo-initial { color: #fff; font-size: 34px; font-weight: 700; }

.pf-photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pf-photo-actions .btn { margin: 0; }
.pf-photo-hint { font-size: 12px; color: var(--text-muted); }
.pf-photo-remove { color: var(--danger); }

.pf-identity-info { min-width: 0; }
.pf-identity-info h2 { font-size: 20px; margin: 0 0 4px; }
.pf-email { font-size: 13.5px; color: var(--text-muted); }
.pf-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pf-readonly-note { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

.pf-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
}

/* The field that blocked a save — cleared as soon as it is touched. */
.form-control.pf-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-light, rgba(239, 68, 68, .15));
}

.pf-msg {
  margin-top: 16px; padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600;
  /* Restarted from JS on every save, so saving twice still reads as an event
     rather than an unchanged line of text. */
  animation: pf-msg-pop .28s ease;
}
@keyframes pf-msg-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.pf-msg--ok   { background: var(--success-light, rgba(34,197,94,.12)); color: var(--success); }
.pf-msg--bad  { background: var(--danger-light,  rgba(239,68,68,.12)); color: var(--danger); }
.pf-msg--info { background: var(--bg-subtle, rgba(127,127,127,.1));    color: var(--text-muted); }

@media (max-width: 640px) {
  .pf-identity { gap: 16px; }
  .pf-photo { width: 76px; height: 76px; }
  .pf-photo-initial { font-size: 28px; }
}

/* ── Quiz incentive (حافز) ─────────────────────────────────────────────────
   Gift tone = warm amber, kept separate from pass/fail green and red. */
:root              { --gift: #b45309; --gift-light: #fff7ed; --gift-border: #fdba74; }
[data-theme="dark"] { --gift: #fdba74; --gift-light: rgba(194,65,12,.18); --gift-border: rgba(253,186,116,.45); }

.notif-icon-reward { background: var(--gift-light); color: var(--gift); }

/* Builder settings block */
.qb-reward {
  border: 1px dashed var(--border-hover); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 14px;
  transition: border-color var(--transition), background var(--transition);
}
.qb-reward.is-on { border: 1px solid var(--gift-border); background: var(--gift-light); }
.qb-reward-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; margin: 0; }
.qb-reward-toggle input[type="checkbox"] { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; }
.qb-reward-fields { display: none; margin-top: 12px; }
.qb-reward.is-on .qb-reward-fields { display: block; }
.qb-reward-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 10px; }
/* A label that wraps to two lines must not push its input out of line. */
.qb-reward-row > div { display: flex; flex-direction: column; justify-content: flex-end; }
.qb-reward-fields .form-control { margin-bottom: 0; }
.qb-reward-hint { font-size: 12px; color: var(--gift); margin-top: 8px; line-height: 1.5; }
.reward-time-cond {
  display: block; margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--warning-light); color: var(--warning); border: 1px dashed currentColor;
}
.reward-timer-chip { font-variant-numeric: tabular-nums; }
.reward-timer-chip.is-urgent { background: var(--warning); color: #fff; }
.reward-timer-chip.is-over   { background: rgba(0,0,0,.25); opacity: .85; }

/* Trainee-facing banner, chip and result lines */
.reward-banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--gift-light); color: var(--gift); border: 1px solid var(--gift-border);
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 14px; line-height: 1.5;
}
.reward-banner-icon { font-size: 20px; line-height: 1; }
.reward-banner-desc { display: block; font-size: 12.5px; opacity: .85; margin-top: 2px; }
.reward-chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--gift-light); color: var(--gift); border: 1px solid var(--gift-border);
  font-variant-numeric: tabular-nums;
}
.reward-chip.is-paid      { background: var(--success-light); color: var(--success); border-color: transparent; }
.reward-chip.is-cancelled { text-decoration: line-through; opacity: .7; }
.reward-result { display: grid; gap: 8px; margin: 4px 0 16px; text-align: start; }
.reward-earned {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; color: var(--gift); background: var(--gift-light);
  border: 1px solid var(--gift-border); border-radius: var(--radius); padding: 10px 14px;
}
.reward-earned.is-cancelled { color: var(--text-muted); background: var(--bg-subtle); border-color: var(--border); }
.reward-missed { font-size: 13px; color: var(--text-muted); text-align: center; }
.review-notice { font-size: 13.5px; border-radius: var(--radius); padding: 10px 14px; line-height: 1.5; }
.review-notice.is-locked { background: var(--warning-light); color: var(--warning); }
.review-notice.is-open   { background: var(--success-light); color: var(--success); }
.review-notice.is-ended  { background: var(--bg-subtle); color: var(--text-muted); }
.answer-recorded { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

.reward-balance-chip {
  display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
  font-weight: 600; color: var(--gift); background: var(--gift-light);
  border: 1px solid var(--gift-border); border-radius: 999px; padding: 6px 14px; text-decoration: none;
}
.reward-balance-chip:hover { border-color: var(--gift); }
.reward-balance-sub { font-weight: 400; font-size: 12px; opacity: .85; }

/* Balance tiles + ledger table (profile and admin) */
.pf-rewards { margin-bottom: 20px; }
.pf-rewards-title { margin: 0 0 14px; font-size: 16px; }
.reward-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.reward-tile { background: var(--bg-subtle); border-radius: var(--radius); padding: 12px 14px; }
.reward-tile span { display: block; font-size: 12px; color: var(--text-muted); }
.reward-tile b { display: block; font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.reward-tile.is-balance b { color: var(--gift); }
.table-scroll { overflow-x: auto; }
.reward-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.reward-table th, .reward-table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.reward-table th { font-weight: 500; font-size: 12.5px; color: var(--text-muted); }
.reward-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.reward-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.rwd-check { flex: 0 0 auto; width: 18px !important; height: 18px; margin: 0; }
.rwd-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.rwd-toolbar select.form-control { width: auto; min-width: 150px; margin: 0; }
.rwd-paybar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.rwd-paybar .form-control { flex: 1 1 220px; margin: 0; }

/* Quiz responses control bar (progress, lock state, end quiz) */
.qr-control-bar {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.qr-ctl-item { font-size: 13.5px; color: var(--text-muted); }
.qr-ctl-item strong { color: var(--text); font-variant-numeric: tabular-nums; }
.qr-ctl-link { font-size: 13px; }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-light); }

/* Quiz WhatsApp dialog: one chat button per assigned trainee (whatsapp-share.js) */
.wa-recipients { margin: 4px 0 12px; border: 1px solid var(--border); border-radius: 12px; max-height: 240px; overflow-y: auto; text-align: start; }
.wa-recipients-head { position: sticky; top: 0; background: var(--bg-subtle); padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.wa-recipient { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.wa-recipient:last-child { border-bottom: 0; }
.wa-recipient-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-recipient .wa-btn { flex: 0 0 auto; }
.wa-recipient.sent .wa-btn { background: var(--success-light); color: var(--success); border-color: transparent; }
.wa-recipient-nophone { font-size: 12px; color: var(--text-muted); flex: 0 0 auto; }

/* ── Staff dashboard (admin / instructor) — pages/dashboard-admin.js ───────── */
.adash { display: flex; flex-direction: column; gap: 20px; max-width: 1680px; }
.adash-h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.adash a.adash-plain { color: inherit; text-decoration: none; }
.adash a.adash-plain:hover { color: var(--primary); }
.adash-muted { color: var(--text-muted); font-size: 12.5px; }
.adash-empty { color: var(--text-muted); font-size: 13px; padding: 18px 0; text-align: center; }
.adash-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.adash .card { animation: dashIn .4s ease both; }

/* Tones shared by icons, pills and action cards */
.adash .tone-warn    { --tone: var(--warning); --tone-bg: var(--warning-light); }
.adash .tone-info    { --tone: var(--primary); --tone-bg: var(--primary-light); }
.adash .tone-danger  { --tone: var(--danger);  --tone-bg: var(--danger-light); }
.adash .tone-success { --tone: var(--success); --tone-bg: var(--success-light); }
.adash .tone-purple  { --tone: var(--purple);  --tone-bg: rgba(139, 92, 246, .14); }
.adash .tone-neutral { --tone: var(--text-muted); --tone-bg: var(--bg-subtle); }
.adash-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; background: var(--tone-bg); color: var(--tone); white-space: nowrap; }

/* 1. Hero */
.adash-hero { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 24px 26px 26px; color: #fff;
  background: linear-gradient(135deg, #1e3a8a 0%, var(--primary) 55%, #7c3aed 100%); box-shadow: var(--shadow-md);
  animation: dashIn .4s ease both; }
.adash-hero::before, .adash-hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); pointer-events: none; }
.adash-hero::before { width: 260px; height: 260px; inset-inline-end: -70px; top: -110px; }
.adash-hero::after  { width: 160px; height: 160px; inset-inline-start: 30%; bottom: -100px; }
.adash-hero-head { position: relative; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.adash-hero-head h1 { font-size: 24px; margin: 0; color: #fff; }
.adash-hero-since { font-size: 12.5px; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 999px; }
.adash-tiles { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 20px; }
.adash-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; text-decoration: none; color: #fff;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); backdrop-filter: blur(4px);
  transition: transform var(--transition), background var(--transition); }
a.adash-tile:hover { transform: translateY(-3px); background: rgba(255,255,255,.24); }
.adash-tile-icon { font-size: 20px; }
.adash-tile-num { font-size: 28px; font-weight: 800; line-height: 1.15; }
.adash-tile-label { font-size: 12.5px; opacity: .9; }
.adash-hero-quiet { grid-column: 1 / -1; font-size: 14px; opacity: .9; }

/* 2. Action cards */
.adash-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.adash-act { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition); animation: dashIn .4s ease both; }
.adash-act::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: 0; height: 4px; background: var(--tone); }
.adash-act:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.adash-act-top { display: flex; align-items: center; justify-content: space-between; }
.adash-act-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: var(--tone-bg); }
.adash-act-num { font-size: 32px; font-weight: 800; color: var(--tone); line-height: 1; }
.adash-act-title { font-weight: 700; font-size: 14px; margin-top: 4px; }
.adash-act-sub { color: var(--text-muted); font-size: 12.5px; flex: 1; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.adash-act-cta { align-self: flex-start; margin-top: 6px; padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  text-decoration: none; background: var(--tone-bg); color: var(--tone); transition: filter var(--transition); }
.adash-act-cta:hover { filter: brightness(.95); }
.adash-allclear { text-align: center; color: var(--success); font-weight: 600; }

/* 3. KPI cards */
.adash-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .adash-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .adash-kpis { grid-template-columns: 1fr; } }
.adash-kpi { padding: 16px 18px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden; animation: dashIn .4s ease both; }
.adash-kpi::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: 0; height: 3px; background: var(--kpi); }
.adash-kpi-head { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.adash-kpi-icon { font-size: 15px; }
.adash-kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; }
.adash-kpi-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.adash-spark { width: 110px; height: 40px; flex: 0 0 auto; }
.adash-kpi-ring .ring-label { font-size: 0; }
.adash-delta { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.adash-delta.up { color: var(--success); }
.adash-delta.down { color: var(--danger); }

/* 4. 14-day activity chart */
.adash-chart-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.adash-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-muted); }
.adash-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.adash-legend-item b { color: var(--text); }
.adash-cols-chart { display: flex; align-items: stretch; gap: 6px; height: 190px; padding-top: 6px; }
.adash-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; outline: none; }
.adash-col-stack { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0;
  overflow: hidden; background: transparent; }
.adash-col-stack i { display: block; width: 100%; min-height: 3px; transition: opacity var(--transition); }
.adash-col-stack i.zero { height: 3px; background: var(--bg-subtle); }
.adash-col:hover .adash-col-stack i, .adash-col:focus .adash-col-stack i { opacity: .75; }
.adash-col-num { font-size: 11px; font-weight: 700; color: var(--text-muted); min-height: 14px; }
.adash-col-day { font-size: 11px; color: var(--text-subtle); }
.adash-col:last-child .adash-col-day { color: var(--primary); font-weight: 700; }

/* 5. Feed timeline + quiz rings */
.adash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.adash-tl { list-style: none; margin: 0; padding: 0; position: relative; max-height: 460px; overflow-y: auto; }
.adash-tl::before { content: ""; position: absolute; inset-inline-start: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.adash-tl-item { position: relative; display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; }
.adash-tl-icon { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; display: flex;
  align-items: center; justify-content: center; font-size: 15px; background: var(--tone-bg); border: 3px solid var(--card); }
.adash-tl-body { padding-top: 4px; font-size: 13.5px; min-width: 0; }
.adash-qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.adash-qcard { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 14px 10px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--bg-subtle); color: inherit; text-decoration: none;
  transition: transform var(--transition), border-color var(--transition); }
a.adash-qcard:hover { transform: translateY(-3px); border-color: var(--primary); }
.adash-qcard-title { font-weight: 700; font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* 6. Leaders + at risk */
.adash-leader { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.adash-leader:last-child { border-bottom: 0; }
.adash-rank { width: 26px; text-align: center; font-size: 18px; font-weight: 800; color: var(--text-muted); flex: 0 0 auto; }
.adash-leader-main { flex: 1; min-width: 0; }
.adash-leader-line { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.adash-hbar { display: flex; height: 8px; border-radius: 4px; background: var(--bg-subtle); overflow: hidden; }
.adash-hbar i { display: block; height: 100%; }
.adash-leader-total { font-size: 18px; font-weight: 800; color: var(--primary); min-width: 28px; text-align: center; }
.adash-person { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.adash-person:last-of-type { border-bottom: 0; }
.adash-person-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adash-more { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 600; }

/* 7. Quick actions */
.adash-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.adash-quick-btn { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; text-decoration: none;
  color: var(--text); font-weight: 600; font-size: 13.5px; background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: transform var(--transition), border-color var(--transition); }
.adash-quick-btn span { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); font-size: 17px; }
.adash-quick-btn:hover { transform: translateY(-2px); border-color: var(--primary); }

@media (max-width: 520px) {
  .adash-hero { padding: 20px 18px; }
  .adash-hero-head h1 { font-size: 20px; }
  .adash-tiles { grid-template-columns: repeat(2, 1fr); }
  .adash-cols { grid-template-columns: 1fr; }
  .adash-cols-chart { gap: 3px; height: 160px; }
  .adash-col-num { display: none; }
}

/* Clickable counts, people popup, hardest quizzes, promotions */
.adash .is-clickable { cursor: pointer; }
.adash-tile.is-clickable:hover, .adash-tile.is-clickable:focus-visible { transform: translateY(-3px); background: rgba(255,255,255,.24); outline: none; }
.adash-kpi.is-clickable { transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
.adash-kpi.is-clickable:hover, .adash-kpi.is-clickable:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--kpi); outline: none; }
.adash-kpi-more { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--kpi); }
button.adash-act-cta { border: 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; }
button.adash-act-cta:disabled { opacity: .5; cursor: wait; }
.modal.adash-pop { max-width: 440px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.adash-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.adash-pop-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.adash-pop-x { border: 0; background: var(--bg-subtle); color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.adash-pop-x:hover { color: var(--text); }
.adash-pop-list { overflow-y: auto; padding: 6px 10px 10px; }
.adash-pop-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: 10px; color: var(--text); text-decoration: none; }
a.adash-pop-row:hover { background: var(--primary-light); text-decoration: none; }
.adash-pop-list .page-loading { min-height: 120px; padding: 0; }
.adash-pop-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adash-pop-go { color: var(--primary); font-weight: 800; font-size: 18px; }
.modal.adash-pop { max-height: 80vh; }
.adash-pop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.adash-pop-main .adash-pop-name { flex: none; }
.adash-pop-sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adash-pop-dot { width: 32px; text-align: center; color: var(--text-muted); flex: 0 0 auto; }
.adash-pop-row .adash-pill { flex: 0 0 auto; }
.adash-pop-group { display: flex; align-items: center; justify-content: space-between; margin: 10px 8px 2px; padding-bottom: 4px;
  font-size: 12.5px; font-weight: 700; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.adash-pop-cap { text-align: center; font-size: 12px; padding: 8px; }
.adash-pop-foot { padding: 10px 18px; border-top: 1px solid var(--border); }
.adash-pop-foot .adash-more { margin: 0; }
.adash-act.is-clickable:hover, .adash-act.is-clickable:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow-md); outline: none; }
.adash-qcard.is-clickable:hover, .adash-qcard.is-clickable:focus-visible { transform: translateY(-3px); border-color: var(--primary); outline: none; }
.adash-col.is-clickable:hover .adash-col-stack, .adash-col.is-clickable:focus-visible .adash-col-stack { filter: brightness(1.1); outline: 2px solid var(--primary-light); outline-offset: 2px; }
.adash-hard.is-clickable, .adash-leader.is-clickable { border-radius: 8px; transition: background var(--transition); }
.adash-hard.is-clickable:hover, .adash-leader.is-clickable:hover,
.adash-hard.is-clickable:focus-visible, .adash-leader.is-clickable:focus-visible { background: var(--primary-light); outline: none; }
.adash-hard { display: grid; grid-template-columns: 1fr 44px; grid-template-areas: "title title" "bar pct"; align-items: center; gap: 4px 10px; padding: 8px 6px; }
.adash-hard-title { grid-area: title; font-size: 13.5px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.adash-hard .adash-hbar { grid-area: bar; }
.adash-hard-pct { grid-area: pct; }
.adash-hard-pct { font-weight: 800; text-align: end; }
.adash-hard-q { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--danger-light); }
.adash-hard-q-text { font-weight: 700; margin: 4px 0 8px; line-height: 1.5; text-align: start; unicode-bidi: plaintext; }
.adash-hard-q-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adash-promo { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.adash-promo-arrow { color: var(--success); font-weight: 800; }
html[dir="ltr"] .adash-promo-arrow, html[dir="ltr"] .adash-pop-go { display: inline-block; transform: scaleX(-1); }

/* ── Protected (reward) quizzes: no selecting/copying, name watermark ── */
.quiz-wrap.is-protected .quiz-body { position: relative; -webkit-user-select: none; user-select: none; }
.quiz-wrap.is-protected textarea { -webkit-user-select: text; user-select: text; }
.quiz-watermark {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 56px 40px; padding: 24px;
  opacity: .07; color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.quiz-watermark span { transform: rotate(-24deg); }
.qt-leave-note {
  background: var(--warning-light); color: var(--warning); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; margin-bottom: 12px; position: relative; z-index: 3;
}
.qt-protected-note {
  font-size: 12.5px; line-height: 1.6; color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0;
}
@media print {
  .quiz-wrap.is-protected { display: none !important; }
}

/* Admin reference: protection measures on incentive quizzes */
.protect-guide {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  margin: 10px 0 14px; font-size: 13px; line-height: 1.65;
}
.protect-guide > summary {
  cursor: pointer; padding: 10px 14px; font-weight: 600; color: var(--primary); list-style-position: inside;
}
.protect-guide[open] > summary { border-bottom: 1px solid var(--border); }
.protect-guide-intro { margin: 10px 14px 0; color: var(--text-muted); }
.protect-guide-sec { padding: 8px 14px 4px; }
.protect-guide-h { font-weight: 700; margin-bottom: 2px; }
.protect-guide ul { margin: 0; padding-inline-start: 20px; }
.protect-guide li { margin: 3px 0; }

/* Admin "preview as trainee" */
.qt-preview-banner {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--primary-light); color: var(--primary); font-size: 13.5px; line-height: 1.6;
  border: 1px dashed currentColor;
}
.qt-preview-note {
  background: var(--primary-light); color: var(--primary); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}

/* Quiz rules on the trainee start page */
.qt-rules {
  margin: 10px 0; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); font-size: 13.5px; line-height: 1.6;
}
.qt-rules-title { font-weight: 700; margin-bottom: 4px; }
.qt-rules ul { margin: 0 0 10px; padding-inline-start: 20px; }
.qt-rules li { margin: 3px 0; }
.qt-rules-note {
  font-weight: 600; color: var(--danger); font-size: 12.5px;
  padding-top: 8px; border-top: 1px dashed var(--border);
}
