:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #65736c;
  --line: #dfe6e1;
  --brand: #2f7d5c;
  --brand-dark: #205b43;
  --accent: #f2b84b;
  --danger: #b42318;
  --success: #1f7a4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

.mobile-navigation-toggle,
.mobile-navigation-logo,
.brand-mobile-name,
.brand-current-section {
  display: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: #15231d;
  color: #fff;
  padding: 24px 18px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #1d2522;
  font-weight: 800;
}

.brand-mark:has(img) {
  background: transparent;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand small {
  display: block;
  color: #b7c9bf;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 4px;
}

nav a {
  color: #dce7e1;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

nav a:hover {
  background: #22362d;
}

nav a.is-active {
  background: var(--accent);
  color: #1d2522;
  font-weight: 900;
}

.navigation-logout {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid #3b4d43;
}

.navigation-logout button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: transparent;
  color: #ffb4ab;
  text-align: left;
  font-weight: 600;
}

.navigation-logout button:hover {
  background: #22362d;
}

.navigation-logout button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.main {
  width: min(1560px, calc(100% - 260px));
  margin-left: 260px;
  padding: 32px;
  display: flex;
  flex-direction: column;
}

.main > * {
  order: 50;
}

.topbar {
  order: 1;
}

.alert {
  order: 2;
}

.metrics {
  order: 3;
}

#escuela {
  order: 10;
}

#ciclo {
  order: 11;
}

#niveles {
  order: 12;
}

#asignaturas {
  order: 13;
}

#profesores {
  order: 14;
}

#grupos {
  order: 15;
}

#agenda {
  order: 16;
}

#documentos {
  order: 17;
}

#comunicados {
  order: 18;
}

#alumnos {
  order: 19;
}

#familias {
  order: 20;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

.topbar-actions form {
  margin: 0;
}

.cycle-view-form label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
  text-transform: uppercase;
}

.cycle-view-form select {
  min-width: 150px;
  padding: 9px 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 22px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 14px;
  color: var(--muted);
  white-space: nowrap;
}

.alert {
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 14px 16px;
  font-weight: 700;
}

.alert.success {
  background: #dff5e9;
  color: var(--success);
}

.alert.error {
  background: #fde3df;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.metrics article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metrics strong {
  display: block;
  font-size: 28px;
}

.metrics span {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 22px;
}

.panel.is-section-hidden,
.metrics.is-section-hidden {
  display: none;
}

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

.panel-head p {
  max-width: 460px;
  margin: 2px 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label,
fieldset {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend {
  padding: 0 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 9px 10px;
}

textarea {
  min-height: 150px;
  resize: vertical;
}

input[type="color"] {
  padding: 4px;
}

.wide {
  grid-column: 1 / -1;
}

.logo-preview {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 120px;
  overflow: hidden;
  background: #f9fbfa;
  color: var(--muted);
  font-weight: 800;
}

.logo-preview img {
  max-height: 110px;
  max-width: 100%;
  object-fit: contain;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check input,
.check-grid input {
  width: auto;
  min-height: 0;
}

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

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

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

.family-mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  color: var(--brand-dark);
  font-weight: 800;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.agenda-board {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.agenda-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  margin-top: 18px;
  padding: 16px;
}

.agenda-search h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.agenda-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.agenda-tools form {
  margin: 0;
}

.agenda-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.agenda-group-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.agenda-group-head h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.agenda-group-head h3 {
  margin: 0;
}

.agenda-week {
  display: grid;
  gap: 12px;
}

.agenda-timeline {
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
}

.agenda-time-head,
.agenda-day-head,
.agenda-time-cell,
.agenda-cell,
.agenda-empty-row {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 10px;
}

.agenda-time-head,
.agenda-day-head {
  background: #eef4f0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
  position: sticky;
  top: 0;
  z-index: 1;
}

.agenda-time-head,
.agenda-time-cell {
  border-left: 1px solid var(--line);
  min-width: 126px;
}

.agenda-time-cell {
  align-items: flex-start;
  background: #f9fbfa;
  color: var(--brand-dark);
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 900;
  gap: 8px;
}

.agenda-time-cell strong {
  white-space: nowrap;
}

.agenda-time-cell form {
  margin: 0;
}

.agenda-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.agenda-row-add {
  background: #eef6f1;
  border-color: #b8c9bf;
  color: var(--brand-dark);
}

.agenda-cell {
  background: #fff;
  display: grid;
  gap: 8px;
  min-height: 70px;
}

.agenda-add-slot {
  align-items: center;
  align-self: stretch;
  background: #f7faf8;
  border: 1px dashed #b8c9bf;
  border-radius: 8px;
  color: var(--brand-dark);
  cursor: pointer;
  display: flex;
  font-size: 20px;
  font-weight: 900;
  justify-content: center;
  min-height: 46px;
  width: 100%;
}

.agenda-add-slot:hover {
  background: #eef6f1;
  border-style: solid;
}

.agenda-add-slot-compact {
  font-size: 16px;
  min-height: 30px;
}

.agenda-empty-cell,
.agenda-empty-row {
  color: var(--muted);
  font-size: 12px;
}

.agenda-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  padding: 12px;
}

.agenda-day h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.agenda-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 0;
  padding: 9px;
}

.agenda-item .compact-result-main strong,
.agenda-item .compact-result-main small {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.agenda-item strong {
  color: var(--brand-dark);
  font-size: 13px;
  line-height: 1.25;
}

.agenda-item span {
  font-weight: 800;
}

.agenda-item small {
  color: var(--muted);
  display: block;
  line-height: 1.35;
  margin-top: 4px;
}

.document-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.document-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  margin-top: 18px;
  padding: 16px;
}

.document-search h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.news-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  margin-top: 18px;
  padding: 16px;
}

.news-search h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.news-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.student-search,
.family-search {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  margin-bottom: 18px;
  padding: 16px;
}

.student-search h3,
.family-search h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.search-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.student-list,
.family-results {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.news-card,
.document-card,
.student-card,
.family-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px;
}

.news-card div {
  display: grid;
  gap: 4px;
}

.news-card small,
.news-card p {
  color: var(--muted);
}

.news-card p {
  margin: 0;
}

.compact-result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 54px;
  padding: 8px 10px;
}

.compact-result-card.selectable-result {
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.compact-result-card.selectable-result:hover,
.compact-result-card.is-selected-row,
.linked-row.is-selected-row,
.student-note-row.is-selected-row {
  background: color-mix(in srgb, var(--brand) 8%, #fff);
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  box-shadow: 0 8px 22px rgba(37, 86, 62, 0.1);
}

.compact-result-card.selectable-result:hover {
  transform: translateY(-1px);
}

.compact-result-main {
  min-width: 0;
}

.compact-result-main strong,
.compact-result-main span,
.compact-result-main small,
.compact-result-main p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-result-main strong {
  display: block;
  font-size: 14px;
}

.compact-result-main span,
.compact-result-main small,
.compact-result-main p {
  display: block;
  font-size: 12px;
}

.linked-list .compact-result-card {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.inline-select {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

.inline-select select {
  min-width: 120px;
}

.document-card div {
  display: grid;
  gap: 2px;
}

.document-card span,
.document-card small,
.student-card small,
.family-card small {
  color: var(--muted);
}

.card-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.document-card .card-actions,
.news-card .card-actions {
  display: flex;
}

.card-actions form {
  margin: 0;
}

.icon-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.icon-action {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  font-size: 16px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  line-height: 1;
  min-height: 34px;
  padding: 0;
  text-decoration: none;
  width: 34px;
}

.icon-action:hover {
  background: #eef4f0;
}

.danger-icon {
  border-color: #f0b7b0;
  color: var(--danger);
}

.danger-icon:hover {
  background: #fde3df;
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
}

.actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  grid-column: 1 / -1;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0 18px;
}

button:hover {
  background: var(--brand-dark);
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 12px 0;
}

#agenda:not(.is-schedule-editing) > .edit-panel,
#agenda:not(.is-schedule-editing) > .panel-actions,
#agenda:not(.is-schedule-editing) > .create-form {
  display: none;
}

#agenda.is-schedule-editing:not(.is-editing) > .edit-panel,
#agenda.is-schedule-editing:not(.is-creating) > .create-form,
#agenda.is-schedule-editing > .panel-actions {
  display: none;
}

.is-creating > .edit-panel,
.is-creating > .panel-actions,
.is-editing > .panel-actions,
.panel.is-searching > .panel-actions,
.panel.is-searching > .subpanel,
.module-shell.is-searching > .panel-actions,
.panel.is-creating > .subpanel,
.panel.is-creating > .document-search,
.panel.is-creating > .news-search,
.panel.is-creating > .agenda-search,
.module-shell.is-creating > .student-search,
.subpanel.is-creating > label,
.subpanel.is-creating > .editor-form {
  display: none;
}

.create-form {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.is-hidden {
  display: none !important;
}

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

.split-actions {
  justify-content: flex-end;
}

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

.danger-button:hover {
  background: #8f1c13;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chips span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  padding: 8px 10px;
}

.compact-checks {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.compact-checks label {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.field-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.readonly-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.readonly-field span,
.form-note {
  color: var(--muted);
  font-size: 13px;
}

.readonly-field strong {
  color: var(--ink);
}

.form-note {
  margin: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #f9fbfa;
  color: var(--ink);
}

.secondary-button:hover {
  background: #eef4f0;
}

.editable-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.edit-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  margin-top: 18px;
  padding: 16px;
}

.subpanel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 18px;
  padding: 16px;
}

.subpanel h3 {
  margin: 0;
  font-size: 17px;
}

.editor-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.editor-form.is-disabled {
  opacity: 0.58;
}

.editable-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) 110px;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.guardian-row {
  grid-template-columns: repeat(4, minmax(120px, 1fr)) repeat(3, minmax(110px, auto)) 110px;
}

.teacher-row {
  grid-template-columns: repeat(5, minmax(120px, 1fr)) repeat(2, minmax(110px, auto)) 110px;
}

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

.module-shell {
  display: grid;
  gap: 14px;
}

.linked-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  padding: 16px;
}

.family-composition {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.family-composition h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.linked-head,
.inline-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.linked-head h3 {
  margin: 0;
  font-size: 17px;
}

.secondary-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
  text-decoration: none;
}

.secondary-link:hover {
  background: #eef6f1;
}

.input-with-button {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.linked-list,
.guardian-repeater {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.linked-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(100px, 140px) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.compact-linked-row {
  grid-template-columns: 1fr;
  margin-bottom: 8px;
}

.teacher-student-card {
  border: 1px solid #dfe7e2;
  border-radius: 10px;
  background: #fff;
  display: grid;
  gap: 12px;
  padding: 0;
  overflow: hidden;
}

.teacher-student-summary {
  cursor: pointer;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 14px 16px;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.teacher-student-summary:hover {
  background: color-mix(in srgb, var(--brand) 7%, #fff);
}

.teacher-student-summary:hover .student-name-line {
  color: var(--brand);
}

.student-avatar {
  align-items: center;
  background: color-mix(in srgb, var(--brand) 13%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, #fff);
  border-radius: 999px;
  color: var(--brand-dark);
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.student-row-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.student-row-title {
  min-width: 0;
}

.student-name-line {
  align-items: center;
  color: #17241d;
  display: inline-flex;
  font-size: 16px;
  gap: 6px;
  line-height: 1.2;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.student-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.birthday-badge {
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 26px;
  line-height: 1;
  overflow: visible;
  transform: translateY(-2px);
  white-space: nowrap;
}

.student-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.student-meta-pills span {
  background: #f3f6f4;
  border: 1px solid #e2e9e4;
  border-radius: 999px;
  color: #586a60;
  font-size: 12px;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  padding: 5px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-row-chevron {
  color: #8a9a91;
  font-size: 28px;
  line-height: 1;
  justify-self: end;
}

.teacher-student-section {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 0 14px;
}

.teacher-student-section.is-collapsed .student-section-body {
  display: none;
}

.teacher-student-section:not(.is-collapsed) > .student-section-toggle,
.teacher-student-section:not(.is-collapsed) > .student-notes-head .student-section-toggle {
  background: color-mix(in srgb, var(--brand) 8%, #fff);
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  box-shadow: 0 8px 22px rgba(37, 86, 62, 0.1);
  color: var(--brand-dark);
}

.student-section-toggle {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.student-notes-head .student-section-toggle {
  flex: 1;
}

.student-section-body {
  display: grid;
  gap: 10px;
}

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

.teacher-student-grid h3,
.teacher-student-section h3,
.student-notes-head h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.student-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.student-note-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 10px;
  padding: 12px;
}

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

.student-note-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
}

.student-note-row.is-note-editing {
  display: none;
}

.student-note-row time {
  color: var(--muted);
  font-size: 13px;
}

.student-note-row strong,
.student-note-row small {
  display: block;
}

.student-note-content {
  margin: 8px 0 0;
  color: var(--text);
}

.attendance-filter {
  margin-bottom: 16px;
}

.attendance-mode-actions {
  justify-content: flex-start;
}

.attendance-date-banner {
  align-items: center;
  background: color-mix(in srgb, var(--brand) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line));
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
}

.attendance-form {
  display: grid;
  gap: 14px;
}

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

.attendance-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) 150px minmax(180px, 1fr);
  padding: 10px;
}

.attendance-row strong,
.attendance-row small {
  display: block;
}

.attendance-status-present {
  background: #e7f6ee;
  color: #17633e;
}

.attendance-status-absent {
  background: #fde8e6;
  color: #9b1c13;
}

.attendance-status-late {
  background: #fff4d8;
  color: #7a4d00;
}

.attendance-status-justified {
  background: #e8f0ff;
  color: #244f9e;
}

.attendance-status-none {
  background: #f1f3f2;
  color: var(--muted);
}

.attendance-summary-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
}

.attendance-summary-card.has-alert {
  border-color: var(--danger);
}

.attendance-summary-head {
  appearance: none;
  background: #fff;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-weight: 700;
  justify-content: space-between;
  padding: 12px;
  text-align: left;
}

.attendance-summary-card.has-alert .attendance-summary-head {
  background: #fff0ee;
  color: var(--danger);
}

.attendance-summary-body {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.attendance-summary-body p {
  margin: 0;
}

.alert-text {
  color: var(--danger);
  font-weight: 700;
}

.family-response-form {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.family-response-form .actions {
  align-items: end;
}

.status-note {
  background: color-mix(in srgb, var(--primary) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, #fff);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-top: 10px;
  padding: 10px 12px;
}

.authorization-response-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 10px;
}

.authorization-response-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) auto minmax(140px, auto);
  padding: 9px 10px;
}

.authorization-response-row strong,
.authorization-response-row small {
  display: block;
}

.authorization-status {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  text-align: center;
}

.authorization-status-accepted {
  background: #dcfce7;
  color: #166534;
}

.authorization-status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.authorization-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.panel.family-profile,
.panel.teacher-authorizations {
  border: 0;
  padding: 0;
  background: transparent;
}

.profile-contact-card,
.teacher-authorization-card {
  min-width: 0;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow-wrap: anywhere;
}

.profile-caption {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.profile-contact-card h3,
.teacher-authorization-card h3 {
  margin: 5px 0 0;
  font-size: 20px;
  line-height: 1.3;
}

.profile-contact-card header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-contact-data,
.teacher-authorization-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 0;
}

.profile-contact-data dt,
.teacher-authorization-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.profile-contact-data dd,
.teacher-authorization-meta dd {
  margin: 4px 0 0;
  font-size: 14px;
}

.profile-address {
  grid-column: 1 / -1;
}

.profile-guardians-title {
  margin: 24px 0 12px;
  font-size: 16px;
}

.profile-guardian-list,
.teacher-authorization-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  align-items: start;
  gap: 16px;
}

.profile-access {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.profile-access strong {
  color: var(--ink);
  font-weight: 600;
}

.teacher-authorization-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.teacher-publication-status {
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 12px;
}

.teacher-authorization-description {
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.teacher-authorization-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  margin-top: 18px;
  border-radius: 12px;
  background: #f5f7f4;
  font-size: 11px;
  color: var(--muted);
}

.teacher-authorization-counts strong {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
}

.teacher-authorization-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.teacher-authorization-actions form {
  margin: 0;
}

.teacher-authorization-actions button {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.teacher-authorization-delete {
  color: var(--danger);
  background: transparent;
}

.teacher-authorization-delete:hover {
  background: #fff0ee;
}

.teacher-authorizations .authorization-response-row {
  grid-template-columns: minmax(0, 1fr) auto;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0;
  font-size: 13px;
}

.teacher-authorizations .authorization-response-row > small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.teacher-authorizations .authorization-response-row > div {
  min-width: 0;
}

.teacher-authorizations .authorization-response-row .authorization-status {
  font-size: 11px;
  font-weight: 600;
}

.teacher-authorizations [data-teacher-authorization-form] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.teacher-authorizations [data-teacher-authorization-form] :is(label, input, select, textarea) {
  min-width: 0;
  max-width: 100%;
}

.teacher-authorizations .actions {
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .profile-guardian-list,
  .teacher-authorization-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .profile-contact-card,
  .teacher-authorization-card {
    padding: 16px;
  }

  .profile-contact-card h3,
  .teacher-authorization-card h3 {
    font-size: 18px;
  }

  .profile-contact-data,
  .teacher-authorizations [data-teacher-authorization-form] {
    grid-template-columns: minmax(0, 1fr);
  }

  .teacher-authorizations [data-teacher-authorization-form] :is(input, select, textarea) {
    font-size: 16px;
  }

  .teacher-authorizations .student-notes-head {
    flex-wrap: wrap;
  }
}

.panel.family-students {
  padding: 0;
  border: 0;
  background: transparent;
}

.family-student-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: 16px;
}

.family-student-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  overflow-wrap: anywhere;
}

.family-student-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.family-student-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #e8f0e9;
  color: var(--brand-dark);
  font-size: 17px;
  font-weight: 600;
  text-transform: uppercase;
}

.family-student-caption,
.family-student-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.family-student-head h3 {
  margin: 3px 0 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.family-student-school,
.family-student-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.family-student-school {
  padding: 14px;
  border-radius: 12px;
  background: #f5f7f4;
}

.family-student-data {
  padding: 18px 0;
}

.family-student-card dd {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
}

.family-student-school dd {
  font-weight: 600;
  color: var(--brand-dark);
}

.family-student-tutors {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.family-student-tutors h4 {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.family-student-tutor {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.family-student-tutor + .family-student-tutor {
  margin-top: 12px;
}

.family-student-tutor-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f4f1;
  color: var(--muted);
}

.family-student-tutor strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.family-student-tutor div > span,
.family-student-tutors p {
  display: block;
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.family-student-empty {
  grid-column: 1 / -1;
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
}

.family-student-empty p {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .family-student-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .family-student-card {
    padding: 16px;
  }

  .family-student-head {
    margin-bottom: 16px;
  }

  .family-student-head h3 {
    font-size: 18px;
  }
}

.family-authorizations {
  background: transparent;
  border: 0;
  padding: 0;
}

.family-authorization-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: 16px;
}

.family-authorization-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  overflow-wrap: anywhere;
}

.family-authorization-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.family-authorization-type {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.family-authorization-head .authorization-status {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
}

.family-authorization-card h3 {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.family-authorization-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin: 0;
}

.family-authorization-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.family-authorization-card dd {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.family-authorization-description {
  margin: 18px 0 0;
  color: #46564c;
  font-size: 14px;
  line-height: 1.65;
}

.family-authorization-route {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin: 16px 0 0;
  background: #f5f7f4;
  border-radius: 12px;
}

.family-authorization-route > div {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.family-authorization-route dd {
  margin: 0;
  font-weight: 400;
}

.family-authorization-form,
.family-authorization-response {
  border-top: 1px solid var(--line);
  margin: 18px 0 0;
  padding-top: 12px;
}

.family-authorization-comment-field summary {
  min-height: 44px;
  padding: 11px 0;
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 13px;
}

.family-authorization-comment-field summary span {
  color: var(--muted);
}

.family-authorization-comment-field label {
  margin: 6px 0 14px;
}

.family-authorization-comment-field textarea {
  min-height: 84px;
  font-size: 16px;
  font-weight: 400;
  border-radius: 12px;
}

.family-authorization-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.family-authorization-actions button {
  min-width: 0;
  min-height: 44px;
  padding: 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.family-authorization-reject {
  border: 1px solid var(--line);
  color: var(--danger);
  background: transparent;
}

.family-authorization-reject:hover {
  background: #fff0ee;
}

.family-authorization-card :is(button, summary, textarea):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.family-authorization-response p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.family-authorization-response .family-authorization-comment {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
}

.family-authorization-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 32px 18px;
  text-align: center;
}

.family-authorization-empty p {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .panel.family-authorizations {
    padding: 0;
  }

  .family-authorization-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .family-authorization-card {
    padding: 16px;
  }

  .family-authorization-card h3 {
    font-size: 18px;
  }
}

.chat-new-form {
  margin-bottom: 18px;
}

.chat-list {
  display: grid;
  gap: 16px;
}

.chat-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
}

.chat-conversation-list {
  align-content: start;
  display: grid;
  gap: 10px;
  max-height: 680px;
  overflow-y: auto;
}

.chat-conversation-list a {
  text-decoration: none;
}

.chat-thread {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.chat-thread-head {
  align-items: center;
  background: #f7faf8;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.chat-thread-head strong,
.chat-thread-head span,
.chat-thread-head small {
  display: block;
}

.chat-thread-head span,
.chat-thread-head small {
  color: var(--muted);
  font-size: 12px;
}

.chat-bubbles {
  background: #eef4f0;
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px;
}

.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: min(76%, 680px);
  padding: 10px 12px;
}

.chat-bubble p {
  margin: 0 0 6px;
}

.chat-bubble small {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.read-dot {
  background: #16a34a;
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  margin-left: 6px;
  vertical-align: middle;
  width: 8px;
}

.chat-bubble.is-own {
  justify-self: end;
  background: #dcf4e7;
  border-color: #b9e5cc;
}

.chat-bubble.is-other {
  justify-self: start;
  background: #fff;
}

.chat-reply-form {
  align-items: stretch;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.chat-reply-form textarea {
  min-height: 46px;
}

.family-schedule-list {
  display: grid;
  gap: 12px;
}

.family-schedule-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.family-schedule-toggle {
  align-items: center;
  appearance: none;
  background: #fff;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  justify-content: space-between;
  padding: 14px;
  text-align: left;
  width: 100%;
}

.family-schedule-toggle:hover {
  background: #f7faf8;
}

.family-schedule-toggle strong,
.family-schedule-toggle small {
  display: block;
}

.family-schedule-toggle small {
  color: var(--muted);
  margin-top: 3px;
}

.family-schedule-body {
  border-top: 1px solid var(--line);
  padding: 14px;
}

.family-schedule-week {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.family-schedule-day {
  display: grid;
  align-content: start;
  gap: 8px;
}

.family-schedule-day h3 {
  color: var(--brand-dark);
  font-size: 13px;
  margin: 0;
}

.student-teacher-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
}

.student-teacher-list strong,
.student-teacher-list span {
  display: block;
}

.student-teacher-list span {
  color: var(--muted);
  font-size: 13px;
}

.guardian-repeater-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  html {
    touch-action: manipulation;
    scroll-padding-top: calc(104px + env(safe-area-inset-top, 0px));
  }

  .sidebar {
    position: sticky;
    inset: 0 auto auto;
    z-index: 20;
    width: 100%;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    overflow: visible;
    background: rgba(245, 247, 244, 0.94);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
  }

  .sidebar .brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: auto 44px;
    margin: 0;
    gap: 0;
  }

  .sidebar .brand-mark,
  .sidebar .brand-desktop-name {
    display: none;
  }

  .sidebar .brand > div {
    display: contents;
  }

  .sidebar .brand strong {
    display: block;
    grid-column: 2;
    grid-row: 1;
    text-align: center;
    font-size: 18px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar .brand small {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.3;
    overflow-wrap: anywhere;
    color: var(--muted);
  }

  .sidebar .brand-mobile-name,
  .sidebar .brand-current-section {
    display: inline;
  }

  .mobile-navigation-logo {
    display: grid;
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
    place-items: center;
    width: 44px;
    height: 44px;
    color: var(--brand-dark);
    font-size: 22px;
    font-weight: 700;
  }

  .mobile-navigation-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .mobile-navigation-toggle {
    display: grid;
    grid-column: 3;
    grid-row: 2;
    place-items: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--brand-dark);
  }

  .mobile-navigation-toggle:hover,
  .mobile-navigation-toggle[aria-expanded="true"] {
    background: #d5e3da;
  }

  .mobile-navigation-toggle:focus-visible,
  .navigation-logout button:focus-visible,
  .sidebar nav a:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
  }

  .sidebar nav {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: max(12px, env(safe-area-inset-right, 0px));
    width: min(320px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    max-height: calc(100vh - 110px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 110px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    box-shadow: 0 16px 48px rgba(21, 35, 29, 0.2);
  }

  .sidebar.is-navigation-open nav {
    display: grid;
  }

  .sidebar nav a {
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--ink);
  }

  .sidebar nav a:hover {
    background: #edf3ee;
  }

  .sidebar nav a.is-active {
    background: #e0eee5;
    color: var(--brand-dark);
  }

  .navigation-logout {
    display: block;
    margin: 6px 0 0;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }

  .navigation-logout button {
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 12px;
    background: transparent;
    color: var(--danger);
    text-align: left;
    font-weight: 600;
  }

  .navigation-logout button:hover {
    background: #fff0ee;
  }

  .main {
    width: 100%;
    margin-left: 0;
    min-width: 0;
    padding: 14px max(12px, env(safe-area-inset-right, 0px)) 20px max(12px, env(safe-area-inset-left, 0px));
  }

  .topbar {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    min-width: 0;
  }

  .topbar > div {
    min-width: 0;
  }

  .topbar h1 {
    font-size: 22px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .topbar .eyebrow {
    font-size: 11px;
    margin-bottom: 3px;
    overflow-wrap: anywhere;
  }

  .topbar-actions {
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
  }

  .topbar-actions .status-pill {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 5px 8px;
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .cycle-view-form {
    min-width: 0;
    max-width: 100%;
  }

  .cycle-view-form label {
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 11px;
  }

  .cycle-view-form select {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    font-size: 16px;
  }

  .panel {
    min-width: 0;
    padding: 14px;
    margin-bottom: 14px;
  }

  .panel-head {
    display: block;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
  }

  .panel-head h2 {
    font-size: 19px;
  }

  .panel-head p {
    font-size: 13px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }

  .metrics article {
    min-width: 0;
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }

  .metrics strong {
    font-size: 23px;
  }

  .metrics span {
    font-size: 12px;
  }

  .form-grid,
  .form-grid.compact,
  .editable-row,
  .guardian-row,
  .teacher-row,
  .linked-row,
  .family-composition,
  .agenda-board,
  .agenda-week,
  .attendance-row,
  .chat-layout,
  .family-schedule-week,
  .guardian-repeater-row,
  .teacher-student-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .teacher-student-summary {
    display: grid;
    align-items: stretch;
  }

}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.login-logo {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  height: 88px;
  justify-content: center;
  margin: 0 auto 18px;
  overflow: hidden;
  padding: 10px;
  width: 88px;
}

.login-logo img {
  display: block;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.login-logo span {
  color: var(--brand-dark);
  font-size: 34px;
  font-weight: 800;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.quick-login-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.portal-choice-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.portal-choice-list form {
  margin: 0;
}

.portal-choice-button {
  width: 100%;
}

.error-card {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.error-card p {
  color: var(--muted);
}

.error-card dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.error-card dl div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.error-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.error-card dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.error-card pre {
  overflow-x: auto;
  border-radius: 8px;
  background: #15231d;
  color: #e8f2ed;
  padding: 14px;
}

@media (max-width: 980px) {
  .panel.admin-mobile-panel {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .admin-mobile-panel :where(div, form, label, fieldset, article, section) {
    min-width: 0;
    max-width: 100%;
  }

  .admin-mobile-panel :where(h3, p, strong, span, small, label, legend, a) {
    overflow-wrap: anywhere;
  }

  .admin-mobile-panel :is(.edit-panel, .student-search, .family-search, .subpanel) {
    padding: 14px;
    margin-top: 12px;
    border-radius: 16px;
    background: var(--panel);
  }

  .admin-mobile-panel :is(.student-search, .family-search) {
    margin-bottom: 0;
  }

  .admin-mobile-panel .create-form {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
  }

  .admin-mobile-panel :is(.form-grid, .form-grid.compact, .family-seed-row, .family-composition, .guardian-repeater-row, .check-grid, .compact-checks, .editable-row, .guardian-row, .teacher-row, .linked-row, .input-with-button) {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .admin-mobile-panel :is(input, select, textarea) {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
    border-radius: 10px;
  }

  .admin-mobile-panel input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  .admin-mobile-panel select {
    min-height: 44px;
  }

  .admin-mobile-panel :is(input[type="checkbox"], input[type="radio"]) {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
  }

  .admin-mobile-panel fieldset {
    min-inline-size: 0;
    padding: 10px;
    border-radius: 12px;
  }

  .admin-mobile-panel legend {
    max-width: 100%;
    white-space: normal;
  }

  .admin-mobile-panel .check-grid label {
    min-height: 44px;
    font-weight: 500;
  }

  .admin-mobile-panel :is(.linked-panel, .family-composition, .guardian-repeater-row) {
    padding: 10px;
    border-radius: 12px;
  }

  .admin-mobile-panel [data-group-staff-panel] {
    grid-column: 1 / -1;
  }

  .admin-mobile-panel :is(.compact-result-card, .linked-list .compact-result-card, .family-card, .student-card) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
    gap: 10px;
    border-radius: 12px;
  }

  .admin-mobile-panel .compact-result-main :is(strong, span, small, p) {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .admin-mobile-panel .compact-result-main strong {
    font-size: 15px;
  }

  .admin-mobile-panel .compact-result-main :is(span, small, p) {
    margin-top: 4px;
    line-height: 1.5;
  }

  .admin-mobile-panel :is(.linked-head, .inline-tools, .inline-select) {
    flex-wrap: wrap;
    gap: 8px;
    white-space: normal;
  }

  .admin-mobile-panel .inline-select {
    width: 100%;
  }

  .admin-mobile-panel .inline-select select {
    min-width: 0;
    width: 100%;
  }

  .admin-mobile-panel :is(.actions, .panel-actions, .row-actions, .search-actions, .card-actions, .icon-actions) {
    flex-wrap: wrap;
    gap: 8px;
  }

  .admin-mobile-panel :is(.actions, .panel-actions, .row-actions, .search-actions) > button {
    flex: 1 1 140px;
    min-width: 0;
  }

  .admin-mobile-panel button,
  .admin-mobile-panel .secondary-link {
    min-height: 44px;
    max-width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    border-radius: 10px;
  }

  .admin-mobile-panel .icon-action {
    width: 44px;
    flex-shrink: 0;
    padding: 0;
  }

  .admin-mobile-panel .panel-actions {
    margin-top: 12px;
  }
}

@media (max-width: 560px) {
  .teacher-student-summary {
    grid-template-columns: 40px minmax(0, 1fr) 16px;
    gap: 10px;
    padding: 12px;
  }

  .student-avatar {
    font-size: 12px;
    height: 38px;
    width: 38px;
  }

  .student-name-line {
    font-size: 15px;
  }

  .birthday-badge {
    font-size: 23px;
  }

  .student-meta-pills span {
    font-size: 11px;
    padding: 5px 7px;
  }
}
