/* ============================================================
   SchoolPixels — Design System v2
   Award-grade UI  ·  Bootstrap 5.3.3 overrides
   ============================================================ */

/* ─── 1. Design tokens ──────────────────────────────────── */
:root {
  /* Topbar height — shared between navbar and sidebar positioning */
  --sp-topbar-height: 62px;

  /* Colour palette */
  --sp-bg:             #f0f4f8;
  --sp-surface:        #ffffff;
  --sp-surface-2:      #f8fafc;
  --sp-surface-strong: #ffffff;
  --sp-border:         rgba(15, 23, 42, 0.08);
  --sp-border-strong:  rgba(15, 23, 42, 0.14);

  /* Shadows */
  --sp-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --sp-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sp-shadow:    0 4px 8px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
  --sp-shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.09), 0 4px 8px rgba(15, 23, 42, 0.05);
  --sp-shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.12), 0 8px 16px rgba(15, 23, 42, 0.06);

  /* Accent colours */
  --sp-accent:   #2563eb;
  --sp-accent-h: #1d4ed8;
  --sp-accent-2: #0d9488;
  --sp-accent-3: #f97316;

  /* Text */
  --sp-text:  #0f172a;
  --sp-muted: #64748b;

  /* Border radius */
  --sp-radius:    16px;
  --sp-radius-sm: 10px;
  --sp-radius-xs: 6px;

  /* Focus ring */
  --sp-ring: 0 0 0 3px rgba(37, 99, 235, 0.16);

  /* Sidebar — always dark regardless of colour scheme */
  --sp-sb-bg:         #111827;
  --sp-sb-border:     rgba(255, 255, 255, 0.06);
  --sp-sb-text:       rgba(255, 255, 255, 0.70);
  --sp-sb-muted:      rgba(255, 255, 255, 0.34);
  --sp-sb-hover:      rgba(255, 255, 255, 0.07);
  --sp-sb-active-bg:  rgba(37, 99, 235, 0.85);
  --sp-sb-group-bg:   rgba(255, 255, 255, 0.06);
  --sp-sb-group-text: rgba(255, 255, 255, 0.82);
}

html[data-bs-theme="dark"] {
  --sp-bg:             #0d1117;
  --sp-surface:        #161b22;
  --sp-surface-2:      #1c2128;
  --sp-surface-strong: #21262d;
  --sp-border:         rgba(240, 246, 252, 0.10);
  --sp-border-strong:  rgba(240, 246, 252, 0.18);

  --sp-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.20);
  --sp-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.20);
  --sp-shadow:    0 4px 8px rgba(0, 0, 0, 0.30), 0 2px 4px rgba(0, 0, 0, 0.22);
  --sp-shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.38), 0 4px 8px rgba(0, 0, 0, 0.28);
  --sp-shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.48), 0 8px 16px rgba(0, 0, 0, 0.32);

  --sp-text:  #e6edf3;
  --sp-muted: #8b949e;
  --sp-ring:  0 0 0 3px rgba(88, 166, 255, 0.22);

  --sp-sb-bg:     #0d1117;
  --sp-sb-border: rgba(255, 255, 255, 0.05);
}

/* ─── 2. Base ────────────────────────────────────────────── */
html {
  scroll-padding-top: calc(var(--sp-topbar-height) + 16px);
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100vh;
  background: var(--sp-bg);
  color: var(--sp-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body,
button,
input,
select,
textarea {
  font-family: Manrope, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.is-loading { overflow: hidden; }

h1, h2, h3, h4, h5, h6,
.display-1, .display-2, .display-3,
.display-4, .display-5, .display-6,
.navbar-brand strong,
.panel-kicker {
  letter-spacing: -0.022em;
}

/* Thin scrollbar on supporting browsers */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

html[data-bs-theme="dark"] * {
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ─── 3. App shell & layout ──────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  flex: 1;
  gap: 0;
  padding: 0;
  align-items: start;
}

/* ─── 4. Topbar ──────────────────────────────────────────── */
.navbar-app {
  min-height: var(--sp-topbar-height);
  padding-top: 0;
  padding-bottom: 0;
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-border) !important;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: var(--sp-shadow-xs);
  backdrop-filter: none;
  z-index: 1030;
}

html[data-bs-theme="dark"] .navbar-app {
  background: var(--sp-surface);
  border-bottom-color: var(--sp-border) !important;
}

.navbar-app .container-fluid {
  min-height: var(--sp-topbar-height);
}

.navbar-app .navbar-brand {
  color: var(--sp-text);
  gap: 0.55rem !important;
  line-height: 1;
  letter-spacing: -0.015em;
}

html[data-bs-theme="dark"] .navbar-app .navbar-brand {
  color: var(--sp-text);
}

.navbar-app .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  font-size: 0;
  color: transparent;
  background:
    url("assets/brand/logo.svg") center/cover no-repeat,
    linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.navbar-app .brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
}

.navbar-brand {
  color: var(--sp-text);
  text-decoration: none;
}

.navbar-brand > span:last-child {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.navbar-brand > span:last-child strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  color: transparent;
  font-size: 0;
  font-weight: 800;
  background:
    url("assets/brand/logo.svg") center/cover no-repeat,
    linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--sp-border);
}

.navbar-glass {
  border-left: 0;
  border-right: 0;
}

/* Topbar icon buttons */
.nav-icon-btn {
  width: auto;
  height: auto;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--sp-muted);
  border: 0;
  background: transparent;
  padding: 0.25rem 0.35rem;
  box-shadow: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-icon-btn:hover {
  color: var(--sp-text);
  background: var(--sp-surface-2);
}

html[data-bs-theme="dark"] .nav-icon-btn:hover {
  background: var(--sp-surface-strong);
}

.btn-soft {
  border-radius: 8px;
  color: var(--sp-text);
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-xs);
}

.btn-soft:hover {
  color: var(--sp-text);
  border-color: var(--sp-border-strong);
  background: var(--sp-surface-strong);
  transform: translateY(-1px);
  box-shadow: var(--sp-shadow-sm);
}

.btn-theme-toggle {
  border-radius: 8px;
  color: var(--sp-muted);
  background: transparent;
  border: 0;
  padding: 0.25rem 0.35rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.btn-theme-toggle:hover {
  color: var(--sp-text);
  background: var(--sp-surface-2);
}

.btn-hero {
  border-radius: 999px;
  padding-inline: 1rem;
}

.notification-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px var(--sp-surface);
  animation: sp-pulse-dot 2s infinite;
}

@keyframes sp-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.marks-deadline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(220, 53, 69, 0.10);
  border: 1px solid rgba(220, 53, 69, 0.22);
  color: #dc3545;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.marks-deadline-badge:hover {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.18);
}

.nav-flag {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  display: inline-block;
  background: linear-gradient(
    to bottom,
    #7ab2e5 0 36%,
    #ffffff 36% 42%,
    #0b0b0f 42% 58%,
    #ffffff 58% 64%,
    #7ab2e5 64% 100%
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.searchbar {
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  max-width: 680px;
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
  box-shadow: none;
  backdrop-filter: none;
}

.searchbar input {
  background: transparent;
  color: var(--sp-text);
}

/* ─── 5. Sidebar ─────────────────────────────────────────── */
.sidebar {
  /* Position — sticks below the topbar */
  position: sticky;
  top: var(--sp-topbar-height);
  height: calc(100vh - var(--sp-topbar-height));
  align-self: start;

  /* Sizing */
  width: 260px;
  flex-shrink: 0;

  /* Appearance — always dark */
  background: var(--sp-sb-bg);
  border: none;
  border-right: 1px solid var(--sp-sb-border);
  border-radius: 0;
  backdrop-filter: none;
  box-shadow: none;
  padding: 1.25rem 0.75rem 1.5rem;

  /* Scroll */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.10) transparent;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
}

/* Sidebar section containers */
.sidebar .sidebar-section {
  display: grid;
  gap: 0.35rem;
}

.sidebar .sidebar-section + .sidebar-section {
  margin-top: 1.25rem;
}

/* Brand chip — first sidebar-section label (school name / role scope) */
.sidebar .sidebar-section:first-child .sidebar-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.65rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Regular section labels (e.g. "Quick Stats") */
.sidebar .sidebar-label {
  margin: 0 0 0.35rem;
  padding: 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--sp-sb-muted);
}

/* Nav links */
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  border-radius: 10px;
  color: var(--sp-sb-text);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.52rem 0.65rem;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.sidebar .nav-link i {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.78;
  transition: opacity 0.15s ease;
}

.sidebar .nav-link:hover {
  color: #ffffff;
  background: var(--sp-sb-hover);
  border-color: rgba(255, 255, 255, 0.07);
}

.sidebar .nav-link:hover i { opacity: 1; }

.sidebar .nav-link.active {
  color: #ffffff;
  background: var(--sp-sb-active-bg);
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.30);
}

.sidebar .nav-link.active i { opacity: 1; }

/* Group toggle */
.sidebar-menu-heading {
  margin: 0 0 0.2rem;
  padding: 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--sp-sb-muted);
}

.sidebar .sidebar-menu-toggle {
  color: var(--sp-sb-text);
}

.sidebar .sidebar-menu-toggle.sidebar-menu-toggle-active {
  background: var(--sp-sb-group-bg) !important;
  color: var(--sp-sb-group-text) !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
  box-shadow: none !important;
}

.sidebar-menu-toggle .sidebar-menu-chevron {
  margin-left: auto;
  opacity: 0.6;
  transition: transform 0.22s ease, opacity 0.15s ease;
  font-size: 0.8rem;
}

.sidebar-menu-toggle[aria-expanded="true"] .sidebar-menu-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* Submenu children */
.sidebar-submenu {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.2rem 0 0.3rem 1.65rem;
  position: relative;
}

.sidebar-submenu::before {
  content: "";
  position: absolute;
  left: -0.95rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
}

.sidebar .sidebar-submenu .nav-link {
  font-size: 0.835rem;
  padding: 0.42rem 0.6rem;
  color: rgba(255, 255, 255, 0.60);
  border-radius: 8px;
}

.sidebar .sidebar-submenu .nav-link:hover {
  color: rgba(255, 255, 255, 0.92);
}

.sidebar .sidebar-submenu .nav-link.active {
  color: #ffffff;
  background: rgba(37, 99, 235, 0.65);
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 1px 8px rgba(37, 99, 235, 0.25);
}

/* Override Bootstrap nav-pills .show rule (paints all children blue) */
.sidebar .sidebar-submenu.show > .nav-link:not(.active),
.sidebar-offcanvas .sidebar-submenu.show > .nav-link:not(.active) {
  background-color: transparent;
  background-image: none;
  color: rgba(255, 255, 255, 0.58);
}

.sidebar .sidebar-submenu.show > .nav-link:not(.active):hover,
.sidebar-offcanvas .sidebar-submenu.show > .nav-link:not(.active):hover {
  background-color: var(--sp-sb-hover);
  color: rgba(255, 255, 255, 0.92);
}

/* Badge counter inside sidebar link */
.sidebar .nav-link .sp-unread-chat-badge,
.sidebar-offcanvas .nav-link .sp-unread-chat-badge {
  position: static;
  margin-left: auto;
  flex: 0 0 auto;
}

/* Mini stats at bottom of sidebar */
.sidebar .mini-stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
}

.sidebar .mini-stat span {
  color: rgba(255, 255, 255, 0.40) !important;
}

.sidebar .mini-stat strong {
  color: rgba(255, 255, 255, 0.80);
  font-size: 0.82rem;
}

.sidebar-menu-group + .sidebar-menu-group {
  margin-top: 0.5rem;
}

/* ─── 5b. Offcanvas (mobile sidebar) ─────────────────────── */
.sidebar-offcanvas {
  background: var(--sp-sb-bg);
  border-right: 1px solid var(--sp-sb-border) !important;
}

.sidebar-offcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.sidebar-offcanvas .offcanvas-title {
  color: rgba(255, 255, 255, 0.90);
  font-weight: 700;
}

.sidebar-offcanvas .btn-close {
  filter: invert(1) brightness(0.7);
}

.sidebar-offcanvas .sidebar-section {
  display: grid;
  gap: 0.35rem;
}

.sidebar-offcanvas .sidebar-section:first-child .sidebar-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.65rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.82);
}

.sidebar-offcanvas .sidebar-label,
.sidebar-offcanvas .sidebar-menu-heading {
  color: var(--sp-sb-muted);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  padding: 0 0.6rem;
  margin-bottom: 0.3rem;
}

.sidebar-offcanvas .nav-link {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  border-radius: 10px;
  color: var(--sp-sb-text);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.52rem 0.65rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-offcanvas .nav-link i {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.78;
}

.sidebar-offcanvas .nav-link:hover {
  color: #ffffff;
  background: var(--sp-sb-hover);
}

.sidebar-offcanvas .nav-link.active {
  color: #ffffff;
  background: var(--sp-sb-active-bg);
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.25);
}

.sidebar-offcanvas .sidebar-menu-toggle.sidebar-menu-toggle-active {
  background: var(--sp-sb-group-bg) !important;
  color: rgba(255, 255, 255, 0.82) !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
  box-shadow: none !important;
}

.sidebar-offcanvas .sidebar-submenu {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.2rem 0 0.3rem 1.65rem;
  position: relative;
}

.sidebar-offcanvas .sidebar-submenu::before {
  content: "";
  position: absolute;
  left: -0.95rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 999px;
}

.sidebar-offcanvas .sidebar-submenu .nav-link {
  font-size: 0.835rem;
  padding: 0.42rem 0.6rem;
  color: rgba(255, 255, 255, 0.58);
  border-radius: 8px;
}

.sidebar-offcanvas .sidebar-submenu .nav-link:hover {
  color: rgba(255, 255, 255, 0.92);
}

.sidebar-offcanvas .sidebar-submenu .nav-link.active {
  color: #ffffff;
  background: rgba(37, 99, 235, 0.65);
}

.sidebar-offcanvas .mini-stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
}

.sidebar-offcanvas .mini-stat span {
  color: rgba(255, 255, 255, 0.40) !important;
}

.sidebar-offcanvas .mini-stat strong {
  color: rgba(255, 255, 255, 0.80);
  font-size: 0.82rem;
}

/* ─── 6. Main content ────────────────────────────────────── */
.main-content {
  display: grid;
  gap: 1rem;
  align-content: start;
  padding: 1.5rem;
  min-width: 0;
}

/* Prevent Bootstrap margin utilities from fighting the grid gap */
.main-content > * {
  margin-bottom: 0 !important;
  margin-top: 0 !important;
}

.main-content .card-body {
  padding: 1rem;
}

#students,
#attendance,
#teachers,
#classes,
#reports,
#schools {
  scroll-margin-top: calc(var(--sp-topbar-height) + 16px);
}

/* ─── 7. Page header ─────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
  padding: 0.25rem 0 0.5rem;
}

.page-header h3,
.page-header .display-6 {
  font-size: clamp(1.4rem, 2vw + 0.5rem, 1.9rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.page-header p.text-body-secondary {
  font-size: 0.92rem;
  max-width: 60ch;
}

.header-actions {
  position: relative;
  z-index: 11;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header-actions .dropdown-menu {
  z-index: 2200;
}

/* ─── 8. Sidebar label / panel-kicker ───────────────────── */
.sidebar-label,
.panel-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-size: 0.70rem;
  font-weight: 700;
  color: var(--sp-muted);
}

/* ─── 9. Mini-stat (main content) ───────────────────────── */
.mini-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.72rem 0.9rem;
  border-radius: 10px;
  background: var(--sp-surface-2);
  border: 1px solid var(--sp-border);
}

.mini-stat span,
.stat-card p,
.stack span,
.chart-row span,
.timeline-item p,
.text-body-secondary,
.breadcrumb-item,
.breadcrumb a {
  color: var(--sp-muted) !important;
}

.mini-stat strong {
  color: var(--sp-text);
  font-weight: 700;
}

/* ─── 10. Stats grid ─────────────────────────────────────── */
.stats-grid,
.content-grid {
  display: grid;
  gap: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid--leadership {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-wide {
  grid-column: span 2;
}

/* ─── 11. Panels ─────────────────────────────────────────── */
.panel {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1.25rem;
  box-shadow: var(--sp-shadow-sm);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--sp-shadow-lg);
  border-color: var(--sp-border-strong);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Add a separator line only when panel-head is followed by content */
.panel:has(> .panel-head + *) > .panel-head,
.panel:has(.panel-head + *) .panel-head {
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--sp-border);
}

.panel-head h3 {
  margin: 0.1rem 0 0;
}

/* ─── 12. Stat cards ─────────────────────────────────────── */
.stat-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1.25rem;
  box-shadow: var(--sp-shadow-sm);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sp-shadow-lg);
  border-color: var(--sp-border-strong);
}

.stat-card p,
.stat-card h2 {
  margin-bottom: 0.2rem;
}

.stat-card p {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card h2,
.stat-card .h3 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--sp-text);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
}

/* Gradient stat icon overrides for more vivid colours */
.stat-icon.bg-primary-subtle {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.08)) !important;
  border: 1px solid rgba(37, 99, 235, 0.14);
}
.stat-icon.text-primary { color: #2563eb !important; }

.stat-icon.bg-success-subtle {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.08)) !important;
  border: 1px solid rgba(16, 185, 129, 0.14);
}
.stat-icon.text-success { color: #059669 !important; }

.stat-icon.bg-warning-subtle {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.20), rgba(245, 158, 11, 0.10)) !important;
  border: 1px solid rgba(245, 158, 11, 0.16);
}
.stat-icon.text-warning { color: #d97706 !important; }

.stat-icon.bg-danger-subtle {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.08)) !important;
  border: 1px solid rgba(239, 68, 68, 0.14);
}
.stat-icon.text-danger { color: #dc2626 !important; }

.stat-icon.bg-info-subtle {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(14, 165, 233, 0.08)) !important;
  border: 1px solid rgba(14, 165, 233, 0.14);
}
.stat-icon.text-info { color: #0284c7 !important; }

.stat-icon.bg-secondary-subtle {
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.18), rgba(100, 116, 139, 0.08)) !important;
  border: 1px solid rgba(100, 116, 139, 0.14);
}
.stat-icon.text-secondary { color: #64748b !important; }

/* Card (Bootstrap) */
.card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sp-shadow-lg);
}

.card .card-header {
  background: transparent;
  border-bottom-color: var(--sp-border);
}

/* ─── 13. Buttons ────────────────────────────────────────── */
.btn {
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease;
}

.btn:active {
  transform: translateY(0) !important;
}

.btn-primary,
.btn.btn-primary {
  background: linear-gradient(135deg, var(--sp-accent) 0%, #3b82f6 50%, var(--sp-accent-2));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.30);
}

.btn-primary:hover,
.btn.btn-primary:hover {
  background: linear-gradient(135deg, var(--sp-accent-h) 0%, #2563eb 50%, #0b8079);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.38);
  color: #ffffff;
}

.btn-outline-secondary,
.btn-outline-primary {
  border-width: 1px;
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
  background: var(--sp-surface);
}

.btn-outline-secondary:hover,
.btn-outline-primary:hover {
  border-color: color-mix(in srgb, var(--sp-accent) 40%, var(--sp-border));
  background: var(--sp-surface-2);
  color: var(--sp-text);
}

.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover,
.btn-outline-info:hover {
  transform: translateY(-1px);
}

/* ─── 14. Form controls ──────────────────────────────────── */
.form-control,
.form-select,
.form-check-input {
  border-color: var(--sp-border-strong);
  background: var(--sp-surface);
  color: var(--sp-text);
  border-radius: var(--sp-radius-sm);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: color-mix(in srgb, var(--sp-accent) 60%, var(--sp-border));
  box-shadow: var(--sp-ring);
  background: var(--sp-surface);
}

.form-control::placeholder {
  color: color-mix(in srgb, var(--sp-muted) 70%, transparent);
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--sp-text);
  margin-bottom: 0.4rem;
}

.form-text {
  color: var(--sp-muted);
  font-size: 0.80rem;
}

.input-group .input-group-text {
  border-color: var(--sp-border-strong);
  background: var(--sp-surface-2);
  color: var(--sp-muted);
}

input[type="search"]::-webkit-search-cancel-button,
.form-control[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--sp-text) 22%, transparent);
  background-color: color-mix(in srgb, var(--sp-text) 20%, var(--sp-surface));
  background-image:
    linear-gradient(45deg, transparent 42%, var(--sp-surface-strong) 42%, var(--sp-surface-strong) 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--sp-surface-strong) 42%, var(--sp-surface-strong) 58%, transparent 58%);
  cursor: pointer;
  opacity: 1;
}

/* ─── 15. Focus ring (all interactive) ───────────────────── */
.btn:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.form-check-input:focus {
  outline: none;
  box-shadow: var(--sp-ring);
}

/* ─── 16. Tables ─────────────────────────────────────────── */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--sp-text);
  --bs-table-striped-bg: var(--sp-surface-2);
  --bs-table-hover-bg: color-mix(in srgb, var(--sp-accent) 6%, var(--sp-surface));
  border-color: var(--sp-border);
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--sp-border);
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.table thead th,
.table-light th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--sp-muted);
  border-bottom-width: 1px;
  background: var(--sp-surface) !important;
}

.table-responsive {
  border-radius: var(--sp-radius-sm);
  overflow-x: auto;
  overflow-y: hidden;
}

.table-responsive.sp-table-dropdown-open {
  overflow: visible;
}

.activity-logs-table-wrap {
  max-height: min(68vh, 680px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.activity-logs-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.activity-logs-table-wrap .table-hover > tbody > tr:hover > * {
  background: color-mix(in srgb, var(--sp-accent) 8%, var(--sp-surface));
}

/* Table action buttons */
.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.table-actions .btn,
.table-actions .dropdown .btn {
  margin: 0;
}

.table-actions .btn-more-toggle::after {
  display: none;
}

@media (min-width: 992px) {
  .table-actions .btn-more-toggle {
    min-width: 2rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }
}

/* ─── 17. Badges ─────────────────────────────────────────── */
.badge {
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 0.72rem;
}

.text-bg-success-soft {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

html[data-bs-theme="dark"] .text-bg-success-soft {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.text-bg-warning-soft {
  background: rgba(245, 158, 11, 0.14);
  color: #d97706;
}

html[data-bs-theme="dark"] .text-bg-warning-soft {
  background: rgba(245, 158, 11, 0.20);
  color: #fbbf24;
}

.text-bg-info-soft {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
}

html[data-bs-theme="dark"] .text-bg-info-soft {
  background: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
}

.text-bg-danger-soft {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

html[data-bs-theme="dark"] .text-bg-danger-soft {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

/* ─── 18. Alerts ─────────────────────────────────────────── */
.alert {
  border-radius: var(--sp-radius-sm);
  border-color: var(--sp-border);
}

/* ─── 19. List groups ────────────────────────────────────── */
.list-group-item {
  border-color: var(--sp-border);
  background: transparent;
  border-radius: 0;
}

/* ─── 20. Dropdowns ──────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--sp-border);
  background: var(--sp-surface);
  box-shadow: var(--sp-shadow-xl);
  border-radius: var(--sp-radius);
  padding: 0.4rem;
}

.dropdown-item {
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--sp-text);
  padding: 0.42rem 0.65rem;
  transition: background 0.12s ease, color 0.12s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: color-mix(in srgb, var(--sp-accent) 8%, var(--sp-surface));
  color: var(--sp-text);
}

.dropdown-divider {
  border-color: var(--sp-border);
  margin: 0.3rem 0;
}

/* ─── 21. Modals ─────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--sp-border);
  background: var(--sp-surface);
  box-shadow: var(--sp-shadow-xl);
  border-radius: var(--sp-radius);
}

.modal-header,
.modal-footer {
  border-color: var(--sp-border);
}

.modal-dialog-scrollable .modal-content {
  max-height: 90vh;
}

.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-content > form .modal-body {
  overflow-y: auto;
}

.modal-dialog-scrollable .modal-content > form .modal-footer {
  flex-shrink: 0;
}

/* Stacking helpers for nested modals */
.sp-modal-on-top { z-index: 2000 !important; }
.sp-modal-backdrop-on-top { z-index: 1995 !important; }

/* ─── 22. Breadcrumbs ────────────────────────────────────── */
.breadcrumb {
  --bs-breadcrumb-divider-color: var(--sp-muted);
  font-size: 0.82rem;
}

.breadcrumb .breadcrumb-item a {
  color: color-mix(in srgb, var(--sp-accent) 75%, var(--sp-text));
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb .breadcrumb-item a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── 23. Pagination ─────────────────────────────────────── */
.pagination .page-link {
  border-color: var(--sp-border);
  border-radius: 999px !important;
  margin: 0 0.12rem;
  color: var(--sp-text);
  background: var(--sp-surface);
  transition: all 0.15s ease;
}

.pagination .page-link:hover {
  background: var(--sp-surface-2);
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
  transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
  border-color: transparent;
  background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-2));
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.30);
}

/* ─── 24. Avatars ────────────────────────────────────────── */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--sp-accent), #6366f1);
  flex-shrink: 0;
}

.avatar-shell {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.avatar-photo {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--sp-surface);
  box-shadow: var(--sp-shadow-xs);
}

.avatar-status {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  position: absolute;
  right: 0;
  bottom: 1px;
  box-shadow: 0 0 0 2px var(--sp-surface);
}

.table-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--sp-border);
}

.table-avatar-trigger {
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
  border-radius: 999px;
}

.table-avatar-trigger:focus-visible {
  outline: none;
  box-shadow: var(--sp-ring);
}

.table-avatar-trigger + div,
.table-avatar-trigger + span {
  cursor: pointer;
}

.table-avatar-trigger + div:hover,
.table-avatar-trigger + span:hover {
  color: var(--sp-accent);
}

/* ─── 25. Profile ────────────────────────────────────────── */
.profile-card {
  display: grid;
  align-items: center;
}

.profile-image {
  width: min(260px, 100%);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-lg);
}

.profile-image-fallback {
  width: min(260px, 100%);
  aspect-ratio: 1;
  border-radius: 20px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  color: #ffffff;
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: linear-gradient(135deg, var(--sp-accent), #6366f1);
}

/* Photo thumbnails in modals */
.modal-photo-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
}

.modal-photo-thumb-lg {
  width: 110px;
  height: 110px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
}

.modal-photo-thumb-xl {
  width: 140px;
  height: 140px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
}

/* Profile modal */
.profile-modal-content { overflow: hidden; }

.profile-modal-header {
  background: linear-gradient(135deg, #4f46e5, var(--sp-accent));
  color: #f8fbff;
}

.profile-modal-header .modal-title { color: inherit; }

.profile-modal-header .btn-close {
  filter: invert(1) grayscale(100%);
}

.profile-modal-body { padding: 0; }

.profile-modal-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 420px;
}

.profile-modal-aside {
  background: linear-gradient(180deg, #0f1628, #0a1020);
  color: #e5edff;
  padding: 1.25rem;
  display: grid;
  align-content: start;
  gap: 0.7rem;
  justify-items: center;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-pill {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.30);
  background: rgba(148, 163, 184, 0.12);
  color: #f8fbff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.28rem 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-pill.is-active {
  background: rgba(34, 197, 94, 0.20);
  border-color: rgba(34, 197, 94, 0.45);
}

.profile-pill.is-inactive,
.profile-pill.is-deleted {
  background: rgba(239, 68, 68, 0.20);
  border-color: rgba(239, 68, 68, 0.45);
}

.profile-pill.is-other {
  background: rgba(245, 158, 11, 0.20);
  border-color: rgba(245, 158, 11, 0.45);
}

.profile-modal-main { padding: 1rem; }

.profile-modal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--sp-border);
  padding-bottom: 0.6rem;
}

.profile-modal-tabs button {
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
  border-radius: 8px;
  font-size: 0.80rem;
  font-weight: 700;
  padding: 0.32rem 0.62rem;
  color: var(--sp-text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.profile-modal-tabs button:hover {
  border-color: var(--sp-border-strong);
  background: var(--sp-surface-strong);
}

.profile-modal-tabs button.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--sp-accent), #6366f1);
  border-color: transparent;
}

.profile-tab-panel { display: none; }
.profile-tab-panel.active { display: block; }

.profile-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.profile-modal-grid.profile-tab-panel { display: none; }
.profile-modal-grid.profile-tab-panel.active { display: grid; }

.profile-modal-item {
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 0.58rem 0.7rem;
  background: var(--sp-surface-2);
  display: grid;
  gap: 0.2rem;
}

.profile-modal-item strong {
  color: var(--sp-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.profile-modal-item span {
  font-size: 0.90rem;
  font-weight: 600;
  color: var(--sp-text);
}

.profile-modal-item-full { grid-column: 1 / -1; }

.profile-modal-footer { border-top: 1px solid var(--sp-border); }

.profile-history-list {
  max-height: 320px;
  overflow-y: auto;
}

@media (max-width: 991.98px) {
  .profile-modal-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .profile-modal-aside {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-right: none;
  }
}

@media (max-width: 575.98px) {
  .profile-modal-grid { grid-template-columns: 1fr; }
}

/* ─── 26. Charts & analysis ──────────────────────────────── */
.chart-card,
.timeline,
.stacked-metrics {
  display: grid;
  gap: 0.9rem;
}

.chart-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 52px;
  gap: 0.75rem;
  align-items: center;
}

.progress {
  height: 6px;
  background: var(--sp-border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.attendance-ring {
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle closest-side, var(--sp-surface) 74%, transparent 75%),
    conic-gradient(var(--sp-accent) 0 347deg, var(--sp-border) 347deg 360deg);
  max-width: 240px;
  margin: 0 auto;
}

.ring-value {
  text-align: center;
}

.ring-value strong {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.timeline-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 0.9rem;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 0.45rem;
  box-shadow: 0 0 0 4px var(--sp-border);
}

.timeline-item p { margin-bottom: 0; }

.stacked-metrics div {
  display: flex;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--sp-border);
}

.analysis-class-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.analysis-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.analysis-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--sp-radius-sm);
  border: 1px solid var(--sp-border);
  background: var(--sp-surface-2);
  color: var(--sp-text);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.analysis-tile i {
  font-size: 1.2rem;
  flex: 0 0 auto;
}

.analysis-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--sp-shadow);
  border-color: color-mix(in srgb, var(--sp-accent) 30%, var(--sp-border));
  color: var(--sp-text);
}

/* ─── 27. Student report link ────────────────────────────── */
.student-report-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--sp-accent);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.05;
  text-decoration: none;
  transition: color 0.15s ease;
}

.student-report-link i { font-size: 0.85rem; }

.student-report-link:hover { color: var(--sp-accent-2); }

.student-report-link:focus-visible {
  outline: none;
  box-shadow: var(--sp-ring);
}

/* ─── 28. Toasts ─────────────────────────────────────────── */
.schoolpixels-toast {
  min-width: min(92vw, 360px);
  box-shadow: var(--sp-shadow-xl);
  border-radius: 14px;
  border: 1px solid var(--sp-border);
}

.schoolpixels-toast .toast-body {
  font-size: 0.91rem;
  line-height: 1.45;
}

.schoolpixels-toast .toast-body strong { font-weight: 700; }

.schoolpixels-toast-icon {
  margin-top: 0.1rem;
  font-size: 1rem;
  opacity: 0.95;
}

/* ─── 29. Loading overlay ────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay-card {
  min-width: min(92vw, 360px);
  padding: 1.5rem;
  border-radius: 20px;
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  text-align: center;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-xl);
}

.loading-overlay-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.loading-overlay-text {
  color: var(--sp-muted);
  font-size: 0.92rem;
}

/* ─── 30. sp-reveal (scroll animation) ──────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .sp-reveal {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.45s ease, transform 0.45s ease;
  }

  .sp-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── 31. Auth shell ─────────────────────────────────────── */
.auth-shell {
  display: grid;
  grid-template-rows: auto 1fr;
}

.auth-page.auth-page-staff {
  background:
    radial-gradient(circle at 14% 12%, rgba(106, 130, 251, 0.24), transparent 34%),
    radial-gradient(circle at 90% 4%, rgba(0, 192, 250, 0.2), transparent 30%),
    linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
}

.auth-page.auth-page-parent {
  background:
    radial-gradient(circle at 16% 10%, rgba(17, 154, 90, 0.22), transparent 34%),
    radial-gradient(circle at 92% 6%, rgba(0, 192, 250, 0.2), transparent 30%),
    linear-gradient(135deg, #2c3e50 0%, #4ca1af 100%);
}

.auth-page .navbar-glass {
  background: rgba(25, 44, 56, 0.8);
  backdrop-filter: blur(14px) saturate(1.5);
  border-color: rgba(255, 255, 255, 0.15) !important;
}

.auth-page .navbar-brand,
.auth-page .navbar-brand small,
.auth-page .btn-theme-toggle {
  color: #ffffff;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.8fr);
  gap: 1.25rem;
  align-items: start;
  padding: 1.25rem;
}

.auth-grid-login-only {
  grid-template-columns: minmax(320px, 495px);
  justify-content: center;
}

.auth-card-centered {
  width: min(495px, 96vw);
  margin: 0 auto;
  align-self: start;
}

.auth-portal-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 0.55rem;
  padding-bottom: 0.15rem;
}

.auth-portal-links::-webkit-scrollbar { height: 0; }

.auth-portal-link {
  flex: 0 0 auto;
  white-space: nowrap;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-decoration: none;
  font-size: 0.89rem;
  font-weight: 800;
  color: #ffffff;
  background: #2370ff;
  padding: 0.45em 0.75em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  position: relative;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
  transform: translateZ(0);
  opacity: 0.94;
  transition: transform 0.13s ease, box-shadow 0.13s ease, filter 0.13s ease;
  backdrop-filter: blur(8px);
}

.auth-portal-link:hover {
  color: #ffffff;
  transform: translateY(-2px);
  filter: brightness(1.02);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
  opacity: 1;
}

.auth-portal-link.is-current,
.auth-portal-link[aria-current="page"] {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.42), 0 14px 30px rgba(0, 0, 0, 0.2);
  filter: brightness(1.03);
  opacity: 1;
}

.auth-portal-link:active { transform: translateY(0); }

.auth-portal-link::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.auth-portal-link-home    { background: #2370ff; }
.auth-portal-link-parent  { background: #2370ff; }
.auth-portal-link-portal  { background: #119a5a; }
.auth-portal-link-scheduler { background: #119a5a; }
.auth-portal-link-students { background: #00c0fa; }
.auth-portal-link-library {
  background: #ffd600;
  color: #232b3a;
  border-color: rgba(255, 214, 0, 0.42);
}
.auth-portal-link-library:hover { color: #0f172a; }

html[data-bs-theme="light"] .auth-portal-link { color: #f8fbff; }

.auth-quick-links {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.6rem;
  padding: 0.72rem;
  overflow-x: auto;
}

.auth-quick-links::-webkit-scrollbar { height: 0; }

.auth-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 700;
  color: var(--sp-text);
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 0.42rem 0.78rem;
  background: color-mix(in srgb, var(--sp-surface) 90%, transparent);
  transition: all 0.15s ease;
}

.auth-quick-link:hover {
  color: var(--sp-accent);
  border-color: color-mix(in srgb, var(--sp-accent) 34%, var(--sp-border));
}

.auth-brand-chip {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: color-mix(in srgb, var(--sp-surface) 78%, transparent);
  color: var(--sp-text);
  padding: 0.35rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-login-logo {
  width: 68px;
  height: 68px;
  margin: calc(1.8rem + 15px) auto 0.75rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(44, 62, 80, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.auth-login-logo img {
  width: 48px;
  height: 48px;
  display: block;
}

.auth-login-brand-card {
  margin: 20px auto 0.6rem;
  width: fit-content;
  max-width: calc(100% - 2rem);
  padding: 0.58rem 0.9rem;
  border-radius: 12px;
  background: linear-gradient(45deg, #edc68f 0%, #8a7958 100%);
  color: #202021;
  text-align: center;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.24;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.auth-card-modern {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 395px;
  padding: 1.15rem 2rem 0.12rem;
}

.auth-card-modern .panel-head { margin-bottom: 1rem !important; }
.auth-card-modern .auth-form { gap: 0.7rem !important; }

.auth-page-footer {
  text-align: center;
  margin-top: 50px;
  padding: 0.2rem 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.88rem;
  font-weight: 600;
}

.auth-page-footer a {
  color: #ffd7a8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-page-footer a:hover { color: #ffe6c7; }

.auth-card-modern::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 90% at 12% 8%, rgba(255, 255, 255, 0.28), transparent 52%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02));
  pointer-events: none;
  z-index: 0;
}

.auth-card-modern::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(10, 20, 35, 0.22);
  pointer-events: none;
  z-index: 0;
}

.auth-card-modern > * {
  position: relative;
  z-index: 1;
}

.auth-page .panel-kicker,
.auth-page .auth-card-modern h4,
.auth-page .auth-card-modern .text-body-secondary,
.auth-page .auth-card-modern .demo-credentials,
.auth-page .auth-card-modern .form-label {
  color: #ffffff !important;
}

.auth-page .auth-card-modern a { color: #dfeaff; }
.auth-page .auth-card-modern a:hover { color: #ffffff; }
.auth-page .auth-card-modern .auth-portal-link { color: #f8fbff; }

.auth-page .auth-card-modern .auth-portal-link:hover,
.auth-page .auth-card-modern .auth-portal-link:focus-visible,
.auth-page .auth-card-modern .auth-portal-link.is-current,
.auth-page .auth-card-modern .auth-portal-link[aria-current="page"] {
  color: #ffffff;
}

.auth-input-group .input-group-text {
  border-color: #6a82fb;
  background: #232b3a;
  color: #6a82fb;
}

.auth-input-group .form-control {
  border-left: 0;
  font-weight: 600;
  background: #f5f7fa;
  border-color: #6a82fb;
  color: #232b3a;
}

.auth-input-group .btn {
  border-color: #6a82fb;
  border-left: 0;
  border-radius: 0 var(--sp-radius-sm) var(--sp-radius-sm) 0;
  background: #f5f7fa;
  color: #232b3a;
}

.auth-input-group .btn:hover { color: #1f2a44; }

.auth-page .btn.btn-primary {
  background: linear-gradient(90deg, #6a82fb 0%, #fc5c7d 100%);
  border: 0;
  box-shadow: 0 14px 34px rgba(106, 130, 251, 0.2);
}

html[data-bs-theme="light"] .auth-page.auth-page-staff,
html[data-bs-theme="light"] .auth-page.auth-page-parent {
  background:
    radial-gradient(circle at 14% 12%, rgba(106, 130, 251, 0.2), transparent 34%),
    radial-gradient(circle at 90% 4%, rgba(0, 192, 250, 0.16), transparent 30%),
    linear-gradient(135deg, #3d5c86 0%, #4ca1af 100%);
}

html[data-bs-theme="dark"] .auth-page.auth-page-staff,
html[data-bs-theme="dark"] .auth-page.auth-page-parent {
  background:
    radial-gradient(circle at 14% 12%, rgba(106, 130, 251, 0.22), transparent 34%),
    radial-gradient(circle at 90% 4%, rgba(0, 192, 250, 0.18), transparent 30%),
    linear-gradient(135deg, #253a57 0%, #3f93a1 100%);
}

html[data-bs-theme="light"] .auth-page .navbar-glass {
  background: rgba(19, 43, 66, 0.84);
  border-color: rgba(255, 255, 255, 0.2) !important;
}

html[data-bs-theme="dark"] .auth-page .navbar-glass {
  background: rgba(8, 23, 42, 0.82);
  border-color: rgba(160, 190, 235, 0.26) !important;
}

html[data-bs-theme="light"] .auth-page .auth-card-modern {
  background: rgba(186, 208, 223, 0.88);
  border: 1px solid rgba(124, 154, 198, 0.34);
  box-shadow: 0 18px 48px rgba(8, 24, 46, 0.24);
}

html[data-bs-theme="dark"] .auth-page .auth-card-modern {
  background: rgba(52, 86, 118, 0.72);
  border: 1px solid rgba(142, 180, 240, 0.3);
  box-shadow: 0 20px 52px rgba(0, 10, 24, 0.42);
}

html[data-bs-theme="light"] .auth-page .panel-kicker,
html[data-bs-theme="light"] .auth-page .auth-card-modern h4,
html[data-bs-theme="light"] .auth-page .auth-card-modern .text-body-secondary,
html[data-bs-theme="light"] .auth-page .auth-card-modern .demo-credentials,
html[data-bs-theme="light"] .auth-page .auth-card-modern .form-label {
  color: #21354f !important;
}

html[data-bs-theme="dark"] .auth-page .panel-kicker,
html[data-bs-theme="dark"] .auth-page .auth-card-modern h4,
html[data-bs-theme="dark"] .auth-page .auth-card-modern .text-body-secondary,
html[data-bs-theme="dark"] .auth-page .auth-card-modern .demo-credentials,
html[data-bs-theme="dark"] .auth-page .auth-card-modern .form-label {
  color: #e7f0ff !important;
}

html[data-bs-theme="light"] .auth-page .demo-credentials {
  background: rgba(212, 228, 243, 0.92);
  border-color: rgba(92, 118, 154, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 10px 20px rgba(47, 80, 121, 0.1);
}

html[data-bs-theme="light"] .auth-page .auth-card-modern a { color: #2f4d79; }
html[data-bs-theme="light"] .auth-page .auth-card-modern a:hover { color: #1f3555; }
html[data-bs-theme="light"] .auth-page .auth-card-modern .demo-credentials a { color: #2459a8; }

html[data-bs-theme="dark"] .auth-page .demo-credentials {
  background: rgba(43, 79, 118, 0.78);
  border-color: rgba(146, 178, 232, 0.36);
  box-shadow: inset 0 1px 0 rgba(173, 199, 245, 0.18), 0 10px 22px rgba(0, 8, 20, 0.28);
}

html[data-bs-theme="dark"] .auth-page .auth-card-modern a { color: #d6e6ff; }
html[data-bs-theme="dark"] .auth-page .auth-card-modern a:hover { color: #ffffff; }
html[data-bs-theme="dark"] .auth-page .auth-card-modern .demo-credentials a { color: #9ec2ff; }

html[data-bs-theme="light"] .auth-input-group .input-group-text {
  border-color: #6a82fb;
  background: #22354f;
  color: #87a0ff;
}

html[data-bs-theme="light"] .auth-input-group .form-control {
  background: #ffffff;
  border-color: #7e99ca;
  color: #1f3048;
}

html[data-bs-theme="light"] .auth-input-group .form-control::placeholder {
  color: #7387a5;
}

html[data-bs-theme="light"] .auth-input-group .btn {
  border-color: #7e99ca;
  background: #ffffff;
  color: #1f3048;
}

html[data-bs-theme="dark"] .auth-input-group .input-group-text {
  border-color: #5f82d6;
  background: #2b5d8a;
  color: #bfd3ff;
}

html[data-bs-theme="dark"] .auth-input-group .form-control {
  background: #2b5f8f;
  border-color: #6f93da;
  color: #e4eeff;
}

html[data-bs-theme="dark"] .auth-input-group .form-control::placeholder {
  color: #d2e0f4;
}

html[data-bs-theme="dark"] .auth-input-group .btn {
  border-color: #6f93da;
  background: #2f6696;
  color: #e4eeff;
}

html[data-bs-theme="light"] .auth-page .btn.btn-primary {
  background: linear-gradient(90deg, #5f7cff 0%, #ef5b8f 100%);
}

html[data-bs-theme="dark"] .auth-page .btn.btn-primary {
  background: linear-gradient(90deg, #6f86ff 0%, #ff5d87 100%);
  box-shadow: 0 14px 30px rgba(85, 120, 255, 0.28);
}

html[data-bs-theme="light"] .auth-portal-link { opacity: 0.92; }
html[data-bs-theme="dark"] .auth-portal-link  { opacity: 0.85; }

.auth-hero,
.auth-card {
  border-radius: 28px;
  padding: 1.5rem;
}

.auth-hero {
  display: grid;
  align-content: start;
  gap: 1rem;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(36, 87, 245, 0.16), transparent 32%),
    radial-gradient(circle at bottom left, rgba(20, 184, 166, 0.14), transparent 30%),
    var(--sp-surface);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.auth-hero h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
}

.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto -42px -46px auto;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.24), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.auth-points,
.auth-role-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.auth-points div,
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--sp-border);
  background: color-mix(in srgb, var(--sp-surface) 82%, transparent);
}

.auth-points i { color: var(--sp-accent); }

.auth-card { background: var(--sp-surface); }

.role-badge {
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
}

.auth-form .form-control {
  border-radius: 16px;
  border-color: var(--sp-border);
  background: color-mix(in srgb, var(--sp-surface) 94%, transparent);
  color: var(--sp-text);
}

.auth-form .form-control:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.demo-credentials {
  padding: 1rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--sp-surface) 88%, transparent);
  border: 1px dashed var(--sp-border);
}

/* ─── 32. Error pages ────────────────────────────────────── */
.error-page {
  --error-accent: #2563eb;
  --error-accent-soft: rgba(37, 99, 235, 0.18);
  --error-bg-top: rgba(11, 99, 243, 0.24);
  --error-bg-right: rgba(13, 148, 136, 0.2);
  --error-bg-bottom: rgba(249, 115, 22, 0.14);
  background:
    radial-gradient(circle at 8% -8%, var(--error-bg-top), transparent 32%),
    radial-gradient(circle at 94% 0%, var(--error-bg-right), transparent 28%),
    radial-gradient(circle at 50% 110%, var(--error-bg-bottom), transparent 32%),
    var(--sp-bg);
}

.error-page.error-403 {
  --error-accent: #f59e0b;
  --error-accent-soft: rgba(245, 158, 11, 0.2);
  --error-bg-top: rgba(245, 158, 11, 0.25);
  --error-bg-right: rgba(217, 119, 6, 0.2);
  --error-bg-bottom: rgba(251, 191, 36, 0.15);
}

.error-page.error-401 {
  --error-accent: #7c3aed;
  --error-accent-soft: rgba(124, 58, 237, 0.2);
  --error-bg-top: rgba(124, 58, 237, 0.24);
  --error-bg-right: rgba(59, 130, 246, 0.2);
  --error-bg-bottom: rgba(99, 102, 241, 0.14);
}

.error-page.error-404 {
  --error-accent: #2563eb;
  --error-accent-soft: rgba(37, 99, 235, 0.2);
  --error-bg-top: rgba(14, 165, 233, 0.24);
  --error-bg-right: rgba(37, 99, 235, 0.2);
  --error-bg-bottom: rgba(14, 165, 233, 0.15);
}

.error-page.error-429 {
  --error-accent: #0f766e;
  --error-accent-soft: rgba(15, 118, 110, 0.2);
  --error-bg-top: rgba(13, 148, 136, 0.24);
  --error-bg-right: rgba(20, 184, 166, 0.2);
  --error-bg-bottom: rgba(45, 212, 191, 0.14);
}

.error-page.error-500 {
  --error-accent: #dc2626;
  --error-accent-soft: rgba(220, 38, 38, 0.2);
  --error-bg-top: rgba(239, 68, 68, 0.25);
  --error-bg-right: rgba(220, 38, 38, 0.2);
  --error-bg-bottom: rgba(248, 113, 113, 0.14);
}

.error-page.error-503 {
  --error-accent: #d97706;
  --error-accent-soft: rgba(217, 119, 6, 0.2);
  --error-bg-top: rgba(245, 158, 11, 0.24);
  --error-bg-right: rgba(249, 115, 22, 0.2);
  --error-bg-bottom: rgba(245, 158, 11, 0.14);
}

.error-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.error-main {
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.error-panel {
  width: min(960px, 100%);
  padding: clamp(1.2rem, 2.6vw, 2rem);
  display: grid;
  gap: 1rem;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--error-accent) 22%, transparent), transparent 36%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--error-accent) 14%, transparent), transparent 36%),
    var(--sp-surface);
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-xl);
}

.error-panel::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  bottom: -90px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--error-accent) 28%, transparent), transparent 68%);
  pointer-events: none;
}

.error-code-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.error-code {
  font-size: clamp(2.6rem, 8vw, 4.8rem);
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: -0.045em;
  color: color-mix(in srgb, var(--error-accent) 70%, var(--sp-text));
}

.error-panel .badge {
  color: var(--sp-text);
  background: color-mix(in srgb, var(--error-accent) 15%, var(--sp-surface));
  border-color: color-mix(in srgb, var(--error-accent) 32%, var(--sp-border)) !important;
}

html[data-bs-theme="dark"] .error-panel .badge { color: #e8f1ff; }

.error-title {
  margin: 0;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  letter-spacing: -0.03em;
}

.error-description {
  margin: 0;
  max-width: 72ch;
  color: var(--sp-muted);
}

.error-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.error-meta-grid div {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 0.86rem;
  border-radius: 12px;
  border: 1px solid var(--sp-border);
  background: color-mix(in srgb, var(--sp-surface) 76%, var(--error-accent-soft));
  font-weight: 600;
  color: var(--sp-text);
}

.error-meta-grid i {
  color: color-mix(in srgb, var(--error-accent) 82%, var(--sp-text));
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.error-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.error-context div {
  display: grid;
  gap: 0.2rem;
  padding: 0.62rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--sp-border);
  background: color-mix(in srgb, var(--sp-surface) 88%, var(--error-accent-soft));
}

.error-context span {
  color: var(--sp-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.error-context strong {
  color: var(--sp-text);
  font-size: 0.9rem;
  word-break: break-word;
}

html[data-bs-theme="dark"] .error-panel {
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--error-accent) 20%, transparent), transparent 36%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--error-accent) 14%, transparent), transparent 36%),
    var(--sp-surface);
  border-color: color-mix(in srgb, var(--error-accent) 25%, var(--sp-border));
}

html[data-bs-theme="dark"] .error-meta-grid div,
html[data-bs-theme="dark"] .error-context div {
  border-color: color-mix(in srgb, var(--error-accent) 28%, var(--sp-border));
}

html[data-bs-theme="dark"] .error-footnote,
html[data-bs-theme="dark"] .error-description,
html[data-bs-theme="dark"] .error-context span {
  color: var(--sp-muted);
}

.error-footnote {
  color: var(--sp-muted);
  font-size: 0.92rem;
}

@media (max-width: 991.98px) {
  .error-meta-grid { grid-template-columns: 1fr; }
  .error-context   { grid-template-columns: 1fr; }
}

/* ─── 33. Global transition helper ──────────────────────── */
.panel,
.stat-card,
.card,
.form-control,
.form-select,
.form-check-input,
.btn,
.dropdown-menu,
.modal-content,
.pagination .page-link,
.list-group-item,
.table,
.nav-link {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    opacity 0.18s ease;
}

/* ─── 34. Entry animations (@starting-style) ────────────── */
@media (prefers-reduced-motion: no-preference) {
  @supports (selector(:has(+ *))) {
    /* Stat cards and panels slide up on initial render */
    @starting-style {
      .stat-card,
      .panel {
        opacity: 0;
        transform: translateY(14px);
      }
    }
  }

  .main-content .stat-card {
    animation: sp-fade-up 0.4s ease both;
  }

  .main-content .stats-grid .stat-card:nth-child(1) { animation-delay: 0.00s; }
  .main-content .stats-grid .stat-card:nth-child(2) { animation-delay: 0.06s; }
  .main-content .stats-grid .stat-card:nth-child(3) { animation-delay: 0.12s; }
  .main-content .stats-grid .stat-card:nth-child(4) { animation-delay: 0.18s; }

  .main-content > .panel {
    animation: sp-fade-up 0.45s ease both;
    animation-delay: 0.10s;
  }

  .main-content > .row > * > .panel {
    animation: sp-fade-up 0.42s ease both;
    animation-delay: 0.14s;
  }
}

@keyframes sp-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sp-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Skeleton loader */
.sp-skeleton {
  background: linear-gradient(
    90deg,
    var(--sp-border) 0%,
    color-mix(in srgb, var(--sp-border) 50%, var(--sp-surface)) 50%,
    var(--sp-border) 100%
  );
  background-size: 200% 100%;
  animation: sp-shimmer 1.8s ease infinite;
  border-radius: var(--sp-radius-xs);
}

/* ─── 35. Parent quick nav ───────────────────────────────── */
.parent-quick-nav .btn {
  border-radius: 999px;
  font-weight: 700;
}

/* ─── 36. Responsive ─────────────────────────────────────── */
@media (max-width: 1199.98px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: auto;
  }
}

@media (max-width: 991.98px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .auth-card-modern {
    padding: 1rem 0.9rem 0.1rem;
    min-height: unset;
  }

  .auth-portal-links { gap: 0.4rem; }

  .auth-login-logo { margin-top: calc(1.82rem + 15px); }

  .auth-login-brand-card {
    font-size: 0.95rem;
    padding: 0.52rem 0.78rem;
  }

  .app-layout {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }

  .main-content {
    padding: 1rem;
    min-width: 0;
  }
}

@media (max-width: 767.98px) {
  .panel,
  .stat-card,
  .card,
  .modal-content {
    border-radius: 14px;
  }

  .panel {
    padding: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid--leadership {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: flex-start;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .chart-row strong {
    justify-self: start;
  }

  .main-content {
    padding: 0.875rem;
    gap: 0.875rem;
  }
}

/* ─── 37. Dark mode refinements ──────────────────────────── */
html[data-bs-theme="dark"] .navbar-glass,
html[data-bs-theme="dark"] .sidebar,
html[data-bs-theme="dark"] .panel,
html[data-bs-theme="dark"] .stat-card,
html[data-bs-theme="dark"] .btn-soft,
html[data-bs-theme="dark"] .searchbar {
  border-color: var(--sp-border);
}

html[data-bs-theme="dark"] .panel:hover,
html[data-bs-theme="dark"] .stat-card:hover,
html[data-bs-theme="dark"] .card:hover {
  box-shadow: var(--sp-shadow-xl);
}

html[data-bs-theme="dark"] .table thead th {
  background: var(--sp-surface) !important;
}

html[data-bs-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-primary {
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
  background: transparent;
}

html[data-bs-theme="dark"] .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: var(--sp-surface-strong);
  color: var(--sp-text);
}

html[data-bs-theme="dark"] .modal-content {
  background: var(--sp-surface);
}

html[data-bs-theme="dark"] .dropdown-menu {
  background: var(--sp-surface-strong);
  border-color: var(--sp-border);
}

html[data-bs-theme="dark"] .stat-icon.bg-primary-subtle {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(37, 99, 235, 0.12)) !important;
}
html[data-bs-theme="dark"] .stat-icon.text-primary { color: #60a5fa !important; }

html[data-bs-theme="dark"] .stat-icon.bg-success-subtle {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.12)) !important;
}
html[data-bs-theme="dark"] .stat-icon.text-success { color: #34d399 !important; }

html[data-bs-theme="dark"] .stat-icon.bg-warning-subtle {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(245, 158, 11, 0.14)) !important;
}
html[data-bs-theme="dark"] .stat-icon.text-warning { color: #fbbf24 !important; }

html[data-bs-theme="dark"] .stat-icon.bg-danger-subtle {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.12)) !important;
}
html[data-bs-theme="dark"] .stat-icon.text-danger { color: #f87171 !important; }

html[data-bs-theme="dark"] .stat-icon.bg-info-subtle {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(14, 165, 233, 0.12)) !important;
}
html[data-bs-theme="dark"] .stat-icon.text-info { color: #38bdf8 !important; }

html[data-bs-theme="dark"] .breadcrumb .breadcrumb-item a {
  color: color-mix(in srgb, #60a5fa 75%, var(--sp-text));
}

html[data-bs-theme="dark"] .mini-stat {
  background: var(--sp-surface-strong);
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .form-check-input {
  background: var(--sp-surface-2);
  border-color: var(--sp-border-strong);
  color: var(--sp-text);
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  background: var(--sp-surface-strong);
}

html[data-bs-theme="dark"] .input-group .input-group-text {
  background: var(--sp-surface-strong);
  border-color: var(--sp-border-strong);
}

html[data-bs-theme="dark"] .alert {
  border-color: var(--sp-border);
}

html[data-bs-theme="dark"] .analysis-tile {
  background: var(--sp-surface-strong);
  border-color: var(--sp-border);
}

html[data-bs-theme="dark"] .card {
  background: var(--sp-surface);
  border-color: var(--sp-border);
}
