:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  --line: #d9dde7;
  --text: #182033;
  --muted: #687084;
  --panel: #f7f8fb;
  --accent: #1f6f78;
  --lesson: #d9ecff;
  --blocked: #eee8d6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: #fff;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
}

.shell {
  max-width: 1280px;
  height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.actions, .toolbar, .app-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.app-tabs { margin: 16px 0 0; }
.app-tabs button.selected {
  background: #e7f5f2;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.toolbar { margin: 16px 0; }
.toolbar button { background: var(--accent); color: #fff; border-color: var(--accent); }
.week-load-summary {
  width: 100%;
  min-width: 0;
  margin: 0 0 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.week-summary-card {
  min-width: 0;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 14px;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.week-load-summary[hidden] { display: none; }
.week-summary-card > span { color: var(--muted); }
.week-summary-card > strong { font-size: 22px; text-align: right; }
.week-summary-card > small {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.week-grid {
  display: grid;
  grid-template-columns: 112px repeat(7, minmax(130px, 1fr));
  border: 1px solid var(--line);
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.week-grid.day-grid {
  grid-template-columns: 86px minmax(210px, 1fr);
}

.time-head, .day-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 54px;
  padding: 8px;
}
.time-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: end;
  color: var(--muted);
  font-size: 12px;
}
.day-head strong,
.day-head span {
  display: block;
}
.day-head strong { margin-bottom: 2px; }
.day-head span { color: var(--muted); }
.day-head.today {
  background: #e7f5f2;
  box-shadow: inset 0 -3px 0 var(--accent);
}
.day-head.today strong {
  color: var(--accent);
}
.day-head.today span {
  color: #22545a;
  font-weight: 600;
}

.time-col, .day-col { position: relative; min-height: 900px; border-right: 1px solid var(--line); }
.day-col:last-child { border-right: 0; }
.time-col { background: var(--panel); color: var(--muted); font-size: 12px; }
.tick {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #edf0f5;
}
.tick.major { background: var(--line); }
.tick-label {
  position: absolute;
  transform: translateY(-8px);
  left: 8px;
  right: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  line-height: 1.2;
}
.event {
  position: absolute;
  left: 6px;
  right: 6px;
  border: 1px solid #9ec8e8;
  background: var(--lesson);
  border-radius: 6px;
  padding: 6px;
  overflow: hidden;
  font-size: 12px;
  color: var(--event-text, var(--text));
}
.event.blocked {
  background: var(--blocked);
  border-color: #d8cfae;
}
.event.google {
  box-shadow: inset 3px 0 0 #1f6f78;
}
.event.clickable { cursor: pointer; }
.event.clickable:hover { border-color: var(--accent); }
.event strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event span { color: var(--event-text, var(--muted)); display: block; }
.event .event-surname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event.has-surname {
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 11px;
  line-height: 1.05;
}
.event.has-surname strong {
  margin-bottom: 0;
  font-size: 12px;
}
.event .event-lesson-marker {
  position: absolute;
  top: 3px;
  right: 4px;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid rgba(22, 101, 52, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #166534;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}
.event .event-lesson-marker.conducted {
  border-color: rgba(24, 32, 51, 0.45);
  background: rgba(255, 255, 255, 0.78);
}
.event.has-lesson-marker strong { padding-right: 17px; }

.review-view,
.students-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  padding: 14px;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 20px;
}
.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
}
.review-list {
  display: grid;
  gap: 10px;
}
.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.review-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.review-card p {
  margin: 0;
  color: var(--muted);
}
.review-card .review-warning {
  margin-top: 8px;
  color: #8a5a00;
  font-weight: 600;
}
.discrepancy-card { border-color: #d99a33; box-shadow: inset 4px 0 0 #d99a33; }
.discrepancy-choice {
  display: grid;
  gap: 8px;
}
.discrepancy-choice > strong,
.discrepancy-other-actions > strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.discrepancy-choice label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.discrepancy-choice select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  color: var(--text);
  background: #fff;
}
.review-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.review-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.review-fields select,
.review-fields input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  color: var(--text);
  background: #fff;
}
.review-fields .review-color-field { grid-column: 1 / -1; }
.review-fields input[type="color"] {
  height: 42px;
  padding: 3px;
  cursor: pointer;
}
.review-fields input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.review-fields input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}
.review-actions {
  display: grid;
  gap: 8px;
  min-width: 150px;
}
.school-year-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  margin-bottom: 16px;
}
.school-year-form .school-year-notes {
  grid-column: span 2;
}
.school-year-form menu {
  margin: 0;
  justify-content: stretch;
}
.school-year-form menu button {
  width: 100%;
}
.exam-dates-list {
  display: grid;
  gap: 10px;
}
.exam-date-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 150px 170px minmax(180px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.exam-date-row strong,
.exam-date-row span {
  display: block;
}
.exam-date-row span {
  margin-top: 4px;
  color: var(--muted);
}
.exam-date-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.exam-date-row input,
.exam-date-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  background: #fff;
}
.exam-date-actions {
  display: flex;
  gap: 8px;
}

.modal[hidden] { display: none; }
[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: 24px;
  background: rgba(24, 32, 51, 0.28);
}
.modal-card {
  width: min(620px, 100%);
  margin: 24px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 16px 44px rgba(24, 32, 51, 0.18);
}
.modal-card-wide { width: min(980px, 100%); }
.modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-title-row h2 { margin: 0; }
.students-layout {
  display: grid;
  grid-template-columns: minmax(240px, 330px) 1fr;
  gap: 16px;
  min-height: min(620px, calc(100vh - 230px));
}
.student-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.student-filters button { padding: 6px 9px; font-size: 13px; }
.students-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 300px);
  overflow: auto;
}
.student-row {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: left;
}
.student-row-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--text) !important; }
.student-balance-badge { flex: 0 0 auto; font-size: 11px; font-weight: 700; }
.student-balance-badge.positive { color: #18723a !important; }
.student-balance-badge.negative { color: #a42a2a !important; }
.student-row.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.student-row span,
.student-row em,
.muted {
  color: var(--muted);
}
.student-row em { font-style: normal; font-size: 12px; }
.student-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: calc(100vh - 300px);
  overflow: auto;
}
.student-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.student-card-head h3 { margin: 0; }
.student-card-head p { margin: 4px 0 0; color: var(--muted); }
.student-profile-details { margin-bottom: 16px; }
.student-profile-details summary {
  width: fit-content;
  margin-bottom: 12px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.student-profile-details:not([open]) summary { margin-bottom: 0; }
.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}
.status-pill.active { background: #e6f6ed; border-color: #b7dfc4; }
.status-pill.pause { background: #fff3d8; border-color: #e7cb85; }
.status-pill.archive { background: #f1f2f5; border-color: #d6d9e0; }
.student-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.student-fields div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}
.student-fields dt { color: var(--muted); font-size: 12px; }
.student-fields dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.student-rate-set { display: block; margin-top: 5px; }
.subject-view-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.subject-color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  flex: 0 0 auto;
}
.subject-color-row {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  cursor: pointer;
}
.subject-color-row input[type="color"] {
  width: 56px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.subject-color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}
.subject-color-row input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}
.subject-edit-group { display: grid; }
.inline-action {
  margin-top: 6px;
  width: 100%;
  min-height: 30px;
}
.student-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.student-payments-journal { margin-top: 22px; }
.student-payments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.student-payments-head h3 { margin: 0; }
.student-balance-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.student-balance-card span { color: var(--muted); }
.student-balance-card strong { font-size: 23px; }
.student-balance-card.positive { border-color: #afd9bb; background: #f3fbf5; }
.student-balance-card.positive strong { color: #18723a; }
.student-balance-card.negative { border-color: #e6b8b8; background: #fff7f7; }
.student-balance-card.negative strong { color: #a42a2a; }
.student-balance-card.loading strong { color: var(--muted); font-size: 14px; font-weight: 500; }
.student-rates-panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.student-rates-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.student-rates-head h4 { margin: 0; }
.student-rate-history { line-height: 1.45; }
.student-empty-payments { margin: 0; }
.payment-history-table { min-width: 620px; }
.payment-history-table td:first-child { white-space: nowrap; }
.student-section-details > summary,
.subject-journal > summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}
.student-section-details > summary { font-size: 20px; }
.student-section-details[open] > summary,
.subject-journal[open] > summary { margin-bottom: 12px; }
.lesson-journal { margin-top: 22px; }
.lesson-journal > h3 { margin: 0 0 12px; }
.subject-journal { margin-top: 16px; }
.subject-journal > summary { font-size: 16px; }
.lesson-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.lesson-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 13px; }
.lesson-table th, .lesson-table td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.lesson-table th { background: #f6f7f9; color: var(--muted); font-weight: 600; }
.lesson-table tr:last-child td { border-bottom: 0; }
.lesson-table td:first-child { white-space: nowrap; }
.lesson-table td:first-child span { display: block; margin-top: 3px; color: var(--muted); }
.lesson-table td:first-child em { display: block; margin-top: 5px; color: #9b2c2c; font-style: normal; font-weight: 600; }
.lesson-table .needs-attention { background: #fff3d8; color: #7a5200; }
.lesson-table tr.future-lesson td { background: #f7f8fb; color: var(--muted); }
.lesson-table tr.incomplete-lesson td { background: #fff1f3; }
.lesson-table tr.complete-lesson td { background: #eaf7ee; }
.lesson-table .lesson-state { margin-top: 5px; font-weight: 600; }
.incomplete-table td:nth-child(2) { white-space: nowrap; }
.incomplete-table td:nth-child(2) span { display: block; margin-top: 3px; color: var(--muted); }
.lesson-table tr.cancelled-lesson td { background: #fff4f3; }
.student-lesson-table { min-width: 840px; table-layout: fixed; }
.student-lesson-table .lesson-date-column { width: 145px; }
.student-lesson-table .lesson-notes-column { width: 21%; }
.student-lesson-table .lesson-homework-column { width: 35%; }
.student-lesson-table .lesson-payment-column { width: 82px; }
.student-lesson-table .lesson-payment-date-column { width: 128px; }
.student-lesson-table .lesson-action-column { width: 116px; }
.student-lesson-table th:nth-child(4),
.student-lesson-table td:nth-child(4),
.student-lesson-table th:nth-child(5),
.student-lesson-table td:nth-child(5) { white-space: nowrap; }
.payment-date-item { white-space: nowrap; }

.statistics-view {
  flex: none;
  min-height: auto;
  overflow-y: visible;
  overscroll-behavior: auto;
  padding: 20px 0 96px;
}
.statistics-year { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.statistics-year select { min-width: 150px; }
.statistics-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 18px; }
.statistics-yandex { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; }
.statistics-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 280px)); gap: 10px; margin: 18px 0 28px; }
.statistics-summary.workload-summary { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.statistics-summary article { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.statistics-summary span { display: block; color: var(--muted); }
.statistics-summary strong { display: block; margin-top: 5px; font-size: 23px; }
.statistics-summary small { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; }
.statistics-section { margin-top: 26px; }
.statistics-section h3 { margin: 0 0 14px; }
.income-chart { display: grid; gap: 8px; margin-bottom: 28px; }
.income-row { display: grid; grid-template-columns: 90px minmax(120px, 1fr) 110px; gap: 10px; align-items: center; }
.income-row > strong { text-align: right; font-size: 13px; }
.income-track { display: flex; height: 18px; overflow: hidden; border-radius: 3px; background: #eef1f4; }
.income-track i { display: block; height: 100%; }
.income-month-summary { table-layout: fixed; min-width: 1050px; }
.income-month-summary th, .income-month-summary td { padding: 9px 5px; text-align: center !important; font-size: 12px; }
.income-month-chart-wrap { margin-top: 18px; overflow-x: auto; }
.income-month-chart { display: grid; grid-template-columns: repeat(12, minmax(62px, 1fr)); gap: 10px; min-width: 960px; height: 310px; padding: 12px 10px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 58px, #e5e8ec 59px); }
.income-month-column { display: grid; grid-template-rows: 24px 1fr 34px; min-width: 0; text-align: center; }
.income-month-column > strong { align-self: start; overflow: hidden; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.income-month-column > div { display: flex; align-items: end; justify-content: center; min-height: 0; }
.income-month-column i { display: block; width: 58%; min-height: 1px; border-radius: 3px 3px 0 0; }
.income-month-column > span { align-self: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.stacked-chart { display: flex; align-items: end; gap: 14px; min-height: 330px; overflow-x: auto; padding: 28px 10px 0 58px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 64px, #e5e8ec 65px); }
.stacked-column { width: 76px; height: 300px; flex: 0 0 76px; display: grid; grid-template-rows: 24px 1fr 38px; align-items: end; text-align: center; }
.stacked-column > strong { align-self: center; font-size: 10px; font-weight: 500; white-space: nowrap; }
.stacked-column > span { align-self: start; padding-top: 8px; font-size: 11px; white-space: nowrap; }
.stacked-bar { width: 44px; height: 100%; justify-self: center; display: flex; flex-direction: column-reverse; justify-content: flex-start; }
.stacked-bar i { display: block; width: 100%; min-height: 1px; }
.statistics-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.statistics-legend span { display: inline-flex; align-items: center; gap: 5px; }
.statistics-legend i { width: 10px; height: 10px; border-radius: 2px; }
.workload-month-legend { justify-content: center; }
.line-chart-wrap { width: 100%; overflow-x: auto; border-bottom: 1px solid var(--line); }
.line-chart { display: block; width: 100%; height: 330px; }
.line-chart line { stroke: #dfe3e8; stroke-width: 1; }
.line-chart text { fill: var(--muted); font-size: 10px; }
.line-chart polyline { fill: none; stroke: currentColor; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.line-chart circle { fill: currentColor; stroke: #fff; stroke-width: 1; vector-effect: non-scaling-stroke; }
.statistics-table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.statistics-table-wrap.compact { max-width: 500px; margin-top: 18px; }
.statistics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.statistics-table th, .statistics-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.statistics-table thead th { position: sticky; top: 0; z-index: 1; background: #f6f7f9; color: var(--muted); font-weight: 600; }
.statistics-table th:first-child, .statistics-table td:first-child { position: sticky; left: 0; z-index: 2; text-align: left; background: #fff; }
.statistics-table thead th:first-child { z-index: 3; background: #f6f7f9; }
.statistics-table tbody tr:last-child th, .statistics-table tbody tr:last-child td { border-bottom: 0; }
.student-income-table { min-width: 1180px; }
.student-income-table th:first-child { min-width: 180px; }
.student-income-name { display: block; }
.student-income-subjects { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.3; white-space: normal; }
.income-year-month-table { table-layout: fixed; min-width: 1050px; }
.income-year-month-table th, .income-year-month-table td { padding: 9px 5px; text-align: center; font-size: 12px; }
.income-year-month-table th:first-child, .income-year-month-table td:first-child { width: 92px; }
.income-year-month-table td.max-income-cell { background: #def3e4; color: #166534; font-weight: 700; }
.workload-year-table { table-layout: fixed; min-width: 0; }
.workload-year-table th, .workload-year-table td { padding: 9px 4px; font-size: 12px; text-align: center; }
.workload-year-table th:first-child, .workload-year-table td:first-child { width: 92px; }
.workload-month-summary { table-layout: fixed; min-width: 1050px; }
.workload-month-summary th, .workload-month-summary td { padding: 9px 5px; text-align: center !important; font-size: 12px; }
.workload-month-summary td.max-workload-cell { background: #def3e4; color: #166534; font-weight: 700; }
.workload-chart-toggle { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--muted); }
.workload-chart { margin-top: 18px; }
.workload-days-matrix { table-layout: fixed; min-width: 1050px; }
.workload-days-matrix th, .workload-days-matrix td { width: 78px; padding: 7px 4px; text-align: center; font-size: 12px; }
.workload-days-matrix th:first-child, .workload-days-matrix td:first-child { width: 46px; }
.workload-days-matrix td.impossible-day { background: #d9dde3; }
.workload-weeks { max-width: 620px !important; }
.workload-weeks-details > summary { width: fit-content; cursor: pointer; font-size: 20px; font-weight: 700; }
.workload-weeks-details[open] > summary { margin-bottom: 14px; }
.workload-weeks-details .workload-weeks { margin-top: 0; }
.student-income-table .other-income-row th, .student-income-table .other-income-row td { background: #fff8e5; }
.vacation-cell { color: var(--muted); font-style: italic; }
.analysis-summary article.positive { border-color: #a9d9b8; background: #f3fbf5; }
.analysis-summary article.negative { border-color: #e7b8b8; background: #fff7f7; }
.analysis-note { margin-bottom: 14px; padding: 11px 13px; border-left: 3px solid #d39a29; background: #fff9eb; color: #5f5135; font-size: 13px; }
.analysis-table { min-width: 1040px; }
.analysis-table th:first-child { min-width: 190px; }
.analysis-table th:nth-child(6), .analysis-table td:nth-child(6) { text-align: left; }
.analysis-table th:last-child, .analysis-table td:last-child { width: 42px; padding-left: 4px; padding-right: 8px; }
.analysis-week-row:hover th, .analysis-week-row:hover td { background: #fafbfc; }
.analysis-status { display: inline-block; color: var(--muted); font-size: 12px; }
.analysis-status.complete { color: #27623a; }
.analysis-status.current { color: #8a6416; }
.analysis-difference { font-weight: 700; }
.analysis-difference.positive { color: #18723a; }
.analysis-difference.negative { color: #a42a2a; }
.analysis-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.analysis-badge { display: inline-block; padding: 3px 6px; border-radius: 3px; font-size: 11px; line-height: 1.2; }
.analysis-badge.extra { background: #e1f3e6; color: #176b34; }
.analysis-badge.lost { background: #fbe4e4; color: #9d2828; }
.analysis-badge.transfer { background: #fff0cf; color: #7a5711; }
.analysis-badge.unresolved { background: #eceff3; color: #4b5563; }
.analysis-no-changes { color: var(--muted); font-size: 12px; }
.analysis-expand { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: #34455d; font-size: 20px; line-height: 1; }
.analysis-detail-row > td { padding: 0 !important; background: #fbfcfd; }
.analysis-details-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.analysis-detail { display: grid; grid-template-columns: 126px minmax(150px, 210px) 150px minmax(240px, 1fr) 110px; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid #e7e9ed; text-align: left; white-space: normal; }
.analysis-detail:last-child { border-bottom: 0; }
.analysis-detail-kind { font-size: 12px; font-weight: 700; }
.analysis-detail.extra .analysis-detail-kind { color: #18723a; }
.analysis-detail.lost .analysis-detail-kind { color: #a42a2a; }
.analysis-detail.transfer_out .analysis-detail-kind, .analysis-detail.transfer_in .analysis-detail-kind { color: #8a6416; }
.analysis-detail.unresolved .analysis-detail-kind { color: #596273; }
.analysis-detail-note { color: var(--muted); }
.analysis-detail b { text-align: right; }
.analysis-empty-detail { margin: 0; padding: 14px 16px; color: var(--muted); }
.analysis-footnote { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.analysis-footnote.warning { color: #7a5711; }
@media (max-width: 760px) {
  .income-row { grid-template-columns: 72px minmax(80px, 1fr) 92px; }
  .stacked-chart { padding-left: 12px; }
  .statistics-summary.workload-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-detail { grid-template-columns: 1fr; gap: 4px; }
  .analysis-detail b { text-align: left; }
}
.lesson-table tr.cancelled-lesson-closed td {
  white-space: normal;
  color: #9b2c2c;
  font-weight: 600;
}
.cancelled-lesson-date { display: inline-block; min-width: 190px; margin-right: 16px; color: var(--text); font-weight: 400; }
.occurrence-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.occurrence-summary div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}
.occurrence-summary dt {
  color: var(--muted);
  font-size: 12px;
}
.occurrence-summary dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}
.google-subject-assignment {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f7f9;
}
.google-subject-assignment[hidden] { display: none; }
.google-subject-assignment label { display: grid; gap: 5px; }
.occurrence-appearance-form {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f7f9;
}
.occurrence-appearance-form h3 { margin: 0; font-size: 16px; }
.occurrence-appearance-form label { display: grid; gap: 5px; }
.occurrence-appearance-form .occurrence-color-row {
  grid-template-columns: 1fr 120px;
}
.occurrence-appearance-form .occurrence-color-row input[type="color"] {
  width: 120px;
}
.lesson-record-button { margin: 0 0 16px; background: var(--accent); border-color: var(--accent); color: #fff; }
.lesson-record-button[hidden] { display: none; }
.form { display: grid; gap: 10px; }
.form h2 { margin: 0 0 4px; font-size: 20px; }
.form label { display: grid; gap: 4px; color: var(--muted); }
.form input, .form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: var(--text);
  background: #fff;
}
.form-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.form-section legend {
  padding: 0 4px;
  color: var(--muted);
}
.rate-editor > label { grid-column: 1 / -1; }
.rate-editor-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}
.choice-group legend {
  width: 100%;
  margin-bottom: 2px;
  color: var(--muted);
}
.choice-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  background: #fff;
}
.choice-group input {
  width: auto;
  margin: 0;
}
.form label.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: var(--text);
}
.form label.inline-check input {
  width: auto;
  margin: 0;
}
.form menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 8px 0 0; }
.form menu.split-actions { flex-wrap: wrap; }
.form menu.split-actions button { flex: 1 1 220px; }

body.content-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
body.content-page .shell {
  height: auto;
  min-height: 100vh;
}

@media (min-width: 761px) {
  body.calendar-page {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body.calendar-page .shell {
    height: auto;
    min-height: 100vh;
  }
  body.calendar-page .week-grid {
    flex: none;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior: auto;
  }
}

@media (max-width: 760px) {
  .shell { padding: 10px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .week-grid { grid-template-columns: 104px repeat(7, 150px); }
  .week-grid.day-grid { grid-template-columns: 76px minmax(190px, 1fr); }
  .students-layout { grid-template-columns: 1fr; }
  .student-fields { grid-template-columns: 1fr; }
  .week-load-summary { grid-template-columns: 1fr; }
  .rate-editor-grid { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; }
  .school-year-form,
  .exam-date-row { grid-template-columns: 1fr; }
  .school-year-form .school-year-notes { grid-column: auto; }
}
