  [x-cloak] { display: none !important; }
  /* Modal overlay: x-show clears inline display when toggling, which broke grid centering.
     Move display+centering into a CSS rule so the original layout is restored on show. */
  .modal-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; }
  .modal-overlay.top { z-index: 210; }
  :root {
    --bg: #fafaf7;
    --surface: #ffffff;
    --surface-2: #f4f3ee;
    --border: #e7e5de;
    --border-strong: #d4d2c8;
    --ink: #1a1a17;
    --ink-2: #44433d;
    --ink-3: #767266;
    --ink-4: #a8a49a;
    --accent: #1a1a17;
    --accent-ink: #fafaf7;
    --good: oklch(0.62 0.11 150);
    --bad: oklch(0.58 0.15 25);
    --warn: oklch(0.72 0.11 75);
    --info: oklch(0.58 0.09 235);
    --radius: 10px;
    --radius-lg: 16px;
    --gap: 16px;
    --tick: 1px;
  }
  html[data-theme="dark"] {
    /* Warm-dark palette — мягче чистого чёрного, чёткая иерархия слоёв.
       bg → surface → surface-2 идут лесенкой по светлоте, чтобы карточки
       и поля ввода читались как отдельные плоскости, а не сливались.
       Палитра подсветлена на один тон от изначальной — было слишком
       темно/контрастно, читалось хуже на больших панелях. */
    --bg: #26241f;            /* теплый graphite, не #000 */
    --surface: #2f2d28;       /* карточки, шапка */
    --surface-2: #3a3732;     /* поля ввода, hover, sub-блоки */
    --border: #494640;        /* контурная граница, видна на surface */
    --border-strong: #5a574f; /* акцентные границы (фокус, чекбокс) */
    --ink: #f3f1ec;           /* основной текст (не чисто белый — мягче) */
    --ink-2: #d2cfc7;
    --ink-3: #a09c93;         /* приглушённый, читается на surface */
    --ink-4: #76716a;         /* placeholder/бледный текст */
    --accent: #f3f1ec;
    --accent-ink: #26241f;
    /* color-scheme сообщает движку браузера, какие системные цвета
       использовать для нативных контролов (выпадашка <select>, скроллбары,
       автокомплит, дата-пикеры). Без этого нативный select на тёмной теме
       оставался белым с тёмным текстом. */
    color-scheme: dark;
  }
  :root { color-scheme: light; }
  html[data-density="compact"] { --gap: 10px; }
  html[data-density="comfy"] { --gap: 22px; }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
  body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
  }
  /* `.mono` исторически был отдельным monospaced-шрифтом (IBM Plex Mono),
     но это давало неуместный «терминальный» вид у дат, времён, логинов и
     прочих коротких служебных значений по всему проекту.
     Теперь класс наследует основной шрифт интерфейса (Inter), а из «моно»-
     поведения сохраняем только `tabular-nums` — это даёт ровные колонки
     цифр в датах и таблицах без смены гарнитуры. */
  .mono {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "zero";
    letter-spacing: 0;
  }
  /* Для настоящего «кодового» контента — JSON-блоки, поля пароля и т.п. —
     monospace всё ещё нужен (иначе плохо читается). Возвращаем IBM Plex Mono
     точечно через теги, на которых класс реально означает «код». */
  pre.mono, code.mono, input.mono {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
  }
  .serif { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; }

  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: default; background: none; border: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }

  /* === App shell === */
  .app { min-height: 100vh; display: flex; flex-direction: column; }
  .topbar {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in oklab, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-bottom: var(--tick) solid var(--border);
  }
  .topbar-inner {
    max-width: 1440px; margin: 0 auto;
    display: flex; align-items: center; gap: 8px;
    padding: 14px 32px;
  }
  .brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
    padding-right: 16px; margin-right: 10px;
    border-right: var(--tick) solid var(--border);
  }
  .brand-text { white-space: nowrap; }
  /* Две картинки: полный лого — десктоп, знак — мобильный (см. media ниже). */
  .brand-logo, .brand-mark {
    display: block; width: auto;
    /* Делаем лого монохромным «под дизайн»:
       brightness(0) превращает любую заливку в чёрную (alpha сохраняется),
       а на тёмной теме invert(1) переводит в белый. */
    filter: brightness(0);
  }
  .brand-logo { height: 30px; }
  .brand-mark { display: none; height: 32px; }
  [data-theme="dark"] .brand-logo,
  [data-theme="dark"] .brand-mark { filter: brightness(0) invert(1); }
  /* Сохраняем .brand-dot для обратной совместимости (если где-то ещё
     используется как акцентный квадрат вне топбара). */
  .brand-dot {
    width: 18px; height: 18px; border-radius: 5px;
    background: var(--ink); color: var(--bg);
    display: grid; place-items: center; font-size: 10px; font-weight: 700;
  }
  .nav { display: flex; gap: 2px; flex: 1; }
  /* Бэкдроп бургер-меню. На десктопе никогда не показывается, на мобиле
     включается через .open (тоггл навешивает JS).
     z-index 89 — такой же, как у .user-menu-backdrop, чтобы затемнение
     ровно так же накрывало и топбар (раньше было 49: топбар оставался
     ярким, а затемнялся только контент под ним). */
  .nav-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 0; padding: 0; appearance: none;
    z-index: 89;
  }
  .nav-item {
    padding: 8px 14px; border-radius: 8px;
    font-size: 14px; font-weight: 500; color: var(--ink-2);
    display: flex; align-items: center; gap: 8px;
    transition: background .12s;
  }
  .nav-item:hover { background: var(--surface-2); color: var(--ink); }
  .nav-item.active { background: var(--ink); color: var(--bg); }
  /* Десктопный popover дочерних пунктов nav-dropdown */
  .nav-dropdown-menu {
    position: absolute; top: 100%; left: 0; margin-top: 6px;
    background: var(--surface);
    border: var(--tick) solid var(--border);
    border-radius: 12px;
    padding: 6px;
    min-width: 220px;
    box-shadow: 0 12px 32px rgba(0,0,0,.10);
    z-index: 90;
    display: flex; flex-direction: column; gap: 2px;
  }
  .nav-count {
    font-size: 11px; padding: 1px 6px; border-radius: 999px;
    background: color-mix(in oklab, currentColor 15%, transparent);
    font-variant-numeric: tabular-nums;
  }
  .nav-item.active .nav-count { background: color-mix(in oklab, var(--bg) 20%, transparent); }

  .top-right { display: flex; align-items: center; gap: 8px; }
  .icon-btn {
    width: 34px; height: 34px; border-radius: 8px;
    display: grid; place-items: center;
    color: var(--ink-2);
  }
  .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  /* Иконка-звезда «Избранное» в топбаре. На странице /favorites закрашена,
     чтобы было видно, что раздел активен (как звезда у избранных курсов). */
  .icon-btn.fav-link.is-active { color: oklch(0.72 0.14 75); }
  .icon-btn.fav-link.is-active svg { fill: currentColor; stroke: currentColor; }

  .role-switch {
    display: inline-flex; background: var(--surface-2); border-radius: 8px;
    padding: 3px; border: var(--tick) solid var(--border);
  }
  .role-switch button {
    padding: 5px 12px; font-size: 12.5px; font-weight: 500;
    color: var(--ink-3); border-radius: 6px;
  }
  .role-switch button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.04); }

  .user-chip {
    position: relative;
    display: flex; align-items: center;
  }
  .user-chip-trigger {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    background: var(--surface-2);
    border: var(--tick) solid transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background .12s, border-color .12s;
  }
  .user-chip-trigger:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--ink) 5%); }
  .user-chip-trigger:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 10%, transparent);
  }
  .user-chip-name { font-size: 13px; font-weight: 500; }
  .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, oklch(.75 .05 250), oklch(.65 .08 200));
    color: white; display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
  }

  /* Выпадающее меню профиля.
     После телепорта в body используем position:fixed с координатами от
     viewport. На широких экранах (>1440px) учитываем, что .topbar-inner
     центрирован — иначе меню «уезжало» бы влево от триггера. */
  .user-menu {
    position: fixed;
    top: 70px;
    right: max(32px, calc((100vw - 1440px) / 2 + 32px));
    background: var(--surface);
    border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px;
    min-width: 260px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .04);
    z-index: 90;
  }
  .user-menu-head {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px 14px;
    border-bottom: var(--tick) solid var(--border);
    margin-bottom: 8px;
  }
  .user-menu-id { min-width: 0; }
  .user-menu-name {
    font-size: 14px; font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 200px;
  }
  .user-menu-role {
    font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--ink-3); margin-top: 2px;
  }
  .user-menu-form { margin: 0; }
  .user-menu-logout {
    width: 100%; justify-content: flex-start;
    padding: 12px 14px; font-size: 14px; border-radius: 10px;
  }
  .user-menu-backdrop {
    /* По умолчанию выключен — на десктопе бэкдроп нам не нужен.
       Видимость на мобиле включается ниже в media (max-width: 820px),
       а Alpine через x-show подставляет inline-стиль display:block/none
       в зависимости от того, открыто меню или нет. */
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 0; padding: 0; appearance: none;
    z-index: 89;
  }

  /* === Content === */
  .main { max-width: 1440px; margin: 0 auto; padding: 28px 32px 80px; width: 100%; }
  .breadcrumbs {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-3); margin-bottom: 20px;
    flex-wrap: nowrap; white-space: nowrap;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
    min-width: 0;
  }
  .breadcrumbs::-webkit-scrollbar { display: none; }
  .breadcrumbs a,
  .breadcrumbs .curr { flex: 0 0 auto; }
  .breadcrumbs a:hover { color: var(--ink); }
  .breadcrumbs .sep { color: var(--ink-4); flex: 0 0 auto; }
  .breadcrumbs .curr { color: var(--ink-2); font-weight: 500; }
  /* На узких экранах сокращаем последний (текущий) пункт по ширине,
     чтобы не выезжать за экран; полная подпись остаётся в title. */
  @media (max-width: 720px) {
    .breadcrumbs { gap: 6px; font-size: 12px; margin-bottom: 14px; }
    .breadcrumbs .curr {
      max-width: 60vw;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
  }
  @media (max-width: 480px) {
    .breadcrumbs { gap: 5px; font-size: 11.5px; }
    .breadcrumbs .curr { max-width: 55vw; }
  }

  h1.page-title { font-size: 32px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }
  h2.page-title { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 8px; }
  .page-sub { color: var(--ink-3); font-size: 15px; margin: 0 0 28px; max-width: 780px; }

  /* === Cards/Surfaces === */
  .card {
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
  }
  .hairline { border-bottom: var(--tick) solid var(--border); }

  /* === Buttons === */
  .btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px; border-radius: 8px;
    font-size: 14px; font-weight: 500;
    border: var(--tick) solid var(--border); background: var(--surface);
    color: var(--ink);
    transition: background .12s, border-color .12s;
  }
  .btn:hover { background: var(--surface-2); }
  .btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .btn.primary:hover { background: color-mix(in oklab, var(--ink) 88%, white); }
  .btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
  .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
  .btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 7px; }
  .btn.lg { padding: 12px 18px; font-size: 15px; border-radius: 10px; }
  .btn.danger { color: var(--bad); }
  .btn:disabled { opacity: .4; }

  /* Группа кнопок-действий в шапке админских страниц (Темы курса, Вопросы и т.д.).
     Базово — горизонтальный ряд равновысоких кнопок. На узких экранах
     переносится, иконки/тексты остаются по центру, кнопки выравниваются по
     одной высоте независимо от длины подписи. */
  .admin-actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }
  .admin-actions-row .btn {
    height: 38px;
    line-height: 1;
    padding-top: 0; padding-bottom: 0;
    white-space: nowrap;
  }
  @media (max-width: 540px) {
    .admin-actions-row { width: 100%; }
    .admin-actions-row .btn {
      flex: 1 1 calc(50% - 4px);
      min-width: 0;
      justify-content: center;
      padding-left: 8px; padding-right: 8px;
      font-size: 13px;
    }
  }

  /* === Chip/Badge === */
  .badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 500; line-height: 1.4;
    border: var(--tick) solid var(--border);
    background: var(--surface-2);
    color: var(--ink-2);
  }
  .badge.good { color: var(--good); border-color: color-mix(in oklab, var(--good) 30%, var(--border)); background: color-mix(in oklab, var(--good) 8%, var(--surface)); }
  .badge.bad  { color: var(--bad);  border-color: color-mix(in oklab, var(--bad) 30%, var(--border));  background: color-mix(in oklab, var(--bad) 8%, var(--surface)); }
  .badge.warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 35%, var(--border)); background: color-mix(in oklab, var(--warn) 10%, var(--surface)); }
  .badge.info { color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, var(--border)); background: color-mix(in oklab, var(--info) 7%, var(--surface)); }
  .badge.solid-ink { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

  /* === Inputs === */
  .input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: var(--tick) solid var(--border); background: var(--surface);
    font-size: 14px; outline: none; color: var(--ink);
  }
  .input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 10%, transparent); }
  .input::placeholder { color: var(--ink-4); }

  .field-label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-3); margin-bottom: 6px; letter-spacing: 0.01em; }
  .field-label .req { color: var(--bad); margin-left: 2px; }
  .field-hint { font-size: 12px; color: var(--ink-4); margin-top: 5px; }
  .input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad) 12%, transparent); }
  .field-error { font-size: 12px; color: var(--bad); margin-top: 6px; line-height: 1.35; }

  .search {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 10px;
    border: var(--tick) solid var(--border); background: var(--surface);
  }
  .search input { flex: 1; border: 0; outline: none; background: transparent; font-size: 14px; color: var(--ink); }
  .search input::placeholder { color: var(--ink-4); }
  .search svg { color: var(--ink-4); flex-shrink: 0; }
  .search kbd {
    font-family: 'IBM Plex Mono', monospace; font-size: 11px;
    padding: 2px 6px; border-radius: 4px; background: var(--surface-2);
    color: var(--ink-3); border: var(--tick) solid var(--border);
  }

  /* Checkbox / radio custom */
  .check {
    width: 18px; height: 18px; border-radius: 5px;
    border: 1.5px solid var(--border-strong); background: var(--surface);
    display: grid; place-items: center; flex-shrink: 0;
    transition: all .12s;
  }
  .check.on { background: var(--ink); border-color: var(--ink); }
  .check.on svg { color: var(--bg); }
  .radio {
    width: 18px; height: 18px; border-radius: 50%;
    border: 1.5px solid var(--border-strong); background: var(--surface);
    display: grid; place-items: center; flex-shrink: 0;
    transition: all .12s;
  }
  .radio.on { border-color: var(--ink); }
  .radio.on::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }

  /* Toggle */
  .toggle {
    width: 34px; height: 20px; border-radius: 999px;
    background: var(--border-strong); position: relative;
    transition: background .14s; flex-shrink: 0;
  }
  .toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform .14s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
  .toggle.on { background: var(--ink); }
  .toggle.on::after { transform: translateX(14px); }

  /* === Tables === */
  .tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
  .tbl th, .tbl td {
    text-align: left; padding: 14px 16px;
    border-bottom: var(--tick) solid var(--border);
    font-size: 14px;
  }
  .tbl th {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--ink-3);
    background: var(--surface-2);
    padding: 10px 16px;
  }
  .tbl tbody tr { transition: background .1s; }
  .tbl tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 50%, transparent); }
  .tbl tr:last-child td { border-bottom: 0; }
  .tbl .num { font-variant-numeric: tabular-nums; color: var(--ink-3); }

  /* Progress */
  .prog { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
  .prog > div { height: 100%; background: var(--ink); border-radius: 999px; transition: width .3s; }

  /* === Timeline === */
  .timeline {
    display: flex; align-items: stretch; gap: 12px;
    padding: 22px 24px;
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
  }
  .tl-step {
    display: flex; flex-direction: column; gap: 10px;
    min-width: 168px; flex: 1;
    cursor: default;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
  }
  .tl-step + .tl-step { margin-left: 4px; }
  .tl-step:hover { background: var(--surface-2); }
  .tl-step.active { background: color-mix(in oklab, var(--ink) 5%, var(--surface)); border-color: color-mix(in oklab, var(--ink) 12%, var(--border)); }
  .tl-step.done { background: color-mix(in oklab, var(--good) 6%, var(--surface)); border-color: color-mix(in oklab, var(--good) 28%, var(--border)); }
  .tl-track {
    display: flex; align-items: center; gap: 10px;
    position: relative;
  }
  .tl-node {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--surface); border: 1.5px solid var(--border-strong);
    display: grid; place-items: center; flex-shrink: 0;
    font-size: 12px; font-weight: 600; color: var(--ink-3);
    font-variant-numeric: tabular-nums;
    transition: background .15s, border-color .15s, color .15s;
  }
  .tl-node.done {
    background: var(--good); border-color: var(--good); color: #fff;
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--good) 15%, transparent);
  }
  .tl-node.curr { border-color: var(--ink); color: var(--ink); border-width: 2px; }
  .tl-node.milestone { border-radius: 7px; }
  .tl-line { flex: 1; height: 2px; background: var(--border); border-radius: 1px; min-width: 8px; }
  .tl-line.done { background: var(--good); }
  .tl-label { font-size: 13px; font-weight: 500; color: var(--ink-2); line-height: 1.35; }
  .tl-meta { font-size: 11px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; }
  .tl-done-mark {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
    color: var(--good); text-transform: uppercase; margin-top: 4px;
  }

  /* === Utility === */
  .row { display: flex; align-items: center; gap: var(--gap); }
  .col { display: flex; flex-direction: column; gap: var(--gap); }
  .spacer { flex: 1; }
  .muted { color: var(--ink-3); }
  .ink-4 { color: var(--ink-4); }
  .small { font-size: 13px; }
  .tiny { font-size: 12px; }
  .right { text-align: right; }
  .tab-nums { font-variant-numeric: tabular-nums; }
  .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }

  /* === Course module sections === */
  .section-card {
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color .15s;
  }
  .section-card:hover { border-color: var(--border-strong); }
  .section-head {
    display: flex; align-items: flex-start; gap: 20px;
    padding: 24px 28px;
    cursor: default;
  }
  .section-num {
    font-family: 'Fraunces', serif;
    font-size: 36px; font-weight: 500;
    color: var(--ink-4);
    font-variant-numeric: tabular-nums;
    line-height: 1; letter-spacing: -0.02em;
    min-width: 52px;
  }
  .section-title {
    font-size: 20px; font-weight: 600; line-height: 1.3;
    margin: 4px 0 8px; letter-spacing: -0.01em;
  }
  .section-meta {
    display: flex; gap: 16px; font-size: 13px; color: var(--ink-3);
  }
  .section-meta .m-label { color: var(--ink-4); margin-right: 4px; }
  .section-body {
    padding: 0 28px 24px 100px;
    display: flex; flex-direction: column; gap: 10px;
  }
  .section-body.collapsed { display: none; }

  .material {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border: var(--tick) solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: background .12s, border-color .12s;
  }
  .material:hover { background: var(--surface-2); border-color: var(--border-strong); }
  .material.active { background: color-mix(in oklab, var(--ink) 4%, var(--surface)); border-color: var(--ink); }

  /* Кликабельная плитка материала на странице курса. Вся плитка — ссылка,
     при наведении проявляется подпись «Читать» / «Смотреть» с шевроном. */
  a.material.material--card {
    text-decoration: none; color: inherit;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  }
  a.material.material--card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in oklab, var(--info) 35%, var(--border));
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
  }
  .material--card .material-body { flex: 1; min-width: 0; }
  .material--card .material-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .material-action {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px; font-weight: 500;
    color: var(--ink-3);
    background: transparent;
    transition: color .15s ease, background .15s ease, padding .15s ease;
    flex-shrink: 0;
  }
  .material-action-label {
    max-width: 0; overflow: hidden; white-space: nowrap;
    opacity: 0;
    transition: max-width .18s ease, opacity .15s ease;
  }
  .material-action-chev {
    transition: transform .15s ease;
  }
  a.material.material--card:hover .material-action {
    color: var(--info);
    background: color-mix(in oklab, var(--info) 10%, transparent);
  }
  a.material.material--card:hover .material-action-label {
    max-width: 120px;
    opacity: 1;
  }
  a.material.material--card:hover .material-action-chev {
    transform: translateX(2px);
  }
  a.material.material--card:focus-visible {
    outline: 2px solid var(--info);
    outline-offset: 2px;
  }
  .file-icon {
    width: 40px; height: 48px;
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: 6px;
    display: grid; place-items: center;
    position: relative;
    font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
    color: var(--bad);
    flex-shrink: 0;
  }
  .file-icon::before {
    content: ""; position: absolute; top: 0; right: 0;
    width: 10px; height: 10px;
    background: var(--border);
    clip-path: polygon(0 0, 100% 100%, 0 100%);
  }
  .material-title { font-size: 15px; font-weight: 500; color: var(--ink); }
  .material-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

  /* === PDF viewer === */
  .pdfv {
    display: grid; grid-template-columns: 260px 1fr;
    border: var(--tick) solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; background: var(--surface);
    height: 720px;
  }
  .pdfv-toc {
    border-right: var(--tick) solid var(--border);
    background: var(--surface-2);
    overflow-y: auto;
    display: flex; flex-direction: column;
  }
  .pdfv-toc-hd {
    padding: 16px 18px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
    border-bottom: var(--tick) solid var(--border);
  }
  .toc-item {
    padding: 10px 18px; font-size: 13px; color: var(--ink-2);
    display: flex; gap: 10px; align-items: baseline;
    border-left: 2px solid transparent;
    transition: background .1s;
  }
  .toc-item:hover { background: color-mix(in oklab, var(--ink) 4%, transparent); }
  .toc-item.active { background: var(--surface); border-left-color: var(--ink); color: var(--ink); font-weight: 500; }
  .toc-item .toc-num { color: var(--ink-4); font-variant-numeric: tabular-nums; font-size: 11px; min-width: 20px; }
  .toc-item.nested { padding-left: 40px; font-size: 12.5px; color: var(--ink-3); }

  .pdfv-pane { display: flex; flex-direction: column; background: var(--surface-2); }
  .pdfv-toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    border-bottom: var(--tick) solid var(--border);
    background: var(--surface);
    font-size: 13px;
  }
  .pdfv-pages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; align-items: center; }
  .pdf-page {
    width: 600px; max-width: 100%; aspect-ratio: 1/1.414;
    background: white; border: var(--tick) solid var(--border);
    border-radius: 4px; box-shadow: 0 4px 20px rgba(0,0,0,.06);
    padding: 60px 54px;
    font-family: 'Inter', serif;
    color: #1a1a17;
    font-size: 12px; line-height: 1.55;
    position: relative;
  }
  .pdf-page h3 { font-size: 16px; font-weight: 600; margin: 0 0 14px; color: #1a1a17; }
  .pdf-page p { margin: 0 0 10px; color: #44433d; }
  .pdf-page .pn { position: absolute; bottom: 18px; right: 24px; font-size: 10px; color: #767266; font-variant-numeric: tabular-nums; }

  /* === Exam question === */
  .exam-shell { max-width: 920px; margin: 0 auto; }
  .exam-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
  .exam-prog-bar { flex: 1; height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
  .exam-prog-bar > div { height: 100%; background: var(--ink); border-radius: 999px; transition: width .25s; }
  .exam-question-num { font-family: 'Fraunces', serif; font-size: 96px; font-weight: 500; line-height: 1; letter-spacing: -0.03em; color: var(--ink); }
  .exam-question-num .slash { color: var(--ink-4); }
  .exam-question-num .total { color: var(--ink-3); font-size: 40px; }
  .exam-question-text {
    font-size: 24px; font-weight: 500; line-height: 1.4; letter-spacing: -0.01em;
    margin: 20px 0 32px;
    text-wrap: pretty;
  }
  .exam-answer {
    display: flex; gap: 16px; align-items: flex-start;
    padding: 18px 22px;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: 14px;
    margin-bottom: 10px;
    transition: all .12s;
  }
  .exam-answer:hover { border-color: var(--border-strong); background: var(--surface-2); }
  .exam-answer.sel { border-color: var(--ink); background: color-mix(in oklab, var(--ink) 4%, var(--surface)); }
  .exam-answer.correct { border-color: var(--good); background: color-mix(in oklab, var(--good) 8%, var(--surface)); }
  .exam-answer.wrong { border-color: var(--bad); background: color-mix(in oklab, var(--bad) 8%, var(--surface)); }
  .exam-answer-letter {
    width: 32px; height: 32px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--surface-2); border: var(--tick) solid var(--border);
    font-size: 13px; font-weight: 600; color: var(--ink-3);
    flex-shrink: 0; font-variant-numeric: tabular-nums;
  }
  .exam-answer.sel .exam-answer-letter { background: var(--ink); border-color: var(--ink); color: var(--bg); }
  .exam-answer-text { font-size: 16px; line-height: 1.5; padding-top: 5px; flex: 1; text-wrap: pretty; }

  .exam-nav-dots {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 14px; border: var(--tick) solid var(--border);
    border-radius: 12px; background: var(--surface);
  }
  .qdot {
    width: 28px; height: 28px; border-radius: 7px;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
    background: var(--surface-2); color: var(--ink-3);
    border: var(--tick) solid var(--border);
  }
  .qdot:hover { background: var(--border); }
  .qdot.answered { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .qdot.current { outline: 2px solid var(--ink); outline-offset: 2px; }
  .qdot.flagged { color: var(--warn); border-color: var(--warn); }

  /* === Schedule cards === */
  .cadet-card {
    display: flex; flex-direction: column; gap: 16px;
    padding: 22px;
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color .12s, transform .12s;
  }
  .cadet-card:hover { border-color: var(--border-strong); }
  .cadet-head { display: flex; align-items: center; gap: 12px; }
  .cadet-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, oklch(.8 .04 250), oklch(.7 .07 200));
    color: white; display: grid; place-items: center;
    font-size: 14px; font-weight: 600;
  }
  .cadet-name { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
  .cadet-rank { font-size: 12px; color: var(--ink-3); }
  .cadet-courses { display: flex; flex-direction: column; gap: 11px; }
  .cc-row { display: flex; flex-direction: column; gap: 5px; }
  .cc-head { display: flex; justify-content: space-between; font-size: 12.5px; }
  .cc-name { color: var(--ink-2); }
  .cc-val { color: var(--ink-3); font-variant-numeric: tabular-nums; }
  .cc-bar { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
  .cc-bar > div { height: 100%; border-radius: 999px; }
  .cc-bar.done > div { background: var(--good); }
  .cc-bar.progress > div { background: var(--ink); }
  .cc-bar.locked > div { background: var(--border-strong); }

  /* === Split layout === */
  .split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
  .split-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
  .split-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }
  @media (max-width: 960px){
    .split-2, .split-3, .split-4 { grid-template-columns: 1fr; }
  }

  /* stats */
  .stat {
    display: flex; flex-direction: column; gap: 8px;
    padding: 20px 22px;
    background: var(--surface); border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg);
  }
  .stat-label { font-size: 12px; font-weight: 500; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
  .stat-value { font-family: 'Fraunces', serif; font-size: 40px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
  .stat-delta { font-size: 12px; color: var(--ink-3); }

  /* form layout samples */
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
  .form-grid .full { grid-column: 1 / -1; }

  /* Classifier table tweaks */
  .filterbar {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    padding: 14px 18px;
    border: var(--tick) solid var(--border); border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--surface);
  }
  .table-wrap {
    border: var(--tick) solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface);
  }
  .table-wrap.no-filter { border-radius: var(--radius-lg); }

  /* pagination */
  .pager { display: flex; align-items: center; gap: 4px; padding: 14px 18px; border-top: var(--tick) solid var(--border); background: var(--surface-2); font-size: 13px; }
  .page-btn { padding: 5px 10px; border-radius: 6px; color: var(--ink-3); font-size: 13px; min-width: 30px; text-align: center; }
  .page-btn:hover { background: var(--surface); color: var(--ink); }
  .page-btn.on { background: var(--ink); color: var(--bg); }

  /* Kicker strip */
  .kicker {
    padding: 16px 20px; border: var(--tick) solid var(--border);
    border-radius: var(--radius-lg); background: var(--surface);
    display: flex; gap: 14px; align-items: center;
  }
  .kicker .k-ico {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--surface-2); display: grid; place-items: center;
    color: var(--ink-2); flex-shrink: 0;
  }

  /* skeleton stripes for PDF placeholders */
  .stripe-bg {
    background-image: repeating-linear-gradient(45deg, transparent 0 8px, color-mix(in oklab, var(--ink-4) 20%, transparent) 8px 9px);
  }

  /* segmented control */
  .seg {
    display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px;
    border: var(--tick) solid var(--border);
  }
  .seg button {
    padding: 6px 14px; font-size: 13px; font-weight: 500;
    border-radius: 6px; color: var(--ink-3);
  }
  .seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

  /* scrollbars */
  /* Резервируем место под вертикальный скроллбар всегда, даже если страница
     короткая и скроллить нечего (например, пустое /favorites). Иначе при
     переходе на «короткую» страницу viewport становится шире на ~10px и
     вся центрированная разметка прыгает вправо. `scrollbar-gutter: stable`
     поддерживается всеми актуальными браузерами; для совсем старых WebKit
     добавляем `overflow-y: scroll` как фолбэк — он гарантирует ту же ширину
     полосы прокрутки во всех состояниях. */
  html { scrollbar-gutter: stable; overflow-y: scroll; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); border: 2px solid var(--bg); background-clip: content-box; }

  /* hover reveal */
  .clickable { cursor: default; }

  /* Focus ring global */
  :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

  /* === Catalog (tiles + list) === */
  .cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
  }
  .cat-tile {
    position: relative;
    display: flex; flex-direction: column; gap: 12px;
    padding: 20px; min-height: 240px;
    border: 1px solid var(--border); border-radius: 14px;
    background: var(--surface);
    transition: border-color .15s, transform .15s, box-shadow .15s, background .15s;
    cursor: pointer;
  }
  .cat-tile:hover {
    border-color: var(--ink-2);
    box-shadow: 0 10px 28px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.04);
    transform: translateY(-2px);
  }
  .cat-tile.has-exam {
    border-color: color-mix(in oklab, var(--warn) 45%, var(--border));
    background:
      linear-gradient(180deg,
        color-mix(in oklab, var(--warn) 6%, var(--surface)) 0%,
        var(--surface) 70%);
  }
  .cat-tile.has-exam::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; border-radius: 14px 0 0 14px;
    background: var(--warn);
  }
  .cat-tile.has-exam:hover {
    border-color: var(--warn);
    box-shadow: 0 10px 28px color-mix(in oklab, var(--warn) 18%, transparent),
                0 2px 6px rgba(0,0,0,.05);
  }
  .cat-tile-title {
    font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
    margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .cat-tile-sub {
    font-size: 12.5px; color: var(--ink-3); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-wrap: pretty;
  }
  .cat-tile-meta {
    display: flex; gap: 14px; flex-wrap: wrap;
    padding-top: 10px; border-top: 1px dashed var(--border);
    font-size: 12px; color: var(--ink-2);
  }
  .cat-row {
    position: relative;
    display: flex; align-items: flex-start; gap: 20px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    transition: background .15s, box-shadow .15s, transform .15s;
    cursor: pointer;
  }
  .cat-row:last-child { border-bottom: 0; }
  .cat-row:hover {
    background: color-mix(in oklab, var(--surface-2) 80%, transparent);
    box-shadow: inset 3px 0 0 var(--ink-2);
  }
  .cat-row.has-exam {
    background: color-mix(in oklab, var(--warn) 4%, var(--surface));
    box-shadow: inset 3px 0 0 var(--warn);
  }
  .cat-row.has-exam:hover {
    background: color-mix(in oklab, var(--warn) 9%, var(--surface));
    box-shadow: inset 3px 0 0 var(--warn);
  }
  .cat-row-num {
    font-size: 28px; color: var(--ink-4); font-weight: 500;
    letter-spacing: -0.02em; min-width: 42px;
    font-variant-numeric: tabular-nums;
  }
  .cat-row-info { flex: 1; min-width: 0; }
  .cat-row-meta {
    gap: 8px; margin-bottom: 4px; flex-wrap: wrap; align-items: center;
    min-height: 18px;
  }
  .cat-row-title {
    font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
  }
  .cat-row-sub {
    font-size: 12.5px; color: var(--ink-3); margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .cat-row-stats {
    display: flex; gap: 22px; flex-shrink: 0;
    font-size: 12.5px; align-items: flex-start;
  }
  .cat-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .cat-cell-val {
    font-weight: 500; font-size: 13.5px; line-height: 1.25;
    color: var(--ink);
  }
  .cat-cell--topics  { width: 60px; }
  .cat-cell--time    { width: 90px; }
  .cat-cell--period  { width: 140px; }
  .cat-cell--exams   { width: 84px; }
  .cat-cell--progress { width: 160px; }

  /* Admin tweaks */
  .admin-tbl th { white-space: nowrap; }
  .admin-tbl td { vertical-align: middle; }

  /* Chip-ссылка «Файлы темы» в админском списке тем — кликабельный
     pill-бейдж с иконкой документа и счётчиком. При наведении уходит
     в info-акцент: визуально читается как «открыть управление файлами»,
     а не «справочный счётчик». Для пустого значения слегка приглушаем
     цвет, чтобы строка с 0 файлов читалась как приглашение к загрузке. */
  .materials-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; min-width: 54px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink-2);
    font-size: 12px; font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s, transform .06s;
  }
  .materials-chip:hover {
    background: color-mix(in oklab, var(--info) 10%, var(--surface));
    border-color: color-mix(in oklab, var(--info) 40%, var(--border));
    color: var(--info);
    transform: translateY(-1px);
  }
  .materials-chip:focus-visible {
    outline: 2px solid var(--ink); outline-offset: 2px;
  }
  .materials-chip.is-empty {
    color: var(--ink-3);
    background: color-mix(in oklab, var(--surface-2) 60%, var(--surface));
  }
  .materials-chip.is-empty:hover {
    color: var(--info);
  }

  /* === Cadets — view shell, tiles, list rows === */
  .view-shell {
    padding: 18px;
    border: 1px solid var(--border); border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--surface);
  }
  .cadet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
  }

  /* Tile */
  .tile {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 14px;
    padding: 20px 20px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    transition: border-color .14s, transform .14s, box-shadow .14s;
  }
  .tile:hover { border-color: var(--border-strong); box-shadow: 0 6px 20px rgba(0,0,0,.05); }
  .tile-stripe {
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: 14px 14px 0 0;
  }
  .tile-head { display: flex; align-items: center; gap: 12px; }
  .tile-name {
    font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tile-rank { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
  .tile-streak {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--ink-2); flex-shrink: 0;
    padding: 3px 8px; border-radius: 999px; background: var(--surface-2);
    border: 1px solid var(--border);
  }
  .tile-headline {
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: 10px;
    border-left: 3px solid var(--border-strong);
  }
  .tile-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
  .tile-h {
    font-family: 'Fraunces', serif;
    font-size: 17px; font-weight: 500; letter-spacing: -0.01em;
    line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-wrap: pretty;
  }
  .tile-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }

  .tile-courses { display: flex; gap: 6px; }
  .tile-stat {
    flex: 1; padding: 10px 8px;
    background: var(--surface-2); border-radius: 8px;
    text-align: center;
  }
  .tile-stat-val { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
  .tile-stat-lbl { font-size: 10.5px; color: var(--ink-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

  .tile-heat { padding-top: 4px; }
  .heat-row { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
  .heat-cell { height: 14px; border-radius: 3px; }

  .tile-foot {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 10px; border-top: 1px dashed var(--border);
  }
  .tile-actions {
    display: flex; gap: 6px;
    margin: 4px -4px -4px;
  }
  .tile-actions .btn { flex: 1; justify-content: center; }

  /* === List rows === */
  .lrow {
    display: grid;
    grid-template-columns: 64px minmax(220px, 1.4fr) minmax(260px, 1.6fr) 200px 130px 110px;
    align-items: center; gap: 18px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color .12s, background .12s;
  }
  .lrow:hover { border-color: var(--border-strong); background: color-mix(in oklab, var(--surface-2) 40%, var(--surface)); }
  .lrow-id { display: flex; align-items: center; }
  .lrow-progress { min-width: 0; }
  .lrow-next { min-width: 0; }
  .lrow-status { display: flex; justify-content: flex-start; }
  .lrow-actions { display: flex; gap: 2px; justify-content: flex-end; }

  .lrow-coursechips { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
  .coursechip {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
    padding: 3px 6px; border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2); color: var(--ink-4);
  }
  .coursechip.done { background: color-mix(in oklab, var(--good) 12%, var(--surface)); color: var(--good); border-color: color-mix(in oklab, var(--good) 30%, var(--border)); }
  .coursechip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .coursechip.queued { background: color-mix(in oklab, var(--warn) 10%, var(--surface)); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 30%, var(--border)); }
  .coursechip.off { opacity: 0.4; }

  @media (max-width: 1100px) {
    .lrow { grid-template-columns: 56px 1fr 1fr 120px; gap: 14px; }
    .lrow-next, .lrow-status { display: none; }
  }
  @media (max-width: 720px) {
    .lrow { grid-template-columns: 48px 1fr auto; padding: 14px; }
    .lrow-progress { grid-column: 1 / -1; padding-top: 6px; border-top: 1px dashed var(--border); }
    .lrow-actions { justify-self: end; }
  }

  /* Question editor modal answers */
  .qa-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface);
    transition: border-color .12s, background .12s;
  }
  .qa-row.correct { background: color-mix(in oklab, var(--good) 6%, var(--surface)); border-color: color-mix(in oklab, var(--good) 30%, var(--border)); }
  .qa-letter {
    width: 28px; height: 28px; border-radius: 7px;
    display: grid; place-items: center;
    background: var(--surface-2); font-weight: 600; font-size: 12px;
    flex-shrink: 0; font-variant-numeric: tabular-nums;
  }
  .qa-row.correct .qa-letter { background: var(--good); color: white; }
  .qa-row.removed { opacity: .42; background: var(--surface-2); border-style: dashed; }
  .qa-row.removed input { text-decoration: line-through; pointer-events: none; }
  .qa-row.removed .qa-letter { background: var(--ink-3); color: var(--bg); }

  /* Tooltip — design-styled */
  [data-tip] { position: relative; }
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: 0; top: calc(100% + 6px);
    background: var(--ink); color: var(--bg);
    padding: 6px 10px; border-radius: 8px;
    font-size: 12px; line-height: 1.35; font-weight: 500;
    white-space: pre-wrap; max-width: 560px; min-width: 280px; width: max-content;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    opacity: 0; transform: translateY(-2px); pointer-events: none;
    transition: opacity .12s ease, transform .12s ease;
    z-index: 100;
  }
  [data-tip]:hover::after, [data-tip]:focus-visible::after {
    opacity: 1; transform: translateY(0);
  }
  [data-tip-pos="top"]::after { top: auto; bottom: calc(100% + 6px); }
  /* Якорим тултип к правому краю элемента — нужно для кнопок у правого края карточки,
     чтобы подсказка не вылезала за пределы блока. */
  [data-tip-pos="bottom-right"]::after { left: auto; right: 0; }
  [data-tip-pos="top-right"]::after { left: auto; right: 0; top: auto; bottom: calc(100% + 6px); }

  /* Баннер «Доступна ещё N попыток» на странице результата экзамена. */
  .retry-banner {
    position: relative;
    margin-top: 18px;
    padding: 28px 28px 24px;
    border-radius: 16px;
    border: 1px solid color-mix(in oklab, var(--info) 28%, var(--border));
    background:
      radial-gradient(120% 120% at 50% -20%, color-mix(in oklab, var(--info) 14%, transparent), transparent 60%),
      color-mix(in oklab, var(--info) 5%, var(--surface));
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .retry-banner-icon {
    width: 44px; height: 44px;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--info);
    background: color-mix(in oklab, var(--info) 14%, var(--bg));
    border: 1px solid color-mix(in oklab, var(--info) 32%, var(--border));
    margin-bottom: 4px;
  }
  .retry-banner-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: color-mix(in oklab, var(--info) 70%, var(--ink-2));
    font-weight: 600;
  }
  .retry-banner-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--ink-1);
    max-width: 640px;
  }
  .retry-banner-text {
    font-size: 13px;
    color: var(--ink-2);
    max-width: 560px;
    line-height: 1.5;
  }
  .retry-banner-action { margin-top: 14px; }

  /* === Responsive === */
  .mobile-only { display: none !important; }
  .desk-only { display: flex; }
  @media (max-width: 1100px) {
    .hide-md { display: none !important; }
    .topbar-inner { padding: 12px 20px; }
    .main { padding: 22px 20px 80px; }
    h1.page-title { font-size: 28px; }
    .cat-row-stats { gap: 16px; }
  }
  @media (max-width: 820px) {
    .hide-sm { display: none !important; }
    .desk-only { display: none !important; }
    .mobile-only { display: grid !important; }
    /* Топбар на мобильном — три зоны через CSS Grid:
       [бургер слева] [лого по центру] [тема + профиль справа].
       Grid даёт настоящее центрирование лого независимо от ширины
       соседних колонок (которые могут быть разной ширины). */
    .topbar-inner {
      display: grid;
      grid-template-columns: auto 1fr auto;
      grid-template-areas: "burger brand right";
      align-items: center;
      padding: 8px 12px; gap: 8px; min-height: 56px;
    }
    [data-burger]    { grid-area: burger; }
    .topbar .brand   { grid-area: brand; justify-self: center; }
    .topbar .top-right { grid-area: right; }
    /* .nav на мобильном — position:fixed, поэтому из grid-потока выпадает,
       grid-area можно не указывать. */

    .topbar .icon-btn { width: 42px; height: 42px; border-radius: 10px; }
    .brand {
      padding-right: 0; margin-right: 0; border-right: 0;
      font-size: 14px; gap: 6px;
      min-width: 0;
    }
    .brand-text { display: none; }
    /* На мобиле полную версию прячем, показываем компактный знак. */
    .brand-logo { display: none; }
    .brand-mark { display: block; height: 30px; }
    .top-right { gap: 4px; }
    .main { padding: 18px 14px 80px; }
    h1.page-title { font-size: 24px; }
    h2.page-title { font-size: 20px; }
    .page-sub { font-size: 14px; margin-bottom: 20px; }
    /* Бургер-меню на мобиле — плавающий «лист» в стиле меню профиля:
       не прибит к краям, со скруглением и тенью, с бэкдропом.
       z-index 90 — выше .nav-backdrop (89) и совпадает с .user-menu. */
    .nav {
      position: fixed;
      top: 64px;
      left: 12px;
      right: 12px;
      flex-direction: column; gap: 4px;
      background: var(--surface);
      border: var(--tick) solid var(--border);
      border-radius: 14px;
      padding: 10px;
      z-index: 90;
      display: none;
      box-shadow: 0 24px 48px rgba(0, 0, 0, .18);
      max-height: calc(100dvh - 64px - 16px);
      overflow-y: auto;
    }
    .nav.open { display: flex; }
    .nav-backdrop.open { display: block; }
    /* Когда мобильное меню открыто, body не должен прокручиваться под бэкдропом. */
    body.nav-locked { overflow: hidden; touch-action: none; }
    .nav-item {
      width: 100%; justify-content: flex-start;
      padding: 14px 16px; font-size: 15px; border-radius: 10px;
      gap: 12px;
    }
    .nav-item svg { width: 18px !important; height: 18px !important; }
    /* Группа с детьми (nav-dropdown) — на мобильном раскрыта инлайн, без
       поповера. Иначе пришлось бы дополнительно тапать «Администрирование»
       и матать вложенный список — нам нужен один экран, в котором всё видно. */
    .nav .nav-dropdown { width: 100%; position: static !important; }
    .nav .nav-dropdown-trigger {
      pointer-events: none;        /* в мобильном меню это просто заголовок секции */
      background: transparent !important; color: var(--ink-3) !important;
      text-transform: uppercase;
      font-size: 11px; letter-spacing: 0.08em; font-weight: 600;
      padding: 14px 16px 6px;
    }
    .nav .nav-dropdown-trigger .nav-dropdown-chev { display: none; }
    .nav .nav-dropdown-trigger > svg:first-child { opacity: .6; }
    /* Список детей: всегда видим, плоско вписан в общий список,
       с лёгким отступом слева, чтобы визуально понимать вложенность.
       !important нужен, чтобы перебить inline display:none, который
       Alpine ставит при x-show=false (на десктопе так и работает поповер). */
    .nav .nav-dropdown-menu {
      display: flex !important;
      position: static !important;
      margin: 0; padding: 0 0 6px 0;
      background: transparent !important;
      border: 0 !important; box-shadow: none !important;
      min-width: 0;
    }
    .nav .nav-dropdown-menu .nav-item { padding-left: 32px; }
    /* Профиль на мобиле: компактный (только аватар + шеврон), бо́льше тапа. */
    .user-chip-trigger { padding: 4px 10px 4px 4px; min-height: 44px; }
    .avatar { width: 32px; height: 32px; font-size: 13px; }
    /* Меню профиля — выезжает как «лист» из-под топбара, центрирован
       по правому краю, с бэкдропом. Нет ощущения «приклеенности
       к экрану» — есть рамка, тень, отступы. */
    .user-menu {
      position: fixed;
      top: 64px; right: 12px; left: auto;
      width: calc(100vw - 24px); max-width: 340px;
      padding: 10px;
      border-radius: 14px;
      box-shadow: 0 24px 48px rgba(0, 0, 0, .18);
    }
    .user-menu-name { max-width: none; font-size: 15px; }
    .user-menu-logout { padding: 14px 16px; font-size: 15px; }
    /* На мобиле — дефолт «показан»; Alpine через x-show ставит inline
       display:none, когда меню закрыто, и снимает его при открытии,
       поэтому в открытом состоянии работает этот display:block. */
    .user-menu-backdrop { display: block; }
    .cat-row-stats { display: none; }
    .cat-row-num { font-size: 20px; min-width: 30px; }
    .cat-row { padding: 14px 14px; gap: 12px; }
    .tbl th, .tbl td { padding: 10px 10px; font-size: 13px; }
    .section-body { padding: 0 18px 18px 18px; }
    .section-head { padding: 18px 18px; gap: 14px; }
    .section-num { font-size: 28px; min-width: 36px; }
    .section-title { font-size: 16px; }
    .pdfv { grid-template-columns: 1fr; height: auto; }
    .pdfv-toc { max-height: 200px; border-right: 0; border-bottom: 1px solid var(--border); }
    .pdf-page { width: 100%; padding: 30px 24px; }
    .exam-question-num { font-size: 64px; }
    .exam-question-text { font-size: 19px; }
    .exam-answer { padding: 14px 16px; }
    .exam-answer-text { font-size: 15px; }
    .cat-tile { min-height: 0; padding: 16px; }
    .filterbar { padding: 12px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .cadet-card { padding: 16px; }
  }
  @media (max-width: 500px) {
    .role-switch { display: none; }
    .split-2, .split-3, .split-4 { grid-template-columns: 1fr !important; }
    .stat-value { font-size: 30px; }
  }

/* === Auth screen === */
.auth-shell {
  /* Фуллскрин-оверлей: фиксированно прижимаем к окну. Так раскладка не
     зависит от паддингов .main (которые на десктопе/планшете/телефоне
     разные — иначе градиент и карточка съезжали влево на мобильном). */
  position: fixed;
  inset: 0;
  z-index: 50;
  /* dvh — чтобы на мобильном Safari карточка не уезжала под нижний бар */
  min-height: 100vh;
  min-height: 100dvh;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(at 18% 12%,  color-mix(in oklab, var(--info) 22%, transparent), transparent 55%),
    radial-gradient(at 82% 88%,  color-mix(in oklab, var(--good) 18%, transparent), transparent 55%),
    radial-gradient(at 50% 50%,  color-mix(in oklab, var(--warn) 8%,  transparent), transparent 60%),
    linear-gradient(135deg,
      color-mix(in oklab, var(--bg) 92%, var(--info) 8%) 0%,
      var(--bg) 60%,
      color-mix(in oklab, var(--bg) 92%, var(--good) 8%) 100%);
}
[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(at 20% 10%,  color-mix(in oklab, var(--info) 28%, transparent), transparent 55%),
    radial-gradient(at 80% 90%,  color-mix(in oklab, #9bd8c7 20%,    transparent), transparent 55%),
    radial-gradient(at 50% 50%,  color-mix(in oklab, var(--ink) 5%,  transparent), transparent 70%),
    linear-gradient(135deg,
      color-mix(in oklab, var(--bg) 80%, var(--info) 20%) 0%,
      var(--bg) 55%,
      color-mix(in oklab, var(--bg) 80%, #5fbfa6 20%) 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px 32px;
  background: var(--surface);
  border: var(--tick) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .03);
  text-align: center;
}
.auth-logo {
  display: flex; justify-content: center;
  margin: 0 0 26px;
}
.auth-logo-img {
  display: block; height: 110px; width: auto; max-width: 260px;
  /* То же монохромное окрашивание, что и в шапке. */
  filter: brightness(0);
}
[data-theme="dark"] .auth-logo-img { filter: brightness(0) invert(1); }
@media (max-width: 480px) {
  .auth-logo-img { height: 92px; }
}

.auth-title { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.auth-sub { margin: 0 0 24px; color: var(--ink-3); font-size: 14px; line-height: 1.35; }
.auth-sub-full  { display: inline; }
/* На телефоне больше не подменяем полное наименование на аббревиатуру —
   просто ужимаем шрифт, чтобы оно аккуратно поместилось. */
.auth-sub-short { display: none; }
@media (max-width: 480px) {
  .auth-sub { font-size: 12px; }
  .auth-title { font-size: 20px; }
}
/* Форма выровнена по левому краю даже внутри центрированной карточки. */
.auth-card form { text-align: left; }
.auth-card .field-label { text-align: left; }
.auth-error {
  padding: 10px 12px; margin-bottom: 16px;
  border-radius: 8px; font-size: 13px;
  color: var(--bad);
  background: color-mix(in oklab, var(--bad) 8%, var(--surface));
  border: var(--tick) solid color-mix(in oklab, var(--bad) 30%, var(--border));
}
.auth-field { margin-bottom: 14px; }
.auth-foot { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 13px; color: var(--ink-2); }

/* === DataTables (yajra) — приведение к стилю сайта === */
.dt-wrap { border: var(--tick) solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.dt-wrap .dt-container {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
.dt-wrap .dt-layout-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
}
.dt-wrap .dt-layout-row--top { border-bottom: var(--tick) solid var(--border); background: var(--surface); }
.dt-wrap .dt-layout-row--bottom { border-top: var(--tick) solid var(--border); background: var(--surface-2); }
.dt-wrap .dt-layout-cell { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dt-wrap .dt-layout-start { margin-right: auto; }
.dt-wrap .dt-layout-end { margin-left: auto; }
.dt-wrap .dt-layout-full { flex: 1 1 100%; }

/* Поиск занимает 50% ширины слева; селектор «Показывать N» — справа. */
.dt-wrap .dt-layout-row--top .dt-layout-start { flex: 0 0 50%; max-width: 50%; margin-right: auto; }
.dt-wrap .dt-layout-row--top .dt-layout-start .dt-search { width: 100%; }
.dt-wrap .dt-layout-row--top .dt-layout-start .dt-search label { width: 100%; }
.dt-wrap .dt-layout-row--top .dt-layout-start .dt-search input.dt-input { flex: 1 1 auto; width: 100%; min-width: 0; }
@media (max-width: 720px) {
  .dt-wrap .dt-layout-row--top .dt-layout-start { flex: 1 1 100%; max-width: 100%; }
}

/* Шире — поле поиска в таблице пользователей: 70% слева, выбор pageLength справа. */
.dt-wrap.users-dt .dt-layout-row--top .dt-layout-start { flex: 0 0 70%; max-width: 70%; }
.dt-wrap.users-dt .dt-layout-row--top .dt-layout-end { flex: 0 0 30%; max-width: 30%; justify-content: flex-end; }
.dt-wrap.users-dt input.dt-input { min-width: 520px; }

.dt-wrap .dt-length, .dt-wrap .dt-search, .dt-wrap .dt-info, .dt-wrap .dt-paging { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.dt-wrap .dt-length label, .dt-wrap .dt-search label { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-3); font-size: 13px; }
.dt-wrap select.dt-input,
.dt-wrap input.dt-input {
  padding: 7px 10px; border-radius: 8px;
  border: var(--tick) solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--ink); outline: none;
  font-family: inherit;
  min-width: 64px;
}
.dt-wrap input.dt-input { min-width: 220px; padding: 8px 12px; }
.dt-wrap select.dt-input:focus,
.dt-wrap input.dt-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 10%, transparent); }
.dt-wrap input.dt-input::placeholder { color: var(--ink-4); }

.dt-wrap table.dataTable { width: 100% !important; border-collapse: separate; border-spacing: 0; margin: 0 !important; table-layout: fixed; }
.dt-wrap table.dataTable tbody td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-wrap table.dataTable tbody td.dt-actions,
.dt-wrap table.dataTable tbody td:has(.badge),
.dt-wrap table.dataTable tbody td:has(.row-actions) { overflow: visible; text-overflow: clip; }
.dt-wrap table.dataTable thead th,
.dt-wrap table.dataTable tbody td {
  text-align: left; padding: 14px 18px;
  border-bottom: var(--tick) solid var(--border);
  font-size: 14px; color: var(--ink);
}
.dt-wrap table.dataTable thead th {
  font-size: 13px; font-weight: 600;
  letter-spacing: 0; color: var(--ink-2);
  background: var(--surface-2);
  padding: 12px 18px;
  border-bottom: var(--tick) solid var(--border);
  white-space: nowrap;
}
.dt-wrap table.dataTable thead th.dt-orderable-asc,
.dt-wrap table.dataTable thead th.dt-orderable-desc { cursor: pointer; user-select: none; }
.dt-wrap table.dataTable thead th.dt-orderable-asc:hover,
.dt-wrap table.dataTable thead th.dt-orderable-desc:hover { background: color-mix(in oklab, var(--ink) 6%, var(--surface-2)); color: var(--ink); }
.dt-wrap table.dataTable thead th .dt-column-order { display: inline-block; width: 10px; margin-left: 6px; opacity: .45; font-size: 10px; line-height: 1; }
.dt-wrap table.dataTable thead th.dt-orderable-asc .dt-column-order::before,
.dt-wrap table.dataTable thead th.dt-orderable-desc .dt-column-order::before { content: '\2195'; }
.dt-wrap table.dataTable thead th.dt-ordering-asc { color: var(--ink); }
.dt-wrap table.dataTable thead th.dt-ordering-desc { color: var(--ink); }
.dt-wrap table.dataTable thead th.dt-ordering-asc .dt-column-order { opacity: 1; }
.dt-wrap table.dataTable thead th.dt-ordering-desc .dt-column-order { opacity: 1; }
.dt-wrap table.dataTable thead th.dt-ordering-asc .dt-column-order::before { content: '\25B2'; font-size: 9px; }
.dt-wrap table.dataTable thead th.dt-ordering-desc .dt-column-order::before { content: '\25BC'; font-size: 9px; }
.dt-wrap table.dataTable tbody tr { transition: background .1s; }
.dt-wrap table.dataTable tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 50%, transparent); }
.dt-wrap table.dataTable tbody tr:last-child td { border-bottom: 0; }
.dt-wrap table.dataTable tbody td.dt-empty { padding: 32px 18px; text-align: center; color: var(--ink-3); }

/* пагинация */
.dt-wrap .dt-paging .dt-paging-button {
  padding: 6px 10px; border-radius: 6px; min-width: 30px; text-align: center;
  color: var(--ink-3); font-size: 13px; background: transparent; border: 0;
  font-family: inherit;
  cursor: pointer;
}
.dt-wrap .dt-paging .dt-paging-button:hover:not(.disabled):not(.current) { background: var(--surface); color: var(--ink); }
.dt-wrap .dt-paging .dt-paging-button.current { background: var(--ink); color: var(--bg); }
.dt-wrap .dt-paging .dt-paging-button.disabled { opacity: .35; cursor: default; }
.dt-wrap .dt-info { color: var(--ink-3); }
.dt-wrap .dt-processing { color: var(--ink-3); font-size: 13px; }

/* большие иконки действий в таблицах */
.icon-btn.lg { width: 40px; height: 40px; border-radius: 10px; }
.row-actions { display: inline-flex; gap: 6px; }

/* Раздел «Курсы»: фильтры в шапке таблицы и компактные действия. */
.dt-wrap.courses-dt .dt-layout-row--top { flex-wrap: nowrap; }
.dt-wrap.courses-dt .dt-layout-row--top .dt-layout-start { flex: 1 1 auto; min-width: 0; max-width: none; margin-right: 12px; }
.dt-wrap.courses-dt .dt-layout-row--top .dt-layout-end { flex: 0 0 auto; max-width: none; justify-content: flex-end; }
.dt-wrap.courses-dt .dt-layout-row--top .dt-search { width: 100%; flex: 1 1 auto; }
.dt-wrap.courses-dt .dt-layout-row--top .dt-search label { width: 100%; flex: 1 1 auto; }
.dt-wrap.courses-dt .dt-layout-row--top .dt-search input.dt-input { width: 100% !important; min-width: 0 !important; flex: 1 1 auto; }
.dt-wrap.courses-dt .dt-filters { display: inline-flex; gap: 8px; align-items: center; }
.dt-wrap.courses-dt .dt-filters .ts-wrapper { min-width: 180px; }
.dt-wrap.courses-dt .dt-filters .ts-wrapper.single .ts-control { padding: 7px 12px; }
.dt-wrap.courses-dt .dt-filters .dt-filters-reset { white-space: nowrap; }
.dt-wrap.courses-dt table.dataTable tbody td.dt-actions .row-actions .icon-btn.lg { width: 34px; height: 34px; }
@media (max-width: 960px) {
  .dt-wrap.courses-dt .dt-layout-row--top .dt-layout-start,
  .dt-wrap.courses-dt .dt-layout-row--top .dt-layout-end { flex: 1 1 100%; max-width: 100%; }
}

/* ========== Адаптив админских таблиц (Курсы / Пользователи / Группы) ========== */
@media (max-width: 960px) {
  /* Никакой контент шире экрана не должен «панить» страницу горизонтально. */
  html, body { overflow-x: hidden; max-width: 100vw; }
  .main { max-width: 100%; overflow-x: hidden; }

  /* Внешняя обёртка таблицы — на ширину экрана, без горизонтального переполнения
     наружу (горизонтальный скролл — только у самой таблицы внутри). */
  .dt-wrap { overflow: hidden; max-width: 100%; }
  .dt-wrap .dt-container { max-width: 100%; }

  /* Тулбары: верх/низ — в столбик во всю ширину, с дышащими отступами. */
  .dt-wrap .dt-layout-row { padding: 16px 20px; gap: 14px; flex-wrap: wrap; }
  .dt-wrap .dt-layout-row:not(.dt-layout-table) { flex-direction: column; align-items: stretch; gap: 16px; padding: 16px 20px; }
  .dt-wrap .dt-layout-row:not(.dt-layout-table) .dt-layout-start,
  .dt-wrap .dt-layout-row:not(.dt-layout-table) .dt-layout-end {
    flex: 1 1 100% !important; max-width: 100% !important;
    margin: 0 !important; justify-content: flex-start; gap: 10px;
  }
  /* Внутри cell контролы должны иметь отступы между лейблом «Поиск:» / «Показывать»
     и самим инпутом/селектом, и не прижиматься к краям. */
  .dt-wrap .dt-search label,
  .dt-wrap .dt-length label { gap: 10px; }
  /* Сам инпут поиска получает дополнительный «комфортный» внутренний padding. */
  .dt-wrap input.dt-input { padding: 10px 14px !important; }
  .dt-wrap select.dt-input { padding: 8px 12px !important; }

  /* dt-search и dt-length — оба flex-row с фиксированным label слева
     и растягивающимся контролом справа. Это даёт стабильную раскладку
     независимо от внутренней разметки DataTables 2. */
  .dt-wrap .dt-search,
  .dt-wrap .dt-length,
  .dt-wrap.users-dt .dt-search,
  .dt-wrap.courses-dt .dt-search {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box;
  }
  .dt-wrap .dt-search label,
  .dt-wrap .dt-length label,
  .dt-wrap.users-dt .dt-search label,
  .dt-wrap.courses-dt .dt-search label {
    width: auto !important;
    flex: 0 0 auto !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    white-space: nowrap;
  }
  /* Инпут поиска: занимает остаток внутри .dt-search, не вылезает. */
  .dt-wrap input.dt-input,
  .dt-wrap.users-dt input.dt-input,
  .dt-wrap.courses-dt input.dt-input {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }
  /* Селект «Показывать N» — естественной ширины. */
  .dt-wrap .dt-length select.dt-input {
    flex: 0 0 auto !important;
    width: auto !important;
  }

  /* Селектор «Показывать N» — слева, не уезжает вправо. */
  .dt-wrap .dt-length { justify-content: flex-start; flex-wrap: wrap; }
  .dt-wrap .dt-length label { flex-wrap: wrap; }

  /* Фильтры на странице «Курсы» — две полноценные плитки + кнопка «Сброс» снизу. */
  .dt-wrap.courses-dt .dt-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }
  .dt-wrap.courses-dt .dt-filters > * { min-width: 0; }
  .dt-wrap.courses-dt .dt-filters .ts-wrapper { min-width: 0; width: 100%; }
  .dt-wrap.courses-dt .dt-filters .ts-wrapper.single .ts-control { padding: 9px 12px; }
  .dt-wrap.courses-dt .dt-filters .dt-filters-reset {
    grid-column: 1 / -1;
    justify-self: stretch;
    padding: 9px 12px;
  }

  /* Низ: «Записи 1–10» и пагинация — в столбик, без выравнивания вправо. */
  .dt-wrap .dt-info { justify-content: flex-start; }
  .dt-wrap .dt-paging { flex-wrap: wrap; justify-content: flex-start; gap: 2px; }

  /* Горизонтальный скролл собственно для таблицы. DataTables 2 помечает
     ряд с таблицей классом .dt-layout-table — делаем его прокручиваемым,
     а таблице снимаем фиксированную раскладку и даём минимальную ширину. */
  .dt-wrap .dt-layout-row.dt-layout-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
  }
  .dt-wrap .dt-layout-row.dt-layout-table .dt-layout-cell {
    flex: 1 1 auto; min-width: max-content; padding: 0;
  }
  .dt-wrap table.dataTable {
    table-layout: auto;
    width: auto !important;
    min-width: 760px;
  }
  .dt-wrap table.dataTable thead th,
  .dt-wrap table.dataTable tbody td { padding: 10px 14px; font-size: 13px; }
}

@media (max-width: 720px) {
  .dt-wrap table.dataTable { min-width: 640px; }
  /* На самых узких экранах фильтры курсов — в одну колонку. */
  .dt-wrap.courses-dt .dt-filters { grid-template-columns: 1fr; }
}

/* ========== Модальные окна — единая адаптивная схема ==========
   Все модалки в проекте — это .modal-overlay > div[style*="position: relative"]
   с внутренней структурой: header (no-shrink) / body (flex:1; overflow:auto)
   / footer (no-shrink). На некоторых модалках между панелью и хедером/футером
   стоит <form style="display: contents"> — в продакшене это ломает flex-цепочку,
   поэтому форсим её во flex-контейнер на всех вьюпортах.

   Высота — через dvh (динамический viewport), чтобы URL-бар iOS Safari и
   панель навигации Android не «съедали» футер. */

/* Блокируем прокрутку body, пока открыта модалка (Alpine x-show чистит
   inline display, поэтому проверяем не-display:none). */
body:has(.modal-overlay:not([style*="display: none"])) {
  overflow: hidden;
  touch-action: none;
}

.modal-overlay { overscroll-behavior: contain; touch-action: auto; }
.modal-overlay > div[style*="position: relative"] { touch-action: auto; }

/* Панель модалки — общие правила для всех вьюпортов.
   Перебиваем inline max-height: 90vh на dvh-вариант. Также форсим flex-column
   через !important: иначе на десктопе Alpine x-transition при показе подменяет
   inline display: flex на display: block, и flex-цепочка к телу/футеру рвётся —
   контент перестаёт ездить, кнопки уезжают за viewport. На мобиле этого бага
   не было только потому, что в @media (max-width: 640px) ниже уже стоит
   display: flex !important. Поднимаем правило в общую секцию. */
.modal-overlay > div[style*="position: relative"] {
  max-height: min(90dvh, calc(100dvh - 32px)) !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Форма с display:contents → принудительно делаем flex-контейнером,
   чтобы flex:1 у тела работал и футер не уезжал за viewport.
   Применяется на всех вьюпортах — фиксит низкие десктоп-окна. */
.modal-overlay > div[style*="position: relative"] > form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* Прокручиваемое тело модалки (по inline overflow: auto) — должно ужиматься
   в flex-контейнере, иначе на коротких экранах футер «уползает».
   ВАЖНО: селектор ограничен прямыми детьми панели/формы — иначе ловит
   внутренности TinyMCE и других сторонних виджетов, у которых тоже бывает
   inline overflow:auto, и ломает их вёрстку. */
.modal-overlay > div[style*="position: relative"] > div[style*="overflow: auto"],
.modal-overlay > div[style*="position: relative"] > div[style*="overflow:auto"],
.modal-overlay > div[style*="position: relative"] > form > div[style*="overflow: auto"],
.modal-overlay > div[style*="position: relative"] > form > div[style*="overflow:auto"] {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* TinyMCE внутри модалки — минимальные фиксы:
   1) редактор не распирает панель (ужимается в коротких окнах);
   2) выпадашки (меню форматов/ссылок и тулбар-«ещё») поверх модалки.
   Раскладку тулбара НЕ трогаем — её должен решать сам TinyMCE через
   toolbar_mode: 'sliding' / 'wrap', выставленный в init-конфиге. */
.modal-overlay .tox-tinymce {
  max-width: 100% !important;
  min-height: 0 !important;
  flex: 1 1 auto;
}
.modal-overlay .tox.tox-tinymce { border-radius: 8px; }
.modal-overlay .tox .tox-editor-container { min-height: 0; }
/* TinyMCE-овский контейнер всплывашек (.tox-tinymce-aux) мы программно
   переносим в <body> сразу после init редактора (см. setup() в init-конфиге).
   Здесь только z-index — он должен быть выше нашей .modal-overlay (200),
   чтобы диалог «Изображение» / «Таблица» / «Ссылка» рисовался поверх
   модалки описания вопроса. Дефолтный z-index из скина TinyMCE — 1300,
   но раньше в проекте он принудительно понижался до 1100 (вероятно,
   когда aux ещё лежал внутри модалки и его поднимали над её слоями);
   с переносом в body эта необходимость отпала, можно вернуть дефолт. */
.tox-tinymce-aux,
.tox-silver-sink { z-index: 1300 !important; }
/* Сам диалог и его бэкдроп. position:fixed; inset:0 — viewport-relative.
   touch-action: auto на iOS Safari снимает влияние body { touch-action:none },
   которое мы вешаем, пока открыта .modal-overlay — без этого тапы в полях
   диалога обрабатывались с заметными задержками. */
.tox-dialog-wrap,
.tox-dialog-wrap__backdrop,
.tox-dialog {
  touch-action: auto !important;
}
.tox-dialog-wrap { pointer-events: auto !important; }
body:has(.tox-dialog-wrap) .tox-dialog__body-content {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* TinyMCE — рамка/тень соответствуют теме. Сам редактор грузится с
   oxide-dark скином + content_css 'dark' на тёмной теме (см. init),
   здесь только обрамляющие пиксели, которые скин не контролирует. */
html[data-theme="dark"] .tox.tox-tinymce {
  border-color: var(--border) !important;
}
html[data-theme="dark"] .tox-tinymce-aux,
html[data-theme="dark"] .tox-silver-sink {
  /* всплывающие меню/тулбары — тень мягче на тёмной теме */
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .4));
}

/* Flatpickr (календарь дат) — над всеми модалками. И ограничиваем ширину
   на мобильном, чтобы 1-месячная сетка влезала в экран и не уезжала за
   правый край. Перевод на 1 месяц задаётся уже через showMonths в JS. */
.flatpickr-calendar {
  z-index: 1001 !important;
  /* flatpickr-вский дефолтный `transition: all 0.3s` приводит к
     визуальному «прыжку» от дефолтной координаты к нашей пересчитанной
     (см. window.placeFlatpickrAboveInput в app.js). Оставляем переход
     только на прозрачность для аккуратного fade-in/out. */
  transition: opacity .12s ease-out !important;
  animation: none !important;
}
@media (max-width: 720px) {
  /* На мобильном «отрываем» календарь от поля ввода и центрируем по
     viewport как мини-модалку — иначе внутри модалки редактирования
     пользователя календарь либо уезжал за пределы, либо обрезался
     внутренним скроллом. position:fixed нужен с !important — flatpickr
     перетирает top/left инлайн-стилями. transform тоже с !important —
     иначе flatpickr-вский transition: all 0.3s анимирует наш «центр»
     от его дефолтной координаты, и календарь визуально «прыгает».
     Сам transition заглушаем для гарантии. */
  .flatpickr-calendar.open {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 32px);
    box-sizing: border-box;
    overflow: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
    transition: opacity .12s ease-out !important;
    animation: none !important;
  }
  /* Перед открытием полностью прячем — чтобы дефолтное «лежит в (0,0)»
     состояние не успело промелькнуть кадром. */
  .flatpickr-calendar:not(.open) {
    visibility: hidden !important;
    opacity: 0 !important;
  }
  /* Полупрозрачный бэкдроп под календарём — чтобы было понятно,
     что это плавающее окно, и чтобы тап мимо закрывал его (закрытие
     handle'ит сам flatpickr по клику вне). */
  .flatpickr-calendar.open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: -1;
    pointer-events: none;
  }
  /* Полоска-«стрелочка», указывающая на инпут, на мобильном центрировании
     не нужна и выглядит мусором. */
  .flatpickr-calendar.arrowTop:before,
  .flatpickr-calendar.arrowTop:after,
  .flatpickr-calendar.arrowBottom:before,
  .flatpickr-calendar.arrowBottom:after {
    display: none !important;
  }
  .flatpickr-calendar.rangeMode .flatpickr-days,
  .flatpickr-calendar.rangeMode .dayContainer {
    width: 100%;
    min-width: 0;
  }
  .flatpickr-days { width: 100%; }
  .flatpickr-days .dayContainer {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* TomSelect — выпадающий список с dropdownParent:'body' должен быть выше
   модалки (.modal-overlay z-index:200 / .top:210) и принимать касания. */
.ts-dropdown { z-index: 1000 !important; touch-action: auto; }
/* Single-select: убрать мигающую каретку в скрытом контрольном <input>. */
.ts-wrapper.single .ts-control input { caret-color: transparent; }

/* Tom-Select по умолчанию хардкодит белый фон у контрола и выпадашки —
   на тёмной теме это даёт «белые селекты». Перекрашиваем через переменные. */
.ts-wrapper .ts-control {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.ts-wrapper.focus .ts-control,
.ts-wrapper .ts-control:hover { border-color: var(--border-strong); }
.ts-wrapper .ts-control > input { color: var(--ink); }
.ts-wrapper .ts-control > input::placeholder { color: var(--ink-4); }
.ts-wrapper.single .ts-control,
.ts-wrapper.full .ts-control { background-color: var(--surface); }
.ts-wrapper.disabled .ts-control { background-color: var(--surface-2); color: var(--ink-3); }
/* В вендорном tom-select-2.3.1.css есть правило:
     .ts-control, .ts-wrapper.single.input-active .ts-control { background: #fff; }
   При клике на single-select Tom-Select добавляет класс .input-active и фон
   контрола превращается в белый — в тёмной теме светлое выбранное значение
   становится нечитаемым на белом фоне («значение становится белым»). Бьём
   по той же связке селекторов с !important. focus / dropdown-active покрываем
   за компанию, т.к. вендор там подменяет цвет тем же способом. */
.ts-control,
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  background: var(--surface) !important;
  background-color: var(--surface) !important;
  color: var(--ink) !important;
}
/* Выбранный .item внутри single-select не имеет своего цвета в вендоре —
   наследуется от .ts-control. На случай если кто-то по дороге переопределит
   color на контроле, фиксируем явно цвет «таблетки» выбранного значения. */
.ts-wrapper .ts-control .item { color: var(--ink) !important; }
.ts-wrapper.disabled .ts-control .item { color: var(--ink-3) !important; }
/* === Tom-Select dropdown ===
   Вендорная таблица tom-select-2.3.1.css хардкодит белый #fff и
   #303030 в .ts-dropdown / .option / .active / .dropdown-content и т. п.
   На тёмной теме это даёт «всё белое — нельзя прочитать». Дублируем
   правила с !important и токенами проекта, для всех состояний. */
.ts-dropdown,
.ts-dropdown .dropdown-content {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--ink) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
}
.ts-dropdown .option,
.ts-dropdown .optgroup-header,
.ts-dropdown .no-results,
.ts-dropdown .create {
  color: var(--ink) !important;
  background: transparent !important;
}
.ts-dropdown .optgroup-header {
  background: var(--surface) !important;
  color: var(--ink-3) !important;
  font-weight: 600;
}
/* Hover/keyboard-active — единая подсветка через token */
.ts-dropdown .option:hover,
.ts-dropdown .option.active,
.ts-dropdown .active {
  background: color-mix(in oklab, var(--ink) 10%, var(--surface)) !important;
  color: var(--ink) !important;
}
/* Уже выбранный вариант в открытой выпадашке */
.ts-dropdown .option.selected,
.ts-dropdown .option[aria-selected="true"] {
  background: color-mix(in oklab, var(--ink) 16%, var(--surface)) !important;
  color: var(--ink) !important;
}
.ts-dropdown [data-selectable] .highlight {
  background: color-mix(in oklab, var(--info) 25%, transparent) !important;
  color: var(--ink) !important;
}
.ts-dropdown .no-results,
.ts-dropdown .create {
  color: var(--ink-3) !important;
  font-style: italic;
}
.ts-wrapper.multi .ts-control > div {
  background: var(--surface-2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--border) !important;
}
.ts-wrapper.multi .ts-control > div.active {
  background: color-mix(in oklab, var(--ink) 12%, var(--surface)) !important;
  color: var(--ink) !important;
}
/* Кнопка ✕ в multi-chip — вендор красит чёрным */
.ts-wrapper.multi .ts-control > div .remove {
  border-left-color: var(--border) !important;
  color: var(--ink-2) !important;
}
.ts-wrapper.multi .ts-control > div .remove:hover {
  background: color-mix(in oklab, var(--bad) 25%, transparent) !important;
  color: var(--ink) !important;
}

/* Нативный <select class="input"> (data-no-ts). Без appearance:none браузеры
   рисуют системную «таблетку», игнорируя background, и на тёмной теме контрол
   остаётся белым со светлым выбранным значением, хотя выпадающие <option>
   уже подхватывают color-scheme:dark. Принудительно убираем системный chrome
   и подкладываем собственный chevron. */
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2376716a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='1,1.5 6,6.5 11,1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
select.input::-ms-expand { display: none; }
/* Options раскрытого нативного списка — некоторые движки игнорируют
   color-scheme и оставляют белый фон. Дублируем явно. */
html[data-theme="dark"] select.input option {
  background: var(--surface);
  color: var(--ink);
}

/* Раскрывающийся список Tom-Select на мобильных — крупнее тап-зона.
   Дефолтный padding 5px 8px на тач-устройстве слишком мелок, по строкам
   тяжело попасть пальцем. */
@media (max-width: 720px) {
  .ts-dropdown .option,
  .ts-dropdown .optgroup-header,
  .ts-dropdown .no-results,
  .ts-dropdown .create {
    padding: 14px 16px !important;
    font-size: 15px;
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  .ts-dropdown .optgroup-header { min-height: 36px; }
}

/* ===== DataTables — крупный читаемый индикатор загрузки =====
   Дефолтная подпись «Загрузка…» рисуется мелким текстом возле тулбара
   и теряется глазом. Заменяем на крупную центрированную карточку поверх
   таблицы. CSS-класс is-loading на .dt-wrap тоглит глобальный обработчик
   init.dt в public/js/datatables-ru.js — overlay подключается ко всем
   .dt-wrap проекта автоматически. */
.dt-wrap { position: relative; }
.dt-wrap .dt-processing { display: none !important; }
.dt-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 84px;
  pointer-events: none;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.dt-wrap.is-loading > .dt-loading-overlay { display: flex; }
.dt-loading-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  pointer-events: auto;
}
.dt-loading-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--ink) 20%, transparent);
  border-top-color: var(--ink);
  animation: dt-loading-spin .8s linear infinite;
}
@keyframes dt-loading-spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .dt-loading-overlay { padding-top: 64px; }
  .dt-loading-card { font-size: 14px; padding: 12px 20px; }
}

/* ----- Планшет: 641–1024px — обычная центрированная карточка, не fullscreen.
   Только уменьшаем внешний паддинг overlay'а, чтобы дать чуть больше места. */
@media (min-width: 641px) and (max-width: 1024px) {
  .modal-overlay { padding: 16px; }
}

/* ----- Мобильный: ≤640px — карточка с полями от краёв (не fullscreen),
   скруглёнными углами и safe-area для нижней зоны (home-indicator iPhone).
   Это даёт визуальный «отступ» между кнопками/титлом и краями экрана,
   о котором просили. */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 12px;
    /* iOS: учитываем safe-area-inset, чтобы карточка не подпирала home-indicator
       и notch; стандартный padding всё равно работает поверх. */
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .modal-overlay > div[style*="position: relative"] {
    width: 100% !important;
    max-width: 100% !important;
    /* Высота — оставшийся динамический viewport минус наши паддинги. */
    max-height: calc(100dvh - 24px) !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Уменьшаем внутренние паддинги шапки/футера/тела на узких экранах. */
  .modal-overlay > div[style*="position: relative"] > div[style*="border-bottom"],
  .modal-overlay > div[style*="position: relative"] > form > div[style*="border-bottom"] {
    padding: 16px 18px !important;
  }
  .modal-overlay > div[style*="position: relative"] > div[style*="border-top"],
  .modal-overlay > div[style*="position: relative"] > form > div[style*="border-top"] {
    padding: 12px 18px !important;
  }
  .modal-overlay [style*="overflow: auto"] {
    padding: 16px 18px !important;
  }

  /* Двух-/трёхколоночные сетки внутри модалки — в одну колонку. */
  .modal-overlay .split-2,
  .modal-overlay .split-3,
  .modal-overlay .split-4 { grid-template-columns: 1fr !important; }
}

/* ============================================================
   Избранное (favorites) — кнопка-звезда + страница
   ============================================================
   Кнопка <x-fav-btn> приклеивается к карточкам курсов и кнопкам.
   Два варианта:
   - .fav-btn--overlay   — поверх .cat-tile / .sched-tile в правом верхнем
                            углу. Абсолютно позиционируется.
   - .fav-btn--inline    — обычная inline-кнопка рядом с заголовком
                            (например, на странице курса /courses/{id}).

   Состояния:
   - default        — outline: stroke есть, fill отсутствует
   - .is-active     — в избранном: заливка золотисто-янтарным цветом
   - hover          — лёгкое поднятие/затемнение фона
   - tap-target     — на тач-устройствах не менее 44×44 (рекомендации
                       Apple HIG / Material Touch Targets).

   Звезда отрисована в [components/icon.blade.php] как 'star'
   (polygon без fill — fill включается классом .is-active ниже). */
.fav-btn {
  /* Базовая кнопка — сама по себе круглая, без фона. Цвет — приглушённый,
     чтобы не отвлекать от контента карточки. */
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .08s ease;
  flex-shrink: 0;
  padding: 0;
}
.fav-btn svg {
  /* По умолчанию — обводка. fill включается у .is-active ниже. */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .15s ease, fill .15s ease, stroke .15s ease;
}
.fav-btn:hover { background: color-mix(in oklab, var(--ink) 6%, transparent); color: var(--ink-3); }
.fav-btn:active { transform: scale(0.92); }
.fav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--info) 22%, transparent);
}
/* Активное состояние — звезда заполнена «янтарным» цветом из палитры,
   подходит и под светлую, и под тёмную тему. */
.fav-btn.is-active {
  color: oklch(0.72 0.14 75);
}
.fav-btn.is-active svg {
  fill: currentColor;
  stroke: currentColor;
}
.fav-btn.is-active:hover { background: color-mix(in oklab, oklch(0.72 0.14 75) 14%, transparent); }
.fav-btn[data-fav-pending="1"] {
  /* Лёгкий «мигалка»-эффект пока летит запрос — едва заметный,
     чтобы пользователь не нажимал многократно. */
  opacity: 0.7;
  pointer-events: none;
}

/* Overlay-вариант — поверх карточки. */
.fav-btn--overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  /* Лёгкий бэкграунд для контраста с подложкой карточки. */
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.fav-btn--overlay:hover {
  background: color-mix(in oklab, var(--surface) 92%, transparent);
}
/* Родительская карточка должна быть relative — задаём осторожно, не
   ломая существующую сетку. .cat-tile / .sched-tile уже могут быть
   relative; если нет — этот селектор гарантирует. */
.cat-tile, .sched-tile, .sched-row { position: relative; }

/* Inline-вариант — обычная иконочная кнопка в потоке (в заголовке курса,
   в строке списка .cat-row). На мобильных немного крупнее, чтобы было
   удобно попасть пальцем. */
.fav-btn--inline {
  position: relative;
  margin-right: 2px;
}
/* В .cat-row у нас flex-строка; ставим звезду слева от номера. */
.cat-row > .fav-btn--inline {
  margin-right: 6px;
  align-self: center;
}
/* Уменьшенный inline-вариант — для таблицы «Управление курсами», где
   стандартные 36×36 раздували строку. */
.fav-btn--xs { width: 26px; height: 26px; }
.fav-btn--xs svg { width: 14px; height: 14px; }

/* Кнопка фильтра «Только избранные» в шапке таблицы. В выключенном
   виде — обычный ghost-btn; включённой подсвечиваем тёплым цветом (тем
   же, что у заполненной звезды), чтобы было сразу понятно, что фильтр
   активен. SVG заполняется через currentColor. */
.dt-fav-filter { display: inline-flex; align-items: center; gap: 6px; }
.dt-fav-filter.is-active {
  color: oklch(0.72 0.14 75);
  border-color: color-mix(in oklab, oklch(0.72 0.14 75) 45%, var(--border));
  background: color-mix(in oklab, oklch(0.72 0.14 75) 10%, var(--surface));
}
.dt-fav-filter.is-active svg { fill: currentColor; stroke: currentColor; }
/* В .sched-row номер выезжает абсолютно (см. .sched-row-num). Чтобы
   звёздочка не наезжала на полоску, прижимаем её к правому верхнему
   углу строки. */
.sched-row > .fav-btn--inline {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  background: color-mix(in oklab, var(--surface) 70%, transparent);
}

/* Карточка на странице /favorites — плавное «удаление» после снятия
   звезды (см. favorites.js: класс .is-removed на 200ms перед remove). */
[data-fav-card] {
  transition: opacity .18s ease, transform .18s ease;
}
[data-fav-card].is-removed {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

/* Мобила — увеличиваем тап-таргет до 44×44 (мин. рекомендация HIG). */
@media (hover: none) and (pointer: coarse) {
  .fav-btn { width: 44px; height: 44px; }
  .fav-btn--overlay { top: 6px; right: 6px; }
  .sched-row > .fav-btn--inline { top: 6px; right: 6px; }
}

/* ---------- Кастомные чекбоксы ----------
   Применяются ко всем <input type="checkbox"> в проекте.
   Чтобы вернуть нативный вид (например, в служебном UI), добавьте класс
   .checkbox-native на сам input или на родителя. */
input[type="checkbox"]:not(.checkbox-native):not(.checkbox-native *) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  vertical-align: middle;
  margin: 0;
}
input[type="checkbox"]:not(.checkbox-native):hover {
  border-color: color-mix(in oklab, var(--ink) 35%, var(--border));
}
input[type="checkbox"]:not(.checkbox-native):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ink) 18%, transparent);
}
input[type="checkbox"]:not(.checkbox-native):checked {
  background: var(--ink);
  border-color: var(--ink);
}
input[type="checkbox"]:not(.checkbox-native):checked::after {
  content: '';
  width: 12px;
  height: 7px;
  border-left: 2px solid var(--surface);
  border-bottom: 2px solid var(--surface);
  transform: rotate(-45deg) translate(1px, -1px);
}
input[type="checkbox"]:not(.checkbox-native):indeterminate {
  background: var(--ink);
  border-color: var(--ink);
}
input[type="checkbox"]:not(.checkbox-native):indeterminate::after {
  content: '';
  width: 12px;
  height: 2px;
  background: var(--surface);
  border-radius: 1px;
}
input[type="checkbox"]:not(.checkbox-native):disabled {
  opacity: .5;
  cursor: not-allowed;
}


/* === Reader page actions (Скачать / Закрыть) === */
.reader-actions { margin-left: auto; }
@media (max-width: 1023px) {
  .reader-actions { width: 100%; justify-content: flex-end; }
}

/* === Tippy: переводы строк в подсказках === */
.tippy-box .tippy-content { white-space: pre-line; }

/* === Раздел «Расписание»: фото, чипы курсов, прогресс === */
.cadet-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap); }
@media (max-width: 1100px) {
  .cadet-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .cadet-stats { grid-template-columns: 1fr; }
}
.stat-hint {
  margin-top: 6px;
  font-size: 12px; line-height: 1.35;
  color: var(--ink-3);
}
.stat-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  color: var(--ink-3);
  cursor: help;
  transition: color .12s, background .12s;
}
.stat-tip:hover, .stat-tip:focus-visible {
  color: var(--ink); background: var(--surface-2);
  outline: none;
}

.dt-wrap table.dataTable tbody td.cdt-photo-cell { padding: 8px 12px; }
.dt-wrap table.dataTable tbody td.cdt-row-num {
  font-size: 28px; color: var(--ink-4); font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.cdt-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.cdt-name { font-weight: 600; line-height: 1.25; }
.cdt-login {
  margin-top: 2px;
  font-size: 12px; color: var(--ink-3);
  font-family: 'IBM Plex Mono', monospace;
}

.ccchip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 3px;
  max-width: 220px;
}
.ccchip {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 4px 4px; border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink-4);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: default;
}
.ccchip-blue {
  background: color-mix(in oklab, var(--info) 12%, var(--surface));
  color: var(--info);
  border-color: color-mix(in oklab, var(--info) 30%, var(--border));
}
.ccchip-yellow {
  background: color-mix(in oklab, var(--warn) 14%, var(--surface));
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
}
.ccchip-red {
  background: color-mix(in oklab, var(--bad) 14%, var(--surface));
  color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
}
.ccchip-gray {
  background: var(--surface-2);
  color: var(--ink-3);
}
.ccchip-assigned { font-weight: 600; }
.ccchip-as-scheduled {
  background: color-mix(in oklab, var(--info) 12%, var(--surface));
  color: var(--info);
  border-color: color-mix(in oklab, var(--info) 30%, var(--border));
}
.ccchip-as-in_progress {
  background: color-mix(in oklab, var(--warn) 14%, var(--surface));
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
}
.ccchip-as-finished {
  background: color-mix(in oklab, var(--good) 14%, var(--surface));
  color: var(--good);
  border-color: color-mix(in oklab, var(--good) 35%, var(--border));
}
.ccchip-as-graded {
  background: color-mix(in oklab, var(--good) 18%, var(--surface));
  color: var(--good);
  border-color: color-mix(in oklab, var(--good) 40%, var(--border));
}

.cdt-ring { position: relative; width: 44px; height: 44px; display: inline-grid; place-items: center; }
.cdt-ring-val {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.dt-wrap table.dataTable tbody td.cdt-progress-cell { text-align: center; }

/* === Админский раздел «Логи»: фильтры === */
/* Базовая раскладка фильтров: горизонтальная строка на десктопе,
   стэкаются в 2×2 сетку на планшете и в один столбец на телефоне.
   Кнопка «Сбросить» прижимается к правому краю и не уезжает за экран. */
.logs-filterbar {
  display: grid;
  grid-template-columns: 1fr 1fr 280px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.logs-filter-action,
.logs-filter-user { min-width: 0; }
.logs-filter-range { cursor: default; }
.logs-filter-reset { white-space: nowrap; justify-self: end; }
@media (max-width: 980px) {
  .logs-filterbar {
    grid-template-columns: 1fr 1fr;
  }
  .logs-filter-range { grid-column: 1 / -1; }
  .logs-filter-reset { grid-column: 1 / -1; justify-self: stretch; text-align: center; justify-content: center; }
}
@media (max-width: 540px) {
  .logs-filterbar { grid-template-columns: 1fr; }
  .logs-filter-range,
  .logs-filter-reset { grid-column: auto; }
}

/* === Админский раздел «Экзамены»: datatable аттестаций === */

.att-filterbar {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.att-filterbar-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3);
  flex: 0 0 auto;
}
/* На телефоне 5 кнопок статуса не вмещаются в строку. Делаем
   горизонтальный скролл с прячемой полосой и компактнее кнопки. */
@media (max-width: 820px) {
  .att-filterbar {
    gap: 8px;
    padding: 10px 12px;
    flex-wrap: nowrap;
  }
  .att-filterbar > .seg {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
  .att-filterbar > .seg::-webkit-scrollbar { display: none; }
  .att-filterbar > .seg button {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 12.5px;
    white-space: nowrap;
  }
}

.dt-wrap table.dataTable tbody td.att-num {
  font-weight: 500; color: var(--ink-3);
}
.att-course-title { font-weight: 500; line-height: 1.25; color: var(--ink); }
.att-course-sub   { margin-top: 2px; color: var(--ink-4); }
.att-student-name { font-weight: 500; line-height: 1.25; color: var(--ink); }
.att-student-login { margin-top: 2px; color: var(--ink-4); }

.dt-wrap table.dataTable tbody td.att-report,
.dt-wrap table.dataTable tbody td.att-grade-cell { text-align: center; }

/* Колонка «Оценка» — не обрезаем плитку: пилюля имеет nowrap, а у ячейки
   глобальный ellipsis из .dt-wrap td пересекался с padding'ом плитки. */
.dt-wrap table.dataTable tbody td.att-grade-cell {
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Курс — название с ellipsis (узкая колонка), полное название
   показывается в tippy-тултипе. */
.att-course-trunc {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
/* Краткое наименование курса в столбце «Курс» — точечный hover-тултип
   с полным названием. Подчёркиваем точечной линией, чтобы было понятно,
   что под подписью есть подсказка. */
.att-course-short {
  display: inline-block;
  max-width: 100%;
  font-weight: 500; color: var(--ink);
  cursor: help;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  vertical-align: middle;
  border-bottom: 1px dotted color-mix(in oklab, var(--ink-3) 50%, transparent);
}
.att-course-short:hover { color: var(--info); }

.att-grade {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 96px; padding: 6px 12px;
  font-size: 13px; font-weight: 500;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink-3);
  white-space: nowrap;
}

/* Иконочная кнопка «скачать отчёт» в колонке DataTable. Открывает
   popover-меню (см. AttestationsIndex._openReportMenu) с выбором PDF/XLSX.
   Компактный размер 32×32, чтобы влезать в узкие колонки без переноса. */
.att-report-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  font-family: inherit;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .06s;
}
.att-report-btn:hover {
  background: color-mix(in oklab, var(--info) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 40%, var(--border));
  color: var(--info);
}
.att-report-btn:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
.att-report-btn:active { transform: translateY(1px); }
.att-report-btn[aria-expanded="true"] {
  background: color-mix(in oklab, var(--info) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 50%, var(--border));
  color: var(--info);
}

/* Выпадающее меню XLSX/PDF — собственный popover, прикреплённый к <body>
   (см. AttestationsIndex._initReportPopover). Не используем tippy, чтобы
   избежать конфликта с делегированными hover-тултипами. */
.att-report-pop {
  position: absolute;
  z-index: 9000;
  display: flex; flex-direction: column;
  min-width: 240px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.14),
              0 4px 12px rgba(0,0,0,.06);
}
.att-report-pop[hidden] { display: none; }
.att-report-popitem {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  text-decoration: none; color: var(--ink);
  border-radius: 8px;
  transition: background .12s;
}
.att-report-popitem:hover {
  background: var(--surface-2);
}
.att-report-popitem:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}
.att-report-popicon {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  width: 38px; height: 28px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}
.att-report-popicon--xlsx { background: #1f7a3d; }
.att-report-popicon--pdf  { background: #b3261e; }
.att-report-popitem-text {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.att-report-popitem-title {
  font-size: 13px; font-weight: 500; line-height: 1.25; color: var(--ink);
}
.att-report-popitem-sub {
  font-size: 11.5px; color: var(--ink-3); line-height: 1.25;
}
/* Кликабельная плитка — кнопка-пилюля. Состояния hover/focus подчёркивают
   интерактивность; цвет рамки/фона остаётся от модификатора att-grade--*. */
button.att-grade,
.att-grade-btn {
  cursor: pointer;
  font-family: inherit;
  transition: filter .12s, transform .12s, box-shadow .12s;
}
button.att-grade:hover,
.att-grade-btn:hover { filter: brightness(0.96); transform: translateY(-1px); box-shadow: 0 4px 12px -8px rgba(0,0,0,.25); }
button.att-grade:focus-visible,
.att-grade-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.att-grade:active,
.att-grade-btn:active { transform: translateY(0); }
.att-grade--good {
  color: var(--good);
  background: color-mix(in oklab, var(--good) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--good) 35%, var(--border));
}
.att-grade--info {
  color: var(--info);
  background: color-mix(in oklab, var(--info) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 30%, var(--border));
}
.att-grade--warn {
  color: var(--warn);
  background: color-mix(in oklab, var(--warn) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
}
.att-grade--bad {
  color: var(--bad);
  background: color-mix(in oklab, var(--bad) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
}
.att-grade--gray {
  color: var(--ink-3);
  background: var(--surface-2);
}

/* === «Расписание» preподa/админa: быстрые фильтры-плитки ===
   Та же сегментная панель, что у студента (.sched-seg), но с цветовым
   акцентом по типу проблемы — преподу с первого взгляда понятно, какая
   плитка отвечает за «срочное» / «ждёт оценки» / «нет даты». */
.cdt-seg button {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  border-left: 3px solid transparent;
  border-radius: 8px;
}
.cdt-seg-count {
  font-size: 11px; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
  font-weight: 500;
}
.cdt-seg-btn.on .cdt-seg-count {
  background: color-mix(in oklab, var(--ink) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--ink) 25%, var(--border));
  color: var(--ink);
}
/* Цветовая маркировка кнопок-фильтров: красная — срочно, жёлтая — скоро,
   зелёная — ждут оценки (это положительная очередь действий препода),
   синяя — назначенные, серая — без даты, фиолетовая — идёт экзамен.
   Border-left даёт «акцентную полоску» без перекраски всей кнопки —
   когда фильтр активен (.on), полоска становится толще, кнопка
   подкрашивается мягким фоном того же тона. */
.cdt-seg-btn--awaiting   { border-left-color: color-mix(in oklab, var(--good) 60%, transparent); }
.cdt-seg-btn--in_progress { border-left-color: color-mix(in oklab, #a78bfa 70%, transparent); }
.cdt-seg-btn--scheduled  { border-left-color: color-mix(in oklab, var(--info) 60%, transparent); }
.cdt-seg-btn--danger     { border-left-color: color-mix(in oklab, var(--bad) 70%, transparent); }
.cdt-seg-btn--warn       { border-left-color: color-mix(in oklab, var(--warn) 70%, transparent); }
.cdt-seg-btn--no_date    { border-left-color: var(--border-strong); }

.cdt-seg-btn.on.cdt-seg-btn--awaiting   { background: color-mix(in oklab, var(--good) 12%, var(--surface)) !important; }
.cdt-seg-btn.on.cdt-seg-btn--in_progress { background: color-mix(in oklab, #a78bfa 14%, var(--surface)) !important; }
.cdt-seg-btn.on.cdt-seg-btn--scheduled  { background: color-mix(in oklab, var(--info) 12%, var(--surface)) !important; }
.cdt-seg-btn.on.cdt-seg-btn--danger     { background: color-mix(in oklab, var(--bad) 12%, var(--surface)) !important; }
.cdt-seg-btn.on.cdt-seg-btn--warn       { background: color-mix(in oklab, var(--warn) 14%, var(--surface)) !important; }
.cdt-seg-btn.on.cdt-seg-btn--no_date    { background: var(--surface-2) !important; }

/* На телефоне/планшете — горизонтальный скролл, как у .sched-seg */
@media (max-width: 820px) {
  .filterbar .cdt-seg {
    display: flex;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filterbar .cdt-seg::-webkit-scrollbar { display: none; }
  .filterbar .cdt-seg button {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 12.5px;
  }
}

/* === Студенческое «Расписание»: список курсов === */

.sched-seg button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sched-seg-count {
  font-size: 11px; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
  font-weight: 500;
}
.sched-seg button.on .sched-seg-count {
  background: color-mix(in oklab, var(--ink) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--ink) 25%, var(--border));
  color: var(--ink);
}

/* На телефоне/планшете сегментный фильтр (Все/Срочно/Скоро срок/...) не
   вмещается в строку — даём ему горизонтальный скролл вместо распирания
   экрана, ужимаем padding и шрифт. */
@media (max-width: 820px) {
  .filterbar .sched-seg,
  .filterbar > .seg {
    display: flex;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filterbar .sched-seg::-webkit-scrollbar,
  .filterbar > .seg::-webkit-scrollbar { display: none; }
  .filterbar .sched-seg button,
  .filterbar > .seg button {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 12.5px;
  }
  .filterbar .search { max-width: none; width: 100%; }
}

.sched-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 18px;
  padding: 16px 20px 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.sched-row:last-child { border-bottom: 0; }
.sched-row:hover { background: color-mix(in oklab, var(--surface-2) 55%, transparent); }

.sched-row-strip {
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0;
  background: var(--ink-4);
}
.sched-row--red    .sched-row-strip { background: var(--bad); }
.sched-row--yellow .sched-row-strip { background: var(--warn); }
.sched-row--blue   .sched-row-strip { background: var(--info); }
.sched-row--gray   .sched-row-strip { background: color-mix(in oklab, var(--ink-4) 50%, var(--surface-2)); }

/* Курс с активным назначенным экзаменом — мягкая жёлтая подсветка строки
   и более выраженная вертикальная полоса слева. Поверх любого статуса. */
.sched-row--has-exam {
  background: color-mix(in oklab, var(--warn) 6%, var(--surface));
}
.sched-row--has-exam:hover {
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
}
.sched-row--has-exam .sched-row-strip {
  width: 5px;
  background: var(--warn);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--warn) 35%, transparent);
}
.sched-row-meta {
  gap: 8px; margin-bottom: 4px; flex-wrap: wrap; align-items: center;
}
.sched-row-title {
  margin-top: 2px;
}

/* Плитка с активным назначенным экзаменом */
.sched-tile--has-exam {
  border-color: color-mix(in oklab, var(--warn) 45%, var(--border)) !important;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--warn) 7%, var(--surface)) 0%,
    var(--surface) 70%) !important;
}
.sched-tile--has-exam:hover {
  border-color: var(--warn) !important;
  box-shadow: 0 10px 28px color-mix(in oklab, var(--warn) 18%, transparent),
              0 2px 6px rgba(0,0,0,.05);
}

.sched-row-num {
  font-size: 28px; color: var(--ink-4); font-weight: 500;
  letter-spacing: -0.02em; min-width: 36px; text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto;
}
.sched-row-info { flex: 1; min-width: 0; }

.sched-row-stats {
  display: flex; gap: 22px; flex-shrink: 0;
  align-items: flex-start;
}
.sched-cell { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sched-cell-val { font-weight: 500; font-size: 13.5px; line-height: 1.25; }
/* Колоночные ширины — чтобы значения «как в таблице» вставали в один столбец
   по всей сетке строк (вне зависимости от длины наименования). */
.sched-cell--topics  { width: 64px; }
.sched-cell--studied { width: 170px; }
.sched-cell--period  { width: 150px; }
.sched-cell--last    { width: 130px; }
.sched-cell--due     { width: 140px; }

.sched-bar {
  margin-top: 4px;
  width: 140px; height: 4px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.sched-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, color-mix(in oklab, var(--ink) 75%, transparent), var(--ink));
  border-radius: 999px;
}

.sched-due {
  font-weight: 600; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
  /* На узких экранах flex-родитель не должен ужимать пилюлю — иначе текст
     «Просрочено 860 дн.» вылезает за её цветную обводку. */
  flex-shrink: 0;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
}
.sched-due--red {
  color: var(--bad);
  background: color-mix(in oklab, var(--bad) 12%, var(--surface));
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
}
.sched-due--yellow {
  color: var(--warn);
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
}
.sched-due--blue {
  color: var(--info);
  background: color-mix(in oklab, var(--info) 12%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 30%, var(--border));
}
.sched-due--gray { color: var(--ink-3); }

@media (max-width: 1100px) {
  .sched-row { flex-wrap: wrap; }
  .sched-row-stats { flex-wrap: wrap; gap: 14px 22px; width: 100%; padding-left: 36px; }
}
@media (max-width: 640px) {
  .sched-row { padding: 14px 14px 14px 18px; gap: 12px; }
  .sched-row-num { font-size: 22px; min-width: 28px; }
  .sched-bar { width: 100%; }
}

/* Легенда чипов над таблицей «Расписание» */
.cdt-legend {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px; color: var(--ink-2);
}
.cdt-legend-group {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 14px;
}
.cdt-legend-label {
  font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  font-size: 11px;
  margin-right: 4px;
}
.cdt-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.cdt-legend-item .ccchip {
  cursor: default; min-width: 0; padding: 3px 8px;
  font-size: 10px;
}

/* === Студенческая страница «Мои экзамены» === */

/* Pill-индикатор количества активных назначений в шапке */
.se-pending-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: color-mix(in oklab, var(--warn) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--border));
  border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
}
.se-pending-pill-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--warn) 22%, transparent);
}

/* Пустое состояние «нет активных назначений» */
.se-empty-block {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 20px; margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink-2);
}
.se-empty-block > svg { color: var(--good); flex: 0 0 auto; margin-top: 1px; }
.se-empty-title { font-weight: 600; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.se-empty-text  { font-size: 13px; color: var(--ink-3); }

/* Карточка активного назначения */
.se-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(20,20,18,.02);
}
.se-card-head {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--surface-2) 80%, var(--surface)) 0%,
    var(--surface) 100%);
  border-bottom: 1px solid var(--border);
}
.se-card-headline { min-width: 0; flex: 1 1 auto; }
.se-card-eyebrow {
  font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 4px;
}
.se-card-title {
  font-family: 'Fraunces', serif;
  font-size: 20px; font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.se-card-actions { flex: 0 0 auto; }

/* Span-обёртка вокруг disabled-кнопки «Завершить» — нужна tippy.js
   (на disabled-кнопках hover-события не возникают). Сама обёртка не
   disabled, так что hover ловится; тултип-контент висит на ней. */
.btn-finish-wrap { display: inline-flex; }

/* Кнопка «Завершить» */
.btn.btn-finish {
  background: var(--bad); border-color: var(--bad); color: #fff;
  padding: 9px 20px; font-weight: 600; min-width: 140px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .12s, transform .06s;
}
.btn.btn-finish:hover:not(:disabled) { filter: brightness(1.05); cursor: pointer; }
.btn.btn-finish:active:not(:disabled) { transform: translateY(1px); }
.btn.btn-finish:disabled {
  opacity: 1; cursor: not-allowed;
  background: var(--surface-2); color: var(--ink-3); border-color: var(--border);
}

/* Метаинформация по аттестации — три ячейки в строку */
.se-meta {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0; margin: 0;
  border-bottom: 1px solid var(--border);
}
.se-meta-cell {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
}
.se-meta-cell:last-child { border-right: none; }
.se-meta-cell dt {
  font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 6px;
}
.se-meta-cell dd {
  margin: 0; font-size: 14px; color: var(--ink);
}

/* Список итоговых экзаменов */
.se-exams { list-style: none; padding: 0; margin: 0; }
.se-exam {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.se-exam:last-child { border-bottom: none; }
.se-exam:hover { background: color-mix(in oklab, var(--surface-2) 40%, transparent); }
.se-exam-main {
  display: flex; gap: 14px; align-items: center;
  flex: 1 1 auto; min-width: 0;
}
.se-exam-num {
  flex: 0 0 auto;
  font-size: 13px; font-weight: 600; color: var(--ink-3);
  min-width: 28px; text-align: right;
}
.se-exam-info { min-width: 0; flex: 1 1 auto; }
.se-exam-title {
  font-size: 14px; font-weight: 500; color: var(--ink);
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.se-exam-tags {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-3);
}
.se-exam-tags strong { color: var(--ink-2); font-weight: 500; }
.se-exam-action { flex: 0 0 auto; }

.se-card-empty {
  padding: 22px 20px;
  text-align: center;
  color: var(--ink-3); font-size: 13px;
  background: var(--surface-2);
}

@media (max-width: 720px) {
  .se-meta { grid-template-columns: 1fr; }
  .se-meta-cell { border-right: none; border-bottom: 1px solid var(--border); }
  .se-meta-cell:last-child { border-bottom: none; }
  .se-exam { flex-direction: column; align-items: flex-start; }
  .se-exam-action { margin-left: 40px; }
}

/* Разделитель «активные ↔ история» — типографическая линия с центральным
   лейблом. Усиливает чтение страницы как двух чётко разных секций. */
.se-section-divider {
  display: flex; align-items: center; gap: 16px;
  margin: 56px 0 28px;
  color: var(--ink-3);
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; font-weight: 600;
}
.se-section-divider::before,
.se-section-divider::after {
  content: ''; flex: 1 1 auto; height: 1px; background: var(--border);
}

/* История — заголовок + DataTable. Сама секция теперь обёрнута в мягкий
   surface-«панель» — визуально отделяет архив от живого списка вверху. */
.se-history-section {
  margin-top: 0;
  padding: 22px 24px 24px;
  background: color-mix(in oklab, var(--surface-2) 38%, var(--bg));
  border: 1px solid var(--border);
  border-radius: 14px;
}
.se-history-title {
  font-family: 'Fraunces', serif;
  font-size: 22px; font-weight: 500; letter-spacing: -0.01em;
  margin: 0;
}
.dt-wrap.student-exams-dt input.dt-input { min-width: 320px; }

/* Колонка «Курс» в истории экзаменов: показываем краткое наименование
   (или код курса), а полное название — в tippy-тултипе при наведении.
   Аккуратно жмём в одну строку с многоточием, чтобы колонка была узкой. */
.se-course-cell {
  display: inline-block;
  max-width: 100%;
  font-weight: 500;
  color: var(--ink);
  cursor: help;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  border-bottom: 1px dotted color-mix(in oklab, var(--ink-3) 50%, transparent);
}
.se-course-cell:hover { color: var(--info); }

/* Комментарий преподавателя — многострочный, ужимаем до 2 строк в ячейке
   с многоточием, полный текст — в тултипе. */
.se-comment-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
  max-width: 360px;
  cursor: help;
}

@media (max-width: 720px) {
  .se-section-divider { margin: 40px 0 20px; }
  .se-history-section { padding: 18px 16px 20px; }
}

/* Confirm-dialog для «Завершить экзамен» */
.se-confirm {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
}
.se-confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.se-confirm-text  { font-size: 13px; color: var(--ink-2); line-height: 1.5; margin-bottom: 16px; }
.se-confirm-foot  { display: flex; gap: 8px; justify-content: flex-end; }

/* === Toasts (правый верхний угол) === */
.cdt-toasts {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10000;
  pointer-events: none;
}
.cdt-toast {
  pointer-events: auto;
  min-width: 280px; max-width: 420px;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  animation: cdtToastIn .25s ease-out;
}
@keyframes cdtToastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.cdt-toast-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
  background: var(--ink-3);
}
.cdt-toast-dot--success { background: var(--good); }
.cdt-toast-dot--error   { background: var(--bad); }
.cdt-toast-dot--info    { background: var(--info); }
.cdt-toast-body { flex: 1; min-width: 0; }
.cdt-toast-title {
  font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--ink);
}
.cdt-toast-text {
  margin-top: 2px;
  font-size: 12px; color: var(--ink-3); line-height: 1.4;
}
.cdt-toast-close {
  appearance: none; background: transparent; border: 0;
  color: var(--ink-3); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 4px;
  flex-shrink: 0;
}
.cdt-toast-close:hover { color: var(--ink); }

/* === Глобальные тосты ($x-flash и window.TB.toast()) ===
   Стили вынесены сюда сознательно: компонент <x-flash /> рендерится
   только когда в сессии есть flash-сообщение, и его внутренний <style>
   тогда не попадает на страницу. Но window.TB.toast() из AJAX-обработчиков
   (модалки пользователей/курсов/материалов и т.д.) создаёт `.toast-stack`
   в любой момент — без этих стилей тост попадал бы в DOM невидимым
   (без position:fixed/фона), и пользователь думал, что «уведомлений нет». */
.toast-stack {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 48px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 14px 36px rgba(0, 0, 0, .14);
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink-1);
}
.toast__icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.toast__text {
    flex: 1;
    min-width: 0;
    color: var(--ink-1);
    word-wrap: break-word;
}
.toast__close { flex-shrink: 0; }
.toast--good {
    border-color: color-mix(in oklab, var(--good) 38%, var(--border));
    background: color-mix(in oklab, var(--good) 9%, var(--surface));
}
.toast--good .toast__icon {
    background: color-mix(in oklab, var(--good) 18%, transparent);
    color: var(--good);
}
.toast--warn {
    border-color: color-mix(in oklab, var(--warn) 38%, var(--border));
    background: color-mix(in oklab, var(--warn) 9%, var(--surface));
}
.toast--warn .toast__icon {
    background: color-mix(in oklab, var(--warn) 18%, transparent);
    color: var(--warn);
}
.toast--bad {
    border-color: color-mix(in oklab, var(--bad) 40%, var(--border));
    background: color-mix(in oklab, var(--bad) 8%, var(--surface));
}
.toast--bad .toast__icon {
    background: color-mix(in oklab, var(--bad) 18%, transparent);
    color: var(--bad);
}
.toast-enter { transition: transform .25s ease, opacity .25s ease; }
.toast-enter-start { opacity: 0; transform: translateX(16px); }
.toast-enter-end { opacity: 1; transform: translateX(0); }
.toast-leave { transition: transform .2s ease, opacity .2s ease; }
.toast-leave-start { opacity: 1; transform: translateX(0); }
.toast-leave-end { opacity: 0; transform: translateX(16px); }

/* === Виджет выставления оценки в модалке аттестации === */
.cdt-grade-bar {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--good) 8%, var(--surface));
}
.cdt-grade-bar-info { flex: 1; min-width: 0; }
.cdt-grade-bar-actions { flex: 0 0 auto; padding-top: 4px; }

.cdt-grade-options {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 10px;
}
.cdt-grade-pill {
  appearance: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font: inherit; font-weight: 600; font-size: 13px;
  color: var(--ink-2);
  transition: filter .12s, transform .06s, border-color .12s, background .12s;
}
.cdt-grade-pill:hover:not(:disabled) { filter: brightness(0.97); }
.cdt-grade-pill:active:not(:disabled) { transform: translateY(1px); }
.cdt-grade-pill:disabled { opacity: .55; cursor: not-allowed; }

.cdt-grade-pill--good { border-color: color-mix(in oklab, var(--good) 40%, var(--border)); color: var(--good); }
.cdt-grade-pill--info { border-color: color-mix(in oklab, var(--info) 40%, var(--border)); color: var(--info); }
.cdt-grade-pill--warn { border-color: color-mix(in oklab, var(--warn) 50%, var(--border)); color: var(--warn); }
.cdt-grade-pill--bad  { border-color: color-mix(in oklab, var(--bad)  45%, var(--border)); color: var(--bad); }

.cdt-grade-pill--on.cdt-grade-pill--good { background: var(--good); color: #fff; border-color: var(--good); }
.cdt-grade-pill--on.cdt-grade-pill--info { background: var(--info); color: #fff; border-color: var(--info); }
.cdt-grade-pill--on.cdt-grade-pill--warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.cdt-grade-pill--on.cdt-grade-pill--bad  { background: var(--bad);  color: #fff; border-color: var(--bad); }

.cdt-grade-comment {
  width: 100%; resize: vertical; min-height: 50px;
  font: inherit; font-size: 13px;
}

.cdt-grade-submit {
  min-width: 200px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}

/* Спиннер для кнопок в состоянии «Сохраняю…» / «Назначаю…» */
.cdt-spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cdtSpin .8s linear infinite;
}
@keyframes cdtSpin { to { transform: rotate(360deg); } }

/* Action-bar в модалке курса с кнопкой «Назначить экзамен» */
.cdt-action-bar {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--good) 8%, var(--surface));
}
.cdt-action-bar:has(.cdt-assign-btn[disabled]) {
  background: var(--surface-2);
}
.cdt-action-bar-info { min-width: 0; flex: 1; }
.cdt-action-bar-title {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  color: var(--ink); margin-bottom: 2px;
}
.cdt-action-bar-hint {
  font-size: 12px; color: var(--ink-3); line-height: 1.4;
}
.cdt-assign-btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  font-weight: 600;
  background: var(--good);
  border-color: var(--good);
  color: #fff;
  transition: filter .12s, transform .06s;
}
.cdt-assign-btn:hover:not(:disabled) { filter: brightness(1.05); }
.cdt-assign-btn:active:not(:disabled) { transform: translateY(1px); }
.cdt-assign-btn:disabled {
  opacity: .55; cursor: not-allowed;
  background: var(--surface-2); color: var(--ink-3); border-color: var(--border);
}

/* Комментарий преподавателя в модалке */
.cdt-comment {
  font-size: 13px; line-height: 1.45;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
}

/* Двухколоночная dl-разметка для широких карточек */
.cdt-dl--inline {
  grid-template-columns: minmax(180px, auto) 1fr;
}

/* Кликабельный чип в колонке «Доступные курсы» */
.ccchip-clickable {
  appearance: none;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: filter .12s, transform .06s;
}
.ccchip-clickable:hover { filter: brightness(0.97); }
.ccchip-clickable:active { transform: translateY(1px); }
.ccchip-clickable:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* === Модалка с подробностями курса === */
.cdt-modal {
  position: relative;
  width: min(96vw, 1100px);
  max-height: 90vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cdt-modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 14px; align-items: flex-start;
}
.cdt-modal-title {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25;
}
.cdt-modal-sub { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.cdt-modal-body {
  flex: 1; overflow: auto;
  padding: 18px 24px;
  background: var(--surface);
}
.cdt-modal-foot {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex; gap: 8px; justify-content: flex-end;
}

.cdt-loading, .cdt-error, .cdt-empty {
  padding: 32px 16px; text-align: center; color: var(--ink-3);
  font-size: 13px;
}
.cdt-error { color: var(--bad); }

/* Inline-подтверждение сброса прогресса.
   Показывается над футером модалки, делает явным, ЧТО именно сотрётся:
   суммарные секунды, диапазон дат, число событий. */
.cdt-confirm-reset {
  margin: 0; padding: 16px 24px;
  border-top: 1px solid color-mix(in oklab, var(--bad) 35%, var(--border));
  background: color-mix(in oklab, var(--bad) 6%, var(--surface));
}
.cdt-confirm-reset__head {
  display: flex; gap: 8px; align-items: center;
  font-size: 14px; color: var(--bad);
  margin-bottom: 10px;
}
.cdt-confirm-reset__body { font-size: 13px; line-height: 1.5; color: var(--ink); }
.cdt-confirm-reset__stats {
  display: grid;
  grid-template-columns: minmax(170px, auto) 1fr;
  gap: 4px 14px;
  margin: 8px 0 0;
  font-size: 13px;
}
.cdt-confirm-reset__stats dt { color: var(--ink-3); }
.cdt-confirm-reset__stats dd { margin: 0; color: var(--ink); }
.cdt-confirm-reset__actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed color-mix(in oklab, var(--bad) 25%, var(--border));
}

.cdt-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cdt-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.cdt-card--wide { grid-column: 1 / -1; }
.cdt-card-title {
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.cdt-dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.cdt-dl dt { color: var(--ink-3); }
.cdt-dl dd { margin: 0; color: var(--ink); }
.cdt-bad { color: var(--bad); font-weight: 500; }

.cdt-status-row { margin-bottom: 12px; }

.cdt-progress-summary {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 12px;
}
.cdt-progress-summary-bar {
  flex: 1; height: 8px; border-radius: 4px;
  background: var(--surface-2); overflow: hidden;
}
.cdt-progress-summary-bar > div {
  height: 100%; background: var(--ink); transition: width .3s;
}
.cdt-progress-summary-text { font-size: 13px; white-space: nowrap; }

.cdt-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  table-layout: fixed;
}
.cdt-table thead th {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-3); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.cdt-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px dashed var(--border);
  vertical-align: top;
}
.cdt-table tbody tr:last-child td { border-bottom: none; }
.cdt-table .nowrap { white-space: nowrap; }
.cdt-trunc {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 0;
}

/* Темы курса: 6 столбцов — Тема (резина) / Тип / План / Факт / Осталось / %.
   Колонки времени расширены до 110px — должны вмещать «1 ч 30 мин» и
   «5 мин 30 сек», тип темы — 130px (пилюля «Промежуточная» в неё помещается). */
.cdt-table--topics col, .cdt-table--topics colgroup { display: none; }
.cdt-table--topics th:nth-child(1), .cdt-table--topics td:nth-child(1) { width: auto; }
.cdt-table--topics th:nth-child(2), .cdt-table--topics td:nth-child(2) { width: 130px; }
.cdt-table--topics th:nth-child(3), .cdt-table--topics td:nth-child(3) { width: 110px; }
.cdt-table--topics th:nth-child(4), .cdt-table--topics td:nth-child(4) { width: 110px; }
.cdt-table--topics th:nth-child(5), .cdt-table--topics td:nth-child(5) { width: 110px; }
.cdt-table--topics th:nth-child(6), .cdt-table--topics td:nth-child(6) { width: 60px; }
/* На случай, если бейдж всё-таки перерастёт колонку, не даём ему ломать
   ширину таблицы — переносится текст внутри пилюли. */
.cdt-table--topics td .badge {
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  padding-top: 2px; padding-bottom: 2px;
}

/* Активность: дата+время / тема (резина) / длительность.
   Колонка длительности — 120px: вмещает «5 мин 30 сек» и заголовок «Длительность». */
.cdt-table--activity th:nth-child(1), .cdt-table--activity td:nth-child(1) { width: 130px; }
.cdt-table--activity th:nth-child(2), .cdt-table--activity td:nth-child(2) { width: auto; }
.cdt-table--activity th:nth-child(3), .cdt-table--activity td:nth-child(3) { width: 120px; }

/* История экзаменов: даты и метрики не должны переноситься */
.cdt-table--exams th:nth-child(1), .cdt-table--exams td:nth-child(1) { width: 95px; }
.cdt-table--exams th:nth-child(2), .cdt-table--exams td:nth-child(2) { width: 105px; }
.cdt-table--exams th:nth-child(3), .cdt-table--exams td:nth-child(3) { width: auto; }
.cdt-table--exams th:nth-child(4), .cdt-table--exams td:nth-child(4) { width: 130px; }
.cdt-table--exams th:nth-child(5), .cdt-table--exams td:nth-child(5) { width: 100px; }
.cdt-table--exams th:nth-child(6), .cdt-table--exams td:nth-child(6) { width: 90px; }
.cdt-table--exams th:nth-child(7), .cdt-table--exams td:nth-child(7) { width: 80px; }

/* === Attempts list (modal) === */
.cdt-exam-groups {
  display: flex; flex-direction: column; gap: 18px;
}
.cdt-exam-group { display: flex; flex-direction: column; gap: 8px; }
.cdt-exam-group-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 12px; flex-wrap: wrap;
  padding: 0 2px 6px;
  border-bottom: 1px dashed var(--border);
}
.cdt-exam-group-title {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.cdt-exam-group-idx {
  font-family: 'Fraunces', serif;
  font-size: 28px; font-weight: 500; line-height: 1;
  color: var(--ink-3);
  letter-spacing: -0.02em;
  width: 38px; text-align: center;
  flex-shrink: 0;
}
.cdt-exam-group-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cdt-exam-group-name {
  font-size: 15px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cdt-exam-group-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.cdt-attempt-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.cdt-attempt {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: stretch;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.cdt-attempt:hover { border-color: var(--border-strong); }
.cdt-attempt--latest {
  border-color: color-mix(in oklab, var(--good) 45%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--good) 12%, transparent) inset;
}
.cdt-attempt-num {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 28px; font-weight: 500; line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 6px 0;
}
.cdt-attempt-num-hash { font-size: 16px; color: var(--ink-4); margin-right: 1px; }
.cdt-attempt--passing .cdt-attempt-num { color: var(--good); }
.cdt-attempt--failed  .cdt-attempt-num { color: var(--bad); }

.cdt-attempt-body {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.cdt-attempt-head {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px;
}
.cdt-attempt-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.cdt-attempt-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  font-size: 12.5px; color: var(--ink-2);
}
.cdt-attempt-meta-item { display: inline-flex; gap: 4px; }

.cdt-attempt-score {
  min-width: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.cdt-attempt-score-value {
  font-family: 'Fraunces', serif; font-size: 28px; font-weight: 500;
  line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.cdt-attempt-score-value--empty { color: var(--ink-4); }
.cdt-attempt-score-pct { font-size: 14px; color: var(--ink-3); margin-left: 1px; }
.cdt-attempt-score-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); margin-top: 4px; font-weight: 600;
}
.cdt-attempt-score--pass {
  background: color-mix(in oklab, var(--good) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--good) 35%, var(--border));
}
.cdt-attempt-score--pass .cdt-attempt-score-value,
.cdt-attempt-score--pass .cdt-attempt-score-label { color: var(--good); }
.cdt-attempt-score--pass .cdt-attempt-score-pct { color: color-mix(in oklab, var(--good) 70%, var(--ink-3)); }
.cdt-attempt-score--fail {
  background: color-mix(in oklab, var(--bad) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
}
.cdt-attempt-score--fail .cdt-attempt-score-value,
.cdt-attempt-score--fail .cdt-attempt-score-label { color: var(--bad); }
.cdt-attempt-score--fail .cdt-attempt-score-pct { color: color-mix(in oklab, var(--bad) 70%, var(--ink-3)); }
.cdt-attempt-score--idle .cdt-attempt-score-value { color: var(--ink-3); }

.cdt-attempt-review {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-2);
  text-decoration: none;
  transition: border-color .12s, color .12s, background .12s;
  white-space: nowrap;
}
.cdt-attempt-review:hover {
  border-color: var(--ink); color: var(--ink); background: var(--surface);
}

@media (max-width: 820px) {
  .cdt-modal-grid { grid-template-columns: 1fr; }

  .cdt-exam-group-idx { font-size: 22px; width: 28px; }
  .cdt-exam-group-name { font-size: 14px; }

  .cdt-attempt {
    grid-template-columns: 44px 1fr;
    gap: 10px;
    padding: 10px 12px;
  }
  .cdt-attempt-num { font-size: 22px; }
  .cdt-attempt-num-hash { font-size: 13px; }
  .cdt-attempt-score {
    grid-column: 1 / -1;
    flex-direction: row; gap: 8px;
    min-width: 0; padding: 8px 12px;
  }
  .cdt-attempt-score-value { font-size: 22px; }
  .cdt-attempt-score-label { margin-top: 0; }
  .cdt-attempt-meta { gap: 4px 10px; font-size: 12px; }

  /* --- Модалки «назначенного экзамена» и «доступного курса» (cdt-modal)
     на мобильном. Принципиально — НЕ fullscreen, а такая же центрированная
     карточка, как все прочие модалки в проекте: width:100% внутри
     паддингованного оверлея, max-height ≤ viewport, flex-column.
     Только так .cdt-modal-foot стабильно прижимается к низу карточки
     (body имеет flex:1, поэтому грабит всё свободное место). */
  .cdt-modal {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 16px;
  }
  .cdt-modal-head { padding: 14px 16px; }
  .cdt-modal-body { padding: 14px 16px; }
  .cdt-modal-title { font-size: 16px; }

  /* Виджет выставления оценки: была flex-строка из двух колонок (info + кнопка),
     на телефоне ужималось и поле комментария становилось узким. Стэкаем
     вертикально, всё на 100% ширины. */
  .cdt-grade-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
  }
  .cdt-grade-bar-info { width: 100%; }
  .cdt-grade-bar-actions { width: 100%; padding-top: 0; }
  .cdt-grade-bar-actions .btn,
  .cdt-grade-submit { width: 100%; min-width: 0; justify-content: center; }
  .cdt-grade-comment { width: 100%; min-height: 64px; }
  .cdt-grade-options { gap: 6px; }
  .cdt-grade-pill { flex: 1 1 calc(50% - 6px); justify-content: center; }

  /* Подтверждение отмены курса не помещается с кнопками — даём блоку
     собственный скролл, а на футере прижимаем кнопки к видимой области. */
  .cdt-confirm-reset { padding: 12px 16px; max-height: 55vh; overflow-y: auto; }
  .cdt-confirm-reset__actions { flex-wrap: wrap; }
  .cdt-confirm-reset__actions .btn { flex: 1 1 auto; justify-content: center; }
  .cdt-modal-foot { padding: 10px 16px; flex-wrap: wrap; }
  .cdt-modal-foot .btn { flex: 1 1 auto; justify-content: center; }
}

/* ============================================================
   Кликабельные ФИО / аватар студента в таблице «Расписание»
============================================================ */
.cdt-name-link {
  color: inherit;
  text-decoration: none;
  border-radius: 4px;
  transition: color .15s, background-color .15s;
  padding: 0 2px; margin: 0 -2px;
}
.cdt-name-link:hover,
.cdt-name-link:focus-visible {
  color: var(--ink);
  background: color-mix(in oklab, var(--ink) 5%, transparent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.cdt-avatar-link {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: white; font-weight: 600; font-size: 14px;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.cdt-avatar-link:hover,
.cdt-avatar-link:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
}

/* ============================================================
   Student profile (sp-*) — страница сводной аналитики студента
   Открывается из «Расписания» кликом на ФИО.
============================================================ */

/* --- Hero --- */
.sp-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 28px 28px;
  margin-bottom: 22px;
  border: var(--tick) solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    color-mix(in oklab, var(--surface) 92%, var(--ink) 4%) 100%
  );
}
.sp-hero__main {
  display: flex; align-items: flex-start; gap: 20px; min-width: 0;
}
.sp-hero__avatar {
  box-shadow: 0 8px 24px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
.sp-hero__id { min-width: 0; }
.sp-hero__name {
  font-family: 'Fraunces', serif;
  font-size: 32px; font-weight: 500; line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.sp-hero__meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px;
}
.sp-hero__contacts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 22px;
  margin: 0;
  font-size: 13px;
}
.sp-hero__contacts > div { display: contents; }
.sp-hero__contacts dt {
  color: var(--ink-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px;
}
.sp-hero__contacts dd { margin: 0; color: var(--ink); }
.sp-link { color: var(--ink); text-decoration: none; border-bottom: 1px dashed var(--border-strong); }
.sp-link:hover { border-bottom-style: solid; }

.sp-hero__ring {
  position: relative;
  width: 140px; height: 140px;
  flex-shrink: 0;
}
/* Текст ВНУТРИ кольца — flex column с центрированием по обеим осям.
   Grid с place-items:center центрирует только В ЯЧЕЙКАХ, но не саму
   сетку — поэтому при 100% (трёхзначное число) контент уезжал вверх. */
.sp-hero__ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  line-height: 1.05;
}
.sp-hero__ring-val {
  font-family: 'Fraunces', serif;
  font-size: 36px; font-weight: 500; line-height: 1;
  letter-spacing: -0.025em;
  white-space: nowrap;
}
/* Чуть ужимаем при 100% — иначе "100%" касается внутренней кромки кольца. */
.sp-hero__ring--full .sp-hero__ring-val { font-size: 30px; }
.sp-hero__ring-pc { font-size: 18px; color: var(--ink-3); margin-left: 1px; }
/* Подпись «Готовность» с info-иконкой внутри кольца.
   Размеры аккуратно подобраны под inner-диаметр кольца (~102 px):
   font-size 9 px + letter-spacing 0.04em + узкий gap + 11px-иконка
   — всё умещается с запасом и не наезжает на цветную дугу. */
.sp-hero__ring-cap {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-3); font-weight: 600;
  margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  white-space: nowrap;
  line-height: 1;
}
/* Сжимаем info-иконку именно ВНУТРИ кольца — снаружи (в KPI-плитках)
   она остаётся 14 px. */
.sp-hero__ring-cap .sp-info {
  width: 11px; height: 11px;
  margin: 0;
}
.sp-ring-progress {
  transition: stroke-dashoffset 1s cubic-bezier(.4, 0, .2, 1);
  animation: sp-ring-draw 1s cubic-bezier(.4, 0, .2, 1);
}
@keyframes sp-ring-draw {
  from { stroke-dashoffset: 352; }
}

/* --- KPI tiles --- */
.sp-kpis {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.sp-kpi {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 20px;
  background: var(--surface);
  border: var(--tick) solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.sp-kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.05);
}
.sp-kpi--accent {
  background: linear-gradient(135deg, var(--surface), color-mix(in oklab, var(--surface) 90%, var(--ink) 5%));
}
.sp-kpi__label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sp-kpi__value {
  font-family: 'Fraunces', serif;
  font-size: 34px; font-weight: 500; line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.sp-kpi__unit {
  font-family: inherit;
  font-size: 16px; color: var(--ink-3); font-weight: 500;
  margin-left: 4px;
}
.sp-kpi__sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}
.sp-kpi__sub .muted { color: var(--ink-3); }

/* --- Card primitive (унифицированный контейнер для секций) --- */
.sp-card {
  background: var(--surface);
  border: var(--tick) solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.sp-card__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.sp-card__title {
  font-size: 15px; font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.sp-card__sub {
  margin-top: 4px;
  font-size: 13px; color: var(--ink-3);
}
.sp-card__divider {
  height: 1px;
  background: var(--border);
  margin: 18px -22px 0;
}
.sp-empty {
  padding: 32px 12px;
  text-align: center;
  font-size: 13px; color: var(--ink-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--surface-2) 50%, transparent);
}

/* --- Grid helpers --- */
.sp-grid--2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

/* --- Heatmap (GitHub-style), но плитки растягиваются на всю ширину карточки ---
   .sp-heat-grid использует CSS-переменную --heat-weeks (число столбцов),
   которая задаётся inline в шаблоне. Все клетки квадратные за счёт
   aspect-ratio: 1 — значит, чем шире блок, тем крупнее каждая плитка. */
.sp-heat-legend {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--ink-3);
}
.sp-heat-legend .sp-heat-cell {
  width: 14px; height: 14px;
  aspect-ratio: auto;
}
.sp-heat-wrap {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  /* Потолок размера клетки: на широких мониторах сетка иначе раздувается.
     При 52 колонках (год) 18 px × 7 строк = 126 px высоты — нормальная
     пропорция, не «полоска». На 1100+ мониторе клетки достигнут потолка,
     на меньших — авторазмер по 1fr. */
  --heat-cell-max: 18px;
}
.sp-heat-rows {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  font-size: 10px; color: var(--ink-4);
}
.sp-heat-rowlabel {
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 4px;
  min-height: 0;
}
.sp-heat-grid {
  display: grid;
  grid-template-columns: repeat(var(--heat-weeks, 14), minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}
.sp-heat-col {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  min-width: 0;
}
.sp-heat-cell {
  width: 100%;
  aspect-ratio: 1;
  max-height: var(--heat-cell-max);
  max-width:  var(--heat-cell-max);
  justify-self: center;
  align-self:   center;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid color-mix(in oklab, var(--border) 55%, transparent);
  transition: transform .12s, box-shadow .12s;
}
.sp-heat-cell--empty { visibility: hidden; }
.sp-heat-cell--0 { background: var(--surface-2); }
.sp-heat-cell--1 { background: color-mix(in oklab, var(--good) 22%, var(--surface)); border-color: color-mix(in oklab, var(--good) 18%, var(--border)); }
.sp-heat-cell--2 { background: color-mix(in oklab, var(--good) 42%, var(--surface)); border-color: color-mix(in oklab, var(--good) 30%, var(--border)); }
.sp-heat-cell--3 { background: color-mix(in oklab, var(--good) 64%, var(--surface)); border-color: color-mix(in oklab, var(--good) 45%, var(--border)); }
.sp-heat-cell--4 { background: var(--good); border-color: color-mix(in oklab, var(--good) 70%, var(--ink)); }
.sp-heat-cell[tabindex]:hover,
.sp-heat-cell[tabindex]:focus-visible {
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink);
  z-index: 1; position: relative;
}

/* --- Daily bars (последние 30 дней) --- */
.sp-bars {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  align-items: flex-end;
  gap: 4px;
  height: 130px;
  padding: 8px 4px 22px;
  position: relative;
}
.sp-bars__col {
  position: relative;
  height: 100%;
  display: flex; align-items: flex-end;
  cursor: default;
}
.sp-bars__fill {
  width: 100%;
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-radius: 3px 3px 1px 1px;
  transition: height .4s cubic-bezier(.4,0,.2,1), background .15s;
  min-height: 2px;
}
.sp-bars__col:hover .sp-bars__fill {
  background: linear-gradient(180deg, var(--good), color-mix(in oklab, var(--good) 70%, var(--ink)));
}
.sp-bars__label {
  position: absolute; left: 50%; bottom: -18px;
  transform: translateX(-50%);
  font-size: 10px; color: var(--ink-4);
  white-space: nowrap;
}

/* --- Segmented bar (распределение курсов) --- */
.sp-segbar {
  display: flex;
  height: 14px; border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: var(--tick) solid var(--border);
  gap: 2px;
  padding: 0;
  margin-top: 6px;
}
.sp-segbar__seg { transition: filter .15s; }
.sp-segbar__seg:hover { filter: brightness(1.06); }
.sp-segbar__seg--red    { background: oklch(0.62 0.18 25); }
.sp-segbar__seg--yellow { background: oklch(0.78 0.13 80); }
.sp-segbar__seg--blue   { background: oklch(0.68 0.10 235); }
.sp-segbar__seg--gray   { background: var(--ink-4); }
.sp-segbar-legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin-top: 12px;
}
.sp-segbar-legend__item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2);
}
.sp-segbar-legend__dot {
  width: 10px; height: 10px; border-radius: 3px;
}

/* --- Шкала среднего балла --- */
.sp-scale { margin: 12px 0 6px; }
.sp-scale__track {
  position: relative;
  height: 10px; border-radius: 6px;
  background: var(--surface-2);
  border: var(--tick) solid var(--border);
}
.sp-scale__fill {
  height: 100%;
  background: linear-gradient(90deg,
    var(--bad) 0%,
    color-mix(in oklab, var(--warn) 70%, var(--bad) 30%) 50%,
    var(--good) 100%);
  border-radius: 6px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.sp-scale__threshold {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px;
  background: var(--ink);
  border-radius: 1px;
  opacity: .55;
}
.sp-scale__threshold::after {
  content: '80%';
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  font-size: 10px; color: var(--ink-3); font-weight: 600;
  white-space: nowrap;
}
.sp-scale__pin {
  position: absolute; top: -22px;
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.sp-scale__pin::after {
  content: '';
  position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--ink);
}
.sp-scale__legend {
  display: flex; justify-content: space-between;
  margin-top: 6px;
}
.sp-mini-stats {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin: 12px 0 0;
  font-size: 13px;
}
.sp-mini-stats > div { display: contents; }
.sp-mini-stats dt {
  color: var(--ink-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500;
  align-self: end;
}
.sp-mini-stats dd {
  margin: 0;
  font-size: 18px; font-weight: 500;
  font-family: 'Fraunces', serif;
}

/* --- Универсальные таблицы профиля (курсы, попытки, аттестации) --- */
.sp-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -22px; padding: 0 22px; }
.sp-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.sp-table thead th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  position: sticky; top: 0; z-index: 1;
}
.sp-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px dashed var(--border);
  vertical-align: middle;
}
.sp-table tbody tr:last-child td { border-bottom: 0; }
.sp-table tbody tr:hover { background: color-mix(in oklab, var(--surface-2) 50%, transparent); }
.sp-table .nowrap { white-space: nowrap; }
.sp-trunc { min-width: 0; overflow: hidden; }
.sp-trunc__title {
  font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Цветная полоска слева у строки курса — статус подсвечивается без шума. */
.sp-table--courses tbody tr {
  position: relative;
}
.sp-table--courses tbody tr td:first-child {
  position: relative;
}
.sp-table--courses tbody tr td:first-child::before {
  content: '';
  position: absolute; left: -10px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--ink-4);
}
.sp-row--red    td:first-child::before { background: oklch(0.62 0.18 25); }
.sp-row--yellow td:first-child::before { background: oklch(0.78 0.13 80); }
.sp-row--blue   td:first-child::before { background: oklch(0.68 0.10 235); }
.sp-row--gray   td:first-child::before { background: var(--ink-4); }

/* Inline-прогресс в ячейке: тонкий бар + цифровое значение справа. */
.sp-cell-progress {
  display: flex; align-items: center; gap: 8px;
}
.sp-cell-progress__bar {
  flex: 1; min-width: 40px;
  height: 6px; border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.sp-cell-progress__bar > span {
  display: block; height: 100%;
  background: var(--ink);
  border-radius: 3px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.sp-cell-progress__bar--red    > span { background: var(--bad); }
.sp-cell-progress__bar--yellow > span { background: var(--warn); }
.sp-cell-progress__bar--blue   > span { background: var(--info); }
.sp-cell-progress__bar--gray   > span { background: var(--ink-3); }
.sp-cell-progress__val {
  font-size: 12px; color: var(--ink-2); font-weight: 500;
  min-width: 34px; text-align: right;
}

/* Колонка «До срока» — цветная подсветка соответствующего тона. */
.sp-cell-due {
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.sp-cell-due--red    { color: var(--bad); }
.sp-cell-due--yellow { color: var(--warn); }
.sp-cell-due--blue   { color: var(--ink-2); }
.sp-cell-due--gray   { color: var(--ink-3); }

/* --- Клиентская пагинация таблиц профиля --- */
.sp-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
.sp-pager[hidden] { display: none !important; }
.sp-pager__info { color: var(--ink-3); }
.sp-pager__nav {
  display: inline-flex; align-items: center; gap: 2px;
  flex-wrap: wrap;
}
.sp-pager__btn {
  min-width: 28px; height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s;
}
.sp-pager__btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}
.sp-pager__btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.sp-pager__btn.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.sp-pager__dots {
  display: inline-block;
  min-width: 16px;
  text-align: center;
  color: var(--ink-4);
}

/* --- Чип «код курса» (короткое имя + tooltip с полным).
   Используется во всех таблицах профиля и в timeline, чтобы строки
   таблиц оставались компактными и колонки не «наезжали». */
.sp-course-chip {
  display: inline-block;
  max-width: 110px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  cursor: help;
  border: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  transition: background-color .12s, color .12s, border-color .12s;
}
.sp-course-chip:hover {
  background: color-mix(in oklab, var(--surface-2) 60%, var(--ink) 6%);
  color: var(--ink-2);
  border-color: var(--border-strong);
}

/* Не даём бейджам со статусом аттестации переноситься внутри ячейки
   (например, «Сдан, ждёт оценки»). Колонка под них уже расширена. */
.sp-table .badge.nowrap { white-space: nowrap; }

/* --- Info-иконка (?) — подпись для KPI и hero-кольца ---
   Двойной замок размера: и контейнер, и сам SVG получают жёсткие
   width/height (а не % от родителя). Так иконка не «раздувается»
   даже если рядом включается flex-stretch или иной align. */
.sp-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  flex: 0 0 14px;
  margin-left: 4px;
  color: var(--ink-4);
  cursor: help;
  border-radius: 50%;
  transition: color .12s, background-color .12s;
  vertical-align: middle;
}
.sp-info > svg {
  width: 14px; height: 14px;
  max-width: 100%; max-height: 100%;
  flex: 0 0 14px;
  display: block;
}
.sp-info:hover,
.sp-info:focus-visible { color: var(--ink); background: var(--surface-2); }
.sp-kpi__label { display: inline-flex; align-items: center; }
.sp-hero__ring-cap { display: inline-flex; align-items: center; justify-content: center; }

/* Внутри готовность-кольца — компактный размер, чтобы иконка была
   соразмерна подписи «Готовность» и не вылезала за пределы бублика. */
.sp-hero__ring-cap .sp-info,
.sp-hero__ring-cap .sp-info > svg {
  width: 11px; height: 11px;
  flex-basis: 11px;
}
.sp-hero__ring-cap .sp-info { margin: 0; }

@media (max-width: 540px) {
  .sp-hero__ring-cap { font-size: 8px; gap: 2px; margin-top: 3px; }
  .sp-hero__ring-cap .sp-info,
  .sp-hero__ring-cap .sp-info > svg {
    width: 9px !important;
    height: 9px !important;
    flex-basis: 9px !important;
    min-width: 0;
    min-height: 0;
  }
}

/* --- Timeline хронологии действий --- */
.sp-timeline {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 22px;
  position: relative;
}
.sp-timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 10px; bottom: 10px;
  width: 1px;
  background: linear-gradient(180deg, var(--border) 0%, var(--border-strong) 50%, var(--border) 100%);
}
.sp-timeline__item {
  display: grid; grid-template-columns: 20px 1fr;
  gap: 16px;
  position: relative;
  padding: 6px 0;
}
.sp-timeline__dot {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink-2);
  margin-top: 4px;
  position: relative; z-index: 1;
  transition: border-color .15s, transform .15s, background-color .15s;
}
.sp-timeline__item--exam     .sp-timeline__dot { border-color: var(--good); }
.sp-timeline__item--material .sp-timeline__dot { border-color: var(--info); }
.sp-timeline__item--auth     .sp-timeline__dot { border-color: var(--ink-3); }
.sp-timeline__item:hover .sp-timeline__dot {
  background: var(--ink);
  transform: scale(1.15);
}
.sp-timeline__body { min-width: 0; }
.sp-timeline__head {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.sp-timeline__title {
  font-size: 14px; font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.sp-timeline__detail {
  margin-top: 2px;
  font-size: 13px; color: var(--ink-2);
  line-height: 1.45;
}

/* --- Responsive ---
   Десктоп → планшет (≤1100) → узкий планшет (≤820) → телефон (≤540).
   Цели: ничего не наезжает, ничего не обрезается без скролла, тапы по
   кнопкам пагинации удобные пальцем (≥28px по высоте). */
@media (max-width: 1100px) {
  .sp-kpis { grid-template-columns: repeat(2, 1fr); }
  .sp-grid--2col { grid-template-columns: 1fr; }
  /* На планшете при 52 колонках клетки уменьшаются 1fr-распределением.
     Потолок снижаем — иначе на планшете в альбомной ориентации сетка
     становится непропорционально высокой. */
  .sp-heat-wrap { --heat-cell-max: 14px; }
}
@media (max-width: 820px) {
  .sp-hero { grid-template-columns: 1fr; gap: 18px; padding: 22px; }
  .sp-hero__main { flex-direction: column; align-items: flex-start; }
  .sp-hero__ring { margin: 0 auto; }
  .sp-hero__contacts { grid-template-columns: 1fr; }
  .sp-hero__name { font-size: 26px; }
  .sp-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .sp-kpi { padding: 14px 16px; }
  .sp-kpi__value { font-size: 28px; }

  /* Таблицы получают горизонтальный скролл через .sp-table-scroll.
     min-width гарантирует, что колонки не «жмутся» друг к другу. */
  .sp-table--courses       { min-width: 720px; }
  .sp-table--attempts      { min-width: 880px; }
  .sp-table--attestations  { min-width: 820px; }
  .sp-pager { font-size: 11px; padding: 8px 6px; }
  .sp-pager__btn { min-width: 32px; height: 32px; }  /* удобнее тапать */

  .sp-card { padding: 16px; }
  .sp-card__divider { margin-left: -16px; margin-right: -16px; }
  .sp-table-scroll { margin: 0 -16px; padding: 0 16px; }

  .sp-heat-wrap { --heat-cell-max: 12px; gap: 6px; }
  .sp-bars { height: 110px; }
}
@media (max-width: 540px) {
  .sp-kpis { grid-template-columns: 1fr; }
  .sp-hero { padding: 18px; }
  .sp-hero__name { font-size: 22px; }
  .sp-hero__avatar { width: 64px !important; height: 64px !important; }
  .sp-hero__ring { width: 110px; height: 110px; }
  .sp-hero__ring svg { width: 110px; height: 110px; }
  .sp-hero__ring-val { font-size: 28px; }

  /* На телефоне год × 7 = клетки становятся слишком мелкими (52×4=≈4 px).
     Включаем горизонтальный скролл и фиксированный размер клетки. */
  .sp-heat-wrap {
    grid-template-columns: 24px 1fr;
    --heat-cell-max: 10px;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .sp-heat-grid {
    grid-template-columns: repeat(var(--heat-weeks, 14), 10px);
    gap: 2px;
  }
  .sp-heat-col  { gap: 2px; }

  .sp-bars { grid-template-columns: repeat(30, 1fr); gap: 2px; height: 100px; }
  .sp-bars__label { display: none; }   /* на телефоне подписи сливаются */

  /* Курс-чип на узких экранах ужимаем, иначе ломает раскладку шапки timeline. */
  .sp-course-chip { max-width: 80px; font-size: 10px; }

  .sp-timeline__head { gap: 6px; }
}

/* ============================================================
   Statistics dashboard (st-*) — общесистемная аналитика.
   Использует те же базовые токены и переиспользует .sp-card,
   .sp-heat-* (тепловая карта года), .sp-segbar / .sp-empty.
============================================================ */

/* --- KPI плитки --- */
.st-kpis {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.st-kpi {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 20px;
  background: var(--surface);
  border: var(--tick) solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.st-kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.05);
}
.st-kpi--accent {
  background: linear-gradient(135deg, var(--surface), color-mix(in oklab, var(--surface) 88%, var(--ink) 6%));
}
.st-kpi--alert {
  border-color: color-mix(in oklab, var(--bad) 35%, var(--border));
  background: color-mix(in oklab, var(--bad) 5%, var(--surface));
}
.st-kpi__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  flex-shrink: 0;
}
.st-kpi--alert .st-kpi__icon {
  background: color-mix(in oklab, var(--bad) 14%, var(--surface));
  color: var(--bad);
}
.st-kpi__body { min-width: 0; flex: 1; }
.st-kpi__label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.st-kpi__value {
  font-family: 'Fraunces', serif;
  font-size: 32px; font-weight: 500; line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.st-kpi__unit {
  font-family: inherit; font-size: 14px; color: var(--ink-3);
  font-weight: 500; margin-left: 4px;
}
.st-kpi__sub {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-2);
}
.st-kpi__sub .muted { color: var(--ink-3); }

.st-delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-weight: 600;
  font-size: 12px;
}
.st-delta--good   { color: var(--good); }
.st-delta--bad    { color: var(--bad); }
.st-delta--muted  { color: var(--ink-3); }

.st-link {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-strong);
  font-weight: 500;
}
.st-link:hover { border-bottom-style: solid; }

/* --- Сетка двух колонок (используем общую sp-grid--2col тоже) --- */
.st-grid--2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 0;
}
.st-grid--2col > .sp-card { margin-bottom: 18px; }

/* --- Часовая теплокарта 7 × 24 --- */
.st-hourmap {
  display: flex; flex-direction: column;
  gap: 4px;
  font-size: 11px; color: var(--ink-3);
}
.st-hourmap__cols {
  display: grid;
  grid-template-columns: 24px repeat(24, 1fr);
  gap: 3px;
  margin-bottom: 2px;
}
.st-hourmap__hour {
  text-align: center;
  font-size: 9px; color: var(--ink-4);
  line-height: 1.4;
}
.st-hourmap__row {
  display: grid;
  grid-template-columns: 24px repeat(24, 1fr);
  gap: 3px;
  align-items: center;
}
.st-hourmap__rowlabel {
  font-size: 10px; color: var(--ink-4);
  text-align: right;
  padding-right: 4px;
}
.st-hourcell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid color-mix(in oklab, var(--border) 55%, transparent);
  max-height: 22px;
  justify-self: center; align-self: center;
  width: 100%;
  transition: transform .12s, box-shadow .12s;
}
.st-hourcell--0 { background: var(--surface-2); }
.st-hourcell--1 { background: color-mix(in oklab, var(--info) 22%, var(--surface)); border-color: color-mix(in oklab, var(--info) 18%, var(--border)); }
.st-hourcell--2 { background: color-mix(in oklab, var(--info) 42%, var(--surface)); border-color: color-mix(in oklab, var(--info) 30%, var(--border)); }
.st-hourcell--3 { background: color-mix(in oklab, var(--info) 64%, var(--surface)); border-color: color-mix(in oklab, var(--info) 45%, var(--border)); }
.st-hourcell--4 { background: var(--info); border-color: color-mix(in oklab, var(--info) 70%, var(--ink)); }
.st-hourcell[tabindex]:hover,
.st-hourcell[tabindex]:focus-visible {
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink);
  z-index: 1; position: relative;
}

/* --- Гистограмма распределения баллов --- */
.st-hist {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: flex-end;
  gap: 12px;
  height: 220px;
  padding: 10px 4px 0;
}
.st-hist__col {
  display: flex; flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
  cursor: default;
}
.st-hist__count {
  font-size: 13px; font-weight: 600;
  color: var(--ink); margin-bottom: 4px;
}
.st-hist__bar {
  width: 60%; max-width: 80px;
  height: 100%;
  display: flex; align-items: flex-end;
  background: linear-gradient(180deg, color-mix(in oklab, var(--surface-2) 50%, transparent), var(--surface-2));
  border-radius: 6px 6px 2px 2px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.st-hist__bar > span {
  display: block; width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height .6s cubic-bezier(.4,0,.2,1);
}
.st-hist__col--fail .st-hist__bar > span {
  background: linear-gradient(180deg, color-mix(in oklab, var(--bad) 75%, var(--ink)), var(--bad));
}
.st-hist__col--pass .st-hist__bar > span {
  background: linear-gradient(180deg, color-mix(in oklab, var(--good) 75%, var(--ink)), var(--good));
}
.st-hist__label {
  margin-top: 8px;
  font-size: 11px; color: var(--ink-3);
  font-weight: 500;
}

/* --- Дневные столбики (60 дней) — переиспользуем стиль sp-bars,
   но шире (на dashboard полная ширина карточки). --- */
.st-bars {
  display: grid;
  grid-template-columns: repeat(60, 1fr);
  align-items: flex-end;
  gap: 3px;
  height: 150px;
  padding: 8px 4px 22px;
  position: relative;
}
.st-bars__col {
  position: relative;
  height: 100%;
  display: flex; align-items: flex-end;
  cursor: default;
}
.st-bars__fill {
  width: 100%;
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-radius: 3px 3px 1px 1px;
  transition: height .4s cubic-bezier(.4,0,.2,1), background .15s;
  min-height: 2px;
}
.st-bars__col:hover .st-bars__fill {
  background: linear-gradient(180deg, var(--info), color-mix(in oklab, var(--info) 70%, var(--ink)));
}
.st-bars__label {
  position: absolute; left: 50%; bottom: -18px;
  transform: translateX(-50%);
  font-size: 10px; color: var(--ink-4);
  white-space: nowrap;
}

/* --- Рейтинговые списки --- */
.st-rank {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: 8px;
}
.st-rank__item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, background-color .15s, transform .15s;
}
.st-rank__item:hover {
  border-color: var(--border-strong);
  transform: translateX(2px);
}
.st-rank__pos {
  font-family: 'Fraunces', serif;
  font-size: 20px; font-weight: 500;
  color: var(--ink-3);
  text-align: center;
  line-height: 1;
}
.st-rank__body { min-width: 0; }
.st-rank__title {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px;
  margin-bottom: 6px;
}
.st-rank__title .muted { color: var(--ink-3); }
.st-rank__bar {
  height: 5px; border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.st-rank__bar-fill {
  display: block; height: 100%; border-radius: 3px;
  background: var(--ink);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.st-rank__bar-fill--good { background: var(--good); }
.st-rank__bar-fill--warn { background: var(--warn); }
.st-rank__bar-fill--bad  { background: var(--bad); }
.st-rank__chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.st-rank__metric {
  font-size: 16px;
  color: var(--ink);
}

/* --- Донат активных аттестаций ---
   Не используем grid place-items: при двух дочерних элементах grid
   делает по строке на каждого, и центральная пара «число + подпись»
   выглядит сдвинутой. Flex column в комбинации с absolute inset:0
   ставит обе строки строго по центру SVG. */
.st-donut-wrap {
  position: relative;
  margin: 8px auto 16px;
  width: 160px; height: 160px;
}
.st-donut {
  display: block;
  width: 100%; height: 100%;
}
.st-donut circle {
  transition: stroke-dasharray .6s cubic-bezier(.4,0,.2,1);
}
.st-donut-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  pointer-events: none;
  /* Чуть-чуть подвинем вверх, чтобы цифра + подпись визуально лежали
     по центру оптического круга, а не математического центра коробки
     (низ кольца чуть тяжелее благодаря тени). */
  line-height: 1.05;
}
.st-donut-value {
  font-family: 'Fraunces', serif;
  font-size: 32px; font-weight: 500; line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.st-donut-cap {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3); font-weight: 600;
  margin-top: 6px;
}
.st-donut-legend {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px;
}
.st-donut-legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.st-donut-legend__dot {
  width: 12px; height: 12px;
  border-radius: 3px;
}
.st-donut-legend__label { color: var(--ink-2); }
.st-donut-legend .muted { color: var(--ink-3); font-size: 12px; }

/* --- Responsive --- */
@media (max-width: 1200px) {
  .st-kpis { grid-template-columns: repeat(3, 1fr); }
  .st-kpi--accent { grid-column: span 1; }
}
@media (max-width: 1024px) {
  .st-grid--2col { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .st-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .st-kpi { padding: 14px 16px; gap: 10px; }
  .st-kpi__value { font-size: 26px; }
  .st-kpi__icon { width: 30px; height: 30px; }

  .st-bars { grid-template-columns: repeat(60, 1fr); gap: 2px; height: 110px; }
  .st-bars__label { display: none; }

  .st-hourmap__cols, .st-hourmap__row {
    grid-template-columns: 22px repeat(24, 1fr);
    gap: 2px;
  }
  .st-hourcell { max-height: 16px; }

  .st-hist { height: 180px; gap: 8px; }
  .st-hist__bar { width: 80%; }

  /* На планшете уменьшаем сам контейнер и шрифт значения.
     ВНИМАНИЕ: не трогать `.st-donut > *` — это <circle> внутри SVG,
     CSS width/height ломают их геометрию и сегменты «съезжают». */
  .st-donut-wrap { width: 140px; height: 140px; }
  .st-donut-value { font-size: 28px; }
}
@media (max-width: 540px) {
  .st-kpis { grid-template-columns: 1fr; }
  .st-kpi__value { font-size: 24px; }

  /* На телефоне строки часовой карты становятся очень тесными — даём
     карточке горизонтальный скролл. */
  .st-hourmap {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .st-hourmap__cols, .st-hourmap__row {
    grid-template-columns: 22px repeat(24, 12px);
    gap: 2px;
  }
  .st-hourcell { width: 12px; height: 12px; max-height: 12px; aspect-ratio: auto; }

  .st-bars { grid-template-columns: repeat(60, 1fr); height: 90px; }
  .st-hist { grid-template-columns: repeat(5, 1fr); height: 150px; gap: 6px; }
  .st-rank__item {
    grid-template-columns: 22px 1fr;
    gap: 8px;
  }
  .st-rank__metric { grid-column: 2; justify-self: end; }
}

