/**
 * ============================================================
 * SMILE v2 — Component Library
 * St Mary's School Ascot
 * ============================================================
 *
 * Reusable UI components built entirely from design tokens.
 * Import AFTER tokens.css.
 *
 * Contents:
 *   1. Reset & Base
 *   2. App Shell (sidebar, topbar, sysbar, content)
 *   3. Sidebar Components
 *   4. Cards
 *   5. Buttons
 *   6. Form Elements
 *   7. Tags & Badges
 *   8. Typography Helpers
 *   9. Quick Tiles
 *  10. Data Display (stats, timetable, notices)
 *  11. Utility Classes
 *  12. Entrance Animations
 *  21. School Houses
 *  24. Tooltips
 * ============================================================
 */


/* ── 1. RESET & BASE ─────────────────────────────────────── */

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-page);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-ui); }


/* ── 2. APP SHELL ────────────────────────────────────────── */

.smile-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  min-height: 600px;
  overflow: hidden;
  transition: grid-template-columns 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.smile-shell.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.smile-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-page);
  border-left: 1px solid rgba(255,255,255,0.06);
}

.smile-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6) var(--space-8);
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
  position: relative;
}
.smile-content::-webkit-scrollbar { width: 8px; }
.smile-content::-webkit-scrollbar-track { background: transparent; }
.smile-content::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }
.smile-content::-webkit-scrollbar-thumb:hover { background: var(--color-gold); border: 2px solid transparent; background-clip: padding-box; }



/* ── 3. SIDEBAR ──────────────────────────────────────────── */

.smile-sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  /* Subtle radial glow from brand gold */
  background-image: radial-gradient(
    ellipse 240px 180px at 124px -10px,
    rgba(168,153,110,0.07) 0%,
    transparent 65%
  );
}

.sidebar-collapsed .smile-sidebar {
  transform: translateX(-100%);
}

/* Sidebar collapse toggle — pinned to right edge */
.sb-collapse-btn {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-periwinkle-dim);
  font-size: 0.65rem;
  z-index: 11;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.smile-sidebar:hover .sb-collapse-btn {
  opacity: 1;
}

.sb-collapse-btn:hover {
  color: var(--color-white);
  background: rgba(255,255,255,0.04);
}

/* Expand tab — fixed to left edge of viewport when sidebar collapsed.
   Mirrors the collapse tab's shape (rounded right, flat left). */
.sb-expand-burger {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--color-periwinkle-dim);
  font-size: 0.65rem;
  z-index: 11;
  opacity: 0.5;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.sb-expand-burger:hover {
  opacity: 1;
  color: var(--color-white);
  background: rgba(255,255,255,0.04);
}

.sb-expand-burger.visible {
  display: flex;
}

:root:not([data-theme="dark"]) .sb-expand-burger {
  border-color: rgba(4,30,66,0.12);
  color: rgba(4,30,66,0.45);
}
:root:not([data-theme="dark"]) .sb-expand-burger:hover {
  color: var(--color-navy);
  background: rgba(4,30,66,0.06);
  opacity: 1;
}

/* Brand area — crest + user identity in one block */
.sb-brand {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sb-logo-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
}

.sb-logo-wrap svg,
.sb-logo-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}

/* User identity — sits next to crest inside sb-brand */
.sb-user {
  display: none;
}

.sb-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sb-brand-text .sb-user-name {
  /* Decorative Rotis is allow-listed here — matches the logo's small-caps
     treatment. Every other heading on the platform uses Segoe UI via the
     flipped --font-display token. */
  font-family: var(--font-display-hero);
  font-variant: small-caps;
  font-size: var(--text-md);
  color: var(--color-periwinkle);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.sb-brand-text .sb-user-role {
  font-family: var(--font-ui);
  font-size: 0.5rem;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: rgb(168, 153, 110);
  margin-top: 2px;
}

/* Navigation */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-3);
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}
.sb-nav::-webkit-scrollbar { display: none; }

.sb-group {
  margin-bottom: var(--space-3);
}

.sb-group-label {
  font-family: var(--font-ui);
  font-size: 0.55rem;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: rgb(200, 180, 120);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
  display: block;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sb-text-idle);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  letter-spacing: 0.01em;
  cursor: pointer;
  margin-bottom: 1px;
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

.sb-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--color-periwinkle);
}

.sb-item.active {
  background: var(--sb-active-bg);
  color: var(--sb-text-active);
}

.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 16px;
  background: var(--sb-active-bar);
  border-radius: 0 2px 2px 0;
}

.sb-item-icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  flex-shrink: 0;
  opacity: 0.8;
}

.sb-item.active .sb-item-icon { opacity: 1; }

/* ── My Department(s) sidebar group ──────────────────────
   Synthetic nav entry injected from /api/me/nav `depts` payload.
   Single primary item links straight to the dept area; multi-dept
   users see a chevron toggling a submenu of secondary depts. */
.sb-mydept-primary {
  position: relative;
  padding-right: var(--space-7);
}
.sb-mydept-chevron {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sb-text-idle);
  border-radius: var(--radius-sm);
  opacity: 0.7;
  transition: transform var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}
.sb-mydept-chevron:hover {
  background: rgba(255,255,255,0.08);
  opacity: 1;
}
.sb-group-mydept.sb-mydept-open .sb-mydept-chevron {
  transform: translateY(-50%) rotate(180deg);
}
.sb-mydept-submenu {
  display: none;
  margin-left: var(--space-3);
  padding-left: var(--space-2);
  border-left: 1px solid rgba(168, 153, 110, 0.18);
  margin-top: 2px;
}
.sb-group-mydept.sb-mydept-open .sb-mydept-submenu {
  display: block;
}
.sb-mydept-secondary {
  font-size: calc(var(--text-base) - 1px);
  opacity: 0.92;
}

.sb-app-header {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-3);
}
.sb-app-header-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--sb-text-active);
  line-height: 1.3;
  margin-bottom: 4px;
}
.sb-return {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: rgba(200,180,120,0.5);
  cursor: pointer;
  transition: color var(--transition-fast);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.sb-return:hover {
  color: var(--color-periwinkle);
}
.sb-return-arrow {
  font-size: 0.55rem;
  opacity: 0.7;
}

.sb-badge {
  margin-left: auto;
  background: rgba(168,153,110,0.18);
  color: var(--text-gold-on-dark);
  font-size: 0.48rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  letter-spacing: var(--tracking-wide);
}

/* Sidebar footer */
.sb-footer {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* ── Light mode sidebar overrides ─────────────────────────────
   The default sidebar is dark navy; in light mode it becomes a
   light periwinkle-blue — text/hover colours need to flip to dark.
   Scoped to :root:not([data-theme="dark"]) to cover both the
   "no theme set" default state and an explicit light theme set.
   ─────────────────────────────────────────────────────────── */

:root:not([data-theme="dark"]) .sb-brand-text .sb-user-name {
  color: var(--color-navy);
}
:root:not([data-theme="dark"]) .sb-brand-text .sb-user-role {
  color: rgba(4,30,66,0.55);
}
:root:not([data-theme="dark"]) .sb-group-label {
  color: rgba(4,30,66,0.50);
}
:root:not([data-theme="dark"]) .sb-item:hover {
  background: rgba(4,30,66,0.07);
  color: var(--color-navy);
}
:root:not([data-theme="dark"]) .sb-return {
  color: rgba(4,30,66,0.45);
}
:root:not([data-theme="dark"]) .sb-return:hover {
  color: var(--color-navy);
}
:root:not([data-theme="dark"]) .sb-badge {
  background: rgba(4,30,66,0.10);
  color: var(--color-navy);
}
:root:not([data-theme="dark"]) .smile-sidebar {
  border-right: 1px solid rgba(4,30,66,0.10);
}
:root:not([data-theme="dark"]) .sb-footer {
  border-top-color: rgba(4,30,66,0.10);
}
:root:not([data-theme="dark"]) .sb-collapse-btn {
  border-color: rgba(4,30,66,0.12);
  color: rgba(4,30,66,0.45);
}
:root:not([data-theme="dark"]) .sb-collapse-btn:hover {
  color: var(--color-navy);
  background: rgba(4,30,66,0.06);
}
:root:not([data-theme="dark"]) .sb-admin-cog {
  color: rgba(4,30,66,0.55);
}
:root:not([data-theme="dark"]) .sb-admin-cog:hover {
  background: rgba(4,30,66,0.08);
  opacity: 1;
}

/* Platform Admin cog in footer — icon only */
.sb-admin-cog {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--color-periwinkle);
  opacity: 0.6;
  border-radius: 50%;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.sb-admin-cog:hover {
  opacity: 1;
  background: rgba(255,255,255,0.08);
}
.sb-admin-cog .sb-item-icon {
  width: auto; height: auto;
  font-size: inherit;
  opacity: 1;
}

.sb-danger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wide);
  transition: all var(--transition-fast);
}

.sb-danger-btn.fire {
  background: rgba(170,60,0,0.18);
  border: 1px solid rgba(200,80,20,0.22);
  color: #f0a070;
}

.sb-danger-btn.fire:hover {
  background: rgba(170,60,0,0.28);
}

.sb-danger-btn.emergency {
  background: rgba(160,20,20,0.18);
  border: 1px solid rgba(200,40,40,0.2);
  color: #f08080;
}

.sb-danger-btn.emergency:hover {
  background: rgba(160,20,20,0.28);
}


/* ── TOPBAR ──────────────────────────────────────────────── */

.smile-topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-default);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  z-index: 5;
}

/* Topbar left group — keeps hamburger + breadcrumb + date together */
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  flex: 1;
}

/* Breadcrumb crest — visible only when sidebar collapsed */
.bc-crest {
  display: none;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar-collapsed .bc-crest {
  display: inline-block;
}

/* Breadcrumb navigation */
.smile-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  min-width: 0;
}

.smile-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.smile-breadcrumb a:hover {
  color: var(--text-heading);
}

.smile-breadcrumb .bc-sep {
  color: var(--text-faint);
  font-size: 0.65rem;
  flex-shrink: 0;
}

.smile-breadcrumb .bc-current {
  color: var(--text-heading);
  font-family: var(--font-display);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-date {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--text-muted);
  font-style: italic;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.topbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-default);
  margin: 0 var(--space-1);
}

.topbar-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-navy);
  border: 1.5px solid var(--border-gold-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 0.68rem;
  color: var(--color-gold-light);
  cursor: pointer;
  margin-left: var(--space-1);
}


/* ── SYSBAR (external links) ─────────────────────────────── */

.smile-sysbar {
  background: var(--color-navy);
  height: var(--sysbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: 1px;
  flex-shrink: 0;
  border-top: 1px solid rgba(168,153,110,0.1);
}

.sysbar-link {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: rgba(203,211,235,0.5);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.sysbar-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(203,211,235,0.88);
}

.sysbar-link.featured {
  background: rgba(168,153,110,0.12);
  color: var(--text-gold-on-dark);
}

.sysbar-sep {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.07);
  margin: 0 var(--space-1);
  flex-shrink: 0;
}

.sysbar-link.push-right {
  margin-left: auto;
}


/* ── 4. CARDS ────────────────────────────────────────────── */

.card {
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--bg-card-tint) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-gold) 0%, transparent 100%);
  opacity: 0.15;
}

.card-head {
  padding: var(--space-3) var(--space-4) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.card-title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-faint);
}

.card-link {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  color: var(--text-gold-on-light);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.card-link:hover { color: var(--text-heading); }

.card-body {
  padding: 0 var(--space-4) var(--space-3);
}

/* Gold decorative rule — brand touch under card headers */
.gold-rule {
  height: 1px;
  margin: 0 var(--space-4);
  background: linear-gradient(90deg, var(--color-gold) 0%, transparent 100%);
  opacity: 0.2;
}


/* ── 5. BUTTONS ──────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  letter-spacing: var(--tracking-wide);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-navy);
  color: var(--color-white);
  border-color: var(--color-navy);
}
.btn-primary:hover {
  background: var(--color-navy-mid);
  border-color: var(--color-navy-mid);
}

.btn-gold {
  background: var(--color-gold);
  color: var(--color-navy);
  border-color: var(--color-gold);
  font-weight: 600;
}
.btn-gold:hover {
  background: var(--color-gold-light);
  border-color: var(--color-gold-light);
}

.btn-outline {
  background: transparent;
  color: var(--text-heading);
  border-color: var(--border-default);
}
.btn-outline:hover {
  background: var(--bg-card-tint);
  border-color: var(--border-gold);
}

.btn-ghost {
  background: var(--bg-page);
  color: var(--text-muted);
  border-color: var(--border-default);
}
.btn-ghost:hover {
  background: var(--bg-card-tint);
  color: var(--text-body);
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
  border-color: var(--color-danger);
}

/* Topbar button variant — smaller, lighter */
.btn-topbar {
  padding: 6px 11px;
  font-size: var(--text-sm);
  background: none;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}
.btn-topbar:hover {
  background: var(--bg-card-tint);
  border-color: var(--border-default);
  color: var(--text-body);
}

.btn-topbar.safeguarding {
  background: var(--color-success-bg);
  border-color: rgba(26,107,58,0.18);
  color: var(--color-success);
}
.btn-topbar.safeguarding:hover {
  background: rgba(26,107,58,0.14);
}

.btn-topbar.fire {
  background: var(--color-danger-bg);
  border-color: rgba(200,50,50,0.18);
  color: var(--color-danger);
}
.btn-topbar.fire:hover {
  background: rgba(200,50,50,0.14);
}


/* ── 6. FORM ELEMENTS ────────────────────────────────────── */

.form-group {
  margin-bottom: var(--space-3);
}

.form-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-heading);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(168,153,110,0.12);
  background: var(--bg-card);
}

.form-select { appearance: none; cursor: pointer; }

.form-textarea { resize: vertical; min-height: 80px; }

.form-upload {
  border: 1.5px dashed var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.form-upload:hover {
  border-color: var(--color-gold);
  background: var(--color-gold-subtle);
}

.form-upload-icon { font-size: 1.2rem; margin-bottom: var(--space-1); }
.form-upload-label { font-size: var(--text-sm); color: var(--text-faint); }

/* Form card wrapper */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.form-card-header {
  background: var(--color-navy);
  padding: var(--space-4) var(--space-6);
  border-bottom: 2px solid var(--color-gold);
}

.form-card-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-white);
  font-weight: 400;
}

.form-card-header .form-card-sub {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-gold-on-dark);
  margin-top: var(--space-1);
}

.form-card-body {
  padding: var(--space-6);
}

.form-card-footer {
  padding: var(--space-4) var(--space-6);
  background: var(--bg-page);
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}


/* ── 7. TAGS & BADGES ────────────────────────────────────── */

.tag {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.48rem;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-md);
}

.tag-gold    { background: rgba(168,153,110,0.1);   color: var(--text-gold-on-light); }
.tag-navy    { background: rgba(4,30,66,0.07);       color: var(--text-heading); }
.tag-danger  { background: var(--color-danger-bg);     color: var(--color-danger); }
.tag-success { background: rgba(26,107,58,0.08);     color: var(--color-success); }
.tag-warning { background: rgba(184,120,32,0.08);    color: var(--color-warning); }
.tag-info    { background: rgba(42,90,184,0.08);     color: var(--color-info); }


/* ── 8. TYPOGRAPHY HELPERS ───────────────────────────────── */

.page-eyebrow {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-1);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  color: var(--text-heading);
  line-height: 1.1;
  letter-spacing: var(--tracking-tight);
}

.page-title em {
  font-style: italic;
  color: var(--text-gold-on-light);
}

/* Dashboard hero greeting — one of the two sanctioned Rotis moments.
   Decorative by design; small-caps to match the school logo. */
.dash-hero-text .page-title,
.page-title.hero-greeting {
  font-family: var(--font-display-hero);
  font-variant: small-caps;
  letter-spacing: 0.01em;
}

.page-subtitle {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--text-heading);
}

.display-heading {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 400;
  color: var(--text-heading);
  line-height: 1.1;
}


/* ── 9. QUICK TILES ──────────────────────────────────────── */

.quick-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, 88px);
  grid-auto-rows: min-content;
  grid-auto-flow: dense;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.q-tile { width: 88px; flex-shrink: 0; }
.q-tile-wide { width: 184px; grid-column: span 2; }

.q-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--bg-card-tint) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-1) var(--space-2);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  height: 72px;
}

.q-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-gold) 0%, transparent 100%);
  opacity: 0.15;
  transition: opacity var(--transition-fast);
}

.q-tile:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-gold);
  transform: translateY(-1px);
}

.q-tile:hover::before { opacity: 1; }

.q-tile.featured {
  background: var(--tile-featured-bg, var(--color-navy));
  border-color: var(--tile-featured-bg, var(--color-navy));
}

.q-tile.featured::before {
  background: var(--color-gold);
  opacity: 1;
}

.q-tile.featured .q-tile-label { color: rgba(203,211,235,0.7); }
.q-tile.featured .q-tile-icon svg { stroke: var(--color-gold-bright); }

.q-tile-icon {
  font-size: 1rem;
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
}

.q-tile-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-heading);
  stroke-width: 1.8;
  fill: none;
}

.q-tile-label {
  font-family: var(--font-ui);
  font-size: 0.56rem;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  line-height: 1.3;
}

/* External link indicator */
.q-tile-external {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0.3;
}
.q-tile-external svg {
  width: 8px;
  height: 8px;
  stroke: var(--text-faint);
  stroke-width: 2;
  fill: none;
}

/* Edit pencil on custom tiles in jiggle mode */
.q-tile-edit {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.jiggle-mode .q-tile-edit { opacity: 1; }
.q-tile-edit:hover { background: rgba(0,0,0,0.65); }
.q-tile-edit svg {
  width: 11px;
  height: 11px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
}

/* ── Coloured tiles ────────────────────────── */
.q-tile-colored .q-tile-icon svg {
  stroke: var(--tile-icon-color, var(--text-heading));
}
.q-tile-colored .q-tile-label {
  color: var(--tile-label-color, var(--text-muted));
}
.q-tile-colored::before {
  background: var(--tile-icon-color, var(--border-gold));
  opacity: 1;
}

/* ── Double-width tiles ───────────────────── */
.q-tile-wide .q-tile-icon svg { width: 24px; height: 24px; }
.q-tile-wide .q-tile-label { font-size: 0.65rem; }

/* ── Tile Cards (visible grouped containers) ─ */
.tile-panel {
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  align-content: start;
  /* Span enough parent grid columns to fit inner tile grid + padding */
  grid-column: span 3;
}
.tile-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  padding: 0 var(--space-1);
}
.tile-panel-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.tile-panel-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.tile-panel-grid .q-tile-wide { width: 184px; }
.tile-panel .q-tile {
  background: var(--bg-card-tint);
  border-color: var(--border-default);
}
/* Empty card placeholder */
.tile-panel-empty {
  grid-column: 1 / -1;
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-faint);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
}

/* ── Coloured panels ──────────────────────── */
.tile-panel-colored {
  border-color: var(--tile-icon-color, var(--border-card)) !important;
}
.tile-panel-colored .tile-panel-label {
  color: var(--tile-label-color, var(--text-muted));
}

/* Card select mode — highlight selected tiles */
.q-tile-panel-selected {
  box-shadow: 0 0 0 3px var(--color-gold) !important;
  border-color: var(--color-gold) !important;
  animation: none !important;
}

/* Colour swatch picker in customise modal */
.tile-color-swatches {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tile-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}
.tile-color-swatch:hover {
  transform: scale(1.2);
}
.tile-color-swatch.active {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 2px rgba(168,153,110,0.3);
  transform: scale(1.15);
}

/* ── Colour picker popover (jiggle mode tap) ── */
.tile-color-popover {
  position: fixed;
  z-index: 10000;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  box-shadow: var(--shadow-lg);
  animation: tcp-pop 0.15s ease-out;
}
@keyframes tcp-pop {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}
.tcp-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tcp-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.tcp-swatch:hover {
  transform: scale(1.2);
}
.tcp-swatch.active {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 2px rgba(168,153,110,0.3);
  transform: scale(1.15);
}

/* ── Folder tile (grouped tiles) ────────────── */
.q-tile-folder {
  cursor: pointer;
  background: var(--bg-card);
  position: relative;
}
.q-tile-folder:hover {
  border-color: var(--border-gold);
}
.q-folder-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-1);
}
.q-folder-preview-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168,153,110,0.08);
  border-radius: 3px;
}
.q-folder-preview-icon svg {
  width: 10px;
  height: 10px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}
.q-folder-count {
  position: absolute;
  top: 4px;
  right: 4px;
  font-family: var(--font-ui);
  font-size: 0.45rem;
  font-weight: 600;
  color: var(--text-faint);
  background: rgba(168,153,110,0.12);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

/* ── Folder modal overlay ──────────────────── */
.tile-folder-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(4, 30, 66, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.tile-folder-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.tile-folder-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  padding: var(--space-5);
  width: 100%;
  max-width: 400px;
  animation: folder-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes folder-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.tile-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.tile-folder-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-heading);
  font-weight: 600;
}
.tile-folder-header-actions {
  display: flex;
  gap: var(--space-2);
}
.tile-folder-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-faint);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.tile-folder-edit:hover {
  color: var(--color-gold);
  background: rgba(168,153,110,0.1);
}
.tile-folder-edit svg {
  stroke: currentColor;
  fill: none;
}
.tile-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--space-2);
}
.tile-folder-grid .q-tile {
  min-height: 72px;
  position: relative;
}
/* Ungroup button — remove tile from folder */
.tile-folder-grid .q-tile-ungroup {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 13px;
  line-height: 17px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile-folder-grid .q-tile:hover .q-tile-ungroup {
  opacity: 0.8;
}
.tile-folder-grid .q-tile-ungroup:hover {
  opacity: 1 !important;
  background: rgba(180,50,50,0.7);
}

/* ── Merge target indicator (during reorder drag) ── */
.quick-tiles.jiggle-mode .q-tile.merge-target {
  animation: none;
  transform: scale(1.15);
  border: 2px solid var(--color-gold);
  box-shadow: 0 0 16px rgba(168,153,110,0.35), 0 0 0 4px rgba(168,153,110,0.15);
  z-index: 3;
  transition: transform 0.2s cubic-bezier(0.2,0,0,1), box-shadow 0.2s ease;
}

/* Edit/add tile — dashed border */
.q-tile.q-tile-edit {
  border-style: dashed;
  border-color: var(--border-default);
  opacity: 0.6;
  min-height: 72px;
}
.q-tile.q-tile-edit:hover { opacity: 1; }

/* Tile picker modal */
.tile-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 15, 34, 0.45);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.tile-picker-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.tile-picker {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.06);
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - var(--space-8));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tile-picker-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tile-picker-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tile-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
}

.tile-picker-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-heading);
}

.tile-picker-count {
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.tile-picker-body {
  padding: var(--space-3) var(--space-4);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Search input */
.tile-picker-search-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}
.tile-picker-search-wrap > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--text-faint);
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}
.tile-picker-search {
  width: 100%;
  padding: 8px var(--space-3) 8px 34px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-body);
  background: var(--bg-page);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.tile-picker-search:focus {
  border-color: var(--color-gold);
}

/* Collapsible sections */
.tile-picker-section {
  margin-bottom: var(--space-2);
}
.tile-picker-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--space-2);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.tile-picker-section-header:hover {
  background: rgba(168,153,110,0.06);
}
.tile-picker-section-title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tile-picker-section-title svg {
  width: 13px;
  height: 13px;
  stroke: var(--text-faint);
  stroke-width: 2;
  fill: none;
}
.tile-picker-section-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tile-picker-section-count {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
}
.section-chevron {
  width: 14px;
  height: 14px;
  stroke: var(--text-faint);
  stroke-width: 2;
  fill: none;
  transition: transform 0.2s ease;
}
.tile-picker-section.collapsed .section-chevron {
  transform: rotate(-90deg);
}
.tile-picker-section.collapsed .tile-picker-grid {
  display: none;
}
.tile-picker-section-hint {
  font-size: var(--text-xs);
  color: var(--text-faint);
  padding: 0 var(--space-2);
  margin-bottom: 4px;
  opacity: 0.7;
}

/* Compact list rows */
.tile-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: var(--space-2);
}

.tile-pick {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-body);
}
.tile-pick:hover {
  background: rgba(168,153,110,0.06);
}
.tile-pick.selected {
  background: rgba(168,153,110,0.08);
  color: var(--text-heading);
}
.tile-pick.filtered-out {
  display: none;
}

/* Checkbox indicator */
.tile-pick-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.tile-pick.selected .tile-pick-check {
  background: var(--color-gold);
  border-color: var(--color-gold);
}
.tile-pick-check svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
  opacity: 0;
}
.tile-pick.selected .tile-pick-check svg {
  opacity: 1;
}

.tile-pick > svg,
.tile-pick > i svg {
  width: 15px;
  height: 15px;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  fill: none;
  flex-shrink: 0;
}
.tile-pick.selected > svg,
.tile-pick.selected > i svg {
  stroke: var(--color-gold);
}

.tile-picker-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── Tile group headers ────────────────────── */
.q-tile-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}
.q-tile-group-label {
  font-family: var(--font-ui);
  font-size: 0.55rem;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-faint);
  opacity: 0.7;
}

/* ── Jiggle reorder mode — iOS-style in-place drag ── */

@keyframes tile-jiggle {
  0%   { transform: rotate(-0.5deg); }
  25%  { transform: rotate(0.5deg); }
  50%  { transform: rotate(-0.3deg); }
  75%  { transform: rotate(0.4deg); }
  100% { transform: rotate(-0.5deg); }
}
.quick-tiles.jiggle-mode .q-tile {
  animation: tile-jiggle 0.6s ease-in-out infinite;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 2px dashed var(--border-gold);
  box-shadow: 0 0 0 1px rgba(168,153,110,0.15), var(--shadow-sm);
  background: var(--bg-card);
}
.quick-tiles.jiggle-mode .q-tile:nth-child(2n) {
  animation-delay: 0.08s;
}
.quick-tiles.jiggle-mode .q-tile:nth-child(3n) {
  animation-delay: 0.18s;
  animation-duration: 0.7s;
}
.quick-tiles.jiggle-mode .q-tile.featured {
  border-color: var(--color-gold);
}
/* Placeholder: faded but holds space in grid */
.quick-tiles.jiggle-mode .q-tile.q-tile-placeholder {
  opacity: 0.15;
  animation: none;
  transform: scale(0.9);
  border-style: dashed;
}
/* Floating clone follows pointer */
.q-tile-floater {
  position: fixed !important;
  z-index: 10000 !important;
  pointer-events: none !important;
  animation: none !important;
  transform: scale(1.08) rotate(2deg) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 2px var(--color-gold) !important;
  border: 2px solid var(--color-gold) !important;
  opacity: 0.95;
  transition: none !important;
}
.quick-tiles.jiggle-mode .q-tile:hover::before {
  opacity: 0;
}
.quick-tiles.jiggle-mode .q-tile-group-header {
  animation: none;
}

/* Icon picker grid */
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: var(--space-1);
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.icon-pick {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-pick:hover { background: var(--bg-card-tint); }
.icon-pick.selected { background: var(--color-navy); }
.icon-pick.selected svg { stroke: var(--color-gold-bright); }
.icon-pick svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  fill: none;
}

/* Toggle switch */
.toggle { position: relative; width: 36px; height: 20px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--color-quartz); border-radius: var(--radius-full); cursor: pointer; transition: background var(--transition-fast); }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform var(--transition-fast); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-slider { background: var(--color-success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

@media (max-width: 768px) {
  .quick-tiles {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }
}


/* ── 10. DATA DISPLAY ────────────────────────────────────── */

/* Stat trio */
.stat-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-default);
}

.stat-block {
  background: var(--bg-card);
  padding: var(--space-4) var(--space-3);
  position: relative;
}

.stat-block::after {
  content: '';
  position: absolute;
  bottom: 0; left: var(--space-3); right: var(--space-3);
  height: 2px;
  border-radius: 1px;
}

.stat-block.gold::after   { background: var(--color-gold);      opacity: 0.55; }
.stat-block.navy::after   { background: var(--color-navy);      opacity: 0.25; }
.stat-block.peri::after   { background: var(--color-periwinkle-mid); opacity: 0.5; }
.stat-block.green::after  { background: var(--color-success);   opacity: 0.5; }
.stat-block.danger::after { background: var(--color-danger);    opacity: 0.5; }

.stat-num {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 400;
  color: var(--text-heading);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Timetable / lesson list */
.lesson-list { display: flex; flex-direction: column; }

.lesson-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-default);
}

.lesson-row:last-child { border-bottom: none; }

.lesson-time {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: var(--text-faint);
  width: 38px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.lesson-pip {
  width: 3px;
  height: 30px;
  border-radius: 2px;
  flex-shrink: 0;
}

.lesson-info { flex: 1; min-width: 0; }

.lesson-subject {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-detail {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: var(--text-faint);
  margin-top: 1px;
}

.lesson-room {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  color: var(--text-muted);
  background: var(--bg-page);
  padding: 2px 7px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Notice list */
.notice-list { display: flex; flex-direction: column; }

.notice-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-default);
}

.notice-row:last-child { border-bottom: none; }

.notice-bar {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 28px;
}

.notice-bar.gold   { background: var(--color-gold); }
.notice-bar.navy   { background: var(--text-muted); opacity: 0.4; }
.notice-bar.danger { background: var(--color-danger); }
.notice-bar.green  { background: var(--color-success); }

.notice-content { flex: 1; }

.notice-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--text-heading);
  font-weight: 400;
  line-height: 1.2;
}

.notice-sub {
  font-family: var(--font-ui);
  font-size: 0.63rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* At-a-glance items */
.glance-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-default);
}

.glance-item:last-child { border-bottom: none; }

.glance-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.glance-icon.gold  { background: rgba(168,153,110,0.1); }
.glance-icon.navy  { background: rgba(4,30,66,0.06); }
.glance-icon.green { background: var(--color-success-bg); }
.glance-icon.red   { background: var(--color-danger-bg); }

.glance-body { flex: 1; }

.glance-title {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-heading);
}

.glance-sub {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: var(--text-faint);
  margin-top: 1px;
}

.glance-meta {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.glance-meta.urgent { color: var(--color-danger); }


/* ── 11. UTILITY CLASSES ─────────────────────────────────── */

/* Layout */
.u-flex         { display: flex; }
.u-flex-wrap    { display: flex; flex-wrap: wrap; }
.u-flex-col     { display: flex; flex-direction: column; }
.u-flex-center  { display: flex; align-items: center; justify-content: center; }
.u-flex-between { display: flex; align-items: center; justify-content: space-between; }
.u-items-center { align-items: center; }
.u-items-start  { align-items: flex-start; }
.u-flex-1       { flex: 1; }
.u-w-full       { width: 100%; }
.u-text-center  { text-align: center; }
.u-text-right   { text-align: right; }

/* Gap */
.u-gap-1        { gap: var(--space-1); }
.u-gap-2        { gap: var(--space-2); }
.u-gap-3        { gap: var(--space-3); }
.u-gap-4        { gap: var(--space-4); }

/* Margin */
.u-mt-1         { margin-top: var(--space-1); }
.u-mt-2         { margin-top: var(--space-2); }
.u-mt-3         { margin-top: var(--space-3); }
.u-mt-4         { margin-top: var(--space-4); }
.u-mb-1         { margin-bottom: var(--space-1); }
.u-mb-2         { margin-bottom: var(--space-2); }
.u-mb-3         { margin-bottom: var(--space-3); }
.u-mb-4         { margin-bottom: var(--space-4); }

/* Typography */
.u-text-faint   { color: var(--text-faint); }
.u-text-muted   { color: var(--text-muted); }
.u-text-gold    { color: var(--text-gold-on-light); }
.u-text-danger  { color: var(--color-danger); }
.u-font-display { font-family: var(--font-display); }
.u-font-mono    { font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.u-uppercase    { text-transform: uppercase; letter-spacing: var(--tracking-wider); }
.u-sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Composites — high-frequency patterns */
.u-hint         { font-size: var(--text-sm); color: var(--text-muted); }
.u-field-hint   { display: block; margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
.u-label        { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wider); color: var(--text-faint); }
.u-code         { background: var(--bg-hover, rgba(4,30,66,0.04)); padding: 2px 6px; border-radius: var(--radius-md); font-size: var(--text-xs); }


/* ── 12. LOADING & FEEDBACK STATES ──────────────────────── */

/*
 * Platform-wide loading, button states, toasts, skeletons.
 * Applies automatically — no per-app setup needed.
 *
 * Button loading:    btn.smileLoading(label?) / btn.smileDone(label?) / btn.smileReset()
 * Toast:             SMILE.toast(message, type)   type: success | error | info | warning
 * Skeleton:          <div class="skeleton"> or <div class="skeleton-text">
 * Page overlay:      SMILE.showOverlay() / SMILE.hideOverlay()
 */


/* ── BUTTON LOADING STATE ────────────────────────────────── */

.btn {
  position: relative;
  overflow: hidden;
}

/* Ripple effect on click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  border-radius: inherit;
}
.btn:active::after { opacity: 1; }

/* Loading state — set via JS: btn.classList.add('btn-loading') */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn.btn-loading .btn-label { opacity: 0; }

.btn.btn-loading::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: smile-spin 0.65s linear infinite;
}

/* For ghost/outline buttons the spinner uses navy */
.btn-ghost.btn-loading::before,
.btn-outline.btn-loading::before {
  border-color: rgba(4,30,66,0.15);
  border-top-color: var(--color-navy);
}

/* Success flash */
.btn.btn-success-flash {
  background: var(--color-success) !important;
  border-color: var(--color-success) !important;
  color: white !important;
  pointer-events: none;
  transition: background 0.2s, border-color 0.2s;
}

/* Error flash */
.btn.btn-error-flash {
  background: var(--color-danger) !important;
  border-color: var(--color-danger) !important;
  color: white !important;
  pointer-events: none;
}

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


/* ── SKELETON LOADERS ────────────────────────────────────── */

@keyframes smile-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card-tint) 25%,
    rgba(168,153,110,0.06) 50%,
    var(--bg-card-tint) 75%
  );
  background-size: 800px 100%;
  animation: smile-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-card-tint) 25%,
    rgba(168,153,110,0.06) 50%,
    var(--bg-card-tint) 75%
  );
  background-size: 800px 100%;
  animation: smile-shimmer 1.4s ease-in-out infinite;
}

.skeleton-text.short  { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long   { width: 90%; }
.skeleton-text.full   { width: 100%; }

/* Skeleton card — drop in instead of a card while data loads */
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.skeleton-avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-default);
}
.skeleton-row:last-child { border-bottom: none; }


/* ── TOAST NOTIFICATIONS ─────────────────────────────────── */

.smile-toast-wrap {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 360px;
}

.smile-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-navy);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(4,30,66,0.22), 0 1px 4px rgba(4,30,66,0.12);
  color: var(--color-white);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: 1.45;
  pointer-events: all;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-left: 3px solid var(--color-gold);
  min-width: 260px;
}

.smile-toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.smile-toast.exiting {
  opacity: 0;
  transform: translateY(4px) scale(0.98);
}

.smile-toast-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.smile-toast-body { flex: 1; }
.smile-toast-title {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 1px;
}
.smile-toast-msg {
  color: rgba(255,255,255,0.7);
  font-size: var(--text-sm);
}

.smile-toast-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.smile-toast-close:hover { color: rgba(255,255,255,0.85); }

/* Type variants */
.smile-toast.success { border-left-color: var(--color-success); }
.smile-toast.error   { border-left-color: var(--color-danger);  background: var(--color-navy-deep); }
.smile-toast.warning { border-left-color: var(--color-warning); }
.smile-toast.info    { border-left-color: var(--color-info);    }

/* Progress bar */
.smile-toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: rgba(255,255,255,0.2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transition: width linear;
}


/* ── PAGE OVERLAY (full-screen loading) ──────────────────── */

.smile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 8888;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.smile-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.smile-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.smile-overlay-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(4,30,66,0.1);
  border-top-color: var(--color-navy);
  border-right-color: var(--color-gold);
  border-radius: 50%;
  animation: smile-spin 0.8s ease-in-out infinite;
}

.smile-overlay-label {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--text-heading);
  font-style: italic;
  letter-spacing: 0.02em;
}


/* ── INLINE SPINNER (for table rows, cards etc) ──────────── */

.smile-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(4,30,66,0.12);
  border-top-color: var(--color-navy);
  border-radius: 50%;
  animation: smile-spin 0.65s linear infinite;
  flex-shrink: 0;
}

.smile-spinner.gold {
  border-color: rgba(168,153,110,0.2);
  border-top-color: var(--color-gold);
}

.smile-spinner.sm {
  width: 12px; height: 12px;
  border-width: 1.5px;
}

.smile-spinner.lg {
  width: 24px; height: 24px;
  border-width: 3px;
}

/* Loading row — used in tables while data fetches */
.smile-loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}


/* ── CREST LOADER ─────────────────────────────────────────────
 * Branded loading animation: school crest with a clean gold highlight
 * tracing around the crown teeth.
 * Use SMILE.crestLoader(label) to generate the HTML.
 * ──────────────────────────────────────────────────────────── */

.smile-crest-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
}

.smile-crest-loader svg {
  display: block;
}

/* Dimmed base crest — "unetched metal" look while laser traces */
.smile-crest-loader .crest-base {
  animation: crest-pulse 2.8s ease-in-out infinite;
}

/* Gold engraved trail — grows from 12 o'clock as the laser engraves */
.smile-crest-loader .crest-trail {
  animation: crest-engrave-grow 60s linear infinite;
}
.smile-crest-loader .crest-spark-burst {
  filter: url(#crest-laser-glow);
  pointer-events: none;
}
.smile-crest-loader .crest-spark-core {
  animation: crest-spark-core 0.34s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.smile-crest-loader .crest-spark-ray {
  animation: crest-spark-flicker 0.58s ease-out infinite;
  opacity: 0;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: right center;
  vector-effect: non-scaling-stroke;
}
.smile-crest-loader .crest-spark-ray.ray-2 { animation-delay: -0.07s; }
.smile-crest-loader .crest-spark-ray.ray-3 { animation-delay: -0.13s; }
.smile-crest-loader .crest-spark-ray.ray-4 { animation-delay: -0.19s; }
.smile-crest-loader .crest-spark-ray.ray-5 { animation-delay: -0.25s; }
.smile-crest-loader .crest-spark-ray.ray-6 { animation-delay: -0.31s; }
.smile-crest-loader .crest-spark-ray.ray-7 { animation-delay: -0.37s; }
.smile-crest-loader .crest-spark-ray.ray-8 { animation-delay: -0.43s; }
.smile-crest-loader .crest-spark-ray.ray-9 { animation-delay: -0.49s; }
.smile-crest-loader .crest-spark-ray.ray-10 { animation-delay: -0.55s; }
.smile-crest-loader .crest-spark-ray.ray-11 { animation-delay: -0.1s; }
.smile-crest-loader .crest-spark-ray.ray-12 { animation-delay: -0.22s; }
.smile-crest-loader .crest-spark-ray.ray-13 { animation-delay: -0.34s; }
.smile-crest-loader .crest-spark-ray.ray-14 { animation-delay: -0.46s; }
.smile-crest-loader .crest-spark-dot {
  animation: crest-spark-dot 0.5s ease-out infinite;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.smile-crest-loader .crest-spark-dot.dot-2 { animation-delay: -0.08s; }
.smile-crest-loader .crest-spark-dot.dot-3 { animation-delay: -0.16s; }
.smile-crest-loader .crest-spark-dot.dot-4 { animation-delay: -0.24s; }
.smile-crest-loader .crest-spark-dot.dot-5 { animation-delay: -0.32s; }
.smile-crest-loader .crest-spark-dot.dot-6 { animation-delay: -0.4s; }
.smile-crest-loader .crest-spark-dot.dot-7 { animation-delay: -0.06s; }
.smile-crest-loader .crest-spark-dot.dot-8 { animation-delay: -0.14s; }
.smile-crest-loader .crest-spark-dot.dot-9 { animation-delay: -0.22s; }
.smile-crest-loader .crest-spark-dot.dot-10 { animation-delay: -0.3s; }
.smile-crest-loader .crest-spark-dot.dot-11 { animation-delay: -0.38s; }
.smile-crest-loader .crest-spark-dot.dot-12 { animation-delay: -0.46s; }

.smile-crest-loader .crest-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.02em;
}

@keyframes crest-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.7; }
}

/* Trail grows from nothing to the full teeth path over one minute */
@keyframes crest-engrave-grow {
  0%   { stroke-dasharray: 0.001 0.999; }
  100% { stroke-dasharray: 1 0; }
}

@keyframes crest-spark-flicker {
  0%, 100% { opacity: 0; transform: scaleX(0.12); }
  9%       { opacity: 1; transform: scaleX(1); }
  24%      { opacity: 0.72; transform: scaleX(0.86); }
  46%      { opacity: 0.18; transform: scaleX(0.42); }
}

@keyframes crest-spark-dot {
  0%, 100% { opacity: 0; transform: scale(0.4); }
  12%      { opacity: 1; transform: scale(1); }
  38%      { opacity: 0.45; transform: scale(0.72); }
}

@keyframes crest-spark-core {
  0%, 100% { opacity: 0.65; transform: scale(0.72); }
  35%      { opacity: 1; transform: scale(1.08); }
}

/* Size variants — doubled 2026-04-26 for legibility on large displays */
.smile-crest-loader.crest-sm svg { width:  96px; height:  96px; }
.smile-crest-loader.crest-md svg { width: 144px; height: 144px; }
.smile-crest-loader.crest-lg svg { width: 192px; height: 192px; }

.smile-crest-loader.crest-md .crest-label,
.smile-crest-loader.crest-lg .crest-label {
  font-size: var(--text-base);
}


/* ── ENTRANCE ANIMATIONS ────────────────────────────────────
 * Consistent page entrance across all SMILE apps.
 * .smile-content gets a smooth fade-up on load.
 * Cards stagger in with child delay via .anim-stagger.
 * Add .anim-enter to any element for a single fade-up.
 * ──────────────────────────────────────────────────────────── */

.smile-content {
  opacity: 0;
  animation: smile-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@keyframes smile-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Staggered card entrance — add .anim-stagger to the parent grid/container */
.anim-stagger > .card,
.anim-stagger > [class*="card"],
.anim-stagger > .profile-section,
.anim-stagger > .stat-card {
  opacity: 0;
  animation: smile-card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.anim-stagger > :nth-child(1) { animation-delay: 0.25s; }
.anim-stagger > :nth-child(2) { animation-delay: 0.35s; }
.anim-stagger > :nth-child(3) { animation-delay: 0.45s; }
.anim-stagger > :nth-child(4) { animation-delay: 0.55s; }
.anim-stagger > :nth-child(5) { animation-delay: 0.65s; }
.anim-stagger > :nth-child(6) { animation-delay: 0.75s; }

@keyframes smile-card-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Generic single-element entrance — add class="anim-enter" */
.anim-enter {
  opacity: 0;
  animation: smile-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

/* ── SCROLL REVEAL ─────────────────────────────────────────────
 * Scroll-triggered reveal via IntersectionObserver.
 * Add .anim-scroll to any element — fades up when scrolled into view.
 * Add .anim-scroll-stagger to a parent — children reveal sequentially.
 * JS observer in smile-shell.js adds .is-visible when element enters viewport.
 * ──────────────────────────────────────────────────────────── */

/* Single element scroll reveal */
.anim-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.anim-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered scroll reveal — add .anim-scroll-stagger to parent container.
   Direct children get cascading delays automatically. */
.anim-scroll-stagger > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.anim-scroll-stagger.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}
.anim-scroll-stagger.is-visible > :nth-child(1)  { transition-delay: 0s; }
.anim-scroll-stagger.is-visible > :nth-child(2)  { transition-delay: 0.06s; }
.anim-scroll-stagger.is-visible > :nth-child(3)  { transition-delay: 0.12s; }
.anim-scroll-stagger.is-visible > :nth-child(4)  { transition-delay: 0.18s; }
.anim-scroll-stagger.is-visible > :nth-child(5)  { transition-delay: 0.24s; }
.anim-scroll-stagger.is-visible > :nth-child(6)  { transition-delay: 0.30s; }
.anim-scroll-stagger.is-visible > :nth-child(7)  { transition-delay: 0.36s; }
.anim-scroll-stagger.is-visible > :nth-child(8)  { transition-delay: 0.42s; }
.anim-scroll-stagger.is-visible > :nth-child(9)  { transition-delay: 0.48s; }
.anim-scroll-stagger.is-visible > :nth-child(10) { transition-delay: 0.54s; }
.anim-scroll-stagger.is-visible > :nth-child(n+11) { transition-delay: 0.6s; }

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .anim-scroll,
  .anim-scroll-stagger > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
}


/* ── 12. MODALS ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 15, 34, 0.45);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-heading);
  font-weight: 500;
  flex: 1;
  margin: 0;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-page);
}

.modal-close svg {
  width: 14px;
  height: 14px;
}

.modal-body {
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-ui);
}
.modal-body input,
.modal-body select,
.modal-body textarea {
  font-family: var(--font-ui);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
}


/* ── 13. PANELS (show/hide content sections) ──────────────── */

.panel { display: none; }
.panel.active { display: block; }


/* ── 14. STAT CARDS ───────────────────────────────────────── */

.stat-card {
  background: linear-gradient(135deg, var(--bg-card) 60%, var(--bg-card-tint) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--text-heading);
  font-weight: 500;
  line-height: 1;
}
.stat-sub {
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: var(--space-1);
}

/* Stat card severity variants — coloured top bar */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
}
.stat-card.highlight { border-color: var(--border-gold); background: linear-gradient(135deg, var(--bg-card) 0%, var(--color-gold-subtle) 100%); }
.stat-card.highlight::before { background: var(--color-gold); }
.stat-card.danger { border-color: var(--color-danger-bg); }
.stat-card.danger .stat-value { color: var(--color-danger); }
.stat-card.danger::before { background: var(--color-danger); }
.stat-card.success::before { background: var(--color-success); }
.stat-card.warning::before { background: var(--color-warning); }
.stat-card.info::before { background: var(--color-info); }
.stat-card.neutral::before { background: var(--color-quartz); }

/* Stat grid layouts */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
@media (max-width: 768px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-row { grid-template-columns: 1fr; } }


/* ── 15. FILTER BAR & BUTTONS ─────────────────────────────── */

.filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.filter-bar input[type="text"] {
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--bg-card);
  color: var(--text-body);
  min-width: 150px;
}
.filter-bar input[type="text"]:focus {
  outline: none;
  border-color: var(--color-gold);
}
.filter-group { display: flex; gap: var(--space-1); }
.filter-btn {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  font-weight: 600;
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-btn:hover { border-color: var(--border-gold); color: var(--text-heading); }
.filter-btn.active { background: var(--color-navy); border-color: var(--color-navy); color: var(--color-white); }


/* ── 16. BADGES ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Status colours */
.badge.success, .badge.allowed, .badge.cleared, .badge.reviewed { background: var(--color-success-bg); color: var(--color-success); }
.badge.danger, .badge.critical, .badge.blocked, .badge.active, .badge.flagged { background: var(--color-danger-bg); color: var(--color-danger); }
.badge.warning, .badge.high { background: var(--color-warning-bg); color: #b45309; }
.badge.info, .badge.medium, .badge.actioned { background: var(--color-info-bg); color: var(--color-info); }
.badge.muted, .badge.archived { background: var(--bg-card-tint); color: var(--text-muted); }
.badge.gold { background: var(--color-gold-subtle); color: var(--color-gold); }
.badge.navy { background: var(--color-navy); color: var(--color-white); }


/* ── 17. DATA TABLE ───────────────────────────────────────── */

.data-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-card); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th {
  background: var(--bg-card-tint);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-card);
  white-space: nowrap;
  font-weight: 500;
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
  color: var(--text-body);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-card-tint); }
.data-table .mono { font-family: var(--font-ui); font-variant-numeric: tabular-nums; font-size: var(--text-sm); color: var(--text-muted); }
.data-table .truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { display: flex; gap: var(--space-2); align-items: center; }

/* ── 18. BUTTON SIZE VARIANTS ─────────────────────────────── */

.btn-xs { padding: 3px 10px; font-size: var(--text-xs); }
.btn-sm { padding: 4px var(--space-3); font-size: var(--text-sm); }
.btn-icon { width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; }

/* ── 19. LOADING & EMPTY STATES ───────────────────────────── */

.loading-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-5); color: var(--text-muted); }
.empty-state { text-align: center; padding: var(--space-6); color: var(--text-muted); }
.empty-icon { font-size: 2rem; margin-bottom: var(--space-2); opacity: 0.5; }
.empty-label { font-size: var(--text-sm); }

/* ── 20. STATUS DOTS ──────────────────────────────────────── */

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok, .dot-success { background: var(--color-success); box-shadow: 0 0 6px var(--color-success-bg); }
.dot-warn, .dot-warning { background: var(--color-warning); }
.dot-error, .dot-danger { background: var(--color-danger); box-shadow: 0 0 6px var(--color-danger-bg); }
.dot-unknown, .dot-muted { background: var(--color-quartz); }


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤768px) & Mobile (≤480px)
   ══════════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop, injected by smile-shell.js */
.smile-hamburger {
  display: none;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid var(--border-default);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-body);
  transition: background var(--transition-fast);
}
.smile-hamburger:hover { background: var(--bg-card-tint); }
.smile-hamburger svg { width: 16px; height: 16px; }

/* Sidebar backdrop overlay for mobile */
.smile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.smile-sidebar-backdrop.visible { opacity: 1; }

/* ── TABLET ≤768px ─────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Shell: sidebar becomes slide-over drawer */
  .smile-shell {
    grid-template-columns: 1fr;
  }

  .smile-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
  }

  .smile-sidebar.open {
    transform: translateX(0);
  }

  .smile-sidebar-backdrop {
    display: block;
  }

  .smile-hamburger {
    display: flex;
  }

  /* Topbar: reduce padding */
  .smile-topbar {
    padding: 0 var(--space-3);
  }

  /* Content: tighter padding */
  .smile-content {
    padding: var(--space-4) var(--space-4) var(--space-6);
  }

  /* Toast: full width on tablet */
  .smile-toast-wrap {
    right: var(--space-3);
    left: var(--space-3);
    max-width: none;
  }

  .smile-toast { min-width: 0; }

  /* Stat trio: stack on tablet */
  .stat-trio { grid-template-columns: repeat(3, 1fr); }

  /* Modal: constrain to viewport on tablet — !important overrides inline max-width */
  .modal { max-width: 95vw !important; }
  .modal-overlay { padding: var(--space-3); }

  /* Tile picker */
  .tile-picker { max-width: 95vw !important; }

  /* Filter bar: stack vertically on tablet */
  .filter-bar { gap: var(--space-2); }
  .filter-bar input[type="text"] { min-width: 120px; }

  /* Data tables: ensure horizontal scroll */
  .data-table-wrap { -webkit-overflow-scrolling: touch; }

  /* Collapse sidebar button — hide on tablet (hamburger replaces it) */
  .sb-collapse-btn { display: none !important; }
}

/* ── MOBILE ≤480px ─────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Content: minimal padding */
  .smile-content {
    padding: var(--space-3) var(--space-3) var(--space-5);
  }

  /* Topbar: compact */
  .smile-topbar {
    padding: 0 var(--space-2);
    height: 44px;
  }

  .topbar-date { font-size: var(--text-sm); }
  .topbar-avatar { width: 26px; height: 26px; font-size: 0.6rem; }

  /* Stat trio: single column */
  .stat-trio { grid-template-columns: 1fr; }

  /* Toast: edge to edge */
  .smile-toast-wrap {
    right: var(--space-2);
    left: var(--space-2);
    bottom: var(--space-3);
  }

  /* Modal: full-width bottom-sheet on mobile — !important overrides inline max-width */
  .modal {
    max-width: 100vw !important;
    width: 100vw;
    max-height: calc(100vh - var(--space-4));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-body { padding: var(--space-4); }
  .modal-header { padding: var(--space-3) var(--space-4); }
  .modal-footer { padding: var(--space-3) var(--space-4); }

  /* Quick tiles: smaller on phone */
  .quick-tiles {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: var(--space-1);
  }
  .q-tile { padding: var(--space-2) var(--space-1); }
  .q-tile-label { font-size: 0.55rem; }

  /* Buttons: full-width on phone for primary actions */
  .btn-primary.btn-block-mobile { width: 100%; justify-content: center; }

  /* Filter bar: full-width inputs on phone */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input[type="text"] { width: 100%; min-width: 0; }
  .filter-group { flex-wrap: wrap; }

}


/* ── 21. SCHOOL HOUSES ──────────────────────────────────── */

/* House badge — compact pill, use with .house-badge.house-{name} */
.house-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  line-height: 1.6;
}
.house-badge svg { width: 14px; height: 14px; flex-shrink: 0; }

.house-badge.house-babthorpe  { background: var(--house-babthorpe-light);  color: var(--house-babthorpe-dark);  border: 1px solid var(--house-babthorpe-border); }
.house-badge.house-bedingfeld { background: var(--house-bedingfeld-light); color: var(--house-bedingfeld-dark); border: 1px solid var(--house-bedingfeld-border); }
.house-badge.house-wigmore    { background: var(--house-wigmore-light);    color: var(--house-wigmore-dark);    border: 1px solid var(--house-wigmore-border); }
.house-badge.house-rookwood   { background: var(--house-rookwood-light);   color: var(--house-rookwood-dark);   border: 1px solid var(--house-rookwood-border); }
.house-badge.house-dawson     { background: var(--house-dawson-light);     color: var(--house-dawson-dark);     border: 1px solid var(--house-dawson-border); }
.house-badge.house-poytnz     { background: var(--house-poytnz-light);    color: var(--house-poytnz-dark);    border: 1px solid var(--house-poytnz-border); }
.house-badge.house-mary-ward  { background: var(--house-mary-ward-light); color: var(--house-mary-ward-dark); border: 1px solid var(--house-mary-ward-border); }

/* House dot — tiny colour indicator, use inline with text */
.house-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  vertical-align: middle;
  flex-shrink: 0;
}
.house-dot.house-babthorpe  { background: var(--house-babthorpe); }
.house-dot.house-bedingfeld { background: var(--house-bedingfeld); }
.house-dot.house-wigmore    { background: var(--house-wigmore); }
.house-dot.house-rookwood   { background: var(--house-rookwood); }
.house-dot.house-dawson     { background: var(--house-dawson); }
.house-dot.house-poytnz     { background: var(--house-poytnz); }
.house-dot.house-mary-ward  { background: var(--house-mary-ward); }

/* House card accent — top border stripe on any card */
.house-accent { border-top: 3px solid transparent; }
.house-accent.house-babthorpe  { border-top-color: var(--house-babthorpe); }
.house-accent.house-bedingfeld { border-top-color: var(--house-bedingfeld); }
.house-accent.house-wigmore    { border-top-color: var(--house-wigmore); }
.house-accent.house-rookwood   { border-top-color: var(--house-rookwood); }
.house-accent.house-dawson     { border-top-color: var(--house-dawson); }
.house-accent.house-poytnz     { border-top-color: var(--house-poytnz); }
.house-accent.house-mary-ward  { border-top-color: var(--house-mary-ward); }

/* House card — full house-themed card with tinted background */
.house-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.house-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.house-card.house-babthorpe  { background: var(--house-babthorpe-light); }
.house-card.house-bedingfeld { background: var(--house-bedingfeld-light); }
.house-card.house-wigmore    { background: var(--house-wigmore-light); }
.house-card.house-rookwood   { background: var(--house-rookwood-light); }
.house-card.house-dawson     { background: var(--house-dawson-light); }
.house-card.house-poytnz     { background: var(--house-poytnz-light); }
.house-card.house-mary-ward  { background: var(--house-mary-ward-light); }

.house-card.house-babthorpe::before  { background: var(--house-babthorpe); }
.house-card.house-bedingfeld::before { background: var(--house-bedingfeld); }
.house-card.house-wigmore::before    { background: var(--house-wigmore); }
.house-card.house-rookwood::before   { background: var(--house-rookwood); }
.house-card.house-dawson::before     { background: var(--house-dawson); }
.house-card.house-poytnz::before     { background: var(--house-poytnz); }
.house-card.house-mary-ward::before  { background: var(--house-mary-ward); }

/* House icon container — circular coloured icon holder */
.house-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.house-icon svg { width: 60%; height: 60%; }
.house-icon-sm { width: 28px; height: 28px; }
.house-icon-md { width: 40px; height: 40px; }
.house-icon-lg { width: 56px; height: 56px; }
.house-icon-xl { width: 72px; height: 72px; }

.house-icon.house-babthorpe  { background: var(--house-babthorpe-pale);  color: var(--house-babthorpe-dark); }
.house-icon.house-bedingfeld { background: var(--house-bedingfeld-pale); color: var(--house-bedingfeld-dark); }
.house-icon.house-wigmore    { background: var(--house-wigmore-pale);    color: var(--house-wigmore-dark); }
.house-icon.house-rookwood   { background: var(--house-rookwood-pale);   color: var(--house-rookwood-dark); }
.house-icon.house-dawson     { background: var(--house-dawson-pale);     color: var(--house-dawson-dark); }
.house-icon.house-poytnz     { background: var(--house-poytnz-pale);    color: var(--house-poytnz-dark); }
.house-icon.house-mary-ward  { background: var(--house-mary-ward-pale); color: var(--house-mary-ward-dark); }

/* House text colour — apply to any text element */
.house-text.house-babthorpe  { color: var(--house-babthorpe-dark); }
.house-text.house-bedingfeld { color: var(--house-bedingfeld-dark); }
.house-text.house-wigmore    { color: var(--house-wigmore-dark); }
.house-text.house-rookwood   { color: var(--house-rookwood-dark); }
.house-text.house-dawson     { color: var(--house-dawson-dark); }
.house-text.house-poytnz     { color: var(--house-poytnz-dark); }
.house-text.house-mary-ward  { color: var(--house-mary-ward-dark); }

/* House grid — seven-column layout for house summaries / leaderboards */
.house-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}
@media (max-width: 768px) {
  .house-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--space-3);
  }
}
@media (max-width: 375px) {
  .house-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
}

/* ── 22. Jiggle Reorder ──────────────────────────────────────── */
/* Generic iOS-style jiggle-to-reorder. Apply .jiggle-reorder to  */
/* a container; children get the animation. Use .jr-item for each */
/* draggable child. Reuses the tile-jiggle keyframe.              */
/*                                                                 */
/* Container: .jiggle-reorder                                      */
/* Items:     .jr-item                                             */
/* States:    .jr-placeholder  (original position during drag)     */
/*            .jr-floater      (clone following pointer)           */
/*            .jr-drop-target  (valid drop highlight)              */

.jiggle-reorder .jr-item {
  animation: tile-jiggle 0.6s ease-in-out infinite;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 1px dashed var(--color-gold);
  box-shadow: 0 0 0 1px rgba(168,153,110,0.15), var(--shadow-sm);
  transition: border-color 0.15s;
}
.jiggle-reorder .jr-item:nth-child(2n)  { animation-delay: 0.08s; }
.jiggle-reorder .jr-item:nth-child(3n)  { animation-delay: 0.18s; animation-duration: 0.7s; }
.jiggle-reorder .jr-item:nth-child(5n)  { animation-delay: 0.12s; animation-duration: 0.65s; }

.jiggle-reorder .jr-item.jr-placeholder {
  opacity: 0.15;
  animation: none;
  transform: scale(0.95);
  border-style: dashed;
}

.jr-floater {
  position: fixed !important;
  z-index: 10000 !important;
  pointer-events: none !important;
  animation: none !important;
  transform: scale(1.05) rotate(1.5deg) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25), 0 0 0 2px var(--color-gold) !important;
  border: 2px solid var(--color-gold) !important;
  opacity: 0.95;
  transition: none !important;
}

.jiggle-reorder .jr-item.jr-drop-target {
  animation: none;
  transform: scale(1.05);
  border: 2px solid var(--color-gold);
  box-shadow: 0 0 12px rgba(168,153,110,0.3);
  transition: transform 0.2s cubic-bezier(0.2,0,0,1), box-shadow 0.2s ease;
}

/* ── 23. Main menu customise ─────────────────────────────────── */

.sb-pin-indicator {
  margin-left: auto;
  font-size: 10px;
  color: var(--color-gold);
  opacity: 0.7;
}

.sb-menu-customise-bar {
  padding: var(--space-1) var(--space-3) var(--space-2);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

.sb-menu-customise-btn {
  background: none;
  border: none;
  color: var(--sidebar-text, #CBD3EB);
  font-size: var(--text-xs, 11px);
  padding: 0;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.sb-menu-customise-btn:hover {
  opacity: 1;
}

.sb-customise-done {
  color: var(--color-gold);
  font-weight: 600;
  opacity: 0.9;
}
.sb-customise-done:hover { opacity: 1; }

.sb-customise-cancel {
  opacity: 0.4;
}
.sb-customise-cancel:hover { opacity: 0.7; }

.sb-customise-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: grab;
  user-select: none;
}

.sb-customise-label { flex: 1; min-width: 0; }

.sb-pin-toggle {
  margin-left: auto;
  cursor: pointer;
  font-size: 14px;
  color: rgba(255,255,255,0.3);
  transition: color 0.15s;
  padding: 0 4px;
}
.sb-pin-toggle:hover { color: var(--color-gold); }
.sb-pin-toggle.pinned { color: var(--color-gold); }

.sb-customise-group-header {
  display: flex;
  align-items: center;
  padding: 6px var(--space-3);
  margin-top: var(--space-2);
}

.sb-customise-group-header .sb-group-label-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-gold);
  flex: 1;
}

.sb-group-delete {
  cursor: pointer;
  font-size: 16px;
  color: rgba(255,255,255,0.3);
  padding: 0 4px;
  transition: color 0.15s;
}
.sb-group-delete:hover { color: #e74c3c; }

.sb-drop-indicator {
  height: 2px;
  background: var(--color-gold);
  border-radius: 1px;
  margin: 2px var(--space-3);
  transition: opacity 0.15s;
}

/* ── 24. TOOLTIPS ──────────────────────────────────────────────── */
/* JS-driven tooltips via data-tip attribute.                       */
/* Usage: <button data-tip="Help text">...</button>                 */
/* Position: data-tip-pos="bottom|left|right" (default: top)        */
/* 300ms hover delay — industry standard.                           */
/* Tooltip element is appended to <body> by smile-shell.js to       */
/* escape overflow:hidden containers (sidebar, tiles, tables).      */

/* CSS nesting adopted from session 44 — nest related selectors under parent */
.smile-tooltip {
  position: fixed;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-family: var(--font-ui);
  font-size: var(--tooltip-font);
  font-weight: 400;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: var(--tooltip-radius);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--tooltip-shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 10000;
  letter-spacing: 0;
  text-transform: none;

  &.visible { opacity: 1; }

  &.wrap {
    white-space: normal;
    text-align: left;
    width: max-content;
    max-width: 280px;
  }
}


/* ── 26. PROGRESS BARS ─────────────────────────────────────────── */
/* Track + fill pattern for horizontal bars.                        */
/* Sizes: default 8px, .progress-sm 4px, .progress-lg 12px.        */
/* Usage:                                                           */
/*   <div class="progress-row">                                     */
/*     <span class="progress-label">Label</span>                    */
/*     <div class="progress">                                       */
/*       <div class="progress-fill" style="width:65%"></div>        */
/*     </div>                                                       */
/*     <span class="progress-value">65%</span>                      */
/*   </div>                                                         */

.progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.progress-label {
  width: 130px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-body);
  font-size: var(--text-xs);
}

.progress-value {
  width: 60px;
  flex-shrink: 0;
  text-align: right;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress {
  flex: 1;
  height: 8px;
  background: var(--bg-card-tint);
  border-radius: var(--radius-sm);
  overflow: hidden;

  & .progress-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    background: var(--color-navy);
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  &.progress-sm { height: 4px; }
  &.progress-sm .progress-fill { border-radius: 2px; }
  &.progress-lg { height: 12px; }
}


/* ── 27. TABS ──────────────────────────────────────────────────── */
/* Shared tab component with three visual variants.                 */
/* Usage:                                                           */
/*   <div class="tabs tabs-underline">                              */
/*     <button class="tab active">Tab 1</button>                    */
/*     <button class="tab">Tab 2 <span class="tab-count">3</span></button> */
/*   </div>                                                         */

/* Base */
.tabs {
  display: flex;
  gap: var(--space-1);
  font-size: var(--text-sm);
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-ui);
  font-size: inherit;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text-body); }

.tab-count {
  display: inline-block;
  background: var(--bg-card-tint);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: 10px;
  margin-left: var(--space-1);
}

.tab.active .tab-count {
  background: var(--color-navy);
  color: var(--color-white);
}

/* Variant: Underline */
.tabs-underline {
  gap: 0;
  border-bottom: 1px solid var(--border-default);
}

.tabs-underline .tab {
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: var(--space-2) var(--space-4);
}

.tabs-underline .tab:hover { color: var(--text-heading); }
.tabs-underline .tab.active {
  color: var(--text-heading);
  border-bottom-color: var(--color-gold);
}

/* Variant: Pill */
.tabs-pill { gap: var(--space-2); }

.tabs-pill .tab {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
}

.tabs-pill .tab:hover { background: var(--bg-card-tint); }
.tabs-pill .tab.active {
  background: var(--color-navy);
  color: var(--color-white);
  border-color: var(--color-navy);
}

/* Variant: Segmented */
.tabs-segmented {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tabs-segmented .tab {
  border-right: 1px solid var(--border-card);
  border-radius: 0;
  padding: var(--space-1) var(--space-3);
}

.tabs-segmented .tab:last-child { border-right: none; }
.tabs-segmented .tab:hover { background: var(--bg-card-tint); }
.tabs-segmented .tab.active {
  background: var(--color-navy);
  color: var(--color-white);
}


/* ── 28. PAGINATION ────────────────────────────────────────────── */
/* Centred button row for paged data. Uses existing .btn-xs.        */
/* Usage:                                                           */
/*   <div class="pagination">                                       */
/*     <button class="btn btn-xs btn-ghost">&laquo;</button>        */
/*     <button class="btn btn-xs btn-primary">1</button>            */
/*     <button class="btn btn-xs btn-ghost">2</button>              */
/*     <span class="pagination-info">Page 1 of 5</span>            */
/*   </div>                                                         */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);

  & .pagination-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0 var(--space-2);
  }
}

/* Responsive: §26-28 */
@media (max-width: 768px) {
  .tabs { overflow-x: auto; }
  .progress-label { width: 100px; }
}
@media (max-width: 375px) {
  .progress-label { width: 80px; }
  .progress-row { gap: var(--space-1); }
  .tabs-underline .tab { padding: var(--space-2) var(--space-3); }
}


/* ── 29. HELPERS & UTILITIES ────────────────────────────────────── */
/* Small reusable patterns that prevent inline style repetition.     */

/* Section header — flex row with space-between, wrap, standard gap */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

/* Badge extra-small — for inline count pills in tables */
.badge-xs { font-size: 9px; padding: 1px 5px; }

/* Loading centre — padded spinner container */
.loading-center { padding: var(--space-5); text-align: center; }

/* Error message — padded danger text */
.error-message { padding: var(--space-4); color: var(--color-danger); }

/* Metadata text — small faint secondary info */
.metadata { font-size: var(--text-xs); color: var(--text-faint); }

/* Monospace muted — usernames, IDs, codes */
.mono-muted { font-family: var(--font-ui); font-variant-numeric: tabular-nums; font-size: var(--text-xs); color: var(--text-muted); }

/* Modal width modifiers */
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 680px; }
.modal-xl { max-width: 800px; }


/* ── 25. Honour board creatures ────────────────────────────────── */
/* Pure CSS — mouse silhouette via ::after on .smile-content.       */
/* No JS, no DOM manipulation, completely static.                   */
/* Creature is now placed via JS in smile-shell.js — sits on top edge of a card/box */
