/* Кабинет «НейроМиша для образования» — /business/app.
 *
 * Значения — из дизайн-системы продукта (design-system/tokens). Маскота в
 * разделе нет по решению заказчика, эмодзи запрещены везде.
 *
 * Почему свой файл, а не styles.css кабинета ученика: тот весит 372 КБ и
 * описывает тренажёры, карточки и лаборатории, которых здесь нет. Общими взяты
 * токены и характер — тёплая кремовая база, коричневые тени, нижний бортик у
 * кнопок, пружинная моторика.
 */

/* ─── Токены ────────────────────────────────────────────────────────────── */

:root {
  --brand: #DF995B;
  --brand-ink: #B36E30;
  --brand-deep: #8C5422;
  --brand-soft: #F6D9B8;
  --brand-light: #E8B07C;

  --sec: #496F82;
  --sec-ink: #2F4E5E;
  --sec-soft: #C9DCE6;

  --bg: #FCEDD0;
  --bg-warm: #F9E4BE;
  --bg-deep: #F4DAAF;

  --surface: #FFF8EC;
  --surface-2: #FBEEDA;
  --surface-3: #F8E7CB;

  --ink: #1F2937;
  --ink-2: #4B5563;
  --ink-3: #6B7280;

  --good: #10B981;
  --good-soft: #DDEBD2;
  --good-ink: #2F6B3B;
  --bad: #EF4444;
  --bad-soft: #F5D4C4;
  --bad-ink: #8B2F22;
  --gold: #F59E0B;
  --gold-soft: #FFEDC9;
  --gold-ink: #B97500;
  --blue: #3B82F6;

  --line: rgba(73, 111, 130, .13);
  --line-2: rgba(140, 84, 34, .2);

  --shadow-sm: 0 2px 5px rgba(79, 54, 24, .06), 0 14px 30px -26px rgba(79, 54, 24, .42);
  --shadow-md: 0 8px 18px rgba(79, 54, 24, .1), 0 26px 52px -34px rgba(79, 54, 24, .48);
  --shadow-lg: 0 8px 24px rgba(79, 54, 24, .08), 0 32px 64px -32px rgba(79, 54, 24, .25);
  --gloss-top: inset 0 1px 0 rgba(255, 255, 255, .82);

  --radius-sm: 8px;
  --radius: 10px;
  --radius-btn: 13px;
  --radius-action: 14px;
  --radius-lg: 16px;
  --radius-card: 20px;
  --radius-pill: 999px;

  --dur-fast: 200ms;
  --dur-smooth: 300ms;
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --ease-spring: cubic-bezier(.22, 1, .36, 1);

  --rail-w: 248px;
  --topbar-h: 72px;
}

[data-theme="dark"] {
  --brand-ink: #D4923C;
  --brand-deep: #c47a2e;
  --brand-soft: #3D2A1A;
  --sec-ink: #8CBAD3;
  --sec-soft: #1C2C34;
  --bg: #1A1410;
  --bg-warm: #201A14;
  --bg-deep: #141010;
  --surface: #241E17;
  --surface-2: #2E261E;
  --surface-3: #382F26;
  --ink: #F5EDE0;
  --ink-2: #B8AFA3;
  --ink-3: #8A8078;
  --good-soft: #1A2E24;
  --good-ink: #34D399;
  --bad-soft: #3B2020;
  --bad-ink: #F87171;
  --gold-soft: #3A2C12;
  --gold-ink: #FBBF24;
  --line: rgba(245, 237, 224, .1);
  --line-2: rgba(245, 237, 224, .16);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .6);
  --gloss-top: inset 0 1px 0 rgba(255, 255, 255, .06);
}

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

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: 'Unbounded', 'Manrope', sans-serif;
  font-weight: 700;
  letter-spacing: -.02em;
}

p { margin: 0; }

a { color: var(--brand-ink); }

.ic { flex: 0 0 auto; width: 20px; height: 20px; }
.ic-sm { width: 16px; height: 16px; }

.b-boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--ink-3);
  font-size: .95rem;
}

.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: .94rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 248, 236, .88);
  border: 1px solid rgba(73, 111, 130, .14);
  border-bottom: 3px solid var(--line-2);
  box-shadow: 0 2px 4px rgba(79, 54, 24, .06), 0 12px 24px -22px rgba(79, 54, 24, .46);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce),
              box-shadow var(--dur-fast) ease,
              background var(--dur-fast) ease,
              border-color var(--dur-fast) ease;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: scale(.96); transition-duration: 80ms; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: rgba(140, 84, 34, .12);
  border-bottom-width: 4px;
  box-shadow: 0 16px 28px -22px rgba(140, 84, 34, .86), inset 0 -3px 0 rgba(140, 84, 34, .28);
}

.btn-primary:active:not(:disabled) { transform: scale(.94); border-bottom-width: 2px; padding-bottom: 13px; }

.btn-ghost { background: rgba(255, 248, 236, .5); border-color: rgba(73, 111, 130, .16); }

.btn-danger {
  background: var(--bad-soft);
  color: var(--bad-ink);
  border-color: rgba(239, 68, 68, .22);
  border-bottom: 4px solid rgba(192, 58, 42, .55);
}

.btn-sm { min-height: 36px; padding: 8px 13px; font-size: .85rem; gap: 7px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-wide { width: 100%; }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-action);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
}

.btn-icon:hover { color: var(--brand-deep); border-color: rgba(223, 153, 91, .4); background: var(--surface-2); }
.btn-icon.danger:hover { color: var(--bad-ink); border-color: rgba(239, 68, 68, .34); }

.btn.loading { pointer-events: none; position: relative; }
.btn.loading::after {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: b-spin .65s linear infinite;
}

@keyframes b-spin { to { transform: rotate(360deg); } }

:where(.btn, .btn-icon, .field, .b-nav-item, .b-tab, .b-row-link):focus-visible {
  outline: 3px solid rgba(73, 111, 130, .46);
  outline-offset: 3px;
}

/* ─── Экран входа ───────────────────────────────────────────────────────── */

.b-auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 20px;
  background:
    radial-gradient(46% 40% at 82% 6%, rgba(223, 153, 91, .12), transparent 70%),
    radial-gradient(40% 36% at 10% 92%, rgba(73, 111, 130, .07), transparent 70%),
    var(--bg);
}

.b-auth-card {
  width: min(460px, 100%);
  padding: 32px 28px 26px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg), var(--gloss-top);
}

.b-auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.b-auth-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-action);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: .95rem;
  border: 1px solid rgba(140, 84, 34, .18);
  box-shadow: var(--gloss-top);
}

.b-auth-brand h1 { font-size: 1.12rem; line-height: 1.2; }
.b-auth-brand p { font-size: .82rem; color: var(--ink-3); margin-top: 3px; }

.b-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 20px;
  border-radius: var(--radius-btn);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.b-tab {
  padding: 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
}

.b-tab.active {
  background: var(--surface);
  color: var(--brand-deep);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.b-auth-note {
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .86rem;
  line-height: 1.5;
}

.b-auth-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--ink-3);
}

/* ─── Каркас ────────────────────────────────────────────────────────────── */

.b-shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

.b-rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: rgba(255, 248, 236, .74);
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .72);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

[data-theme="dark"] .b-rail { background: rgba(36, 30, 23, .84); box-shadow: none; }

.b-rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 15px;
  background: rgba(255, 248, 236, .78);
  border: 1px solid rgba(140, 84, 34, .16);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
}

[data-theme="dark"] .b-rail-brand { background: rgba(46, 38, 30, .7); }

.b-rail-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: .82rem;
  flex-shrink: 0;
}

/* Название в одну строку: на 248 пикселях рейла «Для образования» ломалось
 * пополам и съедало высоту, из-за которой шапка выглядела сломанной. */
.b-rail-title {
  min-width: 0;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.25;
  color: var(--brand-deep);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b-rail-title span {
  display: block;
  font-family: 'Manrope', sans-serif;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.b-nav { display: grid; gap: 3px; }

.b-nav-group {
  margin: 12px 0 4px;
  padding: 0 12px;
  font-family: 'Unbounded', sans-serif;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.b-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: transparent;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  color: rgba(31, 41, 55, .74);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
}

[data-theme="dark"] .b-nav-item { color: var(--ink-2); }

.b-nav-item:hover {
  color: var(--brand-deep);
  background: rgba(255, 247, 236, .9);
  border-color: rgba(140, 84, 34, .12);
  transform: translateX(2px);
}

[data-theme="dark"] .b-nav-item:hover { background: rgba(61, 42, 26, .5); color: var(--brand-ink); }

.b-nav-item.active {
  color: var(--brand-deep);
  background: rgba(246, 217, 184, .68);
  border-color: rgba(179, 110, 48, .24);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 12px 26px -24px rgba(140, 84, 34, .72);
}

[data-theme="dark"] .b-nav-item.active { background: rgba(61, 42, 26, .85); }

/* Точка справа: активный пункт различим и без цвета. */
.b-nav-item.active::after {
  content: "";
  position: absolute;
  right: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sec);
  box-shadow: 0 0 0 5px rgba(73, 111, 130, .1);
}

.b-nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
}

.b-rail-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }

.b-quota {
  padding: 12px;
  border-radius: var(--radius-action);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.b-quota-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.b-quota-head b {
  font-family: 'Unbounded', sans-serif;
  font-size: .92rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.b-quota.low .b-quota-head b { color: var(--bad-ink); }

.b-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-action);
  font-size: .82rem;
}

.b-user-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--sec-soft);
  color: var(--sec-ink);
  font-weight: 800;
  font-size: .8rem;
}

.b-user-name { min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-user-role { font-size: .72rem; color: var(--ink-3); }

/* ─── Рабочая область ───────────────────────────────────────────────────── */

.b-work { display: flex; flex-direction: column; min-width: 0; }

.b-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 13px 28px;
  background: rgba(255, 248, 236, .82);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 34px -34px rgba(79, 54, 24, .5);
  backdrop-filter: blur(24px) saturate(1.22);
  -webkit-backdrop-filter: blur(24px) saturate(1.22);
}

[data-theme="dark"] .b-topbar { background: rgba(36, 30, 23, .86); }

.b-topbar h1 { font-size: 1.2rem; line-height: 1.2; }
.b-topbar p { margin-top: 3px; font-size: .84rem; color: var(--ink-3); }

.b-topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.b-burger { display: none; }

.b-view {
  flex: 1;
  padding: 26px 28px 60px;
  animation: b-page-in var(--dur-smooth) var(--ease-spring) both;
}

@keyframes b-page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* min-width: 0 обязателен: элемент грида по умолчанию не уже своего
 * содержимого, а внутри панелей лежат таблицы с min-width 560px. Без этого
 * правила таблица распирала не себя, а всю страницу — и вместо прокрутки
 * внутри рамки появлялась горизонтальная прокрутка кабинета. */
.b-stack { display: grid; gap: 18px; }
.b-stack > * { min-width: 0; }

/* ─── Панели и карточки ─────────────────────────────────────────────────── */

.panel {
  position: relative;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(255, 248, 236, .92);
  border: 1px solid rgba(140, 84, 34, .13);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .panel { background: rgba(46, 38, 30, .78); border-color: var(--line); }

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--gloss-top);
  pointer-events: none;
}

.panel > * { position: relative; }

.panel.plain { background: var(--surface); }

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

.panel-head h2 { font-size: 1.05rem; line-height: 1.28; }
.panel-head p { margin-top: 4px; font-size: .84rem; color: var(--ink-3); }

.b-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.b-grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.b-grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.b-grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.b-split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* Метрики */
.b-metric {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 104px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid rgba(140, 84, 34, .13);
  box-shadow: var(--shadow-sm);
}

.b-metric::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--brand);
}

.b-metric:nth-child(2)::after { background: var(--gold); }
.b-metric:nth-child(3)::after { background: var(--sec); }
.b-metric:nth-child(4)::after { background: var(--good); }

.b-metric-num {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.b-metric-label { font-size: .88rem; font-weight: 700; }
.b-metric-hint { font-size: .78rem; color: var(--ink-3); }

/* Строка списка */
.b-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-action);
  background: rgba(255, 247, 236, .74);
  border: 1px solid rgba(140, 84, 34, .13);
  text-decoration: none;
  color: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .16s ease;
}

[data-theme="dark"] .b-item { background: rgba(46, 38, 30, .6); }

a.b-item:hover, button.b-item:hover { border-color: rgba(223, 153, 91, .42); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.b-item.active { background: #FFF2DA; border-color: rgba(223, 153, 91, .42); box-shadow: inset 4px 0 0 var(--brand); }

.b-item-main { flex: 1; min-width: 0; }

/* Перенос внутри слова обязателен: «Обществознание» рядом с несжимаемым
 * бейджем задаёт строке минимальную ширину больше, чем есть на телефоне, и
 * распирает всю страницу — горизонтальная прокрутка появлялась на 360 px. */
.b-item-title, .b-item-sub { overflow-wrap: anywhere; }
.b-item-title { font-size: .95rem; font-weight: 700; line-height: 1.32; }
.b-item-sub { font-size: .82rem; color: var(--ink-2); margin-top: 2px; }

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

.b-tile-ic {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-action);
  background: var(--brand-soft);
  color: var(--brand-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .62);
}

.b-tile-ic.sec { background: var(--sec-soft); color: var(--sec-ink); }
.b-tile-ic.good { background: var(--good-soft); color: var(--good-ink); }
.b-tile-ic.bad { background: var(--bad-soft); color: var(--bad-ink); }

/* ─── Метки ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(140, 84, 34, .12);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}

.badge.good { background: var(--good-soft); color: var(--good-ink); }
.badge.bad { background: var(--bad-soft); color: var(--bad-ink); }
.badge.warn { background: var(--gold-soft); color: var(--gold-ink); }
.badge.quiet { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
}

.chip:hover { border-color: rgba(223, 153, 91, .4); }
.chip.active { background: var(--brand-soft); color: var(--brand-deep); border-color: rgba(223, 153, 91, .42); }

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

/* Метки, идущие подряд в ячейке таблицы, обязаны разделяться: без зазора
 * «Обществознание» и «Химия» читаются как одно слово. */
.badge + .badge, .tag + .tag { margin-left: 6px; }

/* ─── Прогресс ──────────────────────────────────────────────────────────── */

.progress {
  position: relative;
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(31, 41, 55, .08);
  overflow: hidden;
}

[data-theme="dark"] .progress { background: rgba(245, 237, 224, .1); }

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #F3B880, var(--brand));
  transition: width var(--dur-smooth) var(--ease-spring);
}

.progress.good > span { background: linear-gradient(90deg, #7FD4AE, var(--good)); }
.progress.bad > span { background: linear-gradient(90deg, #F0A08E, var(--bad)); }

/* ─── Поля ──────────────────────────────────────────────────────────────── */

.b-field { display: block; }
.b-field + .b-field { margin-top: 14px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: .84rem;
  font-weight: 700;
  color: var(--ink-2);
}

.field-label .req { color: var(--brand-ink); }

.field {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(73, 111, 130, .18);
  background: rgba(255, 248, 236, .94);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

[data-theme="dark"] .field { background: rgba(36, 30, 23, .9); border-color: var(--line-2); box-shadow: none; }

.field::placeholder { color: var(--ink-3); }

.field:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(223, 153, 91, .18); }

textarea.field { min-height: 120px; resize: vertical; line-height: 1.55; font-size: .95rem; }
textarea.field.tall { min-height: 260px; }

.b-select-wrap { position: relative; }
.b-select-wrap select.field { appearance: none; padding-right: 40px; cursor: pointer; }
.b-select-ic { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); }

.b-hint { margin-top: 6px; font-size: .78rem; line-height: 1.5; color: var(--ink-3); }

.field-error { margin-top: 8px; font-size: .82rem; font-weight: 700; color: var(--bad-ink); }

.b-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: .9rem; line-height: 1.45; }
.b-check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); cursor: pointer; flex-shrink: 0; }

.b-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.b-row + .b-field, .b-field + .b-row, .b-row + .b-row { margin-top: 14px; }

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

.b-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}

.b-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; }

.b-table th, .b-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: .89rem;
  line-height: 1.4;
  vertical-align: middle;
}

.b-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-3);
  font-size: .8rem;
  font-weight: 800;
  color: var(--ink-2);
  white-space: nowrap;
  z-index: 1;
}

.b-table tbody tr:last-child td { border-bottom: 0; }
.b-table tbody tr:hover td { background: var(--surface-2); }
.b-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.b-table td.act { width: 1%; white-space: nowrap; }
.b-table .b-row-link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-ink); font-weight: 700; cursor: pointer; text-align: left; }
.b-table .b-row-link:hover { text-decoration: underline; }

/* ─── Состояния ─────────────────────────────────────────────────────────── */

.b-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
}

.b-empty-ic {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-action);
  background: var(--surface);
  color: var(--ink-3);
  border: 1px solid var(--line);
}

.b-empty h3 { font-size: 1rem; }
.b-empty p { max-width: 46ch; font-size: .88rem; color: var(--ink-2); line-height: 1.55; }

.b-error {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--bad-soft);
  border: 1px solid rgba(239, 68, 68, .28);
  color: var(--bad-ink);
}

.b-error-ic { flex-shrink: 0; }
.b-error b { display: block; font-size: .95rem; }
.b-error p { font-size: .85rem; line-height: 1.5; margin-top: 2px; }
.b-error .btn { margin-left: auto; flex-shrink: 0; }

.b-skeleton { display: grid; gap: 10px; }

.b-skeleton-row {
  display: block;
  height: 56px;
  border-radius: var(--radius-action);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: b-shimmer 1.4s ease infinite;
}

@keyframes b-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.b-note {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: var(--radius-action);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: .86rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.b-note .ic { color: var(--sec); margin-top: 1px; }
.b-note.warn { background: var(--gold-soft); border-color: rgba(245, 158, 11, .3); color: var(--gold-ink); }
.b-note.warn .ic { color: var(--gold-ink); }
.b-note.bad { background: var(--bad-soft); border-color: rgba(239, 68, 68, .28); color: var(--bad-ink); }
.b-note.bad .ic { color: var(--bad-ink); }

/* ─── Тосты и диалоги ───────────────────────────────────────────────────── */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  pointer-events: none;
}

.b-toast {
  display: block;
  max-width: min(440px, 92vw);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: .88rem;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  animation: b-slide-up var(--dur-fast) ease both;
}

.b-toast.good { background: var(--good-ink); }
.b-toast.warn { background: var(--gold-ink); }
.b-toast.bad { background: var(--bad-ink); }

@keyframes b-slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.b-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: clamp(14px, 4vw, 40px);
  background: rgba(31, 41, 55, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}

.b-dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  animation: b-bounce-in var(--dur-smooth) var(--ease-spring) both;
}

.b-dialog.wide { width: min(820px, 100%); }

@keyframes b-bounce-in {
  0% { transform: scale(.9); opacity: 0; }
  55% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

.b-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 14px;
}

.b-dialog-head h2 { font-size: 1.1rem; line-height: 1.25; }

.b-dialog-body { padding: 0 22px; overflow-y: auto; flex: 1; }
.b-dialog-text { font-size: .95rem; line-height: 1.6; color: var(--ink-2); }

.b-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px 20px;
}

.b-dialog #modal-error { padding: 0 22px; }

/* ─── Экран проверки ────────────────────────────────────────────────────── */

.b-check-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.b-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }

.b-page {
  position: relative;
  border-radius: var(--radius-action);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  aspect-ratio: 3 / 4;
}

.b-page img { width: 100%; height: 100%; object-fit: cover; display: block; }

.b-page-tag {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(31, 41, 55, .78);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
}

.b-page.bad { border-color: rgba(239, 68, 68, .4); }
.b-page-warn { position: absolute; right: 6px; top: 6px; color: var(--bad); background: #fff; border-radius: 50%; }

.b-page-add {
  display: grid;
  place-items: center;
  gap: 6px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-action);
  border: 1px dashed var(--line-2);
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-spring);
}

.b-page-add:hover { color: var(--brand-deep); border-color: var(--brand); background: var(--surface-3); }

/* Критерии в разборе */
.b-crit {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-action);
  background: var(--surface);
  border: 1px solid var(--line);
}

.b-crit + .b-crit { margin-top: 8px; }

.b-crit-code {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--good-soft);
  color: var(--good-ink);
  font-family: 'Unbounded', sans-serif;
  font-size: .76rem;
  font-weight: 800;
}

.b-crit.miss .b-crit-code { background: var(--bad-soft); color: var(--bad-ink); }
.b-crit.part .b-crit-code { background: var(--gold-soft); color: var(--gold-ink); }

.b-crit-text { font-size: .86rem; line-height: 1.5; color: var(--ink-2); min-width: 0; }
.b-crit-text b { display: block; color: var(--ink); font-size: .92rem; font-weight: 800; margin-bottom: 2px; }

.b-crit-score {
  font-family: 'Unbounded', sans-serif;
  font-size: .92rem;
  font-weight: 800;
  color: var(--good-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.b-crit.miss .b-crit-score { color: var(--bad-ink); }
.b-crit.part .b-crit-score { color: var(--gold-ink); }

.b-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--brand-deep);
  color: #fff;
}

.b-total-label { font-size: .86rem; font-weight: 700; opacity: .9; }

.b-total-value {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.b-answer {
  padding: 14px 16px;
  border-radius: var(--radius-action);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: .9rem;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
}

.b-recs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.b-recs li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.b-recs li .ic { color: var(--brand-ink); margin-top: 2px; }

/* Очередь пакета */
.b-queue { display: grid; gap: 8px; }

.b-queue-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-action);
  background: var(--surface);
  border: 1px solid var(--line);
}

.b-queue-n {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: .78rem;
  font-weight: 800;
}

.b-queue-row.done .b-queue-n { background: var(--good-soft); color: var(--good-ink); }
.b-queue-row.failed .b-queue-n { background: var(--bad-soft); color: var(--bad-ink); }
.b-queue-row.running .b-queue-n { background: var(--gold-soft); color: var(--gold-ink); }

/* ─── Тепловая карта ────────────────────────────────────────────────────── */

.b-heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }

.b-heat-cell {
  display: grid;
  gap: 2px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  text-align: center;
  background: var(--surface-2);
}

.b-heat-kim { font-family: 'Unbounded', sans-serif; font-size: .78rem; font-weight: 800; }
.b-heat-val { font-size: .72rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.b-heat-cell.l1 { background: var(--good-soft); border-color: rgba(16, 185, 129, .3); }
.b-heat-cell.l2 { background: #EAF0D8; border-color: rgba(120, 160, 80, .28); }
.b-heat-cell.l3 { background: var(--gold-soft); border-color: rgba(245, 158, 11, .3); }
.b-heat-cell.l4 { background: var(--bad-soft); border-color: rgba(239, 68, 68, .3); }

/* ─── Столбики ──────────────────────────────────────────────────────────── */

.b-bars { display: flex; align-items: flex-end; gap: 6px; height: 132px; padding-top: 10px; }

.b-bar { flex: 1; display: grid; align-content: end; gap: 6px; min-width: 0; }

.b-bar-fill {
  border-radius: 6px 6px 2px 2px;
  background: var(--brand);
  min-height: 3px;
  transition: height var(--dur-smooth) var(--ease-spring);
}

.b-bar-label {
  font-size: .64rem;
  color: var(--ink-3);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

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

@media (max-width: 1180px) {
  .b-split, .b-check-grid { grid-template-columns: minmax(0, 1fr); }
  .b-grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .b-shell { grid-template-columns: minmax(0, 1fr); }

  .b-rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 272px;
    transform: translateX(-100%);
    transition: transform var(--dur-smooth) var(--ease-spring);
    box-shadow: var(--shadow-lg);
  }

  .b-rail.open { transform: none; }

  .b-rail-scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(31, 41, 55, .4);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  .b-burger { display: inline-grid; }
  .b-topbar { padding: 12px 18px; }
  .b-view { padding: 20px 18px 80px; }
  .b-grid.k3, .b-grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .b-grid, .b-grid.k2, .b-grid.k3, .b-grid.k4 { grid-template-columns: minmax(0, 1fr); }
  .b-row { grid-template-columns: minmax(0, 1fr); }
  .b-topbar h1 { font-size: 1.05rem; }
  .b-topbar-actions .btn span { display: none; }
  .panel { padding: 17px; }
  .b-dialog-foot { flex-direction: column-reverse; }
  .b-dialog-foot .btn { width: 100%; }
  /* Бейдж состояния уходит на вторую строку, а не сдавливает текст в столбик
   * по одной букве. */
  .b-item { flex-wrap: wrap; }
  .b-item .badge { margin-left: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
