@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --font-family-base: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  --font-size-100: 12px;
  --font-size-200: 13px;
  --font-size-300: 14px;
  --font-size-400: 16px;
  --font-size-500: 20px;
  --line-height-tight: 1.25;
  --line-height-base: 1.45;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 4px 12px rgba(34, 40, 49, .12);
  --shadow-md: 0 12px 28px rgba(34, 40, 49, .16);
  --shadow-lg: 0 20px 48px rgba(34, 40, 49, .22);
  --layout-max: 1600px;
  --layout-gutter: 16px;
  --control-height: 32px;
  --theme-ink: #222831;
  --theme-slate: #393E46;
  --theme-accent: #00ADB5;
  --theme-paper: #EEEEEE;
  --primary: var(--theme-accent);
  --primary-hover: #008f96;
  --surface: #ffffff;
  --surface-2: var(--theme-paper);
  --surface-3: #e3e6e8;
  --border: #cfd4d8;
  --border-soft: #dde1e4;
  --text: var(--theme-ink);
  --secondary: var(--theme-slate);
  --muted: #6f7780;
  --sidebar: var(--theme-ink);
  --sidebar-hover: var(--theme-slate);
  --hover: #e7f5f6;
  --focus-ring: rgba(0, 173, 181, .18);
  --accent-soft: rgba(0, 173, 181, .10);
  --overlay: rgba(34, 40, 49, .38);
  --shadow-color: rgba(34, 40, 49, .16);
  --danger: #b4232a;
  --danger-hover: #8f1d23;
  --danger-bg: #f8e2e4;
  --danger-border: #e7a8ad;
  --success-bg: #dff4ed;
  --success: #16624a;
  --success-border: #a6dacb;
  --warning-bg: #f6edcf;
  --warning: #76601e;
  --info-bg: #d8f1f2;
  --info: #007d84;
}

* {
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-family-base);
  font-size: var(--font-size-200);
  line-height: var(--line-height-base);
}

body.modal-open {
  overflow: hidden;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface-2);
}

.auth-panel {
  width: min(100%, 380px);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 36px var(--shadow-color);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand span,
.auth-panel p,
.auth-note {
  color: var(--secondary);
}

.auth-panel h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-form .button {
  justify-content: center;
}

.auth-note {
  margin: 14px 0 0;
  font-size: 12px;
}

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger-hover);
  font-weight: 600;
}

.form-success {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--success-border);
  border-radius: 6px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 600;
}

.form-feedback {
  grid-column: 1 / -1;
  display: none;
  padding: 9px 11px;
  border-radius: 6px;
  font-weight: 650;
}

.form-feedback.is-open {
  display: block;
}

.form-feedback.is-error {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-hover);
}

.form-feedback.is-success {
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.auth-note a,
.form-success a {
  color: var(--primary);
  font-weight: 700;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  background: var(--surface-2);
}

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.brand {
  height: 56px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--theme-paper);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: block;
  background: var(--theme-paper);
  border: 1px solid rgba(238, 238, 238, .2);
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 13px;
  line-height: 1.15;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: rgba(238, 238, 238, .72);
  font-size: 11px;
}

.nav {
  padding: 10px 8px;
  display: grid;
  gap: 2px;
}

.nav a {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(238, 238, 238, .82);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover {
  background: var(--sidebar-hover);
  color: var(--theme-paper);
}

.nav a.active {
  background: var(--theme-accent);
  color: var(--theme-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .16);
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group summary {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(238, 238, 238, .82);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary:hover {
  background: var(--sidebar-hover);
  color: var(--theme-paper);
}

.nav-group-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-group-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-chevron {
  transform: rotate(0deg);
  transition: transform .16s ease;
}

.nav-group[open] .nav-chevron {
  transform: rotate(90deg);
}

.nav svg,
.icon {
  width: 16px;
  height: 16px;
  color: currentColor;
  flex: 0 0 auto;
}

.nav a.active svg {
  color: var(--theme-ink);
}

.subnav {
  display: grid;
  gap: 2px;
  margin: 0 0 4px 24px;
}

.subnav a {
  min-height: 28px;
  padding: 0 8px 0 12px;
  color: rgba(238, 238, 238, .72);
  font-size: 11px;
  line-height: 1.2;
  white-space: normal;
}

.subnav a.active {
  background: var(--theme-accent);
  color: var(--theme-ink);
  font-weight: 600;
}

.account {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid rgba(238, 238, 238, .16);
}

.account-card {
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--theme-slate);
  color: var(--theme-paper);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--theme-accent);
  color: var(--theme-ink);
  font-size: 12px;
  font-weight: 700;
}

.account-card strong {
  display: block;
  font-size: 12px;
  line-height: 1.1;
}

.account-card span {
  display: block;
  margin-top: 2px;
  color: rgba(238, 238, 238, .72);
  font-size: 11px;
}

.main,
.main-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-shell {
  transition: opacity 140ms ease;
}

body.is-page-loading .main-shell {
  opacity: .72;
}

.topbar {
  min-height: 48px;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
}

.crumbs {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page {
  width: min(100%, var(--layout-max));
  margin: 0 auto;
  padding: var(--space-4) var(--layout-gutter) var(--space-8);
}

.page-header {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--secondary);
  font-size: 12px;
}

.button {
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--theme-ink);
}

.button.primary:hover {
  background: var(--primary-hover);
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--theme-paper);
}

.button.danger:hover {
  background: var(--danger-hover);
}

.button.icon-only {
  width: 30px;
  padding: 0;
}

.button[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.school-year-grid,
.school-year-terms-panel {
  margin-top: 12px;
}

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: visible;
}

.toolbar {
  position: relative;
  z-index: 10;
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
}

.search {
  width: min(390px, 100%);
  min-height: var(--control-height);
  padding: 0 var(--space-3) 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.search-wrap {
  position: relative;
  min-width: 240px;
  flex: 1 1 auto;
}

.search-wrap svg {
  position: absolute;
  left: 9px;
  top: 8px;
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.toolbar-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-note {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
}

.table-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: 220px;
  display: none;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 26px var(--shadow-color);
}

.table-popover.is-open {
  display: grid;
  gap: 8px;
}

.table-popover > label:not(.form-field) {
  min-height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 13px;
}

.table-popover > label:not(.form-field):hover {
  background: var(--hover);
}

.table-popover input[type="checkbox"] {
  width: auto;
  height: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

thead th {
  height: 34px;
  padding: 0 9px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  height: 38px;
  padding: 0 9px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--secondary);
  white-space: nowrap;
}

tbody tr:hover td {
  background: var(--hover);
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.student-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--info-bg);
  color: var(--info);
  font-size: 11px;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.active {
  background: var(--success-bg);
  color: var(--success);
}

.pill.review {
  background: var(--warning-bg);
  color: var(--warning);
}

.pill.info {
  background: var(--info-bg);
  color: var(--info);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

tbody tr.is-editing td {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--focus-ring);
}

td[contenteditable="true"] {
  outline: none;
}

td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px rgba(0, 173, 181, .38);
}

.row-action-menu {
  position: absolute;
  z-index: 80;
  width: 136px;
  display: none;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 26px var(--shadow-color);
}

.row-action-menu.is-open {
  display: grid;
  gap: 2px;
}

.row-action-menu button {
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.row-action-menu button:hover {
  background: var(--hover);
  color: var(--text);
}

.undo-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 36px));
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--text);
  color: var(--theme-paper);
  box-shadow: 0 16px 34px rgba(34, 40, 49, .24);
  font-size: 13px;
}

.undo-toast.is-open {
  display: flex;
}

.undo-toast.is-error {
  border-color: var(--danger-hover);
  background: var(--danger);
}

.undo-toast.is-success {
  border-color: var(--success);
  background: var(--success);
}

.undo-toast button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 6px;
  background: rgba(255, 255, 255, .12);
  color: var(--theme-paper);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.undo-toast button:hover {
  background: rgba(255, 255, 255, .2);
}

.bulk-toolbar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 90;
  min-width: min(420px, calc(100vw - 36px));
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 34px var(--shadow-color);
  transform: translateX(-50%);
}

.bulk-toolbar.is-open {
  display: flex;
}

.bulk-toolbar > span {
  color: var(--text);
  font-weight: 700;
}

.bulk-toolbar-actions {
  display: flex;
  gap: 8px;
}

.table-scroll {
  overflow-x: auto;
}

.table-pagination {
  min-height: 34px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.table-pagination-actions {
  display: flex;
  gap: 6px;
}

.table-pagination .button {
  min-height: 30px;
  padding: 0 10px;
}

.side-panel {
  padding: 12px;
}

.side-panel h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
}

.side-panel p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.panel-heading {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.panel-heading p {
  margin-left: 0;
  margin-right: 0;
}

.panel-heading p {
  margin-bottom: 0;
}

.panel-stack {
  display: grid;
  gap: 12px;
}

.school-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.school-logo-row {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.school-logo-preview,
.school-summary-logo {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  object-fit: cover;
}

.school-logo-preview {
  width: 64px;
  height: 64px;
}

.school-logo-item {
  min-width: 0;
  display: grid;
  gap: 8px;
  justify-items: start;
}

.school-file-button {
  width: fit-content;
  min-width: 76px;
}

.field-note {
  grid-column: 1 / -1;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.school-summary {
  position: sticky;
  top: 58px;
}

.school-summary-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.school-summary-logo {
  width: 44px;
  height: 44px;
}

.school-summary-header h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.school-summary-header p {
  margin: 3px 0 0;
}

.info-list {
  display: grid;
  gap: 8px;
}

.info-row {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.info-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.info-row strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 18px;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: var(--overlay);
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(100%, 980px);
  max-height: calc(100vh - 36px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.record-view-modal {
  width: min(100%, 680px);
}

.confirm-dialog-backdrop {
  align-items: center;
}

.confirm-dialog {
  width: min(100%, 420px);
}

.confirm-dialog .modal-header {
  min-height: auto;
  padding: 14px;
}

.confirm-dialog .modal-header p {
  margin-top: 6px;
  color: var(--secondary);
  line-height: 1.45;
}

.confirm-dialog .modal-footer {
  padding: 10px 14px;
}

.learner-assign-modal {
  width: min(100%, 480px);
}

.learner-import-modal {
  width: min(100%, 560px);
}

.learner-assign-modal .modal-header {
  min-height: 48px;
  padding: 9px 12px;
}

.learner-assign-modal .modal-body {
  padding: 10px 12px 0;
}

.learner-assign-modal .modal-footer {
  margin: 10px -12px 0;
}

.import-panel {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
}

.import-panel p {
  margin: 0;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.4;
}

.import-results {
  margin-top: 10px;
  color: var(--secondary);
  font-size: 12px;
}

.import-results.is-open {
  padding: 9px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
}

.import-results strong {
  color: var(--text);
}

.import-results ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-summary span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.import-preview-table {
  max-height: 180px;
  margin-top: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: auto;
}

.import-preview-table table {
  width: 100%;
  min-width: 520px;
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 8px;
  font-size: 11px;
}

.record-view-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  row-gap: 0;
}

.record-view-body {
  display: block;
}

[data-record-view-body].record-view-grid {
  padding: 12px;
}

.record-view-item {
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}

.record-view-item span,
.record-view-item strong {
  display: block;
}

.record-view-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.record-view-item strong {
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.staff-profile-summary {
  margin: 12px 14px 0;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
}

.staff-profile-summary h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.staff-profile-summary p {
  margin: 3px 0 0;
  color: var(--secondary);
  font-size: 12px;
}

.record-view-sections {
  padding: 12px 14px 14px;
  display: grid;
  gap: 14px;
}

.record-view-section {
  min-width: 0;
}

.record-view-section h3 {
  margin: 0 0 4px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
}

.modal-header {
  min-height: 54px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.modal-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-body {
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.form-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.panel-form-grid {
  padding: 0;
}

.form-field {
  display: grid;
  gap: 4px;
}

.form-row-three {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.form-row-school {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 2fr minmax(90px, 130px) 1fr;
  gap: 10px;
}

.form-row-four {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.form-row-two {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-row-full {
  grid-column: 1 / -1;
}

.form-section-title {
  grid-column: 1 / -1;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.form-section-title:first-child {
  padding-top: 0;
  border-top: 0;
}

.subject-form-grid {
  gap: 12px;
}

.subject-setup-grid,
.subject-detail-grid {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.subject-setup-grid {
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
}

.subject-detail-grid {
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
}

.weight-panel {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  background: var(--surface-2);
}

.weight-panel-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.weight-panel-header strong,
.weight-panel-header span {
  display: block;
}

.weight-panel-header > div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.form-field span {
  color: var(--secondary);
  font-size: 11px;
  font-weight: 600;
}

.form-field.required span::after {
  content: " *";
  color: var(--danger);
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.form-field input.is-invalid,
.form-field select.is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
  box-shadow: 0 0 0 3px rgba(180, 35, 42, .14);
}

.form-field.compact input,
.form-field.compact select {
  width: auto;
  min-width: 120px;
  max-width: 140px;
}

.hidden {
  display: none !important;
}

.multi-select {
  position: relative;
}

.multi-select-trigger {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 28px 5px 10px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-trigger::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 11px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
}

.multi-select.is-open .multi-select-trigger {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 70;
  display: none;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 26px var(--shadow-color);
}

.multi-select.is-open .multi-select-menu {
  display: block;
}

.multi-select-menu input[type="text"] {
  width: 100%;
}

.multi-select-options {
  max-height: 104px;
  margin-top: 6px;
  overflow-y: auto;
}

.multi-select-options label {
  min-height: 28px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 13px;
}

.multi-select-options label:hover {
  background: var(--hover);
}

.multi-select-options input {
  width: auto;
  height: auto;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.checkbox-grid label {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 13px;
}

.checkbox-grid input {
  width: auto;
  height: auto;
}

.settings-grid {
  margin-top: 12px;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-profile-grid {
  display: grid;
  gap: 8px;
}

.dashboard-profile-grid div {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.dashboard-profile-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-profile-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-weight: 600;
}

.dashboard-stats {
  margin-bottom: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.settings-checklist {
  margin-top: 12px;
}

.settings-audit {
  margin-top: 12px;
}

.assignments-filters {
  display: grid;
  grid-template-columns: minmax(135px, .8fr) minmax(120px, .65fr) minmax(130px, .7fr) minmax(130px, .7fr) minmax(210px, 1.2fr);
  gap: 8px;
}

.assignment-command-bar {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 10px;
}

.compact-field {
  gap: 4px;
}

.compact-field span {
  font-size: 11px;
  line-height: 1;
}

.compact-field input,
.compact-field select {
  min-height: 34px;
  padding: 0 9px;
}

.assignment-search-field {
  min-width: 210px;
}

.assignments-layout {
  display: grid;
  grid-template-columns: minmax(240px, 286px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 10px;
}

.assignments-sections {
  position: sticky;
  top: 74px;
  padding: 10px;
}

.assignments-workspace {
  padding: 10px;
}

.assignment-section-list,
.assignment-subject-list,
.teacher-assignment-list,
.assignment-warning-list,
.assignment-workload-list {
  display: grid;
  gap: 6px;
}

.assignment-section-button {
  width: 100%;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(72px, auto);
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

.assignment-section-button.active {
  border-color: var(--primary);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.assignment-section-button strong,
.teacher-assignment-row strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-section-button small,
.teacher-assignment-row small,
.assignment-table small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
}

.assignment-section-main {
  min-width: 0;
}

.assignment-section-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.assignment-section-metrics b {
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  line-height: 1;
}

.assignment-workspace-header {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
}

.assignment-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.assignment-adviser-picker {
  display: grid;
  gap: 2px;
}

.assignment-adviser-picker span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.assignment-adviser-picker select {
  width: min(260px, 28vw);
  height: 30px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.assignment-workspace-header h2,
.assignment-sidebar-summary h2,
.assignment-list-header h3 {
  margin: 0;
}

.assignment-workspace-header h2 {
  font-size: 16px;
  line-height: 1.25;
}

.assignment-workspace-header p {
  margin-top: 2px;
  font-size: 12px;
}

.assignment-sidebar-summary h2,
.assignment-list-header h3 {
  font-size: 13px;
}

.assignments-tabs {
  width: fit-content;
  display: inline-flex;
  gap: 2px;
  margin: 0 0 10px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.assignments-tabs button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.assignments-tabs button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px var(--shadow-color);
}

.assignment-tab-panel {
  display: none;
}

.assignment-tab-panel.active {
  display: block;
}

.assignment-toolbar,
.assignment-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.assignment-toolbar .search-wrap {
  max-width: 360px;
  min-height: 34px;
}

.assignment-roster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.assignment-table-wrap {
  max-height: 500px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.assignment-table td,
.assignment-table th {
  padding: 7px 9px;
  white-space: normal;
}

.assignment-table th {
  font-size: 11px;
}

.assignment-table td {
  font-size: 12px;
}

.assignment-number-column {
  width: 42px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.assignment-row-action-button {
  width: 32px;
  height: 32px;
}

.school-files-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.school-files-header {
  min-height: 34px;
  margin-bottom: 8px;
  align-items: center;
}

.school-files-header h1 {
  font-size: 18px;
}

.school-files-header .subtitle {
  margin-top: 1px;
}

.school-files-sidebar {
  position: sticky;
  top: 58px;
}

.school-files-pane-heading {
  min-height: 38px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.school-files-pane-heading h2 {
  margin: 0;
  font-size: 15px;
}

.school-files-pane-heading p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.school-folder-list {
  display: grid;
  gap: 2px;
  padding: 6px;
}

.school-folder-row {
  min-width: 0;
  min-height: 30px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.25;
}

.school-folder-row.active,
.school-folder-row:hover {
  border-color: var(--border);
  background: var(--surface-2);
  text-decoration: none;
}

.school-folder-row *,
.school-child-folder * {
  text-decoration: none;
}

.school-folder-row span {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-folder-row small {
  display: inline;
  margin-top: 0;
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-folder-row strong {
  flex: 0 0 auto;
  min-width: 20px;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.school-files-main {
  overflow: hidden;
}

.school-files-main .toolbar {
  min-height: 42px;
  padding: 6px 8px;
}

.school-files-main .toolbar h2 {
  margin: 0;
  font-size: 14px;
}

.school-files-breadcrumbs {
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.school-files-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.school-files-title-row span {
  color: var(--muted);
  font-size: 12px;
}

.school-files-main .search-wrap {
  min-width: 220px;
}

.school-files-main .search {
  height: 28px;
}

.school-files-breadcrumbs a {
  color: var(--secondary);
}

.school-files-breadcrumbs strong {
  color: var(--text);
}

.school-child-folder-grid {
  margin: 0;
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}

.school-child-folder {
  min-width: 0;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.school-child-folder:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.school-child-folder .icon {
  flex: 0 0 auto;
  color: var(--primary);
}

.school-child-folder span {
  min-width: 0;
}

.school-child-folder strong,
.school-child-folder small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-child-folder strong {
  font-size: 12px;
}

.school-child-folder small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.school-files-main .table-scroll {
  border-top: 0;
}

.school-files-main thead th {
  height: 30px;
}

.school-files-main tbody td {
  height: 34px;
}

.school-file-dropzone {
  min-height: 132px;
  padding: 18px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--surface-2);
  color: var(--secondary);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.school-file-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.school-file-dropzone strong,
.school-file-dropzone small {
  display: block;
}

.school-file-dropzone strong {
  color: var(--text);
  font-size: 14px;
}

.school-file-dropzone small {
  margin-top: 4px;
  font-size: 12px;
}

.school-file-dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--accent-soft);
}

.school-file-selection {
  display: none;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.school-file-selection.is-open {
  display: block;
}

.school-file-selection-row {
  min-height: 34px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}

.school-file-selection-row:last-child {
  border-bottom: 0;
}

.school-file-selection-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-file-selection-row strong {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.school-file-selection p {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.school-file-kind {
  display: inline-flex;
  min-width: 74px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 11px;
  font-weight: 750;
}

.school-file-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  background: var(--surface-2);
  color: var(--secondary);
}

.school-file-icon .icon {
  width: 18px;
  height: 18px;
}

.school-file-icon-pdf {
  background: var(--theme-ink);
  color: var(--theme-paper);
}

.school-file-icon-document {
  background: var(--accent-soft);
  color: var(--primary);
}

.school-file-icon-spreadsheet {
  background: var(--theme-slate);
  color: var(--theme-paper);
}

.school-file-icon-video {
  background: var(--surface-2);
  color: var(--theme-slate);
}

.school-file-icon-audio {
  background: var(--surface-3);
  color: var(--theme-slate);
}

.school-file-icon-archive {
  background: var(--theme-accent);
  color: var(--theme-ink);
}

.school-file-thumb {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  display: block;
  object-fit: cover;
  background: var(--surface-2);
}

.school-file-thumb-button {
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.school-file-thumb-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.school-image-preview-modal {
  width: min(100%, 900px);
}

.school-image-preview-body {
  padding: 12px;
  display: grid;
  place-items: center;
  background: var(--theme-ink);
}

.school-image-preview-body img {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  border-radius: 6px;
  object-fit: contain;
  background: var(--surface);
}

.assignment-pager {
  min-height: 30px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.assignment-subject-table tr.is-assigned {
  background: var(--surface-2);
  color: var(--muted);
}

.teacher-assignment-row input,
.teacher-assignment-row select,
.assignment-toolbar select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--surface);
  font-size: 12px;
}

.assignment-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.assignment-side-row {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--surface);
  font-size: 12px;
}

.assignment-side-row.warning strong {
  color: var(--danger);
}

.class-record-filters {
  display: grid;
  grid-template-columns: minmax(140px, .85fr) minmax(125px, .7fr) minmax(105px, .55fr) minmax(145px, .8fr) minmax(160px, .95fr) minmax(155px, .9fr) minmax(100px, .55fr) minmax(180px, 1fr);
  align-items: end;
  gap: 6px;
  margin-bottom: 10px;
}

.class-record-command-bar {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 8px;
}

.class-record-command-bar .compact-field {
  gap: 3px;
}

.class-record-command-bar .compact-field span {
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
}

.class-record-command-bar .compact-field input,
.class-record-command-bar .compact-field select {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.class-record-search {
  min-width: 170px;
}

.class-record-list-panel {
  padding: 10px 0 0;
}

.class-record-list-panel .panel-heading {
  margin: 0 10px 8px;
}

.class-record-list-panel .panel-heading h2 {
  margin: 0;
  font-size: 15px;
}

.class-record-list-panel .panel-heading p {
  margin-top: 2px;
  font-size: 12px;
}

.class-record-list-table th,
.class-record-list-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.class-record-list-table tr.is-selected td {
  background: var(--hover);
}

.class-record-list-table td small,
.class-record-sheet td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.class-record-progress {
  width: 82px;
  height: 6px;
  display: inline-flex;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
  vertical-align: middle;
}

.class-record-progress span {
  display: block;
  background: var(--primary);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 11px;
  font-weight: 700;
}

.status-pill.active {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.review {
  border-color: var(--warning-bg);
  background: var(--warning-bg);
  color: var(--warning);
}

.status-pill.info {
  border-color: color-mix(in srgb, var(--primary) 44%, var(--border) 56%);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface) 88%);
  color: color-mix(in srgb, var(--primary) 80%, var(--text) 20%);
}

.class-record-modal-backdrop {
  align-items: stretch;
  justify-content: stretch;
  padding: 10px;
}

.class-record-modal-backdrop.is-open {
  display: flex;
}

.class-record-modal {
  width: 100%;
  height: calc(100vh - 20px);
  max-width: none;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
}

.class-record-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-soft);
}

.class-record-detail-header h2 {
  margin: 0;
  font-size: 16px;
}

.class-record-detail-header p {
  margin: 3px 0 0;
  color: var(--muted);
}

.class-record-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.class-record-sheet-wrap {
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}

.class-record-sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

.class-record-sheet th,
.class-record-sheet td {
  min-width: 42px;
  padding: 3px 4px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  white-space: nowrap;
}

.class-record-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 10px;
  font-weight: 800;
}

.class-record-sheet thead tr:nth-child(2) th {
  top: 24px;
}

.class-record-sheet thead tr:nth-child(3) th {
  top: 48px;
}

.class-record-sheet .cr-component {
  border-bottom-color: var(--border);
  color: #ffffff;
  font-weight: 800;
}

.class-record-sheet .cr-ww {
  background: #1d6fa5;
}

.class-record-sheet .cr-pt {
  background: #247a52;
}

.class-record-sheet .cr-ta {
  background: #a86416;
}

.class-record-sheet .cr-calc {
  background: #5b6570;
}

.class-record-sheet .cr-sticky {
  position: sticky;
  z-index: 3;
  text-align: left;
}

.class-record-sheet thead .cr-sticky {
  z-index: 6;
}

.class-record-sheet .cr-number {
  left: 0;
  min-width: 34px;
  text-align: center;
}

.class-record-sheet .cr-lrn {
  left: 34px;
  min-width: 92px;
}

.class-record-sheet .cr-name {
  left: 126px;
  min-width: 172px;
}

.class-record-sheet .cr-highest {
  position: relative;
  background: var(--surface-2);
  color: var(--secondary);
  font-weight: 800;
}

.class-record-sheet .cr-highest.cr-ww-hps {
  color: #1d6fa5;
}

.class-record-sheet .cr-highest.cr-pt-hps {
  color: #247a52;
}

.class-record-sheet .cr-highest.cr-ta-hps {
  color: #a86416;
}

.class-record-sheet .cr-highest.is-empty-hps::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 14px;
  background: currentColor;
  opacity: .85;
  transform: translate(-50%, -50%);
}

.class-record-sheet .cr-input-cell {
  cursor: text;
}

.class-record-sheet .cr-input-cell.is-disabled {
  cursor: default;
  background: var(--surface-2);
}

.cr-item-title-button {
  width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
}

.cr-item-title-button .icon {
  width: 15px;
  height: 15px;
}

.cr-item-title-button:hover,
.cr-item-title-button:focus-visible {
  outline: none;
  background: var(--hover);
  color: var(--text);
}

.cr-item-title-button:disabled {
  cursor: default;
  opacity: .65;
}

.cr-ww-icon {
  color: #1d6fa5;
}

.cr-pt-icon {
  color: #247a52;
}

.cr-ta-icon {
  color: #a86416;
}

.cr-item-title-popover {
  position: absolute;
  z-index: 90;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 32px var(--shadow-color);
}

.cr-item-title-popover[hidden] {
  display: none;
}

.cr-item-title-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.cr-score-input,
.cr-hps-input {
  width: 36px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
  pointer-events: none;
}

.cr-hps-input {
  height: 18px;
  font-weight: 800;
}

.cr-score-input::-webkit-inner-spin-button,
.cr-score-input::-webkit-outer-spin-button,
.cr-hps-input::-webkit-inner-spin-button,
.cr-hps-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.cr-score-input:focus,
.cr-hps-input:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.cr-item-edit,
.cr-item-delete {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.cr-item-delete {
  margin-left: 5px;
  color: var(--danger);
}

.sf2-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px);
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.sf7-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr)) auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.sf7-filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sf7-list-table td strong {
  display: block;
}

.sf7-list-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.sf7-list-table td[data-label="Actions"] {
  text-align: center;
  width: 70px;
}

.sf7-edit-modal {
  width: min(760px, 96vw);
}

.sf4-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px);
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.sf4-list-table td small {
  display: block;
  color: var(--muted);
}

.sf4-modal .class-record-detail-header {
  background: var(--surface);
}

.sf4-sheet {
  width: 100%;
  min-width: 900px;
  font-size: 11px;
}

.sf4-sheet th,
.sf4-sheet td {
  min-width: 82px;
  padding: 5px 6px;
  border-color: color-mix(in srgb, var(--border) 76%, var(--text) 24%);
  vertical-align: middle;
}

.sf4-sheet thead th {
  height: 28px;
}

.sf4-sheet tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 5;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--secondary);
  font-weight: 900;
}

.sf4-metric-head {
  background: #1d6fa5 !important;
  color: #ffffff !important;
}

.sf4-movement-head {
  background: #247a52 !important;
  color: #ffffff !important;
}

.sf4-notes-head {
  background: #52616d !important;
  color: #ffffff !important;
}

.sf4-input-cell {
  min-width: 96px !important;
  padding: 0 !important;
}

.sf4-input-cell input,
.sf4-notes-cell input {
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: center;
}

.sf4-input-cell input::-webkit-inner-spin-button,
.sf4-input-cell input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.sf4-input-cell input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.sf4-input-cell input:focus,
.sf4-notes-cell input:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.sf4-notes-cell {
  min-width: 260px !important;
  padding: 0 !important;
}

.sf4-notes-cell input {
  min-width: 260px;
  text-align: left;
}

.sf4-consolidated-sheet {
  min-width: 980px;
}

.sf8-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px);
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.sf8-list-table td strong {
  display: block;
}

.sf8-list-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.sf8-modal .class-record-detail-header {
  background: var(--surface);
}

.sf8-sheet {
  font-size: 11px;
}

.sf8-sheet th,
.sf8-sheet td {
  min-width: 72px;
  padding: 3px 4px;
  border-color: color-mix(in srgb, var(--border) 76%, var(--text) 24%);
  vertical-align: middle;
}

.sf8-sheet thead th {
  height: 28px;
}

.sf8-sticky {
  position: sticky;
  z-index: 3;
  text-align: left;
}

.sf8-sheet thead .sf8-sticky {
  z-index: 6;
}

.sf8-number {
  left: 0;
  min-width: 34px !important;
  text-align: center;
}

.sf8-lrn {
  left: 34px;
  min-width: 92px !important;
}

.sf8-name {
  left: 126px;
  min-width: 190px !important;
}

.sf8-input-cell {
  min-width: 82px !important;
  padding: 0 !important;
}

.sf8-input-cell input,
.sf8-notes-cell input {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: center;
}

.sf8-input-cell input::-webkit-inner-spin-button,
.sf8-input-cell input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.sf8-input-cell input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.sf8-input-cell input:focus,
.sf8-notes-cell input:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.sf8-notes-cell {
  min-width: 220px !important;
  padding: 0 !important;
}

.sf8-notes-cell input {
  min-width: 220px;
  text-align: left;
}

.sf9-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.sf9-list-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.sf9-card-wrap {
  min-height: 0;
  overflow: auto;
  background: var(--surface-2);
  padding: 14px;
}

.sf9-card {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.sf9-card-header,
.sf9-learner-band,
.sf9-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sf9-card-header {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  text-align: center;
}

.sf9-card-header strong,
.sf9-card-header span,
.sf9-learner-band span,
.sf9-learner-band strong {
  display: block;
}

.sf9-card-header span,
.sf9-learner-band span {
  color: var(--muted);
  font-size: 11px;
}

.sf9-learner-band {
  grid-template-columns: 1.4fr .8fr 1fr 1fr;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.sf9-card-section {
  margin-top: 14px;
}

.sf9-card-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.sf9-grade-table,
.sf9-attendance-table {
  font-size: 11px;
}

.sf9-grade-table th,
.sf9-grade-table td,
.sf9-attendance-table th,
.sf9-attendance-table td {
  padding: 6px;
  border-color: color-mix(in srgb, var(--border) 76%, var(--text) 24%);
  text-align: center;
}

.sf9-grade-table th:first-child,
.sf9-grade-table td:first-child {
  text-align: left;
}

.sf9-grade-table td small {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.sf9-grade-table tfoot th {
  background: var(--surface-2);
}

.sf9-signatures {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 26px;
  gap: 22px;
  text-align: center;
}

.sf9-signatures div {
  min-height: 48px;
  display: grid;
  align-content: end;
  border-top: 1px solid var(--border);
  padding-top: 5px;
}

.sf9-signatures span,
.sf9-signatures strong {
  display: block;
  font-size: 11px;
}

@media print {
  body:has([data-sf9-detail].is-open) .sidebar,
  body:has([data-sf9-detail].is-open) .topbar,
  body:has([data-sf9-detail].is-open) .page-header,
  body:has([data-sf9-detail].is-open) .class-record-detail-header,
  body:has([data-sf9-detail].is-open) .sf9-filters,
  body:has([data-sf9-detail].is-open) .sf9-list-panel {
    display: none !important;
  }

  body:has([data-sf9-detail].is-open) .app,
  body:has([data-sf9-detail].is-open) .main-shell,
  body:has([data-sf9-detail].is-open) .modal-backdrop,
  body:has([data-sf9-detail].is-open) .modal,
  body:has([data-sf9-detail].is-open) .sf9-card-wrap {
    position: static !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  body:has([data-sf9-detail].is-open) .sf9-card {
    width: 100% !important;
    border: 0 !important;
  }
}

.sf2-list-table th,
.sf2-list-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.sf2-modal .class-record-detail-header {
  background: var(--surface);
}

.sf2-autosave-note {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sf2-autosave-note.is-saving {
  color: var(--primary);
}

.sf2-sheet {
  font-size: 11px;
}

.sf2-sheet th,
.sf2-sheet td {
  min-width: 34px;
  padding: 2px 3px;
  border-color: color-mix(in srgb, var(--border) 76%, var(--text) 24%);
}

.sf2-sheet thead th {
  height: 24px;
}

.sf2-sheet thead tr:nth-child(2) th {
  top: 24px;
}

.sf2-sheet tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 5;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 10px;
}

.sf2-sheet tfoot tr:first-child th {
  bottom: 22px;
}

.sf2-date-group {
  background: #1d6fa5 !important;
  color: #ffffff !important;
}

.sf2-summary-head {
  background: #52616d !important;
  color: #ffffff !important;
}

.sf2-date-head span,
.sf2-date-head small {
  display: block;
  line-height: 1.05;
}

.sf2-date-head small {
  margin-top: 1px;
  font-size: 9px;
  color: var(--muted);
}

.sf2-sticky {
  position: sticky;
  z-index: 3;
  text-align: left;
}

.sf2-sheet thead .sf2-sticky,
.sf2-sheet tfoot .sf2-sticky {
  z-index: 7;
}

.sf2-number {
  left: 0;
  min-width: 34px;
  text-align: center;
}

.sf2-lrn {
  left: 34px;
  min-width: 92px;
}

.sf2-name {
  left: 126px;
  min-width: 170px;
}

.sf2-mark-cell {
  padding: 0 !important;
}

.sf2-attendance-button {
  width: 100%;
  min-width: 30px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
}

.sf2-attendance-button:hover,
.sf2-attendance-button:focus-visible {
  outline: none;
  background: var(--hover);
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}

.sf2-attendance-button.is-absent {
  background: #fff1f1;
  color: #b42318;
}

.sf2-attendance-button.is-late {
  background: #fff7e6;
  color: #a86416;
}

.sf2-attendance-button:disabled {
  cursor: default;
  opacity: .68;
}

.sf2-remarks-cell {
  min-width: 190px !important;
  padding: 0 !important;
}

.sf2-remarks-cell input {
  width: 100%;
  min-width: 190px;
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.sf2-remarks-cell input:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.assignment-sidebar-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.assignment-sidebar-summary section + section {
  margin-top: 10px;
}

.empty-cell,
.empty-state {
  padding: 12px;
  color: var(--muted);
  text-align: center;
}

.toolbar-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-field input:disabled,
.form-field select:disabled,
.checkbox-grid input:disabled {
  cursor: not-allowed;
  opacity: .72;
}

.modal-footer {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}

/*
  Design system normalization layer.
  Enforces consistent typography, radius, shadows, container rhythm, and 4px-grid spacing.
*/

:where(.panel, .auth-panel, .modal, .table-popover, .row-action-menu, .multi-select-menu, .bulk-toolbar, .undo-toast, .assignment-table-wrap, .school-file-selection, .import-panel, .import-results.is-open) {
  border-radius: var(--radius-sm);
}

:where(.panel, .modal, .auth-panel, .table-popover, .row-action-menu, .multi-select-menu, .bulk-toolbar, .undo-toast, .import-panel, .import-results.is-open) {
  box-shadow: var(--shadow-md);
}

:where(.button, .search, .form-field input, .form-field select, .multi-select-trigger, .assignment-adviser-picker select, .teacher-assignment-row input, .teacher-assignment-row select, .assignment-toolbar select) {
  border-radius: var(--radius-sm);
  font-size: var(--font-size-200);
  line-height: var(--line-height-tight);
}

:where(.button, .search, .form-field input, .form-field select, .assignment-adviser-picker select) {
  min-height: var(--control-height);
}

:where(.page-header, .panel-heading, .panel-stack, .toolbar-group, .top-actions, .stats, .dashboard-grid, .dashboard-summary, .settings-actions, .school-layout, .grid, .school-files-layout, .assignments-layout, .assignment-roster-grid, .form-grid, .form-row-two, .form-row-three, .form-row-four, .subject-setup-grid, .subject-detail-grid, .weight-panel, .checkbox-grid) {
  gap: var(--space-3);
}

.page-header,
.panel-heading,
.school-logo-row,
.assignment-workspace-header,
.class-record-list-panel .panel-heading {
  margin-bottom: var(--space-3);
}

.side-panel,
.form-grid,
[data-record-view-body].record-view-grid,
.class-record-detail-header,
.modal-header,
.school-image-preview-body,
.assignment-command-bar,
.class-record-command-bar {
  padding: var(--space-3);
}

h1,
.auth-panel h1 {
  line-height: var(--line-height-tight);
}

.subtitle,
.modal-header p,
.toolbar-note,
.topbar .crumbs,
.form-field span {
  line-height: var(--line-height-base);
}

:where(.button, .search, .form-field input, .form-field select):focus-visible,
.multi-select-trigger:focus-visible,
.assignment-adviser-picker select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Data-dense dashboard mode */
body.dense-ui {
  font-size: 12px;
}

body.dense-ui .page {
  padding: 8px 12px 16px;
}

body.dense-ui .page-header,
body.dense-ui .panel-heading,
body.dense-ui .toolbar,
body.dense-ui .toolbar-group,
body.dense-ui .table-pagination {
  gap: 6px;
}

body.dense-ui .page-header {
  margin-bottom: 8px;
}

body.dense-ui h1 {
  font-size: 18px;
  line-height: 1.2;
}

body.dense-ui .subtitle,
body.dense-ui .crumbs,
body.dense-ui .toolbar-note {
  font-size: 11px;
  line-height: 1.35;
}

body.dense-ui .toolbar {
  min-height: 38px;
  padding: 4px 8px;
}

body.dense-ui .button,
body.dense-ui .search,
body.dense-ui .form-field input,
body.dense-ui .form-field select,
body.dense-ui .multi-select-trigger,
body.dense-ui .assignment-adviser-picker select,
body.dense-ui .teacher-assignment-row input,
body.dense-ui .teacher-assignment-row select,
body.dense-ui .assignment-toolbar select {
  min-height: 28px;
  height: 28px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 12px;
}

body.dense-ui .button.icon-only {
  width: 28px;
  min-width: 28px;
  height: 28px;
}

body.dense-ui table[data-table-name] {
  table-layout: fixed;
}

body.dense-ui table[data-table-name] thead th {
  height: 28px;
  padding: 0 6px;
  font-size: 11px;
}

body.dense-ui table[data-table-name] tbody td {
  height: 32px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.25;
}

body.dense-ui table[data-table-name] th,
body.dense-ui table[data-table-name] td {
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dense-ui table[data-table-name] td > :not(.row-actions),
body.dense-ui table[data-table-name] td > .name-cell,
body.dense-ui table[data-table-name] td > .name-cell > :not(.student-avatar),
body.dense-ui table[data-table-name] td strong,
body.dense-ui table[data-table-name] td small,
body.dense-ui table[data-table-name] td span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dense-ui table[data-table-name] td .name-cell {
  gap: 6px;
}

body.dense-ui .pill {
  min-height: 18px;
  padding: 0 6px;
  font-size: 11px;
}

body.dense-ui .student-avatar {
  width: 20px;
  height: 20px;
  font-size: 10px;
}

body.dense-ui .stat {
  padding: 8px;
}

@media (max-width: 1024px) {
  body.dense-ui table[data-table-name] tbody tr.is-compact-collapsed td:nth-child(n+5):nth-last-child(n+2) {
    display: none;
  }

  body.dense-ui table[data-table-name] tbody tr.is-compact-collapsed td:last-child .row-actions::before {
    content: "More";
    display: inline-block;
    margin-right: 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
  }
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav span,
  .account-card div {
    display: none;
  }

  .brand {
    justify-content: center;
    padding: 14px 8px;
  }

  .nav a {
    justify-content: center;
  }

  .subnav {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .school-layout {
    grid-template-columns: 1fr;
  }

  .assignments-filters,
  .class-record-filters,
  .sf2-filters,
  .sf4-filters,
  .sf8-filters,
  .sf7-filters,
  .assignments-layout,
  .assignment-roster-grid {
    grid-template-columns: 1fr;
  }

  .assignments-sections {
    position: static;
  }

  .teacher-assignment-row {
    grid-template-columns: 1fr;
  }

  .assignment-workspace-header,
  .assignment-header-actions,
  .class-record-detail-header,
  .class-record-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .class-record-item-form {
    grid-template-columns: 1fr 1fr;
  }

  .school-files-layout {
    grid-template-columns: 1fr;
  }

  .school-files-sidebar {
    position: static;
  }

  .assignment-adviser-picker select {
    width: 100%;
  }

  .record-view-grid,
  .staff-profile-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-summary,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .school-summary {
    position: static;
  }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  body.mobile-nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 110;
    background: var(--overlay);
  }

  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    min-height: 100dvh;
    z-index: 120;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 0 18px 40px rgba(34, 40, 49, .28);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .nav-toggle {
    display: inline-flex;
    min-width: 44px;
    width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 0;
    flex: 0 0 auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 130;
    min-height: 56px;
    padding: 0 var(--space-3);
    gap: var(--space-2);
    background: var(--surface);
  }

  .crumbs {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
  }

  .top-actions {
    margin-left: auto;
  }

  .page {
    width: 100%;
    padding: var(--space-3) var(--space-3) var(--space-6);
  }

  .grid,
  .school-layout,
  .dashboard-summary,
  .dashboard-grid,
  .assignments-filters,
  .class-record-filters,
  .sf2-filters,
  .sf4-filters,
  .sf8-filters,
  .sf7-filters,
  .assignments-layout,
  .assignment-roster-grid,
  .school-files-layout,
  .record-view-grid,
  .school-logo-row,
  .form-grid,
  .form-row-three,
  .form-row-four,
  .form-row-two,
  .form-row-school,
  .subject-setup-grid,
  .subject-detail-grid,
  .weight-panel,
  .checkbox-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .page-header,
  .toolbar,
  .assignment-workspace-header,
  .class-record-detail-header,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group,
  .assignment-header-actions,
  .class-record-actions,
  .settings-actions,
  .modal-footer {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-group .button,
  .modal-footer .button,
  .settings-actions .button {
    width: 100%;
  }

  .button,
  .button.icon-only,
  .search,
  .form-field input,
  .form-field select,
  .multi-select-trigger,
  .assignment-adviser-picker select,
  .teacher-assignment-row input,
  .teacher-assignment-row select,
  .assignment-toolbar select {
    min-height: 44px;
  }

  .button.icon-only {
    min-width: 44px;
    width: 44px;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .nav a,
  .nav-group summary,
  .subnav a {
    min-height: 44px;
  }

  .subnav {
    margin: 0;
    gap: var(--space-1);
  }

  .search-wrap {
    min-width: 0;
    width: 100%;
  }

  .search {
    width: 100%;
    min-width: 0;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll table {
    min-width: 640px;
  }

  .table-scroll .mobile-card-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 var(--space-2);
    background: transparent;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: var(--space-2);
    margin-bottom: var(--space-2);
    box-shadow: var(--shadow-sm);
  }

  .mobile-card-table tbody td {
    display: grid;
    grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
    align-items: start;
    gap: var(--space-2);
    height: auto;
    min-height: 0;
    padding: 6px 0;
    white-space: normal;
    border-bottom: 1px solid var(--border-soft);
  }

  .mobile-card-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: .02em;
  }

  .mobile-card-table tbody td:first-child {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .mobile-card-table tbody td:first-child::before {
    content: none;
  }

  .mobile-card-table tbody td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .mobile-card-table tbody td:last-child .row-actions {
    justify-content: flex-end;
  }

  .mobile-card-table .name-cell {
    align-items: flex-start;
  }

  .mobile-card-table .name-cell .student-avatar {
    flex: 0 0 auto;
  }

  .mobile-card-table tbody td strong,
  .mobile-card-table tbody td small {
    display: block;
  }

  .school-summary,
  .school-files-sidebar,
  .assignments-sections {
    position: static;
    top: auto;
  }

  .assignment-adviser-picker select {
    width: 100%;
  }

  .modal-backdrop {
    padding: var(--space-2);
  }

  .modal {
    width: min(100%, 100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
}

@media (max-width: 720px) {
  .app {
    display: block;
  }

  .sidebar {
    min-height: auto;
  }

  .brand div:not(.brand-mark),
  .nav span,
  .account-card div {
    display: block;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .subnav {
    grid-column: 1 / -1;
    display: grid;
    margin: 0;
  }

  .topbar,
  .page {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .page-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-group {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-row-three {
    grid-template-columns: 1fr;
  }

  .subject-setup-grid,
  .subject-detail-grid,
  .weight-panel {
    grid-template-columns: 1fr;
  }

  .weight-panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-row-four {
    grid-template-columns: 1fr;
  }

  .form-row-two {
    grid-template-columns: 1fr;
  }

  .class-record-item-form {
    grid-template-columns: 1fr;
  }

  .form-row-school {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    flex-direction: column-reverse;
  }

  .settings-actions .button {
    width: 100%;
  }

  .school-logo-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .button {
    width: 100%;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
