/* St Ignatius College: burgundy & gold theme.
   Design language (sidebar shell, card/table/stat-card/badge style, serif+sans
   typography pairing) mirrors the school's approved SIS mockup, adapted to
   this app's own burgundy/gold palette instead of the mockup's navy/gold. */

:root {
  --sic-burgundy: #6d0f2b;
  --sic-burgundy-dark: #4a0a1d;
  --sic-burgundy-light: #8a1339;
  --sic-burgundy-pale: #f7eaee;
  --sic-gold: #c9973a;
  --sic-gold-dark: #a5821e;
  --sic-gold-light: #e6c85c;
  --sic-gold-pale: #fdf3e0;
  --sic-cream: #faf8f4;
  --sic-text-dark: #2b2b2b;
  --sic-text-mid: #55607a;
  --sic-text-muted: #6f7d99;
  --sic-border: #e4e0d8;
  --sic-border-light: #eef1f7;

  /* Grade tones (see core/grade_tones.py). */
  --tone-excellent-bg: #e2f2e7; --tone-excellent-fg: #1d5e38;
  --tone-good-bg: #e5eef9;      --tone-good-fg: #22487a;
  --tone-fair-bg: #fdf0d8;      --tone-fair-fg: #84560a;
  --tone-fail-bg: #fbe3e3;      --tone-fail-fg: #9b1c1c;
  --tone-none-bg: #eef1f7;      --tone-none-fg: #6f7d99;

  --sidebar-w: 240px;
  --shadow-sm: 0 1px 4px rgba(13, 15, 20, 0.05), 0 4px 14px rgba(109, 15, 43, 0.05);
  --shadow-md: 0 6px 18px rgba(13, 15, 20, 0.08), 0 2px 6px rgba(109, 15, 43, 0.06);

  --bs-border-radius: 0.6rem;
  --bs-border-radius-sm: 0.45rem;
  --bs-border-radius-lg: 0.9rem;
}

body {
  font-size: 0.95rem;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  background-color: var(--sic-cream);
  color: var(--sic-text-dark);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .school-name, .card-title, .stat-value {
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
}
h2.h5, h2.h6 { color: var(--sic-burgundy-dark); }

a {
  color: var(--sic-burgundy);
  transition: color 0.15s ease;
}
a:hover { color: var(--sic-gold-dark); }

.text-muted { color: var(--sic-text-muted) !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sic-burgundy);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  border-right: 3px solid var(--sic-gold);
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo img.brand-logo, .brand-monogram {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar-logo img.brand-logo { background: #fff; padding: 2px; object-fit: contain; }
.brand-monogram {
  display: flex; align-items: center; justify-content: center;
  background: rgba(201, 151, 58, 0.22);
  color: var(--sic-gold-light);
  font-family: "EB Garamond", serif; font-weight: 600; font-size: 18px;
  border: 1px solid rgba(230, 200, 92, 0.35);
}
.logo-text { line-height: 1.2; }
.logo-text .school-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--sic-gold-light);
  letter-spacing: 0.01em;
}
.logo-text .sys-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-section {
  padding: 16px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 1px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13.5px;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(201, 151, 58, 0.2);
  color: var(--sic-gold-light);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--sic-gold);
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(201, 151, 58, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--sic-gold-light);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.9); }
.user-role { font-size: 11px; color: rgba(255, 255, 255, 0.5); }
.btn-logout {
  width: 100%;
  margin-top: 10px;
  padding: 6px 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 6, 11, 0.45);
  z-index: 1030;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}

/* =========================================================
   MAIN / TOPBAR
   ========================================================= */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main.main-anon { margin-left: 0; }

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--sic-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 4px rgba(13, 15, 20, 0.04);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.page-breadcrumb {
  font-family: "EB Garamond", serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--sic-burgundy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-toggle {
  display: none;
  border: 1px solid var(--sic-border);
  background: #fff;
  border-radius: 8px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  color: var(--sic-burgundy);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.term-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--sic-gold-pale);
  color: #6b4d12;
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
}
.term-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sic-gold); }

/* Global student search with a live dropdown (static/js/app.js). */
.global-search { position: relative; width: 300px; }
.global-search input {
  padding-left: 34px;
  border-radius: 999px;
  background: var(--sic-cream);
}
.global-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--sic-text-muted); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--sic-border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  overflow: hidden; z-index: 1050;
}
.search-results a {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 9px 14px; text-decoration: none; color: var(--sic-text-dark);
  font-size: 14px;
}
.search-results a .meta { color: var(--sic-text-muted); font-size: 12px; }
.search-results a:hover, .search-results a.active { background: var(--sic-gold-pale); }
.search-results .empty { padding: 10px 14px; color: var(--sic-text-muted); font-size: 13px; }

.content {
  padding: 28px;
  flex: 1;
  width: 100%;
  max-width: 1440px;
}
.main-anon .content { padding: 0; max-width: none; }

/* Page header: title on the left, actions on the right, wrapping when narrow. */
.page-head, .content > .d-flex.justify-content-between {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-subtitle { color: var(--sic-text-muted); margin-top: 6px; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  border-radius: var(--bs-border-radius-sm);
  transition: transform 0.1s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  font-weight: 500;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  --bs-btn-bg: var(--sic-burgundy);
  --bs-btn-border-color: var(--sic-burgundy);
  --bs-btn-hover-bg: var(--sic-burgundy-dark);
  --bs-btn-hover-border-color: var(--sic-burgundy-dark);
  --bs-btn-active-bg: var(--sic-burgundy-dark);
  --bs-btn-active-border-color: var(--sic-burgundy-dark);
  --bs-btn-disabled-bg: var(--sic-burgundy);
  --bs-btn-disabled-border-color: var(--sic-burgundy);
  --bs-btn-focus-shadow-rgb: 109, 15, 43;
  box-shadow: 0 2px 6px rgba(109, 15, 43, 0.25);
}
.btn-outline-primary {
  --bs-btn-color: var(--sic-burgundy);
  --bs-btn-border-color: var(--sic-burgundy);
  --bs-btn-hover-bg: var(--sic-burgundy);
  --bs-btn-hover-border-color: var(--sic-burgundy);
  --bs-btn-active-bg: var(--sic-burgundy-dark);
  --bs-btn-active-border-color: var(--sic-burgundy-dark);
  --bs-btn-disabled-color: var(--sic-burgundy);
  --bs-btn-disabled-border-color: var(--sic-border);
  --bs-btn-focus-shadow-rgb: 109, 15, 43;
}
.btn-outline-secondary {
  --bs-btn-color: var(--sic-text-mid);
  --bs-btn-border-color: var(--sic-border);
  --bs-btn-hover-color: var(--sic-burgundy);
  --bs-btn-hover-bg: var(--sic-gold-pale);
  --bs-btn-hover-border-color: var(--sic-gold);
  --bs-btn-active-color: var(--sic-burgundy);
  --bs-btn-active-bg: var(--sic-gold-pale);
  --bs-btn-active-border-color: var(--sic-gold);
  background: #fff;
}
.btn-secondary {
  --bs-btn-bg: var(--sic-gold);
  --bs-btn-border-color: var(--sic-gold-dark);
  --bs-btn-color: #3a2c00;
  --bs-btn-hover-bg: var(--sic-gold-dark);
  --bs-btn-hover-border-color: var(--sic-gold-dark);
  --bs-btn-hover-color: #3a2c00;
  --bs-btn-active-bg: var(--sic-gold-dark);
  --bs-btn-active-color: #3a2c00;
}

/* A button showing "Preparing…" while a slow download is generated. */
.btn.is-busy { pointer-events: none; opacity: 0.85; }
.btn .spinner {
  display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.45em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.1em; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   CARDS
   ========================================================= */
.card {
  border: 1px solid var(--sic-border);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  color: var(--sic-burgundy);
  border-bottom: 1px solid var(--sic-border-light);
  border-top-left-radius: var(--bs-border-radius-lg);
  border-top-right-radius: var(--bs-border-radius-lg);
  font-family: "EB Garamond", serif;
  font-weight: 600;
  font-size: 1.05rem;
}
/* Tables inside flush cards scroll sideways on narrow screens instead of
   pushing the page wider than the phone. */
.card-body.p-0 { overflow-x: auto; border-radius: inherit; }

/* Dashboard stat tiles: pale cards with a coloured left accent bar. Scoped to
   .card so the same Bootstrap colour classes on badges stay pills. */
.card.text-bg-primary,
.card.text-bg-secondary,
.card.text-bg-success,
.card.text-bg-info {
  background: #fff !important;
  color: var(--sic-text-dark) !important;
  border: 1px solid var(--sic-border);
  border-left: 3px solid var(--sic-burgundy);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card.text-bg-secondary { border-left-color: #6b6b6b; }
.card.text-bg-success { border-left-color: var(--sic-gold); }
.card.text-bg-info { border-left-color: var(--sic-burgundy-light); }
.card.text-bg-primary:hover,
.card.text-bg-secondary:hover,
.card.text-bg-success:hover,
.card.text-bg-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(13, 15, 20, 0.1);
}
.card[class*="text-bg-"] .small {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 500;
  color: var(--sic-text-muted) !important;
}
.card[class*="text-bg-"] .h3 {
  font-family: "EB Garamond", serif;
  font-weight: 600;
  color: var(--sic-burgundy) !important;
  font-size: 1.9rem;
}

/* KPI tiles used by the dashboard and parent portal. */
.kpi {
  background: #fff;
  border: 1px solid var(--sic-border);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--kpi-accent, var(--sic-burgundy));
}
.kpi-label {
  text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 11px; font-weight: 600; color: var(--sic-text-muted);
}
.kpi-value {
  font-family: "EB Garamond", serif; font-weight: 600;
  font-size: 2rem; line-height: 1.15; color: var(--sic-burgundy);
  margin-top: 4px;
}
.kpi-value small { font-size: 1rem; color: var(--sic-text-muted); font-weight: 500; }
.kpi-note { font-size: 12.5px; color: var(--sic-text-muted); margin-top: 2px; }
.kpi.gold { --kpi-accent: var(--sic-gold); }
.kpi.green { --kpi-accent: #2f8a55; }
.kpi.red { --kpi-accent: #b42318; }
.kpi.blue { --kpi-accent: #345f9c; }

/* Progress bars (submission progress, subject vs class average). */
.progress-thin {
  height: 6px; border-radius: 999px; background: var(--sic-border-light);
  overflow: hidden;
}
.progress-thin > span { display: block; height: 100%; border-radius: inherit; background: var(--sic-gold); }
.progress-thin.done > span { background: #2f8a55; }

/* Attention list on the dashboard. */
.attention-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--sic-border-light);
  text-decoration: none; color: inherit;
}
.attention-item:last-child { border-bottom: 0; }
a.attention-item:hover { background: var(--sic-gold-pale); color: inherit; }
.attention-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.attention-icon.warn { background: var(--tone-fair-bg); color: var(--tone-fair-fg); }
.attention-icon.bad { background: var(--tone-fail-bg); color: var(--tone-fail-fg); }
.attention-icon.ok { background: var(--tone-excellent-bg); color: var(--tone-excellent-fg); }
.attention-icon.info { background: var(--tone-good-bg); color: var(--tone-good-fg); }
.attention-title { font-weight: 500; }
.attention-sub { font-size: 12.5px; color: var(--sic-text-muted); }

/* Dashboard welcome banner: greeting and quick actions beside the term timeline. */
.dash-hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px;
  padding: 28px 30px;
  border-radius: 18px;
  color: #fff;
  background:
    radial-gradient(circle at 85% -20%, rgba(230, 200, 92, 0.28) 0%, transparent 45%),
    radial-gradient(circle at 0% 120%, rgba(201, 151, 58, 0.18) 0%, transparent 40%),
    linear-gradient(135deg, var(--sic-burgundy-light) 0%, var(--sic-burgundy) 45%, var(--sic-burgundy-dark) 100%);
  box-shadow: 0 10px 30px rgba(74, 10, 29, 0.25);
}
.dash-hero::after {
  /* A faint crest-like ring in the corner, purely decorative. */
  content: ""; position: absolute; right: -60px; bottom: -90px; width: 260px; height: 260px;
  border-radius: 50%; border: 28px solid rgba(255, 255, 255, 0.04); pointer-events: none;
}
.dash-hero-date { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); }
.dash-hero h1 { color: #fff; font-size: 2.1rem; font-weight: 600; margin: 4px 0 6px; }
.dash-hero-sub { color: rgba(255, 255, 255, 0.78); margin-bottom: 18px; }
.dash-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-hero, .btn-hero-primary {
  --bs-btn-padding-y: 0.45rem; --bs-btn-padding-x: 0.95rem;
  border-radius: 999px; font-size: 0.9rem;
}
.btn-hero {
  --bs-btn-color: #fff; --bs-btn-bg: rgba(255, 255, 255, 0.1); --bs-btn-border-color: rgba(255, 255, 255, 0.25);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: rgba(255, 255, 255, 0.2); --bs-btn-hover-border-color: rgba(255, 255, 255, 0.4);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: rgba(255, 255, 255, 0.25);
}
.btn-hero-primary {
  --bs-btn-color: #3a2c00; --bs-btn-bg: var(--sic-gold-light); --bs-btn-border-color: var(--sic-gold-light);
  --bs-btn-hover-color: #3a2c00; --bs-btn-hover-bg: #f0d77a; --bs-btn-hover-border-color: #f0d77a;
  --bs-btn-active-bg: var(--sic-gold); --bs-btn-active-color: #3a2c00;
}
.dash-hero-term {
  align-self: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px; padding: 16px 18px;
  backdrop-filter: blur(4px);
}
.dash-hero-term .term-name { font-family: "EB Garamond", serif; font-size: 1.25rem; font-weight: 600; color: var(--sic-gold-light); }
.dash-hero-term .term-week { font-size: 13px; color: rgba(255, 255, 255, 0.8); }
.term-track { position: relative; height: 10px; margin: 14px 0 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); }
.term-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--sic-gold), var(--sic-gold-light)); }
.term-today {
  position: absolute; top: 50%; width: 16px; height: 16px; margin-left: -8px; margin-top: -8px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(230, 200, 92, 0.45);
}
.term-flag {
  position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: #fff; opacity: 0.85;
}
.term-flag::before {
  content: "Due"; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(255, 255, 255, 0.85);
  margin-bottom: 2px;
}
.term-dates { font-size: 11.5px; color: rgba(255, 255, 255, 0.6); }
.term-deadline { margin-top: 10px; font-size: 13.5px; color: rgba(255, 255, 255, 0.9); }
.term-deadline strong { color: var(--sic-gold-light); }

/* Marks this term: the three headline numbers above the chart. */
.marks-strip { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 12px; }
.marks-strip .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sic-text-muted); font-weight: 600; }
.marks-strip .val { font-family: "EB Garamond", serif; font-size: 1.6rem; font-weight: 600; color: var(--sic-burgundy); font-variant-numeric: tabular-nums; }

/* Recent activity feed. */
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--sic-border-light);
  color: inherit; text-decoration: none;
}
.activity-item:last-child { border-bottom: 0; }
a.activity-item:hover { background: var(--sic-gold-pale); color: inherit; }
.activity-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.activity-submitted { background: var(--tone-excellent-bg); color: var(--tone-excellent-fg); }
.activity-assessment { background: var(--tone-good-bg); color: var(--tone-good-fg); }
.activity-released { background: var(--sic-gold-pale); color: var(--sic-gold-dark); }
.activity-text { font-size: 14px; line-height: 1.3; }
.activity-sub { font-size: 12px; color: var(--sic-text-muted); margin-top: 2px; }
.min-w-0 { min-width: 0; }

/* Today's lessons for a teacher. */
.lesson {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; border-bottom: 1px solid var(--sic-border-light);
}
.lesson:last-child { border-bottom: 0; }
.lesson-time { width: 52px; flex-shrink: 0; font-weight: 600; font-size: 14px; line-height: 1.15; color: var(--sic-burgundy); }
.lesson-time span { display: block; font-weight: 400; font-size: 12px; color: var(--sic-text-muted); }
.lesson-body { flex: 1; min-width: 0; }
.lesson-subject { font-weight: 500; }
.lesson-class { font-size: 12.5px; color: var(--sic-text-muted); }
.lesson-done { opacity: 0.5; }
.lesson-now { background: var(--tone-excellent-bg); box-shadow: inset 3px 0 0 #2f8a55; }
.lesson-next { background: var(--sic-gold-pale); box-shadow: inset 3px 0 0 var(--sic-gold); }

/* Class cards on the dashboard. */
.class-card {
  display: block; height: 100%;
  background: #fff; border: 1px solid var(--sic-border);
  border-radius: var(--bs-border-radius-lg); box-shadow: var(--shadow-sm);
  padding: 14px 16px; color: inherit; text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--sic-gold); color: inherit; }
.class-card .name { font-family: "EB Garamond", serif; font-weight: 600; font-size: 1.15rem; color: var(--sic-burgundy); }
.class-card .meta { font-size: 12.5px; color: var(--sic-text-muted); }

/* =========================================================
   HEADINGS
   ========================================================= */
h1.h3, h1.h4 {
  color: var(--sic-burgundy);
  border-bottom: 3px solid var(--sic-gold);
  padding-bottom: 0.35rem;
  display: inline-block;
}
.content h2.h5 { margin-top: 1.75rem; margin-bottom: 0.75rem; }

/* =========================================================
   TABLES
   ========================================================= */
.table thead th {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--sic-text-muted);
  background-color: var(--sic-cream);
  border-bottom-color: var(--sic-border);
  white-space: nowrap;
}
.table > :not(caption) > * > * {
  border-bottom-color: var(--sic-border-light);
  padding-top: 0.7rem; padding-bottom: 0.7rem;
}
.table-hover > tbody > tr:hover > * {
  background-color: rgba(201, 151, 58, 0.08);
}
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
th.sortable a:hover { color: var(--sic-burgundy); }
th.sortable .arrow { font-size: 0.8em; opacity: 0.8; }

/* Empty states: say what's missing and what to do next. */
.empty-state {
  text-align: center; padding: 36px 20px; color: var(--sic-text-muted);
}
.empty-state .empty-title {
  font-family: "EB Garamond", serif; font-size: 1.2rem; color: var(--sic-text-dark); margin-bottom: 4px;
}

/* =========================================================
   BADGES & GRADE PILLS
   ========================================================= */
.badge {
  border-radius: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 4px 10px;
}
.badge.text-bg-secondary, .badge.text-bg-light {
  background-color: var(--sic-border-light) !important;
  color: var(--sic-text-mid) !important;
}
.badge.text-bg-success { background-color: var(--tone-excellent-bg) !important; color: var(--tone-excellent-fg) !important; }
.badge.text-bg-warning { background-color: var(--tone-fair-bg) !important; color: var(--tone-fair-fg) !important; }
.badge.text-bg-danger { background-color: var(--tone-fail-bg) !important; color: var(--tone-fail-fg) !important; }
.badge.text-bg-info { background-color: var(--tone-good-bg) !important; color: var(--tone-good-fg) !important; }

.grade-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1em; padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700; font-size: 0.82rem; line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.grade-excellent { background: var(--tone-excellent-bg); color: var(--tone-excellent-fg); }
.grade-good { background: var(--tone-good-bg); color: var(--tone-good-fg); }
.grade-fair { background: var(--tone-fair-bg); color: var(--tone-fair-fg); }
.grade-fail { background: var(--tone-fail-bg); color: var(--tone-fail-fg); }
.grade-none { background: var(--tone-none-bg); color: var(--tone-none-fg); font-weight: 500; }

/* =========================================================
   FORMS
   ========================================================= */
.form-label {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  font-weight: 500;
  color: var(--sic-text-mid);
}
.form-control, .form-select {
  border-radius: 7px;
  border-color: var(--sic-border);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--sic-gold);
  box-shadow: 0 0 0 0.2rem rgba(201, 151, 58, 0.25);
}
.form-control.is-invalid:focus { box-shadow: 0 0 0 0.2rem rgba(180, 35, 24, 0.2); }

/* =========================================================
   PAGINATION
   ========================================================= */
.page-link { color: var(--sic-burgundy); }
.page-item.active .page-link {
  background-color: var(--sic-burgundy);
  border-color: var(--sic-burgundy);
}

dt { font-weight: 500; color: var(--sic-text-mid); }

/* =========================================================
   ALERTS & TOASTS
   ========================================================= */
.alert { border-radius: var(--bs-border-radius); }
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 1080;
  display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px));
}
.toast-stack .alert {
  box-shadow: var(--shadow-md); margin: 0;
  animation: toast-in 0.25s ease-out;
}
.toast-stack .alert.leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* =========================================================
   TIMETABLE
   ========================================================= */
.tt-cell { border-radius: 8px; padding: 6px 8px; text-align: left; }
.tt-cell .tt-subject { font-weight: 600; font-size: 0.85rem; line-height: 1.2; }
.tt-cell .tt-sub { font-size: 0.78rem; opacity: 0.8; }
.tt-free { color: var(--sic-text-muted); font-size: 0.82rem; }
.tt-break { background: repeating-linear-gradient(45deg, var(--sic-cream), var(--sic-cream) 6px, #f2eee6 6px, #f2eee6 12px); color: var(--sic-text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.tt-edit { display: none; font-size: 0.75rem; margin-top: 2px; }
.tt-editing .tt-edit { display: inline-block; }
.tt-today { background: var(--sic-gold-pale) !important; }
.tt-now td, .tt-now th { box-shadow: inset 0 2px 0 var(--sic-gold), inset 0 -2px 0 var(--sic-gold); }
.tt-c0 { background: #f7e9ee; color: #6d0f2b; }
.tt-c1 { background: #e5eef9; color: #22487a; }
.tt-c2 { background: #e2f2e7; color: #1d5e38; }
.tt-c3 { background: #fdf0d8; color: #84560a; }
.tt-c4 { background: #efe7f7; color: #55307f; }
.tt-c5 { background: #e1f3f4; color: #165f66; }
.tt-c6 { background: #fbe6dc; color: #8a3a12; }
.tt-c7 { background: #eceef2; color: #3d4757; }

/* =========================================================
   PARENT PORTAL
   ========================================================= */
.child-card {
  background: #fff; border: 1px solid var(--sic-border);
  border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 18px; height: 100%; display: flex; flex-direction: column; gap: 12px;
}
.child-head { display: flex; align-items: center; gap: 12px; }
.child-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--sic-burgundy); color: var(--sic-gold-light);
  font-family: "EB Garamond", serif; font-weight: 600; font-size: 1.2rem;
}
.child-name { font-family: "EB Garamond", serif; font-size: 1.3rem; font-weight: 600; color: var(--sic-burgundy); line-height: 1.1; }
.child-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.child-stats .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sic-text-muted); }
.child-stats .val { font-family: "EB Garamond", serif; font-size: 1.5rem; font-weight: 600; color: var(--sic-text-dark); }

.subject-row { padding: 12px 16px; border-bottom: 1px solid var(--sic-border-light); }
.subject-row:last-child { border-bottom: 0; }
.subject-row .top { display: flex; align-items: center; gap: 10px; }
.subject-row .name { font-weight: 500; flex: 1; min-width: 0; }
.subject-row .score { font-variant-numeric: tabular-nums; font-weight: 600; }
.subject-bar { position: relative; height: 8px; background: var(--sic-border-light); border-radius: 999px; margin-top: 8px; }
.subject-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--sic-burgundy); }
.subject-bar .marker {
  position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--sic-gold-dark); border-radius: 2px;
}
.subject-row .cmp { font-size: 12px; color: var(--sic-text-muted); margin-top: 4px; }
details.breakdown summary { cursor: pointer; font-size: 12.5px; color: var(--sic-burgundy); margin-top: 6px; }
details.breakdown table { margin-top: 6px; font-size: 13px; }

/* =========================================================
   LOGIN PAGE (anonymous, no sidebar/topbar)
   ========================================================= */
.login-page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(201, 151, 58, 0.18) 0%, transparent 40%),
    radial-gradient(circle at top, var(--sic-burgundy-light) 0%, var(--sic-burgundy-dark) 70%);
  padding: 2rem 0.75rem;
}
.login-card {
  border: none;
  border-top: 5px solid var(--sic-gold);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.login-card .card-body { padding: 2.5rem 2rem; text-align: center; }
.login-card form, .login-card .alert { text-align: left; }
.login-card h1.h4 { display: block; border: 0; padding: 0; font-size: 1.75rem; }
.login-card .login-rule { width: 48px; height: 3px; background: var(--sic-gold); margin: 10px auto 12px; border-radius: 3px; }
.login-logo {
  display: block;
  max-height: 90px;
  margin: 0 auto 1rem;
}
.login-crest {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--sic-burgundy); color: var(--sic-gold-light);
  font-family: "EB Garamond", serif; font-weight: 600; font-size: 1.7rem;
  box-shadow: 0 0 0 4px var(--sic-gold-pale), 0 0 0 5px var(--sic-gold);
}
.login-motto { font-family: "EB Garamond", serif; font-style: italic; color: var(--sic-text-mid); }
.login-help { font-size: 12.5px; color: var(--sic-text-muted); margin-top: 1.25rem; }
.login-footer { color: rgba(255, 255, 255, 0.55); font-size: 12px; text-align: center; margin-top: 1rem; }

/* =========================================================
   SMALL SCREENS
   Below 992px the sidebar becomes a slide-out drawer behind the menu button.
   ========================================================= */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; gap: 10px; }
  .global-search { width: auto; flex: 1; max-width: 360px; }
  .term-chip { display: none; }
  .content { padding: 18px 16px; }
  .dash-hero { grid-template-columns: 1fr; gap: 20px; padding: 22px 20px; }
}
@media (max-width: 575.98px) {
  .topbar .page-breadcrumb { display: none; }
  .global-search { max-width: none; }
  h1.h3 { font-size: 1.45rem; }
  .dash-hero h1 { font-size: 1.65rem; }
  .marks-strip { gap: 18px; }
  .page-actions .btn { flex: 1 1 auto; }
  .kpi-value { font-size: 1.6rem; }
  .login-card .card-body { padding: 2rem 1.4rem; }
  /* Long tables keep their columns but scroll inside the card. */
  .table { font-size: 0.88rem; }
  .table td, .table th { white-space: nowrap; }
  .table td.wrap { white-space: normal; }
}

@media print {
  .sidebar, .topbar, .sidebar-backdrop, .toast-stack, .page-actions, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

/* ==========================================================================
   GUIDED TOUR (static/js/tour.js) and HELP PAGE
   ========================================================================== */
.tour-blocker { position: fixed; inset: 0; z-index: 2000; }
.tour-spot {
  position: fixed; z-index: 2001; pointer-events: none;
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--sic-gold), 0 0 0 9999px rgba(20, 8, 12, 0.55);
}
.tour-spot.tour-spot-none { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important;
  box-shadow: 0 0 0 9999px rgba(20, 8, 12, 0.55); }
.tour-card {
  position: fixed; z-index: 2002; width: min(340px, calc(100vw - 24px));
  background: #fff; border-radius: var(--bs-border-radius-lg); box-shadow: var(--shadow-md);
  border-top: 4px solid var(--sic-burgundy); padding: 16px 18px 14px; outline: none;
}
.tour-card.tour-docked { width: calc(100vw - 24px); }
.tour-progress { display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--sic-text-muted); margin-bottom: 6px; }
.tour-skip { background: none; border: 0; padding: 0; color: var(--sic-text-muted);
  font-size: 0.78rem; text-decoration: underline; cursor: pointer; }
.tour-skip:hover { color: var(--sic-burgundy); }
.tour-title { font-family: "EB Garamond", Georgia, serif; font-size: 1.3rem; font-weight: 600;
  color: var(--sic-burgundy); margin: 0 0 6px; }
.tour-text { color: var(--sic-text-dark); margin: 0 0 12px; line-height: 1.5; }
.tour-dots { display: flex; gap: 5px; margin-bottom: 12px; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--sic-border); }
.tour-dots span.on { background: var(--sic-gold); width: 16px; border-radius: 3px; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; }

.help-intro { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.help-task { border: 1px solid var(--sic-border-light); border-radius: var(--bs-border-radius); background: #fff; }
.help-task + .help-task { margin-top: 8px; }
.help-task summary { cursor: pointer; padding: 12px 16px; font-weight: 500; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.help-task summary::-webkit-details-marker { display: none; }
.help-task summary::after { content: "+"; color: var(--sic-gold-dark); font-size: 1.2rem; line-height: 1; }
.help-task[open] summary::after { content: "−"; }
.help-task[open] summary { border-bottom: 1px solid var(--sic-border-light); }
.help-task .help-body { padding: 12px 16px 14px; }
.help-task ol { padding-left: 1.2rem; margin-bottom: 10px; }
.help-task li + li { margin-top: 4px; }
.help-note { font-size: 0.88rem; color: var(--sic-text-mid); background: var(--sic-gold-pale);
  border-radius: var(--bs-border-radius-sm); padding: 8px 12px; margin-bottom: 10px; }

/* Inactivity warning (static/js/session-timeout.js) */
.session-warning {
  position: fixed; right: 20px; bottom: 20px; z-index: 2100; max-width: 340px;
  background: #fff; border-radius: var(--bs-border-radius-lg); box-shadow: var(--shadow-md);
  border-top: 4px solid var(--sic-gold); padding: 14px 16px;
}
.session-warning-title { font-family: "EB Garamond", Georgia, serif; font-size: 1.15rem; font-weight: 600;
  color: var(--sic-burgundy); margin-bottom: 4px; }
.session-warning-text { font-size: 0.88rem; color: var(--sic-text-dark); margin-bottom: 10px; }

/* Mini trend charts in Stats tables (SICCharts.spark) */
.trend-cell { display: flex; align-items: center; gap: 0.6rem; }
.trend-spark { position: relative; width: 104px; height: 38px; flex: none; }
.trend-change { font-size: 0.82rem; font-weight: 600; white-space: nowrap; color: var(--sic-text-muted); }
.trend-change.up { color: #1d5e38; }
.trend-change.down { color: #9b1c1c; }

/* ==========================================================================
   PARENTS PORTAL: at a glance (templates/parents/home.html)
   ========================================================================== */
.results-updates { display: flex; flex-wrap: wrap; gap: 12px; }
.update-chip { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid var(--sic-border-light);
  border-radius: var(--bs-border-radius-lg); padding: 10px 14px; box-shadow: var(--shadow-sm); min-width: 220px; flex: 1 1 220px; }
.update-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--sic-gold); }
.update-chip.is-released .update-dot { background: #1d5e38; box-shadow: 0 0 0 4px #e2f2e7; }
.update-chip.is-pending .update-dot { box-shadow: 0 0 0 4px var(--sic-gold-pale); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .update-chip.is-pending .update-dot { animation: none; } }
.update-name { font-weight: 600; color: var(--sic-text-dark); }
.update-state { font-size: 0.85rem; color: var(--sic-text-mid); }

.glance { overflow: hidden; }
.glance-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 18px 20px;
  background: linear-gradient(90deg, var(--sic-burgundy-pale), #fff 70%); border-bottom: 1px solid var(--sic-border-light); }
.child-avatar.lg { width: 56px; height: 56px; font-size: 1.25rem; }
.glance-name { font-family: "EB Garamond", Georgia, serif; font-size: 1.6rem; font-weight: 600; color: var(--sic-burgundy); margin: 0; }
.glance-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.88rem; color: var(--sic-text-mid); }
.glance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.glance-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--sic-border-light); }
.glance-tile { padding: 18px 20px; border-right: 1px solid var(--sic-border-light); min-width: 0; }
.glance-grid > .glance-tile:last-child { border-right: 0; }
@media (max-width: 991.98px) {
  .glance-grid, .glance-grid.two { grid-template-columns: 1fr; }
  .glance-tile { border-right: 0; border-top: 1px solid var(--sic-border-light); }
}
.tile-label { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sic-text-muted);
  font-weight: 600; margin-bottom: 10px; }
.tile-big { font-family: "EB Garamond", Georgia, serif; font-size: 1.9rem; font-weight: 600; color: var(--sic-text-dark); line-height: 1; }
.tile-big small { font-size: 1rem; color: var(--sic-text-muted); }
.tile-note { font-size: 0.82rem; color: var(--sic-text-muted); }
.tile-empty { color: var(--sic-text-mid); font-size: 0.92rem; }
.tile-empty-icon { font-size: 1.6rem; margin-bottom: 4px; }

.score-ring { --pct: 0; width: 92px; height: 92px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--sic-burgundy) calc(var(--pct) * 1%), var(--sic-burgundy-pale) 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.score-ring span { position: relative; font-family: "EB Garamond", Georgia, serif; font-size: 1.7rem; font-weight: 600; color: var(--sic-burgundy); }
.score-ring small { font-size: 0.9rem; }

.change-pill { display: inline-flex; gap: 6px; align-items: center; margin-top: 8px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; background: var(--tone-none-bg); color: var(--tone-none-fg); }
.change-pill span { font-weight: 400; }
.change-pill.up { background: var(--tone-excellent-bg); color: var(--tone-excellent-fg); }
.change-pill.down { background: var(--tone-fail-bg); color: var(--tone-fail-fg); }

.subject-line { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.subject-line + .subject-line { border-top: 1px dashed var(--sic-border-light); }
.subject-tag { font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.subject-tag.good { background: var(--tone-excellent-bg); color: var(--tone-excellent-fg); }
.subject-tag.watch { background: var(--tone-fair-bg); color: var(--tone-fair-fg); }

.trend-svg { width: 100%; height: 72px; display: block; }
.trend-area { fill: var(--sic-burgundy-pale); }
.trend-line { fill: none; stroke: var(--sic-burgundy); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke; }
.trend-last { fill: var(--sic-gold); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }

.lesson-list { list-style: none; padding: 0; margin: 0; }
.lesson-list li { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--sic-border-light); }
.lesson-list li:last-child { border-bottom: 0; }
.lesson-list li.done { color: var(--sic-text-muted); }
.lesson-list li.now { font-weight: 600; color: var(--sic-burgundy); }
.lesson-time { width: 3.2rem; color: var(--sic-text-muted); font-size: 0.85rem; }

.subject-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.subject-chip { background: var(--sic-cream); border: 1px solid var(--sic-border-light); border-radius: var(--bs-border-radius);
  padding: 8px 10px; font-size: 0.86rem; line-height: 1.3; }
.subject-chip strong { display: block; color: var(--sic-text-dark); font-weight: 600; }
.subject-chip span { color: var(--sic-text-muted); font-size: 0.8rem; }
.glance-contact a { font-weight: 500; }
