/* ============================================================
   Delta School Routine Planner — Modernized UI
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Primary palette — indigo */
  --primary-600: #4338CA;
  --primary-700: #3730A3;
  --primary-800: #312E81;
  --primary-50: #EEF2FF;
  --primary-100: #E0E7FF;

  /* Neutral palette */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Semantic colors */
  --success-50: #ECFDF5;
  --success-100: #D1FAE5;
  --success-600: #059669;
  --success-700: #047857;
  --warning-50: #FFFBEB;
  --warning-100: #FEF3C7;
  --warning-500: #F59E0B;
  --warning-600: #D97706;
  --error-50: #FFF1F2;
  --error-100: #FFE4E6;
  --error-500: #F43F5E;
  --error-600: #E11D48;

  /* Layout */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* --- Header --- */
header {
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
  /* per-unit accent stripe (Round 7c) — inset so it never shifts layout;
     transparent until shell.js sets --unit-accent */
  border-bottom: 4px solid var(--unit-accent, transparent);
}

header h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#statusline {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
}
#statusline:not(:empty) {
  animation: fadeIn 0.2s ease;
}
#statusline.ok { background: var(--success-600); color: #fff; }
#statusline.err { background: var(--error-500); color: #fff; }

#editedline {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  margin-left: auto;
}

#headerauth {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}
#headerauth:empty { display: none; }
/* "who else has the planner open" strip in the header */
.who-online { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.online-dot { display: inline-flex; align-items: center; gap: 5px; color: rgba(255,255,255,0.7); }
.online-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,0.25);
}
.online-dot.me { color: #fff; font-weight: 600; }
button.linklike {
  background: none;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
button.linklike:hover {
  background: rgba(255,255,255,0.12);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Navigation Tabs --- */
nav#tabs {
  display: flex;
  gap: 0;
  background: var(--primary-800);
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

nav#tabs::-webkit-scrollbar { height: 4px; }
nav#tabs::-webkit-scrollbar-track { background: transparent; }
nav#tabs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.tab {
  background: transparent;
  color: rgba(255,255,255,0.65);
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition-base);
  border-bottom: 2px solid transparent;
  position: relative;
  letter-spacing: 0.01em;
}
.tab:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
}
.tab.active {
  color: #fff;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--primary-700);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 2px solid var(--primary-600);
}
.tab.more {
  color: rgba(255,255,255,0.5);
  font-style: italic;
  font-size: 12px;
  border-left: 1px solid rgba(255,255,255,0.15);
}
.tab.more:hover, .tab.more.open {
  color: rgba(255,255,255,0.85);
  font-style: normal;
  background: rgba(255,255,255,0.05);
}

/* --- Main Content --- */
main {
  padding: 24px;
  max-width: 1600px;
  animation: fadeIn 0.25s ease;
}

/* --- Toolbar --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 4px 0;
}

/* --- Buttons --- */
button {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  background: #fff;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
  line-height: 1.4;
  user-select: none;
}
button:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  box-shadow: var(--shadow-sm);
}
button:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-xs);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
button.primary {
  background: var(--primary-600);
  color: #fff;
  border-color: var(--primary-600);
  box-shadow: 0 1px 3px rgba(67,56,202,0.3);
}
button.primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
  box-shadow: 0 2px 6px rgba(67,56,202,0.35);
}
button.danger {
  background: var(--error-500);
  color: #fff;
  border-color: var(--error-500);
  box-shadow: 0 1px 3px rgba(244,63,94,0.3);
}
button.danger:hover {
  background: var(--error-600);
  border-color: var(--error-600);
  box-shadow: 0 2px 6px rgba(244,63,94,0.35);
}
button.sug {
  font-size: 12px;
  background: var(--success-50);
  border-color: var(--success-600);
  color: var(--success-700);
  font-weight: 500;
}
button.sug:hover {
  background: var(--success-100);
}
button.sug:active {
  background: var(--success-100);
  transform: scale(0.97);
}

/* --- Form Elements --- */
input, select {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-700);
  background: #fff;
  transition: all var(--transition-base);
  line-height: 1.4;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(67,56,202,0.12);
}
input::placeholder {
  color: var(--gray-400);
}
input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary-600);
}
input[type="date"] {
  cursor: pointer;
}
input[type="search"] {
  cursor: text;
}
input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

/* --- Labels & Text --- */
.daylabel {
  font-weight: 700;
  color: var(--primary-700);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--gray-500);
  font-size: 13px;
  line-height: 1.5;
}

/* --- Status Pills --- */
.pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: inline-block;
}
.pill.draft {
  background: var(--warning-100);
  color: var(--warning-600);
  border: 1px solid var(--warning-500);
}
.pill.published {
  background: var(--success-100);
  color: var(--success-700);
  border: 1px solid var(--success-600);
}

/* --- Panels / Cards --- */
.panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}
.panel:hover {
  box-shadow: var(--shadow-md);
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

/* --- Chips (absent teachers) --- */
.chips {
  margin: 8px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: var(--error-50);
  border: 1px solid var(--error-100);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--error-600);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-base);
}
.chip:hover {
  background: var(--error-100);
}
.chip a {
  color: var(--error-500);
  text-decoration: none;
  font-weight: 700;
  margin-left: 2px;
  transition: all var(--transition-fast);
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
}
.chip a:hover {
  color: #fff;
  background: var(--error-500);
}
.chip.partial {
  background: var(--warning-50);
  border-color: var(--warning-100);
  color: var(--warning-600);
}
.chip.partial a {
  color: var(--warning-500);
}
.chip.partial a:hover {
  background: var(--warning-500);
  color: #fff;
}

/* --- Tables --- */
table.covers, table.list {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: #fff;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
/* `overflow: hidden` here clips the cover-picker combobox's drop-down to the
   table box — on the last row it's cut off mid-list (the "Anyone else" group
   and anything below become unreachable). Only table.list can afford to clip
   to its radius; table.covers rounds its corner cells instead so the frame
   still looks right while the drop-down is free to overhang. */
table.list { overflow: hidden; }
table.covers tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
table.covers tr:first-child th:last-child { border-top-right-radius: var(--radius-lg); }
table.covers tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
table.covers tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }
table.covers th, table.list th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-700);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
table.covers td, table.list td {
  border-bottom: 1px solid var(--gray-100);
  padding: 8px 12px;
  vertical-align: middle;
}
table.covers tr:last-child td, table.list tr:last-child td {
  border-bottom: none;
}
table.covers tr:hover td, table.list tr:hover td {
  background: var(--gray-50);
}
table.covers tr.uncovered td:first-child {
  border-left: 4px solid var(--error-500);
}
table.covers tr.covered td:first-child {
  border-left: 4px solid var(--success-600);
}
/* The covers table has one very wide column (the suggestion dropdown, whose
   option text is long) and six narrow ones. Without fixed layout the browser
   sizes columns from content, so a long message — a Gemini API error, say —
   stretched the row to many screens wide and pushed the buttons off-screen.
   Fixed layout + explicit widths keep the buttons where the eye expects them
   no matter what text appears. */
table.covers.covers-grid {
  table-layout: fixed;
  width: 100%;
}
table.covers.covers-grid th:nth-child(1),
table.covers.covers-grid td:nth-child(1) { width: 14%; }
table.covers.covers-grid th:nth-child(2),
table.covers.covers-grid td:nth-child(2) { width: 8%; }
table.covers.covers-grid th:nth-child(3),
table.covers.covers-grid td:nth-child(3) { width: 10%; }
table.covers.covers-grid th:nth-child(4),
table.covers.covers-grid td:nth-child(4) { width: 9%; }
table.covers.covers-grid th:nth-child(5),
table.covers.covers-grid td:nth-child(5) { width: 44%; }
table.covers.covers-grid th:nth-child(6),
table.covers.covers-grid td:nth-child(6) { width: 15%; }
table.covers.covers-grid td { vertical-align: top; word-break: break-word; }
table.covers.covers-grid select { width: 100%; max-width: 100%; box-sizing: border-box; }

/* Routine Builder → Lab Matrix: editable Period × Class grid, one subject/tab */
.labsubtabs button { border-left: 3px solid var(--accent, var(--primary-600)); }
table.labmatrix2 {
  border-collapse: separate; border-spacing: 0; font-size: 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg); background: #fff;
}
table.labmatrix2 th, table.labmatrix2 td {
  border-bottom: 1px solid var(--gray-100); border-right: 1px solid var(--gray-100);
  padding: 4px; text-align: center; vertical-align: middle;
}
table.labmatrix2 tr:first-child th {
  background: var(--gray-50); position: sticky; top: 0; z-index: 2;
  font-size: 11px; color: var(--gray-700); padding: 6px 8px;
}
table.labmatrix2 th.lm-per, table.labmatrix2 th.corner {
  position: sticky; left: 0; z-index: 1; background: var(--gray-50);
  white-space: nowrap; text-align: right; padding-right: 8px; font-weight: 600;
}
table.labmatrix2 th.corner { z-index: 3; }
table.labmatrix2 th.lm-per small, table.labmatrix2 tr:first-child th small {
  display: block; font-weight: 400; color: var(--gray-400); font-size: 10px;
}
table.labmatrix2 .lm-cls { font-weight: 600; }
td.lm-has { background: var(--gray-50); padding: 3px; }
.lm-card {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--accent, var(--primary-600));
  border-radius: var(--radius-sm); background: #fff; cursor: pointer;
  padding: 5px 6px; font: inherit; text-align: left; line-height: 1.25;
}
.lm-card:hover { border-color: var(--accent, var(--primary-600)); box-shadow: var(--shadow-sm); }
.lm-card .lm-day { font-weight: 700; color: var(--accent, var(--primary-700)); }
.lm-card .lm-pr { color: var(--gray-600); }
.lm-card .lm-room { color: var(--gray-500); font-size: 11px; }
.lm-card .lm-tch { color: var(--gray-600); font-size: 11px; }
td.lm-empty { padding: 0; }
.lm-add {
  width: 100%; height: 100%; min-height: 28px; border: none; background: none;
  color: var(--gray-300); font-size: 15px; cursor: pointer; border-radius: 4px;
}
.lm-add:hover { background: var(--gray-100); color: var(--accent, var(--primary-600)); }

/* Routine Builder → Requirements & Load Matrix: wide editable grids. They
   used to be bare <table class="list"> with no scroll box, so on anything
   narrower than the full column run they dragged the page sideways. Now they
   sit in a .gridwrap and scroll inside it like the Lab Matrix, with the
   Class column and the header row frozen. */
table.list.matrixgrid { overflow: visible; width: auto; min-width: 100%; }
table.list.matrixgrid th:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--gray-50); box-shadow: 1px 0 0 var(--gray-200);
}
table.list.matrixgrid tr:first-child th:first-child { z-index: 4; }
table.list.matrixgrid tr:first-child th { z-index: 3; }
/* The teacher-initial column headers on the Load Matrix are .linklike
   buttons — that class is white-on-dark, meant for the app's header bar, so
   the initials were invisible against the light th. Recolour for a light
   background; this is the "click to edit teacher" affordance. */
table.list th button.linklike {
  color: var(--primary-700); border-color: var(--gray-300); font-weight: 600;
}
table.list th button.linklike:hover {
  background: var(--primary-50); border-color: var(--primary-600);
}
@media (max-width: 760px) {
  /* the generic mobile rule turns table.list into a display:block scroller of
     its own; here the .gridwrap is the scroller, so keep it a real table. */
  table.list.matrixgrid { display: table; overflow: visible; white-space: normal; }
}

/* School days: a card of day toggles instead of seven checkboxes strung
   along a toolbar (which wrapped mid-week and read as clutter on a phone). */
.dayselect {
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
  background: #fff; box-shadow: var(--shadow-xs);
  padding: 12px 14px; max-width: 460px;
}
.dayselect-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--gray-700);
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px;
}
.dayselect-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.daypill {
  display: flex; align-items: center; justify-content: center;
  padding: 9px 4px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: #fff;
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  cursor: pointer; user-select: none; text-align: center;
  transition: background .12s, border-color .12s, color .12s;
}
.daypill input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.daypill:hover { border-color: var(--gray-400); }
.daypill.on {
  background: var(--primary-50); border-color: var(--primary-600); color: var(--primary-700);
}
.daypill:focus-within { outline: 2px solid var(--primary-600); outline-offset: 1px; }
@media (max-width: 420px) {
  .dayselect { max-width: none; }
  .dayselect-grid { gap: 5px; }
  .daypill { padding: 11px 2px; font-size: 11px; }
}

/* long API/status messages under the dropdown: readable but never row-stretching */
.ai-note:empty { display: none; }
.ai-note {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--gray-600, #555);
  max-height: 4.6em;
  overflow-y: auto;
  word-break: break-word;
}

/* AI suggest + Assign stack so neither is pushed out of reach */
.cover-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.cover-actions button { width: 100%; white-space: nowrap; }

/* a teacher scheduled in two rooms at once — the one grid marker that means
   "this is broken", so it outranks the advisory back-to-back tint */
table.grid td.cell.clash {
  box-shadow: inset 0 0 0 3px var(--error-500);
}
table.grid td.cell.clash::after {
  content: "⚠";
  float: right;
  font-size: 11px;
  color: var(--error-600);
  line-height: 1;
}

/* advisory tint for a teacher running more than maxConsecutive classes
   back-to-back — deliberately far lighter than any legend colour, since it's
   information rather than a change to the routine */
table.grid td.cell.b2b {
  background: #FFF8E1;
  box-shadow: inset 0 0 0 1px #F5D98B;
}
.legend .lg.b2b-legend {
  background: #FFF8E1;
  color: #8A6D1F;
  box-shadow: inset 0 0 0 1px #F5D98B;
}
tr.cover-tier-row td {
  background: var(--gray-50);
  border-left: 4px solid var(--warning-500, #f59e0b);
  font-size: 12.5px;
  padding: 6px 12px;
}
.cover-tiers span { display: block; margin: 2px 0; }
.cover-tiers b { font-weight: 700; }
.cover-tiers button { margin-left: 6px; }
.cover-tiers .xunit-req { color: var(--primary-700, #3730a3); font-weight: 600; }
.cover-tiers .xunit-form select { margin: 0 4px; }

td.extra {
  background: #FFC7CE;
  font-weight: 600;
}
td.warn, th.warn {
  background: var(--warning-50);
}

/* --- Validation List --- */
.validation-list {
  max-height: 60vh;
  overflow-y: auto;
  margin: 10px 0;
  padding: 2px;
}
.vrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin: 4px 0;
  font-size: 13px;
  transition: all var(--transition-base);
}
.vrow.error {
  background: var(--error-50);
  color: var(--error-600);
  font-weight: 500;
  border-left: 3px solid var(--error-500);
}
.vrow.warn {
  background: var(--warning-50);
  color: var(--warning-600);
  border-left: 3px solid var(--warning-500);
}
.vrow .ignore-link {
  flex-shrink: 0;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  background: #fff;
  transition: all var(--transition-base);
  cursor: pointer;
}
.vrow .ignore-link:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--gray-700);
}

/* --- Grid (timetable) --- */
.gridwrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}

.legend {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.lg {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-xs);
  border: 1px solid transparent;
}
.lg.b2b-legend {
  border: 1px dashed var(--gray-300);
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  min-width: 1180px;
}
/* Lighter inner rules, one solid frame — the old uniform gray-200 grid made
   every cell shout for equal attention. */
table.grid th, table.grid td {
  border: 1px solid var(--gray-100);
  padding: 7px 9px;
  text-align: center;
}
table.grid tr:first-child th { border-top-color: var(--gray-200); }
table.grid th.sec, table.grid tr th:first-child { border-left-color: var(--gray-200); }
table.grid th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 11px;
  padding: 9px 8px;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--gray-200);
}
table.grid th.sec {
  min-width: 132px;
  text-align: left;
  background: var(--gray-100);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--gray-800);
  /* `table.grid th` sticks the header row to the top; a row header is a th
     too, and must opt out — otherwise every section that scrolls off the top
     pins itself there and they stack up on each other. Only the first row's
     cells belong in the frozen top band. */
  top: auto;
  box-shadow: none;
}
table.grid th.sec small {
  display: block;
  color: var(--gray-500);
  font-weight: 400;
  font-size: 10.5px;
  margin-top: 1px;
}
table.grid th.sec.XII {
  background: var(--primary-50);
}
/* faint band on alternate section rows — easier to track across 9 periods */
table.grid tr:nth-child(even) td.cell:not([style*="background"]) { background: #FCFCFD; }

td.break {
  background: var(--gray-700);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
}

td.cell {
  cursor: pointer;
  min-width: 116px;
  height: 54px;
  transition: box-shadow var(--transition-fast), outline-color var(--transition-fast);
  position: relative;
  line-height: 1.3;
}
td.cell:hover {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(67,56,202,0.12);
}
td.cell:active {
  outline-color: var(--primary-700);
  outline-width: 3px;
}

.subj { font-weight: 700; font-size: 12.5px; letter-spacing: -0.005em; }
.tchr { font-size: 11px; color: var(--gray-600); margin-top: 3px; }

td.cell.edited {
  outline: 3px solid var(--warning-500);
  outline-offset: -3px;
}

/* --- Issues --- */
.issue {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.5;
}
.issue.error {
  background: var(--error-50);
  border-left: 4px solid var(--error-500);
  color: var(--error-600);
}
.issue.warn {
  background: var(--warning-50);
  border-left: 4px solid var(--warning-500);
  color: var(--warning-600);
}

.sugs {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.okline {
  color: var(--success-700);
  font-weight: 600;
  font-size: 14px;
}

/* --- Collapsible sections --- */
details.collapsible > summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 0;
  transition: color var(--transition-base);
  user-select: none;
}
details.collapsible > summary:hover {
  color: var(--primary-600);
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before {
  content: "▶ ";
  font-size: 11px;
  color: var(--gray-400);
  transition: transform var(--transition-base);
  display: inline-block;
}
details.collapsible[open] > summary::before {
  content: "▼ ";
}
details.collapsible > summary h3 { margin: 0; }

/* --- Inline toolbar menu: a disclosure that looks like one button until
   opened, for grouping a few related actions (export formats, say) without
   giving each its own full-width row. --- */
details.menu { display: inline-block; position: relative; }
details.menu > summary {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 16px; border: 1px solid var(--gray-300); background: #fff;
  border-radius: var(--radius-md); cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--gray-700); box-shadow: var(--shadow-xs); list-style: none; user-select: none;
}
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: "▾"; font-size: 10px; color: var(--gray-400); }
details.menu[open] > summary::after { content: "▴"; }
details.menu > summary:hover { background: var(--gray-50); border-color: var(--gray-400); }
details.menu .menu-body {
  display: flex; flex-direction: column; gap: 6px;
  /* float over the page rather than shove the panels below it down —
     opening an export menu shouldn't move the thing you were about to click */
  position: absolute; z-index: 50; top: 100%; right: 0;
  min-width: max(200px, 100%);
  margin-top: 6px; padding: 10px; border: 1px solid var(--gray-300); border-radius: var(--radius-md);
  background: #fff; box-shadow: 0 10px 28px rgba(0,0,0,.18);
}
details.menu .menu-body button { width: 100%; text-align: left; }

tr.forcedrow td {
  background: var(--warning-50);
}

/* --- Dialog / Modal --- */
dialog {
  border: none;
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 92%;
  padding: 28px;
  box-shadow: var(--shadow-xl);
  animation: dialogIn 0.2s ease;
  /* the global `* { margin: 0 }` reset above zeroes out the margin the
     browser otherwise uses to auto-center a showModal() dialog — restore
     it explicitly or the dialog opens pinned to the top instead of centered */
  margin: auto;
}
dialog::backdrop {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}
dialog h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Form Rows --- */
.formrow {
  margin: 10px 0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.formrow > label {
  min-width: 110px;
  font-weight: 600;
  padding-top: 7px;
  font-size: 13px;
  color: var(--gray-700);
}

/* --- Teacher Pick Grid --- */
.tpick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px 12px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  padding: 8px;
  border-radius: var(--radius-md);
  flex: 1;
  background: var(--gray-50);
}
.topt {
  font-size: 12px;
  white-space: nowrap;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.topt:hover {
  background: var(--primary-50);
}
/* Which periods of a lab this teacher takes. Only rendered for a two-period
   lab block, and only while the teacher is actually ticked, so the ordinary
   single-period editor looks exactly as it did. */
.halfpick {
  font-size: 11px;
  margin-left: 4px;
  padding: 0 2px;
  max-width: 8.5em;
  vertical-align: middle;
}
.halfpick[hidden] { display: none; }

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--gray-100);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* --- Responsive adjustments --- */
@media (max-width: 1200px) {
  main { padding: 18px; }
  .tpick { grid-template-columns: repeat(3, 1fr); }
  header { gap: 12px; }
}

@media (max-width: 768px) {
  header { padding: 10px 16px; flex-wrap: wrap; }
  header h1 { font-size: 14px; }
  main { padding: 12px; }
  nav#tabs { padding: 0 8px; }
  .tab { padding: 10px 12px; font-size: 12px; }
  .tpick { grid-template-columns: repeat(2, 1fr); }
  .formrow { flex-direction: column; gap: 4px; }
  .formrow > label { min-width: auto; padding-top: 0; }
  dialog { max-width: 100%; width: 100%; margin: 10px; padding: 20px; }
  .login-gate { padding: 24px 20px 20px; max-width: 100%; }
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
  .search-box input { min-width: 180px; }
  .cover-actions { flex-direction: row; flex-wrap: wrap; }
  .cover-actions button { width: auto; flex: 1; min-width: 80px; }
  .confirm-box { padding: 20px; }
}

@media (max-width: 480px) {
  header h1 { font-size: 13px; }
  .tab { padding: 8px 10px; font-size: 11px; }
  .search-box input { min-width: 140px; font-size: 12px; }
}

/* Print styles live in one block at the end of this file (search "@page"). */

/* --- Utility classes --- */
.text-success { color: var(--success-600); }
.text-warning { color: var(--warning-600); }
.text-error { color: var(--error-500); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Transition utilities --- */
.fade-in {
  animation: fadeIn 0.25s ease;
}

/* --- Active/click state visual feedback --- */
.clickable {
  cursor: pointer;
  transition: all var(--transition-base);
}
.clickable:active {
  transform: scale(0.98);
}

/* --- Badge for counts --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--gray-700);
}
.badge.error {
  background: var(--error-100);
  color: var(--error-600);
}
.badge.success {
  background: var(--success-100);
  color: var(--success-700);
}
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.toast {
  background: var(--gray-800);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease forwards;
  animation-delay: 0s, 4s;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  word-break: break-word;
}
.toast.success {
  background: var(--success-600);
  box-shadow: 0 4px 12px rgba(5,150,105,0.3);
}
.toast.error {
  background: var(--error-500);
  box-shadow: 0 4px 12px rgba(244,63,94,0.3);
}
.toast.warning {
  background: var(--warning-500);
  color: var(--gray-900);
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
  border-radius: 4px;
}
.toast.warning .toast-close {
  color: var(--gray-700);
}
.toast-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.15);
  box-shadow: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* --- Search Input --- */
.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-box input {
  padding-left: 34px;
  min-width: 240px;
}
.search-box::before {
  content: "\1F50D";
  position: absolute;
  left: 10px;
  font-size: 13px;
  opacity: 0.45;
  pointer-events: none;
}

/* --- Empty States --- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--gray-500);
}
.empty-state-icon {
  font-size: 56px;
  margin-bottom: 20px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.empty-state-desc {
  font-size: 14px;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.6;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Keyboard Shortcut Hints --- */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: 'SF Mono', monospace;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--gray-300);
  color: var(--gray-600);
}

/* --- Focus Visible for Keyboard Users --- */
*:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
}
button:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(67,56,202,0.12);
}

/* --- Table Row Highlight on Filter --- */
tr.filter-match td {
  background: var(--primary-50) !important;
}

/* --- Confirm Dialog --- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.confirm-box {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 480px;
  width: 92%;
  box-shadow: var(--shadow-xl);
  animation: dialogIn 0.2s ease;
}
.confirm-box h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-900);
}
.confirm-box p {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-line;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.confirm-actions button {
  min-width: 80px;
}

/* --- Login gate --- */
.login-gate-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-gate {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.login-gate h2 {
  font-size: 20px;
  margin: 0 0 4px;
  text-align: center;
  color: var(--gray-900);
}
.login-gate p.muted {
  text-align: center;
  margin: 0 0 20px;
  font-size: 13px;
}
.login-gate label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-top: 12px;
}
.login-gate input {
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md, 8px);
  font-size: 14px;
}
.login-gate input:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(67,56,202,0.12);
}
.login-gate button {
  margin-top: 18px;
  padding: 11px;
  font-size: 14px;
}
.login-gate-err {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--error-600, #c00);
  text-align: center;
}

/* ============================================================
   Small screens
   The admin app is desktop-shaped by nature — a 24-section by
   9-period grid can't become a phone layout without ceasing to
   be a grid. So wide things scroll inside their own container
   (never the page), and everything around them stacks.
   ============================================================ */
@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; }
  main { padding: 14px 12px 28px; }

  header {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px 12px;
  }
  header h1 { font-size: 14px; white-space: normal; }
  #editedline { margin-left: 0; font-size: 11px; }
  #headerauth { font-size: 11px; }

  nav#tabs { padding: 0 8px; }
  .tab { padding: 11px 13px; font-size: 12.5px; }

  /* toolbars become stacked rows rather than a wrapping jumble */
  .toolbar { gap: 8px; }
  .toolbar > label { font-size: 12px; }
  .toolbar input[type="text"],
  .toolbar input[type="password"],
  .toolbar select { min-width: 0; flex: 1 1 160px; }
  .toolbar button { flex: 0 0 auto; }
  /* wide flexed <input type=date> renders abnormally tall on some mobile builds */
  .toolbar input[type="date"] { flex: 0 0 auto; width: 150px; min-width: 0; }
  /* 16px prevents iOS zooming the whole page when a field is focused */
  input, select, textarea { font-size: 16px; }

  /* every wide table scrolls in its own box */
  .gridwrap, .scrollbox { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.grid { min-width: 780px; }

  /* Freeze both edges of the timetable.
     `table.grid th` already asked for `position: sticky; top: 0`, but it could
     never take effect: .gridwrap sets overflow-x, which computes overflow-y to
     auto as well, so the header stuck to .gridwrap's own scrollport — and that
     scrollport had no height, so it never scrolled and the row simply left the
     screen with the page. Bounding the height makes .gridwrap a real
     two-axis scroller, which is what the sticky was written for.
     24 sections by 9 periods on a phone is unreadable once the period times
     have scrolled away. */
  .gridwrap {
    max-height: 74vh; overflow: auto; overscroll-behavior: contain; padding: 0;
  }
  table.grid th.sec {
    position: sticky; left: 0; z-index: 2;
    background: var(--gray-50); box-shadow: 1px 0 0 var(--gray-200);
  }
  table.grid tr:first-child th { z-index: 3; box-shadow: 0 1px 0 var(--gray-200); }
  /* the corner is in both frozen bands, so it has to outrank each of them */
  table.grid tr:first-child th:first-child { left: 0; z-index: 4; }

  /* the cover table stops pretending to be a table and becomes cards —
     six columns at 375px is unreadable */
  table.covers.covers-grid,
  table.covers.covers-grid tbody,
  table.covers.covers-grid tr,
  table.covers.covers-grid td { display: block; width: auto; }
  table.covers.covers-grid { table-layout: auto; border: none; background: none; box-shadow: none; }
  table.covers.covers-grid tr:first-child { display: none; }   /* header row */
  table.covers.covers-grid tr {
    background: #fff; border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg); padding: 10px 12px; margin-bottom: 8px;
  }
  table.covers.covers-grid td {
    border: none; padding: 3px 0; width: auto !important;
  }
  table.covers.covers-grid td:empty { display: none; }
  /* label each field, since the header row is gone */
  table.covers.covers-grid td::before {
    content: attr(data-label);
    display: block; font-size: 10px; letter-spacing: .06em;
    text-transform: uppercase; color: var(--gray-500); margin-bottom: 2px;
  }
  table.covers.covers-grid td:first-child {
    font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--gray-100);
    padding-bottom: 6px; margin-bottom: 4px;
  }
  table.covers.covers-grid tr.cover-tier-row { background: var(--gray-50); }
  .cover-actions { flex-direction: row; gap: 8px; margin-top: 6px; }
  .cover-actions button { flex: 1; }

  /* Teacher/report lists are plain tables with no wrapper to scroll inside,
     so give them their own scroll context rather than letting them drag the
     whole page sideways. `display:block` is what makes overflow apply to a
     table element at all. */
  table.list {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap; font-size: 12px; max-width: 100%;
  }
  table.list th, table.list td { padding: 7px 8px; }
  table.list input[type="text"] { min-width: 9em; }

  .login-gate { max-width: 100%; padding: 22px 18px; }
  dialog#dialog { width: calc(100vw - 24px); max-width: none; padding: 18px; }
  .confirm-box { width: calc(100vw - 32px); }
}

@media (max-width: 420px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  /* flex-basis (the "160px" in flex:1 1 160px, set for the row layout above)
     applies to the main axis — once .toolbar goes column that's height, not
     width, so every stretched select/input rendered ~160px tall. Reset the
     basis here so width:100% is the only thing controlling their size. */
  .toolbar button, .toolbar select, .toolbar input:not([type="date"]) { width: 100%; flex: 0 0 auto; }
  .toolbar input[type="date"] { align-self: flex-start; }
  .toolbar details.menu { width: 100%; }
  .toolbar details.menu > summary { width: 100%; box-sizing: border-box; justify-content: center; }
  .legend { gap: 4px; }
  .legend .lg { font-size: 10px; padding: 3px 6px; }
}

/* Excel export picker */
.export-parts { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 14px; }
.export-part {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 9px 10px; border-radius: var(--radius-md); cursor: pointer;
}
.export-part:hover { background: var(--gray-50); }
.export-part input { margin-top: 3px; }
.export-part b { display: block; font-weight: 600; font-size: 13.5px; color: var(--gray-800); }
.export-part small { color: var(--gray-500); font-size: 12px; }

/* Undo sits with the editor identity in the header — it belongs to the
   session, not to any one tab. */
button.linklike.undo { border-color: rgba(255,255,255,.55); font-weight: 600; }

/* the published day has drifted from what teachers can currently see */
.pill.unpublished {
  background: var(--warning-100);
  color: var(--warning-600);
  border: 1px solid var(--warning-500);
}

/* Per-day working hours, opened from the Constraints tab's "Per-day" button.
   Sits inside a table cell, so it lays itself out rather than inheriting the
   row's alignment. */
.perday {
  margin-top: .4rem;
  padding: .4rem .5rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: rgba(0, 0, 0, .02);
  min-width: 22rem;
}
.perday-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: space-between;
  padding: .15rem 0;
  white-space: nowrap;
}
.perday-row label { display: flex; align-items: center; gap: .3rem; }
.perday .fine { margin: .4rem 0 0; font-size: .78em; color: var(--gray-500); white-space: normal; }
/* per-day period ticks — a wrapping grid of small P1..Pn checkboxes */
.perday-periods { display: flex; flex-wrap: wrap; gap: .1rem .55rem; justify-content: flex-end; }
.perday-periods .perday-p { font-size: .8em; gap: .15rem; }
.perday-periods .perday-p input { margin: 0; }

/* Per-row Edit / Delete on the Teachers table. Kept compact so adding the
   column doesn't push the wide table into a horizontal scroll on a laptop. */
.rowacts { white-space: nowrap; }
.rowacts button {
  font-size: 12px;
  padding: 3px 8px;
  margin-left: 2px;
}

/* Section headings inside the merged Rules panel (Constraints tab). */
.rules-h {
  margin: 8px 0 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.rules-h:first-child { margin-top: 0; }
.perday { min-width: 20rem; }

/* Sign-off list on the Routine Builder's Generate & Review step. */
.signoff-list { margin: 4px 0 8px 18px; font-size: 13px; }
.signoff-list li { margin: 2px 0; }

/* ---- Reports tab: at-a-glance strip + charts ---- */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 18px; }
.kpi {
  flex: 1 1 140px; background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--shadow-xs);
}
.kpi-value { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.15; }
.kpi-label { font-size: 12px; color: var(--gray-600); margin-top: 2px; }
.kpi-sub { font-size: 11px; color: var(--gray-400); margin-top: 1px; }

.report-summary {
  background: var(--primary-50, #eef2ff); border: 1px solid var(--primary-100, #e0e7ff);
  border-radius: var(--radius-md); padding: 10px 14px; margin: 10px 0 16px;
  font-size: 13px; color: var(--gray-800); line-height: 1.5;
}
.report-summary b { color: var(--gray-900); }
.chart-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.chart-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.chart-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-xs);
}
.chart-row .chart-card { flex: 1 1 320px; }
.chart-card h4 { margin: 0 0 4px; font-size: 13px; color: var(--gray-700); }
.chart-card .chart-sub { margin: 0 0 8px; font-size: 11px; color: var(--gray-400); }
.chart-card .chart-empty { font-size: 12px; color: var(--gray-400); padding: 12px 0; }
.barchart { overflow: visible; }
.barchart .bc-label { font-size: 11px; fill: var(--gray-600); }
.barchart .bc-value { font-size: 11px; fill: var(--gray-800); font-weight: 600; }
.barchart .bc-tick { font-size: 9px; fill: var(--gray-400); }
.barchart .bc-grid { stroke: var(--gray-100); stroke-width: 1; }
.barchart .bc-axis { stroke: var(--gray-300); stroke-width: 1; }
.barchart .bc-track { fill: var(--gray-50); }
.barchart .bc-row:hover .bc-track { fill: var(--gray-100); }
.barchart .bc-row:hover rect:not(.bc-track) { opacity: .85; }

table.list tr.tr-clickable { cursor: pointer; }
table.list tr.tr-clickable:hover td { background: var(--primary-50, #eef2ff); }

/* per-teacher report card (dialog) */
.tr-card h4 { margin: 14px 0 6px; font-size: 13px; color: var(--gray-700); }
.tr-card > div:nth-child(2) { margin: 4px 0 6px; }
.tr-stat { display: inline-flex; gap: 6px; align-items: baseline; margin-right: 16px; font-size: 13px; color: var(--gray-600); }
.tr-stat b { font-size: 18px; color: var(--gray-900); }
.tr-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0;
  border-bottom: 1px dashed var(--gray-100); font-size: 13px; }
.tr-copy { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 10px; max-height: 220px; overflow: auto; }

table.sortable th { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable th:hover { color: var(--primary-600); }
.row-focus { animation: row-flash 1.6s ease-out; }
@keyframes row-flash {
  0% { background: var(--primary-100); }
  100% { background: transparent; }
}

/* ---- Teacher search combobox — type to filter, click a match ---- */
.combobox { position: relative; display: inline-block; min-width: 16em; }
.combobox input {
  width: 100%; box-sizing: border-box;
}
.combobox-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--gray-300); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); max-height: 16rem; overflow-y: auto; margin-top: 2px;
}
.combobox-opt {
  /* 10px vertical padding + 13px text lands each row around 38-40px tall —
     comfortable for a fingertip on a phone, still dense enough that a long
     alphabetical list doesn't take forever to scroll through */
  padding: 10px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.combobox-opt:hover { background: var(--primary-50); }
.combobox-opt.sel { font-weight: 600; }
/* the ▾ affordance — click to open the full list like a native <select> */
.combobox > input { padding-right: 26px; }
.combobox-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer; padding: 0;
  font-size: 10px; color: var(--gray-500);
}
.combobox-toggle:hover { color: var(--gray-800); }
/* optgroup labels carried over from a wrapped <select> */
.combobox-group {
  padding: 6px 10px 3px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; color: var(--gray-500);
  background: var(--gray-50); position: sticky; top: 0;
}
/* inside the cover table a cell is narrow — let the box use the column */
td .combobox { min-width: 0; width: 100%; }


/* ============================================================
   Polish pass — app-wide refinements layered over the base above.
   Kept in one block so it's easy to see (and revert) as a set.
   ============================================================ */

/* Content column: a touch narrower for comfortable line length, and it no
   longer hugs the left edge on wide screens. */
main { max-width: 1400px; margin: 0 auto; padding: 22px 26px 40px; }
@media (max-width: 1200px) { main { padding: 18px; } }
@media (max-width: 768px)  { main { padding: 12px 12px 28px; } }

/* Section headings appended straight into the page (Reports, Builder, …),
   not just the ones inside .panel. */
main h2 { font-size: 16px; font-weight: 700; color: var(--gray-900); margin: 22px 0 10px; letter-spacing: -0.01em; }
main h3 { font-size: 14px; font-weight: 700; color: var(--gray-800); margin: 18px 0 8px; }
main h4 { font-size: 13px; font-weight: 700; color: var(--gray-700); margin: 14px 0 6px; }
main > p.muted:first-of-type { margin-bottom: 14px; }
.fine { font-size: 11.5px; line-height: 1.5; }

/* Calmer buttons — the drop shadow on every button was doing a lot of work. */
button { box-shadow: none; border-color: var(--gray-300); }
button:hover { box-shadow: var(--shadow-xs); }
button.primary { box-shadow: none; }
button.primary:hover { box-shadow: 0 1px 4px rgba(67,56,202,0.28); }
button.danger { box-shadow: none; }

/* One consistent keyboard focus ring everywhere. */
button:focus-visible, .tab:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary-600); outline-offset: 2px; border-radius: var(--radius-sm);
}
.tab:focus-visible { outline-offset: -2px; }

/* Panels: hold still on hover (a whole card lifting as the pointer crosses
   the page was restless), keep a quiet resting shadow. */
.panel { box-shadow: var(--shadow-xs); border-color: var(--gray-200); }
.panel:hover { box-shadow: var(--shadow-xs); }
details.panel { padding-top: 12px; padding-bottom: 12px; }
details.panel[open] { padding-bottom: 18px; }

/* Collapsible disclosure: one rotating chevron instead of swapping glyphs,
   a real hit target, and the label carries the weight. */
details.collapsible > summary { padding: 8px 2px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 8px; }
details.collapsible > summary::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 5px solid var(--gray-400); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast); transform: rotate(0deg);
}
details.collapsible[open] > summary::before { content: ""; transform: rotate(90deg); }
details.collapsible > summary:hover::before { border-left-color: var(--primary-600); }
details.collapsible > summary b { font-weight: 700; }

/* Long roster tables (Teachers, Ledger, History, Reports breakdown) read
   far faster with zebra rows and a header that stays put while you scroll.
   Row-level tint so cells with their own colour (.warn, .extra) keep it. */
table.list tr:nth-child(even) { background: var(--gray-50); }
table.list tr:hover td { background: var(--primary-50); }
/* only the header row sticks — a row-header <th> (Requirements, Load/Lab
   Matrix) must not pin itself to the top and stack. */
table.list tr:first-child th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--gray-200); }

/* KPI tiles: a hair tighter, with a subtle top accent so the strip reads as
   a unit rather than four loose boxes. */
.kpi { border-top: 3px solid var(--primary-100); padding: 12px 14px 13px; }
.kpi-value { font-size: 21px; }

/* Toolbars: labels sit on the control's baseline, a bit more air between groups. */
.toolbar { gap: 10px 14px; }
.toolbar > label { font-size: 13px; color: var(--gray-600); font-weight: 500; align-self: center; }

/* "your filter matched nothing" — distinct from .empty-state above, which is
   the page-level "nothing exists yet" panel with an icon and a description.
   Two near-identical class names was a trap waiting for the next edit. */
.no-results {
  text-align: center; color: var(--gray-500); font-size: 13px;
  padding: 28px 16px; border: 1px dashed var(--gray-300); border-radius: var(--radius-lg);
  background: var(--gray-50);
}


/* ---- Daily Routine / Master grid: room to breathe ------------------------
   The grid was built to a 12px / 4px-padding density that fits nine periods
   on a laptop but reads as a wall — the subject and the initials ran into
   each other and the row you were tracking was easy to lose. Taller cells,
   real padding, a stronger type hierarchy inside the cell, and a frozen
   class column so the leftmost label stays put while you scroll sideways. */
table.grid { font-size: 13px; border-spacing: 0; }
table.grid th, table.grid td { padding: 7px 9px; }
table.grid th {
  font-size: 11px; padding: 10px 9px; letter-spacing: .03em;
  text-transform: uppercase; color: var(--gray-600);
}
table.grid th.sec {
  /* the class column stays visible while the nine period columns scroll */
  position: sticky; left: 0; z-index: 2;
  min-width: 132px; padding: 9px 12px;
  font-size: 12px; text-transform: none; letter-spacing: 0;
  color: var(--gray-800); box-shadow: 1px 0 0 var(--gray-200);
}
table.grid tr:first-child th.sec { z-index: 3; }
/* the corner header ("TIME / SEC") belongs to both frozen bands */
table.grid tr:first-child th:first-child {
  position: sticky; left: 0; top: 0; z-index: 4; background: var(--gray-100);
  box-shadow: 1px 0 0 var(--gray-200);
}
table.grid th.sec small { font-size: 11px; margin-top: 1px; }
td.cell { min-width: 104px; height: 56px; padding: 6px 8px; }
.subj { font-size: 12.5px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.tchr { font-size: 11px; color: var(--gray-600); margin-top: 3px; line-height: 1.3; }
/* an empty period should read as empty space, not as a character */
td.cell:not(:has(.subj)) { color: var(--gray-300); font-size: 15px; }
td.break { font-size: 10px; letter-spacing: .08em; }
.gridwrap { padding: 16px; }
.legend { margin-bottom: 14px; }

@media (max-width: 768px) {
  /* on a phone the density has to come back, but keep the frozen column */
  table.grid { font-size: 12px; }
  table.grid th, table.grid td { padding: 5px 6px; }
  td.cell { min-width: 88px; height: 46px; }
  table.grid th.sec { min-width: 104px; }
}


/* ---- teacher page (today.html) is styled by today.css; nothing here ---- */


/* ---- Settings sub-tabs (also reusable by any tab that grows too long) ---- */
.subtabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 10px; margin: 4px 0 18px;
}
.subtabs button { border-radius: 999px; padding: 7px 16px; }
.subtabs button.primary { box-shadow: none; }

/* A grid narrower than its card left a band of dead space on the right
   (most visible on the Teacher Ledger, whose 5 rows never fill a wide
   screen). Let it stretch to the card; min-width still forces the
   horizontal scroll on a narrow one. */
table.grid { width: 100%; }


/* ---- Teachers roster: fewer, roomier columns ---------------------------
   Eleven columns plus a second header row of filter boxes made this the
   most cramped screen in the app. Related facts now share a cell, so the
   ones that remain can breathe. */
table.list.roster td { padding: 9px 12px; vertical-align: middle; }
table.list.roster td small {
  display: block; font-size: 10.5px; line-height: 1.3; margin-top: 1px;
  font-weight: 400;
}
table.list.roster td small.muted { color: var(--gray-500); }
/* the code column: initials, optional id, and the lab-only badge */
table.list.roster td:first-child { white-space: nowrap; }
table.list.roster td:first-child small { display: inline; margin: 0; }
.tag-lab {
  display: inline-block; margin-left: 6px; padding: 1px 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  border-radius: 4px; background: var(--warning-100); color: var(--warning-600);
  vertical-align: middle;
}
/* an inactive teacher stays readable but recedes */
tr.row-inactive td:not(.rowacts) { opacity: .55; }
table.list.roster input[type="text"] { min-width: 9em; }


/* ---- Daily Routine / Master grid: room to read -------------------------
   Nine periods across meant 92px cells with 11px subject text and 10px
   initials stacked inside 42px of height — legible only if you leaned in.
   Taller rows, a clearer type hierarchy, and the class column frozen so it
   stays put when the grid scrolls sideways. */
table.grid th, table.grid td { padding: 6px 8px; }
td.cell { height: 54px; min-width: 96px; padding: 6px 7px; }
.subj { font-size: 12px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.tchr { font-size: 11px; color: var(--gray-500); margin-top: 2px; line-height: 1.2; }
td.cell:hover .tchr { color: var(--gray-700); }

/* Freeze the class column. `table.grid th` sticks the header row to the
   top; a row header opts out of that (top:auto) and sticks sideways
   instead, so the section you're reading never scrolls out of view. */
table.grid th.sec {
  position: sticky; left: 0; z-index: 2;
  box-shadow: 1px 0 0 var(--gray-200);
  padding: 8px 10px; font-size: 12px;
}
table.grid tr:first-child th:first-child {
  position: sticky; left: 0; top: 0; z-index: 4;
  box-shadow: 1px 0 0 var(--gray-200), 0 1px 0 var(--gray-200);
}
table.grid tr:first-child th { z-index: 3; }
table.grid th.sec small { font-size: 10.5px; margin-top: 1px; }

/* The legend is reference, not headline — let it sit quieter above the grid. */
.legend .lg { box-shadow: none; font-size: 10.5px; padding: 4px 11px; }

/* An empty period should read as empty, not as a character. */
td.cell:not(:has(.subj)) { color: var(--gray-300); }


/* ---- The frozen column had a gap beside it -----------------------------
   `position: sticky; left: 0` pins to the scrollport's PADDING box, not its
   border box. .gridwrap carried 16-18px of horizontal padding, so the frozen
   class column parked that far in from the card edge and the columns
   scrolling past showed through the strip beside it — fragments of "12:5",
   "XI-D…" bleeding along the left edge on a phone. Zero the horizontal
   padding so the scrollport edge and the card edge are the same line, and
   give the children back their own breathing room.

   The same is true vertically: on a phone .gridwrap is also a vertical
   scrollport (max-height + overflow:auto), so any padding-top left an
   11px strip above the frozen header row with the scrolled rows sliding
   through it. Both axes have to be zero; the children carry the inset. */
.gridwrap { padding: 0; }
.gridwrap > .legend { padding: 14px 14px 0; }
.gridwrap > table { margin-bottom: 14px; }
@media (max-width: 768px) {
  .gridwrap > .legend { padding: 10px 10px 0; }
  .gridwrap > table { margin-bottom: 10px; }
}

/* ---- role: viewer / no-access (Round 1) ------------------------------------
   The routine_state RLS is the real guard; this just stops the edit
   affordances from looking live. Tabs, sub-tabs, disclosures, the search box
   and export buttons stay usable — a viewer can still look around and print. */
.role-tag {
  margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
  background: var(--primary-100, #e0e7ff); color: var(--primary-700, #3730a3);
}
.role-tag.ro { background: #fde8e8; color: #9b1c1c; }

body.role-viewer #content button.primary,
body.role-viewer #content button.danger,
body.role-viewer #content .cover-actions button,
body.role-viewer #content .cover-tiers button,
body.role-viewer #content table.grid td.cell,
body.role-viewer #content input:not([type="search"]),
body.role-viewer #content select,
body.role-viewer #content textarea {
  opacity: .5;
  pointer-events: none;
}
body.role-viewer #content table.grid td.cell { cursor: default; }

/* ---- footer + privacy notice (Round 3 follow-up) ---- */
#appfoot {
  margin: 2rem 0 1rem; padding: 0 1rem; text-align: center;
  font-size: 12px; color: var(--muted, #6b7280);
}
.privacy-link { color: inherit; text-decoration: underline; }
#privacy-banner a:focus, #privacy-banner button:focus { outline: 2px solid #c7d2fe; outline-offset: 2px; }

/* ---- "recent changes to this unit" strip on the Daily Routine tab ---- */
.recent-changes { margin: .5rem 0 1rem; font-size: 13px; }
.recent-changes > summary { cursor: pointer; color: var(--muted, #6b7280); }
.recent-changes ul { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .25rem; }
.recent-changes li { display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; }
.recent-changes .rc-when { color: var(--muted, #9ca3af); min-width: 5.5rem; }
.recent-changes .rc-sum { color: var(--muted, #6b7280); }

/* ---- step-by-step onboarding wizard (ui/wizard.js) ---- */
.wizard-steps { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0 1rem; }
.wizard-steps .wstep {
  font: inherit; font-size: 12px; padding: .3rem .6rem; border: 1px solid #d4d4d8;
  border-radius: 999px; background: #fff; cursor: pointer; color: var(--muted, #6b7280);
}
.wizard-steps .wstep.on { border-color: #6366f1; color: #3730a3; font-weight: 600; }
.wizard-steps .wstep.done { color: #16a34a; }
.wizard-step { display: grid; gap: .75rem; margin-bottom: 1rem; }
.wfield { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.wfield > span { min-width: 9rem; color: var(--muted, #6b7280); font-size: 13px; }
.dayrow { display: flex; gap: .35rem; flex-wrap: wrap; }
.wlist { display: grid; gap: .4rem; }
.wlist-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.wlist-lead { min-width: 2.5rem; color: var(--muted, #9ca3af); font-size: 13px; }
.wlist-del { font: inherit; border: 0; background: none; color: #b91c1c; cursor: pointer; }
.wlist-add { font: inherit; align-self: start; border: 1px dashed #d4d4d8; border-radius: .4rem; background: #fafafa; padding: .25rem .6rem; cursor: pointer; }
.wshared { font-size: 12px; display: inline-flex; gap: .25rem; align-items: center; color: var(--muted, #6b7280); }
.wfmt { background: #f4f4f5; border-radius: .4rem; padding: .6rem .8rem; font-size: 12px; overflow-x: auto; }
.wtt-report { display: grid; gap: .2rem; }
.wizard-foot { margin-top: .5rem; }

/* ============================================================
   Print / Save-as-PDF   (Round 4c)
   The Daily Routine tab's "Print / PDF" button is just window.print();
   everything that makes it a usable sheet is here. Target: the cover
   list + the grid, colours intact, on one A4 landscape page, with no
   app chrome. `.print-head` (a routine.js element) carries the school
   name / date / published-or-draft onto the paper.
   ============================================================ */
.print-head { display: none; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }

  /* Cell background colours (the diff legend) and the covered/uncovered
     accent borders are information, not decoration — force them through. */
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body { background: #fff !important; }
  body * { visibility: hidden; }               /* hide everything… */
  main, main * { visibility: visible; }        /* …then bring back the page body */

  header, nav#tabs, #appfoot, #statusline, #dialog,
  .toast-container, .toolbar, details.menu, .menu,
  .recent-changes, .chip, .sugs, .issue,
  .cover-actions, tr.cover-tier-row,
  button, input, select, textarea {
    display: none !important;
  }

  main { position: static; padding: 0 !important; }
  #content { display: block !important; }

  /* a coordinator may have collapsed the cover list before hitting print —
     expand every disclosure so nothing needed is hidden behind it */
  details, details > summary { display: block !important; }
  details:not([open]) > *:not(summary) { display: revert !important; }
  details.collapsible > summary {
    list-style: none; font-weight: 700; font-size: 12px; margin-bottom: 2mm;
  }
  details.collapsible > summary::-webkit-details-marker { display: none; }

  .print-head { display: block !important; margin: 0 0 4mm; }
  .print-head .print-title { font-size: 15px; font-weight: 700; }
  .print-head .print-sub { font-size: 11px; color: #333; margin-top: 1mm; }

  /* the cover list */
  table.covers {
    width: 100% !important; page-break-inside: avoid; margin: 0 0 5mm;
    box-shadow: none !important; border: 1px solid #999;
  }
  table.covers th, table.covers td { border: 0.5pt solid #999 !important; padding: 2px 4px !important; }
  table.covers th:last-child, table.covers td:last-child { display: none; }   /* Actions column */
  table.covers tr:hover td { background: transparent !important; }

  /* the grid — from a sideways-scrolling widescreen box to a fixed sheet */
  .gridwrap {
    overflow: visible !important; max-height: none !important;
    border: 0 !important; box-shadow: none !important;
  }
  .gridwrap > .legend { padding: 0 0 3mm !important; gap: 4px; }
  .legend .lg { border: 1px solid #ccc; font-size: 8px; padding: 1px 4px; }
  .legend .b2b-legend { display: none; }

  table.grid {
    width: 100% !important; min-width: 0 !important; table-layout: fixed;
    border-collapse: collapse !important; font-size: 8px !important;
    page-break-inside: avoid;
  }
  table.grid th, table.grid td {
    padding: 2px 3px !important; border: 0.5pt solid #999 !important;
    position: static !important; box-shadow: none !important;
    overflow: hidden; white-space: normal; word-break: break-word;
  }
  table.grid th { background: #f0f0f0 !important; letter-spacing: 0; }
  table.grid .subj { font-weight: 700; line-height: 1.1; }
  table.grid .tchr { line-height: 1.1; }
  table.grid td.break { writing-mode: initial; font-size: 7px !important; }

  /* a viewer-role print shouldn't carry the greyed-out look onto paper */
  body.role-viewer #content * { opacity: 1 !important; filter: none !important; }
}

/* ---- Error boundary (Round 7a) ----------------------------------------- */
.err-banner {
  position: sticky; top: 0; z-index: 9999;
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 10px 16px; font-size: 13px;
  background: var(--error-50, #fef2f2); border-bottom: 2px solid var(--error-500, #ef4444);
  color: var(--error-700, #b91c1c);
}
.err-banner .err-detail { flex-basis: 100%; }
.err-banner .err-detail pre,
.card.err-tab .err-detail pre {
  white-space: pre-wrap; word-break: break-word; font-size: 11px;
  max-height: 220px; overflow: auto; margin: 6px 0 0;
  background: var(--gray-50, #f9fafb); border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 6px; padding: 8px;
}
.card.err-tab { border-left: 4px solid var(--error-500, #ef4444); }
.card.err-tab .err-detail summary,
.err-banner .err-detail summary { cursor: pointer; color: var(--gray-500, #6b7280); font-size: 12px; }

/* ---- inline "?" help (Round 7c) -------------------------------------- */
.help { display: inline; }
.help-tip {
  width: 16px; height: 16px; padding: 0; margin-left: 4px;
  border: 1px solid var(--gray-300, #d1d5db); border-radius: 999px;
  background: var(--gray-50, #f9fafb); color: var(--gray-500, #6b7280);
  font-size: 11px; font-weight: 700; line-height: 14px; cursor: pointer;
  vertical-align: middle;
}
.help-tip:hover,
.help-tip[aria-expanded="true"] {
  background: var(--primary-50, #eef2ff); border-color: var(--primary-300, #a5b4fc);
  color: var(--primary-700, #4338ca);
}
.help-body {
  display: block; margin: 6px 0 2px; padding: 8px 10px; max-width: 44ch;
  font-size: 12px; font-weight: 400; line-height: 1.45;
  color: var(--gray-600, #4b5563);
  background: var(--primary-50, #eef2ff); border: 1px solid var(--primary-100, #e0e7ff);
  border-radius: 6px;
}
