/**
 * Sophia STARS — home.html page styles (roadmap Phase 1 migration)
 *
 * Consolidates FOUR previous sources into one: home.html's own inline
 * <style> block (~1740 lines — genuinely well-designed, not legacy bloat:
 * documented contrast ratios, a deliberate section-hierarchy system, CLS
 * guards, full dark-mode coverage) plus three external page-specific
 * files it was still loading (home-specific.css, home-dashboard-2026.css,
 * enhanced-analytics-dashboard.css). Those three had accumulated into
 * three literal cascade layers fighting each other with !important —
 * enhanced-analytics-dashboard.css's base .metric-card/.chart-card rules,
 * a "polish" pass in home-specific.css forcing new radii/shadows over
 * them with !important, then a second "responsive tightening" pass in
 * the same file forcing yet more values with !important on top of that.
 * This file keeps only the FINAL value each property ended up at after
 * all three layers — no !important needed anywhere, since this is now
 * the only stylesheet touching these selectors.
 *
 * One real bug fixed while consolidating: home-specific.css's own reduced-
 * motion block set `.action-card { opacity: 1 !important; transform: none
 * !important; }` specifically to patch over the fact that .action-card's
 * entrance animation used opacity:0 as its base/rest state — so disabling
 * the animation for reduced-motion left cards permanently invisible.
 * Fixed properly here instead of re-patching: base state is the visible
 * end state, animation is opt-in behind prefers-reduced-motion: no-preference.
 */

/* ── Page-local tokens ──────────────────────────────────────────────── */
:root {
  --sophia-primary: #003057;
  --sophia-secondary: #0078d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(255, 255, 255, 0.2);
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-attachment: fixed;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: var(--z-behind);
}
@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
}

.main-content,
body.sidebar-layout .main-content {
  margin-left: 220px;
  margin-top: var(--header-height, 64px);
  padding: 0;
  min-height: calc(100vh - var(--header-height, 64px));
  position: relative;
  z-index: var(--z-raised);
  animation: contentFadeIn 0.38s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .main-content { animation: none; }
}

.dashboard-wrapper {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0.75rem 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.dashboard-wrapper > * { margin-bottom: 0; }

/* Visual reorder without touching HTML source order. */
.hero-section { order: 1; }
.priority-strip { order: 2; }
.quick-actions-section { order: 3; }
#reflectionAlertsSection { order: 4; }
.role-alerts-section { order: 5; }
.dashboard-grid { order: 6; }
.analytics-dashboard { order: 7; }
.ai-insights-section { order: 8; }

/* ── House leaderboard bar ──────────────────────────────────────────── */
.house-leaderboard-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem clamp(1rem, 2.5vw, 2.5rem);
  margin: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-md);
}
.house-leaderboard-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  flex: 0 0 auto;
  white-space: nowrap;
}
.house-leaderboard-label .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
  animation: lb-pulse 2s ease-in-out infinite;
}
@keyframes lb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.house-leaderboard-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.house-leaderboard-chips::-webkit-scrollbar { display: none; }
.hdr-house-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.hdr-house-chip:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.22); }
.hdr-house-chip:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }
.hdr-house-chip .hdr-house-icon { font-size: 0.95rem; line-height: 1; }
.hdr-house-chip .hdr-house-name { font-weight: 500; opacity: 0.75; letter-spacing: 0.01em; }
.hdr-house-chip .hdr-house-pts {
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  margin-left: 0.05rem;
}
.hdr-house-chip[data-house="solis"] .hdr-house-pts { color: #fcd34d; }
.hdr-house-chip[data-house="aqua"] .hdr-house-pts { color: #7dd3fc; }
.hdr-house-chip[data-house="luna"] .hdr-house-pts { color: #c4b5fd; }
.hdr-house-chip[data-house="ignis"] .hdr-house-pts { color: #fca5a5; }
.hdr-house-chip.hdr-leader {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
  transform: translateY(-1px);
}
.hdr-house-chip.hdr-leader::before {
  content: "👑";
  font-size: 0.8rem;
  margin-right: -0.1rem;
}
@media (max-width: 640px) {
  .house-leaderboard-label span:not(.live-dot) { display: none; }
  .hdr-house-chip .hdr-house-name { display: none; }
  .hdr-house-chip { padding: 0.4rem 0.65rem; }
}

/* toast-manager.js's own injected #unified-toast-container style
   positions toasts at header-height + 1rem, which is correct on every
   other page but sits under this page's extra house-leaderboard-bar
   strip, so a toast like the "press ? for shortcuts" hint overlaps it.
   That injected <style> tag loads after this stylesheet (deferred
   script), so a plain #unified-toast-container override here would lose
   the cascade tie on load order alone — this compound selector is more
   specific than the plain ID selector, so it wins regardless of order. */
body.sidebar-layout #unified-toast-container {
  top: calc(var(--header-height, 64px) + 156px + 0.75rem);
}

/* ── Hero (date + search) ───────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(135deg, var(--navy-900, #082f5a) 0%, #0d2748 100%);
  border-radius: 20px;
  padding: 1.75rem 2.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 20px -4px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 130px;
}
.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 90% -10%, rgba(168, 118, 26, 0.18) 0%, transparent 55%),
    radial-gradient(circle at 10% 90%, rgba(51, 78, 104, 0.12) 0%, transparent 45%);
  pointer-events: none;
}
.hero-content {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  position: relative;
  z-index: var(--z-raised);
}
.hero-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
.hero-section:hover .hero-logo { transform: scale(1.05) rotate(-2deg); }
.hero-text h1 {
  font-size: 1.95rem;
  font-weight: 800;
  color: white;
  margin: 0 0 0.3rem 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
  min-height: 1.3em;
}
#heroStaffName {
  display: inline-block;
  min-width: 8ch;
  color: var(--gold-300, #efc55c);
}
.hero-text p {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
  line-height: 1.4;
  max-width: 34ch;
}
.hero-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.7rem;
  background: rgba(168, 118, 26, 0.15);
  border: 1px solid rgba(168, 118, 26, 0.3);
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gold-200, #f5db94);
}
.hero-date-badge svg { width: 14px; height: 14px; display: block; flex-shrink: 0; }

.hero-search { margin-left: auto; flex: 0 0 360px; }
.search-wrapper { position: relative; }
.search-wrapper .search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(59, 130, 246, 0.7);
  pointer-events: none;
}
.search-wrapper .search-icon svg { width: 18px; height: 18px; display: block; }
.search-wrapper input {
  width: 100%;
  padding: 0.75rem 1.25rem 0.75rem 3.25rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  font-size: 0.95rem;
  color: #0f172a;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(10px);
}
.search-wrapper input::placeholder { color: #64748b; }
.search-wrapper input:focus {
  background: white;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-height: 350px;
  overflow-y: auto;
  z-index: var(--z-dropdown, 9999);
  display: none;
}
.search-results-dropdown.active { display: block; animation: slideDown 0.2s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .search-results-dropdown.active { animation: none; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #e2e8f0;
  transition: background 0.2s ease, transform 0.2s ease;
}
.search-result-item:hover { background: #f1f5f9; transform: translateX(2px); }
.search-result-item:focus-visible {
  background: #f1f5f9;
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}
.search-result-item:active { background: #e2e8f0; }
.search-result-name { font-weight: 600; color: #0f172a; }
.search-result-meta { font-size: 0.85rem; color: #64748b; }
.search-no-results { padding: 16px; text-align: center; color: #64748b; font-style: italic; }

/* Compact hero variant (current markup: date + search only). */
.hero-section--compact {
  padding: 0.65rem 2rem;
  min-height: 0;
  margin-bottom: 1rem;
}
.hero-section--compact .hero-content { justify-content: flex-start; gap: 1rem; align-items: center; }
.hero-section--compact .hero-date-badge { margin-top: 0; flex-shrink: 0; }
.hero-section--compact .hero-search { flex: 1; max-width: 600px; margin-left: 0; }
.hero-section--compact .search-wrapper input { padding: 0.6rem 1.1rem 0.6rem 3rem; }
@media (max-width: 640px) {
  .hero-section--compact { padding: 0.55rem 0.9rem; margin-bottom: 0.75rem; }
  .hero-section--compact .hero-date-badge { display: none; }
  .hero-section--compact .hero-search { max-width: 100%; }
}

/* ── Section header / title hierarchy ──────────────────────────────── */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: 1.08rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.01em;
  line-height: 1.2;
  padding-bottom: 0.45rem;
}
.section-title .icon svg { width: 1.2rem; height: 1.2rem; display: block; }
.section-subtitle { font-size: 0.84rem; color: #475569; margin: 0; max-width: 64ch; letter-spacing: 0.01em; }

/* Quick Actions is the one thing most staff come here to do; reference/
   browsing sections recede so they don't visually outrank it. */
.section-title--primary { font-size: 1.3rem; font-weight: 800; }
.section-title--reference { font-size: 0.95rem; font-weight: 600; color: #64748b; }

/* ── Priority strip ─────────────────────────────────────────────────── */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.priority-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-left: 3px solid var(--chip-color);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  min-height: 62px;
}
.priority-chip .chip-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chip-color);
}
.priority-chip .chip-icon svg { width: 20px; height: 20px; display: block; }
.priority-chip .chip-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.priority-chip .chip-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0.1rem 0 0;
  line-height: 1.1;
  min-width: 2ch;
  min-height: 1.5em;
  display: block;
}
.priority-chip .chip-value.stat-error {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--warning-700, #b45309);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: help;
}
.priority-chip.critical { --chip-color: #ef4444; }
.priority-chip.warning { --chip-color: #f59e0b; }
.priority-chip.info { --chip-color: #3b82f6; }
.priority-chip.timeout { --chip-color: #7c3aed; }

/* ── Quick actions ──────────────────────────────────────────────────── */
.quick-actions-section {
  margin-bottom: 0;
  background: linear-gradient(180deg, rgba(168, 118, 26, 0.04) 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-top: 4px solid var(--gold-600, #a8761a);
  border-radius: 18px;
  padding: 1.25rem 1.1rem 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}
.quick-actions-header { margin-bottom: 0.9rem; }
.quick-actions-meta { display: flex; flex-direction: column; gap: 0.2rem; }
.quick-actions-grid { display: grid; gap: 0.85rem; }
.quick-action-group { display: grid; gap: 0.5rem; }
.quick-action-group-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  margin: 0;
  padding-left: 0.2rem;
}
.quick-action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.action-card {
  background: var(--glass-bg);
  border-radius: 10px;
  min-height: 124px;
  min-width: 0;
  padding: 1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.4rem;
  touch-action: manipulation;
}
.action-card:hover,
.action-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--card-accent) 16%, rgba(15, 23, 42, 0.08));
  background: color-mix(in srgb, var(--card-accent) 8%, var(--glass-bg));
  border-color: color-mix(in srgb, var(--card-accent) 35%, transparent);
}
.action-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 3px;
}
.action-card .action-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  background: color-mix(in srgb, var(--card-accent) 15%, transparent);
  color: var(--card-accent);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.action-card .action-icon svg { width: 20px; height: 20px; display: block; }
.action-card:hover .action-icon,
.action-card:focus-visible .action-icon {
  transform: translateY(-1px) scale(1.1);
  background: var(--card-accent);
  color: white;
}
.action-card h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin: 0; line-height: 1.2; }
.action-card p { display: none; }
.card-live-stat {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--card-accent);
  background: color-mix(in srgb, var(--card-accent) 10%, transparent);
  border-radius: 8px;
  padding: 0.1rem 0.45rem;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-live-stat:empty { display: none; }

.action-card.infringement { --card-accent: #ef4444; }
.action-card.outofclass { --card-accent: #f59e0b; }
.action-card.recognition { --card-accent: #10b981; }
.action-card.reengagement { --card-accent: #8b5cf6; }
.action-card.timeout { --card-accent: #7c3aed; }
.action-card.profiles { --card-accent: #0ea5e9; }
.action-card.admin { --card-accent: #6366f1; }

@media (pointer: coarse) {
  .action-card { min-height: 128px; padding: 1.05rem; }
  .filter-btn,
  .stats-toggle-btn,
  .close-stats-btn,
  .role-alert-ack-btn,
  .house-modal-close {
    min-height: 44px;
    touch-action: manipulation;
  }
}

/* ── Dashboard grid (Activity feed — single column since House
   Competition moved to the top leaderboard bar) ──────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: clamp(260px, 28%, 340px) 1fr; gap: 1.5rem; align-items: start; }
.dashboard-grid.single-column { grid-template-columns: 1fr; }
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Activity feed ──────────────────────────────────────────────────── */
.activity-section {
  background: var(--glass-bg);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.activity-filters { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-btn {
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  min-height: 34px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.filter-btn svg { width: 13px; height: 13px; vertical-align: -2px; flex-shrink: 0; }
.filter-btn:hover { background: rgba(59, 130, 246, 0.1); border-color: var(--accent-blue); color: var(--accent-blue); }
.filter-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: white; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.filter-btn:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.24); outline-offset: 3px; }

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 48, 87, 0.2) transparent;
}
.activity-list::-webkit-scrollbar { width: 4px; }
.activity-list::-webkit-scrollbar-track { background: transparent; }
.activity-list::-webkit-scrollbar-thumb { background: rgba(0, 48, 87, 0.2); border-radius: 4px; }
.activity-list::-webkit-scrollbar-thumb:hover { background: rgba(0, 48, 87, 0.4); }
@media (max-width: 1024px) {
  .activity-list { max-height: none; }
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  min-width: 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  border-left: 3px solid var(--activity-color, #e2e8f0);
  transition: background 0.16s ease, box-shadow 0.16s ease;
}
.activity-item:hover {
  background: rgba(59, 130, 246, 0.05);
  border-left-width: 4px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--activity-color, #3b82f6) 12%, transparent);
}
.activity-item.affirmation { --activity-color: #10b981; }
.activity-item.infringement { --activity-color: #ef4444; }
.activity-item.outofclass { --activity-color: #f59e0b; }
.activity-item.referral { --activity-color: #8b5cf6; }
.activity-item.placeholder { justify-content: center; opacity: 0.7; }
.activity-item.placeholder .activity-content { text-align: center; }

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--activity-color) 15%, transparent);
  flex-shrink: 0;
}
.activity-icon svg { width: 22px; height: 22px; display: block; }
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; overflow-wrap: anywhere; }
.activity-meta { font-size: 0.8rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.activity-time { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; border-radius: 8px; flex-shrink: 0; }

/* ── AI insights ────────────────────────────────────────────────────── */
.ai-insights-section { margin-bottom: 1.5rem; content-visibility: auto; contain-intrinsic-size: 700px; }
.ai-insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.875rem; }
.ai-insight-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 58, 138, 0.95) 100%);
  border-radius: 12px;
  padding: 1rem;
  color: white;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ai-insight-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.15) 0%, transparent 60%);
  pointer-events: none;
}
.ai-insight-card:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }
.ai-insight-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; position: relative; z-index: var(--z-raised); }
.ai-insight-icon { font-size: 1.25rem; opacity: 0.9; }
.ai-insight-icon svg { width: 1.25rem; height: 1.25rem; display: block; }
.ai-insight-title { font-size: 0.8125rem; font-weight: 600; margin: 0; color: white; opacity: 0.95; }
.ai-insight-text { font-size: 0.8125rem; line-height: 1.4; color: rgba(255, 255, 255, 0.85); margin: 0; position: relative; z-index: var(--z-raised); }
.ai-insight-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(59, 130, 246, 0.15);
  backdrop-filter: blur(8px);
  padding: 0.1875rem 0.5rem;
  border-radius: 12px;
  font-size: 0.625rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.ai-loading-skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.1) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  height: 1.25rem;
  margin-bottom: 0.5rem;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Personalised role alerts ───────────────────────────────────────── */
.role-alerts-section { margin-bottom: 2.5rem; }
.role-alerts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.role-badge.solis { background: rgba(245, 158, 11, 0.12); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3); }
.role-badge.aqua { background: rgba(59, 130, 246, 0.12); color: #2563eb; border: 1px solid rgba(59, 130, 246, 0.3); }
.role-badge.luna { background: rgba(148, 163, 184, 0.15); color: #64748b; border: 1px solid rgba(148, 163, 184, 0.35); }
.role-badge.ignis { background: rgba(249, 115, 22, 0.12); color: #ea580c; border: 1px solid rgba(249, 115, 22, 0.3); }
.role-badge.life79 { background: rgba(16, 185, 129, 0.12); color: #059669; border: 1px solid rgba(16, 185, 129, 0.3); }
.role-badge.life1012 { background: rgba(139, 92, 246, 0.12); color: #7c3aed; border: 1px solid rgba(139, 92, 246, 0.3); }
.role-badge.fratelli { background: rgba(14, 116, 144, 0.12); color: #0e7490; border: 1px solid rgba(14, 116, 144, 0.3); }
.role-badge.ap-engagement { background: rgba(239, 68, 68, 0.12); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.3); }
.role-badge.leadership { background: rgba(99, 102, 241, 0.12); color: #4338ca; border: 1px solid rgba(99, 102, 241, 0.3); }

.role-alert-card {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-left: 4px solid var(--alert-accent, #6b7280);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.role-alert-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); }
.role-alert-card:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.24); outline-offset: 3px; }
.role-alert-card.priority-high { --alert-accent: #ef4444; }
.role-alert-card.priority-medium { --alert-accent: #f59e0b; }
.role-alert-card.priority-low { --alert-accent: #10b981; }
.role-alert-card.house-solis { --alert-accent: #f59e0b; }
.role-alert-card.house-aqua { --alert-accent: #3b82f6; }
.role-alert-card.house-luna { --alert-accent: #94a3b8; }
.role-alert-card.house-ignis { --alert-accent: #f97316; }
.role-alert-card.house-life79 { --alert-accent: #10b981; }
.role-alert-card.house-life1012 { --alert-accent: #8b5cf6; }
.role-alert-card.house-fratelli { --alert-accent: #0ea5a4; }
.role-alert-actions { margin-top: 0.35rem; }
.role-alert-ack-btn {
  border: 1px solid var(--border-color, #e5e7eb);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-muted, #64748b);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  cursor: pointer;
}
.role-alert-ack-btn.acked { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.4); color: #047857; }
.role-alert-icon { font-size: 1.4rem; line-height: 1; }
.role-alert-count { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--alert-accent, #6b7280); }
.role-alert-count.zero { color: #10b981; }
.role-alert-label { font-size: 0.83rem; font-weight: 600; color: var(--text-primary, #1e293b); }
.role-alert-sub { font-size: 0.71rem; color: var(--text-muted, #6b7280); }
.role-alert-pulse {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: alertPulse 1.6s ease-in-out infinite;
}
@keyframes alertPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.65); }
}
@media (max-width: 768px) { .role-alerts-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .role-alerts-grid { grid-template-columns: 1fr; } }

.fratelli-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: var(--z-modal, 9000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.fratelli-modal {
  width: min(900px, 95vw);
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border-color, #e5e7eb);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
  padding: 1rem 1.1rem;
}
.frequent-flyers-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.frequent-flyers-table th {
  text-align: left;
  padding: 0.45rem 0.7rem;
  font-weight: 700;
  color: var(--text-muted, #6b7280);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.frequent-flyers-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border-color, #e5e7eb); vertical-align: middle; }
.frequent-flyers-table tr:last-child td { border-bottom: none; }
.ff-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.73rem;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}
.ff-bar { height: 6px; border-radius: 3px; background: var(--border-color, #e5e7eb); overflow: hidden; min-width: 50px; }
.ff-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(to right, #f59e0b, #ef4444); transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }

/* ── Teacher reflection alerts ──────────────────────────────────────── */
.reflection-alerts-section { margin-bottom: 2.5rem; }
.reflection-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(102, 0, 0, 0.1);
  color: #660000;
  border: 1px solid rgba(102, 0, 0, 0.25);
}
.reflection-count-badge--clear { background: rgba(22, 163, 74, 0.1); color: #15803d; border-color: rgba(22, 163, 74, 0.3); }
.reflection-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.reflection-empty-state { grid-column: 1 / -1; text-align: center; padding: 2rem 1rem; color: var(--text-secondary, #64748b); }
.reflection-empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.reflection-empty-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; color: var(--text-primary, #334155); }
.reflection-empty-sub { font-size: 0.85rem; }
.reflection-card {
  background: var(--card-bg, #fff);
  border-radius: 14px;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-left: 4px solid #660000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.reflection-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); }
.reflection-card:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.24); outline-offset: 3px; }
.reflection-card-student { font-size: 0.95rem; font-weight: 700; color: var(--text-primary, #1e293b); }
.reflection-card-date { font-size: 0.73rem; color: var(--text-muted, #6b7280); }
.reflection-card-reason { font-size: 0.78rem; color: var(--text-secondary, #475569); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reflection-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(102, 0, 0, 0.08);
  color: #660000;
  border: 1px solid rgba(102, 0, 0, 0.2);
  margin-top: 0.2rem;
  width: fit-content;
}
.reflection-card-badge.viewed { background: rgba(16, 185, 129, 0.08); color: #047857; border-color: rgba(16, 185, 129, 0.3); }

/* Reflection viewer modal */
.rr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: var(--z-modal, 9100);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.rr-modal-panel {
  width: min(700px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color, #e5e7eb);
  overflow: hidden;
}
.rr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: linear-gradient(135deg, #660000 0%, #8b0000 100%);
  color: #fff;
}
.rr-modal-title { font-size: 1.1rem; font-weight: 700; margin: 0; color: #fff; }
.rr-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.rr-modal-close:hover { background: rgba(255, 255, 255, 0.35); }
.rr-modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; }
.rr-detail-section { background: var(--bg-soft, #f8fafc); border-radius: 10px; padding: 1rem 1.2rem; border: 1px solid var(--border-color, #e5e7eb); }
.rr-detail-section h3 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted, #6b7280); margin: 0 0 0.65rem 0; }
.rr-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.8rem; }
.rr-detail-item label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted, #6b7280); display: block; margin-bottom: 0.15rem; }
.rr-detail-item span { font-size: 0.85rem; font-weight: 500; color: var(--text-primary, #1e293b); }
.rr-incident-text { font-size: 0.87rem; color: var(--text-primary, #1e293b); line-height: 1.55; }
.rr-reflection-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  background: #660000;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  text-decoration: none;
}
.rr-reflection-download-btn:hover { background: #8b0000; transform: translateY(-1px); }
.rr-follow-up-note { background: #fff; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.5rem; }
.rr-follow-up-note .note-meta { font-size: 0.7rem; color: var(--text-muted, #6b7280); margin-bottom: 0.25rem; }
.rr-follow-up-note .note-text { font-size: 0.84rem; color: var(--text-primary, #1e293b); line-height: 1.5; }
.rr-action-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.rr-btn { padding: 0.55rem 1.1rem; border-radius: 8px; font-size: 0.84rem; font-weight: 600; border: 1px solid transparent; cursor: pointer; transition: all 0.15s; }
.rr-btn-primary { background: #660000; color: #fff; border-color: #660000; }
.rr-btn-primary:hover { background: #8b0000; }
.rr-btn-secondary { background: transparent; color: var(--text-primary, #1e293b); border-color: var(--border-color, #e5e7eb); }
.rr-btn-secondary:hover { background: var(--bg-soft, #f8fafc); }
.rr-btn-success { background: #059669; color: #fff; border-color: #059669; }
.rr-btn-success:hover { background: #047857; }
.rr-btn-success.confirmed { background: rgba(16, 185, 129, 0.12); color: #047857; border-color: rgba(16, 185, 129, 0.4); cursor: default; }
.rr-note-textarea {
  width: 100%;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.84rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
  color: var(--text-primary, #1e293b);
}
.rr-note-textarea:focus { outline: none; border-color: #660000; box-shadow: 0 0 0 3px rgba(102, 0, 0, 0.1); }
@media (max-width: 600px) {
  .rr-detail-grid { grid-template-columns: 1fr; }
  .reflection-cards-grid { grid-template-columns: 1fr; }
}

/* ── Analytics dashboard ────────────────────────────────────────────── */
.analytics-dashboard {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 100%;
}
.analytics-dashboard .section-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 2px solid rgba(0, 0, 0, 0.05); }
.analytics-period { display: flex; align-items: center; gap: 0.5rem; }
.period-selector {
  padding: 0.5rem 1rem;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  min-height: 34px;
  background: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.period-selector:hover { border-color: #3b82f6; background: rgba(59, 130, 246, 0.05); }
.period-selector:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.24); outline-offset: 3px; }

.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.875rem; margin-bottom: 2rem; }
.metric-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6));
  border-radius: 10px;
  min-height: 122px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1.5px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
}
.metric-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.metric-card.positive::after { background: linear-gradient(90deg, #059669, #10b981); }
.metric-card.negative::after { background: linear-gradient(90deg, #dc2626, #ef4444); }
.metric-card.neutral::after { background: linear-gradient(90deg, #d97706, #f59e0b); }
.metric-card.info::after { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.metric-card:hover { transform: translateY(-5px); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12); }
.metric-icon { font-size: 2rem; line-height: 1; opacity: 0.9; }
.metric-icon svg { width: 32px; height: 32px; display: block; }
.metric-content { flex: 1; }
.metric-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #6b7280; margin-bottom: 0.25rem; }
.metric-value { font-size: 2.25rem; font-weight: 800; color: #111827; line-height: 1; margin-bottom: 0.25rem; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.metric-change { font-size: 0.75rem; font-weight: 500; }

.enhanced-charts-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.5rem; }
.chart-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 10px;
  padding: 1.15rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}
.chart-card:hover { box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08); border-color: rgba(0, 0, 0, 0.1); }
.chart-card.large { grid-column: span 6; }
.chart-card.medium { grid-column: span 6; }
.chart-card.full-width { grid-column: span 12; }
.chart-card canvas { min-height: 210px; }
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.chart-header h3 { font-size: 0.95rem; font-weight: 700; color: #111827; margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.chart-subtitle { font-size: 0.75rem; color: #6b7280; font-weight: 500; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; row-gap: 0.4rem; }
.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; font-weight: 500; color: #4b5563; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot.positive { background: #10b981; }
.legend-dot.negative { background: #ef4444; }
.legend-dot.neutral { background: #f59e0b; }
.chart-container { position: relative; width: 100%; }
.chart-container.large { height: 280px; }
.chart-container.medium { height: 240px; }
.chart-container.comparison { height: 300px; }
.chart-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: #9ca3af; font-size: 0.875rem; }
.chart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #9ca3af; font-size: 0.875rem; text-align: center; padding: 2rem; }
.chart-empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

@media (max-width: 1400px) {
  .chart-card.large, .chart-card.medium { grid-column: span 12; }
}
@media (max-width: 768px) {
  .analytics-dashboard { padding: 1rem; }
  .analytics-dashboard .section-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .metrics-row { grid-template-columns: 1fr; }
  .metric-card { padding: 1rem; }
  .metric-value { font-size: 1.5rem; }
  .enhanced-charts-grid { grid-template-columns: 1fr; gap: 1rem; }
  .chart-card.large, .chart-card.medium, .chart-card.full-width { grid-column: span 1; }
  .chart-container.large, .chart-container.medium { height: 220px; }
  .chart-container.comparison { height: 250px; }
  .chart-header { flex-direction: column; }
  .chart-legend { width: 100%; }
}

/* ── Stats slide-out panel ──────────────────────────────────────────── */
.stats-panel {
  position: fixed;
  top: 64px;
  right: 0;
  width: 320px;
  height: calc(100vh - 64px);
  background: linear-gradient(180deg, rgba(0, 35, 65, 0.98) 0%, rgba(0, 48, 87, 0.98) 100%);
  backdrop-filter: blur(20px);
  z-index: var(--z-drawer, 1000);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}
.stats-panel.open { transform: translateX(0); }
.stats-panel-header { padding: 1.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: space-between; }
.stats-panel-header h3 { color: white; font-size: 1.1rem; margin: 0; }
.close-stats-btn { background: rgba(255, 255, 255, 0.1); border: none; color: white; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1.2rem; transition: var(--transition); }
.close-stats-btn:hover { background: rgba(255, 255, 255, 0.2); }
.stats-panel-content { padding: 1.5rem; }
.stat-item { background: rgba(255, 255, 255, 0.08); border-radius: 16px; padding: 1.25rem; margin-bottom: 1rem; border: 1px solid rgba(255, 255, 255, 0.1); transition: var(--transition); }
.stat-item:hover { background: rgba(255, 255, 255, 0.12); transform: translateX(-4px); }
.stat-item-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.stat-item-icon { font-size: 1.5rem; }
.stat-item-icon svg { width: 24px; height: 24px; display: block; }
.stat-item-title { font-size: 0.75rem; color: rgba(255, 255, 255, 0.7); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-item-value { font-size: 2.5rem; font-weight: 800; color: white; line-height: 1; }
.stat-item-label { font-size: 0.85rem; color: rgba(255, 255, 255, 0.6); margin-top: 0.25rem; }

#statsToggle.stats-toggle-btn {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background: var(--navy-800, #104780);
  color: white;
  border: none;
  padding: 1rem 0.75rem;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
  z-index: var(--z-sticky, 1001);
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
  min-width: 0;
  max-width: 48px;
  display: block;
  box-sizing: content-box;
}
.stats-toggle-btn:hover { padding-right: 1rem; background: var(--navy-900, #082f5a); }
.stats-toggle-btn.hidden { display: none; }

/* ── Loading skeletons ──────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%); background-size: 200% 100%; animation: skeletonShimmer 1.5s infinite; border-radius: 8px; }
@keyframes skeletonShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 1rem; width: 80%; }
.skeleton-value { height: 2.5rem; width: 60%; }

/* Footer itself (position, background, borders, dark-mode) is owned by
   chrome.css's shared .enhanced-app-footer-2026 rule — this page used to
   duplicate it with margin-left: 0, which fought chrome.css's
   margin-left: var(--sidebar-width) and left the footer starting under
   the fixed sidebar instead of beside it, throwing off its centered
   max-width: 1200px content and making it look like it didn't reach the
   right edge. No other migrated page overrides this selector; don't
   reintroduce the override here either. */
body, html { margin-bottom: 0; padding-bottom: 0; }
.main-content { padding-bottom: 0; }

/* ── Dark mode ──────────────────────────────────────────────────────── */
[data-theme="dark"] body { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%); }
[data-theme="dark"] body::before {
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}
[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.97) 0%, rgba(51, 65, 85, 0.95) 50%, rgba(59, 130, 246, 0.3) 100%);
}
[data-theme="dark"] .hero-text h1,
[data-theme="dark"] .hero-text p { color: white; }
[data-theme="dark"] .search-wrapper input { background: rgba(30, 41, 59, 0.98); color: #f1f5f9; border-color: rgba(100, 116, 139, 0.3); }
[data-theme="dark"] .search-wrapper input::placeholder { color: #94a3b8; }
[data-theme="dark"] .search-results-dropdown { background: #1e293b; border: 1px solid #334155; }
[data-theme="dark"] .section-title { color: #f1f5f9; }
[data-theme="dark"] .section-subtitle { color: rgba(226, 232, 240, 0.78); }
[data-theme="dark"] .priority-chip { background: rgba(30, 41, 59, 0.95); border-color: rgba(100, 116, 139, 0.26); }
[data-theme="dark"] .priority-chip .chip-label { color: #94a3b8; }
[data-theme="dark"] .priority-chip .chip-value { color: #f8fafc; }
[data-theme="dark"] .priority-chip .chip-value.stat-error { color: var(--warning-400, #fbbf24); }
[data-theme="dark"] .section-title--reference { color: rgba(226, 232, 240, 0.6); }
[data-theme="dark"] .quick-action-group-title { color: #94a3b8; }
[data-theme="dark"] .quick-actions-section { background: linear-gradient(180deg, rgba(168, 118, 26, 0.08) 0%, rgba(15, 23, 42, 0.94) 100%); border-color: rgba(100, 116, 139, 0.2); }
[data-theme="dark"] .action-card { background: rgba(30, 41, 59, 0.95); border-color: rgba(100, 116, 139, 0.2); }
[data-theme="dark"] .action-card h3 { color: #f1f5f9; }
[data-theme="dark"] .action-card p { color: #94a3b8; }
[data-theme="dark"] .activity-section,
[data-theme="dark"] .analytics-dashboard,
[data-theme="dark"] .charts-section { background: rgba(30, 41, 59, 0.95); border-color: rgba(100, 116, 139, 0.2); }
[data-theme="dark"] .filter-btn { background: rgba(51, 65, 85, 0.5); border-color: rgba(100, 116, 139, 0.3); color: #e2e8f0; }
[data-theme="dark"] .filter-btn:hover { background: rgba(59, 130, 246, 0.2); border-color: var(--accent-blue); }
[data-theme="dark"] .filter-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: white; }
[data-theme="dark"] .activity-item { background: rgba(51, 65, 85, 0.3); }
[data-theme="dark"] .activity-item:hover { background: rgba(59, 130, 246, 0.1); }
[data-theme="dark"] .activity-title { color: #f1f5f9; }
[data-theme="dark"] .activity-meta,
[data-theme="dark"] .activity-time { color: #94a3b8; }
[data-theme="dark"] .chart-card { background: rgba(51, 65, 85, 0.3); }
[data-theme="dark"] .chart-card h4,
[data-theme="dark"] .chart-header h3 { color: #e2e8f0; }
[data-theme="dark"] .role-alert-card,
[data-theme="dark"] .reflection-card { background: #1e293b; border-color: rgba(255, 255, 255, 0.08); }
[data-theme="dark"] .reflection-empty-state { color: #94a3b8; }
[data-theme="dark"] .reflection-empty-title { color: #f1f5f9; }
[data-theme="dark"] .rr-modal-panel { background: #1e293b; }
[data-theme="dark"] .rr-detail-section,
[data-theme="dark"] .rr-follow-up-note { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .activity-list { scrollbar-color: rgba(255, 255, 255, 0.12) transparent; }
[data-theme="dark"] .activity-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); }

/* ── Notification bell badge ────────────────────────────────────────── */
#notificationBell { position: relative; }
#notificationBell.has-live-alert::after {
  content: attr(data-alert-count);
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-size: 0.65rem;
  line-height: 20px;
  text-align: center;
  font-weight: 800;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main-content { margin-left: 60px; }
  .hero-content { flex-direction: column; text-align: center; }
  .hero-search { margin-left: 0; flex: 1; width: 100%; max-width: 500px; }
}
@media (max-width: 900px) {
  .dashboard-wrapper { padding: 1rem; }
  .hero-section { min-height: 0; }
  .quick-action-row,
  .metrics-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { gap: 1rem; }
}
@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .dashboard-wrapper { padding: 1rem; }
  .hero-section { padding: 1.25rem 1.25rem; border-radius: 14px; }
  .priority-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions-grid { gap: 0.45rem; }
  .quick-action-row { gap: 0.45rem; }
  .action-card { padding: 0.45rem 0.85rem 0.45rem 0.6rem; }
  .stats-panel { width: 100%; }
}
@media (max-width: 640px) {
  .priority-grid,
  .quick-action-row,
  .metrics-row { grid-template-columns: 1fr; }
  .action-card,
  .metric-card { min-height: auto; }
  .activity-item { align-items: flex-start; }
  .hero-content { gap: 0.85rem; }
  .hero-logo { width: 56px; height: 56px; flex-basis: 56px; }
}

/* ── Accessibility ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hero-logo,
  .skeleton,
  .ai-loading-skeleton,
  .role-alert-pulse,
  .house-leaderboard-label .live-dot,
  #notificationBell.has-live-alert::after {
    animation: none;
  }
}

/* ── Print ──────────────────────────────────────────────────────────── */
@media print {
  .search-wrapper,
  .activity-filters,
  .stats-panel,
  .house-leaderboard-bar,
  .stats-toggle-btn {
    display: none;
  }
}
