:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #66737d;
  --line: #d9e1e6;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warn: #fef3c7;
  --shadow: 0 18px 50px rgba(20, 34, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a {
  color: inherit;
  text-decoration: none;
}

input,
select,
textarea,
button {
  font: inherit;
}

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

textarea {
  resize: vertical;
}

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

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.1), transparent 38%),
    linear-gradient(240deg, rgba(37, 99, 235, 0.08), transparent 36%),
    var(--bg);
}

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

.brand-mark,
.logo span,
.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.auth-card h1,
.toolbar h1,
.panel h2 {
  margin: 12px 0;
}

.auth-card p,
.class-row span,
.archive-list span,
.timeline span {
  color: var(--muted);
}

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

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

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

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

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

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

.delete-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.delete-icon:hover {
  background: #fff1f2;
}

.edit-icon {
  color: var(--accent-strong);
}

.edit-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edit-icon:hover {
  background: #e6f4f1;
}

.save-icon {
  color: var(--accent-strong);
  border-color: #99d6ce;
  background: #ecfdf5;
}

.save-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save-icon:hover {
  background: #d8f3dc;
}

.subtle-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
}

.text-button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  padding: 0;
  text-align: left;
}

.text-button:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.check input {
  width: 18px;
  min-height: auto;
}

.alert,
.notice,
.success {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  font-weight: 700;
}

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

.notice {
  background: var(--warn);
}

.success {
  background: #dcfce7;
  color: #166534;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 70px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.menu-toggle,
.menu-backdrop {
  display: none !important;
}

.menu-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  height: 2px;
  margin: 5px 0;
  border-radius: 999px;
  background: var(--ink);
}

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

.logo span {
  width: 36px;
  height: 36px;
}

.main-menu {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.main-menu a,
.profile-button,
.lesson-tabs a {
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 10px 12px;
}

.main-menu a.active,
.lesson-tabs a.active {
  background: #e6f4f1;
  color: var(--accent-strong);
}

.profile-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  padding: 0;
  background: #fff;
  color: var(--accent-strong);
}

.profile-button.active,
.profile-button:hover {
  border-color: var(--accent);
  background: #e6f4f1;
}

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

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

.profile-card h3 {
  margin: 0;
}

.profile-card-wide,
.profile-save {
  grid-column: 1 / -1;
}

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

.color-settings input[type="color"] {
  padding: 6px;
}

.color-control {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
}

.color-control input[type="color"] {
  min-height: 42px;
}

.color-control input[type="text"],
.color-control input[data-color-hex] {
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.toolbar h1 {
  font-size: 34px;
  line-height: 1.12;
  margin: 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
  font-size: 12px;
}

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

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

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(20, 34, 45, 0.05);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.panel {
  padding: 20px;
}

.weekly-panel {
  margin-top: 16px;
}

.dashboard-notes-panel {
  margin-top: 16px;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head-row h2,
.panel-head-row p {
  margin: 0;
}

.panel-head-row p {
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}

.dashboard-week-head > div {
  width: 100%;
}

.weekly-list {
  display: grid;
  gap: 10px;
}

.week-lesson {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.week-lesson:hover {
  border-color: var(--accent);
}

.week-lesson small,
.week-topic {
  color: var(--muted);
}

.week-lesson span:nth-child(2) {
  display: grid;
  gap: 3px;
}

.week-lesson em {
  justify-self: end;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  padding: 6px 9px;
}

.grade-progress.pending {
  background: #fef3c7;
  color: #92400e;
}

.grade-progress.complete {
  background: #e6f4f1;
  color: var(--accent-strong);
}

.week-lesson.cancelled {
  border-color: #fecaca;
  background: #fff1f2;
}

.week-lesson.cancelled em {
  background: #fee2e2;
  color: var(--danger);
}

.schedule-panel {
  margin-top: 16px;
}

.preparation-panel {
  margin-top: 16px;
}

.preparation-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preparation-form {
  display: grid;
  gap: 12px;
}

.preparation-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preparation-table th,
.preparation-table td {
  border: 1px solid #9ca3af;
  padding: 3px;
  min-width: 70px;
  max-width: 86px;
  height: 28px;
  vertical-align: middle;
}

.preparation-table thead th {
  background: #f8fafc;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.preparation-table thead small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-top: 2px;
}

.preparation-table thead th.prep-subject-head {
  background: color-mix(in srgb, var(--subject-color) 18%, #fff);
  color: var(--ink);
}

.preparation-table thead th.prep-subject-head small {
  color: #374151;
}

.preparation-table .prep-kw-col,
.preparation-table .prep-date-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  text-align: center;
}

.preparation-table .prep-kw-col {
  min-width: 38px;
  width: 38px;
}

.preparation-table .prep-date-col {
  left: 38px;
  min-width: 68px;
  width: 68px;
}

.preparation-table thead .prep-kw-col,
.preparation-table thead .prep-date-col {
  z-index: 4;
  background: #eef6f5;
}

.preparation-table .prep-day-start {
  border-left: 3px solid #9fd2cb !important;
}

.prep-cell {
  background: #fff;
  color: #000;
  font-weight: 400;
  vertical-align: middle;
  text-align: center;
  white-space: normal;
  line-height: 1.15;
}

.prep-cell textarea {
  width: 100%;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  padding: 0;
  resize: none;
  text-align: center;
  align-content: center;
}

.prep-cell textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: rgba(255, 255, 255, 0.65);
}

.prep-cell strong {
  display: block;
  margin-bottom: 2px;
}

.prep-empty {
  background: #fff;
}

.prep-filled {
  background: #fff3bf;
}

.prep-confirmed {
  background: #d8f3dc;
}

.prep-no-lesson {
  background: var(--no-lesson);
}

.prep-holiday-merged {
  height: 34px;
  font-weight: 900;
  text-align: center;
}

.prep-cancelled {
  background: var(--prep-cancelled);
}

.prep-test {
  background: var(--prep-test);
}

.preparation-table tbody th,
.preparation-table tbody td {
  color: #000;
  font-weight: 400;
}

.preparation-table tbody .prep-holiday-merged {
  color: #000;
  font-weight: 900;
}

.confirmation-panel {
  margin-top: 16px;
}

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

.confirmation-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.confirmation-list span {
  display: grid;
  gap: 3px;
}

.confirmation-list small {
  color: var(--muted);
  font-weight: 800;
}

.confirm-icon {
  border-color: #86efac;
  background: #ecfdf5;
  color: #15803d;
}

.confirm-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.notes-panel {
  display: grid;
  gap: 14px;
}

.note-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

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

.note-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.note-item strong,
.note-item small {
  display: block;
  overflow-wrap: anywhere;
}

.note-item small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.note-item.archived {
  background: #f8fafc;
}

.notes-archive {
  margin-top: 2px;
}

.notes-archive summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.notes-archive .notes-list {
  margin-top: 10px;
}

.schedule-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.schedule-toolbar div {
  margin-left: auto;
  text-align: right;
}

.schedule-jump {
  margin: 0;
}

.schedule-jump label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.schedule-jump input {
  width: 128px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 0;
}

.schedule-jump input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.schedule-toolbar h2,
.schedule-toolbar p {
  margin: 0;
}

.schedule-toolbar p {
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 64px repeat(5, minmax(170px, 1fr));
  grid-template-rows: auto repeat(16, minmax(92px, auto));
  gap: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.schedule-corner,
.schedule-day-head,
.schedule-period,
.schedule-slot {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.schedule-corner,
.schedule-day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef6f5;
  color: var(--accent-strong);
  font-weight: 900;
  padding: 12px;
}

.schedule-day-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.schedule-day-head.holiday {
  background: var(--no-lesson);
  color: #111827;
}

.schedule-day-head small {
  display: block;
  margin-top: 2px;
  color: #111827;
  font-size: 11px;
  line-height: 1.1;
}

.schedule-day-head .schedule-date {
  color: var(--muted);
  font-weight: 700;
}

.day-short {
  display: none;
}

.schedule-period {
  display: grid;
  place-items: center;
  min-height: 92px;
  background: #fafcfc;
  color: var(--muted);
  font-weight: 900;
}

.schedule-slot {
  min-height: 92px;
  padding: 8px;
  background: #fff;
}

.schedule-slot.holiday {
  background: color-mix(in srgb, var(--no-lesson) 72%, #fff);
  color: #111827;
  font-weight: 900;
  text-align: center;
}

.schedule-slot.holiday span {
  display: block;
  font-size: 12px;
  line-height: 1.15;
}

.schedule-item {
  display: grid;
  align-content: start;
  gap: 5px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--subject-color, var(--accent));
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  margin: 6px;
  min-height: calc(100% - 12px);
  z-index: 3;
}

.schedule-item.class-test {
  border-color: #fde68a;
  border-left-color: #d97706;
  background: #fef3c7;
}

.schedule-item small,
.schedule-item em {
  color: var(--muted);
  font-style: normal;
}

.schedule-item.class-test em {
  color: #92400e;
  font-weight: 900;
}

.schedule-item.cancelled {
  border-color: #fecaca;
  border-left-color: var(--danger);
  background: #fff1f2;
}

.schedule-item.cancelled em {
  color: var(--danger);
  font-weight: 900;
}

.schedule-status {
  display: grid;
  gap: 2px;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-form input[type="number"] {
  max-width: 86px;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.grades-layout {
  display: block;
}

.class-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.class-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.class-pill.active {
  border-color: #b7ded8;
  background: #e6f4f1;
  color: var(--accent-strong);
}

.semester-switch {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.semester-switch a {
  border-radius: 6px;
  color: var(--muted);
  font-weight: 900;
  padding: 8px 12px;
  text-decoration: none;
}

.semester-switch a.active {
  background: #e6f4f1;
  color: var(--accent-strong);
}

.grade-control-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}

.grade-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(220px, 320px);
  gap: 12px;
  align-items: end;
}

.inline-exports {
  align-self: end;
  margin-top: 0;
  min-width: 310px;
}

.create-lesson-panel {
  margin-top: 18px;
}

.compact-check {
  min-height: 42px;
}

.rhythm-options {
  display: none;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.rhythm-options.open {
  display: grid;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.modal-backdrop.is-open {
  display: grid !important;
}

.modal-panel {
  width: min(1100px, 100%);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.small-modal {
  width: min(420px, 100%);
}

.modal-head,
.student-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.student-link {
  color: var(--ink);
  text-decoration: none;
}

.student-link:hover {
  color: var(--accent-strong);
}

.student-profile {
  display: grid;
  gap: 18px;
}

.student-profile-head img,
.avatar.large {
  width: 72px;
  height: 72px;
  border-radius: 8px;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}

.overview-list {
  display: grid;
  gap: 10px;
}

.overview-list > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.student-grade-card {
  display: grid;
  gap: 12px;
}

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

.semester-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.semester-card h4 {
  margin: 0 0 10px;
}

.semester-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.semester-card dl div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.semester-card dl .test-summary-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.inline-grade-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.inline-grade-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.inline-grade-list span {
  color: var(--muted);
  font-weight: 800;
}

.student-grade-card dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.student-grade-card dd {
  margin: 0;
  font-weight: 900;
}

.semester-card dd,
.year-grade-card {
  border-radius: 8px;
  padding: 7px 10px;
}

.semester-card dd {
  min-width: 78px;
  text-align: center;
  font-size: 14px;
}

.year-grade-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  font-weight: 900;
}

.year-grade-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.year-grade-card span {
  font-size: 12px;
  text-transform: uppercase;
  color: inherit;
}

.year-grade-card strong {
  font-size: 18px;
}

.grade-band-good {
  background: #dcfce7 !important;
  color: #166534 !important;
}

.grade-band-mid {
  background: #fef3c7 !important;
  color: #92400e !important;
}

.grade-band-danger {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.grade-band-empty {
  background: #f8fafc !important;
  color: var(--muted) !important;
}

.lesson-grade-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.lesson-grade-list > * {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}

.lesson-grade-list > :nth-child(odd) {
  border-right: 1px solid var(--line);
}

.lesson-grade-list > strong {
  background: #f8fafc;
  color: var(--muted);
}

.lesson-grade-list > :nth-last-child(-n+2) {
  border-bottom: 0;
}

.test-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.compact-test-form {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) auto;
}

.test-table {
  display: grid;
  grid-template-columns: 44px minmax(220px, 280px) repeat(var(--test-count), minmax(95px, 120px));
  gap: 8px;
  overflow-x: auto;
  align-items: center;
  margin-bottom: 12px;
}

.test-delete-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.test-delete-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  font-weight: 900;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  justify-self: end;
}

.assignment-form .assignment-semester,
.assignment-form .rhythm-options,
.assignment-form .button {
  grid-column: 1 / -1;
}

.assignment-semester {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.assignment-semester h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 16px;
}

.management-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.manage-row,
.student-admin {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.student-admin {
  grid-template-columns: auto minmax(220px, 1fr) minmax(320px, 1.6fr);
  align-items: center;
}

.student-admin-actions {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
}

.student-admin-actions .student-move-form,
.student-admin-actions form {
  display: contents;
}

.student-admin-actions select {
  min-width: 0;
}

.student-edit-form {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.student-edit-form.open {
  display: grid;
}

.student-edit-form textarea,
.student-edit-form .button {
  grid-column: 1 / -1;
}

.subject-edit-form {
  grid-column: 1 / -1;
  grid-template-columns: minmax(180px, 1fr) 90px minmax(160px, auto);
}

.subject-edit-form .button {
  grid-column: auto;
}

.student-select {
  display: grid;
  place-items: center;
}

.student-select input {
  width: 18px;
  min-height: auto;
}

.manage-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.subject-manage-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  min-height: 58px;
}

.subject-manage-row form:not(.subject-edit-form) {
  display: contents;
}

.subject-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--subject-color);
}

.student-admin-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-admin-name img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.import-box {
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.import-box summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 900;
}

.class-list,
.archive-list,
.timeline {
  display: grid;
  gap: 10px;
}

.class-row,
.archive-list article,
.timeline div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.class-row-head {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.class-row > div:not(.row-actions),
.archive-list div,
.timeline div {
  display: grid;
  gap: 4px;
}

.planner {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
}

.side {
  align-self: start;
  position: sticky;
  top: 88px;
}

.panel-head {
  display: grid;
  gap: 10px;
}

.compact {
  display: grid;
  grid-template-columns: 150px 150px minmax(160px, 1fr) minmax(160px, 1fr) auto;
}

.lesson-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0;
}

.lesson-tabs a {
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.lesson-tabs a.cancelled {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.lesson-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.lesson-editor label small {
  display: block;
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.cancelled-check {
  align-self: center;
  min-height: 42px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: var(--danger);
  padding: 10px 12px;
}

.lesson-actions,
.lesson-delete-form {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.lesson-delete-form {
  margin-left: 10px;
}

.autosave-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.grade-table {
  display: grid;
  grid-template-columns: minmax(230px, 1.4fr) 120px 70px 70px 80px 145px minmax(220px, 1fr);
  gap: 8px;
  align-items: center;
  overflow-x: auto;
}

.current-grade-table {
  grid-template-columns: 44px minmax(230px, 360px) 120px 145px minmax(220px, 1fr);
}

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

.gradebook-semester {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.gradebook-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 13px;
}

.gradebook-table th,
.gradebook-table td {
  border: 1px solid var(--line);
  padding: 5px 6px;
  text-align: center;
  white-space: nowrap;
  min-width: 46px;
}

.gradebook-table th:nth-child(2),
.gradebook-table td:nth-child(2) {
  min-width: 180px;
  text-align: left;
}

.gradebook-table thead th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
}

.gradebook-table .group-header th {
  background: #eef6f5;
  color: var(--accent-strong);
  border-bottom: 2px solid #b7ded8;
  text-align: center;
}

.gradebook-table .group-start {
  border-left: 3px solid #b7ded8;
}

.gradebook-table .grade-attendance {
  background: #dff1ff;
  color: #075985;
  font-weight: 800;
}

.gradebook-table tbody th {
  background: #fff;
  position: sticky;
  left: 40px;
  z-index: 1;
}

.gradebook-table th:first-child,
.gradebook-table td:first-child {
  min-width: 40px;
  width: 40px;
  text-align: center;
}

.number-cell {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.compact-summary-table {
  max-width: 620px;
}

.grade-danger {
  background: #fee2e2 !important;
  color: #991b1b !important;
  font-weight: 900;
}

.grade-header {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.student-cell img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.average-cell {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 8px;
  background: #eef6f5;
  color: var(--accent-strong);
  font-weight: 900;
}

.avatar {
  flex: 0 0 auto;
  background: #1f2937;
  font-size: 13px;
}

.savebar {
  margin-top: 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.empty-state.compact {
  min-height: 90px;
}

@media (max-width: 980px) {
  .toolbar,
  .class-row,
  .archive-list article {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    position: sticky;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 12px 16px;
  }

  .toolbar h1 {
    font-size: 28px;
  }

  .menu-toggle {
    display: block !important;
  }

  .logo {
    min-width: 0;
  }

  .logo strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main-menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    display: grid;
    align-content: start;
    width: min(205px, 58vw);
    height: 100vh;
    padding: 64px 0 18px;
    background: var(--accent);
    border-right: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .main-menu a {
    display: block;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    color: #fff;
    padding: 12px 14px 12px 16px;
    text-align: left;
  }

  .main-menu a:first-child {
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }

  .main-menu a.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    border: 0;
    background: rgba(23, 32, 38, 0.35);
    cursor: pointer;
  }

body.menu-open {
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

  body.menu-open .main-menu {
    transform: translateX(0);
  }

  body.menu-open .menu-backdrop {
    display: block !important;
  }

  .inline-form,
  .compact {
    flex-wrap: wrap;
    justify-content: start;
  }

  .row-actions {
    justify-content: start;
  }

  .class-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .class-row .row-actions {
    justify-content: end;
    justify-self: end;
  }

  .grid.three,
  .columns,
  .planner,
  .compact,
  .lesson-editor,
  .grade-control-bar,
  .grade-controls,
  .profile-grid,
  .compact-test-form,
  .rhythm-options {
    grid-template-columns: 1fr;
  }

  .inline-exports {
    min-width: 0;
  }

  .schedule-toolbar {
    flex-wrap: wrap;
  }

  .schedule-toolbar div {
    flex-basis: 100%;
    margin-left: 0;
    text-align: left;
    order: -1;
  }

  .schedule-jump label {
    min-height: 42px;
    padding: 0 8px;
  }

  .schedule-jump span {
    display: none;
  }

  .schedule-jump input {
    width: 112px;
    font-size: 12px;
  }

  .schedule-grid {
    grid-template-columns: 30px repeat(5, minmax(52px, 1fr));
    grid-template-rows: auto repeat(16, minmax(42px, auto));
    overflow-x: hidden;
    font-size: 11px;
  }

  .schedule-corner,
  .schedule-day-head {
    padding: 6px 3px;
  }

  .schedule-day-head {
    display: grid;
    gap: 1px;
    justify-items: center;
    text-align: center;
  }

  .day-long {
    display: none;
  }

  .day-short {
    display: inline;
  }

  .schedule-period,
  .schedule-slot {
    min-height: 42px;
  }

  .schedule-item {
    align-content: center;
    justify-items: center;
    margin: 2px;
    min-height: calc(100% - 4px);
    padding: 4px 3px;
    border-left-width: 3px;
    gap: 1px;
    text-align: center;
  }

  .schedule-item strong {
    font-size: 10px;
    line-height: 1.1;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .schedule-detail {
    display: none;
  }

  .schedule-item em {
    display: none;
  }

  .schedule-item.class-test em,
  .schedule-item.cancelled em {
    display: block;
    font-size: 9px;
    line-height: 1.05;
    max-width: 100%;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  .schedule-item.cancelled {
    align-content: center;
    justify-items: start;
    padding-left: 5px;
    text-align: left;
  }

  .schedule-item.cancelled strong {
    justify-self: center;
    text-align: center;
  }

  .schedule-item.cancelled .schedule-status {
    display: grid;
    gap: 1px;
    justify-self: start;
    text-align: left;
  }

  .panel-head-row,
  .week-lesson,
  .note-form {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .week-lesson .subject-dot {
    display: none;
  }

  .week-lesson em {
    justify-self: start;
  }

  .side {
    position: static;
  }
}

@media (max-width: 680px) {
  .shell,
  .auth-page {
    padding: 16px;
  }

  .auth-card,
  .panel {
    padding: 18px;
  }

  .toolbar h1 {
    font-size: 24px;
    line-height: 1.18;
  }

  .user-profile-grid,
  .color-settings,
  .semester-overview {
    grid-template-columns: 1fr;
  }

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

  .grade-table {
    grid-template-columns: 190px 100px 70px 70px 80px 125px 170px;
  }

  .current-grade-table {
    grid-template-columns: 34px 160px 100px 125px 170px;
  }

  .class-button-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .class-pill {
    justify-content: center;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 13px;
  }

  .gradebook-table {
    min-width: 0;
    width: max-content;
    font-size: 12px;
  }

  .gradebook-table th,
  .gradebook-table td {
    min-width: 38px;
    padding: 4px 5px;
  }

  .gradebook-table th:nth-child(2),
  .gradebook-table td:nth-child(2) {
    min-width: 112px;
    max-width: 132px;
    white-space: normal;
    line-height: 1.15;
  }

  .gradebook-table tbody th {
    position: sticky;
    left: 34px;
  }

  .gradebook-table th:first-child,
  .gradebook-table td:first-child {
    min-width: 34px;
    width: 34px;
  }

  .preparation-table {
    font-size: 11px;
  }

  .preparation-table th,
  .preparation-table td {
    min-width: 62px;
    max-width: 76px;
    padding: 3px;
  }

  .preparation-table .prep-kw-col {
    min-width: 34px;
    width: 34px;
  }

  .preparation-table .prep-date-col {
    left: 34px;
    min-width: 58px;
    width: 58px;
  }

  .class-row-head {
    display: none;
  }

  .class-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .class-row .row-actions {
    justify-self: end;
    justify-content: end;
    gap: 6px;
  }

  .class-row .row-actions .button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .manage-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .manage-row .button {
    grid-column: 1 / -1;
  }

  .subject-manage-row {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }

  .subject-manage-row .button,
  .subject-manage-row .icon-button {
    grid-column: auto;
  }

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

  .student-admin-actions {
    grid-template-columns: minmax(92px, 1fr) auto auto auto;
    gap: 6px;
  }

  .student-admin-actions .button {
    min-height: 42px;
    padding: 8px 9px;
    font-size: 13px;
  }

  .student-admin-actions .icon-button {
    width: 42px;
    height: 42px;
  }
}
