/* =================================================================
   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 {
  /* MTSS tier-number colors (System A — see docs/architecture/COLOR_REFERENCE.md).
     Canonical convention: Tier 1 green / Tier 2 yellow / Tier 3 red (intensive).
     Tiers 4-5 (rare; districts that configure >3 levels) stay at the most-
     intensive red — proper count-relative coloring is a documented follow-up.
     Do NOT confuse with the --scale-N value bands. */
  --tier-1:    var(--scale-4);  --tier-1-bg:  var(--scale-4-bg);  /* green  */
  --tier-2:    var(--scale-3);  --tier-2-bg:  var(--scale-3-bg);  /* yellow */
  --tier-3:    var(--scale-1);  --tier-3-bg:  var(--scale-1-bg);  /* red    */
  --tier-4:    var(--scale-1);  --tier-4-bg:  var(--scale-1-bg);  /* red    */
  --tier-5:    var(--scale-1);  --tier-5-bg:  var(--scale-1-bg);  /* red    */
}

/* =================================================================
   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; }
[x-cloak] { display: none !important; }

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;
  /* Bound width to (viewport - global sidebar) so flex children can't push
     the page wider. Without this, any inner overflow creates page-level
     horizontal scroll, and content slides under the fixed global sidebar. */
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
}

.main-content {
  padding: 24px;
}

/* Inner-sidebar layouts manage their own spacing — no outer padding */
.main-content:has(> .settings-layout, > .iep-layout, > .interventions-layout, > .markup-page, > .markup-editor-page) {
  padding: 0;
  min-width: 0;
  overflow-x: hidden;
}

.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;
  /* Above wall-grid sticky/fixed layers (≤200) so the top-bar school dropdown
     overlays the grid; stays below modals (z-index 2000). The dropdown menu is
     trapped in this stacking context, so the menu's own z-index can't beat the
     wall unless the bar itself sits above it. */
  z-index: 300;
}

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

.topbar-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
/* School-context prefix: muted, lighter weight; the page title stays prominent.
   School name truncates on narrow viewports so the page title is never lost. */
.topbar-school {
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  max-width: 32vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-school-sep {
  color: var(--text-muted, #94a3b8);
  font-weight: 400;
}

/* Top-bar school switcher (CROSS_ACCOUNT_NAV / preview) */
.topbar-school-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.topbar-school-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 32vw;
  border: none;
  background: none;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font: inherit;
}
.topbar-school-trigger .topbar-school-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-school-trigger:hover { background: var(--surface-alt); color: var(--text); }
.topbar-school-caret { font-size: 10px; color: var(--text-muted); }
.topbar-school-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border-light);
  border-radius: var(--radius, 8px);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(15, 23, 42, 0.12));
  padding: 4px 0;
}
.topbar-school-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-school-item:hover { background: var(--surface-alt); color: var(--text); }
.topbar-school-item.current { color: var(--brand-text); font-weight: 600; }
.topbar-page { white-space: nowrap; }

.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 {
  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);
}

/* A list of links (chat history) — the CONTAINER must not light up like a single
   clickable card; the per-row hover below carries the affordance instead. */
.chat-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.chat-row { border-radius: 6px; transition: background 0.12s; }
.chat-row:hover { background: var(--surface-alt, #F3F4F6); }

.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;
  white-space: nowrap;
}

.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; }
/* Buttons inside tables keep their own button colors, not the link-brand color */
.data-table a.btn { color: var(--text); text-decoration: none; }
.data-table a.btn:hover { text-decoration: none; }
.data-table a.btn-primary,
.data-table a.btn-primary:hover { color: #fff; }
.data-table a.btn-danger,
.data-table a.btn-danger:hover { color: #fff; }

.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); }

.claim-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-secondary);
}
.claim-badge-suite {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
}
.claim-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.claim-remove-btn:hover { color: var(--danger); }

/* =================================================================
   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 INDICATOR
   ================================================================= */
.impersonate-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F59E0B;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
}

.impersonate-indicator:hover {
  background: #D97706;
}

.impersonate-indicator svg {
  width: 16px;
  height: 16px;
}

.user-avatar.impersonating {
  background: #FEF3C7;
  color: #92400E;
}

/* Impersonation modal */
.impersonate-modal-identity {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.impersonate-modal-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.impersonate-modal-real {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  margin-bottom: 20px;
}

/* =================================================================
   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); }

/* Wall cell tier color bands — applied via the cell's `class` field by
   TierLevelDimension. Domains can configure custom levels_available, so
   we cover 0 through 5 explicitly. Unassigned cells (no subject_tier row)
   get .wall-tier-default with a dashed border to distinguish from assigned
   defaults. See docs/architecture/COLOR_REFERENCE.md for the canonical
   MTSS tier-to-scale mapping. */
.wall-tier-0 { background: var(--scale-1-bg); color: var(--scale-1); }
.wall-tier-1 { background: var(--tier-1-bg); color: var(--tier-1); }
.wall-tier-2 { background: var(--tier-2-bg); color: var(--tier-2); }
.wall-tier-3 { background: var(--tier-3-bg); color: var(--tier-3); }
.wall-tier-4 { background: var(--tier-4-bg); color: var(--tier-4); }
.wall-tier-5 { background: var(--tier-5-bg); color: var(--tier-5); }
.wall-tier-default {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
}

/* TierChangeDimension cell variants — direction-aware accents. */
.wall-tier-change-up    { color: var(--scale-4); font-weight: 600; }
.wall-tier-change-down  { color: var(--scale-1); font-weight: 600; }
.wall-tier-change-mixed { color: var(--scale-3); font-weight: 600; }
.wall-tier-change-any   { color: var(--text-muted); font-weight: 600; }
.wall-tier-change-none  { color: var(--text-muted); }

/* =================================================================
   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;
}

/* Badges map directly to the tier number now that --tier-N encodes the MTSS
   triad (green/yellow/red). Previously they remapped 2→tier-3, 3→tier-5 to
   work around the old --tier-2=green definition. */
.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-2-bg, var(--scale-3-bg)); color: var(--tier-2, var(--scale-3)); }
.tier-badge-3 { background: var(--tier-3-bg, var(--scale-1-bg)); color: var(--tier-3, 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;
  /* auto-fit (not auto-fill) so the cards stretch to fill the row instead of
     leaving empty phantom columns to the right. */
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

/* Unified Elmer AI layout (persistent sidebar + main panel) for the non-chat
   surfaces — agent detail, subscriptions, all-agents. The chat view uses its own
   viewport-bounded variant (.agents-chat); here the page scrolls normally and the
   sidebar sticks. The sidebar partial carries both classes; scoping the sticky rule
   to `.ai-layout >` keeps it off the chat container. */
.ai-layout { display: flex; gap: 16px; align-items: flex-start; }
.ai-layout > .ai-sidebar {
  position: sticky;
  top: calc(var(--topbar-height, 56px) + 12px);
  max-height: calc(100dvh - var(--topbar-height, 56px) - 36px);
  overflow-y: auto;
}
.ai-main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 768px) {
  .ai-layout { flex-direction: column; }
  .ai-layout > .ai-sidebar {
    position: static; width: auto !important; flex: 0 0 auto !important; max-height: 40vh;
  }
}

/* Tabbed navigation for plan detail views (IEP/504 etc.) — uses underline
   indicators (`.tab-nav a` has its own `border-bottom: 2px solid transparent;
   margin-bottom: -2px;` so the active tab's color overlays this line).
   When the nav is inside a `.tab-bar` card (student profile), the wrapper
   already supplies its own border + spacing, so the underline rules are
   suppressed below. */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
  /* Scroll the tab strip within itself when there are too many tabs to fit
     (e.g. plan detail's 8 tabs on narrow viewports). Without this the row
     would push the parent wider and create page-level horizontal scroll. */
  overflow-x: auto;
  flex-wrap: nowrap;
}

.tab-nav a,
.tab-nav button {
  white-space: nowrap;
}

.tab-bar .tab-nav {
  border-bottom: none;
  margin-bottom: 0;
}

.tab-nav a,
.tab-nav button {
  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;
  /* Button-tab support (Alpine client-side tabs): reset native chrome so a
     <button> matches the <a> tabs visually. */
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
  font-family: inherit;
}

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

.tab-nav a.active,
.tab-nav button.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);
}

/* =================================================================
   26. STUDENT FILTER — Shared component
   Used by wall_view.html and profile/students.html via
   templates/components/student_filter.html
   ================================================================= */

/* Picker dropdown items (used in wall picker and student filter) */
.wall-picker-section {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.wall-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 12px 5px 24px;
  border: none;
  background: none;
  color: var(--text);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-align: left;
}
.wall-picker-item:hover { background: var(--surface-alt); }
.wall-picker-item.active { color: var(--brand); font-weight: 600; }

/* Student filter bar */
.student-filter-bar {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}
.filter-select {
  padding: 4px 8px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  min-width: 160px;
}
.filter-toggle-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.filter-toggle-btn:hover { color: var(--brand); }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
}
.filter-chip.chip-exclude {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 20%, transparent);
}
.filter-add-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
}

/* Hierarchical picker shared styles */
.picker-search {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
}
.picker-search input {
  width: 100%;
  padding: 5px 8px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
.picker-search input:focus { outline: none; border-color: var(--brand); }
.picker-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px 4px;
  border: none;
  border-top: 1px solid var(--border-light);
  background: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--brand);
  cursor: pointer;
  margin-top: 2px;
}
.picker-section-toggle:first-child { border-top: none; margin-top: 0; }
.picker-section-toggle:hover { color: var(--brand); opacity: 0.8; }
.picker-section-toggle .chevron { font-size: 10px; }
/* Divider lines between picker sections (District | School | My Walls | Recent).
   The section toggle's own border-top is suppressed because each toggle is the
   first child of its block; the block draws the single divider instead. */
.picker-section-block { border-top: 1px solid var(--border-light); }
.picker-section-block:first-child { border-top: none; }
.picker-category {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 5px 12px 5px 16px;
  border: none;
  background: none;
  color: var(--text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.picker-category:hover { background: var(--surface-alt); }
.picker-category .chevron { font-size: 9px; opacity: 0.5; width: 8px; text-align: center; flex-shrink: 0; }
.picker-category-items {
  background: color-mix(in srgb, var(--text) 2%, var(--surface));
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.picker-category-items .wall-picker-item {
  padding-left: 36px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}
.picker-teacher-header {
  padding: 4px 12px 2px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  font-style: italic;
}

/* Wall edit mode header controls */
.edit-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  margin-right: 4px;
  opacity: 0.6;
}
.edit-header-controls {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.edit-header-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  opacity: 0.7;
}
.edit-header-btn:hover { opacity: 1; color: var(--brand); }
.edit-header-btn-danger:hover { color: var(--danger); }
/* Column drag — drop-target indicator. The left edge gets a thick brand-color
   bar (visible against any cell background) plus a subtle tint so users can
   tell at a glance where the column will land. */
th.drag-over {
  box-shadow: inset 4px 0 0 var(--brand);
  background: var(--brand-tint, rgba(99, 102, 241, 0.08));
  position: relative;
}
th.drag-over::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -2px;
  width: 4px;
  background: var(--brand);
  border-radius: 2px;
  pointer-events: none;
  z-index: 4;
}
/* Group-banner cells get the same indicator while a banner drag is in flight. */
th.group-banner-pill.drag-over {
  cursor: grabbing;
}
.edit-insert-btn {
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
th:hover .edit-insert-btn { opacity: 0.7; }
.edit-insert-btn:hover { opacity: 1 !important; }

/* Student filter simple-mode dropdown */
.student-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 260px;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 4px;
}

.btn-sso-clever {
  background: #4274F6;
  color: #fff;
  border-color: #4274F6;
}

.btn-sso-clever:hover {
  background: #2d5fd4;
  border-color: #2d5fd4;
  color: #fff;
}

.btn-sso-classlink {
  background: #0a4d7f;
  color: #fff;
  border-color: #0a4d7f;
}

.btn-sso-classlink:hover {
  background: #083d65;
  border-color: #083d65;
  color: #fff;
}

/* =================================================================
   27. WALL INLINE EDITING — Metadata Picklist + Event Entry Grid
   ================================================================= */

/* Metadata picklist dropdown in wall grid cells */
.meta-picklist {
  width: 100%;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  font-size: var(--font-size-sm);
  color: var(--text);
  cursor: pointer;
}
.meta-picklist:hover { border-color: var(--border); }
.meta-picklist:focus { border-color: var(--brand); outline: none; }

/* Event entry grid cell styles */
.de-cell-select {
  width: 100%;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  font-size: var(--font-size-base);
  color: var(--text);
}
.de-cell-select:focus { border-color: var(--brand); outline: none; }

.de-cell-narrative { width: 200px; text-align: left; }

.de-cell-checks { display: flex; gap: 4px; flex-wrap: wrap; }
.de-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: var(--font-size-xs);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-secondary);
  user-select: none;
}
.de-check-chip.active {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-text);
}

.de-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.de-mode-toggle button {
  padding: 4px 12px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.de-mode-toggle button:not(:last-child) { border-right: 1px solid var(--border); }
.de-mode-toggle button.active {
  background: var(--brand);
  color: white;
}

tr.row-submitted td { opacity: 0.5; }
.col-action { width: 60px; text-align: center; }


/* ──────────────────────────────────────────────────────────────────────────
   Mobile (≤768px): off-canvas sidebar drawer.

   SAFETY: elmer.css has NO other @media blocks, so every rule inside the query
   below is inert at desktop widths — the desktop cascade is byte-for-byte
   unchanged. The only desktop rules shadowed here (.sidebar, .main) are
   re-declared solely inside the query; outside it they keep their originals.
   ────────────────────────────────────────────────────────────────────────── */
.mobile-nav-toggle {
  display: none;            /* hidden on desktop; revealed only in the mobile block */
  align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-right: 4px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text, #1f2937); border-radius: 8px; flex: 0 0 auto;
}
.mobile-nav-toggle:hover { background: var(--surface-2, rgba(0, 0, 0, .05)); }
.sidebar-backdrop { display: none; }   /* never shown on desktop */

/* Search trigger wraps the magnifier icon. On desktop it's an inert inline icon
   (search is always expanded); on mobile it becomes the tap target. The close (×)
   is mobile-expanded-only. */
.search-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; cursor: text; font: inherit; line-height: 0;
}
.search-close { display: none; }   /* desktop: never */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 2px 0 24px rgba(0, 0, 0, .18);
    z-index: 400;                      /* above the sticky topbar (300) when open */
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    margin-left: 0;                    /* neutralize the 240px desktop push */
    max-width: 100vw;
  }

  .mobile-nav-toggle { display: inline-flex; }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 399;   /* below the drawer, above content */
    background: rgba(0, 0, 0, .4);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Topbar: keep it inside the viewport (the no-wrap row of search + title + bell
     + avatar overflowed and scrolled the whole page sideways). Hide the global
     search on phones (⌘K is desktop-only), tighten padding/gaps, and let the
     title shrink/ellipsis so a long school name can't push the bar wide. */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left { gap: 8px; min-width: 0; }
  /* NB: no overflow:hidden here — it would clip the school-switcher dropdown
     (an absolutely-positioned child). Only the page-title span clips/ellipsizes. */
  .topbar-title { min-width: 0; }
  .topbar-page { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { gap: 6px; flex: 0 0 auto; }

  /* Global search collapses to a tap-to-expand magnifier (⌘K is desktop-only).
     Collapsed = just the icon button; tapping expands to a full-width search bar
     overlaying the topbar. */
  .search-box {
    background: transparent;
    border: none;
    padding: 0;
    gap: 0;
    min-width: 0;   /* desktop sets min-width:200px — collapse to just the icon */
  }
  .search-box .search-trigger {
    width: 36px; height: 36px; border-radius: 6px;
    cursor: pointer; color: var(--text-secondary);
  }
  .search-box .search-trigger:hover { background: var(--surface-alt); }
  .search-box input[type="search"] { display: none; }
  .search-box .search-kbd { display: none; }

  .search-box.search-box-expanded {
    position: absolute !important;        /* beats the inline position:relative */
    left: 8px; right: 8px; top: 8px;
    z-index: 350;                         /* above topbar content (300) */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    gap: 8px;
  }
  .search-box.search-box-expanded input[type="search"] {
    display: block;
    width: 100% !important;               /* beats the inline width:200px */
    flex: 1 1 auto;
  }
  .search-box.search-box-expanded .search-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none; background: none;
    font-size: 22px; line-height: 1; color: var(--text-muted);
    cursor: pointer; flex: 0 0 auto;
  }
}
