/* ==========================================================================
   Анкетирование выпускников — дизайн-система
   Адаптив: десктоп (сайдбар) → планшет → мобильный (offcanvas-меню)
   ========================================================================== */

:root {
  --brand-50: #eef4ff;
  --brand-100: #dbe6ff;
  --brand-500: #3b6ef5;
  --brand-600: #2b55d9;
  --brand-700: #2143ab;

  --ink-900: #101828;
  --ink-700: #344054;
  --ink-500: #667085;
  --ink-300: #d0d5dd;

  --surface: #ffffff;
  --canvas: #f3f6fc;
  --line: #e6e9f0;

  --success: #12805c;
  --warning: #b54708;
  --danger: #b42318;
  --danger-bg: #fef3f2;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  --sidebar-width: 272px;
  --topbar-height: 62px;
}

/* ── База ─────────────────────────────────────────────────────────────── */

* { -webkit-tap-highlight-color: transparent; }

body {
  background: radial-gradient(ellipse at 100% 0, #e8efff 0, transparent 45%), var(--canvas);
  color: var(--ink-900);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -0.01em; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

.text-muted { color: var(--ink-500) !important; }

.icon { width: 1.25rem; height: 1.25rem; display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.btn .icon { width: 1rem; height: 1rem; margin-right: 0.3rem; }
:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 3px; }
.card, .card-body, .card-header, .row > *, .page-header > * { min-width: 0; }
.card-header, .page-subtitle, .alert, .badge-scope { overflow-wrap: anywhere; }

/* ── Карточки ─────────────────────────────────────────────────────────── */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 14px rgba(16, 24, 40, 0.04);
  background: var(--surface);
  transition: box-shadow 0.18s ease;
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body { padding: 1.15rem; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }

/* ── Кнопки ───────────────────────────────────────────────────────────── */

.btn {
  border-radius: 10px;
  font-weight: 550;
  padding: 0.5rem 1rem;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  box-shadow: 0 2px 8px rgba(59, 110, 245, 0.25);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-700);
  border-color: var(--brand-700);
}

.btn-sm { border-radius: 8px; padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn-lg { border-radius: 12px; padding: 0.7rem 1.4rem; }

/* ── Формы ────────────────────────────────────────────────────────────── */

.form-label { font-weight: 550; color: var(--ink-700); margin-bottom: 0.35rem; }

.form-control, .form-select {
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--ink-300);
  padding: 0.55rem 0.8rem;
  color: var(--ink-900);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-50);
}

.form-control::placeholder { color: #98a2b3; }

.form-check-input { border-color: var(--ink-300); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus { box-shadow: 0 0 0 4px var(--brand-50); border-color: var(--brand-500); }

.form-switch .form-check-input { width: 2.6em; height: 1.35em; }

/* Блокированные (зафиксированные) поля фильтра */
.locked-filter {
  background: var(--brand-50);
  border: 1px dashed var(--brand-500);
  color: var(--brand-700);
  font-weight: 550;
}

/* ── Раскладка приложения (CSS Grid) ──────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
}

.app-shell--full {
  grid-template-columns: minmax(0, 1fr);
}

/* min-width: 0 обязателен — иначе широкие таблицы растягивают колонку
   и страница уезжает по горизонтали */
.app-main {
  min-width: 0;
  width: 100%;
}

/* ── Сайдбар (десктоп) ────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  grid-column: 1;
  width: var(--sidebar-width);
  min-width: 0;
  height: 100dvh;
  max-height: 100dvh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: radial-gradient(ellipse at 0 0, #233b69 0, transparent 55%), #101a2f;
  color: #fff;
  padding: 1.25rem 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 1.25rem 1.1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 0.9rem;
}

.sidebar-brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-500), #7c3aed);
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  flex: 0 0 auto;
}

.sidebar-brand__text { min-width: 0; }
.sidebar-brand__title {
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.sidebar-brand__subtitle { font-size: 0.75rem; opacity: 0.6; }

.app-navigation { padding: 0 0.75rem; gap: 4px; flex: 0 0 auto; }

.app-navigation .nav-link {
  color: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-navigation .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.app-navigation .nav-link:focus-visible { color: #fff; background: rgba(255, 255, 255, 0.12); }
.app-navigation .nav-link.active { color: #fff; background: linear-gradient(100deg, #315ee7, #4879ef); box-shadow: 0 4px 14px #050e2533; }
.app-navigation .ico { width: 1.2rem; height: 1.2rem; opacity: 0.9; }

.sidebar-section {
  padding: 1rem 1.5rem 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  font-weight: 600;
}

.sidebar-footer {
  margin: auto 1rem 0;
  flex: 0 0 auto;
  padding: 0.9rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
}

.sidebar-footer__identity { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.5rem; }
.sidebar-footer__avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #ffffff14; flex: 0 0 auto; }
.sidebar-footer__name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.sidebar > .sidebar-footer { margin-top: auto; }
.sidebar > .app-navigation { margin-bottom: 1.5rem; }

.badge-scope {
  display: block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(59, 110, 245, 0.22);
  border: 1px solid rgba(124, 158, 255, 0.35);
  color: #dce6ff;
  font-size: 0.76rem;
  line-height: 1.3;
}

/* ── Мобильный topbar + offcanvas ─────────────────────────────────────── */

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  align-items: center;
  padding: 0 0.9rem;
  gap: 0.75rem;
}

.topbar__heading { display: flex; flex: 1 1 0; flex-direction: column; min-width: 0; gap: 2px; }
.topbar__title { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar > .icon-button, .topbar > form { flex: 0 0 auto; }
.topbar__account { font-size: 0.75rem; color: var(--ink-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__scope {
  font-size: 0.72rem;
  color: var(--brand-700);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  max-width: 100%;
  align-self: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offcanvas.sidebar-offcanvas { width: 84vw; max-width: 300px; background: #0d1424; color: #fff; }
.sidebar-offcanvas .offcanvas-body { gap: 1.5rem; }
.sidebar-offcanvas .sidebar-footer { margin-top: auto; }

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: var(--ink-700);
}

/* ── Контент ──────────────────────────────────────────────────────────── */

/* Горизонтальный отступ обязателен: Bootstrap .row использует отрицательные
   margins (-8px на g-3), и без него страница получает горизонтальную прокрутку */
.page { padding: 1.75rem clamp(1rem, 2.2vw, 2.5rem) 3rem; max-width: 1800px; margin-inline: auto; }
.workspace-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: 1.1rem; margin-bottom: 1.4rem; border-bottom: 1px solid var(--line); font-size: 0.8rem; color: var(--ink-500); }
.workspace-bar__label { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--ink-700); }
.workspace-bar__account { overflow-wrap: anywhere; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-title { font-size: clamp(1.4rem, 1.1rem + 0.65vw, 2rem); margin: 0; font-weight: 750; color: #172846; }
.page-subtitle { color: var(--ink-500); font-size: 0.92rem; margin: 0.25rem 0 0; }

.counter-pill {
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ── Оповещения ───────────────────────────────────────────────────────── */

.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.85rem 1.1rem;
}

.alert-success { background: #ecfdf3; border-color: #abefc6; color: var(--success); }
.alert-danger { background: var(--danger-bg); border-color: #fecdca; color: var(--danger); }
.alert-secondary { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.alert-info { background: #eff8ff; border-color: #b9e6fe; color: #175cd3; }

/* ── Таблицы ──────────────────────────────────────────────────────────── */

.table {
  --bs-table-bg: transparent;
  border-color: var(--line);
  margin-bottom: 0;
}

.table > :not(caption) > * > * { padding: 0.65rem 0.75rem; vertical-align: middle; }
.table thead th {
  background: #f8fafc;
  color: var(--ink-500);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 650;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.table tbody tr:hover { background: var(--brand-50); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: transparent; }
.table-sm > :not(caption) > * > * { padding: 0.5rem 0.65rem; }

/* На мобильных таблица превращаются в карточки */
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.admin-password-form { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.admin-password-form input[type="password"] { width: 145px; flex: 1 1 110px; }
.reference-edit-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 0.5rem; align-items: start; }
.reference-edit-form--school { grid-template-columns: minmax(150px, 1fr) minmax(130px, 210px) auto; }
.reference-name-preview { display: none; }

.student-rounds {
  display: grid;
  grid-template-columns: repeat(2, minmax(2rem, max-content));
  gap: 4px;
  justify-content: start;
}
.student-rounds .badge { width: 100%; border: 0; line-height: 1.5; cursor: pointer; }
.student-history-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--brand-700);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.student-history-link:hover { text-decoration: underline; }
.student-history-link:focus-visible, .student-rounds .badge:focus-visible {
  outline: 3px solid var(--brand-500, #6172f3);
  outline-offset: 2px;
  border-radius: 4px;
}
.student-history-answers > div { padding: 0.85rem 0; border-top: 1px solid var(--line); }
.student-history-answers dt { font-size: 0.85rem; font-weight: 500; color: var(--ink-500); margin-bottom: 0.25rem; }
.student-history-answers dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.student-select-all { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; cursor: pointer; }
.student-select-all .form-check-input { margin: 0; flex-shrink: 0; }

/* Формы внутри modal-content тоже должны сжиматься: иначе длинная форма
   обрезается вместе с кнопками вместо прокрутки modal-body. */
.modal-dialog-scrollable .modal-content > form { display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
.modal-header > div { min-width: 0; overflow-wrap: anywhere; }
.modal-title, .modal-body { overflow-wrap: anywhere; }
.modal-header .btn-close { flex-shrink: 0; }

/* Действия ученика: четыре фиксированных места вместо переноса текстовых кнопок. */
.student-actions-cell { width: 1%; white-space: nowrap; }
.student-actions {
  display: inline-grid;
  grid-template-columns: repeat(4, 40px);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  vertical-align: middle;
}
.student-actions .student-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-700);
  background: #f3f5f8;
}
.student-actions .student-action .icon { width: 19px; height: 19px; margin: 0; }
.student-actions .student-action--primary { color: #175cd3; background: #eff8ff; }
.student-actions .student-action--warning { color: #93370d; background: #fffaeb; }
.student-actions .student-action--danger { color: var(--danger); background: var(--danger-bg); }
.student-actions .student-action:hover:not(:disabled) { border-color: currentColor; filter: brightness(0.96); }
.student-actions .student-action:focus-visible { outline: 3px solid var(--brand-500, #6172f3); outline-offset: 2px; box-shadow: none; }
.student-actions .student-action:disabled { opacity: 0.35; }

@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack tbody th { display: none; }
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-responsive:has(> .table-stack) { padding: 0.75rem; }

  .table-stack tbody tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    width: 100%;
  }
  .table-stack tbody tr:last-child { margin-bottom: 0; }

  .table-stack tbody td {
    display: grid;
    grid-template-columns: minmax(70px, 0.35fr) minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    border: none;
    padding: 0.55rem 0.4rem;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    width: auto !important;
    min-width: 0;
  }
  .table-stack tbody td + td { border-top: 1px solid #f0f2f6; }
  .table-stack tbody td > * { grid-column: 2; min-width: 0; max-width: 100%; }
  .table-stack tbody td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
  .table-stack tbody td:not([data-label]) > * { grid-column: 1; }
  .table-stack tbody td:not([data-label])::before { display: none; }
  .table-stack tbody td .badge { justify-self: start; white-space: normal; }
  .table-stack tbody td form.d-inline { display: flex !important; flex-wrap: wrap; gap: 0.5rem; }
  .table-stack tbody td form.row { display: flex; }
  .reference-edit-form, .reference-edit-form--school { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .table-stack tbody td > .reference-edit-form { grid-column: 1 / -1; }
  .reference-edit-form .btn { justify-self: start; }
  .table-stack .text-nowrap { white-space: normal !important; }
  .table-stack tbody td.student-actions-cell { grid-template-columns: minmax(0, 1fr); }
  .table-stack tbody td.student-actions-cell > .student-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    grid-template-columns: repeat(4, 44px);
  }
  .student-actions .student-action { width: 44px; height: 44px; }

  .table-stack tbody td::before {
    content: attr(data-label);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink-500);
    grid-column: 1;
    grid-row: 1;
  }
}

/* ── Фильтры ──────────────────────────────────────────────────────────── */

.filter-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.filter-grid .form-label { font-size: 0.78rem; color: var(--ink-500); font-weight: 600; }

.nav-tabs { border-bottom: 1px solid var(--line); gap: 0.25rem; }

.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-500);
  font-weight: 550;
  border-radius: 8px 8px 0 0;
  padding: 0.5rem 1rem;
}

.nav-tabs .nav-link:hover { background: var(--brand-50); color: var(--brand-700); border-bottom-color: var(--brand-100); }
.nav-tabs .nav-link.active { color: var(--brand-700); border-bottom-color: var(--brand-600); background: var(--brand-50); }

/* ── Анкета ───────────────────────────────────────────────────────────── */

.question-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-500);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.question-card .card-body { padding: 1.25rem 1.4rem; }
.question-card .form-check { padding-left: 2rem; margin-bottom: 0.35rem; }
.question-card .form-check-input { width: 1.15rem; height: 1.15rem; }
.question-card .form-check-label { font-size: 0.98rem; }

.question-step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--brand-600);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  margin-right: 0.6rem;
}

/* ── Статистика ───────────────────────────────────────────────────────── */

.stat-card {
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(16,24,40,0.16); }
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.25), transparent 55%);
  pointer-events: none;
}
.stat-card .card-body { position: relative; z-index: 1; padding: 1.25rem 1.35rem; }
.stats-summary > div { display: flex; }
.stats-summary .stat-card { width: 100%; }
.stat-card__heading { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1rem; min-height: 32px; }
.stat-card__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px; background: #ffffff26; }
.stat-card .value { font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-card .label { font-size: 0.78rem; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card.bg-primary { background: linear-gradient(135deg, #3b6ef5, #7c3aed) !important; }
.stat-card.bg-info { background: linear-gradient(135deg, #0891b2, #2563eb) !important; }
.stat-card.bg-success { background: linear-gradient(135deg, #059669, #10b981) !important; }
.stat-card.bg-warning { background: linear-gradient(135deg, #b54708, #f59e0b) !important; }

.chart-box {
  position: relative;
  height: 300px;
  padding: 0.25rem;
  background: linear-gradient(180deg, rgba(59,110,245,0.04), transparent);
  border-radius: var(--radius-sm);
}
.chart-box canvas { max-width: 100%; }

.progress-thin { height: 6px; border-radius: 999px; background: var(--line); }
.progress-thin .progress-bar { background: var(--brand-500); border-radius: 999px; }

/* ── Прочее ───────────────────────────────────────────────────────────── */

.stat-value { font-weight: 700; font-size: 1.05rem; }

.badge { font-weight: 550; border-radius: 8px; padding: 0.35em 0.65em; }
.badge.text-bg-dark { background: var(--ink-900) !important; }
.badge.text-bg-primary { background: var(--brand-600) !important; }
.badge.text-bg-success { background: var(--success) !important; }
.badge.text-bg-secondary { background: var(--ink-500) !important; }
.badge.text-bg-warning { background: var(--warning) !important; }

/* Кнопки выбора лимита попыток (1..4) */
.attempts-group .btn {
  min-width: 3rem;
  font-weight: 650;
}

.setting-switch {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  /* Bootstrap позиционирует переключатель через float + отрицательный
     margin-left, из-за чего он вылезает за блок и наезжает на текст.
     Переводим на flex, чтобы тумблер всегда стоял по месту. */
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.setting-switch .form-check-input {
  float: none;
  margin-left: 0;
  margin-top: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.setting-switch .form-check-label {
  margin-bottom: 0;
  cursor: pointer;
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-500); }
.empty-state .empty-state__icon { font-size: 2.5rem; opacity: 0.35; }
.empty-state__icon .icon { width: 42px; height: 42px; margin-bottom: 0.6rem; }
.modal-content { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { background: #f8faff; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-footer { background: #fafbfe; }
.modal-body { padding: 1.25rem; }
.pagination .page-link { border-color: var(--line); min-width: 34px; text-align: center; padding: 0.4rem 0.65rem; }
.pagination .page-item.active .page-link { background: var(--brand-600); border-color: var(--brand-600); }

/* ── Адаптив ──────────────────────────────────────────────────────────── */

@media (max-width: 1199.98px) {
  /* Сайдбар ещё помещается, но становится компактнее */
  .app-shell { --sidebar-width: 240px; }

  /* Планшет, в том числе альбомный: запись читается целиком, а не через
     горизонтальную прокрутку таблицы из 10–14 узких столбцов. */
  .admin-interface .table-stack thead,
  .admin-interface .table-stack tbody th { display: none; }
  .admin-interface .table-stack,
  .admin-interface .table-stack tbody { display: block; width: 100%; }
  .admin-interface .table-responsive:has(> .table-stack) { padding: 0.75rem; }
  .admin-interface .table-stack tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    padding: 0.4rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    width: 100%;
  }
  .admin-interface .table-stack tbody tr:last-child { margin-bottom: 0; }
  .admin-interface .table-stack tbody td {
    display: block;
    min-width: 0;
    width: auto !important;
    padding: 0.65rem;
    border: 0;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  .admin-interface .table-stack tbody td + td { border-top: 1px solid var(--line); }
  .admin-interface .table-stack tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.3rem;
    color: var(--ink-500);
    font-size: 0.8rem;
    font-weight: 600;
  }
  .admin-interface .table-stack tbody td:not([data-label])::before { display: none; }
  .admin-interface .table-stack tbody td > * { min-width: 0; max-width: 100%; }
  .admin-interface .table-stack tbody td[colspan],
  .admin-interface .table-stack tbody td.student-actions-cell,
  .admin-interface .table-stack tbody td.student-rounds-cell,
  .admin-interface .table-stack tbody td:has(> form) { grid-column: 1 / -1; }
  .admin-interface .table-stack tbody td form.d-inline { display: inline-flex !important; margin: 0.2rem 0; }
  .admin-interface .table-stack tbody td form.row { display: flex; }
  .admin-interface .table-stack .text-nowrap { white-space: normal !important; }
  .admin-interface .table-stack .badge { white-space: normal; }
  .admin-interface .reference-edit-form { grid-template-columns: minmax(0, 1fr) auto; }
  .admin-interface .reference-name-preview { display: block; font-weight: 600; margin-bottom: 0.6rem; }
  .admin-interface .reference-edit-form--school { grid-template-columns: minmax(0, 1fr); }
  .admin-interface .reference-edit-form .btn { justify-self: start; }

  .admin-interface .btn,
  .admin-interface .icon-button,
  .admin-interface .pagination .page-link { min-height: 44px; }
  .admin-interface .btn { white-space: normal; }
  .admin-interface .form-control,
  .admin-interface .form-select { min-height: 44px; font-size: 1rem; }
  .admin-interface .form-check-input { width: 1.25em; height: 1.25em; }
  .admin-interface .form-switch .form-check-input { width: 2.6em; height: 1.35em; }
  .admin-interface .form-check-label { padding-block: 0.35rem; }
  .admin-interface .student-select-all { min-height: 44px; }
  .admin-interface .table-stack tbody td.student-actions-cell { display: flex; align-items: center; gap: 0.5rem; }
  .admin-interface .table-stack tbody td.student-actions-cell::before { flex-shrink: 0; margin-bottom: 0; }
  .admin-interface .table-stack tbody td.student-actions-cell > .student-actions {
    flex: 0 1 202px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin-inline: auto;
  }
  .admin-interface .student-actions .student-action { width: 100%; height: 44px; }
  .admin-interface .student-rounds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-interface .student-rounds .badge { min-height: 44px; }
  .admin-interface .nav-tabs { flex-wrap: wrap; overflow: visible; }
  .admin-interface .nav-tabs .nav-link { min-height: 44px; white-space: normal; }
}

@media (max-width: 991.98px) {
  .topbar { display: flex; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .page { padding: 1.1rem 1rem 2.5rem; }
  .page-title { font-size: 1.35rem; }
  .chart-box { height: 260px; }
  .workspace-bar { display: none; }
}

@media (max-width: 575.98px) {
  body { font-size: 14.5px; }

  .page-title { font-size: 1.2rem; }
  .card-body, .card-header { padding: 0.95rem 1rem; }
  .question-card .card-body { padding: 1rem; }
  .stat-card .value { font-size: 1.9rem; }
  .stat-card__heading { gap: 0.45rem; }
  .stat-card__heading .small { font-size: 0.72rem; }
  .filter-grid { padding: 0.85rem; }
  .filter-grid .row > [class*="col-"] { margin-bottom: 0.1rem; }

  .btn { padding: 0.45rem 0.8rem; }
  .btn-lg { padding: 0.6rem 1.1rem; font-size: 1rem; width: 100%; }
  .d-flex.gap-2 { flex-wrap: wrap; }
  .nav-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-link { white-space: nowrap; }
  .btn-sm { min-height: 36px; }
  .page-header > .d-flex { width: 100%; }
  .page-header > .d-flex > .btn { flex: 1 1 auto; }
  .modal-dialog { margin: 0.5rem; }
  .modal-dialog-scrollable { height: calc(100% - 1rem); }
  .modal-footer { gap: 0.5rem; }
  .modal-footer > .btn { flex: 1 1 auto; margin: 0; }
  .admin-interface .table-stack tbody tr { grid-template-columns: minmax(0, 1fr); }
  .admin-interface .table-stack tbody td { padding: 0.65rem 0.5rem; }
  .admin-interface .reference-edit-form { grid-template-columns: minmax(0, 1fr); }
  .admin-interface .page-header > .btn { width: 100%; }
  .admin-interface .student-select-all { width: 100%; }
  .admin-interface .modal-footer { flex-direction: column; align-items: stretch; }
  .admin-interface .modal-footer > .btn { width: 100%; }
  .admin-interface input[type="date"] { max-width: 100%; appearance: none; }
  .admin-interface .nav-tabs .nav-link { padding-inline: 0.75rem; }
}

/* Вырезы экрана и домашний индикатор в обеих ориентациях телефона. */
@media (max-width: 991.98px) {
  .topbar { height: calc(var(--topbar-height) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); padding-left: max(0.9rem, env(safe-area-inset-left)); padding-right: max(0.9rem, env(safe-area-inset-right)); }
  .page { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: max(2.5rem, env(safe-area-inset-bottom)); }
  .sidebar-offcanvas .offcanvas-body { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .sidebar-offcanvas .offcanvas-header { padding-top: max(1rem, env(safe-area-inset-top)); }
  .admin-interface .modal-dialog-scrollable { height: calc(100dvh - 1rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print {
  .sidebar, .topbar, .filter-grid, .btn, .nav-tabs { display: none !important; }
  body { background: #fff; }
}
