/* =================================================================
   ELMER SUITE v3 — DESIGN SYSTEM
   Canonical design tokens, component styles, and theme overrides.
   All shared CSS lives here. Page-specific styles stay in templates.
   ================================================================= */

/* =================================================================
   1. DESIGN TOKENS — BRAND (Default: Soft Sunrise)
   ================================================================= */
:root {
  --brand-h: 18;
  --brand-s: 78%;
  --brand-l: 55%;

  --brand:         hsl(var(--brand-h), var(--brand-s), var(--brand-l));
  --brand-light:   hsl(var(--brand-h), 60%, 94%);
  --brand-lighter:  hsl(var(--brand-h), 50%, 97%);
  --brand-dark:    hsl(var(--brand-h), var(--brand-s), 42%);
  --brand-text:    hsl(var(--brand-h), var(--brand-s), 30%);
}

/* =================================================================
   2. DESIGN TOKENS — NEUTRALS
   ================================================================= */
:root {
  --bg:             #FAFAF8;
  --surface:        #FFFFFF;
  --surface-alt:    #F5F3F0;
  --border:         #E8E4DF;
  --border-light:   #F0EDE9;
  --text:           #2D2A26;
  --text-secondary: #6B6560;
  --text-muted:     #9C9590;
}

/* =================================================================
   3. DESIGN TOKENS — SEMANTIC COLORS
   ================================================================= */
:root {
  --success:     #3D9A5F;
  --success-bg:  #E8F5ED;
  --warning:     #D4920A;
  --warning-bg:  #FFF8E6;
  --danger:      #C44040;
  --danger-bg:   #FDECEC;
  --info:        #3B82C4;
  --info-bg:     #EBF2FA;
}

/* =================================================================
   4. DESIGN TOKENS — 5-POINT DATA SCALE (theme-independent)
   ================================================================= */
:root {
  --scale-1:     #DC3545;   --scale-1-bg:  #FDE8EA;  /* Red — worst */
  --scale-2:     #E67E22;   --scale-2-bg:  #FDF0E2;  /* Orange */
  --scale-3:     #F1C40F;   --scale-3-bg:  #FEF9E1;  /* Yellow — middle */
  --scale-4:     #28A745;   --scale-4-bg:  #E6F4EA;  /* Green — good */
  --scale-5:     #3B82F6;   --scale-5-bg:  #E8F0FE;  /* Blue — best */
}

/* Tier compatibility aliases (tier-1=best/green, tier-5=worst/red — inverted from scale) */
:root {
  --tier-1:    var(--scale-4);  --tier-1-bg:  var(--scale-4-bg);
  --tier-2:    var(--scale-4);  --tier-2-bg:  var(--scale-4-bg);
  --tier-3:    var(--scale-3);  --tier-3-bg:  var(--scale-3-bg);
  --tier-4:    var(--scale-2);  --tier-4-bg:  var(--scale-2-bg);
  --tier-5:    var(--scale-1);  --tier-5-bg:  var(--scale-1-bg);
}

/* =================================================================
   5. DESIGN TOKENS — LAYOUT
   ================================================================= */
:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:     0 4px 12px rgba(0,0,0,0.08);
}

/* =================================================================
   6. DESIGN TOKENS — TYPOGRAPHY
   ================================================================= */
:root {
  --font-family:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs:  11px;
  --font-size-sm:  12px;
  --font-size-base: 13px;
  --font-size-md:  14px;
  --font-size-lg:  15px;
  --font-size-xl:  16px;
  --font-size-2xl: 22px;
}

/* =================================================================
   7. RESET & BASE
   ================================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size-md);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* =================================================================
   8. LAYOUT SHELL — SIDEBAR
   ================================================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  text-decoration: none;
}

.sidebar-logo .logo-mark {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.sidebar-logo .logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  object-fit: contain;
}

.sidebar-logo .logo-text {
  font-weight: 700;
  font-size: var(--font-size-xl);
  color: var(--text);
}

.sidebar-logo .logo-text span {
  color: var(--brand);
}

/* =================================================================
   9. NAVIGATION
   ================================================================= */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-item.active {
  background: var(--brand-light);
  color: var(--brand-text);
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.7;
}

.nav-item .icon svg {
  width: 18px;
  height: 18px;
}

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

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.nav-item .legacy-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border-light);
}

/* =================================================================
   10. USER PILL & MENU
   ================================================================= */
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.user-pill:hover {
  background: var(--surface-alt);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-base);
}

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

.user-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User Menu */
.user-menu-wrapper {
  position: relative;
}

.user-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-bottom: 4px;
  z-index: 20;
  overflow: hidden;
}

.user-menu-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.user-menu-header .menu-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text);
}

.user-menu-header .menu-email {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

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

.user-menu-item .chevron {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* School picker sub-panel */
.school-picker {
  max-height: 260px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border-light);
}

.district-group {
  border-bottom: 1px solid var(--border-light);
}

.district-group:last-child { border-bottom: none; }

.district-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}

.district-name:hover { background: var(--surface-alt); }

.district-name .chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.school-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 20px;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  text-decoration: none;
}

.school-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.school-item.current {
  color: var(--brand-text);
  font-weight: 600;
}

.school-item .check {
  font-size: var(--font-size-sm);
  color: var(--brand);
}

/* =================================================================
   11. MAIN CONTENT AREA
   ================================================================= */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  position: relative;
  text-decoration: none;
}

.topbar-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.topbar-btn svg {
  width: 18px;
  height: 18px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  cursor: pointer;
  min-width: 200px;
}

.search-box:hover {
  border-color: var(--brand);
}

.search-box svg {
  width: 16px;
  height: 16px;
}

.search-box kbd {
  font-size: var(--font-size-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: auto;
  font-family: inherit;
}

/* =================================================================
   12. PAGE CONTENT
   ================================================================= */
.page {
  padding: 24px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 24px;
}

.greeting {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.greeting-sub {
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

/* =================================================================
   13. CARDS
   ================================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--brand);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-icon.orange  { background: var(--brand-light); color: var(--brand); }
.card-icon.green   { background: var(--success-bg); color: var(--success); }
.card-icon.blue    { background: var(--info-bg); color: var(--info); }
.card-icon.yellow  { background: var(--warning-bg); color: var(--warning); }

.card-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-bottom: 4px;
}

.card-desc {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.card .legacy-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
}

/* =================================================================
   14. BUTTONS
   ================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.btn:hover { background: var(--surface-alt); border-color: var(--brand); }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 4px 10px; font-size: var(--font-size-sm); }

/* =================================================================
   15. FORMS
   ================================================================= */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--font-size-md);
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* =================================================================
   16. TABLES
   ================================================================= */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  font-size: var(--font-size-base);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }
.data-table a { color: var(--brand); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: var(--danger-bg); color: var(--danger); }
.status-warning { background: var(--warning-bg); color: var(--warning); }
.status-info { background: var(--info-bg); color: var(--info); }

/* =================================================================
   17. MODALS
   ================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 24px;
  max-width: 420px;
  width: 90%;
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.modal-message {
  font-size: var(--font-size-md);
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =================================================================
   18. ALERTS & MESSAGES
   ================================================================= */
.error-message {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: var(--font-size-base);
  margin-bottom: 16px;
}

.success-message {
  background: var(--success-bg);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: var(--font-size-base);
  margin-bottom: 16px;
}

/* =================================================================
   19. SECTION HEADERS & UTILITIES
   ================================================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: var(--font-size-md);
}

/* Iframe wrapper for legacy apps */
.iframe-wrapper {
  height: calc(100vh - var(--topbar-height));
  width: 100%;
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* =================================================================
   20. IMPERSONATION BANNER
   ================================================================= */
.impersonate-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: #c0392b;
  color: white;
  padding: 0 16px;
  text-align: center;
  font-size: var(--font-size-base);
  font-weight: 500;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.impersonating .sidebar { top: 36px; }
.impersonating .topbar { top: 36px; }
.impersonating .main { padding-top: 36px; }

.impersonate-stop-btn {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 3px 12px;
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  margin-left: 12px;
}

.impersonate-stop-btn:hover {
  background: rgba(255,255,255,0.3);
}

/* =================================================================
   21. 5-POINT DATA SCALE — UTILITY CLASSES
   ================================================================= */
.scale-1    { color: var(--scale-1); }
.scale-1-bg { background: var(--scale-1-bg); color: var(--scale-1); }
.scale-2    { color: var(--scale-2); }
.scale-2-bg { background: var(--scale-2-bg); color: var(--scale-2); }
.scale-3    { color: var(--scale-3); }
.scale-3-bg { background: var(--scale-3-bg); color: var(--scale-3); }
.scale-4    { color: var(--scale-4); }
.scale-4-bg { background: var(--scale-4-bg); color: var(--scale-4); }
.scale-5    { color: var(--scale-5); }
.scale-5-bg { background: var(--scale-5-bg); color: var(--scale-5); }

/* =================================================================
   22. BUILT-IN THEMES
   ================================================================= */

/* Nordic Slate — cool steel blue */
[data-theme="nordic"] {
  --brand-h: 210;
  --brand-s: 45%;
  --brand-l: 50%;
  --bg: #F7F8FA;
  --surface-alt: #F0F2F5;
  --border: #E2E5EA;
  --border-light: #ECEEF2;
  --text: #1A1D23;
  --text-secondary: #5A6070;
  --text-muted: #8C92A0;
  --success: #2D8A56;
  --success-bg: #E6F4EC;
  --warning: #C4880A;
  --warning-bg: #FDF5E1;
  --danger: #C03C3C;
  --danger-bg: #FCEBEB;
  --info: #3578B5;
  --info-bg: #E9F0F9;
}

/* Forest — deep green */
[data-theme="forest"] {
  --brand-h: 152;
  --brand-s: 40%;
  --brand-l: 36%;
  --bg: #F6F7F5;
  --surface-alt: #F0F2EE;
  --border: #DDE0D8;
  --border-light: #EAECE6;
  --text: #1C2118;
  --text-secondary: #525E4C;
  --text-muted: #8A9283;
  --success: #2D8A56;
  --success-bg: #E6F4EC;
  --warning: #C4880A;
  --warning-bg: #FDF5E1;
  --danger: #C03C3C;
  --danger-bg: #FCEBEB;
  --info: #3578B5;
  --info-bg: #E9F0F9;
}

/* Neutral — desaturated grey with cool cast */
[data-theme="neutral"] {
  --brand-h: 220;
  --brand-s: 10%;
  --brand-l: 45%;
  --bg: #F5F5F6;
  --surface-alt: #EEEEEF;
  --border: #E0E0E2;
  --border-light: #EBEBEC;
  --text: #212125;
  --text-secondary: #616168;
  --text-muted: #9E9EA5;
  --success: #2D8A56;
  --success-bg: #E6F4EC;
  --warning: #C4880A;
  --warning-bg: #FDF5E1;
  --danger: #C03C3C;
  --danger-bg: #FCEBEB;
  --info: #3578B5;
  --info-bg: #E9F0F9;
}

/* =================================================================
   23. USER COLOR PREFERENCES
   Per-user data scale overrides applied via data-color attribute on <html>.
   These shift the 5-point data scale to different palettes.
   ================================================================= */

/* Cool — blue/teal tones */
[data-color="cool"] {
  --scale-1: #C0392B;  --scale-1-bg: #F9E5E3;
  --scale-2: #5B8C8D;  --scale-2-bg: #E5F0F0;
  --scale-3: #2980B9;  --scale-3-bg: #E1EDF6;
  --scale-4: #1ABC9C;  --scale-4-bg: #DFF5EF;
  --scale-5: #2C3E8C;  --scale-5-bg: #E0E3F2;
}

/* Warm — red/amber/gold tones */
[data-color="warm"] {
  --scale-1: #C0392B;  --scale-1-bg: #F9E5E3;
  --scale-2: #D35400;  --scale-2-bg: #FAE6D5;
  --scale-3: #D4AC0D;  --scale-3-bg: #FBF3D5;
  --scale-4: #B7950B;  --scale-4-bg: #F9F2D6;
  --scale-5: #7D6608;  --scale-5-bg: #F5EDD2;
}

/* Pastel — softer, desaturated versions */
[data-color="pastel"] {
  --scale-1: #E08888;  --scale-1-bg: #FDF0F0;
  --scale-2: #E0A878;  --scale-2-bg: #FDF3EC;
  --scale-3: #D4C878;  --scale-3-bg: #FBF8E8;
  --scale-4: #78C0A0;  --scale-4-bg: #ECF7F1;
  --scale-5: #88A8D8;  --scale-5-bg: #EDF2FA;
}

/* High Contrast — maximum differentiation */
[data-color="high-contrast"] {
  --scale-1: #B80000;  --scale-1-bg: #FFD6D6;
  --scale-2: #CC5500;  --scale-2-bg: #FFE0CC;
  --scale-3: #CC9900;  --scale-3-bg: #FFF2CC;
  --scale-4: #007700;  --scale-4-bg: #D6FFD6;
  --scale-5: #0000CC;  --scale-5-bg: #D6D6FF;
}

/* =================================================================
   24. COLORBLIND MODE
   Adds pattern markers and text labels to color-coded indicators.
   Applied via data-colorblind="true" on <html>.
   ================================================================= */

/* Colorblind markers — hidden by default, shown when enabled */
.colorblind-marker { display: none; }
[data-colorblind="true"] .colorblind-marker { display: inline; }

/* Add distinguishing patterns to scale backgrounds */
[data-colorblind="true"] .scale-1-bg { background-image: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0,0,0,0.08) 3px, rgba(0,0,0,0.08) 4px); }
[data-colorblind="true"] .scale-2-bg { background-image: repeating-linear-gradient(-45deg, transparent, transparent 5px, rgba(0,0,0,0.06) 5px, rgba(0,0,0,0.06) 6px); }
[data-colorblind="true"] .scale-3-bg { background-image: radial-gradient(circle, rgba(0,0,0,0.06) 1px, transparent 1px); background-size: 6px 6px; }
[data-colorblind="true"] .scale-4-bg { background-image: repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(0,0,0,0.06) 4px, rgba(0,0,0,0.06) 5px); }
[data-colorblind="true"] .scale-5-bg { background-image: repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(0,0,0,0.06) 4px, rgba(0,0,0,0.06) 5px); }

/* =================================================================
   25. STANDALONE PAGE STYLES (login, forgot, reset, error)
   These are used by pages that don't extend layout.html.
   ================================================================= */
body.standalone-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo .logo-mark {
  width: 40px;
  height: 40px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.login-logo .logo-text {
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
}

.login-logo .logo-text span {
  color: var(--brand);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: center;
}

.login-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  margin-bottom: 24px;
  text-align: center;
}

.forgot-link {
  display: block;
  text-align: right;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 16px;
}

.forgot-link:hover { color: var(--brand); }

.divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 12px;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.sso-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--font-size-md);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-sso:hover {
  border-color: var(--brand);
  background: var(--bg);
}

.btn-sso .sso-label {
  font-weight: 600;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover { color: var(--brand); }

/* Error page */
.error-container {
  text-align: center;
  padding: 48px 24px;
  max-width: 480px;
}

.error-logo {
  width: 48px;
  height: 48px;
  background: var(--brand);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 32px;
}

.error-code {
  font-size: 72px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 8px;
}

.error-title {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.error-description {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
}

.error-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: var(--font-size-md);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.error-action:hover { background: var(--brand-dark); }


/* ==========================================================================
   IEP/504 & Interventions Components
   ========================================================================== */

/* Progress bars — horizontal fill bars for goal progress, service hours */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}

.progress-bar-lg { height: 12px; }

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  transition: width 0.4s ease;
  min-width: 0;
}

.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* Compliance dots — small colored circles for monthly compliance timeline */
.compliance-timeline {
  display: flex;
  gap: 6px;
  align-items: center;
}

.compliance-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  cursor: default;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.compliance-dot:hover { transform: scale(1.3); }
.compliance-dot.complete { background: var(--success); }
.compliance-dot.partial { background: var(--warning); }
.compliance-dot.missing { background: var(--danger); }
.compliance-dot.pending { background: var(--border); }

/* Plan type badges */
.plan-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-badge-iep { background: var(--info-bg); color: var(--info); }
.plan-badge-504 { background: var(--success-bg); color: var(--success); }
.plan-badge-bip { background: var(--warning-bg); color: var(--warning); }

/* Tier badges — using data scale classes */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.tier-badge-1 { background: var(--tier-1-bg, var(--scale-4-bg)); color: var(--tier-1, var(--scale-4)); }
.tier-badge-2 { background: var(--tier-3-bg, var(--scale-3-bg)); color: var(--tier-3, var(--scale-3)); }
.tier-badge-3 { background: var(--tier-5-bg, var(--scale-1-bg)); color: var(--tier-5, var(--scale-1)); }

/* Stat cards — compact metric display */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

/* Tabbed navigation for plan detail views */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.tab-nav a {
  padding: 10px 18px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-nav a:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.tab-nav a.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* Count badge inside nav items / tabs */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand);
  margin-left: 6px;
}

/* Aimline / chart container */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Service delivery summary bars */
.delivery-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.delivery-bar-label {
  flex: 0 0 120px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: right;
}

.delivery-bar-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.delivery-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.delivery-bar-value {
  flex: 0 0 60px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
