/* ════════════════════════════════════════════════════════════════
   UnivAttend Design System — Midnight Navy & Golden Amber Palette
   Inspired by high-contrast executive dashboard reference design.
   
   Color Architecture:
     Dominant Surface  → Deep Midnight Navy (#0D1535 / #101A38)
     Radiant Accent    → Golden Amber / Radiant Yellow (#FFC727 / #E5AD12)
     Canvas Base       → Cool Mist Slate (#F4F6FA)
     Elevated Cards    → Pure Crisp White (#FFFFFF)
     Text Visibility   → High-contrast dark navy on light (#0D1535, AAA)
                         High-contrast pure white on navy (#FFFFFF, AAA)
                         High-contrast dark navy on gold (#0D1535, AAA)
   
   Role Theming preserves distinctive role identifiers while
   unifying around the Midnight Navy & Golden Amber visual identity.
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Neutral Canvas & Surfaces */
  --bg: #F4F6FA;
  --bg-2: #EAEFF6;
  --card: #FFFFFF;
  --card-dark: #0D1535;
  --ink: #0D1535;
  --muted: #52637D;
  --line: #E2E8F0;

  /* Primary Accent: Golden Amber (matching reference "New Project", "Upgrade", charts) */
  --primary: #FFC727;
  --primary-deep: #E5AD12;
  --primary-soft: #FFF8E5;
  --primary-soft-2: #FFEEB8;
  --primary-shadow: 0 8px 20px rgba(255, 199, 39, 0.32);
  --on-primary: #0D1535;

  /* Midnight Navy Sidebar Tokens */
  --navy-bg: #0D1535;
  --navy-hover: #17244D;
  --navy-active: #141F45;
  --navy-line: #1A2855;
  --navy-text: #9EAFCE;
  --navy-text-active: #FFFFFF;

  /* Semantic Status Colors (High contrast & WCAG AA/AAA compliant) */
  --red: #EF4444;
  --red-soft: #FEE2E2;
  --red-ink: #B91C1C;
  --orange: #F59E0B;
  --orange-soft: #FEF3C7;
  --orange-ink: #B45309;
  --green: #10B981;
  --green-soft: #D1FAE5;
  --green-ink: #065F46;
  --purple: #8B5CF6;
  --purple-soft: #EDE9FE;
  --purple-ink: #5B21B6;

  --shadow: 0 12px 30px rgba(13, 21, 53, 0.09);
  --shadow-sm: 0 4px 14px rgba(13, 21, 53, 0.05);
  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 10px;
  --sidebar-w: 248px;
}

[data-bs-theme="dark"] {
  --bg: #080E20;
  --bg-2: #0F1731;
  --card: #131E3D;
  --card-dark: #0B1228;
  --ink: #F0F4FC;
  --muted: #9BB0D3;
  --line: #22325E;

  --primary: #FFC727;
  --primary-deep: #E5AD12;
  --primary-soft: #2E2916;
  --primary-soft-2: #3E371C;
  --on-primary: #0D1535;

  --navy-bg: #080D1F;
  --navy-hover: #121A3B;
  --navy-active: #17224B;
  --navy-line: #1E2950;
  --navy-text: #9BB0D3;
  --navy-text-active: #FFFFFF;

  --red-soft: #3B1C22;
  --red-ink: #FCA5A5;
  --orange-soft: #382811;
  --orange-ink: #FCD34D;
  --green-soft: #0F3227;
  --green-ink: #6EE7B7;
  --purple-soft: #2B1E48;
  --purple-ink: #C4B5FD;

  --shadow: 0 12px 30px rgba(0, 0, 0, 0.50);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ── ADMIN · Midnight Navy & Golden Amber ── */
body.theme-admin {
  --bg: #F4F6FA;
  --bg-2: #EAEFF6;
  --card: #FFFFFF;
  --ink: #0D1535;
  --muted: #52637D;
  --line: #E2E8F0;
  --primary: #FFC727;
  --primary-deep: #E5AD12;
  --primary-soft: #FFF8E5;
  --primary-soft-2: #FFEEB8;
  --primary-shadow: 0 8px 20px rgba(255, 199, 39, 0.32);
  --on-primary: #0D1535;
}

[data-bs-theme="dark"] body.theme-admin {
  --bg: #080E20;
  --bg-2: #0F1731;
  --card: #131E3D;
  --ink: #F0F4FC;
  --muted: #9BB0D3;
  --line: #22325E;
  --primary: #FFC727;
  --primary-deep: #E5AD12;
  --primary-soft: #2E2916;
  --primary-soft-2: #3E371C;
  --primary-shadow: 0 8px 20px rgba(255, 199, 39, 0.25);
  --on-primary: #0D1535;
}

/* ── DEPT HEAD · Deep Maroon & Gold Harmony ── */
body.theme-dept {
  --bg: #F7F5F7;
  --bg-2: #ECE6EB;
  --card: #FFFFFF;
  --ink: #22141C;
  --muted: #6B5563;
  --line: #E4D9E2;
  --primary: #8C1D40;
  --primary-deep: #701431;
  --primary-soft: #F9EBEF;
  --primary-soft-2: #F2D5DD;
  --primary-shadow: 0 8px 20px rgba(140, 29, 64, 0.28);
  --on-primary: #FFFFFF;
}

[data-bs-theme="dark"] body.theme-dept {
  --bg: #1A0D14;
  --bg-2: #24141D;
  --card: #2B1823;
  --ink: #F8EDF3;
  --muted: #B89EA9;
  --line: #482939;
  --primary: #D6456E;
  --primary-deep: #BF365C;
  --primary-soft: #3D1C2B;
  --primary-soft-2: #4E2538;
  --primary-shadow: 0 8px 20px rgba(214, 69, 110, 0.28);
  --on-primary: #FFFFFF;
}

/* ── STAFF · Emerald & Gold Harmony ── */
body.theme-staff {
  --bg: #F3F8F5;
  --bg-2: #E5EFE9;
  --card: #FFFFFF;
  --ink: #0E291D;
  --muted: #4B6E5E;
  --line: #D5E5DC;
  --primary: #108A58;
  --primary-deep: #0B6B44;
  --primary-soft: #E2F5EC;
  --primary-soft-2: #C8EBDB;
  --primary-shadow: 0 8px 20px rgba(16, 138, 88, 0.28);
  --on-primary: #FFFFFF;
}

[data-bs-theme="dark"] body.theme-staff {
  --bg: #0C1A14;
  --bg-2: #13271E;
  --card: #182E24;
  --ink: #EAF6F0;
  --muted: #95BDB0;
  --line: #274C3B;
  --primary: #34D399;
  --primary-deep: #10B981;
  --primary-soft: #1B3F31;
  --primary-soft-2: #255442;
  --primary-shadow: 0 8px 20px rgba(52, 211, 153, 0.25);
  --on-primary: #0C1A14;
}

/* ── STUDENT · Ocean Teal & Gold Harmony ── */
body.student-theme {
  --bg: #F1F7F9;
  --bg-2: #E2EFF2;
  --card: #FFFFFF;
  --ink: #092833;
  --muted: #456673;
  --line: #CEE2E7;
  --primary: #0284C7;
  --primary-deep: #0369A1;
  --primary-soft: #E0F2FE;
  --primary-soft-2: #BAE6FD;
  --primary-shadow: 0 8px 20px rgba(2, 132, 199, 0.28);
  --on-primary: #FFFFFF;
}

[data-bs-theme="dark"] body.student-theme {
  --bg: #081720;
  --bg-2: #0F2330;
  --card: #142C3D;
  --ink: #E6F3F8;
  --muted: #8FB5C4;
  --line: #22475E;
  --primary: #38BDF8;
  --primary-deep: #0284C7;
  --primary-soft: #173B50;
  --primary-soft-2: #204C66;
  --primary-shadow: 0 8px 20px rgba(56, 189, 248, 0.25);
  --on-primary: #081720;
}

/* ════════ Base Typography & Smoothing ════════ */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
  transition: background .35s ease, color .35s ease;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
}

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

/* Keyframes */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  0% {
    transform: scale(.92);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes floaty {

  0%,
  100% {
    transform: translateY(0) rotate(0);
  }

  50% {
    transform: translateY(-12px) rotate(8deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .45;
  }
}

@keyframes wiggle {

  0%,
  100% {
    transform: rotate(0);
  }

  30% {
    transform: rotate(-10deg);
  }

  60% {
    transform: rotate(8deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Applied to a refresh button's icon for exactly as long as its reload
   actually takes (see withSpin() in api.js) — confirms the tap registered
   and doubles as real "still working" feedback, not a decorative flash. */
.spin-while-loading {
  display: inline-block;
  animation: spin .7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

.tab-pane:not(.d-none) {
  animation: fadeUp .35s ease;
}

/* ════════ Floating Decorative Shapes ════════ */
.shape {
  position: absolute;
  pointer-events: none;
  opacity: .85;
  animation: floaty 7s ease-in-out infinite;
  z-index: 1;
}

.shape.deco {
  position: fixed;
  opacity: .35;
  z-index: 0;
}

.s-tri {
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 26px solid var(--primary);
}

.s-circ {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFC727;
}

.s-ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 5px solid #0D1535;
  background: transparent;
}

.s-arc {
  width: 34px;
  height: 17px;
  border-radius: 34px 34px 0 0;
  background: var(--primary);
}

.s-emoji {
  font-size: 1.5rem;
  background: none;
  border: none;
  opacity: .5;
}

/* ════════ Login Page ════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  background: radial-gradient(circle at 15% 20%, #17244D 0%, #0A1026 85%);
}

.login-card {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(5, 9, 23, 0.45);
  overflow: hidden;
  background: var(--card);
  animation: pop .45s ease;
  position: relative;
  z-index: 2;
}

.login-card .card-header {
  /* Same light-purple-to-gold diagonal used for the section-card headers
     elsewhere in the app, for one consistent brand identity from the very
     first screen a user sees. */
  background: linear-gradient(135deg, #8B5CF6 0%, #A78BFA 10%, #FFC727 38%, #E5AD12 100%);
  border: none;
  border-radius: 0 !important;
  padding: 2.2rem 1.75rem 3.4rem;
  text-align: center;
  color: var(--ink);
  position: relative;
}

.login-card .card-header h4 {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card .card-header small {
  color: #3A2E12 !important;
  font-weight: 600;
}

.login-card .card-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 32px;
  background: var(--card);
  border-radius: 30px 30px 0 0;
}

.login-card .brand-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 6px 16px rgba(255, 199, 39, 0.4));
  color: #FFC727;
}

.login-card .card-body {
  padding: 1.2rem 1.75rem 2rem;
  background: var(--card);
}

/* ════════ Sidebar (Midnight Navy directly matching image) ════════ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  background: var(--navy-bg);
  box-shadow: 0 4px 24px rgba(13, 21, 53, 0.15);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 12px 10px;
  transition: background .35s ease;
  border-right: 1px solid var(--navy-line);
}

.sidebar .brand {
  padding: 1.2rem .8rem .9rem;
  color: #FFFFFF;
  font-size: 1.15rem;
  font-weight: 800;
  border-bottom: 1px solid var(--navy-line);
  margin-bottom: .6rem;
  letter-spacing: -0.01em;
}

.sidebar .brand-label i {
  color: #FFC727;
  display: inline-block;
}

.sidebar .brand:hover .brand-label i {
  animation: wiggle .5s ease;
}

.sidebar .brand-label::after {
  content: " ✦";
  color: #FFC727;
  font-size: .8rem;
  vertical-align: top;
}

.sidebar .nav-item.text-uppercase {
  color: #7284A6 !important;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: .68rem;
  padding-left: 0.95rem;
}

.sidebar .nav-link {
  color: var(--navy-text);
  padding: .65rem .95rem;
  border-radius: 12px;
  margin: 3px 4px;
  font-size: .9rem;
  font-weight: 700;
  transition: background .2s, color .2s, transform .15s, box-shadow .2s;
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar .nav-link:hover {
  background: var(--navy-hover);
  color: #FFFFFF;
  transform: translateX(3px);
}

/* Fixed gold rather than var(--primary) — role themes (theme-staff, theme-dept
   etc.) repoint --primary to green/maroon/teal, but the selected-tab highlight
   is the app's own navy+gold identity, not a per-role accent, so it stays gold
   for every role. */
.sidebar .nav-link.active {
  background: #FFC727;
  color: #0D1535;
  font-weight: 800;
  box-shadow: 0 4px 16px rgba(255, 199, 39, 0.35);
}

.sidebar .nav-link.active i {
  color: #0D1535;
}

.sidebar .nav-link i {
  width: 22px;
  font-size: 1rem;
}

.sidebar-legal {
  text-align: center;
  font-size: .72rem;
  color: var(--navy-text);
}

.sidebar-legal a {
  color: var(--navy-text);
  text-decoration: underline;
}

.sidebar-legal a:hover {
  color: var(--navy-text-active);
}

.sidebar-legal span {
  margin: 0 .35em;
  opacity: .6;
}

.sidebar .nav-link .badge {
  font-size: .65rem;
  margin-left: auto;
}

.sidebar .btn-outline-light {
  border: 1px solid #22325E;
  color: #C2D1E8;
  background: #111A3E;
  border-radius: 999px;
  font-weight: 800;
  transition: .2s;
}

.sidebar .btn-outline-light:hover {
  background: #FFC727;
  border-color: #FFC727;
  color: #0D1535;
  transform: translateY(-1px);
}

.main-content {
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem;
  min-height: 100vh;
  position: relative;
}

/* ════════ Topbar ════════ */
.topbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: .8rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .8rem;
  position: sticky;
  top: 14px;
  z-index: 50;
}

.topbar::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #FFC727;
  flex: none;
  box-shadow: 0 0 10px rgba(255, 199, 39, 0.7);
  animation: pulse 2.6s ease-in-out infinite;
}

.topbar #tabTitle {
  margin-right: auto;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.topbar .badge {
  background: #0D1535 !important;
  color: #FFC727 !important;
  border: 1px solid #FFC727;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .4em .85em;
  box-shadow: 0 2px 8px rgba(13, 21, 53, 0.15);
}

/* role chip emoji per theme */
body.theme-admin #roleLabel::before {
  content: "🛡️ ";
}

body.theme-dept #roleLabel::before {
  content: "🏛️ ";
}

body.theme-staff #roleLabel::before {
  content: "👩‍🏫 ";
}

body.student-theme #studentLabel::before {
  content: "🎓 ";
}

/* ════════ Cards ════════ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: background .35s ease, transform .25s ease, box-shadow .25s ease;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  /* Noticeably lifted at rest, not just on hover — touch devices never see
     a :hover state at all, so a shadow that only shows up there left every
     card on mobile sitting flush with the page background. */
  box-shadow: 0 10px 28px rgba(13, 21, 53, 0.11);
}

.section-card {
  margin-bottom: 1.5rem;
}

.section-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(13, 21, 53, 0.17);
}

.section-card.ts-open,
.section-card.ts-open:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.ts-dropdown .ts-dropdown-content {
  max-height: 260px;
  overflow-y: auto;
}

/* Every section-card header carries the same gold gradient "you act here /
   here's your data" identity that Create Attendance Session established —
   applied once at the base instead of per-card, so it's automatically
   consistent across every screen and any future card picks it up free. */
.section-card .card-header {
  /* Light purple-to-gold diagonal — reuses the app's existing --purple
     token (already used for the "elective" badge) instead of a new
     one-off colour. The wedge resolves into full-saturation gold well
     before ~25% width so title text never crosses it, even on the
     shortest card headers. */
  background: linear-gradient(135deg, #8B5CF6 0%, #A78BFA 10%, #FFC727 38%, #E5AD12 100%);
  border-bottom: 1px solid #C98A0E;
  border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
  font-weight: 800;
  font-size: 1.14rem;
  padding: 1rem 1.25rem;
  color: var(--ink);
  align-items: center;
  letter-spacing: .01em;
}

[data-bs-theme="dark"] .section-card .card-header {
  background: linear-gradient(135deg, #2E2916 0%, #3E371C 100%);
  border-bottom-color: #4A4020;
}

.section-card .card-header i {
  color: var(--ink);
}

/* Card-header icon badges — the leading icon sits in a solid navy chip with
   a gold glyph so it stands out against the gold header instead of
   disappearing into it. */
.section-card .card-header>i:first-child,
.section-card .card-header>span:first-child>i:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--on-primary);
  color: var(--primary);
  font-size: 1.12rem;
  margin-right: .6rem;
  flex: none;
}

/* ── Past Sessions Card Header (Oxford Crimson & Imperial Wine) ── */
#tab-sessions .section-card .card-header {
  background: linear-gradient(135deg, #3B0813 0%, #5C1122 55%, #7F1D35 100%) !important;
  border-bottom: 2px solid #E11D48 !important;
  color: #FFFFFF !important;
}

#tab-sessions .section-card .card-header span {
  color: #FFFFFF !important;
  font-weight: 800;
}

#tab-sessions .section-card .card-header>span:first-child>i:first-child,
#tab-sessions .section-card .card-header>i:first-child {
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1.5px solid rgba(253, 164, 175, 0.45) !important;
  color: #FDA4AF !important;
  box-shadow: 0 2px 10px rgba(127, 29, 53, 0.35);
}

#tab-sessions .section-card .card-header .form-control {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.7) !important;
  color: #1E293B !important;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#tab-sessions .section-card .card-header .form-control:focus {
  background: #FFFFFF !important;
  border-color: #FB7185 !important;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.28) !important;
}

#tab-sessions .section-card .card-header .form-control::placeholder {
  color: #64748B !important;
}

#tab-sessions .section-card .card-header #refreshClosedSessions {
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1.5px solid rgba(253, 164, 175, 0.5) !important;
  color: #FECDD3 !important;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#tab-sessions .section-card .card-header #refreshClosedSessions:hover {
  background: #E11D48 !important;
  border-color: #FB7185 !important;
  color: #FFFFFF !important;
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.5);
}

/* Dark mode compatibility for Oxford Crimson */
[data-bs-theme="dark"] #tab-sessions .section-card .card-header {
  background: linear-gradient(135deg, #26050C 0%, #400B17 55%, #591024 100%) !important;
  border-bottom: 2px solid #BE123C !important;
  color: #FFFFFF !important;
}

[data-bs-theme="dark"] #tab-sessions .section-card .card-header span {
  color: #FFFFFF !important;
}

[data-bs-theme="dark"] #tab-sessions .section-card .card-header>span:first-child>i:first-child,
[data-bs-theme="dark"] #tab-sessions .section-card .card-header>i:first-child {
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1.5px solid rgba(253, 164, 175, 0.35) !important;
  color: #FDA4AF !important;
}

[data-bs-theme="dark"] #tab-sessions .section-card .card-header .form-control {
  background: rgba(30, 10, 16, 0.85) !important;
  border-color: #5C1122 !important;
  color: #FFE4E6 !important;
}

[data-bs-theme="dark"] #tab-sessions .section-card .card-header #refreshClosedSessions {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: #5C1122 !important;
  color: #FDA4AF !important;
}

/* ════════ Period chip selector — replaces a plain <select> for a small,
   bounded choice (1–6) with tappable chips. The real <select> stays in the
   DOM (hidden) as the actual form value; refreshTakenPeriods()'s existing
   taken/disabled logic drives both. ════════ */
.period-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.period-chip {
  width: 46px;
  height: 46px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform .15s cubic-bezier(.32, .72, 0, 1), border-color .15s, background .15s, box-shadow .15s;
}

.period-chip:hover:not(:disabled) {
  border-color: #FFC727;
  transform: translateY(-2px);
}

.period-chip:active:not(:disabled) {
  transform: scale(.94);
}

.period-chip.active {
  background: #FFC727;
  border-color: #FFC727;
  color: #0D1535;
  box-shadow: 0 6px 16px rgba(255, 199, 39, 0.4);
}

.period-chip:disabled {
  background: var(--bg-2);
  color: var(--muted);
  border-color: var(--line);
  opacity: .55;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Semester chip — same tappable identity as the period chip, widened into a
   two-line shape so the admission-year batch (when a semester has one) sits
   under the number instead of forcing every chip to be as wide as the
   longest label. */
.period-chip.semester-chip {
  width: auto;
  min-width: 52px;
  height: 50px;
  flex-direction: column;
  gap: 1px;
  padding: 0 .6rem;
  line-height: 1.1;
}

.period-chip.semester-chip .chip-num {
  font-size: 1.05rem;
}

.period-chip.semester-chip .chip-sub {
  font-size: .62rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
}

.period-chip.semester-chip.active .chip-sub {
  color: #0D1535;
  opacity: .75;
}

/* ════════ Circular percentage ring (live session dashboard, student summary) ════
   --ring-color defaults to gold (an in-progress count, not yet a verdict);
   callers reporting a final graded metric — e.g. cumulative attendance —
   override it per health status instead. */
.pct-ring {
  --size: 96px;
  --ring-color: #FFC727;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--pct) * 1%), var(--bg-2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pct-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--card);
}

.pct-ring-value {
  position: relative;
  z-index: 1;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
}

.pct-ring-value small {
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
}

.dash-stats {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  justify-content: center;
}

.dash-stat {
  display: flex;
  align-items: baseline;
  gap: .6rem;
}

.dash-stat-val {
  font-size: 1.5rem;
  font-weight: 900;
  min-width: 2ch;
  line-height: 1;
}

.dash-stat-label {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
}

/* ════════ Success celebration overlay (see celebrateSuccess() in api.js) ═ */
.celebrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 13, 31, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, background .25s ease;
}

.celebrate-overlay.show {
  opacity: 1;
  background: rgba(8, 13, 31, .4);
}

.celebrate-badge {
  background: var(--card);
  border-radius: 24px;
  padding: 2rem 2.75rem;
  box-shadow: var(--shadow);
  text-align: center;
  transform: scale(.7);
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
}

.celebrate-overlay.show .celebrate-badge {
  transform: scale(1);
}

.celebrate-check {
  width: 84px;
  height: 84px;
}

.celebrate-check circle {
  fill: none;
  stroke: #10B981;
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  transition: stroke-dashoffset .5s ease .1s;
}

.celebrate-overlay.show .celebrate-check circle {
  stroke-dashoffset: 0;
}

.celebrate-check path {
  fill: none;
  stroke: #10B981;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  transition: stroke-dashoffset .3s ease .55s;
}

.celebrate-overlay.show .celebrate-check path {
  stroke-dashoffset: 0;
}

.celebrate-msg {
  margin-top: .85rem;
  font-weight: 800;
  color: var(--ink);
  font-size: 1.05rem;
}

/* ════════ Buttons (Golden Amber primary with high contrast ink) ════════ */
.btn {
  border-radius: 999px;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, filter .2s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(.96);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary, #0D1535) !important;
  font-weight: 800;
  box-shadow: var(--primary-shadow);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: var(--on-primary, #0D1535) !important;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(255, 199, 39, 0.40);
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.28);
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
  color: #FFFFFF;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.28);
}

.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
  color: #FFFFFF;
  transform: translateY(-1px);
}

.btn-warning {
  background: #FFC727;
  border-color: #FFC727;
  color: #0D1535;
  box-shadow: 0 6px 18px rgba(255, 199, 39, 0.32);
}

.btn-warning:hover {
  background: #E5AD12;
  border-color: #E5AD12;
  color: #0D1535;
}

.btn-secondary {
  background: #52637D;
  border-color: #52637D;
  color: #FFFFFF;
}

.btn-outline-primary {
  color: #945B00;
  border: 2px solid #FFC727;
  background: #FFF8E5;
  font-weight: 800;
}

.btn-outline-primary:hover {
  background: #FFC727;
  border-color: #FFC727;
  color: #0D1535 !important;
}

.btn-outline-secondary {
  color: var(--muted);
  border: 2px solid var(--line);
  background: transparent;
}

.btn-outline-secondary:hover {
  border-color: #0D1535;
  color: #0D1535;
  background: #EDF3FA;
}

.btn-outline-danger {
  color: var(--red-ink);
  border: 2px solid var(--red-soft);
  background: var(--red-soft);
}

.btn-outline-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #FFFFFF;
}

.btn-outline-warning {
  color: var(--orange-ink);
  border: 2px solid var(--orange-soft);
  background: var(--orange-soft);
}

.btn-outline-warning:hover {
  background: #FFC727;
  border-color: #FFC727;
  color: #0D1535;
}

.btn-outline-success {
  color: var(--green-ink);
  border: 2px solid var(--green-soft);
  background: var(--green-soft);
}

.btn-outline-success:hover {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.btn-xs {
  padding: 0.24rem 0.72rem;
  font-size: 0.74rem;
  border-radius: 999px;
  font-weight: 800;
}

/* ════════ Badges (Strict high contrast against all surfaces) ════════ */
.badge {
  border-radius: 999px;
  font-weight: 800;
  padding: .35em .75em;
  letter-spacing: .02em;
}

.badge.bg-primary {
  background: #FFF5D6 !important;
  color: #8A5E00 !important;
  border: 1px solid #FCD363;
}

.badge.bg-success {
  background: var(--green-soft) !important;
  color: var(--green-ink) !important;
  border: 1px solid #A7F3D0;
}

.badge.bg-danger {
  background: var(--red-soft) !important;
  color: var(--red-ink) !important;
  border: 1px solid #FECACA;
}

.badge.bg-warning {
  background: var(--orange-soft) !important;
  color: var(--orange-ink) !important;
  border: 1px solid #FDE68A;
}

.badge.bg-info {
  background: var(--purple-soft) !important;
  color: var(--purple-ink) !important;
  border: 1px solid #DDD6FE;
}

.badge.bg-secondary {
  background: var(--bg-2) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line);
}

.sidebar .badge.bg-danger {
  background: var(--red) !important;
  color: #FFFFFF !important;
  border: none;
}

.badge-present {
  background: var(--green-soft);
  color: var(--green-ink);
  border: 1px solid #A7F3D0;
}

.badge-absent {
  background: var(--red-soft);
  color: var(--red-ink);
  border: 1px solid #FECACA;
}

/* ════════ Tables (Signature Midnight Navy Header from Reference) ════════ */
.table {
  color: var(--ink);
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
}

.table thead.table-dark,
.table thead.table-dark th,
.table thead th {
  --bs-table-bg: #0D1535;
  --bs-table-color: #FFFFFF;
  background: #0D1535 !important;
  color: #FFFFFF !important;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 800;
  border: none;
  padding: .85rem 1rem;
}

.table thead th:first-child,
.table thead.table-dark th:first-child {
  border-radius: 12px 0 0 12px;
}

.table thead th:last-child,
.table thead.table-dark th:last-child {
  border-radius: 0 12px 12px 0;
}

.table td {
  border-color: #E2E8F0;
  font-weight: 600;
  vertical-align: middle;
  padding: .85rem 1rem;
  color: var(--ink);
}

[data-bs-theme="dark"] .table td {
  border-color: #1F2E58;
}

/* Bootstrap's contextual row classes set a LIGHT --bs-table-bg, but `.table td` above
   re-colours cell text to --ink and wins on source order (equal specificity, loaded
   later) — so in dark mode a .table-secondary row, such as the Total row of the
   student's attendance track, came out near-white text on a near-white band. Give
   those rows a dark fill so the ink reads again. */
[data-bs-theme="dark"] .table .table-secondary {
  --bs-table-bg: #1B2A52;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  --bs-table-hover-bg: #223464;
  --bs-table-hover-color: var(--ink);
}

/* Bootstrap's .text-dark pins near-black whatever the theme is, so the Departments
   tab's department/course names vanished against the dark background. Follow the
   theme ink instead. Badges are excluded: their own light fill still needs dark text. */
[data-bs-theme="dark"] #tab-departments .text-dark:not(.badge) {
  color: var(--ink) !important;
}

.table-hover tbody tr {
  transition: background .15s;
}

.table-hover tbody tr:hover {
  --bs-table-hover-bg: #EDF3FA;
  --bs-table-hover-color: var(--ink);
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
  --bs-table-hover-bg: #152248;
}

/* ════════ Forms & Inputs (Clear contrast & focus states) ════════ */
.form-control,
.form-select {
  /* var(--line) alone reads as almost invisible pale-gray against a white
     card — blending in some --ink darkens/lightens it per theme so an
     unfocused dropdown's edge is still clearly a dropdown. */
  border: 2px solid color-mix(in srgb, var(--ink) 24%, var(--line));
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  font-weight: 600;
  transition: border .2s, box-shadow .2s, background .35s;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background: var(--bg-2);
}

.form-control:focus,
.form-select:focus {
  border-color: #FFC727;
  box-shadow: 0 0 0 4px rgba(255, 199, 39, 0.28);
  background: var(--card);
  color: var(--ink);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background: var(--bg-2);
  border-color: #FFC727;
}

.form-label {
  font-weight: 800;
  color: #435472;
  font-size: .82rem;
}

[data-bs-theme="dark"] .form-label {
  color: #A0B2CF;
}

.input-group-text {
  border: 1.5px solid var(--line);
  border-right: none;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 14px 0 0 14px;
  font-weight: 700;
}

.form-control::placeholder {
  color: #8C9BB0;
}

/* ════════ Searchable selects (Tom Select) — match the plain .form-select
   look above instead of the library's own generic Bootstrap5 theme, which
   is what every "— Select course —" style dropdown actually renders as. ════ */
.ts-wrapper.form-select {
  padding: 0;
}

.ts-wrapper .ts-control {
  border: 2px solid color-mix(in srgb, var(--ink) 24%, var(--line));
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  font-weight: 600;
  box-shadow: none;
  transition: border .2s, box-shadow .2s, background .35s;
}

[data-bs-theme="dark"] .ts-wrapper .ts-control {
  background: var(--bg-2);
}

.ts-wrapper.focus .ts-control {
  border-color: #FFC727;
  box-shadow: 0 0 0 4px rgba(255, 199, 39, 0.28);
}

.ts-wrapper .ts-control input {
  color: var(--ink);
}

.ts-wrapper .ts-control .item {
  color: var(--ink);
  font-weight: 600;
}

.ts-dropdown {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Fixed navy rather than var(--primary)/role-tinted — same reasoning as the
   sidebar's active-tab highlight: role themes repoint --primary to
   green/maroon/teal, but this highlight is the app's own navy identity, not
   a per-role accent. */
.ts-dropdown .option {
  color: var(--ink);
}

.ts-dropdown .option.active {
  background: #17244D;
  color: #FFFFFF;
}

.ts-dropdown .option:active {
  background: #0D1535;
  color: #FFFFFF;
}

/* ════════ Alerts ════════ */
.alert {
  border: none;
  border-radius: 16px;
  font-weight: 700;
}

.alert-success {
  background: var(--green-soft);
  color: var(--green-ink);
  border: 1px solid #A7F3D0;
}

.alert-danger {
  background: var(--red-soft);
  color: var(--red-ink);
  border: 1px solid #FECACA;
}

.alert-warning {
  background: var(--orange-soft);
  color: var(--orange-ink);
  border: 1px solid #FDE68A;
}

.alert-info {
  background: #E0F2FE;
  color: #0369A1;
  border: 1px solid #BAE6FD;
}

.alert-light {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ════════ Modals ════════ */
.modal-content {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.modal.fade .modal-dialog {
  transform: scale(.93) translateY(10px);
  transition: transform .25s ease;
}

.modal.show .modal-dialog {
  transform: none;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

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

.modal-header .btn-close {
  transition: transform .2s;
}

.modal-header .btn-close:hover {
  transform: rotate(90deg);
}

/* The live-session dashboard goes edge-to-edge below Bootstrap's own
   sm breakpoint (modal-fullscreen-sm-down) — give it the same notch/
   home-indicator clearance as the rest of the app at that width. */
@media (max-width: 575.98px) {
  #dashboardModal .modal-header {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }

  #dashboardModal .modal-body {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

/* ════════ Toast ════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
}

/* Branded toast — navy card with a colour-coded accent stripe + icon,
   replacing the plain Bootstrap green/red pill so it matches the rest of
   the app's identity instead of being the one leftover default-styled
   element. */
.toast {
  min-width: 240px;
  max-width: 340px;
  border-radius: 14px;
  font-weight: 700;
  background: var(--navy-bg) !important;
  color: #FFFFFF !important;
  box-shadow: 0 16px 36px rgba(5, 9, 24, 0.35);
  border-left: 4px solid var(--toast-accent, #FFC727) !important;
  animation: toast-in .35s cubic-bezier(.32, .72, 0, 1);
}

.toast .toast-body {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.toast .toast-icon {
  flex: none;
  font-size: 1.1rem;
  color: var(--toast-accent, #FFC727);
}

.toast.text-bg-success {
  --toast-accent: #34D399;
}

.toast.text-bg-danger {
  --toast-accent: #F87171;
}

@keyframes toast-in {
  from {
    transform: translateY(16px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ════════ Progress ════════ */
.progress {
  background: var(--bg-2);
  border-radius: 999px;
}

.progress-bar {
  border-radius: 999px;
  transition: width .4s ease;
}

.progress-bar.bg-success {
  background-color: var(--green) !important;
}

.progress-bar.bg-danger {
  background-color: var(--red) !important;
}

.progress-bar.bg-warning {
  background-color: #FFC727 !important;
}

/* ════════ Security breach alert ════════
   Deliberately the loudest thing in the product. It interrupts whatever the admin was
   doing, on whichever tab they were on, and cannot be dismissed by clicking away or
   pressing Escape — only the acknowledge button closes it, because closing it is a
   recorded act of taking ownership. */
.breach-modal .modal-content {
  border: 4px solid #B3001B;
  border-radius: var(--r-lg);
  box-shadow: 0 24px 70px rgba(179, 0, 27, .45);
}

.breach-modal .modal-header {
  background: #B3001B;
  color: #FFFFFF;
  border-bottom: none;
}

.breach-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: .01em;
  text-transform: uppercase;
}

.breach-headline {
  font-size: 1.5rem;
  font-weight: 800;
  color: #B3001B;
  line-height: 1.3;
}

[data-bs-theme="dark"] .breach-headline {
  color: #FF6B7F;
}

.breach-deadline {
  font-size: 1.15rem;
  font-weight: 700;
  color: #B3001B;
  background: rgba(179, 0, 27, .08);
  border: 1px solid rgba(179, 0, 27, .35);
  border-radius: var(--r-sm, 8px);
  padding: .65rem .9rem;
}

[data-bs-theme="dark"] .breach-deadline {
  color: #FF8A9B;
  background: rgba(179, 0, 27, .18);
}

/* Draws the eye to the one control that closes this. */
.breach-modal .btn-acknowledge {
  font-size: 1.05rem;
  font-weight: 700;
  padding: .6rem 2.4rem;
}

/* A slow pulse on the border — enough to read as urgent without making the text that
   the admin has to actually read harder to read. */
@keyframes breach-pulse {

  0%,
  100% {
    box-shadow: 0 24px 70px rgba(179, 0, 27, .45);
  }

  50% {
    box-shadow: 0 24px 90px rgba(179, 0, 27, .75);
  }
}

.breach-modal .modal-content {
  animation: breach-pulse 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .breach-modal .modal-content {
    animation: none;
  }
}

/* ════════ Webcam / Face Capture ════════ */
#webcam-feed,
#capture-feed {
  width: 100%;
  border-radius: 20px;
  background: linear-gradient(145deg, #1A2444, #0D1535);
  aspect-ratio: 4/3;
  object-fit: cover;
  transform: scaleX(-1);
}

.capture-thumb {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px dashed var(--line);
  transition: border .3s, transform .2s;
}

.capture-thumb:hover {
  transform: scale(1.06);
}

.capture-thumb.captured {
  border-style: solid;
  border-color: var(--green);
}

/* Capture modal — the one moment lecturers use every single class, so its
   chrome leans into being a camera app rather than reusing the generic
   white modal header used everywhere else. Scoped to #captureModal only;
   every other modal keeps the standard header. */
#captureModal .modal-header {
  background: linear-gradient(135deg, #10193B 0%, var(--navy-bg) 100%);
  border-bottom: none;
}

#captureModal .modal-title,
#captureModal .modal-header .btn-close {
  color: #FFFFFF;
}

#captureModal .modal-header .btn-close {
  filter: invert(1) brightness(2);
  opacity: .85;
}

#capture-video-wrap {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Four corner brackets over the live-preview area — a viewfinder frame
   rather than a plain video box, present whether or not the feed has
   started so "aim within this" reads immediately. */
.vf-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: #FFC727;
  border-style: solid;
  border-width: 0;
  opacity: .9;
  pointer-events: none;
}

.vf-tl {
  top: 10px;
  left: 10px;
  border-top-width: 3px;
  border-left-width: 3px;
  border-top-left-radius: 6px;
}

.vf-tr {
  top: 10px;
  right: 10px;
  border-top-width: 3px;
  border-right-width: 3px;
  border-top-right-radius: 6px;
}

.vf-bl {
  bottom: 10px;
  left: 10px;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-bottom-left-radius: 6px;
}

.vf-br {
  bottom: 10px;
  right: 10px;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-bottom-right-radius: 6px;
}

#capture-cam-label {
  background: rgba(13, 21, 53, 0.65) !important;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 199, 39, 0.35);
  border-radius: 999px;
  font-weight: 700;
}

.capture-shutter {
  border-radius: 999px;
  padding-left: 1.4rem;
  padding-right: 1.4rem;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.35);
}

/* ════════ Policy pages (privacy.html, terms.html) ════════
   A plain readable document layout — no sidebar/topbar chrome, since these
   are reachable both pre-login (footer) and post-login (sidebar link) and
   need to stand alone either way. */
.policy-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 2rem 1rem 4rem;
}

.policy-topbar {
  max-width: 760px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.policy-topbar .brand-label {
  font-weight: 800;
  color: var(--ink);
  font-size: 1.1rem;
}

.policy-topbar .brand-label i {
  color: var(--primary-deep);
  margin-right: .4rem;
}

.policy-back {
  font-weight: 700;
  font-size: .85rem;
  color: var(--muted);
  text-decoration: none;
}

.policy-back:hover {
  color: var(--primary-deep);
}

.policy-card {
  max-width: 760px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
}

@media (max-width: 575.98px) {
  .policy-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--r-md);
  }
}

.policy-card h1 {
  font-size: 1.5rem;
  margin-bottom: .25rem;
}

.policy-card .policy-updated {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.policy-card h2 {
  font-size: 1.1rem;
  margin-top: 2rem;
  padding-top: .5rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1rem;
}

.policy-card h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

.policy-card h3 {
  font-size: .95rem;
  margin-top: 1.1rem;
}

.policy-card p,
.policy-card li {
  color: var(--ink);
  line-height: 1.65;
  font-weight: 500;
}

.policy-card ul,
.policy-card ol {
  padding-left: 1.3rem;
}

.policy-card strong {
  font-weight: 800;
}

.policy-card a {
  color: var(--primary-deep);
  font-weight: 700;
}

.policy-card .policy-placeholder {
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-radius: 6px;
  padding: .05em .4em;
  font-weight: 700;
}

/* Jump-nav — a mobile-first reading list of section links rather than a
   sidebar ToC, since this page has none of the app's own chrome to anchor
   a sidebar to. */
.policy-toc {
  background: var(--bg-2);
  border-radius: var(--r-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: .88rem;
}

.policy-toc div {
  font-weight: 800;
  margin-bottom: .5rem;
  color: var(--ink);
}

.policy-toc ol {
  margin: 0;
  padding-left: 1.2rem;
}

.policy-toc a {
  color: var(--ink);
  font-weight: 600;
}

.policy-toc a:hover {
  color: var(--primary-deep);
}

/* ════════ Misc ════════ */
.table-scroll {
  max-height: 420px;
  overflow: auto;
  border-radius: var(--r-md);
}

.table-scroll.paged-table {
  max-height: none;
  overflow: visible;
}

.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-sm);
}

.tbl-wrap>table {
  margin-bottom: 0;
}

/* Empty-state placeholder (see emptyState() in api.js) — a muted icon over
   the message so "nothing here" reads as a designed state, not a blank one. */
.empty-state {
  color: var(--muted);
}

.empty-state i {
  display: block;
  font-size: 2.1rem;
  color: var(--line);
  margin-bottom: .5rem;
}

.empty-state p {
  color: var(--muted);
}

/* Skeleton loading placeholder (see tableSkeleton() in api.js) — a shimmer
   shaped like the table that's about to arrive, instead of bare "Loading…"
   text jumping the layout around once real rows land. */
.skel-bar {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--line) 37%, var(--bg-2) 63%);
  background-size: 400% 100%;
  animation: skel-shimmer 1.4s ease infinite;
}

.skel-bar {
  width: 85%;
}

.tbl-wrap td:nth-child(3n+1) .skel-bar {
  width: 60%;
}

.tbl-wrap td:nth-child(3n+2) .skel-bar {
  width: 95%;
}

@keyframes skel-shimmer {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}

/* Phone-width tables (any table built by tableHTML()/renderPagedTable() —
   marked `.tbl-cards`) become a stack of labelled rows instead of a
   horizontally-scrolling grid. Purpose-built wide tables elsewhere (the
   timetable grid, performance dashboards) don't carry this class, so they
   keep scrolling as-is — that's the right shape for a spreadsheet-like view,
   card rows would only fight it. */
@media (max-width: 576px) {
  .tbl-cards thead {
    display: none;
  }

  .tbl-cards,
  .tbl-cards tbody,
  .tbl-cards tr,
  .tbl-cards td {
    display: block;
    width: 100%;
  }

  .tbl-cards tr {
    margin-bottom: .65rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: .2rem .9rem;
    background: var(--card);
  }

  .tbl-cards tbody tr:last-child {
    margin-bottom: 0;
  }

  .tbl-cards tr:hover {
    transform: none;
  }

  .tbl-cards td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem 0;
    border: none;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }

  .tbl-cards td:last-child {
    border-bottom: none;
  }

  .tbl-cards td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: .76rem;
    letter-spacing: .01em;
    color: var(--muted);
    text-align: left;
    flex: none;
  }

  .tbl-cards td:empty::before {
    content: none;
  }
}

.list-group-item {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}

.spinner-border.text-primary {
  color: #FFC727 !important;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-deep);
}

hr {
  border-color: var(--line);
  opacity: 1;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #1E2C55;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #2A3D73;
}

/* ════════ Charts & Trendlines (Golden Amber from Reference) ════════ */
.insights-chart-line {
  stroke: #FFC727 !important;
  stroke-width: 3 !important;
}

body.dark-mode .insights-chart-line,
[data-bs-theme="dark"] .insights-chart-line {
  stroke: #FFC727 !important;
}

.perf-chart-node circle {
  fill: #FFC727 !important;
  stroke: #0D1535 !important;
  stroke-width: 2 !important;
}

.face-guide-frame {
  border-color: #FFC727 !important;
}

/* Executive Dark Panel / Card style directly inspired by reference image */
.card-navy-dark {
  background: #0D1535 !important;
  color: #FFFFFF !important;
  border: 1px solid #1D2B57 !important;
}

.card-navy-dark .card-header {
  background: #0D1535 !important;
  color: #FFFFFF !important;
  border-bottom: 1px solid #1D2B57 !important;
}

.card-navy-dark .text-muted {
  color: #9EAFCE !important;
}

/* ════════ Faculty Dashboard Quick Actions ════════ */
#manualSessionBtn {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: var(--primary-shadow, 0 8px 24px rgba(0, 0, 0, 0.25));
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
  cursor: pointer;
  border: none;
}

#manualSessionBtn:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

#manualSessionBtn:active {
  transform: scale(0.95);
}

#manualSessionBtn i {
  line-height: 1;
  font-size: 2.35rem;
  -webkit-text-stroke: 0.6px;
}

/* ════════ Responsive & Mobile Adjustments ════════ */
/* Off-canvas nav drawer: hidden by default, base .sidebar rules (fixed,
   top:0, left:0, full-height column) already do the positioning — mobile
   only needs to add the slide, the width cap and the rounded "card" look. */
#sidebarToggle,
.sidebar-close-btn,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {

  /* apple.com's mobile nav uses a decelerate curve (fast start, gentle
     settle) rather than a linear/material ease — reused for every moving
     part here (drawer, backdrop, content push-back, row entrance) so the
     whole open/close feels like one motion instead of several. */
  .sidebar {
    width: min(82vw, 300px);
    border-radius: 0 28px 28px 0;
    transform: translateX(-105%) scale(.98);
    transition: transform .42s cubic-bezier(.32, .72, 0, 1);
    z-index: 1050;
    /* Clear a notch/dynamic-island above and a home-indicator below on
       devices that report one — viewport-fit=cover is what makes these
       resolve to a real value instead of always being 0. */
    padding-top: calc(12px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    padding-left: calc(10px + env(safe-area-inset-left));
  }

  /* Shadow only while open — its blur radius reaches past the box's own
     edge, so applying it unconditionally let it bleed onto screen even
     while the drawer sat translated off-canvas. */
  body.sidebar-open .sidebar {
    transform: translateX(0) scale(1);
    box-shadow: 16px 0 48px rgba(13, 21, 53, 0.45);
  }

  .sidebar .brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar .nav-link {
    padding: .75rem 1rem;
    font-size: 1.1rem;
    line-height: 1.2;
    transition: background .15s ease, transform .15s ease;
  }

  .sidebar .nav-link:active {
    transform: scale(.97);
    background: var(--navy-hover);
  }

  /* Rows fade/slide in with a per-row stagger once the drawer is open —
     only the open direction gets a delay, so closing stays snappy instead
     of visibly trailing off row by row. */
  .sidebar li {
    opacity: 0;
    transform: translateX(-14px);
    transition: opacity .3s ease, transform .36s cubic-bezier(.32, .72, 0, 1);
  }

  body.sidebar-open .sidebar li {
    opacity: 1;
    transform: translateX(0);
  }

  /* Covers the longest role's list (Admin, 20 rows incl. hidden ones —
     nth-child still counts a d-none row) so every role's wave finishes
     cleanly instead of the later rows popping in with no delay at all. */
  body.sidebar-open .sidebar li:nth-child(1) {
    transition-delay: .045s;
  }

  body.sidebar-open .sidebar li:nth-child(2) {
    transition-delay: .065s;
  }

  body.sidebar-open .sidebar li:nth-child(3) {
    transition-delay: .085s;
  }

  body.sidebar-open .sidebar li:nth-child(4) {
    transition-delay: .105s;
  }

  body.sidebar-open .sidebar li:nth-child(5) {
    transition-delay: .125s;
  }

  body.sidebar-open .sidebar li:nth-child(6) {
    transition-delay: .145s;
  }

  body.sidebar-open .sidebar li:nth-child(7) {
    transition-delay: .165s;
  }

  body.sidebar-open .sidebar li:nth-child(8) {
    transition-delay: .185s;
  }

  body.sidebar-open .sidebar li:nth-child(9) {
    transition-delay: .205s;
  }

  body.sidebar-open .sidebar li:nth-child(10) {
    transition-delay: .225s;
  }

  body.sidebar-open .sidebar li:nth-child(11) {
    transition-delay: .245s;
  }

  body.sidebar-open .sidebar li:nth-child(12) {
    transition-delay: .265s;
  }

  body.sidebar-open .sidebar li:nth-child(13) {
    transition-delay: .285s;
  }

  body.sidebar-open .sidebar li:nth-child(14) {
    transition-delay: .305s;
  }

  body.sidebar-open .sidebar li:nth-child(15) {
    transition-delay: .325s;
  }

  body.sidebar-open .sidebar li:nth-child(16) {
    transition-delay: .345s;
  }

  body.sidebar-open .sidebar li:nth-child(17) {
    transition-delay: .365s;
  }

  body.sidebar-open .sidebar li:nth-child(18) {
    transition-delay: .385s;
  }

  body.sidebar-open .sidebar li:nth-child(19) {
    transition-delay: .405s;
  }

  body.sidebar-open .sidebar li:nth-child(20) {
    transition-delay: .425s;
  }

  /* The page behind gently recedes — depth cue borrowed from the same
     "content steps back, sheet steps forward" feel apple.com's overlays use. */
  .main-content {
    transition: transform .42s cubic-bezier(.32, .72, 0, 1), filter .42s ease;
  }

  body.sidebar-open .main-content {
    transform: scale(.97);
    filter: saturate(.85) brightness(.95);
  }

  /* Hamburger trigger, sits in the topbar. `.topbar::before` (the pulsing
     status dot) is generated content, which always renders before real
     children regardless of source order — `order` is what actually moves
     the button ahead of it, to the true leading edge of the bar.
     Two bars, not three, morphing into an X on open — the same reduced,
     understated menu-glyph treatment apple.com's mobile nav uses, rather
     than a boxed icon-button. */
  #sidebarToggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    order: -1;
    width: 42px;
    height: 42px;
    flex: none;
    margin-left: -.5rem;
    padding: 0;
    border-radius: 13px;
    border: none;
    background: transparent;
    box-shadow: none;
    transition: transform .15s ease;
  }

  #sidebarToggle:active {
    transform: scale(.92);
  }

  #sidebarToggle .hb-bar {
    display: block;
    width: 22px;
    height: 2.5px;
    border-radius: 2px;
    background: #FFFFFF;
    transition: transform .34s cubic-bezier(.32, .72, 0, 1), opacity .2s ease;
  }

  body.sidebar-open #sidebarToggle .hb-bar:first-child {
    transform: translateY(3.75px) rotate(45deg);
  }

  body.sidebar-open #sidebarToggle .hb-bar:last-child {
    transform: translateY(-3.75px) rotate(-45deg);
  }

  /* Close (X) beside the brand, inside the open drawer */
  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 10px;
    border: none;
    background: var(--navy-hover);
    color: #FFFFFF;
    font-size: .95rem;
    transition: transform .2s cubic-bezier(.32, .72, 0, 1), background .15s ease;
  }

  .sidebar-close-btn:active {
    transform: scale(.88) rotate(90deg);
    background: var(--navy-line);
  }

  /* Dimmed scrim behind the open drawer, tap to close */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 13, 31, .55);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s ease;
    z-index: 1040;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .main-content {
    margin-left: 0;
    padding: calc(78px + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
  }

  .shape.deco {
    display: none;
  }

  /* Fixed, edge-to-edge header. Once it spans the full width, a rounded
     card doesn't read right against the screen's own square edges — flush,
     pointed corners plus a hairline + soft shadow for separation instead. */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    margin-bottom: 0;
    /* The bar's own top padding absorbs the notch/status-bar area, so its
       background still paints edge-to-edge behind it instead of leaving a
       plain gap above the content. */
    padding: calc(.7rem + env(safe-area-inset-top)) calc(1.1rem + env(safe-area-inset-right)) .7rem calc(1.1rem + env(safe-area-inset-left));
    border: none;
    /* A faint gold hairline instead of the old grey one — grey would all
       but vanish against navy, gold reads as a deliberate edge instead. */
    border-bottom: 1px solid rgba(255, 199, 39, 0.18);
    border-radius: 0;
    /* Same navy as the sidebar (still tracks dark mode via --navy-bg), just
       let through at partial opacity so scrolled content shows faintly
       behind it instead of a flat solid fill — blur keeps that content from
       turning into illegible noise through it. */
    background: linear-gradient(180deg, color-mix(in srgb, #10193B 82%, transparent) 0%, color-mix(in srgb, var(--navy-bg) 82%, transparent) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 26px rgba(5, 9, 24, 0.35);
    flex-wrap: nowrap;
  }

  .topbar::before {
    display: none;
  }

  .topbar #tabTitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Archivo Black only ships one weight (400) — it's drawn heavy by
       design, so that's the "bold" cut, not a lighter fallback. It also
       runs wider per character than Oswald did, so size/spacing are
       pulled back to keep it from crowding the hamburger and badge. */
    font-family: 'Archivo Black', 'Oswald', 'Segoe UI', system-ui, sans-serif;
    font-weight: 400;
    font-size: 1.28rem;
    line-height: 1.15;
    letter-spacing: 0;
    color: #FFFFFF;
    text-shadow: 0 1px 12px rgba(255, 255, 255, 0.18);
  }

  .topbar .badge {
    flex: none;
  }

  /* Tap feedback everywhere a button appears, not just the nav drawer —
     scoped to `.btn` specifically (not whole cards) so tapping something
     inside a card doesn't make the surrounding card itself visibly flex
     from event bubbling. */
  .btn {
    transition: transform .15s cubic-bezier(.32, .72, 0, 1), filter .15s ease;
  }

  .btn:active {
    transform: scale(.96);
    filter: brightness(.96);
  }

  /* 44px is the accepted minimum comfortable touch target — desktop's
     default Bootstrap control height (~38px) is fine for a mouse but
     cramped for a thumb. */
  .form-control,
  .form-select,
  .ts-wrapper .ts-control {
    min-height: 46px;
    font-size: 1rem;
  }

  .form-select {
    background-position: right .9rem center;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  :root {
    --sidebar-w: 210px;
  }

  .main-content {
    padding: 1.25rem 1.25rem;
  }

  .sidebar .nav-link {
    font-size: .85rem;
    padding: .55rem .8rem;
  }
}

@media (max-width: 768px) {
  .card-body {
    padding: 1rem;
  }

  /* Excludes fullscreen modals — loading after bootstrap.min.css means an
     equal-specificity .modal-dialog rule here would otherwise beat
     Bootstrap's own `.modal-fullscreen-sm-down { margin: 0 }` and leave a
     margin gap around what's supposed to be an edge-to-edge sheet. */
  .modal-dialog:not([class*="modal-fullscreen"]) {
    margin: .6rem;
  }

  .table-scroll {
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: calc(74px + env(safe-area-inset-top)) calc(.7rem + env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) calc(.7rem + env(safe-area-inset-left));
  }

  .topbar {
    padding: calc(.6rem + env(safe-area-inset-top)) calc(.8rem + env(safe-area-inset-right)) .6rem calc(.8rem + env(safe-area-inset-left));
  }

  h2,
  .h2 {
    font-size: 1.3rem;
  }

  .btn {
    font-size: .85rem;
  }
}

/* ════════════════════════════════════════════════════════════════
   DARK MODE — light-only surfaces and pinned text
   ════════════════════════════════════════════════════════════════

   Bootstrap 5.3 makes its *-subtle utilities theme-aware, but NOT the
   plain .bg-light / .bg-white / .text-dark family: those stay near-white
   and near-black whatever [data-bs-theme] says. Anywhere the markup used
   them to paint a panel — the Consent Lookup audit tables, the Analytics
   teaching-records filter bar, the printable consent sheet — a glaring
   white block survived the theme switch, and .table td's dark-mode ink
   then wrote light text onto it.

   These used to be patched one tab at a time (see the #tab-departments
   .text-dark rule above). Generalised here so a new screen using the same
   utility class is themed for free.

   Badges are deliberately excluded: `.badge.bg-light.text-dark` is a
   light chip whose dark text is correct in both themes. */
[data-bs-theme="dark"] .bg-light:not(.badge),
[data-bs-theme="dark"] .bg-white:not(.badge),
[data-bs-theme="dark"] .bg-light-subtle:not(.badge),
[data-bs-theme="dark"] .bg-body-tertiary:not(.badge) {
  background-color: var(--bg-2) !important;
  color: var(--ink);
}

[data-bs-theme="dark"] .text-dark:not(.badge) {
  color: var(--ink) !important;
}

/* A bordered table drawn with Bootstrap's default light border reads as a
   white grid over the dark fill above. */
[data-bs-theme="dark"] .table-bordered> :not(caption)>*,
[data-bs-theme="dark"] .table-bordered> :not(caption)>*>* {
  border-color: var(--line);
}

/* .alert-info is the one alert variant still pinned to a light fill
   (#E0F2FE / #0369A1), so the .text-dark rule above would write near-white
   onto it. Give it the same treatment its siblings already have. */
[data-bs-theme="dark"] .alert-info {
  background: #0B2D44;
  color: #BAE6FD;
  border-color: #155E82;
}

[data-bs-theme="dark"] .alert-info .text-dark:not(.badge) {
  color: #BAE6FD !important;
}

/* btn-outline-dark is black-on-white by definition; invert it rather than
   let the .bg-white rule above hand it a dark fill with dark text. */
[data-bs-theme="dark"] .btn-outline-dark {
  color: var(--ink);
  border-color: var(--line);
  background: var(--bg-2);
}

[data-bs-theme="dark"] .btn-outline-dark:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ── Refresh (and every other) icon button inside a card header ──

   `.section-card .card-header i { color: var(--ink) }` is specificity
   (0,2,1) and beats a button's own (0,1,0) colour, so the icon INSIDE a
   header button took the header's ink instead of the button's. In dark
   mode --ink is near-white while .btn-outline-primary keeps its hardcoded
   cream fill (#FFF8E5) — a near-white arrow on a cream circle, which is
   why every refresh control across every tab and role looked blank.

   Let the glyph inherit from the button it sits in. Fixes light mode's
   (milder) version of the same clash at the same time. */
.section-card .card-header .btn i,
.section-card .card-header button i {
  color: inherit;
}

/* The outline buttons hardcode light-mode fills, which sit far too bright
   against a dark card header. Re-point them at the theme tokens; the glyph
   follows via the `inherit` rule above. */
[data-bs-theme="dark"] .btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary-deep);
  background: var(--primary-soft);
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary) !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  color: var(--ink);
  border-color: var(--line);
  background: var(--bg-2);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background: var(--line);
  border-color: var(--muted);
  color: var(--ink);
}

/* ── Password reveal button (see PasswordReveal in js/api.js) ──
   The wrapper takes the input's place in the layout, so it must be a block
   that fills the width the input used to occupy — otherwise a field inside a
   .col-md-4 collapses to its content width. */
.pw-reveal-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.pw-reveal-wrap > .form-control {
  /* Room for the button so a long password never runs under the eye. */
  padding-right: 2.75rem;
}

.pw-reveal-btn {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  border-radius: 0 14px 14px 0;
  cursor: pointer;
  transition: color .15s;
}

.pw-reveal-btn:hover,
.pw-reveal-btn:focus-visible {
  color: var(--ink);
}

/* Inside an .input-group the field has square inner corners; match them so the
   button does not overhang the input's edge. */
.input-group > .pw-reveal-wrap {
  flex: 1 1 auto;
  width: 1%;
}

/* Bootstrap's contextual table head and the light border utility are pinned to
   a near-white value whatever [data-bs-theme] says — the same gap the .bg-light
   block above closes. The Faculty & Staff Lookup result is built from both, so
   its subject table kept a white header and white grid lines over the dark
   card. */
[data-bs-theme="dark"] .table-light {
  --bs-table-bg: var(--bg-2);
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
}

[data-bs-theme="dark"] .border-light:not(.badge) {
  border-color: var(--line) !important;
}
