:root {
  --ink: #102a43;
  --muted: #62748a;
  --line: #d8e1ea;
  --canvas: #f4f7fa;
  --surface: #ffffff;
  --nav: #123653;
  --nav-soft: #214a68;
  --blue: #2468a2;
  --teal: #17807a;
  --green: #2f855a;
  --amber: #b7791f;
  --coral: #c65d45;
  --red: #b8323c;
  --lavender: #6b5ca5;
  --shadow: 0 12px 30px rgba(16, 42, 67, 0.12);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.login-page { display: grid; grid-template-columns: minmax(360px, .85fr) minmax(480px, 1.15fr); min-height: 100vh; background: white; }
.login-page[hidden], .app-shell[hidden] { display: none; }
.login-brand-panel { display: flex; flex-direction: column; justify-content: space-between; gap: 48px; padding: clamp(32px, 6vw, 86px); background: var(--nav); color: white; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand > span:last-child { display: grid; gap: 3px; }
.login-brand strong { font-size: 20px; }
.login-brand small { color: #bcd0df; }
.login-brand-panel h1 { max-width: 620px; margin: 12px 0 18px; font-size: clamp(32px, 4vw, 52px); line-height: 1.1; }
.login-brand-panel p:last-child { max-width: 600px; margin: 0; color: #c9d9e5; font-size: 16px; line-height: 1.65; }
.login-form-panel { display: grid; place-items: center; padding: 34px; background: #f5f8fb; }
.login-form { display: grid; gap: 18px; width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 6px; background: white; box-shadow: var(--shadow); }
.login-form h2 { margin: 5px 0 7px; font-size: 30px; }
.login-form > div > p:last-child { margin: 0; color: var(--muted); }
.login-form > label { display: grid; gap: 7px; color: #43566a; font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; min-height: 46px; font-size: 14px; }
.login-password-field { display: grid; grid-template-columns: 1fr 42px; gap: 7px; }
.login-password-field .icon-button { width: 42px; min-height: 46px; }
.login-submit { min-height: 46px; }
.login-error { min-height: 20px; margin: -6px 0; color: var(--red); font-size: 12px; font-weight: 700; }
.login-help { margin: 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.55; }

.app-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: var(--nav);
  color: white;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 20px; }
.brand > span:last-child, .session-user > span:last-child { display: grid; gap: 3px; }
.brand strong { font-size: 17px; }
.brand small, .session-user small { color: #bcd0df; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: #f2b84b; color: #17324a; }
.brand-mark svg { width: 21px; height: 21px; }

.primary-nav { display: grid; gap: 5px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d7e4ed;
  text-align: left;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { background: #193f5c; color: white; }
.nav-item.active { background: var(--surface); color: var(--ink); font-weight: 700; }
.nav-item[hidden] { display: none; }

.sidebar-session { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.16); }
.sidebar-session > label { display: block; margin-bottom: 7px; color: #bcd0df; font-size: 12px; font-weight: 600; }
.sidebar-session select { width: 100%; min-height: 38px; border: 1px solid #496b83; border-radius: 5px; background: #0e2d46; color: white; padding: 0 8px; }
.session-user { display: flex; align-items: center; gap: 10px; margin-top: 13px; }
.sidebar-signout { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; margin-top: 12px; padding: 0 9px; border: 1px solid #496b83; border-radius: 5px; background: transparent; color: #d7e4ed; }
.sidebar-signout svg { width: 16px; height: 16px; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #dce9f3; color: var(--ink); font-weight: 700; }
.avatar-small { width: 34px; height: 34px; font-size: 12px; }
.avatar-medium { width: 42px; height: 42px; }
.avatar-large { width: 68px; height: 68px; font-size: 22px; }
.avatar.a1 { background: #deefe9; color: #17685f; }
.avatar.a2 { background: #f8e6c5; color: #875815; }
.avatar.g2 { background: #e4e0f3; color: #594a91; }

.main-area { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 26px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 5px; font-size: 27px; line-height: 1.2; }
.topbar p { margin: 0; color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--blue) !important; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.language-switch { display: inline-grid; grid-template-columns: 1fr 1fr; min-width: 112px; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #f3f6f9; }
.language-switch button { min-width: 50px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-weight: 700; }
.language-switch button.active { background: white; color: var(--blue); box-shadow: 0 1px 3px rgba(20, 52, 78, .16); }

.icon-button, .primary-button, .secondary-button, .danger-button, .table-action {
  border-radius: 5px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.icon-button { display: grid; place-items: center; width: 38px; padding: 0; }
.icon-button svg { width: 18px; height: 18px; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; font-weight: 700; }
.primary-button { border-color: var(--blue); background: var(--blue); color: white; }
.secondary-button { background: white; }
.danger-button { border-color: #e4a3a8; color: var(--red); background: #fff8f8; }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; }
button:hover { filter: brightness(.97); }

.content { padding: 20px 26px 36px; }
.view-stack { display: grid; gap: 16px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.section-heading h2, .section-heading h3 { margin: 0 0 5px; }
.section-heading p { margin: 0; color: var(--muted); }
.section-heading h2 { font-size: 20px; }
.section-heading h3 { font-size: 17px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.kpi { min-height: 92px; padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 6px; background: var(--surface); }
.kpi.teal { border-left-color: var(--teal); }
.kpi.amber { border-left-color: var(--amber); }
.kpi.coral { border-left-color: var(--coral); }
.kpi-label { color: var(--muted); font-weight: 600; }
.kpi-value { display: block; margin: 5px 0 2px; font-size: 25px; font-weight: 700; }
.kpi-note { color: var(--muted); font-size: 12px; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 18px; align-items: start; }
.mentor-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 16px; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 14px; }
.gradebook-header { align-items: center; }
.gradebook-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.gradebook-header > div:first-child { flex: 0 0 auto; }
.gradebook-header .gradebook-actions { flex: 1 1 auto; flex-wrap: nowrap; gap: 6px; }
.gradebook-header .gradebook-actions .primary-button,
.gradebook-header .gradebook-actions .secondary-button { flex: 0 1 auto; min-width: 0; padding-inline: 10px; white-space: nowrap; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .search-box { flex: 1 1 230px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 17px; transform: translateY(-50%); color: var(--muted); }
.search-box input { width: 100%; padding-left: 36px; }
input, select, textarea { border: 1px solid #cbd6e1; border-radius: 5px; background: white; color: var(--ink); }
input, select { min-height: 38px; padding: 0 10px; }
textarea { width: 100%; padding: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fc4e2; outline-offset: 1px; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 10px; background: #edf2f7; border-bottom: 1px solid var(--line); color: #4c6075; font-size: 12px; text-align: left; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #e7edf2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr[data-student-id] { cursor: pointer; }
tbody tr[data-student-id]:hover { background: #f7fafc; }
.student-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.student-cell small { display: block; margin-top: 2px; color: var(--muted); }
.numeric { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 210px; }
.mentor-student-table td { white-space: nowrap; }
.mentor-student-table td:first-child { white-space: normal; }
.grade-input { width: 66px; min-height: 32px; }
.grade-strong { color: var(--green); font-weight: 700; }
.grade-watch { color: var(--amber); font-weight: 700; }
.grade-risk { color: var(--red); font-weight: 700; }

.status, .tag { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status.new, .tag.blue { background: #e2effa; color: #245c88; }
.status.in-progress, .tag.amber { background: #fff0d7; color: #8a5a15; }
.status.completed, .tag.green { background: #def1e7; color: #27664a; }
.tag.red { background: #f9e0e2; color: #9d3038; }
.tag.purple { background: #eae6f7; color: #5d4d95; }
.tag.gray { background: #edf1f4; color: #596b7c; }

.attention-list, .timeline, .course-list, .mentee-list, .case-list { display: grid; }
.attention-item, .timeline-item, .course-item, .mentee-item, .case-item { border-bottom: 1px solid #e7edf2; }
.attention-item:last-child, .timeline-item:last-child, .course-item:last-child, .mentee-item:last-child, .case-item:last-child { border-bottom: 0; }
.attention-item { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; padding: 13px 16px; }
.attention-item strong, .course-item strong, .mentee-item strong { display: block; }
.attention-item p, .course-item p, .mentee-item p, .case-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.attention-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 5px; background: #fce9df; color: var(--coral); }
.attention-icon svg { width: 18px; }

.handoff { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.handoff-step { position: relative; padding: 18px 18px 18px 46px; background: white; }
.handoff-step:not(:last-child) { border-right: 1px solid var(--line); }
.handoff-step span { position: absolute; left: 15px; top: 17px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--nav); color: white; font-size: 11px; font-weight: 700; }
.handoff-step strong { display: block; margin-bottom: 4px; }
.handoff-step small { color: var(--muted); line-height: 1.45; }

.course-item, .mentee-item { padding: 13px 15px; cursor: pointer; }
.course-item:hover, .mentee-item:hover { background: #f7fafc; }
.course-item.active, .mentee-item.active { box-shadow: inset 4px 0 0 var(--blue); background: #eef5fb; }
.course-swatch { width: 10px; height: 34px; border-radius: 3px; float: left; margin-right: 10px; border: 1px solid rgba(16,42,67,.14); }
.lesson-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 3px 1px 7px; scrollbar-width: thin; }
.subject-course-toolbar { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.subject-course-toolbar > label { display: grid; flex: 0 0 150px; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.subject-course-toolbar > .tag { flex: 0 0 auto; margin-bottom: 9px; }
.subject-course-toolbar .lesson-tabs { flex: 1 1 auto; min-width: 0; padding-bottom: 0; }
.lesson-tab { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0; min-height: 42px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); text-align: left; white-space: nowrap; }
.lesson-tab .course-swatch { float: none; flex: 0 0 8px; height: 24px; margin: 0; }
.lesson-tab strong { display: block; }
.lesson-tab.active { border-color: #8ab5d3; box-shadow: inset 0 -4px 0 var(--blue); background: #eef5fb; }
.subject-subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.subject-subtab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 132px; min-height: 42px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; }
.subject-subtab svg { width: 17px; height: 17px; }
.subject-subtab.active { border-bottom-color: var(--blue); color: var(--blue); }
.lesson-kpis .kpi { min-height: 82px; }
.inline-date { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.comment-cell { min-width: 330px; max-width: 560px; line-height: 1.5; }
.muted-text, .block-muted { color: var(--muted); }
.block-muted { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; }
.mentor-student-header { display: flex; align-items: center; gap: 13px; }
.mentor-student-header h3 { margin: 0 0 4px; }
.mentor-student-header p { margin: 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.detail-stat { padding: 13px; border: 1px solid var(--line); border-radius: 5px; }
.detail-stat small { color: var(--muted); }
.detail-stat strong { display: block; margin-top: 6px; font-size: 18px; }

.attendance-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.attendance-toggle button { min-width: 34px; min-height: 30px; padding: 0 9px; border: 0; border-right: 1px solid var(--line); background: white; color: var(--muted); }
.attendance-toggle button:last-child { border-right: 0; }
.attendance-toggle button:disabled { cursor: not-allowed; opacity: .58; }
.attendance-toggle button.active:disabled { opacity: 1; }
.attendance-toggle button.active.present { background: #dff2e8; color: #236847; }
.attendance-toggle button.active.late { background: #fff0d7; color: #8a5a15; }
.attendance-toggle button.active.absent { background: #f9e0e2; color: #9d3038; }
.attendance-toggle button.active.in-school { background: #dff2e8; color: #236847; }
.attendance-toggle button.active.absent-from-school { background: #f9e0e2; color: #9d3038; }
.school-status-toggle button { min-width: 108px; }
.school-absence-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); white-space: nowrap; }
.school-absence-toggle svg { width: 16px; height: 16px; }
.school-absence-toggle.active { border-color: #dfa2a7; background: #fff4f4; color: #9d3038; }
.attendance-toggle button.active.excused { background: #e8edf2; color: #34495e; }
.homeroom-register-header { min-height: 46px; }
.homeroom-register-header .gradebook-actions { flex-wrap: nowrap; }
.homeroom-register-header .primary-button,
.homeroom-register-header .secondary-button { padding-inline: 10px; white-space: nowrap; }
.homeroom-registration-table .attendance-toggle { flex-wrap: nowrap; white-space: nowrap; }
.homework-status-toggle button:disabled { cursor: not-allowed; opacity: .72; }
.evening-study-entry-title { display: flex; align-items: center; gap: 11px; }
.evening-study-entry-title .attention-icon { flex: 0 0 auto; }
.evening-study-entry-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.attendance-reason-input { width: min(300px, 100%); min-width: 210px; }
.attendance-reason-control { display: grid; gap: 7px; min-width: 230px; }
.attendance-reason-select { width: 100%; min-width: 230px; }
.attendance-alert-button { border-color: #dfa2a7; color: #9d3038; background: #fffafa; }
.attendance-alert-inbox { border-top: 3px solid #c94b55; }
.teacher-reminder-panel { border-top: 3px solid #c94b55; }
.reminder-list { display: grid; }
.reminder-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.reminder-item:last-child { border-bottom: 0; }
.reminder-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.attendance-report-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; align-items: start; }
.calendar-heading { display: flex; justify-content: space-between; align-items: center; padding: 15px 16px 8px; }
.calendar-heading strong { font-size: 18px; }
.calendar-legend { display: flex; gap: 13px; color: var(--muted); font-size: 11px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.attendance-calendar { display: grid; grid-template-columns: repeat(7, minmax(52px, 1fr)); gap: 5px; padding: 8px 14px 16px; }
.calendar-weekday { padding: 7px 2px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 700; }
.calendar-day { position: relative; display: grid; place-items: center; min-height: 56px; border: 1px solid transparent; border-radius: 5px; background: #f8fafc; color: var(--ink); }
.calendar-day:hover { border-color: #9dbbd2; }
.calendar-day.selected { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); background: #edf6fc; }
.calendar-day.blank { background: transparent; }
.calendar-day.neutral { color: #8493a1; }
.calendar-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.calendar-day .calendar-dot { position: absolute; right: 8px; bottom: 8px; }
.calendar-dot.complete { background: #2f8b65; }
.calendar-dot.incomplete { background: #c94b55; }
.calendar-dot.holiday { background: #397fb3; }
.calendar-day.holiday { background: #edf5fb; color: #245c88; }
.calendar-detail-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.attendance-group-list { display: grid; }
.attendance-register-detail { max-height: min(66vh, 720px); overflow-y: auto; overscroll-behavior: contain; }
.attendance-register-detail h4 { margin: 0; padding: 11px 14px 7px; border-bottom: 1px solid var(--line); background: #f7fafc; font-size: 13px; color: var(--muted); }
.attendance-bulk-actions { display: flex; justify-content: flex-end; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.compact-empty { min-height: 76px; padding: 18px; }
.attendance-group-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.attendance-group-row:last-child { border-bottom: 0; }
.attendance-group-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.reminder-sent { display: grid; justify-items: end; gap: 4px; }
.reminder-sent small { color: var(--muted); font-size: 10px; }
.senior-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(46px, auto); gap: 8px 10px; padding: 2px 0; }
.senior-tabs .subject-subtab { width: 100%; min-width: 0; min-height: 46px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; white-space: normal; line-height: 1.25; }
.senior-tabs .subject-subtab:hover { border-color: #8ab5d3; background: #f4f8fc; color: var(--blue); }
.senior-tabs .subject-subtab.active { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: 0 2px 5px rgba(25, 92, 145, .18); }
.merit-redemption-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, .7fr); gap: 16px; padding: 16px; align-items: center; }
.merit-redemption-form { display: grid; gap: 15px; }
.merit-redemption-form > label, .merit-redemption-fields label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.merit-balance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.merit-balance-grid > div { padding: 11px; border: 1px solid var(--line); border-radius: 5px; background: #f7fafc; }
.merit-balance-grid strong, .merit-balance-grid small { display: block; }
.merit-balance-grid strong { font-size: 24px; }
.merit-balance-grid small { margin-top: 4px; color: var(--muted); }
.merit-redemption-fields { display: grid; grid-template-columns: 150px minmax(240px, 1fr) auto; gap: 10px; align-items: end; }
.selected-merit-student { display: flex; align-items: center; gap: 10px; min-height: 84px; padding: 14px; border: 1px solid #bfd4e3; border-radius: 6px; background: #f1f7fb; }
.selected-merit-student strong, .selected-merit-student small { display: block; }
.selected-merit-student small { margin-top: 5px; color: var(--muted); }
.merit-ranking-table td, .merit-archive-table td { vertical-align: middle; }
.report-tabs { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0; scrollbar-width: thin; }
.report-tabs .subject-subtab { flex: 0 0 auto; }
.attendance-summary-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.gradebook-actions label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }

.case-item { padding: 12px 14px; }
.case-item-top { display: flex; justify-content: space-between; gap: 12px; }
.case-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.case-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.table-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 31px; padding: 0 9px; font-weight: 600; }
.table-action svg { width: 15px; height: 15px; }
.primary-table-action { border-color: #9dbbd2; color: #1f5e8b; background: #f1f7fb; }
.latest-follow-up { padding: 9px 11px; border-left: 3px solid var(--teal); background: #f2f8f7; color: #40566a !important; line-height: 1.5; }

.profile-drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(1080px, calc(100vw - 90px)); height: 100vh; overflow-y: auto; background: white; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .22s ease; }
.profile-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; z-index: 25; inset: 0; background: rgba(16,42,67,.34); }
.drawer-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 12px; padding: 16px; background: white; border-bottom: 1px solid var(--line); }
.profile-identity { display: flex; align-items: center; gap: 14px; }
.profile-identity h2 { margin: 0 0 5px; }
.profile-identity p { margin: 0; color: var(--muted); }
.profile-identity-status { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.student-privilege-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.privilege-tag { display: inline-flex; align-items: center; gap: 5px; }
.privilege-tag svg { width: 14px; height: 14px; }
.support-status-control { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.support-status-control select { min-width: 140px; padding: 7px 34px 7px 10px; background-color: white; }
.drawer-content { display: grid; gap: 16px; padding: 16px; }
.drawer-section h3 { margin: 0 0 11px; font-size: 15px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.profile-stat { padding: 10px; border: 1px solid var(--line); border-radius: 5px; }
.profile-stat strong { display: block; font-size: 20px; margin-bottom: 3px; }
.profile-stat small { color: var(--muted); }
.mini-grade { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 9px 0; border-bottom: 1px solid #e7edf2; }
.mini-grade:last-child { border-bottom: 0; }
.mini-grade small { color: var(--muted); }
.student-access-note { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid #bcd5e6; border-radius: 6px; background: #f1f7fb; }
.student-access-note > svg { width: 21px; color: var(--blue); }
.student-access-note span:nth-child(2) { display: grid; gap: 3px; }
.student-access-note small { color: var(--muted); }
.student-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.drawer-section { min-width: 0; }
.student-info-grid .drawer-section { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.student-info-grid .drawer-section > h3 { margin: 0; padding: 14px 15px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.information-list { display: grid; }
.information-item { padding: 13px 15px; border-bottom: 1px solid #e7edf2; }
.information-item:last-child { border-bottom: 0; }
.information-item-top { display: flex; justify-content: space-between; gap: 10px; }
.information-item p { margin: 7px 0; color: #3b5065; line-height: 1.5; }
.information-item small { color: var(--muted); }
.full-width-info { border-top: 1px solid var(--line); padding-top: 18px; }
.student-case-section { border-top: 0; padding-top: 0; }
.privilege-form { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(220px, 1fr) minmax(260px, 1.35fr) auto; gap: 12px; align-items: end; padding: 16px; }
.privilege-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.privilege-form .primary-button { min-height: 42px; }
.danger-text { color: #a22c2c; border-color: #e2b4b4; }
.report-list { display: grid; }
.report-item { padding: 15px 16px; border-bottom: 1px solid #e5ecf2; }
.report-item:last-child { border-bottom: 0; }
.report-item-main { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.report-item-main p { margin: 5px 0; color: var(--muted); }
.report-item-main small { display: block; max-width: 920px; color: #40566a; line-height: 1.5; }
.report-item-main .chinese-preview { margin-top: 5px; color: #52687b; }
.timeline-item { position: relative; padding: 9px 0 13px 18px; }
.timeline-item::before { content: ""; position: absolute; left: 3px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.timeline-item::after { content: ""; position: absolute; left: 6px; top: 23px; bottom: -2px; width: 1px; background: var(--line); }
.timeline-item:last-child::after { display: none; }
.timeline-item strong { display: block; }
.timeline-item small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.45; }
.timeline-action { margin-top: 8px; }
.case-follow-up-timeline::before { background: var(--lavender); }

.modal { width: min(520px, calc(100vw - 28px)); border: 0; border-radius: 7px; padding: 0; box-shadow: var(--shadow); }
.modal [hidden] { display: none !important; }
.modal::backdrop { background: rgba(16,42,67,.45); }
.modal form { display: grid; gap: 12px; padding: 18px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; }
.modal-header-actions { display: flex; align-items: center; gap: 7px; }
.modal-header h2 { margin: 3px 0 0; }
.modal-subtitle { margin: 5px 0 0; color: var(--muted); }
.modal label { display: grid; gap: 7px; color: #43566a; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-note { margin: -4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.case-detail-modal { width: min(780px, calc(100vw - 28px)); }
.case-detail-modal form { max-height: min(880px, calc(100vh - 34px)); overflow-y: auto; }
.alert-dialog-content { display: grid; gap: 12px; max-height: min(880px, calc(100vh - 34px)); overflow-y: auto; padding: 16px; }
.alert-score-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.alert-score-summary > div { padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: #f7fafc; }
.alert-score-summary small { display: block; margin-bottom: 7px; color: var(--muted); }
.alert-score-summary strong { font-size: 17px; }
.report-modal { width: min(980px, calc(100vw - 28px)); }
.report-modal form { max-height: min(920px, calc(100vh - 30px)); overflow-y: auto; }
#mentorReportFormActions { flex-wrap: wrap; }
.report-file-section { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, .9fr); gap: 10px 14px; align-items: center; padding: 12px; margin-top: 10px; border: 1px solid #c8d7e4; background: #f7fafc; }
.report-file-section p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.report-file-section input[type="file"] { width: 100%; min-width: 0; padding: 10px; border: 1px solid #c8d7e4; background: #fff; }
.report-file-section #mentorReportExistingFile { grid-column: 1 / -1; }
.report-dispatch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; }
.report-dispatch-card { border: 1px solid #d5e0e9; background: #fff; padding: 12px 14px; }
.report-dispatch-card h4 { margin: 0 0 6px; }
.report-dispatch-card p { margin: 0 0 10px; color: var(--muted); }
.case-create-modal { width: min(900px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow: hidden; }
.case-create-modal form { grid-template-columns: minmax(0, 1.35fr) minmax(190px, .8fr) auto; max-height: calc(100dvh - 28px); overflow-y: auto; overscroll-behavior: contain; }
.case-create-modal .modal-header, .case-create-modal .case-description-field, .case-create-modal .compact-file-upload, .case-create-modal .participant-fieldset, .case-create-modal .modal-actions { grid-column: 1 / -1; }
.case-create-modal .modal-actions { position: sticky; z-index: 2; bottom: -20px; margin: 0 -20px -20px; padding: 13px 20px 20px; border-top: 1px solid var(--line); background: white; box-shadow: 0 -8px 18px rgba(20, 50, 74, .07); }
.evening-study-modal { width: min(1180px, calc(100vw - 28px)); }
.evening-study-tabs { margin-bottom: 2px; }
.evening-study-dialog-content { display: grid; gap: 12px; max-height: min(900px, calc(100vh - 30px)); padding: 16px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.evening-study-controls { display: grid; grid-template-columns: minmax(160px, 220px) minmax(180px, 240px) auto; gap: 12px; align-items: end; }
.evening-study-controls label { display: grid; gap: 7px; color: #43566a; font-weight: 600; }
.evening-study-summary { display: grid; grid-template-columns: repeat(4, minmax(80px, 110px)) 1fr; gap: 9px; align-items: stretch; }
.evening-study-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: #f7fafc; }
.evening-study-summary > div.summary-warning { border-color: #e5ba76; background: #fff8e9; }
.evening-study-summary strong, .evening-study-summary small { display: block; }
.evening-study-summary strong { font-size: 18px; }
.evening-study-summary small { margin-top: 2px; color: var(--muted); }
.evening-study-summary p { align-self: center; margin: 0; color: var(--muted); line-height: 1.45; }
.evening-study-table-wrap { max-height: none; overflow-x: auto; overflow-y: visible; border: 1px solid var(--line); }
.evening-study-table-wrap thead { position: sticky; top: 0; z-index: 1; }
.evening-study-dialog-content > .modal-actions { position: sticky; z-index: 3; bottom: -16px; margin: 0 -16px -16px; padding: 11px 16px 16px; background: white; border-top: 1px solid var(--line); box-shadow: 0 -8px 18px rgba(20, 50, 74, .07); }
.merit-modal { width: min(1220px, calc(100vw - 28px)); height: calc(100vh - 28px); height: calc(100dvh - 28px); max-height: none; overflow: hidden; }
.merit-dialog-content { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; padding: 16px; overflow: hidden; }
.merit-confirmation { position: fixed; z-index: 10; top: 50%; left: 50%; max-width: min(420px, calc(100vw - 40px)); padding: 15px 22px; border: 1px solid #236847; border-radius: 6px; background: #1f6f4a; color: white; font-weight: 700; text-align: center; box-shadow: 0 14px 34px rgba(16, 42, 67, .28); opacity: 0; transform: translate(-50%, -50%) scale(.96); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.merit-confirmation.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.merit-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(170px, 230px); gap: 12px; }
.merit-toolbar label { display: grid; gap: 7px; color: #43566a; font-weight: 600; }
.merit-table-wrap { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); }
.merit-table-wrap thead { position: sticky; top: 0; z-index: 2; }
.merit-table select { min-width: 190px; }
.merit-table input { min-width: 250px; }
.merit-actions { min-width: 255px; }
.merit-add-button { border-color: #9bcbb5; color: #236847; background: #f6fbf8; }
.merit-deduct-button { border-color: #e1b1b5; color: #9d3038; background: #fffafa; }
.merit-dialog-content > .modal-actions { flex: 0 0 auto; margin: 0 -16px -16px; padding: 11px 16px 16px; background: white; border-top: 1px solid var(--line); box-shadow: 0 -8px 18px rgba(20, 50, 74, .07); }
.homework-monitor-toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 12px; }
.homework-monitor-toolbar label { display: grid; gap: 6px; min-width: min(360px, 100%); color: #43566a; font-weight: 600; }
.homework-monitor-summary { display: grid; grid-template-columns: 150px 180px 1fr; gap: 10px; margin-bottom: 12px; }
.homework-monitor-summary > div { padding: 10px 12px; border: 1px solid var(--line); background: #f7fafc; border-radius: 5px; }
.homework-monitor-summary strong, .homework-monitor-summary small { display: block; }
.homework-monitor-summary strong { font-size: 20px; }
.homework-monitor-summary small { margin-top: 2px; color: var(--muted); }
.homework-monitor-summary p { margin: 0; align-self: center; color: var(--muted); }
.homework-status-toggle { min-width: 300px; }
.report-helper { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid #bcd5e6; border-radius: 6px; background: #f1f7fb; }
.report-helper p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.report-source-window { display: grid; grid-template-columns: minmax(230px, 1fr) auto 150px 150px; align-items: end; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.report-source-window label { gap: 5px; }
.report-source-intro p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.report-source-presets { display: flex; gap: 5px; align-items: center; }
.report-source-presets .table-action { white-space: nowrap; }
.report-source-presets .table-action.active { border-color: var(--blue); background: #e6f1f9; color: var(--blue); }
.bilingual-section { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.bilingual-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 13px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.bilingual-section h3 { margin: 0; font-size: 14px; }
.translation-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.translation-actions .table-action { min-height: 31px; background: white; }
.translation-actions button[aria-busy="true"] { opacity: .65; cursor: wait; }
.report-text-field { padding: 10px 12px; }
.report-text-field textarea { min-height: 120px; line-height: 1.5; }
.report-language-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.report-language-grid .report-text-field + .report-text-field { border-left: 1px solid var(--line); }
.report-text-field > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.report-review-field { background: #f7fafc; }
.report-review-field textarea { background: #fff; }
.bilingual-heading > div > p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.report-output-note { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; margin-top: 10px; border: 1px solid #bdd3e4; border-radius: 6px; background: #f1f7fb; }
.report-output-note > svg { flex: 0 0 auto; width: 20px; margin-top: 1px; color: var(--blue); }
.report-output-note p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.inline-translation-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 7px 0 6px; }
.inline-translation-tools > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.inline-translation-tools .table-action { min-height: 29px; padding: 4px 8px; background: white; font-size: 11px; }
.inline-translation-tools button[aria-busy="true"] { opacity: .65; cursor: wait; }
.inline-translation-tools small { margin-left: auto; color: #836326; font-size: 10px; font-weight: 500; }
.translation-note { display: flex; align-items: flex-start; gap: 9px; margin: -2px 0 0; padding: 11px 13px; border: 1px solid #ecd5a7; border-radius: 6px; background: #fff9ec; color: #70521c; font-size: 12px; line-height: 1.5; }
.translation-note svg { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; }
.bilingual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 13px; }
.case-detail-summary { display: grid; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: #f7fafc; }
.case-detail-summary p { margin: 8px 0 0; line-height: 1.55; color: #3f5367; }
.case-detail-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.summary-label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.case-follow-up-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.follow-up-entry { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px; border-bottom: 1px solid #e5ecf2; }
.follow-up-entry:last-child { border-bottom: 0; }
.follow-up-entry p { margin: 8px 0 4px; line-height: 1.55; color: #31485d; }
.follow-up-entry small { color: var(--muted); }
.follow-up-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.follow-up-heading time { color: var(--muted); font-size: 12px; }
.follow-up-entry-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.follow-up-entry-actions .table-action { min-height: 29px; padding: 4px 8px; font-size: 11px; }
.follow-up-entry.retracted { background: #f7f9fb; }
.follow-up-entry.retracted .avatar { opacity: .55; }
.retracted-follow-up-note { color: var(--muted) !important; font-style: italic; }
.follow-up-composer { display: grid; gap: 13px; padding: 15px; border: 1px solid #bfd4e3; border-radius: 6px; background: #f4f8fb; }
.file-upload-field { padding: 12px; border: 1px dashed #a8bdce; border-radius: 5px; background: white; }
.file-upload-field > span:first-child { display: block; margin-bottom: 7px; font-weight: 700; }
.file-picker-row { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: #f8fafc; }
.native-file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.file-picker-button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #b8c7d6; border-radius: 4px; background: #fff; color: var(--ink); font-weight: 700; cursor: pointer; }
.file-picker-row > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-upload-field small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.compact-file-upload { display: grid !important; grid-template-columns: minmax(120px, auto) minmax(260px, 1fr); align-items: center; gap: 8px 14px !important; padding: 9px 11px; }
.compact-file-upload > span:first-child { margin-bottom: 0; }
.compact-file-upload > small { grid-column: 1 / -1; }
.case-attachments { display: grid; gap: 7px; margin-top: 10px; }
.case-attachments > strong { color: #43566a; font-size: 12px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; }
.attachment-download { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 8px 10px; border: 1px solid #b8ccdc; border-radius: 4px; background: #fff; color: #173d62; font-weight: 650; cursor: pointer; }
.attachment-download:hover { background: #edf5fb; }
.attachment-download span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-download small { flex: 0 0 auto; color: var(--muted); font-weight: 400; }
.participant-fieldset { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.participant-fieldset legend { padding: 0 5px; color: #43566a; font-weight: 700; }
.participant-fieldset > p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.participant-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; max-height: 170px; overflow-y: auto; overscroll-behavior: contain; }
.participant-option { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 9px !important; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 5px; background: #f9fbfc; cursor: pointer; }
.participant-option:has(input:checked) { border-color: #80afd0; background: #edf6fc; }
.participant-option input { width: 17px; height: 17px; flex: 0 0 auto; }
.participant-option span { min-width: 0; }
.participant-option strong, .participant-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-option small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 500; }
.entry-participants { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 8px 0 5px; }
.case-closure-summary { margin: 10px 0; padding: 11px 13px; border-left: 4px solid #2f8b66; border-radius: 4px; background: #edf8f3; color: #244b3c; line-height: 1.5; }
.case-closure-summary p { margin: 5px 0; }
.case-closure-summary small { color: #557165; }
.optional-label { margin-left: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: 340px; padding: 12px 15px; border-radius: 5px; background: #173d58; color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-center { top: 50%; right: auto; bottom: auto; left: 50%; padding: 14px 20px; font-weight: 700; text-align: center; transform: translate(-50%, -50%) scale(.96); }
.toast.toast-center.show { transform: translate(-50%, -50%) scale(1); }
.empty-state { padding: 22px 16px; text-align: center; color: var(--muted); }

.gradebook-scroll { position: relative; }
.gradebook-table { width: max-content; min-width: 100%; }
.gradebook-table th, .gradebook-table td { min-width: 130px; text-align: center; }
.gradebook-table .sticky-student-column {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 158px;
  width: 158px;
  text-align: left;
  background: white;
  box-shadow: 1px 0 0 var(--line);
}
.gradebook-table thead .sticky-student-column { z-index: 4; background: #edf2f7; }
.gradebook-table .student-cell { min-width: 0; }
.assessment-column { min-width: 138px; width: 138px; }
.assessment-heading { display: grid; justify-items: center; gap: 5px; min-width: 118px; }
.assessment-heading strong { max-width: 128px; white-space: normal; line-height: 1.35; color: var(--ink); }
.assessment-heading small { color: var(--muted); font-weight: 500; }
.column-tools { display: flex; justify-content: center; gap: 4px; margin-top: 2px; }
.icon-button.compact { width: 29px; min-height: 29px; }
.icon-button.compact svg { width: 15px; height: 15px; }
.danger-icon { color: var(--red); border-color: #efc5c8; }
.score-cell { text-align: center; }
.score-cell .grade-input { width: 64px; text-align: center; }
.score-cell .letter-grade-input { width: 72px; }
.score-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.gradebook-table .average-column { min-width: 128px; width: 128px; }
.average-type-control { display: grid !important; gap: 7px !important; font-weight: 700; }
.average-type-control select { width: 100%; min-width: 116px; padding: 7px 25px 7px 8px; font-size: 11px; font-weight: 600; }
.gradebook-table .status-column { min-width: 90px; width: 90px; }
.gradebook-table .sticky-status-column { position: sticky; right: 0; z-index: 2; background: white; box-shadow: -1px 0 0 var(--line); }
.gradebook-table .sticky-average-column { position: sticky; right: 90px; z-index: 2; background: white; box-shadow: -1px 0 0 var(--line); }
.gradebook-table thead .sticky-status-column,
.gradebook-table thead .sticky-average-column { z-index: 5; background: #edf2f7; }
.weight-total { align-self: center; padding: 6px 9px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.weight-total.valid { color: #236d4c; background: #e5f4ec; }
.weight-total.warning { color: #955d08; background: #fff1d7; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item span, .sidebar-session > label, .sidebar-session select, .session-user > span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .session-user { justify-content: center; }
  .split-layout { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .attendance-report-layout { grid-template-columns: 1fr; }
  .privilege-form { grid-template-columns: 1fr 1fr; }
  .gradebook-header { align-items: flex-start; flex-wrap: wrap; }
  .gradebook-header .gradebook-actions { flex-basis: 100%; flex-wrap: wrap; justify-content: flex-start; }
}

@media (max-width: 760px) {
  .report-file-section, .report-dispatch-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 230px; padding: 28px; }
  .login-brand-panel h1 { font-size: 30px; }
  .login-brand-panel p:last-child { font-size: 14px; }
  .login-form-panel { padding: 24px 18px; }
  .login-form { padding: 24px 20px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 10px 14px; }
  .brand { justify-content: flex-start; padding: 0 0 9px; }
  .brand > span:last-child { display: grid; }
  .brand-mark { width: 34px; height: 34px; }
  .primary-nav { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { flex: 0 0 43px; min-height: 40px; }
  .sidebar-session { display: none; }
  .topbar { padding: 18px; align-items: flex-start; }
  .topbar h1 { font-size: 22px; }
  .topbar-actions .icon-button { display: none; }
  .primary-button span { display: none; }
  .content { padding: 18px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 84px; padding: 12px; }
  .kpi-value { font-size: 23px; }
  .mentor-layout { grid-template-columns: 1fr; }
  .evening-study-entry .panel-header { align-items: stretch; flex-direction: column; }
  .evening-study-controls { grid-template-columns: 1fr 1fr; }
  .evening-study-controls button { grid-column: 1 / -1; }
  .evening-study-summary { grid-template-columns: repeat(2, 1fr); }
  .evening-study-summary p { grid-column: 1 / -1; }
  .merit-toolbar { grid-template-columns: 1fr; }
  .mentee-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mentee-item { border: 1px solid var(--line); }
  .handoff { grid-template-columns: 1fr; }
  .handoff-step:not(:last-child) { border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .case-create-modal form, .compact-file-upload { grid-template-columns: 1fr; }
  .compact-file-upload > small { grid-column: auto; }
  .profile-drawer { width: 100vw; }
  .profile-stats { grid-template-columns: 1fr 1fr; }
  .student-info-grid { grid-template-columns: 1fr; }
  .subject-subtabs { overflow-x: auto; }
  .subject-subtab { flex: 1 0 118px; min-width: 118px; }
  .subject-course-toolbar { flex-wrap: wrap; }
  .subject-course-toolbar .lesson-tabs { flex-basis: 100%; }
  .lesson-tab { min-width: 0; }
  .case-detail-top { display: grid; }
  .follow-up-entry-actions { width: 100%; margin-left: 0; justify-content: space-between; }
  .privilege-form { grid-template-columns: 1fr; }
  .participant-grid { grid-template-columns: 1fr; }
  .alert-score-summary, .bilingual-grid { grid-template-columns: 1fr; }
  .bilingual-heading { align-items: flex-start; flex-direction: column; }
  .report-helper { align-items: flex-start; flex-direction: column; }
  .report-source-window { grid-template-columns: 1fr 1fr; }
  .report-source-intro, .report-source-presets { grid-column: 1 / -1; }
  .report-language-grid { grid-template-columns: 1fr; }
  .report-language-grid .report-text-field + .report-text-field { border-top: 1px solid var(--line); border-left: 0; }
  .attendance-summary-row { grid-template-columns: 1fr; }
  .merit-redemption-layout, .merit-redemption-fields { grid-template-columns: 1fr; }
  .merit-balance-grid { grid-template-columns: 1fr 1fr; }
  .attendance-calendar { grid-template-columns: repeat(7, minmax(38px, 1fr)); gap: 3px; padding-inline: 8px; }
  .calendar-day { min-height: 48px; }
  .reminder-item { grid-template-columns: auto 1fr; }
  .reminder-item .table-action { grid-column: 1 / -1; }
  .panel-header { align-items: flex-start; }
  .panel-header .gradebook-actions { width: 100%; }
  .homeroom-register-header .gradebook-actions { overflow-x: auto; padding-bottom: 2px; }
}

.backup-layout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 16px; align-items: center; }
.backup-summary { display: flex; gap: 16px; align-items: flex-start; }
.backup-summary .attention-icon { flex: 0 0 auto; }
.backup-summary strong { display: block; margin-bottom: 6px; }
.backup-summary p { margin: 0 0 8px; color: var(--muted); max-width: 760px; line-height: 1.45; }
.backup-summary small { color: var(--muted); }
.backup-summary small strong { display: inline; color: var(--ink); }
.backup-actions { display: grid; justify-items: end; gap: 9px; max-width: 440px; }
.backup-warning { display: flex; gap: 8px; margin: 0; color: #9c5d08; line-height: 1.45; }
.backup-warning svg { width: 20px; flex: 0 0 auto; }

@media (max-width: 760px) {
  .backup-layout { grid-template-columns: 1fr; }
  .backup-actions { justify-items: stretch; max-width: none; }
  .backup-actions .primary-button { width: 100%; justify-content: center; }
}

@media (max-width: 470px) {
  .kpi-grid, .detail-grid { grid-template-columns: 1fr; }
  .topbar p#pageDescription { display: none; }
  .mentee-list { grid-template-columns: 1fr; }
}
.sensitive-case-option {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 9px;
  min-height: 46px;
  padding: 7px 11px;
  border: 1px solid #e4b3b3;
  background: #fff7f7;
  white-space: nowrap;
}

.sensitive-case-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.sensitive-case-option span,
.sensitive-case-option small {
  display: block;
}

.sensitive-case-option small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 860px) {
  .case-create-modal form { grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr); }
  .case-create-modal .sensitive-case-option { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 760px) {
  .case-create-modal form { grid-template-columns: 1fr; }
  .case-create-modal .sensitive-case-option { grid-column: auto; justify-self: stretch; }
}

.case-status-stack {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.grade-weight-fields,
.letter-scale-fields {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.grade-weight-fields label,
.letter-scale-fields label {
  display: grid;
  grid-template-rows: auto 38px;
  gap: 4px;
  flex: 0 0 92px;
  width: 92px;
  font-size: 12px;
}

.grade-weight-fields label input,
.letter-scale-fields label input {
  width: 100%;
}

.letter-scale-fields span {
  align-self: center;
  font-weight: 700;
}

.grade-settings-inline {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(210px, 1fr) minmax(280px, 2fr) auto;
  align-items: end;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #f8fbfd;
}

.grade-settings-inline[aria-label="Letter scale settings"] {
  grid-template-columns: minmax(190px, .8fr) minmax(440px, 2fr) auto;
}

.grade-settings-inline h3,
.grade-settings-inline p {
  margin: 0;
}

.grade-settings-inline p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.grade-settings-inline .calculation-mode {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.grade-settings-inline .grade-weight-fields,
.grade-settings-inline .letter-scale-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.grade-settings-inline .grade-weight-fields label,
.grade-settings-inline .letter-scale-fields label {
  width: auto;
  min-width: 0;
}

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

.secondary-button.active {
  border-color: var(--blue);
  background: #eef5fb;
  color: var(--blue);
}

@media (max-width: 1050px) {
  .grade-settings-inline { grid-template-columns: 1fr 1fr; }
  .grade-settings-inline[aria-label="Letter scale settings"] { grid-template-columns: 1fr 2fr; }
  .inline-settings-actions { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .grade-settings-inline { grid-template-columns: 1fr; }
  .grade-settings-inline[aria-label="Letter scale settings"] { grid-template-columns: 1fr; }
  .inline-settings-actions { grid-column: auto; }
}
