/* ============================================================
   Chatty School · Design system v5
   Light SaaS look: 8px grid, 12–16px radii, soft shadows,
   colored status badges, one component language on every page.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-subtle: #fafbfc;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --line-strong: #cbd5e1;

  --brand: #0d9488;
  --brand-dark: #0f766e;
  --brand-soft: #ccfbf1;
  --brand-tint: #f0fdfa;

  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --blue-tint: #eff6ff;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --yellow: #a16207;
  --yellow-soft: #fef9c3;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 10px;

  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .12);
  --shadow: 0 8px 24px -6px rgba(15, 23, 42, .08);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 { letter-spacing: -.015em; }

/* ---------- Top bar ---------- */

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px max(24px, calc((100vw - 1280px) / 2 + 16px));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15.5px;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: inset 0 -8px 12px rgba(255, 255, 255, .16), 0 4px 10px rgba(13, 148, 136, .28);
}

.brand-logo {
  width: auto;
  height: 30px;
  max-width: 132px;
  object-fit: contain;
  border-radius: 8px;
  flex: 0 0 auto;
}

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  padding: 7px 14px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}

.nav a:hover { background: #f1f5f9; color: var(--text-soft); }

.nav a.active { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- Buttons ---------- */

.primary,
.secondary,
.ghost,
.link-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  padding: 8px 15px;
  text-decoration: none;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease, transform .1s ease;
}

.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 148, 136, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
}

.primary:hover { background: var(--brand-dark); }
.primary:active { transform: translateY(1px); }

.secondary,
.link-button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text-soft);
  box-shadow: var(--shadow-soft);
}

.secondary:hover,
.link-button:hover { background: #f8fafc; border-color: #b6c2d2; }

.ghost { background: transparent; color: var(--muted); }
.ghost:hover { background: #f1f5f9; color: var(--text-soft); }

.danger-action { color: var(--red); }
.danger-action:hover { border-color: #fca5a5; background: #fff5f5; }

button:disabled { cursor: not-allowed; opacity: .5; }

.btn-lg { min-height: 46px; padding: 12px 22px; font-size: 15.5px; border-radius: 12px; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }

/* ---------- Shell & headings ---------- */

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 72px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 11.5px;
  font-weight: 800;
}

.subline, .muted { color: var(--muted); }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-head h2 { margin-bottom: 4px; }
.section-head p { margin: 0; }

/* ---------- Panels & KPI cards ---------- */

.panel,
.summary-grid article,
.table-wrap,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.panel { padding: 24px; margin-bottom: 24px; }

.panel h2 { margin: 0 0 14px; font-size: 18px; font-weight: 750; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-grid article {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .18s ease, transform .18s ease;
}

.summary-grid article:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.summary-grid article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
  border-radius: 0 4px 4px 0;
}

.summary-grid article.kpi-blue::before { background: var(--blue); }
.summary-grid article.kpi-violet::before { background: var(--violet); }
.summary-grid article.kpi-orange::before { background: var(--orange); }
/* v25: «Новые оплаты» — очередь приёмки у куратора */
.summary-grid article.kpi-green::before { background: var(--green); }
.summary-grid article.kpi-red::before { background: var(--red); }

.summary-grid span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }

.summary-grid strong {
  display: block;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.summary-grid .kpi-note { font-size: 12px; margin-top: 4px; font-weight: 500; }

/* v16: отрицательный баланс (долг по занятиям) подсвечивается красным */
.negative-balance, .badge.negative-balance { color: var(--red) !important; }
.badge.negative-balance { background: var(--red-soft); border-color: rgba(220, 38, 38, .16); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin-bottom: 24px; }

table { width: 100%; border-collapse: collapse; min-width: 760px; }

th, td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }

th {
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafcff; }

.strong-link { font-weight: 700; color: var(--brand-dark); text-decoration-color: rgba(13, 148, 136, .35); }
.strong-link:hover { color: var(--brand); }

.inner-table { margin-top: 16px; box-shadow: none; margin-bottom: 0; }

/* ---------- Badges, metrics, avatars ---------- */

.metric, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  margin: 2px 6px 2px 0;
  font-size: 12px;
  font-weight: 700;
  background: var(--brand-tint);
  color: var(--brand-dark);
  border: 1px solid rgba(13, 148, 136, .16);
}

.badge.blue { background: var(--blue-tint); color: var(--blue); border-color: rgba(37, 99, 235, .16); }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: rgba(124, 58, 237, .16); }
.badge.orange { background: var(--orange-soft); color: var(--orange); border-color: rgba(234, 88, 12, .16); }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: rgba(180, 83, 9, .16); }
.badge.danger { background: var(--red-soft); color: var(--red); border-color: rgba(220, 38, 38, .16); }
.badge.gray { background: #f1f5f9; color: var(--muted); border-color: var(--line); }
.badge.green { background: var(--green-soft); color: var(--green); border-color: rgba(21, 128, 61, .16); }
.badge.yellow { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(161, 98, 7, .18); }

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: var(--brand-dark);
  font-size: 18px;
  font-weight: 800;
}

.avatar.lg { width: 72px; height: 72px; border-radius: 16px; font-size: 28px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }

.empty { color: var(--muted); padding: 14px 0; margin: 0; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.form-grid.compact { background: transparent; border: 0; padding: 0; box-shadow: none; }

.panel.form-grid.compact { background: var(--panel); border: 1px solid var(--line); padding: 24px; }

.form-grid h2 { grid-column: 1 / -1; }

label span {
  display: block;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 650;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input[type="file"] { padding: 7px 10px; font-size: 13px; }

input:focus, select:focus, textarea:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 3.5px rgba(13, 148, 136, .14);
  outline: none;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.wide, .package-preview, .section-form { grid-column: 1 / -1; }

.section-form { margin-bottom: 12px; }

.package-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(13, 148, 136, .25);
  border-radius: var(--radius);
  background: var(--brand-tint);
}

.package-preview span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.package-preview strong { display: block; margin-top: 2px; font-size: 20px; font-weight: 800; }

/* checkbox chips (levels picker) */

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.check-chips label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin: 0;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.check-chips input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--brand);
}

.check-chips label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-dark);
}

/* segmented control */

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f1f5f9;
}

.segmented button, .segmented .secondary {
  min-height: 32px;
  padding: 5px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: none;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.segmented button.active, .segmented .secondary.active {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: var(--shadow-soft);
  border-color: var(--line);
}

/* radio pills (slot type) */

.pill-toggle { display: flex; gap: 8px; }

.pill-toggle label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.pill-toggle input[type="radio"] { display: none; }

.pill-toggle label:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .1);
}

/* ---------- Layout helpers ---------- */

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.two-col > .panel { margin-bottom: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.item-card {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .18s ease, transform .18s ease;
}

.item-card:hover { box-shadow: var(--shadow); }

.student-card-head { display: flex; gap: 12px; align-items: flex-start; }
.student-card-head > .avatar { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; flex: 0 0 auto; }
.student-card-head-info { display: grid; gap: 4px; min-width: 0; }
.lesson-progress-line { font-size: 12.5px; }

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

.scroll-list { display: grid; gap: 10px; max-height: 560px; overflow: auto; padding-right: 2px; }

.compact-list { max-height: 280px; }

.list-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.list-row:hover { border-color: var(--line-strong); }

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

.notification-row { grid-template-columns: minmax(240px, 2fr) minmax(160px, .8fr) auto; align-items: start; }

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

.metric-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* v27: ученик с несколькими преподавателями в списке куратора. Карточка
   раскладывается в один столбец: сверху сам ученик, ниже — по блоку на
   каждого преподавателя со своими пакетами, балансом, оплатой, контактами и
   кнопками. Данные разных преподавателей визуально разделены рамками, так что
   видно, где заканчивается один и начинается другой. */
.list-row.student-multi { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.student-teachers { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.stg-card {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel-subtle);
  min-width: 0;
}
.stg-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.stg-head strong { font-size: 14px; }
.stg-packages { display: grid; gap: 4px; font-size: 12.5px; }
.stg-package { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.stg-package-title { color: var(--text); font-weight: 600; }
.stg-card .item-actions { flex-wrap: wrap; gap: 6px; }
.stg-card .disclosure { margin: 0; }
.student-teachers .stg-note { grid-column: 1 / -1; margin: 0; font-size: 12.5px; }
@media (max-width: 760px) {
  .student-teachers { grid-template-columns: 1fr; }
}

.meta-lines { display: grid; gap: 3px; }

.action-stack { display: grid; gap: 8px; }
.action-stack form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.actions { display: flex; gap: 8px; }

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

.filter-bar, .inline-cancel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.filter-bar.panel, .inline-cancel.panel { padding: 14px 16px; margin-bottom: 20px; }

.inline-cancel { grid-template-columns: minmax(220px, 1fr) auto; }

.teamlead-filter { grid-template-columns: minmax(130px, 180px) minmax(150px, 1fr) minmax(150px, 1fr) auto; }

.curator-filter { grid-template-columns: minmax(180px, 1fr) minmax(140px, 170px) minmax(140px, 170px) auto auto; }

/* ---------- Notices & toasts ---------- */

.notice {
  margin-bottom: 20px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  border-radius: var(--radius);
  padding: 13px 16px;
  font-weight: 600;
}

.notice.danger { border-color: #fecaca; background: #fff7f7; color: var(--red); }

.notice.success { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }

.flash-toast { animation: flash-toast-in .25s cubic-bezier(.2, .9, .3, 1.2); }

@keyframes flash-toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Disclosures ---------- */

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

.disclosure, .row-details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-subtle);
}

.disclosure summary, .row-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 15px;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 700;
  border-radius: var(--radius);
  transition: background .15s ease;
  list-style: none;
}

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

.disclosure summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .18s ease;
}

.disclosure[open] summary::after { transform: rotate(-135deg); }

.disclosure summary:hover { background: #f1f5f9; }

.disclosure-body { padding: 4px 16px 16px; }

/* Curator "Контакты для уроков" — stacked labelled inputs saved via AJAX */
.lesson-contacts-form .stack-label { display: grid; gap: 4px; }
.lesson-contacts-form .stack-label > span { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.lesson-contacts-form input { width: 100%; }
.lesson-contacts-form .lesson-progress-note { margin: 2px 0 0; font-size: 12.5px; }
.lesson-contacts-status { font-size: 12.5px; }
.lesson-contacts-status.error { color: var(--danger, #dc2626); }

/* ---------- Role switcher ---------- */

.role-switcher { margin: 0; }

.role-switcher select {
  min-height: 36px;
  width: auto;
  max-width: 230px;
  border-color: rgba(13, 148, 136, .35);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

/* ---------- Teacher / profile cards ---------- */

.teacher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.teacher-card, .lesson-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .18s ease, transform .18s ease;
}

.teacher-card:hover, .lesson-card:hover { box-shadow: var(--shadow); }

.teacher-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
  padding: 16px;
}

.teacher-card-body { display: grid; gap: 6px; }

.teacher-card-links { display: flex; gap: 8px; flex-wrap: wrap; }

.teacher-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.teacher-identity > div { min-width: 0; }

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.chip-link:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-tint); }

.chip-link.copied { border-color: #86efac; background: #f0fdf4; color: #15803d; }

.chip-icon { width: 14px; height: 14px; flex: 0 0 auto; }

.teacher-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.teacher-profile-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .18s ease;
}

.teacher-profile-card:hover { box-shadow: var(--shadow); }

.teacher-profile-card.selected {
  border-color: rgba(13, 148, 136, .5);
  background: linear-gradient(180deg, var(--brand-tint), #fff 70%);
}

.teacher-photo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
}

.teacher-photo.placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: var(--brand-dark);
  font-size: 28px;
  font-weight: 800;
}

.teacher-profile-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.teacher-profile-card p { margin: 8px 0 12px; color: var(--text-soft); }

/* v22: карточки «Ваши преподаватели» в кабинете ученика — компактные и
   одинаковой высоты: длинное описание живёт в раскрывающемся блоке, а
   кнопки прижаты к низу карточки. */
.teacher-profile-grid { align-items: stretch; }
.teacher-profile-card .tpc-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  height: 100%;
}
.teacher-profile-card .tpc-stack > .item-actions { margin-top: auto; padding-top: 6px; }
.teacher-profile-card .collapsible { margin: 6px 0 2px; }
.teacher-profile-card .tpc-packages > div + div { margin-top: 2px; }

/* v13: student teacher picker — filter bar, compact equal-height cards and
   the full-profile modal. The preview hides the long description; cards keep
   one height so the grid stays tidy regardless of content length. */
.teacher-pick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-subtle);
}

.tpf-field { display: grid; gap: 4px; min-width: 150px; }
.tpf-field > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.tpf-field select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  font: inherit;
}

.tpf-courses { position: relative; }
.tpf-courses summary {
  list-style: none;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  white-space: nowrap;
  max-width: 280px;
}
.tpf-courses summary::-webkit-details-marker { display: none; }
.tpf-courses summary::after { content: "▾"; color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.tpf-courses[open] summary { border-color: var(--brand); }
.tpf-courses .tpf-summary-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* v14: the course menu is a single scrollable column — one checkbox + name
   per row, equal row heights, long names wrap without overlapping. */
.tpf-course-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: min(340px, calc(100vw - 32px));
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.tpf-course-menu label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
  background: transparent;
  overflow-wrap: anywhere;
}
.tpf-course-menu label:hover { background: var(--panel-subtle); }
.tpf-course-menu label:has(input:checked) {
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 650;
}
/* Reset the global `input { width:100%; min-height:40px; … }` rule — it is
   what made the v13 checkboxes overlap the course names. */
.tpf-course-menu input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--brand);
}
.tpf-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.teacher-profile-card.compact {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}
.teacher-profile-card.compact[hidden] { display: none; }
.teacher-profile-card.compact .teacher-photo { width: 64px; height: 64px; border-radius: 14px; }
.teacher-profile-card.compact .teacher-photo.placeholder { font-size: 24px; }
.tpc-body { display: grid; gap: 4px; }
.tpc-meta { font-size: 13px; }
.tpc-actions {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tpc-actions form { margin: 0; }

/* v22: профиль преподавателя открывается в широком модальном окне — описание
   читается почти во всю ширину экрана, а не узкой длинной колонкой. */
.popover.teacher-modal { width: min(760px, calc(100vw - 24px)); }
.teacher-full-profile {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  display: grid;
  gap: 8px;
}
.tfp-head { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.tfp-head h3 { margin: 0 0 6px; }
.tfp-head .badge { margin-right: 6px; }
.tfp-description {
  margin: 6px 0 10px;
  color: var(--text-soft);
  white-space: pre-line;
  line-height: 1.6;
  max-width: none;
  overflow-wrap: anywhere;
}

.time-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(13, 148, 136, .3);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 750;
  font-size: 13px;
}

.token-link {
  display: block;
  word-break: break-all;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  border: 1px solid var(--line);
  font-size: 13px;
}

/* ---------- Hero / next lesson ---------- */

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 24px 28px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(13, 148, 136, .25);
  background:
    radial-gradient(1200px 300px at 0% 0%, rgba(20, 184, 166, .12), transparent 60%),
    linear-gradient(135deg, #f0fdfa, #ffffff 55%);
  box-shadow: var(--shadow-soft);
}

.hero-card h1 { margin: 2px 0 4px; font-size: 26px; font-weight: 800; }

.next-lesson {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-soft);
  min-width: min(420px, 100%);
}

.next-lesson-when { display: grid; gap: 1px; }

.next-lesson-when strong { font-size: 19px; font-weight: 800; }

.lesson-cta-buttons { display: flex; flex-direction: column; gap: 8px; }
.lesson-cta-buttons .btn-lg { width: 100%; }

/* ---------- Payroll scale ---------- */

.payroll-scale {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: center;
}

.payroll-scale h2 { margin-bottom: 4px; }
.payroll-scale p { margin: 0; }

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

.payroll-steps span {
  display: grid;
  gap: 4px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.payroll-steps span.highlight {
  border-color: rgba(124, 58, 237, .35);
  background: var(--violet-soft);
  color: var(--violet);
}

.payroll-steps strong { font-size: 18px; font-weight: 800; color: var(--text); }
.payroll-steps span.highlight strong { color: var(--violet); }

/* ============================================================
   Calendar (Google-Calendar-like)
   ============================================================ */

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

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-subtle);
}

.cal-toolbar .cal-title {
  font-size: 17px;
  font-weight: 800;
  min-width: 170px;
  text-transform: capitalize;
}

.cal-nav { display: inline-flex; gap: 4px; }

.cal-nav button, .icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text-soft);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.cal-nav button:hover, .icon-button:hover { background: #f8fafc; border-color: #b6c2d2; }

.cal-toolbar .spacer { flex: 1; }

.cal-jump { display: inline-flex; align-items: center; gap: 6px; }

.cal-jump input[type="date"] { min-height: 36px; width: 150px; border-radius: 10px; font-size: 13px; }

/* month view */

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }

.cal-dow {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
}

.cal-cell {
  min-height: 112px;
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  display: grid;
  gap: 5px;
  align-content: start;
  background: #fff;
  cursor: pointer;
  transition: background .12s ease;
  overflow: hidden;
}

.cal-cell:nth-child(7n) { border-right: 0; }

.cal-cell:hover { background: #fafcfd; }

.cal-cell.other-month { background: var(--panel-subtle); }
.cal-cell.other-month .cal-daynum { color: #b6c2d2; }

.cal-cell.past { background: #fbfcfd; }

.cal-daynum {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 700;
}

.cal-cell.today .cal-daynum { background: var(--brand); color: #fff; box-shadow: 0 3px 8px rgba(13, 148, 136, .35); }

.cal-more { color: var(--muted); font-size: 11.5px; font-weight: 700; }

/* week / day time grid */

/* Prominent "Moscow time" note above the teacher calendar (v10). */
.tz-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #93c5fd;
  background: var(--blue-soft, #eff6ff);
  color: #1d4ed8;
  font-size: 14px;
}

.tz-note strong { font-weight: 700; }

.cal-week-wrap { overflow-x: auto; }

.cal-week {
  display: grid;
  grid-template-columns: 56px repeat(var(--cal-days, 7), minmax(96px, 1fr));
  min-width: 100%;
}

.cal-week.single { --cal-days: 1; }

.cal-week-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 8px 8px 9px;
  text-align: center;
}

.cal-week-head .dow { display: block; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }

.cal-week-head .num {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  margin-top: 3px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-soft);
}

.cal-week-head.today .num { background: var(--brand); color: #fff; box-shadow: 0 3px 8px rgba(13, 148, 136, .35); }

/* Time rows auto-grow (min 64px) so lesson cards are never clipped at the
   bottom of a slot: a row with a taller card stretches instead of cutting it. */
.cal-hour-label {
  min-height: 64px;
  padding: 3px 8px 0 0;
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  border-right: 1px solid var(--line-soft);
  transform: translateY(-7px);
  background: #fff;
}

.cal-hour-cell {
  min-height: 64px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  background: #fff;
  padding: 2px;
  cursor: pointer;
  transition: background .12s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: stretch;
  justify-content: flex-start;
}

.cal-hour-cell:hover { background: #f6fdfb; }

.cal-hour-cell:hover::after {
  content: "+";
  position: absolute;
  inset: 2px;
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(13, 148, 136, .4);
  border-radius: 8px;
  color: var(--brand);
  font-weight: 800;
  font-size: 15px;
  pointer-events: none;
}

.cal-hour-cell.has-event { cursor: default; }
.cal-hour-cell.has-event:hover { background: #fff; }
.cal-hour-cell.has-event:hover::after { display: none; }

.cal-hour-cell.today-col { background: #fbfefd; }

.cal-hour-cell.past-cell { background: #fafbfc; }
.cal-hour-cell.past-cell:hover::after { border-color: var(--line-strong); color: var(--muted); content: "+ урок"; font-size: 11px; }

/* event chips */

.cal-event {
  display: grid;
  gap: 1px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 5px 8px 6px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.3;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}

.cal-event:hover { filter: brightness(.97); box-shadow: var(--shadow-soft); }

.cal-event strong { font-size: 12px; font-weight: 750; }

.cal-event .sub { font-weight: 550; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* v23: имя ученика — первая и самая заметная строка карточки. Полный контраст
   (никакой прозрачности), вес больше служебного текста; время и статус живут
   отдельной строкой ниже и не могут вытеснить имя. */
.cal-event .ev-name {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  opacity: 1;
  overflow-wrap: anywhere;
  order: -1;
}
.cal-event .ev-meta {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  opacity: .95;
  min-width: 0;
}
.cal-event .ev-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-event .ev-compact { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event .ev-compact .ev-name { font-size: 11.5px; }

/* Week/day views: uniform card height, full multi-line text (no clipping). */
.cal-week .cal-event { min-height: 56px; overflow: visible; align-content: start; }
.cal-week .cal-event .sub { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.cal-week .cal-event .ev-status { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; }
.cal-week .cal-event .ev-name { white-space: normal; overflow: visible; }
/* Month view keeps compact single-line chips. */
.cal-month .cal-event { overflow: hidden; min-height: 0; }

.cal-event.ev-single { background: var(--yellow-soft); color: var(--yellow); border-color: #fde047; }
.cal-event.ev-recurring { background: var(--green-soft); color: var(--green); border-color: #86efac; }
.cal-event.ev-booked { background: var(--orange-soft); color: var(--orange); border-color: #fdba74; }
.cal-event.ev-group { background: var(--violet-soft); color: var(--violet); border-color: #d8b4fe; }
.cal-event.ev-blocked { background: #f1f5f9; color: var(--text-soft); border-color: var(--line-strong); }
.cal-event.ev-past { background: var(--blue-soft); color: #1d4ed8; border-color: #93c5fd; }
/* lesson outcome states — one card per lesson, colour reflects the status.
   v23: тексты статусов затемнены до уровня, читаемого на своём фоне (имя
   ученика наследует этот же цвет и не сливается с подложкой). */
.cal-event.ev-done { background: var(--green-soft); color: var(--green); border-color: #86efac; }
.cal-event.ev-missed { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.cal-event.ev-unset { background: #fef9c3; color: #854d0e; border-color: #f59e0b; border-width: 1.5px; }
.cal-event.ev-needs-status { position: relative; box-shadow: 0 0 0 2px rgba(245, 158, 11, .18); }
.cal-event .ev-status { font-size: 10px; font-weight: 650; opacity: 1; overflow-wrap: anywhere; }
.cal-event .ev-flag { position: absolute; top: 2px; right: 3px; font-size: 10px; line-height: 1; }
.cal-event.ev-today { background: var(--orange-soft); color: var(--orange); border-color: #fdba74; }
.cal-event.ev-planned { background: var(--yellow-soft); color: var(--yellow); border-color: #fde047; }
.cal-event.ev-free { background: var(--brand-tint); color: var(--brand-dark); border-color: rgba(13, 148, 136, .35); border-style: dashed; }
.cal-event.ev-free:hover { background: var(--brand-soft); }

/* legend */

.cal-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.cal-legend i {
  width: 11px;
  height: 11px;
  display: inline-block;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid transparent;
}

.cal-legend .lg-single i { background: var(--yellow-soft); border-color: #fde047; }
.cal-legend .lg-recurring i { background: var(--green-soft); border-color: #86efac; }
.cal-legend .lg-booked i { background: var(--orange-soft); border-color: #fdba74; }
.cal-legend .lg-group i { background: var(--violet-soft); border-color: #d8b4fe; }
.cal-legend .lg-blocked i { background: #f1f5f9; border-color: var(--line-strong); }
.cal-legend .lg-closed i { background: #fff; border-color: var(--line-strong); }
.cal-legend .lg-past i { background: var(--blue-soft); border-color: #93c5fd; }
.cal-legend .lg-done i { background: var(--green-soft); border-color: #86efac; }
.cal-legend .lg-needs-status i { background: #fef9c3; border-color: #f59e0b; }
.cal-legend .lg-free i { background: var(--brand-tint); border-color: rgba(13, 148, 136, .45); }

/* ---------- Popover ---------- */

.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, .18);
  backdrop-filter: blur(1px);
  animation: fade-in .12s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* v22: серверная разметка диалогов прячется атрибутом hidden — он должен
   побеждать display:flex самого поповера. */
.popover[hidden], .popover-backdrop[hidden] { display: none; }

.popover {
  position: fixed;
  z-index: 61;
  width: min(360px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  /* Always fit the viewport and scroll internally so the save button below is
     never pushed off-screen on small displays. */
  display: flex;
  flex-direction: column;
  max-height: min(640px, calc(100vh - 20px));
  max-height: min(640px, calc(100dvh - 20px));
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.15);
}

/* v14: viewport-centered modal (teacher profile «Узнать больше» and friends).
   Fixed positioning keeps the backdrop still; only the modal body scrolls,
   so the bottom action buttons are always reachable. */
.popover.centered {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  max-height: 88vh;
  max-height: 88dvh;
  animation: pop-in-centered .16s cubic-bezier(.2, .9, .3, 1.15);
}

@keyframes pop-in-centered {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)) scale(.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Shell layout: fixed head, scrolling body, pinned footer (save button). */
.popover.has-shell { padding: 0; }
.popover .popover-head { padding: 18px 18px 6px; flex: 0 0 auto; }
.popover .popover-scroll {
  padding: 6px 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
}
.popover .popover-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover h3 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }

.popover .popover-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.popover .popover-head .popover-sub { margin: 4px 0 0; }

.popover .stack { display: grid; gap: 12px; }

.popover .popover-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}

.popover .popover-close:hover { background: #f1f5f9; color: var(--text); }

.popover-actions { display: grid; gap: 8px; }

.popover-actions form { display: contents; }

.popover-actions button, .popover-actions a {
  width: 100%;
  justify-content: flex-start;
}

.recurring-fields { display: grid; gap: 12px; }

.recurring-fields[hidden] { display: none; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
}

.switch-row .switch-label { font-size: 13.5px; font-weight: 650; color: var(--text-soft); }

.switch {
  position: relative;
  width: 40px;
  height: 24px;
  flex: 0 0 auto;
  display: inline-block;
}

.switch input { display: none; }

.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #e2e8f0;
  transition: background .18s ease;
  cursor: pointer;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
  transition: transform .18s ease;
}

.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(16px); }

/* ---------- Timeline (student history) ---------- */

.timeline { display: grid; gap: 0; max-height: 480px; overflow: auto; }

.timeline-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
  align-items: start;
}

.timeline-row:last-child { border-bottom: 0; }

.timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--line-strong);
  box-shadow: 0 0 0 3px #f1f5f9;
  justify-self: center;
}

.timeline-dot.green { background: #22c55e; box-shadow: 0 0 0 3px var(--green-soft); }
.timeline-dot.red { background: #ef4444; box-shadow: 0 0 0 3px var(--red-soft); }
.timeline-dot.blue { background: #3b82f6; box-shadow: 0 0 0 3px var(--blue-soft); }
.timeline-dot.yellow { background: #eab308; box-shadow: 0 0 0 3px var(--yellow-soft); }
.timeline-dot.violet { background: #8b5cf6; box-shadow: 0 0 0 3px var(--violet-soft); }

/* ---------- Teamlead ---------- */

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

.teamlead-card-grid { display: grid; gap: 18px; }

.teamlead-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.teamlead-card.health-critical { border-color: #fca5a5; }
.teamlead-card.health-warn { border-color: #fcd34d; }

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

.health-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px var(--green-soft);
}

.health-dot.warn { background: #f59e0b; box-shadow: 0 0 0 4px var(--amber-soft); }
.health-dot.critical { background: #ef4444; box-shadow: 0 0 0 4px var(--red-soft); }

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

.kpi-strip div, .hours-box, .vacation-box {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--panel-subtle);
}

.kpi-strip span, .hours-box span, .vacation-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }

.kpi-strip strong { display: block; margin-top: 2px; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }

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

.status-line {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
}

.status-line span, .status-line strong { position: relative; z-index: 1; }

.status-line i { position: absolute; inset: auto auto 0 0; height: 3px; background: #22c55e; }

.status-cancelled_by_student i, .status-cancelled_by_teacher i,
.status-student_no_show i, .status-teacher_no_show i { background: #ef4444; }

.status-rescheduled_by_student i, .status-rescheduled_by_teacher i { background: #f59e0b; }

.teamlead-card-bottom { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr); gap: 12px; }

.hours-box, .vacation-box { display: grid; gap: 8px; }

.hours-box h3, .vacation-box h3 { margin: 0 0 2px; font-size: 14.5px; }

.hours-box strong, .vacation-box strong { font-size: 13px; }

/* ---------- Lesson cards (curator) ---------- */

.lesson-list { max-height: 780px; }

.lesson-card { display: grid; gap: 12px; padding: 16px; }

.lesson-card-main {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(210px, 1.3fr) minmax(160px, auto);
  gap: 14px;
  align-items: start;
}

.row-details { background: var(--panel-subtle); }

.row-details[open] { padding-bottom: 12px; }

.row-details .lesson-actions { padding: 0 12px; }

.lesson-actions { display: grid; gap: 8px; }

.lesson-actions form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

/* ---------- Login ---------- */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(20, 184, 166, .14), transparent 60%),
    radial-gradient(700px 380px at -10% 110%, rgba(37, 99, 235, .08), transparent 55%),
    var(--bg);
  font-family: var(--font);
  color: var(--text);
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-panel h1 { margin: 0 0 18px; font-size: 22px; }

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--text-soft);
  font-weight: 800;
}

.stack { display: grid; gap: 14px; }

/* ---------- Search inputs ---------- */

.search-input {
  position: relative;
  min-width: min(320px, 100%);
}

.search-input input { padding-left: 34px; }

.search-input::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background: currentColor;
  color: var(--muted);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="black" d="M11.7 10.3a6 6 0 1 0-1.4 1.4l3 3a1 1 0 0 0 1.4-1.4zM3 7a4 4 0 1 1 8 0 4 4 0 0 1-8 0z"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="black" d="M11.7 10.3a6 6 0 1 0-1.4 1.4l3 3a1 1 0 0 0 1.4-1.4zM3 7a4 4 0 1 1 8 0 4 4 0 0 1-8 0z"/></svg>') center / contain no-repeat;
  pointer-events: none;
}

/* ---------- Misc ---------- */

.mini-button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text-soft);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.mini-button:hover { background: #f8fafc; }

.mini-button.danger { border-color: #fecaca; color: var(--red); }
.mini-button.danger:hover { background: #fff5f5; }

.logo-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.logo-tools input[type="file"] { max-width: 240px; }

.divider { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }

.hidden { display: none !important; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .payroll-scale { grid-template-columns: 1fr; }
  .payroll-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .teamlead-card-bottom { grid-template-columns: 1fr; }
  .lesson-card-main { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }

  .topbar { flex-wrap: wrap; gap: 10px; padding-top: 12px; padding-bottom: 12px; }

  .shell { width: calc(100% - 24px); padding-top: 20px; }

  .page-head { flex-direction: column; align-items: flex-start; }

  .page-head h1 { font-size: 24px; }

  .summary-grid, .form-grid, .package-preview, .filter-bar, .curator-filter,
  .teamlead-filter, .inline-cancel, .inline-tools, .teacher-grid,
  .lesson-card-main, .teamlead-summary, .kpi-strip, .status-strip,
  .teacher-profile-grid, .payroll-steps, .cards, .pill-toggle {
    grid-template-columns: 1fr;
  }

  .pill-toggle { display: grid; }

  .form-actions { grid-column: auto; }

  .list-row, .upcoming-row, .notification-row, .compact-row,
  .lesson-actions form { grid-template-columns: 1fr; }

  .segmented { width: 100%; }
  .segmented button, .segmented .secondary { flex: 1; }

  .cal-toolbar { padding: 10px 12px; }
  .cal-toolbar .cal-title { min-width: 0; font-size: 15px; order: -1; width: 100%; }
  .cal-cell { min-height: 76px; padding: 5px; }
  .cal-event { padding: 3px 6px; font-size: 10.5px; }
  .cal-week { grid-template-columns: 44px repeat(var(--cal-days, 7), minmax(84px, 1fr)); }

  .nav { width: 100%; order: 3; }
  .nav a { flex: 1; justify-content: center; }

  .hero-card { padding: 18px; }
  .next-lesson { min-width: 100%; }

  .timeline-row { grid-template-columns: 14px minmax(0, 1fr); }
  .timeline-row > span:last-child { grid-column: 2; }
}

/* ---------- v6: teacher hero, language switch, vacation, weekday toggle ---------- */

.teacher-hero { align-items: flex-start; gap: 20px; }
.teacher-hero-main { display: flex; gap: 18px; align-items: flex-start; flex: 1; min-width: 0; }
.teacher-hero-photo img.avatar,
.teacher-hero-photo .avatar { width: 84px; height: 84px; border-radius: 18px; font-size: 32px; object-fit: cover; }
.teacher-bio { margin: 8px 0 0; max-width: 60ch; color: var(--text-soft); font-size: 14px; line-height: 1.5; }
.teacher-hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.hero-video { margin-top: 10px; }
.hero-video video { width: 100%; max-width: 420px; border-radius: 14px; border: 1px solid var(--line); background: #000; }

.lang-switch { flex: 0 0 auto; }
.lang-switch button { min-width: 46px; font-weight: 700; }

/* vacation card */
.vacation-card .vacation-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.vacation-card .vacation-row:first-of-type { border-top: 0; }
.vacation-actions { display: flex; gap: 8px; }

/* calendar vacation highlighting */
.cal-cell.vac { background: rgba(100, 116, 139, .12); }
.cal-cell.vac .cal-daynum { color: var(--muted); }
.cal-vac-label {
  display: inline-block; margin-top: 2px; font-size: 9.5px; font-weight: 700;
  color: #475569; background: rgba(148, 163, 184, .25); padding: 1px 5px; border-radius: 5px;
}
.cal-week-head.vac { background: rgba(100, 116, 139, .12); }
.cal-week-head.vac .vac-tag { display: block; font-size: 9px; color: #475569; font-weight: 700; }
.cal-hour-cell.vac-cell { background: repeating-linear-gradient(45deg, rgba(148,163,184,.10), rgba(148,163,184,.10) 8px, rgba(148,163,184,.16) 8px, rgba(148,163,184,.16) 16px); }

/* multi-day weekday toggle */
.weekday-toggle { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-toggle label {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 0; width: 40px; text-align: center;
  font-size: 13px; font-weight: 650; cursor: pointer; user-select: none; transition: .12s;
}
.weekday-toggle input { display: none; }
.weekday-toggle label:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-dark); }

.danger-action { color: #b91c1c; }
.field-error { color: #b91c1c; font-size: 12.5px; }

@media (max-width: 560px) {
  .popover {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    width: 100%; max-width: 100%; max-height: 90dvh;
    border-radius: 18px 18px 0 0;
  }
  .teacher-hero-main { flex-direction: column; }
  .teacher-hero-side { align-items: flex-start; }
}

/* v6: student next-payment card (v18: responsive tile grid) */
.pay-next-card {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 24px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-subtle); margin-top: 6px;
}
.pay-next-card span { display: block; font-size: 12.5px; }
.pay-next-card strong { font-size: 16px; display: block; }

/* v18: smooth expand/collapse (student payment schedule and friends) */
.collapsible { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.collapsible.open { grid-template-rows: 1fr; }
.collapsible > .collapsible-inner { overflow: hidden; min-height: 0; }

/* v6: curator group panel */
.group-create { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--panel-subtle); }
.gc-type.segmented, .group-filters.segmented { width: 100%; margin-bottom: 6px; }
.gc-type.segmented button, .group-filters.segmented button { flex: 1; }
.group-extra-filters { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.group-extra-filters select { flex: 1; min-width: 160px; }
.group-table td, .group-table th { white-space: nowrap; }
.group-table .group-actions { display: flex; gap: 6px; flex-wrap: wrap; white-space: normal; min-width: 220px; }
.group-table-wrap { margin-bottom: 8px; }

/* v6: manager student card */
.student-card-head .subline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.field-group {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 4px;
  margin: 0 0 14px; display: grid; gap: 10px; grid-template-columns: 1fr 1fr;
}
.field-group legend { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; }
.field-group label.wide { grid-column: 1 / -1; }
.inner-table table { min-width: 520px; }
@media (max-width: 720px) { .field-group { grid-template-columns: 1fr; } }

/* v11: teacher calendar with half-hour rows — slimmer cells so the day still
   fits the viewport; the :30 divider is dashed to read as a half-step. */
/* v12: fixed half-hour geometry. Every row is exactly --slot-h tall, so a
   card can be positioned absolutely inside its start cell and span its true
   50-minute duration (50/30 of a row) into the next row. Rows never stretch,
   cards never push each other around. */
.cal-week.half-hours { --slot-h: 40px; }
.cal-week.half-hours .cal-hour-label,
.cal-week.half-hours .cal-hour-cell { height: var(--slot-h); min-height: 0; }
.cal-week.half-hours .cal-hour-label.half { color: #94a3b8; font-size: 10px; }
/* Cards overlap the following half-hour row: z-index 1 lifts them above the
   later sibling cells (position:relative, z-index auto) while the sticky day
   heads (z-index 2) stay on top. Overlapping events are split into columns
   by the JS, so cards never sit on top of each other. */
.cal-week.half-hours .cal-event {
  position: absolute;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
  padding: 4px 7px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.cal-week.half-hours .cal-event .sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* v23: имя занимает до двух строк и переносится, а служебная строка (время ·
   статус) прижата под ним и сжимается сама — имя не обрезается никогда.
   Обе строки вместе укладываются в фиксированную высоту 50-минутной карточки
   (2 × 14.4px имени + 12px метаданных + padding < var(--slot-h) * 50 / 30). */
.cal-week.half-hours .cal-event .ev-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.cal-week.half-hours .cal-event .ev-meta {
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
}
.cal-week.half-hours .cal-event .ev-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-week.half-hours .cal-hour-cell:not(.half) { border-bottom-style: dashed; }
.cal-week.half-hours .cal-hour-cell.half { border-bottom-style: solid; }
/* v14: the hover "+" preview spans the real 50-minute duration with the exact
   geometry of a placed card (top 1px, height 50/30 of a row − 3px), so the
   slot the teacher is about to open looks identical to the saved one. The
   z-index lifts the overhang above the following row like the cards; the
   light fill keeps the full extent readable across the row border. */
.cal-week.half-hours .cal-hour-cell:hover::after {
  font-size: 12px;
  inset: auto;
  top: 1px;
  left: 2px;
  right: 2px;
  height: calc(var(--slot-h) * 50 / 30 - 3px);
  z-index: 1;
  background: rgba(13, 148, 136, .06);
}
.cal-week.half-hours .cal-hour-cell.past-cell:hover::after { background: rgba(148, 163, 184, .08); }

/* v11: curator — accepting-new-students switch on the teacher card */
.teacher-card .accepting-row { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.teacher-card .accepting-row .switch-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* v11: curator payouts table — sortable headers */
#payoutTable .payout-sort { border: 0; background: transparent; font: inherit; font-weight: 700; color: inherit; cursor: pointer; padding: 0; }
#payoutTable .payout-sort:hover { color: var(--brand); }

/* ---------- v15: teacher «Мои ученики» — wide sectioned cards ---------- */
/* 1-3 columns depending on viewport; each card is a flex column so the
   actions row pins to the bottom and cards in a row stay equal height. */
.student-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}
.teacher-student-card { display: flex; flex-direction: column; gap: 12px; }

.tsc-head { display: flex; gap: 12px; align-items: center; }
.tsc-head > .avatar { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; flex: 0 0 auto; object-fit: cover; }
.tsc-head-info { display: grid; gap: 2px; min-width: 0; }
.tsc-name { font-size: 15px; }
.tsc-meta { font-size: 12.5px; overflow-wrap: anywhere; }

/* Block 2 — the key numbers, visually accented. */
.tsc-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: var(--blue-tint);
  border: 1px solid var(--blue-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.tsc-kpi { display: grid; gap: 2px; align-content: start; min-width: 0; }
.tsc-kpi > span:first-child { font-size: 11px; font-weight: 600; color: var(--muted); }
.tsc-kpi > strong { font-size: 19px; line-height: 1.15; white-space: nowrap; }
.tsc-kpi-sub { font-size: 11px; }

/* Block 3 — per-direction balances as one small three-row table. */
.tsc-types {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-subtle);
  padding: 8px 12px;
  display: grid;
  gap: 0;
}
.tsc-types-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-bottom: 4px;
}
.tsc-type-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(96px, auto);
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
  padding: 5px 0;
}
.tsc-type-row + .tsc-type-row { border-top: 1px dashed var(--line); }
.tsc-type-label { font-weight: 600; }
.tsc-type-left strong { font-size: 14px; }
.tsc-type-paid { font-size: 12px; text-align: right; white-space: nowrap; }

/* AI prompt — its own section: header, big field, send button right below.
   v26: сам текст пишется в отдельном большом редакторе, в карточке остаётся
   компактное превью черновика. */
.tsc-prompt { border-top: 1px dashed var(--line); padding-top: 10px; }
.tsc-prompt label { display: grid; gap: 6px; }
.tsc-prompt-title { font-size: 13px; font-weight: 600; display: block; }
.tsc-prompt textarea { width: 100%; resize: vertical; min-height: 84px; }
.tsc-prompt-preview {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--panel-subtle);
  max-height: 84px;
  overflow: hidden;
}
.tsc-prompt-preview.has-draft { color: var(--text); border-style: solid; }

/* Actions — 2×2 grid (v18 added the history button), buttons share the width. */
.tsc-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.tsc-actions form { display: contents; }
.tsc-actions button { width: 100%; padding: 9px 8px; font-size: 12.5px; }
.tsc-need-tg { margin-top: auto; }

/* v25: архив учеников в кабинете преподавателя. Переключатель разделов и
   приглушённая карточка архивного ученика — данные те же, изменено только
   оформление, чтобы активный список не перегружался. */
.seg-control {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-subtle);
}
.seg-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-soft); }
.teacher-student-card.archived-student { opacity: 0.82; border-style: dashed; }
.tsc-archive { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
.tsc-archive button { width: 100%; }

/* v18: AI trainings — the «no lessons left» guard and the history modal. */
.tsc-ai-guard { margin: 8px 0 0; font-size: 13px; color: var(--danger, #dc2626); }
.prompt-history-pop { width: min(560px, calc(100vw - 24px)); }
.prompt-history-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel-subtle); }
.prompt-history-item .phi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prompt-history-item .phi-meta { font-size: 12.5px; margin: 2px 0 8px; }
.prompt-history-item .phi-text {
  margin: 0 0 10px; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 13.5px; line-height: 1.45;
  max-height: 180px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.prompt-history-item .phi-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* v26: большой редактор промпта. Окно занимает почти весь экран, поле тянется
   по его высоте — длинный текст (несколько тысяч знаков) виден без постоянной
   прокрутки и удобно правится. */
.prompt-editor-pop { width: min(880px, calc(100vw - 24px)); }
.prompt-editor-area {
  width: 100%;
  min-height: min(56vh, 520px);
  min-height: min(56dvh, 520px);
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  white-space: pre-wrap;
}
.prompt-editor-area:focus { outline: 2px solid var(--blue-soft, #bfdbfe); outline-offset: 1px; }
.prompt-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.prompt-editor-foot .form-actions { margin: 0; }

/* v26: «Архив учеников» — свёрнутый блок под активным списком. Раньше карточки
   архива всегда стояли следом (display:grid перебивал атрибут hidden) и
   удлиняли страницу вдвое. */
.students-archive { margin-top: 16px; }
.students-archive .collapsible-toggle { width: 100%; justify-content: space-between; }
.students-archive .student-cards { margin-top: 12px; }
.students-count { font-size: 13px; white-space: nowrap; }
.student-cards[hidden] { display: none; }

@media (max-width: 960px) {
  .student-cards { grid-template-columns: 1fr; }
  .tsc-actions { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tsc-summary { grid-template-columns: 1fr 1fr; }
  .tsc-type-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tsc-type-paid { grid-column: 1 / -1; text-align: left; padding-left: 0; }
}

/* v21: «Мои пакеты» — по карточке на каждый пакет ученика. У каждой карточки
   свой преподаватель, свой остаток и свой график платежей; ничего не
   смешивается между пакетами. */
.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.package-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .18s ease;
}
.package-card:hover { box-shadow: var(--shadow); }
.package-card.archived { opacity: .65; background: var(--panel-subtle); }
.package-card .pkg-teacher { margin: 0 0 8px; font-size: 13px; }
.package-card .pkg-headline { margin: 0 0 8px; font-size: 15px; }
.package-card .item-actions { margin-top: auto; }
.pkg-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pkg-lines li {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--text-soft);
}
.pkg-lines li strong { color: var(--text); white-space: nowrap; }

/* ---------- v25: карточка пакета в кабинете ученика ----------
   Порядок важности: сколько занятий осталось сейчас (крупная цифра) → когда
   следующий платёж → что он откроет → сколько использовано → сколько всего.
   Каждая цифра подписана, «2 из 50» без пояснений больше не показывается. */
.package-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.pkg-card-v2 { gap: 14px; padding: 18px; }
.pkg-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pkg-card-title { font-size: 16px; line-height: 1.3; }
.pkg-card-v2 .pkg-teacher { margin: 4px 0 0; }

/* v27: остаток по каждому типу занятий — компактная плитка «цифра · тип
   занятий · осталось сейчас». Плитки стоят в ряд, поэтому карточка пакета
   занимает по вертикали втрое меньше места, чем раньше, и несколько пакетов
   помещаются рядом. Подробности (использовано / всего / после платежа) живут
   в раскрывающемся блоке карточки. */
.pkg-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.pkg-type {
  display: grid;
  gap: 1px;
  align-content: start;
  justify-items: center;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px;
  background: var(--panel-subtle);
  min-width: 0;
}
.pkg-type-name { font-weight: 700; font-size: 12.5px; line-height: 1.2; }
.pkg-type-value { font-size: 28px; font-weight: 800; line-height: 1.05; color: var(--brand); }
.pkg-type-value.negative-balance { color: var(--red); }
.pkg-type-caption { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Подробности пакета: по колонке на каждый тип занятий. */
.pkg-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.pkg-type-facts { margin: 0; display: grid; gap: 2px; font-size: 12.5px; color: var(--text-soft); }
.pkg-type-facts > div { display: flex; justify-content: space-between; gap: 8px; }
.pkg-type-facts dt { color: var(--muted); }
.pkg-type-facts dd { margin: 0; font-weight: 600; color: var(--text); white-space: nowrap; }
.pkg-type-facts .pkg-type-next dd { color: var(--green); }
.pkg-type-facts-head dt { color: var(--text); font-weight: 700; }
.pkg-details { margin-top: 4px; }
.pkg-details-body { display: grid; gap: 12px; }
.pkg-monthly .section-head { margin-bottom: 8px; }
.pkg-monthly h3 { margin: 0; font-size: 15px; }
.pkg-card-notice { margin: 10px 0 0; font-size: 13px; }

.pkg-payment {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  border: 1px solid var(--blue-soft);
  background: var(--blue-tint);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.pkg-payment-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: block; }
.pkg-payment-date { display: block; font-size: 17px; line-height: 1.25; margin-top: 2px; }
.pkg-payment-sum { display: block; font-size: 14px; font-weight: 600; color: var(--text-soft); }
.pkg-payment-progress strong { display: block; font-size: 15px; margin-top: 2px; }
.pkg-progress-bar { margin-top: 6px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.pkg-progress-bar span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.pkg-card-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.pkg-card-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
/* v26: остановленные автосписания — платёжный блок меняет тон, чтобы состояние
   пакета читалось с первого взгляда. */
.pkg-payment.stopped { border-color: #fecaca; background: #fef2f2; }

/* ---------- v26: широкие экраны кабинета ученика ----------
   Единственный пакет и единственный преподаватель раньше занимали узкую
   колонку слева, а справа оставалась пустота, из-за чего страница была вдвое
   длиннее нужного. Теперь карточка растягивается на всю ширину, а её
   содержимое раскладывается по колонкам. На планшетах — две колонки, на
   телефонах структура прежняя, вертикальная. */
.package-grid.single { grid-template-columns: 1fr; }
.pkg-card-body { display: grid; gap: 12px; }

/* v27: несколько пакетов раскладываются по ширине экрана — две-три карточки
   в ряд вместо длинного вертикального списка. */
@media (min-width: 1180px) {
  .package-grid { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
}
@media (min-width: 1180px) {
  .package-grid.single .pkg-card-body {
    grid-template-columns: minmax(0, 2.2fr) minmax(250px, 1fr);
    align-items: start;
  }
  .package-grid.single .pkg-payment { grid-template-columns: 1fr; height: 100%; align-content: start; }
  /* Компактнее по вертикали: та же информация, меньше воздуха. */
  .package-grid.single .pkg-type-value { font-size: 30px; }
  .package-grid.single .pkg-card-v2 { gap: 12px; }
}

/* Карточка преподавателя: фото · информация · кнопки. */
.teacher-profile-grid.single { grid-template-columns: 1fr; }
.teacher-profile-card .tpc-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.teacher-profile-card .tpc-side .item-actions { margin: 0; flex-wrap: wrap; }
/* Узкая карточка: кнопки — отдельной строкой во всю ширину под информацией. */
.teacher-profile-card.tpc-wide .tpc-side { grid-column: 1 / -1; }
@media (min-width: 1100px) {
  .teacher-profile-grid.single .teacher-profile-card.tpc-wide {
    grid-template-columns: 96px minmax(0, 1fr) minmax(220px, 280px);
    align-items: start;
  }
  .teacher-profile-grid.single .teacher-profile-card.tpc-wide .tpc-side { grid-column: auto; }
  .teacher-profile-grid.single .teacher-profile-card.tpc-wide .teacher-photo { width: 96px; height: 96px; }
  .teacher-profile-grid.single .tpc-side .item-actions { flex-direction: column; align-items: stretch; }
  .teacher-profile-grid.single .tpc-side .item-actions > * { width: 100%; text-align: center; }
}

/* v26: «AI-тренировки с Chatty» в кабинете ученика. */
.ai-new-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
}
.ai-training-list { display: grid; gap: 8px; }
.ai-training-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--panel-subtle);
}
.ai-training-item.is-new { border-color: #86efac; background: #f0fdf4; }
.ai-training-main { display: flex; align-items: center; gap: 8px; }
.ai-training-meta { font-size: 13px; }

/* v21: «Ближайшие уроки» разбиты по дням — «Завтра», «Пятница» и т. д. */
.upcoming-day {
  margin: 10px 0 2px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.upcoming-day:first-child { margin-top: 0; }

/* v21: карточки пакетов в кабинете менеджера — каждая со своими настройками,
   графиком платежей и начислением уроков. */
.pkg-editor { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: #fff; margin-bottom: 14px; }
.pkg-editor.archived { background: var(--panel-subtle); }
.pkg-editor > .section-head { margin-bottom: 8px; }
.pkg-editor .disclosure { margin-top: 10px; }
.pkg-editor .disclosure summary { cursor: pointer; font-weight: 600; }

@media (max-width: 960px) {
  .package-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   v22: блок уведомлений кабинета — белые карточки с мягкой тенью,
   колокольчик и бейдж с количеством, цветной индикатор слева по типу
   уведомления и аккуратная кнопка «✓». Пустого блока не бывает: когда
   закрыто последнее уведомление, панель удаляется целиком.
   ============================================================ */
.notify-panel { margin-bottom: 24px; }
.notify-panel.closing {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
}
.notify-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.notify-head h2 { margin: 0; font-size: 17px; }
.notify-bell { font-size: 18px; line-height: 1; }
.notify-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.notify-list { display: grid; gap: 10px; }
.notify-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: opacity .2s ease, transform .2s ease, box-shadow .15s ease;
}
.notify-card:hover { box-shadow: var(--shadow); }
.notify-card.closing { opacity: 0; transform: translateX(12px); }
.notify-mark {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
}
.notify-card.tone-green .notify-mark { background: var(--green); }
.notify-card.tone-amber .notify-mark { background: var(--orange); }
.notify-card.tone-blue .notify-mark { background: var(--blue); }
.notify-body { flex: 1 1 auto; min-width: 0; }
.notify-text {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.notify-time { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.notify-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.notify-close:hover { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-dark); }
.notify-close:disabled { opacity: .5; cursor: default; }

@media (max-width: 640px) {
  .notify-card { padding: 10px 12px 10px 14px; gap: 8px; }
  .notify-text { font-size: 13.5px; }
}

/* v22: действия карточки пакета у менеджера — статус, архив и удаление. */
.pkg-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.pkg-editor { transition: opacity .2s ease; }

/* ============================================================
   v22: общий раскрывающийся блок (collapsible / accordion).
   Один компонент на все кабинеты: описание преподавателя в
   кабинете ученика и преподавателя, история начислений и т. д.
   Разметку даёт макрос templates/_components.html, поведение —
   делегированный обработчик в base.html.
   ============================================================ */
.collapsible {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.collapsible + .collapsible { margin-top: 10px; }
.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: var(--panel-subtle);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.collapsible-toggle:hover { background: #f1f5f9; }
.collapsible-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.collapsible-toggle .collapsible-label { flex: 1 1 auto; min-width: 0; }
.collapsible-toggle .collapsible-icon {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
  transition: transform .25s ease;
}
.collapsible.open .collapsible-toggle { background: var(--brand-tint); color: var(--brand-dark); }
.collapsible.open .collapsible-toggle .collapsible-icon { transform: rotate(180deg); color: var(--brand-dark); }
/* Анимация 250 мс: max-height считает JS, поэтому текст любой длины
   раскрывается плавно и не обрезается. */
.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease, opacity .25s ease;
  opacity: 0;
}
.collapsible.open .collapsible-body { opacity: 1; }
.collapsible-inner { padding: 14px; }
/* Текст описания занимает всю ширину блока и переносится по словам —
   никаких узких длинных колонок. */
.collapsible-text {
  margin: 0;
  max-width: none;
  width: 100%;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.collapsible-text p { margin: 0 0 10px; }
.collapsible-text p:last-child { margin-bottom: 0; }

/* v21: чекбокс в форме-сетке (оплата открывает уроки выбранного пакета). */
.form-grid label.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.form-grid label.checkbox-row input { width: auto; margin: 0; }

/* ============================================================
   v23: поле выбора с поиском (search_select в _components.html).
   Обычный <select> остаётся в форме и просто скрывается, когда
   компонент включился (без JS список работает как раньше).
   ============================================================ */
.ss-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ss { position: relative; min-width: 0; }
.ss.ss-ready .ss-native { display: none; }
.ss:not(.ss-ready) .ss-input,
.ss:not(.ss-ready) .ss-list,
.ss:not(.ss-ready) .ss-caret { display: none; }
.ss-input { width: 100%; box-sizing: border-box; padding-right: 28px; }
.ss-caret {
  position: absolute;
  top: 9px;
  right: 10px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: auto;
  cursor: pointer;
}
.ss.open .ss-caret { transform: rotate(180deg); }
.ss-hint { font-size: 11.5px; line-height: 1.35; }
.ss-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}
.ss-option {
  display: grid;
  gap: 1px;
  padding: 6px 9px;
  border-radius: 8px;
  cursor: pointer;
}
.ss-option-name { font-size: 13.5px; font-weight: 650; color: var(--text); }
.ss-option-meta { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.ss-option:hover, .ss-option.active { background: var(--brand-tint); }
.ss-option.selected { background: var(--brand-soft); }
.ss-option.selected .ss-option-name { color: var(--brand-dark); }
.ss-empty { margin: 0; padding: 8px 9px; font-size: 12.5px; color: var(--muted); }

/* ============================================================
   v24: карточки подписок (subscription_cards в _components.html).
   ============================================================ */
.sub-cards { display: grid; gap: 10px; }
.sub-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-subtle, #fafbfc);
}
.sub-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sub-title { font-size: 14px; }
.sub-provider { font-size: 12px; }
.sub-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--text-soft); }
.sub-fact strong { color: var(--text); }
.sub-note { margin: 0; font-size: 12.5px; }
.sub-error { margin: 0; font-size: 12.5px; color: var(--danger, #dc2626); }
.sub-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sub-block { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.sub-block-title { margin: 0; font-size: 14px; font-weight: 750; }
@media (max-width: 600px) {
  .sub-head { flex-direction: column; }
}

/* ============================================================
   v25: очередь «Новые оплаты» в кабинете куратора — оплатившие
   ученики, которых ещё нужно настроить.
   ============================================================ */
.intake-panel { border-left: 3px solid var(--green); }
.intake-list { display: grid; gap: 10px; }
.intake-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-subtle, #fafbfc);
}
.intake-main { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.intake-name { font-size: 15px; }
.intake-meta { font-size: 12.5px; margin-top: 2px; }
.intake-checklist { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12.5px; }
.intake-step.done { color: var(--green); font-weight: 650; }
.intake-step.todo { color: var(--muted); }
.intake-error { margin: 6px 0 0; font-size: 12.5px; color: var(--danger, #dc2626); }
.intake-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 720px) { .intake-main { flex-direction: column; } }
