/* Scoped to the management dialog; existing workbench and forms stay unchanged. */
dialog:has(.mg-root){width:min(980px,calc(100vw - 40px));max-height:calc(100dvh - 48px);border-radius:8px}
dialog:has(.mg-root) .modal-shell{max-height:calc(100dvh - 48px)}
dialog:has(.mg-root) .modal-head{padding:18px 24px;align-items:flex-start}
dialog:has(.mg-root) .modal-head>div{min-width:0}
dialog:has(.mg-root) .modal-head h2{font-size:19px;line-height:1.5;overflow-wrap:anywhere}
dialog:has(.mg-root) .modal-head p{overflow-wrap:anywhere}
dialog:has(.mg-root) .modal-body{padding:0 24px 16px;overflow:auto;overscroll-behavior:contain}
dialog:has(.mg-root) .modal-foot{padding:12px 24px;flex-shrink:0}
.mg-root{min-width:0;font-size:13px;line-height:1.6;letter-spacing:0}
.mg-root *{box-sizing:border-box;letter-spacing:0}
.mg-fields,.mg-root fieldset{min-width:0;border:0;padding:0;margin:0}
.mg-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));position:sticky;top:0;z-index:1;background:var(--white);border-bottom:1px solid var(--line);margin-bottom:4px}
.mg-tabs button{min-height:48px;padding:10px 4px;border:0;border-bottom:3px solid transparent;background:none;color:var(--muted);font-size:14px;font-weight:600;white-space:normal}
.mg-tabs button.active{border-bottom-color:var(--green);color:var(--green)}
.mg-section{padding:18px 0;border-bottom:1px solid var(--line)}
.mg-section:last-child{border-bottom:0}
.mg-section h3{font-size:14px;line-height:1.5;margin:0 0 14px;font-weight:700}
.mg-section h3 span{font-size:12px;color:var(--muted);font-weight:400;margin-left:8px}
.mg-section-head{display:flex;justify-content:space-between;gap:12px;align-items:center;margin-bottom:12px}
.mg-section-head h3{margin:0;min-width:0;overflow-wrap:anywhere}
.mg-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px}
.mg-root .field{min-width:0;margin-bottom:14px;display:flex;flex-direction:column;gap:6px}
.mg-root .field>label{font-size:12px;color:var(--muted);line-height:1.5}
.mg-field-label{font-size:12px;color:var(--muted);line-height:1.5}
.mg-course-picker{border:1px solid var(--line);border-radius:6px;background:var(--white);min-width:0}
.mg-course-picker>summary{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:38px;padding:8px 10px;cursor:pointer;list-style:none}
.mg-course-picker>summary::-webkit-details-marker{display:none}
.mg-course-picker>summary span{min-width:0;overflow-wrap:anywhere}
.mg-course-picker>summary svg{width:16px;height:16px;flex:none}
.mg-course-picker[open]>summary{border-bottom:1px solid var(--line)}
.mg-course-picker[open]>summary svg{transform:rotate(180deg)}
.mg-course-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 12px;padding:8px 10px}
.mg-course-options .mg-check{min-height:40px}
.mg-course-footer{display:flex;justify-content:flex-end;padding:0 10px 10px}
.mg-calendar{width:min(100%,480px);margin:0 auto;padding:16px 0}
.mg-calendar-toolbar{display:flex;align-items:flex-end;gap:12px}
.mg-calendar-toolbar .field{flex:1;margin:0}
.mg-calendar-meta{display:flex;align-items:center;justify-content:space-between;margin:12px 0}
.mg-calendar-weekdays,.mg-calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.mg-calendar-weekdays{margin-bottom:6px;text-align:center;color:var(--muted);font-size:12px}
.mg-calendar-grid .btn,.mg-calendar-blank{height:44px;min-width:0;min-height:44px;padding:0;font-variant-numeric:tabular-nums}
.mg-calendar-grid .btn[aria-pressed=true]{background:var(--green);border-color:var(--green);color:white}
.mg-calendar-grid .btn[aria-current=date]{box-shadow:inset 0 0 0 1px var(--green)}
.mg-calendar-grid .btn:disabled{opacity:.35;cursor:not-allowed}
.mg-calendar :focus-visible,.mg-course-picker :focus-visible{outline:2px solid var(--green);outline-offset:2px}
.mg-calendar-selected>span{display:flex;align-items:center;gap:4px}
.mg-calendar-selected .mg-icon{min-width:30px;width:30px;min-height:30px;height:30px;padding:4px;border:0;background:transparent;color:inherit}
.mg-calendar-selected .mg-date-invalid{color:#b42318;background:#fff0ee}
@media(min-width:701px){dialog:has(.mg-calendar){width:min(580px,calc(100vw - 40px))}}
.mg-root input:not([type=checkbox]),.mg-root select,.mg-root textarea{width:100%;min-width:0;max-width:100%;min-height:38px;padding:8px 10px;border:1px solid var(--line);border-radius:6px;background:var(--white);font-size:13px;line-height:1.5}
.mg-root textarea{resize:vertical;min-height:72px;overflow-wrap:anywhere}
.mg-root input:disabled,.mg-root select:disabled,.mg-root textarea:disabled{background:var(--surface)}
.mg-root input[type=checkbox]{width:16px;height:16px;flex:none;margin:0;accent-color:var(--green)}
.mg-actions,.mg-footer{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.mg-footer{width:100%;justify-content:flex-end}
.mg-root .btn,.mg-footer .btn{border-radius:6px;font-size:12px;min-height:36px;padding:7px 11px;white-space:normal;overflow-wrap:anywhere}
.mg-root .mg-icon{width:36px;height:36px;min-width:36px;padding:7px;flex:none}
.mg-icon svg{width:18px;height:18px}
.mg-check{display:flex;align-items:center;gap:9px;min-height:36px;font-size:13px;overflow-wrap:anywhere}
.mg-check span{min-width:0}
.mg-check small,.mg-person small,.mg-room-row small{display:block;color:var(--muted);font-size:11px;line-height:1.6;overflow-wrap:anywhere}
.mg-candidates{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));max-height:240px;overflow:auto;border-top:1px solid var(--line);border-bottom:1px solid var(--line);margin-bottom:10px}
.mg-candidate{padding:9px 6px;border-bottom:1px solid var(--line)}
.mg-candidate[hidden]{display:none}
.mg-person{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--line)}
.mg-person:last-child{border-bottom:0}
.mg-person>div:first-child{min-width:0;overflow-wrap:anywhere}
.mg-person strong,.mg-room-row strong{font-weight:500;font-size:13px}
.mg-person .mg-actions{flex:none}
.mg-tag{font-size:11px;color:var(--muted);background:var(--surface);padding:3px 7px;border-radius:4px;white-space:nowrap}
.mg-more{border-bottom:1px solid var(--line);padding:12px 0}
.mg-more>summary{cursor:pointer;font-size:13px;font-weight:600;min-height:32px;line-height:32px;list-style-position:inside}
.mg-more>summary svg{vertical-align:middle;width:15px;height:15px;margin-left:4px;color:var(--muted)}
.mg-more>.mg-actions{margin:8px 0}
.mg-more .mg-section{padding-bottom:0;border:0}
.mg-segmented{display:inline-flex;gap:0;margin-bottom:16px;border-bottom:1px solid var(--line)}
.mg-segmented .btn{border:0;border-bottom:2px solid transparent;border-radius:0;padding:8px 16px;background:none;color:var(--muted)}
.mg-segmented .btn.active{color:var(--green);border-bottom-color:var(--green)}
.mg-weekdays{display:flex;flex-wrap:wrap;gap:8px 18px;margin:0 0 14px}
.mg-review{margin-top:16px;border-left:3px solid var(--green);padding:4px 0 4px 12px}
.mg-review p{color:var(--muted);font-size:12px;margin-top:5px}
.mg-dates{display:flex;gap:6px;flex-wrap:wrap;max-height:180px;overflow:auto;margin-top:10px}
.mg-dates span{padding:3px 7px;background:var(--green-bg);font-size:11px;color:var(--green-dark);border-radius:4px;font-variant-numeric:tabular-nums}
.mg-session{display:grid;grid-template-columns:132px minmax(0,1fr) auto;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.mg-session:last-child{border-bottom:0}
.mg-session-date strong,.mg-session-date span{display:block;font-size:12px;font-variant-numeric:tabular-nums}
.mg-session-date strong{font-weight:600}
.mg-session-date span{color:var(--muted);margin-top:3px}
.mg-session-meta{display:flex;flex-direction:column;gap:3px;min-width:0;overflow-wrap:anywhere}
.mg-session-meta small{font-size:11px}
.mg-session-meta>strong{font-size:13px;line-height:1.5}
.mg-session>.mg-actions{flex-wrap:wrap}
.session-record-modal{width:min(800px,calc(100vw - 24px));max-width:800px;height:fit-content;max-height:calc(100dvh - 32px);margin:auto;border-radius:8px;inset:0}
.session-record-modal .modal-shell{height:auto;max-height:calc(100dvh - 32px)}
.session-record-modal .modal-head h2{font-size:20px}
.session-record-modal .modal-body{min-height:0;overflow:auto}
.session-record-modal h3{font-size:16px;margin:0 0 8px;overflow-wrap:anywhere}
.session-record-modal h4{font-size:13px;margin:18px 0 8px}
.session-record-modal p{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.7}
.session-record-summary{padding-bottom:18px;margin-bottom:18px;border-bottom:1px solid var(--line)}
.session-record-students{list-style:none;padding:0;margin:0}
.session-record-students li{border-bottom:1px solid var(--line);padding:12px 0}
.session-record-students li>div{display:flex;align-items:center;justify-content:space-between;gap:12px}
.session-record-students .badge{flex-shrink:0}
.mg-lock{display:flex;gap:4px;align-items:center;color:var(--amber);font-size:11px}
.mg-lock svg{width:12px;height:12px}
.mg-notice{border-left:3px solid var(--green);padding:8px 12px;margin:14px 0;background:var(--green-bg);font-size:12px;overflow-wrap:anywhere}
.mg-warning{border-left-color:var(--amber);background:var(--amber-bg)}
.mg-subject{color:var(--muted);font-size:12px;margin-bottom:16px;overflow-wrap:anywhere}
.mg-empty{padding:22px 0;color:var(--muted);font-size:12px}
.mg-root .form-error{min-height:0;margin:12px 0 0;font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere}
.mg-root .form-error:empty{display:none}
#mg-recovery:not(:empty){margin-top:10px}
.mg-room-filters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) auto;gap:12px;align-items:end;margin-bottom:12px}
.mg-room-filters .field{margin-bottom:0}
.mg-room-list{max-height:300px;overflow-y:auto;scrollbar-gutter:stable}
.mg-room-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) 36px;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.mg-room-row>div{min-width:0;overflow-wrap:anywhere}
.mg-room-summary{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding:4px 0 12px;font-size:12px;color:var(--muted)}
.mg-room-summary strong{font-weight:500;color:var(--text)}
.mg-room-toggle{display:flex;align-items:center;gap:8px;margin-left:auto;min-height:44px;cursor:pointer;color:var(--text)}
.mg-room-toggle input{width:18px;height:18px;min-height:0;accent-color:#b4382b}
.mg-room-row.has-conflict{border-left:3px solid #c84737;padding-left:10px;background:#fff7f5}
.mg-room-row .mg-room-warning,.mg-room-summary .mg-room-warning{color:#9e3025}
@media(max-width:700px){
  dialog:has(.mg-root){width:100vw;max-width:none;height:100dvh;max-height:100dvh;border-radius:0;margin:0}
  dialog:has(.mg-root) .modal-shell{height:100dvh;max-height:100dvh}
  dialog:has(.mg-root) .modal-head{padding:14px 16px}
  dialog:has(.mg-root) .modal-head h2{font-size:17px}
  dialog:has(.mg-root) .modal-body{padding:0 16px 12px}
  dialog:has(.mg-root) .modal-foot{padding:10px 16px max(10px,env(safe-area-inset-bottom))}
  .mg-grid{gap:0 12px}
  .mg-root input:not([type=checkbox]),.mg-root select,.mg-root textarea{font-size:16px;min-height:44px}
  .mg-root .btn,.mg-footer .btn{min-height:44px;padding:9px 11px}
  .mg-root .mg-icon{width:44px;height:44px;min-width:44px;padding:11px}
  .mg-candidates{grid-template-columns:repeat(2,minmax(0,1fr))}
  .mg-check{min-height:44px}
  .mg-session{grid-template-columns:116px minmax(0,1fr);gap:8px 10px}
  .mg-session>.mg-actions{grid-column:1/-1;justify-content:flex-end}
  .mg-room-filters{grid-template-columns:repeat(2,minmax(0,1fr));align-items:end}
  .mg-room-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 44px;gap:8px}
}
@media(max-width:390px){
  .mg-grid{grid-template-columns:minmax(0,1fr)}
  .mg-tabs button{font-size:13px}
  .mg-candidates{grid-template-columns:minmax(0,1fr)}
  .mg-person{gap:8px}
  .mg-person .mg-actions{gap:4px}
  .mg-footer .btn{flex:1}
}
.room-week-nav{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:8px 0 16px;font-size:13px}.room-week-nav>div{display:flex;align-items:center;gap:10px}
.room-week-nav .btn{width:40px;height:40px;padding:10px}.room-board{margin:0 0 24px}.room-board .section-head{margin-bottom:10px}.room-board h3{margin:0;font-size:16px}.room-board .section-head>span{font-size:12px;color:var(--muted)}
.room-board-scroll{max-width:100%;overflow-x:auto;border:1px solid var(--line);border-radius:4px}.room-week-table{border-collapse:separate;border-spacing:0;table-layout:fixed;width:100%;min-width:1100px;font-size:12px}
.room-week-table th,.room-week-table td{border-bottom:1px solid var(--line);border-right:1px solid var(--line);vertical-align:top;padding:7px}.room-week-table th{background:#f5f8f9;color:var(--text);font-weight:500;text-align:center}.room-week-table th small{display:block;color:var(--muted);margin-top:4px}
.room-week-table tr>*:first-child{position:sticky;left:0;z-index:1;width:105px;background:#f5f8f9;vertical-align:middle;font-size:11px}.room-week-table tr>*:last-child{border-right:0}.room-week-table tr:last-child>*{border-bottom:0}
.room-slot{display:block;width:100%;min-height:78px;text-align:left;border:0;border-left:3px solid #148579;background:#edf8f5;border-radius:3px;padding:9px 8px;margin:0 0 7px;color:var(--text);white-space:normal;overflow-wrap:anywhere;cursor:pointer;font-family:inherit;line-height:1.5}.room-slot:last-child{margin-bottom:0}.room-slot:hover{background:#dff1eb}.room-slot:focus-visible{outline:2px solid #137e72;outline-offset:1px}.room-slot strong{display:block;font-size:12px;margin:5px 0}.room-slot small{display:block;font-size:11px;color:var(--muted)}
.room-slot-time{display:flex;justify-content:space-between;flex-wrap:wrap;gap:2px;font-size:11px}.room-slot-time b{color:#a53427;font-size:10px}.room-slot.conflict{border-color:#c64735;background:#fff0ec}.room-slot.conflict:hover{background:#ffe3da}.room-free{display:block;text-align:center;color:#89969c;min-height:78px;padding-top:25px;box-sizing:border-box;font-size:11px}.room-invalid{padding:12px;color:#9d3e23;background:#fff4e8;margin-top:12px}
.mg-room-details summary,.mg-room-assignment summary{cursor:pointer;font-size:13px;font-weight:600;padding:14px 0}.mg-room-assignment .mg-grid{margin-top:12px}
dialog:has(.room-board){width:1480px;max-width:calc(100vw - 32px)}
.room-mobile-days{display:none}
.school-section{padding:22px 0;border-bottom:1px solid var(--line)}.school-section .section-head{align-items:flex-start;gap:18px}.school-section h2{font-size:18px}.school-section p{margin:8px 0;font-size:13px}.school-section .record-details{margin-top:14px}.mg-name-preview{padding:16px 0;border-top:1px solid var(--line)}.mg-name-preview span{display:block;font-size:12px;color:var(--muted);margin-bottom:8px}.mg-name-preview output{display:block;font-size:17px;line-height:1.6;font-weight:600;overflow-wrap:anywhere;color:#0e7465}
@media(max-width:700px){.heading{flex-wrap:wrap;gap:12px}.heading>.actions{flex-wrap:wrap;max-width:100%}.school-section .section-head{flex-wrap:wrap}.school-section .actions{width:100%;justify-content:flex-end}#life-editor select,#school-editor select{max-width:100%}}
.mg-candidate-group{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr))}
.mg-candidate-group>strong{grid-column:1/-1;padding:12px 8px;background:#f5f8f9;color:var(--muted);font-size:12px}
.mg-candidate-group:not(:has(.mg-candidate:not([hidden]))){display:none}
#students-directory .student-schedule-heading th{background:#eaf5f1;color:#0e7465;padding:12px 14px;font-size:15px}
#students-directory .student-teacher-heading th{background:#f7f9fa;color:var(--text);padding:12px 14px;font-size:13px}
#students-directory .student-teacher-heading span,#students-directory .student-schedule-heading span{margin-left:16px;font-size:12px;font-weight:400;color:var(--muted)}
@media(max-width:900px){.mg-candidate-group{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){#students-directory tr.student-schedule-heading,#students-directory tr.student-teacher-heading{display:block;padding:0;border:0}#students-directory .student-schedule-heading th,#students-directory .student-teacher-heading th{display:block;width:100%;text-align:left;overflow-wrap:anywhere}#students-directory .student-teacher-heading span,#students-directory .student-schedule-heading span{display:block;margin:4px 0 0;white-space:normal;overflow-wrap:anywhere}.mg-candidate-group{grid-template-columns:minmax(0,1fr)}}
.room-mobile-empty{display:none}
@media(max-width:700px){.room-week-table tbody tr:not(.room-day-has-course){display:none}.room-mobile-empty{display:block;text-align:center;color:var(--muted);padding:18px 0}}
@media(max-width:700px){dialog:has(.room-board){width:100vw;max-width:100vw}.room-week-table{min-width:0}.room-week-table tr>*:first-child{width:84px}.room-week-table tr>*:not(:first-child):not(.room-day-chosen){display:none}.room-week-nav{align-items:flex-start}.room-slot strong{font-size:13px}.room-slot small,.room-slot-time{font-size:12px}.room-mobile-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:3px;margin:0 0 18px}.room-mobile-days button{border:0;background:#f2f6f7;color:var(--muted);font:inherit;min-height:54px;border-radius:4px;padding:6px 0;cursor:pointer}.room-mobile-days button span,.room-mobile-days button strong{display:block;font-size:11px}.room-mobile-days button strong{font-size:15px;margin-top:4px}.room-mobile-days button[aria-pressed=true]{background:#e0f3ed;color:#116f61;box-shadow:inset 0 -3px #158174}}
.school-nav-group>button{width:100%}.school-nav-group>button>span{flex:1;text-align:left}.school-subnav:not([hidden]){display:grid;gap:4px;padding:4px 0 6px 26px}.nav .school-subnav button{min-height:40px;font-size:13px}.school-page-nav{display:flex;gap:20px;border-bottom:1px solid var(--line,#dbe4eb);margin-bottom:24px;overflow:auto}.school-page-nav button{border:0;border-bottom:3px solid transparent;background:transparent;padding:12px 2px;white-space:nowrap;color:var(--muted,#63758a)}.school-page-nav button.active{border-color:#117c70;color:#117c70;font-weight:700}
.mg-room-resources{padding:0 0 18px;border-bottom:1px solid var(--line);margin-bottom:20px}
.mg-room-create{display:flex;align-items:flex-end;gap:12px;margin-bottom:16px}
.mg-room-create .field{flex:1;min-width:0;margin:0}.mg-room-create .btn{flex-shrink:0}
.mg-room-resource-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 18px;margin-top:10px}
.mg-room-resource{display:flex;justify-content:space-between;align-items:center;gap:8px;min-width:0;padding:10px 0;border-bottom:1px solid var(--line)}
.mg-room-resource strong{font-size:13px;overflow-wrap:anywhere}.mg-room-resource small{display:block;color:var(--muted);margin-top:3px}
.mg-room-delete-confirm{padding:14px 0;border-top:1px solid var(--line);margin-top:12px;overflow-wrap:anywhere}
@media(max-width:700px){.mg-room-resource-list{grid-template-columns:1fr}.mg-room-create{gap:8px}.mg-room-create .btn{padding:10px;font-size:12px}}
