:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e5ea;
  --border-strong: #c9ccd3;
  --text: #1d2129;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --ok: #16a34a;
  --chip: #eef2ff;
  --chip-text: #3730a3;
  --teacher: #ecfeff;
  --teacher-text: #155e75;
  --drag-over: #fef3c7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.topbar .meta { display: flex; align-items: center; gap: 12px; flex: 1; }
.topbar .meta label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.topbar .meta input[type=text] {
  border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px; font: inherit;
  min-width: 220px;
}
.topbar .actions { display: flex; gap: 8px; }

button, .btn-like {
  font: inherit;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover, .btn-like:hover { background: #f1f3f7; }
button.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: #f1c0c0; }
button.icon { padding: 2px 6px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 12px;
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;
}
.col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.col-header h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* Tree */
.tree { padding: 8px 6px; overflow: auto; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree > ul { padding-left: 4px; }
.node {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 6px;
  cursor: pointer; user-select: none;
}
.node:hover { background: #f1f3f7; }
.node.selected { background: var(--accent-soft); }
.node .twisty {
  width: 14px; text-align: center; color: var(--muted);
  font-size: 10px;
}
.node .label { flex: 1; }
.node .name { font-weight: 500; }
.node .kind {
  font-size: 11px; text-transform: uppercase;
  color: var(--muted); margin-right: 6px;
}
.node .row-actions {
  display: none; gap: 2px;
}
.node:hover .row-actions, .node.selected .row-actions { display: inline-flex; }

/* Detail panel */
.detail-col { overflow: auto; }
.node-detail { padding: 16px; }
.node-detail.empty { display: grid; place-items: center; color: var(--muted); height: 100%; }
.node-detail .hint { color: var(--muted); }
.node-detail h2 { margin: 0 0 4px 0; }
.node-detail .breadcrumbs { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

.field-row { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.field-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field-row input, .field-row select {
  border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px; font: inherit;
}

.activities-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; margin-bottom: 8px;
}
.activities-header h3 { margin: 0; font-size: 14px; }

.activity {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fcfcfd;
  /* Flex+wrap: everything sits on one row when wide; the teacher block
     (room + teachers + share + delete) wraps to a second line as a unit
     when the row gets narrow. */
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
}
.activity > * { flex: 0 0 auto; }
.activity.opt {
  background: #f5f7ff;
  border-color: #b6c4ff;
}
.activity .opt-tag {
  background: #4f46e5; color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 4px;
}
.activity .opt-tag-slot { width: 0; padding: 0; }
.activity select, .activity input[type=number] {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px; font: inherit;
}
.activity .counter { display: flex; align-items: center; gap: 4px; }
.activity .counter input { width: 56px; text-align: center; }
.activity .teacher-cell {
  display: flex; align-items: center; gap: 6px;
  flex: 1 1 360px;     /* sits inline when there's room, wraps to full width when not */
  min-width: 0;
}
.activity .teacher-cell .teacher-drop { flex: 1 1 auto; min-height: 30px; padding: 4px 6px; min-width: 160px; }
.activity .teacher-cell .room { max-width: 18ch; }

/* Availability (🚫) button — orange when entity has blocked slots */
.avail-btn {
  border: 1px solid var(--border-strong); background: #fff; color: inherit;
  border-radius: 6px; padding: 2px 6px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 1px;
}
.avail-btn:hover { background: #f4f4f8; }
.avail-btn.has-blocks { background: #ffe1d6; border-color: #d97a4a; }
.avail-btn sup { font-size: 9px; font-weight: 600; color: #7a3300; }

/* Availability grid — days × periods clickable cells */
.avail-grid {
  display: grid;
  grid-template-columns: auto repeat(var(--cols, 10), minmax(48px, 1fr));
  gap: 2px; margin: 8px 0; max-height: 60vh; overflow: auto;
}
/* Yellow banner under the dialog title that highlights the right-click
   shortcut — the most-used interaction in this dialog. */
.avail-hint-primary {
  background: #fef3c7; border: 1px solid #f59e0b; color: #78350f;
  padding: 8px 12px; border-radius: 6px; margin: 8px 0;
  font-size: 13px;
}
.avail-hint-primary .legend-3 { color: #b91c1c; }
.avail-grid .avail-cell.pick { cursor: context-menu; }
.avail-grid .avail-cell {
  padding: 4px 6px; font-size: 12px; text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px; background: #fff;
}
.avail-grid .avail-cell.hdr {
  background: #f1f3f7; font-weight: 600; color: var(--muted);
}
.avail-grid .avail-cell.hdr.day { text-align: left; padding-left: 8px; }
.avail-grid .avail-cell.hdr.corner { background: transparent; border-color: transparent; }
.avail-grid .avail-cell.pick { padding: 0; min-height: 26px; }
.avail-grid .avail-cell.pick:hover { filter: brightness(0.96); }
.avail-grid .avail-cell.pick.lv-1 { background: #fff4b3; border-color: #d6c460; }
.avail-grid .avail-cell.pick.lv-2 { background: #fbcf95; border-color: #d97a4a; color: #5a2a0a; }
.avail-grid .avail-cell.pick.lv-3 {
  background: #f8c8b8; border-color: #d97a4a; color: #7a3300;
}
.avail-grid .avail-cell.pick.lv-pref-1 { background: #d8f0d2; border-color: #8bc070; color: #1f4a14; }
.avail-grid .avail-cell.pick.lv-pref-2 { background: #a8dca0; border-color: #5fa54a; color: #0d3a07; }
.avail-grid .avail-cell.pick .avail-input {
  width: 100%; height: 100%; min-height: 26px;
  border: none; background: transparent; color: inherit;
  text-align: center; font: inherit;
  padding: 4px 6px; box-sizing: border-box;
}
.avail-grid .avail-cell.pick .avail-input:focus {
  outline: 1px solid var(--accent, #3b82f6); outline-offset: -1px;
  background: rgba(255,255,255,0.7);
}
.legend-1 { background: #fff4b3; padding: 0 4px; border-radius: 3px; }
.legend-2 { background: #fbcf95; padding: 0 4px; border-radius: 3px; }
.legend-3 { background: #f8c8b8; padding: 0 4px; border-radius: 3px; }
.legend-pref-1 { background: #d8f0d2; padding: 0 4px; border-radius: 3px; }
.legend-pref-2 { background: #a8dca0; padding: 0 4px; border-radius: 3px; }

/* Pin (🕐) button — yellow when activity has fixed times; small sup count */
.pin-btn {
  border: 1px solid var(--border-strong); background: #fff; color: inherit;
  border-radius: 6px; padding: 2px 6px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 1px;
}
.pin-btn:hover { background: #f4f4f8; }
.pin-btn.has-pins { background: #fff4b3; border-color: #d6c460; }
.pin-btn sup { font-size: 9px; font-weight: 600; color: #6a4900; }
.pin-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-height: 50vh; overflow-y: auto; }
.pin-list .pin-row { display: flex; align-items: center; gap: 6px; }
.pin-list .pin-row select { padding: 3px 6px; }
.pin-list .pin-del { padding: 0 6px; }

/* Inline "assigned-to" — chips + picker living on the activity's row */
.share-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.share-inline .group-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 1px 6px; background: #fff; border: 1px solid var(--border-strong);
  border-radius: 10px; font-size: 11px; line-height: 1.4;
}
.share-inline .group-chip.primary { background: #fff8d6; border-color: #d6c460; }
.share-inline .group-chip .x { cursor: pointer; color: #b53; padding: 0 1px; }
.share-inline .group-chip .x:hover { color: #800; }
.share-inline .add-share { font-size: 11px; padding: 1px 4px; }
.activity.linked, .split-activity.linked { border-style: dashed; opacity: 0.95; }
.activity.linked::before, .split-activity.linked::before {
  content: "🔗"; opacity: 0.7; margin-right: 4px;
}

/* Split activity (sets of subjects; students pick a set) */
.split-activity {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fbfaf6;
}
.split-activity .split-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #f4efe1;
  border-radius: 8px 8px 0 0;
}
.split-activity .split-tag {
  background: #b45309; color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 4px;
}
.split-activity .set-tag {
  background: #6b7280; color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 4px;
}
.split-activity .split-name, .split-activity .set-name {
  font: inherit; font-weight: 600;
  border: 1px solid transparent; background: transparent;
  border-radius: 4px; padding: 2px 6px;
}
.split-activity .split-name { min-width: 160px; }
.split-activity .set-name { min-width: 60px; }
.split-activity .split-name:hover, .split-activity .set-name:hover { border-color: var(--border); }
.split-activity .split-name:focus, .split-activity .set-name:focus { border-color: var(--accent); background: #fff; outline: none; }
.split-activity .split-summary, .split-activity .set-summary { color: var(--muted); font-size: 13px; }
.split-activity .split-head .parallel-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.split-activity .split-head .parallel-toggle input[type=checkbox] { margin: 0; }
.split-activity .split-head .parallel-toggle input[disabled] + * { opacity: 0.6; }
.split-activity .split-head .add-set { margin-left: auto; }
.split-activity .split-set-head .add-item { margin-left: auto; }
.split-activity .split-sets { padding: 6px 12px 8px; }
.split-activity .split-set + .split-set { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.split-activity .split-set-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.split-activity .split-items { padding-left: 18px; }
.split-activity .split-item {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  padding: 4px 8px;
}
.split-activity .split-item > * { flex: 0 0 auto; }
.split-activity .split-item + .split-item { border-top: 1px dashed var(--border); }
.split-activity .split-item select, .split-activity .split-item input[type=number] {
  border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 6px; font: inherit;
}
.split-activity .split-item .counter input { width: 48px; }
.split-activity .split-item .t-teacher-cell {
  display: flex; align-items: center; gap: 6px;
  flex: 1 1 320px;     /* same wrap-as-a-unit behaviour as singles */
  min-width: 0;
}
.split-activity .split-item .t-teacher-cell .t-room { max-width: 16ch; }
.split-activity .split-item .t-teacher-drop {
  flex: 1 1 auto;
  border: 1.5px dashed var(--border-strong);
  border-radius: 6px;
  padding: 4px 6px;
  min-height: 30px;
  min-width: 140px;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.split-activity .split-item .t-teacher-drop.drag-over { background: var(--drag-over); border-color: #d97706; }
.split-activity .split-item .t-teacher-drop .placeholder { color: var(--muted); font-size: 11px; }

/* Inherited (read-only) activities surfaced from a parent year/group */
.inherited-acts .locked {
  opacity: 0.55;
  pointer-events: none;
  filter: saturate(0.6);
}
.inherited-acts .inherited-block + .inherited-block { margin-top: 12px; }
.inherited-acts .inherited-block-label { margin: 4px 0; }

.teacher-drop {
  grid-column: 1 / -1;
  border: 1.5px dashed var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  min-height: 36px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.teacher-drop.drag-over { background: var(--drag-over); border-color: #d97706; }
.teacher-drop .placeholder { color: var(--muted); font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip); color: var(--chip-text);
  padding: 3px 8px; border-radius: 999px;
  font-size: 12px;
}
.chip.teacher { background: var(--teacher); color: var(--teacher-text); }
.chip.teacher.auto { font-style: italic; opacity: 0.85; border: 1px dashed currentColor; }
.chip.teacher.hard { box-shadow: inset 0 0 0 2px #b91c1c; font-weight: 700; }
.chip.teacher.hard::before { content: '🔒 '; }
.hard-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; color: var(--muted); cursor: pointer; user-select: none;
}
.hard-toggle input { margin: 0; }
.hard-toggle.t-sameas-wrap { gap: 3px; }
.hard-toggle.t-sameas-wrap .t-sameas {
  max-width: 160px; font-size: 11px; padding: 1px 4px;
  border: 1px solid var(--border); border-radius: 3px;
}

/* Teacher cell when sameTeacherAs is set: visually mute every control
   inside (chips, remove ×, picker, drag-drop, 🔒) so the user can't
   edit a teacher whose value is forced by another activity. The 🔗
   picker that lives in the parent .teacher-cell row OUTSIDE this drop
   stays enabled so the user can clear the link. */
.teacher-cell-linked {
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 6px;
  padding: 4px;
  position: relative;
}
.teacher-cell-linked > *:not(.teacher-linked-badge) {
  opacity: 0.55;
  pointer-events: none;
}
.teacher-linked-badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  color: #78350f;
  background: #fde68a;
  padding: 1px 6px;
  border-radius: 3px;
  margin: 0 4px 2px 0;
  vertical-align: middle;
}

/* Linked subject-row inside a split — visual mirror of the target's
   lesson, read-only. */
.split-item-linked {
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px;
  padding: 4px 8px; display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.split-item-linked.dead { background: #fef2f2; border-color: #fecaca; }
.split-item-linked .link-badge {
  background: #0284c7; color: #fff; font-weight: 600;
  padding: 2px 6px; border-radius: 3px; font-size: 11px;
}
.split-item-linked .linked-subj { font-weight: 600; }
.split-item-linked .linked-pw { color: var(--muted); font-size: 11px; }
.split-item-linked .linked-teachers { flex: 1; }

/* Link-picker dialog — modal list of activities to link to. */
#dlgLinkSubject { width: min(640px, 92vw); }
.dlg-link-pick #linkPickSearch {
  width: 100%; padding: 4px 8px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 13px;
}
.dlg-link-pick .link-pick-body {
  list-style: none; margin: 8px 0; padding: 0;
  max-height: 55vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 4px;
}
.dlg-link-pick .link-pick-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; cursor: pointer; font-size: 12px;
  border-bottom: 1px dotted #e5e7eb;
}
.dlg-link-pick .link-pick-row:hover { background: #f3f4f6; }
.dlg-link-pick .link-pick-row.selected {
  background: #dbeafe; color: #1e3a8a; font-weight: 600;
}
.dlg-link-pick .link-pick-label { flex: 1; }
.dlg-link-pick .link-pick-dist {
  font-family: ui-monospace, monospace; font-size: 10px;
}
.sat-settings { display: inline-block; position: relative; }
.sat-settings > summary {
  cursor: pointer; padding: 4px 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; list-style: none; font-size: 14px;
}
.sat-settings > summary::-webkit-details-marker { display: none; }
.sat-settings[open] > summary { background: #fef3c7; border-color: #fcd34d; }
.sat-settings-body {
  position: absolute; top: 100%; right: 0; z-index: 10;
  display: grid; gap: 6px;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); margin-top: 4px;
  width: min(460px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
}
.sat-settings-body .sat-row {
  display: grid;
  grid-template-columns: 100px 60px minmax(0, 1fr);
  align-items: center; column-gap: 8px;
  padding: 4px 6px; border-radius: 4px;
}
.sat-settings-body .sat-row label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.sat-settings-body .sat-row .sat-name { font-weight: 600; color: #111; }
.sat-settings-body .sat-row input {
  width: 60px; padding: 2px 4px; text-align: right; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 4px;
}
.sat-settings-body .sat-row .sat-sign { font-size: 11px; font-weight: 600; }
.sat-settings-body .sat-row .sat-desc { font-size: 11px; color: #4b5563; line-height: 1.3; white-space: normal; }
.sat-settings-body .sat-row.pos { background: #ecfdf5; }
.sat-settings-body .sat-row.pos .sat-sign { color: #047857; }
.sat-settings-body .sat-row.neg { background: #fef2f2; }
.sat-settings-body .sat-row.neg .sat-sign { color: #b91c1c; }
.sat-settings-body .sat-row.neutral { background: #f3f4f6; }
.sat-settings-body .sat-row.neutral .sat-sign { color: #6b7280; }
.sat-settings-body .sat-actions { text-align: right; }
.chip.room { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.chip.room .x { color: #075985; opacity: 0.7; cursor: pointer; padding: 0 2px; }
.chip.room .x:hover { opacity: 1; color: #b91c1c; }
/* Home-room link chip: emerald tone + dashed border to read as "linked".
   The 🏠 emoji already lives in the chip body. */
.chip.room.home-link { background: #d1fae5; color: #065f46;
                       border: 1px dashed #34d399; }
.chip.room.home-link .x { color: #065f46; }
.room-cell { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.room-cell .room-pick { font-size: 11px; padding: 1px 4px; max-width: 14ch; }
/* Compact dropdown that lives inside a teacher drop-zone — lets the user
 pick a qualified teacher instead of dragging from the side panel. */
.teacher-pick {
  font-size: 11px; padding: 1px 4px;
  border: 1px solid var(--border-strong); background: #fff; color: inherit;
  border-radius: 6px; cursor: pointer; max-width: 18ch;
}
.teacher-pick:disabled { opacity: 0.4; cursor: not-allowed; }
.teacher-drop .teacher-pick { margin-left: 2px; }
.chip .x {
  cursor: pointer; color: inherit; opacity: .6;
}
.chip .x:hover { opacity: 1; }

/* Side column */
.side-col { overflow: auto; }
.chip-list {
  list-style: none; margin: 0; padding: 8px 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip-list li {
  background: var(--teacher); color: var(--teacher-text);
  padding: 4px 8px; border-radius: 999px;
  cursor: grab; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #cffafe;
}
.chip-list li.subject { background: var(--chip); color: var(--chip-text); border-color: #e0e7ff; cursor: default; }
.chip-list li.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-list li:active { cursor: grabbing; }
.chip-list li .x {
  cursor: pointer; opacity: .6;
}
.chip-list li .x:hover { opacity: 1; }

/* Dialog */
/* Static-mode banner: shown when window.FETJS_STATIC=true. Sticks at the
   top of the page; dismissible. */
.static-banner {
  background: #fef3c7; color: #78350f; border-bottom: 1px solid #fcd34d;
  padding: 6px 12px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.static-banner a { color: #b45309; font-weight: 600; }
.static-banner button {
  background: transparent; border: 1px solid #fcd34d; border-radius: 4px;
  cursor: pointer; padding: 1px 8px; color: #78350f; font-size: 12px;
}
/* Solver buttons disabled in static mode: keep the layout but signal that
   they're inactive. */
.static-disabled {
  opacity: 0.55; cursor: not-allowed;
  filter: grayscale(0.5);
}

.lang-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.lang-flag {
  display: inline-flex; align-items: center; line-height: 1;
}
.lang-flag .flag-svg {
  width: 20px; height: 14px;
  border: 1px solid rgba(0,0,0,0.15); border-radius: 2px;
  display: block;
}
.lang-toggle select {
  padding: 2px 4px; font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  background: #fff;
}

dialog {
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 0;
  /* Hard viewport cap so no dialog can spill off-screen, regardless of how
     tall its content grows. Combined with .dlg's own min-width clamp this
     keeps every dialog visually bounded. */
  max-width: 94vw; max-height: 92vh;
  box-sizing: border-box;
}
dialog::backdrop { background: rgba(0,0,0,.3); }
.dlg {
  padding: 16px; min-width: min(360px, 94vw);
  max-width: 94vw; max-height: 92vh; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 10px;
  overflow: auto;
}
.dlg h3 { margin: 0; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.dlg textarea {
  font: inherit; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px; resize: vertical;
}
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; align-items: center; }
.dlg-actions a.btn-like { margin-right: auto; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 6px; text-decoration: none; color: inherit; }

.dlg-wide { min-width: 640px; max-width: 90vw; }
.dlg h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }

/* ---- Unified Schedule Settings dialog ----
   Constrained to the viewport so it can never spill off-screen no matter
   how tall the content grows. The body is a scrollable grid; head + foot
   stay pinned (sticky) so the user always has a visible close button. */
#dlgSettings {
  width: min(960px, 94vw);
  max-width: 94vw;
  max-height: 92vh;
  padding: 0;
}
.dlg-settings-form {
  display: flex; flex-direction: column;
  max-height: 92vh;
  padding: 0; gap: 0;
  /* Override .dlg's overflow:auto — the sticky head/foot need a single
     internal scroller (.dlg-settings-body), not a scrolling form. */
  overflow: hidden;
}
.dlg-settings-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: #fff;
}
.dlg-settings-head h3 { margin: 0; font-size: 16px; }
.dlg-settings-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding: 12px 16px;
  overflow-y: auto;  /* the one and only scroller */
  flex: 1 1 auto;
  min-height: 0;
}
.dlg-settings-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: #fff;
}
.settings-section {
  background: #fafbfc; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
}
.settings-section h4 {
  margin: 0 0 6px 0; font-size: 12px; text-transform: uppercase;
  letter-spacing: .3px; color: var(--muted);
}
.settings-section label {
  display: flex; align-items: center; gap: 6px;
  margin: 4px 0; font-size: 12px; color: var(--text);
  flex-direction: row;  /* override .dlg label column layout */
}
.settings-section input[type=number] {
  width: 70px; padding: 2px 4px; font-size: 12px;
}
.settings-section input[type=checkbox] { margin: 0; }
.settings-section-wide { grid-column: 1 / -1; }
/* Scope picker inside the settings modal — laid out as a wrapping grid
   of year checkboxes + a Clear button, all inline (NOT a floating
   popup like the schedule-controls version). */
.scope-section .scope-years-grid {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 4px 0 0;
}
.scope-section .scope-years-grid label.scope-year {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0; padding: 2px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; cursor: pointer;
}
.scope-section .scope-years-grid label.scope-year:hover { background: #f1f5f9; }
.scope-section .scope-years-grid label.scope-year:has(input:checked) {
  background: #dbeafe; border-color: #93c5fd; color: #1e40af;
}
.scope-section .scope-years-grid #scopeYearsClear {
  margin-left: auto; font-size: 11px; padding: 2px 8px;
}
.ghost-mini { font-size: 11px; padding: 2px 6px; }
.dlg-settings-body .sat-settings-body {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px 12px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.filetable { width: 100%; border-collapse: collapse; font-size: 13px; }
.filetable th, .filetable td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.filetable th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
.filetable td.actions { white-space: nowrap; text-align: right; }
.filetable td.actions button, .filetable td.actions a { margin-left: 4px; }
.filetable .muted { color: var(--muted); }
.status-pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.status-pill.running { background: var(--drag-over); color: #92400e; }
.status-pill.done { background: #dcfce7; color: #166534; }
.status-pill.error, .status-pill.timeout { background: #fee2e2; color: #991b1b; }
.status-pill.unknown { background: #f3f4f6; color: var(--muted); }

.qual-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qual-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; cursor: pointer;
  background: #fff;
  user-select: none;
}
.qual-chip input { display: none; }
.qual-chip.on { background: var(--chip); color: var(--chip-text); border-color: #c7d2fe; }
.qual-chip.allow.on { background: #d1fae5; color: #064e3b; border-color: #6ee7b7; }
.qual-chip.pref.on { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.qual-chip.disallow.on { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.pref-only-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 12px; color: #4b5563;
}
.mini-chip.pref-only { background: #fde68a; color: #78350f; }
.tutor-tag {
  display: inline-block; background: #ecfeff; color: #155e75;
  border: 1px solid #67e8f9; border-radius: 3px;
  padding: 1px 6px; font-size: 11px; font-weight: 600;
}
.teachers-table td.under { color: #047857; }
.teachers-table td.over  { color: #b91c1c; font-weight: 600; }
.extra-list { display: flex; flex-direction: column; gap: 4px; }
.extra-row {
  display: flex; gap: 6px; align-items: center;
}
.extra-row .ex-name { flex: 1 1 auto; min-width: 0; }
.extra-row .ex-hours { width: 80px; }
.extra-row .ex-del { padding: 2px 6px; }
.teachers-table th.sortable { cursor: pointer; user-select: none; }
.teachers-table th.sortable:hover { background: #e7e9ef; }
.teachers-table th.sortable .sort-ind { color: var(--muted); font-size: 10px; margin-left: 2px; }
.teachers-table th.sortable.sorted[data-dir="-1"] .sort-ind::before { content: '▼'; color: #111; }
.teachers-table th.sortable.sorted[data-dir="1"]  .sort-ind::before { content: '▲'; color: #111; }
.diagnose-out { margin-top: 10px; padding: 10px; background: #fffaf2; border: 1px solid #fde68a; border-radius: 6px; }
.diagnose-out .diag-summary { margin-bottom: 6px; }
.diagnose-out .diag-list { list-style: none; padding: 0; margin: 0; }
.diagnose-out .diag-row { padding: 6px 8px; margin: 4px 0; background: #fff; border-left: 3px solid #b91c1c; border-radius: 3px; }
.diagnose-out .diag-row.diag-warning { border-left-color: #d97706; }
.diagnose-out .diag-empty { padding: 6px 0; }
.qual-chip.disallow.on.implicit {
  background: #f3f4f6; color: #6b7280; border-color: #d1d5db;
  font-style: italic; cursor: not-allowed;
}
.qual-chip:hover { background: #f1f3f7; }
.qual-chip.on:hover { background: #dde2ff; }

.vsep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.topbar #currentFile { font-style: italic; }

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex: 0 0 auto;
}
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 14px; cursor: pointer;
  color: var(--muted); font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Teachers / Subjects tab layouts */
.layout.one-col { grid-template-columns: 1fr; }
.subjects-layout { grid-template-columns: 1fr; }

.filetable th.chev, .filetable td.chev {
  width: 22px; text-align: center; color: var(--muted);
  font-size: 11px; padding-left: 6px; padding-right: 0;
}
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: #f1f3f7; }
.row-clickable.expanded { background: var(--accent-soft); }
.row-clickable.expanded td.chev { color: var(--accent); }

.expand-row > td {
  padding: 14px 22px;
  background: #fafbff;
  border-bottom: 1px solid var(--border-strong);
}
.expand-row .breadcrumbs { display: none; }
.expand-row h2 { display: none; }
.scroll-y { overflow-y: auto; }
.col-header .search {
  font: inherit; padding: 4px 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; margin-right: 6px; min-width: 160px;
}
.col-header .subj-filter {
  font: inherit; padding: 4px 8px; border: 1px solid var(--border-strong);
  border-radius: 6px; margin-right: 6px; max-width: 220px; background: #fff;
}

.teachers-table tr, .subjects-table tr { cursor: pointer; }
.teachers-table .t-weight {
  width: 60px; padding: 2px 4px; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 4px; text-align: right;
  cursor: text;
}
.teachers-table tr.selected, .subjects-table tr.selected { background: var(--accent-soft); }
.teachers-table td.muted, .subjects-table td.muted { color: var(--muted); }
.teachers-table td .mini-chips, .subjects-table td .mini-chips {
  display: flex; flex-wrap: wrap; gap: 3px;
}
.mini-chip {
  display: inline-block; font-size: 11px;
  background: var(--chip); color: var(--chip-text);
  padding: 1px 6px; border-radius: 999px;
}
.mini-chip.teacher { background: var(--teacher); color: var(--teacher-text); }
.over { color: var(--danger); font-weight: 600; }
.under { color: var(--ok); }

/* Year tree view in detail pane */
.year-tree { padding: 4px 0; }
.year-tree .level {
  margin: 6px 0 6px 0;
  padding: 8px 10px;
  border-left: 2px solid var(--border);
  background: #fcfcfd;
  border-radius: 0 6px 6px 0;
}
.year-tree .level.kind-group { border-left-color: #93c5fd; }
.year-tree .level.kind-subgroup { border-left-color: #c4b5fd; margin-left: 16px; }
.year-tree .level-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.year-tree .level-head .kind {
  font-size: 10px; text-transform: uppercase; color: var(--muted);
  background: #fff; border: 1px solid var(--border); padding: 1px 6px; border-radius: 999px;
}
.year-tree .level-head .name {
  font-weight: 600; cursor: pointer;
}
.year-tree .level-head .name:hover { color: var(--accent); }
.year-tree .level-head .stats { color: var(--muted); font-size: 12px; }
.year-tree .level-head .add-btn { margin-left: auto; }
.year-tree .acts { display: flex; flex-direction: column; gap: 2px; padding-left: 4px; }
.year-tree .act-row {
  display: flex; align-items: center; gap: 8px; padding: 2px 4px;
  font-size: 13px;
}
.year-tree .act-row .subj { font-weight: 500; min-width: 140px; }
.year-tree .act-row .pw { color: var(--muted); font-variant-numeric: tabular-nums; }
.year-tree .level .empty-row { color: var(--muted); font-size: 12px; padding: 2px 4px; }

/* Time preferences grid (year detail) */
.time-prefs-grid { border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.time-prefs-grid th, .time-prefs-grid td { border: 1px solid var(--border); padding: 2px; text-align: center; }
.time-prefs-grid thead th { background: #fafbfc; font-weight: 500; padding: 4px 8px; color: var(--muted); }
.time-prefs-grid tbody th { background: #fafbfc; padding: 4px 8px; font-weight: 500; color: var(--muted); text-align: right; }
.time-prefs-grid input { width: 48px; padding: 2px 4px; border: 1px solid transparent; border-radius: 4px; text-align: center; font: inherit; background: transparent; }
.time-prefs-grid input:focus { border-color: var(--accent); background: #fff; outline: none; }
.time-prefs-grid input.tp-100 { color: var(--ok); }
.time-prefs-grid input.tp-90 { color: #4d7c0f; background: #f7fee7; }
.time-prefs-grid input.tp-70 { color: #a16207; background: #fef9c3; }
.time-prefs-grid input.tp-50 { color: #b45309; background: #fef3c7; }
.time-prefs-grid input.tp-low { color: var(--danger); background: #fee2e2; }

/* Schedule tab */
.schedule-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Grouped control bar — each .ctrl-group is a fieldset-like cluster with a
   tiny label, an inner row of buttons/inputs, and dashed dividers between
   sub-actions when needed (e.g. Improve vs SA vs Rescore inside Polish). */
.schedule-controls .ctrl-group {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 4px 10px 4px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: #fafbff; position: relative;
}
.schedule-controls .ctrl-group[data-group="generate"] { background: #eff6ff; }
.schedule-controls .ctrl-group[data-group="run"]      { background: #f7f4ee; }
.schedule-controls .ctrl-group[data-group="polish"]   { background: #fff4f7; }
.schedule-controls .ctrl-group[data-group="view"]     { background: #f1faf3; }
.schedule-controls .ctrl-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  padding-right: 2px; align-self: center;
}
.schedule-controls .ctrl-sep {
  width: 0; height: 18px; border-left: 1px dashed var(--border);
  margin: 0 2px;
}
#scheduleGenStatus { white-space: pre-line; line-height: 1.45; }
.score-badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc;
  font-weight: 500;
}
.score-badge b { font-weight: 700; color: #0c4a6e; font-size: 13px; }
.score-badge.unsolved   { background: #fef2f2; color: #7d2b2b; border-color: #f3c6c6; }
.score-badge.ok         { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.score-badge.incomplete { background: #fff7ed; color: #9a3412; border-color: #fed7aa; font-weight: 700; }
.score-badge.in-progress {
  background: #fefce8; color: #854d0e; border-color: #fde68a;
  animation: in-progress-pulse 1.6s ease-in-out infinite;
}
@keyframes in-progress-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.consec-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 6px;
  cursor: pointer; user-select: none; font-size: 12px;
}
.consec-toggle:has(input:checked) { background: #d1fae5; border-color: #6ee7b7; }
.improve-budget {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 6px;
  font-size: 12px; color: var(--muted);
}
.improve-budget input,
.gen-budget input {
  width: 48px; padding: 2px 4px; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 4px; text-align: right;
}
.gen-budget {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 6px;
  font-size: 12px; color: var(--muted);
}
.warm-hint-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 6px;
  cursor: pointer; user-select: none; font-size: 13px;
}
.warm-hint-toggle:has(input:checked) { background: #fff8d6; border-color: #d6c460; }
.scope-picker { position: relative; }
.scope-picker > summary {
  cursor: pointer; padding: 4px 10px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: #fff; user-select: none;
  list-style: none;
}
.scope-picker > summary::-webkit-details-marker { display: none; }
.scope-picker[open] > summary { background: var(--accent-soft); border-color: var(--accent); }
.scope-body {
  position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 10;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,.08);
  display: flex; flex-direction: column; gap: 4px; min-width: 140px;
}
.scope-year { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.scope-year input { margin: 0; }
.schedule-controls select { border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 6px; font: inherit; }
.schedule-grid { padding: 12px; overflow: auto; max-height: calc(100vh - 220px); }
.schedule-grid.empty { color: var(--muted); }
.schedule-unsolved { padding: 16px 18px; border-radius: 8px; background: #fff4f4; border: 1px solid #f3c6c6; color: #7d2b2b; max-width: 720px; }
.schedule-unsolved h3 { margin: 0 0 8px 0; font-size: 16px; }
.schedule-unsolved p { margin: 0; line-height: 1.45; }

/* Overview matrix — rows = classes or teachers, columns = (day, period) */
.overview-matrix {
  border-collapse: collapse;
  font-size: 10px;
  table-layout: fixed;
}
.overview-matrix th, .overview-matrix td {
  border: 1px solid var(--border);
  padding: 2px 3px;
  vertical-align: top;
  word-break: break-word;
}
.overview-matrix .ov-row {
  position: sticky; left: 0; z-index: 2;
  background: #f1f3f7; font-weight: 600; text-align: left;
  min-width: 110px; max-width: 140px;
}
.overview-matrix thead th {
  position: sticky; z-index: 3;
  background: #f1f3f7;
}
/* Stack the two header rows: day-names at top, period-names below them.
   The first row's height ≈ 22px on default font; bump if you change the
   header font-size. */
.overview-matrix thead tr:first-child th  { top: 0;    height: 22px; }
.overview-matrix thead tr:nth-child(2) th { top: 22px; }
/* The empty top-left corner TH belongs to both sticky axes (top for the
   header row, left for the row labels) — bump its z-index so it covers
   both stripes when scrolling. */
.overview-matrix thead tr:first-child th.ov-row,
.overview-matrix thead tr:nth-child(2) th.ov-row { z-index: 4; left: 0; }
.overview-matrix .ov-dayhdr { text-align: center; }
.overview-matrix .ov-col { min-width: 38px; text-align: center; color: var(--muted); font-weight: 500; }
.overview-matrix .ov-cell { width: 56px; min-height: 32px; padding: 1px; }
.overview-matrix .ov-cell.filled { background: transparent; }
.overview-matrix .ov-cell.multi { background: repeating-linear-gradient(135deg, rgba(0,0,0,0.04) 0 3px, transparent 3px 6px); }
.overview-matrix .ov-item {
  display: block; border: 1px solid rgba(0,0,0,0.12); border-radius: 2px;
  padding: 1px 3px; margin: 1px 0; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.overview-matrix .ov-item .ov-room {
  display: inline-block; background: #1e40af; color: #fff;
  font-size: 8px; padding: 0 3px; border-radius: 2px; margin-right: 2px;
  font-weight: 600; vertical-align: middle;
}
.overview-matrix .ov-item .ov-subj { font-weight: 500; }
.overview-matrix .ov-item .ov-meta {
  display: block; font-size: 8px; color: #4b5563;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.overview-matrix .day-start { border-left: 2px solid var(--accent); }
/* Year-wide cells (rowspan'd across all that year's leaf rows). Distinct
   indigo wash so the merge is visually obvious. */
.overview-matrix td.ov-cell.year-wide {
  background: #eef2ff;
  border-left: 2px solid #6366f1; border-right: 2px solid #6366f1;
}

/* Print mode: every schedule view stitched into a single multi-page
   document. The #printRoot is added on click and removed afterprint;
   `body.printing` switches the layout. */
#printRoot { display: none; }
.print-page { page-break-before: always; padding: 8px 0; }
.print-page:first-of-type, .print-cover + .print-page { page-break-before: auto; }
.print-page-title {
  margin: 0 0 8px 0; font-size: 14px; color: #1e3a8a;
  border-bottom: 1px solid #c7d2fe; padding-bottom: 4px;
}
.print-cover { padding: 24px 12px; }
.print-cover h1 { margin: 0 0 8px 0; font-size: 22px; }
.print-cover .print-meta { font-size: 12px; color: #374151; }
.print-cover .cov-weights { margin-top: 18px; }
.print-cover .cov-weights h3 {
  font-size: 12pt; margin: 0 0 6px 0; color: #1e3a8a;
  border-bottom: 1px solid #c7d2fe; padding-bottom: 2px;
}
.cov-weights-table {
  width: 100%; border-collapse: collapse; font-size: 9pt;
}
.cov-weights-table th {
  text-align: left; padding: 3px 6px; border-bottom: 1px solid #d1d5db;
  font-size: 8pt; color: #6b7280; text-transform: uppercase;
  letter-spacing: .3px;
}
.cov-weights-table td { padding: 2px 6px; vertical-align: top; }
.cov-weights-table td.cov-w-k { font-family: ui-monospace, monospace; }
.cov-weights-table td.cov-w-v {
  text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap; width: 1%; font-weight: 600;
}
.cov-weights-table td.cov-w-d { color: #4b5563; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body.printing > :not(#printRoot) { display: none !important; }
  body.printing #printRoot { display: block !important; }
  /* Schedule grids use sticky headers for on-screen scrolling — turn
     them off in print so they don't double-render on every page. */
  body.printing .schedule-grid table.sched thead th,
  body.printing .overview-matrix thead th,
  body.printing .overview-matrix .ov-row {
    position: static !important;
  }
  /* Compress sizing so wide matrices fit on landscape A4. */
  body.printing .overview-matrix { font-size: 7.5pt; }
  body.printing .overview-matrix .ov-col { min-width: 0; }
  body.printing .overview-matrix .ov-cell { width: auto; min-height: 0; }
  body.printing .overview-matrix .ov-item {
    padding: 0 2px; line-height: 1.1; white-space: nowrap;
  }
  body.printing .schedule-grid { padding: 0; max-height: none; overflow: visible; }
  body.printing .print-cfg-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  body.printing .print-cfg-block {
    border: 1px solid #d1d5db; border-radius: 4px; padding: 4px 6px;
    page-break-inside: avoid; break-inside: avoid;
  }
}
.print-cfg-cohort {
  font-weight: 700; font-size: 11pt; color: #1e3a8a;
  border-bottom: 1px solid #c7d2fe; padding-bottom: 2px; margin-bottom: 3px;
}
.print-cfg-table { width: 100%; border-collapse: collapse; font-size: 8pt; }
.print-cfg-table td {
  padding: 1px 4px; vertical-align: top;
  border-bottom: 1px dotted #e5e7eb;
}
.print-cfg-table tr.print-cfg-act-row td,
.print-cfg-table tr.print-cfg-set-row td {
  border-bottom: none; padding-top: 3px;
}
/* Inline set tag — "«A»" prefix on a split-subject row in the print view.
   Per-lane palette gives each set its own colour (matches the bracket
   colour for that lane). Cycles through 6 distinct hues for splits with
   many sets. */
.print-cfg-set-name {
  font-size: 7.5pt; font-weight: 600; margin-right: 3px; color: #1e3a8a;
}
.print-cfg-set-name.print-cfg-set-i0 { color: #1e3a8a; }  /* deep blue   */
.print-cfg-set-name.print-cfg-set-i1 { color: #166534; }  /* forest green */
.print-cfg-set-name.print-cfg-set-i2 { color: #b45309; }  /* amber       */
.print-cfg-set-name.print-cfg-set-i3 { color: #b91c1c; }  /* red         */
.print-cfg-set-name.print-cfg-set-i4 { color: #6d28d9; }  /* purple      */
.print-cfg-set-name.print-cfg-set-i5 { color: #0e7490; }  /* teal        */
/* Splits in the print teacher-config: one bracket (thin vertical rule)
   per LANE — i.e. per set. Consecutive subject rows of the same set are
   connected by one continuous line; between sets the line breaks with
   a visible gap so the lanes are clearly distinguished. The split-title
   row (print-cfg-act-row) is not bracketed, only the subject rows. */
.print-cfg-split-tbody tr:not(.print-cfg-act-row) td:first-child {
  position: relative;
  padding-left: 6px;
}
.print-cfg-split-tbody tr:not(.print-cfg-act-row) td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: #1e3a8a;
}
/* First row of a lane — pull the line down so a gap appears above it. */
.print-cfg-split-tbody tr.print-cfg-set-first td:first-child::before {
  top: 3px;
}
/* Last row of a lane — pull the line up so a gap appears below it. */
.print-cfg-split-tbody tr.print-cfg-set-last td:first-child::before {
  bottom: 3px;
}
/* Bracket colour follows the lane's palette so the name + line agree. */
.print-cfg-split-tbody tr.print-cfg-set-i0 td:first-child::before { background: #1e3a8a; }
.print-cfg-split-tbody tr.print-cfg-set-i1 td:first-child::before { background: #166534; }
.print-cfg-split-tbody tr.print-cfg-set-i2 td:first-child::before { background: #b45309; }
.print-cfg-split-tbody tr.print-cfg-set-i3 td:first-child::before { background: #b91c1c; }
.print-cfg-split-tbody tr.print-cfg-set-i4 td:first-child::before { background: #6d28d9; }
.print-cfg-split-tbody tr.print-cfg-set-i5 td:first-child::before { background: #0e7490; }

/* Print "Teachers" page — flat row-per-teacher list. */
.print-teachers-table {
  width: 100%; border-collapse: collapse; font-size: 8.5pt;
}
.print-teachers-table th {
  text-align: left; padding: 4px 6px; border-bottom: 1.5px solid #1e3a8a;
  background: #eef2ff; color: #1e3a8a; font-size: 8pt;
  text-transform: uppercase; letter-spacing: .3px;
}
.print-teachers-table td {
  padding: 3px 6px; border-bottom: 1px solid #e5e7eb; vertical-align: top;
}
.print-teachers-table td.print-tch-n {
  text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap; width: 1%;
}
.print-teachers-table td.print-tch-quals {
  font-size: 7.5pt; color: #4b5563; line-height: 1.25;
}
.print-teachers-table .print-tch-diff.over  { color: #b45309; font-weight: 700; }
.print-teachers-table .print-tch-diff.under { color: #b91c1c; }
.print-teachers-table .print-tch-diff.ok    { color: #047857; }

/* Auto-built index page (Contents) at the start of the print document. */
.print-index-list {
  list-style: none; padding: 0; margin: 12px 0 0;
  font-size: 11pt; column-count: 2; column-gap: 24px;
}
.print-index-list li {
  padding: 3px 0; border-bottom: 1px dotted #d1d5db;
  break-inside: avoid-column;
}
.print-index-n {
  display: inline-block; width: 24px; color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.print-cfg-pw { width: 24px; text-align: right; font-variant-numeric: tabular-nums; color: #6b7280; }
.print-cfg-teacher {
  display: inline-block; background: #e0e7ff; color: #1e3a8a;
  border-radius: 2px; padding: 0 3px; margin: 0 2px 1px 0; font-size: 7.5pt;
}
.print-cfg-teacher.hard { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.print-cfg-teacher.none { background: #f3f4f6; color: #6b7280; font-style: italic; }
.print-cfg-opt {
  background: #f3e8ff; color: #6d28d9; font-size: 7pt; padding: 0 3px;
  border-radius: 2px; vertical-align: middle;
}
.schedule-grid table.sched { border-collapse: collapse; }
.schedule-grid table.sched th, .schedule-grid table.sched td {
  border: 1px solid var(--border); padding: 2px; vertical-align: top;
  min-width: 80px;
}
.schedule-grid table.sched thead th { background: #f1f3f7; font-weight: 600; position: sticky; top: 0; z-index: 2; }
.schedule-grid table.sched tbody th {
  background: #f8f9fc; font-weight: 500; text-align: right; padding-right: 8px;
  min-width: 56px; position: sticky; left: 0; z-index: 1;
}
.schedule-grid table.sched tbody td {
  /* multiple cell-items lay out side-by-side and wrap */
  white-space: normal;
}
.schedule-grid table.sched .cell-row {
  display: flex; flex-direction: column; gap: 3px;
}
.schedule-grid .cell-item {
  font-size: 10px; line-height: 1.15;
  background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 3px;
  padding: 3px 4px;
  min-width: 0; box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.schedule-grid .cell-item b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.schedule-grid .cell-item .muted.small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 140px; font-size: 9px; }
.schedule-grid .cell-item .set-tag {
  display: inline-block; background: #6b7280; color: #fff;
  font-size: 9px; padding: 0 3px; border-radius: 2px; margin-right: 2px;
}
.schedule-grid .cell-item .room-tag {
  display: inline-block; background: #1e40af; color: #fff;
  font-size: 9px; padding: 0 4px; border-radius: 2px; margin-right: 2px;
  font-weight: 600;
}

.jobs-panel { padding: 6px 12px; }
.jobs-panel .jobs-header { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0; }
.jobs-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.jobs-table th, .jobs-table td { border-bottom: 1px solid var(--border); padding: 3px 6px; text-align: left; vertical-align: top; }
.jobs-table thead th { background: #f8f9fc; color: var(--muted); font-weight: 500; }
.jobs-table .job-state { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.jobs-table .job-state.running { background: #fef3c7; color: #92400e; }
.jobs-table .job-state.ok { background: #d1fae5; color: #065f46; }
.jobs-table .job-state.fail { background: #fee2e2; color: #991b1b; }

.rescore-panel {
  padding: 8px 12px; margin: 4px 12px;
  background: #f8f9fc; border: 1px solid var(--border); border-radius: 6px;
}
.rescore-header { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.rescore-delta {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px;
  background: #e5e7eb; color: #374151;
}
.rescore-delta.better { background: #d1fae5; color: #065f46; }
.rescore-delta.worse  { background: #fee2e2; color: #991b1b; }
.rescore-table { width: auto; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.rescore-table th, .rescore-table td { border-bottom: 1px solid var(--border); padding: 3px 12px 3px 6px; text-align: left; }
.rescore-table thead th { background: #f1f3f9; color: var(--muted); font-weight: 500; }
.rescore-table .rescore-w { text-align: right; font-family: ui-monospace, monospace; color: var(--muted); }
.rescore-table .rescore-v { text-align: right; font-family: ui-monospace, monospace; }
.rescore-table tfoot td { padding-top: 6px; border-top: 2px solid var(--border); }

/* Dedicated "Teacher assignments" view inside the schedule grid area:
   teacher-load summary table at top, then a multi-column cohort grid. */
.assignments-view { padding: 8px 12px; font-size: 12px; }
.assignments-summary-table { font-size: 12px; margin: 0 0 14px 0; border-collapse: collapse; }
.assignments-summary-table th,
.assignments-summary-table td { padding: 2px 8px; border-bottom: 1px solid var(--border); }
.assignments-summary-table thead th { background: #f1f3f9; text-align: left; }
.assignments-summary-table .cfg-diff.over  { color: #b45309; font-weight: 700; }
.assignments-summary-table .cfg-diff.under { color: #b91c1c; }
.assignments-summary-table .cfg-diff.ok    { color: #047857; }
.assignments-view .cfg-cohort-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}
.assignments-view .cfg-cohort-block {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px;
}
.assignments-view .cfg-cohort-name {
  font-size: 13px; border-bottom: 1px solid #c7d2fe;
  padding-bottom: 4px; margin-bottom: 4px; color: #1e3a8a;
}
/* Hierarchical compact cohort tree (Year > Group > Subgroup). One row per
   activity, all activities inline. Indent grows by depth via .cv-d{N}. */
.assignments-view .cv-tree { font-size: 12px; }
.assignments-view .cv-node { margin: 0; padding: 0; }
.assignments-view .cv-d0 {
  border-top: 1px solid var(--border-strong); padding-top: 4px; margin-top: 6px;
}
.assignments-view .cv-d0 > .cv-head {
  font-size: 14px; font-weight: 700; color: #1e3a8a;
  padding: 2px 0;
}
.assignments-view .cv-d1 > .cv-head {
  font-size: 12px; font-weight: 600; color: #374151;
  padding: 1px 0 1px 14px;
}
.assignments-view .cv-d2 > .cv-head {
  font-size: 11px; font-weight: 500; color: #6b7280;
  padding: 1px 0 1px 28px;
}
.assignments-view .cv-head { display: flex; gap: 6px; align-items: baseline; }
.assignments-view .cv-acts {
  padding-left: 18px; border-left: 2px solid #e5e7eb; margin-left: 4px;
}
.assignments-view .cv-d1 > .cv-acts { padding-left: 32px; }
.assignments-view .cv-d2 > .cv-acts { padding-left: 46px; }
.assignments-view .cv-act {
  display: flex; align-items: baseline; gap: 6px; padding: 1px 0;
  font-size: 12px; border-bottom: 1px dotted #e5e7eb;
}
.assignments-view .cv-act:last-child { border-bottom: none; }
.assignments-view .cv-subj { min-width: 80px; }
.assignments-view .cv-pw {
  font-variant-numeric: tabular-nums; color: var(--muted);
  min-width: 28px; text-align: right;
}
.assignments-view .cv-t { flex: 1; }
/* Splits visually break out from the surrounding dotted-row stream:
   solid border, coloured left accent stripe, tinted background, and the
   set lines inside get their own dashed dividers in the accent colour. */
.assignments-view .cv-split {
  display: block;
  border: 1px solid #c7d2fe;
  border-left: 3px solid #6366f1;
  background: #f5f7ff;
  border-radius: 4px;
  padding: 3px 6px;
  margin: 4px 0;
}
.assignments-view .cv-split-name { font-weight: 600; color: #3730a3; }
.assignments-view .cv-set {
  padding: 2px 0 2px 12px; font-size: 11px; color: #4b5563;
  border-top: 1px dashed #c7d2fe; margin-top: 2px;
}
.assignments-view .cv-split > .cv-set:first-of-type {
  border-top: none; margin-top: 2px;
}
.assignments-view .cv-set-name { color: #6366f1; font-weight: 600; margin-right: 4px; }
.assignments-view .cfg-table { width: 100%; border-collapse: collapse; }
.assignments-view .cfg-table td { padding: 2px 4px; vertical-align: top; border-bottom: 1px dotted var(--border); }
.assignments-view .cfg-table tr.cfg-act-row td,
.assignments-view .cfg-table tr.cfg-set-row td { border-bottom: none; padding-top: 4px; }
.assignments-view .cfg-set-name { font-size: 11px; color: var(--muted); padding-left: 8px; }
.assignments-view .cfg-pw { width: 32px; text-align: right; font-variant-numeric: tabular-nums; }
.assignments-view .cfg-teacher { display: inline-block; background: #e0e7ff; color: #1e3a8a; border-radius: 3px; padding: 0 4px; margin: 1px 3px 1px 0; font-size: 11px; }
.assignments-view .cfg-teacher.hard { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.assignments-view .cfg-teacher.none { background: #e5e7eb; color: #6b7280; font-style: italic; border: 1px dashed #9ca3af; }
.assignments-view .cfg-opt { background: #f3e8ff; color: #6d28d9; font-size: 9px; padding: 0 4px; border-radius: 3px; vertical-align: middle; }

/* Run "⚙ used" chip — shows the weights/config the run was solved with.
   Lives inline in the schedule meta strip; opens a small popover table. */
.run-settings { display: inline-block; position: relative; }
.run-settings > summary {
  cursor: pointer; padding: 2px 8px; border-radius: 4px;
  background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe;
  font-size: 12px; list-style: none;
}
.run-settings > summary::-webkit-details-marker { display: none; }
.run-settings[open] > .run-settings-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  min-width: 320px; max-height: 70vh; overflow: auto;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 8px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.run-settings-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.run-settings-table th {
  text-align: left; font-size: 11px; color: var(--muted);
  padding: 4px 4px 2px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .3px;
}
.run-settings-table td { padding: 2px 4px; vertical-align: top; }
.run-settings-table td.num { font-variant-numeric: tabular-nums; text-align: right; }

.prov-badge {
  font-size: 12px; padding: 2px 8px; border-radius: 4px;
  background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe;
}
.prov-badge code { background: rgba(255,255,255,0.6); padding: 0 3px; border-radius: 2px; }

.mini-chip.last-of-day {
  background: #fef3c7; color: #92400e; border-color: #fcd34d;
}

.chip.teacher.no-teacher {
  background: #e5e7eb; color: #374151; border: 1px dashed #9ca3af;
  font-style: italic;
}

/* Compact "max days" optional input on the Subject detail panel.
   Sits inline with the lastOfDay toggle; deliberately small + neutral
   because it's an opt-in advanced control. */
.subj-maxd {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 14px; font-size: 12px; color: var(--muted);
}

/* Inline unit hint after a numeric input — same colour as the static
   labels on other gen-budget inputs but live-updated by JS. */
.gen-budget .unit-hint {
  display: inline-block; min-width: 28px; font-variant-numeric: tabular-nums;
  text-align: left;
}
.subj-maxd input {
  width: 38px; padding: 2px 4px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 4px;
}

/* Two-phase: phase-2 room matching couldn't place this lesson. Highlight
   the cell with a red dashed border + an inline ⚠ no-room tag. */
.cell-item.unmatched-room {
  outline: 2px dashed #dc2626; outline-offset: -2px;
}
/* Linked / shared-lesson placements — chip outlined in blue so the
   reader can see at a glance that this lesson serves more than one
   cohort (sameAs link or extraStudentSetIds). */
.cell-item.linked-activity {
  outline: 2px solid #2563eb; outline-offset: -2px;
  box-shadow: inset 0 0 0 1px rgba(37,99,235,0.18);
}
.cell-item.linked-activity.unmatched-room {
  /* When both apply, the red dashed outline wins; keep the blue inner
     shadow so the "linked" cue isn't lost. */
  outline: 2px dashed #dc2626; outline-offset: -2px;
}

/* ---------- Compare-files modal ---------- */
.dlg-compare { width: min(95vw, 1200px); max-height: 85vh; padding: 0; }
.dlg-compare-form { display: flex; flex-direction: column; gap: 8px; padding: 18px;
                    max-height: 85vh; overflow: hidden; }
.cmp-pickers { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cmp-pickers label { display: inline-flex; flex-direction: column; font-size: 12px; }
.cmp-pickers select { min-width: 280px; padding: 4px 6px; }
.cmp-only-diff { flex-direction: row !important; align-items: center; gap: 6px;
                 font-size: 13px !important; }
.cmp-summary { padding: 4px 0; }
.cmp-result { overflow: auto; flex: 1 1 auto; border: 1px solid #e5e7eb; border-radius: 6px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp-table th, .cmp-table td { padding: 6px 10px; text-align: left;
                               border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.cmp-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1;
                      border-bottom: 2px solid #cbd5e1; }
.cmp-table tr.cmp-diff { background: #fef9c3; }
.cmp-table tr.cmp-diff:hover { background: #fef3c7; }
.cmp-chip { display: inline-block; padding: 2px 8px; margin: 1px;
            border-radius: 10px; background: #e0e7ff; font-size: 11px; }
.cmp-tag { display: inline-block; padding: 1px 6px; border-radius: 8px;
           font-size: 10px; font-weight: 600; }
.cmp-tag.onlyA { background: #dbeafe; color: #1e40af; }
.cmp-tag.onlyB { background: #fce7f3; color: #9d174d; }
.cmp-table .cmp-hour { text-align: right; font-variant-numeric: tabular-nums; width: 56px; }
.cmp-table .cmp-hour-diff { font-weight: 700; color: #b45309; }

/* ---------- Pre-solve warnings pill + list ---------- */
.warn-pill {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 6px;
  padding: 3px 10px; border-radius: 14px;
  background: #fef3c7; color: #92400e;
  border: 1px solid #f59e0b;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.warn-pill:hover { background: #fde68a; }
.warn-pill.hidden { display: none; }
.warn-pill.has-errors { background: #fee2e2; color: #991b1b; border-color: #dc2626; }
.warn-pill .warn-icon { font-size: 13px; }
.dlg-warn { width: min(90vw, 700px); padding: 0; }
.dlg-warn-form { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.warn-list { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto;
             border: 1px solid #e5e7eb; border-radius: 6px; }
.warn-list li { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.warn-list li:last-child { border-bottom: none; }
.warn-list li.warn-error { background: #fef2f2; }
.warn-list li.warn-warn  { background: #fffbeb; }
.warn-cat {
  display: inline-block; padding: 1px 6px; margin-right: 6px;
  background: #e5e7eb; color: #374151;
  border-radius: 6px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.02em;
  vertical-align: 1px;
}

/* ---------- Move-activity picker ---------- */
.move-pick-body .move-section {
  padding: 6px 10px 4px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; background: #f8fafc; border-bottom: 1px solid #e5e7eb;
}
.icon.move-act, .icon.move-item { color: #1e40af; }
.icon.move-act:hover, .icon.move-item:hover { background: #dbeafe; }

/* ---------- Session history dialog ---------- */
.dlg-history { width: min(90vw, 560px); padding: 0; }
.dlg-history-form { padding: 18px; display: flex; flex-direction: column; gap: 10px;
                    max-height: 80vh; overflow: hidden; }
.history-list {
  list-style: none; margin: 0; padding: 0;
  overflow: auto; flex: 1 1 auto;
  border: 1px solid #e5e7eb; border-radius: 6px;
}
.hist-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px; border-bottom: 1px solid #f1f5f9;
  cursor: pointer; user-select: none; font-size: 13px;
}
.hist-row:last-child { border-bottom: none; }
.hist-row:hover { background: #f8fafc; }
.hist-row.current { background: #dcfce7; font-weight: 600; }
.hist-time { font-family: ui-monospace, "SF Mono", Menlo, monospace;
             color: #475569; font-size: 12px; flex: 0 0 110px; }
.hist-label { flex: 1 1 auto; }
.hist-cur-tag {
  padding: 1px 6px; border-radius: 8px;
  background: #166534; color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}

/* Undo / Redo buttons are tighter than other ghost buttons. */
#btnUndo, #btnRedo, #btnHistory {
  padding: 4px 10px; font-size: 15px;
}
#btnUndo[disabled], #btnRedo[disabled] {
  opacity: 0.35; cursor: not-allowed;
}

/* ---------- Open-file picker ---------- */
.dlg-open { width: min(90vw, 640px); padding: 0; }
.dlg-open-form { display: flex; flex-direction: column; gap: 10px; padding: 18px;
                 max-height: 80vh; overflow: hidden; }
.open-toolbar { display: flex; gap: 12px; align-items: center; }
.open-toolbar input[type="search"] { flex: 1; padding: 6px 10px; font-size: 13.5px; }
.open-list {
  list-style: none; margin: 0; padding: 0;
  overflow: auto; flex: 1 1 auto;
  border: 1px solid #e5e7eb; border-radius: 6px;
}
.open-row {
  padding: 8px 12px; border-bottom: 1px solid #f1f5f9;
  cursor: pointer; user-select: none;
}
.open-row:last-child { border-bottom: none; }
.open-row:hover { background: #f8fafc; }
.open-row.selected { background: #dbeafe; }
.open-row.selected .open-meta { color: #1e40af; }
.open-row.current .open-name { font-weight: 600; }
.open-cur-tag {
  display: inline-block; margin-left: 8px;
  padding: 1px 6px; border-radius: 8px;
  background: #dcfce7; color: #166534;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.open-name { font-size: 13.5px; }
.open-meta { margin-top: 2px; font-variant-numeric: tabular-nums; }
.open-empty.hidden { display: none; }
.open-empty { padding: 12px; text-align: center; border: 1px solid #f1f5f9; border-radius: 6px; }
/* Open dialog rows are now flex containers so we can park a ⬇ button
   on the right of each row's text. */
.open-row { display: flex; align-items: center; gap: 12px; }
.open-row > div { flex: 1 1 auto; min-width: 0; }
.open-row .open-dl {
  flex: 0 0 auto; background: transparent; border: 1px solid transparent;
  font-size: 16px; padding: 2px 8px; border-radius: 5px; cursor: pointer;
  color: #64748b;
}
.open-row .open-dl:hover { background: #e0e7ff; color: #1e40af; }
.open-row.selected .open-dl { color: #1e40af; }
.room-tag.unmatched {
  background: #fee2e2; color: #991b1b; border-color: #fca5a5;
  font-weight: 700;
}

.sched-legend { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.sched-legend .legend-chip {
  font-size: 11px; padding: 3px 8px; border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
}
