/*
 * Личный кабинет Vin-Scan (docs/Кабинет.md): общие стили страниц. Системные шрифты, без внешних ресурсов (M-11).
 * Встроенных стилей и скриптов на страницах нет: CSP сервера их не пропускает (cabinet/pages.ts). Иконки — спрайт
 * icons.svg (класс .i) и SVG в data: URI (CSP: img-src 'self' data:).
 * Вид — в духе виджета (apps/widget/src/styles.ts): синий акцент, те же нейтрали, знак — кнопка чата виджета
 * (облачко с тремя точками). Рамки полей темнее рамок карточек: контраст 3:1 с фоном (WCAG 1.4.11).
 * Шкалы: отступы кратны 4 px, скругление карточек 12 px, тени слоями (--shadow-*). Только светлая тема.
 */
:root {
  --accent: #1d5fd1;
  --accent-600: #174fb0;
  --accent-700: #123f96;
  --accent-50: #f5f8fe;
  --accent-100: #eef3fd;
  --accent-200: #dbe6fb;
  --accent-300: #b7c9ee;
  --navy: #0b1f4d;
  --text: #1c2530;
  --text-2: #344054;
  --muted: #5d6b7b;
  --border: #e3e9f0;
  --border-strong: #cfd9e4;
  --control: #8494a6;
  --control-hover: #5d6b7b;
  --bg: #f4f7fa;
  --surface: #fff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --error: #b42318;
  --error-bg: #fdeceb;
  --error-border: #f5c2bd;
  --ok: #17532a;
  --ok-bg: #e8f5ec;
  --ok-border: #b9e0c4;
  --ok-dot: #12b76a;
  --warn: #7a4a00;
  --warn-bg: #fff4e0;
  --warn-border: #f1d6a6;
  --warn-dot: #f79009;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-card: 12px;
  --radius-lg: 16px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --card-pad: 28px;
  --gutter: 32px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md:
    0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 8px -2px rgba(16, 24, 40, 0.06), 0 12px 24px -8px rgba(16, 24, 40, 0.1);
  --shadow-lg:
    0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 24px -6px rgba(16, 24, 40, 0.1), 0 32px 64px -24px rgba(16, 24, 40, 0.22);
  --shadow-pop: 0 4px 6px -2px rgba(16, 24, 40, 0.05), 0 16px 32px -6px rgba(16, 24, 40, 0.16);
  --shadow-accent: 0 1px 2px rgba(18, 63, 150, 0.24), 0 4px 10px -2px rgba(29, 95, 209, 0.32);
  --ring: 0 0 0 3px rgba(29, 95, 209, 0.28);
  --ring-error: 0 0 0 3px rgba(180, 35, 24, 0.2);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --sidebar-w: 256px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 24px;
}

/* Поле в фокусе не прячется под липкими кнопками формы (.form-actions, .save-bar) у нижнего края экрана. */
html:has(.form-actions, .save-bar) {
  scroll-padding-bottom: 96px;
}

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

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-600);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1 {
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2 {
  font-size: 17px;
  line-height: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

h3 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 650;
  margin: 0 0 12px;
}

[hidden] {
  display: none !important;
}

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

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

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(18, 183, 106, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0);
  }
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Иконка из спрайта icons.svg: цвет — currentColor, линия 2 px. */
.i {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

/* ---------- Знак ---------- */

/* Без gap: текст «Vin», «-» и «Scan» — отдельные узлы, gap разнёс бы их; отступ знака — margin-right. */
.logo {
  display: inline-flex;
  align-items: center;
  font-weight: 750;
  font-size: 18px;
  line-height: 24px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.1px;
  white-space: nowrap;
}

.logo:hover {
  color: var(--text);
}

/* Знак — кнопка чата виджета: синий круг, белое облачко с тремя точками (apps/widget/src/ui/icons.tsx). */
.logo::before {
  content: '';
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c-5.25 0-9.5 4.03-9.5 9s4.25 9 9.5 9c1.65 0 3.2-.4 4.5-1.1l4.3.75-.95-4.05c.75-1.35 1.15-2.9 1.15-4.6 0-4.97-4.25-9-9-9Z'/%3E%3Ccircle cx='7.5' cy='12' r='1.55' fill='white' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='1.55' fill='white' stroke='none'/%3E%3Ccircle cx='16.5' cy='12' r='1.55' fill='white' stroke='none'/%3E%3C/svg%3E")
    center / 20px 20px no-repeat;
  margin-right: 10px;
  box-shadow: var(--shadow-accent);
}

.logo span {
  color: var(--accent);
}

/* На тёмно-синем фоне: белый круг с синим облачком, белый текст. */
.logo.on-dark,
.logo.on-dark:hover,
.logo.on-dark span {
  color: #fff;
}

.logo.on-dark::before {
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d5fd1' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3c-5.25 0-9.5 4.03-9.5 9s4.25 9 9.5 9c1.65 0 3.2-.4 4.5-1.1l4.3.75-.95-4.05c.75-1.35 1.15-2.9 1.15-4.6 0-4.97-4.25-9-9-9Z'/%3E%3Ccircle cx='7.5' cy='12' r='1.55' fill='%231d5fd1' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='1.55' fill='%231d5fd1' stroke='none'/%3E%3Ccircle cx='16.5' cy='12' r='1.55' fill='%231d5fd1' stroke='none'/%3E%3C/svg%3E")
    center / 20px 20px no-repeat;
  box-shadow: 0 4px 14px rgba(3, 12, 36, 0.35);
}

/* ---------- Вход, регистрация, пароль: слева панель сервиса, справа форма ---------- */

.auth-layout {
  display: grid;
  grid-template-columns: minmax(440px, 45%) minmax(0, 1fr);
  min-height: 100vh;
}

.brand {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(96, 150, 255, 0.35), rgba(96, 150, 255, 0) 60%),
    linear-gradient(155deg, #1d5fd1 0%, #1748a6 34%, #0e2c6e 70%, #0a1c49 100%);
}

/* Точечная сетка: заметна наверху, к низу панели растворяется. */
.brand::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.5) 45%, transparent 90%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.5) 45%, transparent 90%);
}

.brand::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 420px;
  height: 420px;
  right: -140px;
  bottom: -160px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 0 60px rgba(255, 255, 255, 0.025),
    0 0 0 120px rgba(255, 255, 255, 0.02);
}

.brand-inner {
  height: 100%;
  max-width: 600px;
  margin-left: auto;
  padding: 40px 56px 48px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.brand-inner .logo {
  font-size: 20px;
  align-self: flex-start;
}

.brand-kicker {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #dbe6fb;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.brand-title {
  margin: 0;
  max-width: 15em;
  font-size: 32px;
  line-height: 40px;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.benefits {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.benefits li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.benefit-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.benefits li > span:last-child {
  font-size: 14px;
  line-height: 20px;
  color: #dbe6fb;
}

.benefits b {
  display: block;
  font-size: 15px;
  line-height: 22px;
  font-weight: 650;
  color: #fff;
}

/* Пример диалога: обычный HTML и CSS, без картинок. */
.chat-demo {
  margin-top: auto;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  color: var(--text);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow:
    0 2px 6px rgba(3, 12, 36, 0.18),
    0 24px 48px -12px rgba(3, 12, 36, 0.5);
}

.chat-demo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
  background: var(--accent);
}

.chat-demo-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.chat-demo-avatar .i {
  width: 18px;
  height: 18px;
}

.chat-demo-name {
  display: flex;
  flex-direction: column;
  flex: 1;
  font-size: 14px;
  line-height: 18px;
}

.chat-demo-name small {
  font-size: 12px;
  line-height: 16px;
  color: #dbe6fb;
}

.chat-demo-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #dbe6fb;
}

.chat-demo-online::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}

.chat-demo-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: #f4f7fb;
  font-size: 13px;
  line-height: 18px;
}

.bubble {
  margin: 0;
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 14px;
}

.bubble.me {
  align-self: flex-end;
  color: #fff;
  background: var(--accent);
  border-bottom-right-radius: 4px;
}

.bubble.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.part-card {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
}

.part-top,
.part-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.part-top b {
  font-size: 14px;
}

.part-name {
  color: var(--muted);
}

.stock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-bg);
  border-radius: 999px;
}

.stock::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.part-bottom code {
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 6px;
}

.part-bottom .price {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Правая часть: карточка формы по центру, внизу ссылки на документы. */
.auth-side {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  background: radial-gradient(900px 480px at 50% -160px, #e3ecfb 0, rgba(227, 236, 251, 0) 70%), var(--bg);
}

.auth {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise 0.35s var(--ease) both;
}

.auth.wide .auth-card {
  max-width: 560px;
}

.auth-card h1 {
  font-size: 26px;
  line-height: 34px;
  margin-bottom: 6px;
}

.auth-card > .lead {
  margin-bottom: 28px;
}

.auth form .btn.full {
  margin-top: 8px;
}

.card-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 14px;
  color: var(--accent);
  background: linear-gradient(180deg, var(--accent-100), var(--accent-200));
  box-shadow: inset 0 0 0 1px rgba(29, 95, 209, 0.12);
}

.card-badge .i {
  width: 24px;
  height: 24px;
}

.below {
  text-align: center;
  margin: 24px 0 0;
  color: var(--muted);
}

.below a {
  font-weight: 600;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.back-link .i {
  width: 18px;
  height: 18px;
}

.auth-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 20px;
}

/* Ссылки на документы внизу страниц: и у входа, и в кабинете. */
.footer a {
  color: var(--muted);
}

.footer a:hover {
  color: var(--text);
}

/* Путь подключения на странице регистрации: аккаунт → профиль → ABCP → код на сайт. */
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 28px;
  padding: 0;
  counter-reset: none;
}

.steps li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--muted);
}

/* Линия между шагами: от круга до следующего круга. */
.steps li + li::before {
  content: '';
  position: absolute;
  top: 14px;
  right: calc(50% + 18px);
  width: calc(100% - 28px);
  height: 2px;
  border-radius: 1px;
  background: var(--border-strong);
}

.step-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
}

.steps li[aria-current='step'] {
  color: var(--accent-700);
}

.steps li[aria-current='step'] .step-num {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-100);
}

/* ---------- Кабинет: боковое меню и основная колонка ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  /* Белая колонка меню до низа страницы, даже когда страница выше экрана (меню само — высотой с экран). */
  background: linear-gradient(
    90deg,
    var(--surface) calc(var(--sidebar-w) - 1px),
    var(--border) calc(var(--sidebar-w) - 1px) var(--sidebar-w),
    transparent var(--sidebar-w)
  );
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  top: 12px;
  color: #fff;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 16px 16px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 18px;
}

.sidebar .sidebar-close {
  display: none;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-weight: 550;
  color: var(--muted);
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.menu a .i {
  color: #7c8b9d;
  transition: color 0.15s ease;
}

.menu a:hover {
  color: var(--text);
  background: var(--surface-3);
}

.menu a:hover .i {
  color: var(--text-2);
}

.menu a:active {
  background: #e6ecf2;
}

.menu a:focus-visible {
  outline-offset: -2px;
}

.menu a[aria-current='page'] {
  font-weight: 650;
  color: var(--accent-700);
  background: var(--accent-100);
}

.menu a[aria-current='page'] .i {
  color: var(--accent);
}

/* Отметка раздела у края меню. */
.menu a[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
}

.balance {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: #fff;
  border-radius: var(--radius-card);
  background:
    radial-gradient(160px 90px at 100% 0%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 70%),
    linear-gradient(135deg, var(--accent) 0%, #1748a6 60%, #0e2c6e 100%);
  box-shadow: var(--shadow-accent);
}

.balance-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
}

.balance-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.balance small {
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #dbe6fb;
}

#balance {
  font-size: 18px;
  line-height: 24px;
  font-weight: 750;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 6px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-700);
  background: var(--accent-100);
  box-shadow: inset 0 0 0 1px rgba(29, 95, 209, 0.14);
}

.account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 13px;
  line-height: 18px;
}

.account-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-text b {
  font-size: 14px;
  font-weight: 600;
}

#account-email {
  color: var(--muted);
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(8, 21, 54, 0.45);
  animation: fade-in 0.2s ease both;
}

.app-main {
  --gutter: 32px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  container-type: inline-size;
}

/* Поля колонки: не меньше 32 px, на широком экране содержимое не шире 1120 px. */
@supports (width: 1cqw) {
  .app-main {
    --gutter: max(32px, calc((100cqw - 1120px) / 2));
  }
}

.appbar {
  display: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text-2);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.icon-btn:active {
  background: #e3e9f0;
}

.page {
  flex: 1 0 auto;
  width: 100%;
  padding: 0 var(--gutter) var(--sp-12);
}

/* Шапка страницы: название, пояснение, главное действие — белая полоса во всю ширину колонки. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin: 0 calc(-1 * var(--gutter)) 28px;
  padding: 32px var(--gutter) 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-title {
  flex: 1 1 360px;
  min-width: 0;
}

.page-head h1 {
  margin: 0;
}

.page-desc {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.title-row h1 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}

.crumb .i {
  width: 18px;
  height: 18px;
}

.crumb:hover {
  color: var(--accent);
}

.notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
}

.notice:empty {
  display: none;
}

.notice::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn-dot);
}

/* Пока страница грузит данные (main#page скрыт), на её месте — заготовка: шапка и две карточки. */
.skeleton {
  display: none;
  flex: 1 0 auto;
}

#page[hidden] ~ .skeleton {
  display: block;
}

.sk-head {
  display: grid;
  gap: 12px;
  padding: 36px var(--gutter) 28px;
  margin-bottom: 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.sk-body {
  display: grid;
  gap: 20px;
  padding: 0 var(--gutter);
}

.sk-card {
  display: grid;
  gap: 14px;
  padding: var(--card-pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.sk-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e8edf3 0%, #f4f7fa 40%, #e8edf3 80%) 0 0 / 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk-line.lg {
  height: 22px;
  border-radius: 8px;
}

.w30 {
  width: 30%;
}
.w40 {
  width: 40%;
}
.w50 {
  width: 50%;
}
.w60 {
  width: 60%;
}
.w70 {
  width: 70%;
}
.w80 {
  width: 80%;
}

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

.card {
  min-width: 0;
  margin: 0 0 20px;
  padding: var(--card-pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.lead {
  color: var(--muted);
  margin: 0 0 20px;
}

.spaced {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.card-head h2,
.card-head h3 {
  margin: 2px 0;
  font-size: 17px;
  line-height: 24px;
}

.card-head .lead {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.card-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--accent);
  background: linear-gradient(180deg, var(--accent-100), var(--accent-200));
  box-shadow: inset 0 0 0 1px rgba(29, 95, 209, 0.12);
}

/* Пустое состояние: картинка, заголовок, пояснение, действие. */
.empty,
.empty-card {
  text-align: center;
  padding: 40px 24px 44px;
}

.empty {
  color: var(--muted);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-card);
}

.empty h2,
.empty-card h2 {
  margin: 4px 0 6px;
  color: var(--text);
}

.empty p,
.empty-card .lead {
  max-width: 520px;
  margin: 0 auto 20px;
}

.empty-art {
  display: block;
  width: 200px;
  height: 140px;
  margin: 0 auto 4px;
}

.mini-steps {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.mini-steps li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.mini-steps .i {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

/* ---------- Поля формы ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.grid .wide {
  grid-column: 1 / -1;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.field {
  margin-bottom: 18px;
  min-width: 0;
}

.field label,
.field .label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  margin-bottom: 6px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.label-row .label-link {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  text-decoration: none;
}

.label-row .label-link:hover {
  text-decoration: underline;
}

/* Галочка или переключатель внутри поля — не подпись поля: строка, обычный вес (иначе их перекрывает .field label). */
.field .check {
  display: flex;
  font-weight: 400;
  margin-bottom: 10px;
}

.field .hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  margin-top: 6px;
}

.field .label + .hint {
  margin: -2px 0 8px;
}

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='url'],
input[type='number'],
input[type='time'],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  /* 16px — без автоувеличения страницы в Safari на iPhone. */
  font-size: 16px;
  line-height: 22px;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--control-hover);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Галочки и переключатели: box-shadow на них WebKit не рисует — фокус контуром. */
input[type='checkbox']:focus-visible,
input[type='radio']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

input[readonly],
input[readonly]:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: none;
  color: var(--muted);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

/*
 * Проверка на месте: поле, которое пользователь уже трогал и заполнил неверно (email, обязательное). Кроме type=url:
 * сайт без https:// сервер принимает и дополняет сам (cabinet/validate.ts), а браузер считал бы его ошибкой.
 */
input:not([type='url']):user-invalid,
textarea:user-invalid,
select:user-invalid {
  border-color: var(--error);
}

input:not([type='url']):user-invalid:focus,
textarea:user-invalid:focus {
  box-shadow: var(--ring-error);
}

.field:has(input:not([type='url']):user-invalid, textarea:user-invalid) label,
.field:has(input:not([type='url']):user-invalid, textarea:user-invalid) .hint {
  color: var(--error);
}

/* Ошибка сохранения, которую сервер отнёс к полю (form-result.js): красная рамка, подпись и текст под полем. */
input[aria-invalid='true'],
textarea[aria-invalid='true'],
select[aria-invalid='true'],
input[aria-invalid='true']:hover,
textarea[aria-invalid='true']:hover,
select[aria-invalid='true']:hover {
  border-color: var(--error);
  box-shadow: var(--ring-error);
}

input[type='checkbox'][aria-invalid='true'] {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

.field:has([aria-invalid='true']) > label,
.field:has([aria-invalid='true']) > .label {
  color: var(--error);
}

.field-error {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 6px;
  color: var(--error);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  animation: rise 0.2s var(--ease) both;
}

.field-error::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background: center / 16px 16px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b42318' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5v.01'/%3E%3C/svg%3E");
}

/* Телефоны: текст ошибки под строкой номера, до следующей строки. */
.phones .field-error {
  margin: -2px 0 8px;
}

/* Поле с иконкой слева и (для пароля) кнопкой «показать» справа. */
.control {
  position: relative;
}

.control > .lead-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: #7c8b9d;
  pointer-events: none;
  transition: color 0.15s ease;
}

.control:focus-within > .lead-icon {
  color: var(--accent);
}

.control:has(> .lead-icon) > input {
  padding-left: 42px;
}

.control.has-reveal > input {
  padding-right: 48px;
}

.reveal {
  position: absolute;
  right: 4px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.reveal:hover {
  color: var(--text);
  background: var(--surface-3);
}

.reveal:focus-visible {
  outline-offset: -2px;
}

.reveal .i {
  width: 18px;
  height: 18px;
}

select {
  padding-right: 40px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6b7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    right 12px center / 18px 18px no-repeat;
  cursor: pointer;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input[type='number'] {
  font-variant-numeric: tabular-nums;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
}

.check input {
  margin: 1px 0 0;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.check a {
  font-weight: 500;
}

/* Переключатель «вкл/выкл» вместо галочки: плашка с заголовком и пояснением. */
.check.toggle {
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.check.toggle:hover {
  border-color: var(--border-strong);
}

.check.toggle:has(:checked) {
  background: var(--accent-50);
  border-color: var(--accent-300);
}

.check.toggle input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--control);
  transition: background-color 0.2s ease;
}

.check.toggle input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.3);
  transition: transform 0.2s var(--ease);
}

.check.toggle input:checked {
  background: var(--accent);
}

.check.toggle input:checked::before {
  transform: translateX(16px);
}

.check.toggle b {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.check.toggle span {
  color: var(--muted);
}

#consents {
  margin: 4px 0 16px;
  padding: 14px 16px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

#consents:empty {
  display: none;
}

/* Выбор из двух (кнопка чата справа или слева, окно или весь экран): варианты-плашки. */
.field[role='radiogroup'] .options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field[role='radiogroup'] .check {
  flex: 1 1 120px;
  margin: 0;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.field[role='radiogroup'] .check:hover {
  border-color: var(--control-hover);
}

.field[role='radiogroup'] .check:has(:checked) {
  border-color: var(--accent);
  background: var(--accent-50);
  color: var(--accent-600);
  font-weight: 600;
}

.field[role='radiogroup'] .check:has(:focus-visible) {
  box-shadow: var(--ring);
}

.counter {
  float: right;
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Ловушка для ботов: вне экрана, недоступна с клавиатуры и экранному диктору. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.captcha {
  min-height: 100px;
  margin-bottom: 16px;
}

/* Телефоны 1-5 */
.phones .row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.phones .row .btn {
  flex: none;
}

.phones > .btn.link {
  margin-top: 2px;
}

/* Разделы формы: заголовок с иконкой, между разделами — линия. */
.form-section + .form-section {
  margin-top: 6px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 22px;
}

.section-title .i {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-100);
}

fieldset {
  min-width: 0;
  margin: 0 0 20px;
}

fieldset.card {
  padding: var(--card-pad);
}

/* Подсказки DaData: всплывающий список компаний под полем названия. */
.suggest {
  position: relative;
}

.suggest ul {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  margin: 6px 0 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  animation: rise 0.16s var(--ease) both;
}

.suggest ul::before {
  content: 'Найдено в ЕГРЮЛ и ЕГРИП';
  display: block;
  padding: 6px 10px 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.suggest li button {
  display: grid;
  grid-template-columns: 32px 1fr;
  column-gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.suggest li button::before {
  content: '';
  grid-row: 1 / span 2;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-100)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d5fd1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4.5' y='3' width='15' height='18' rx='2'/%3E%3Cpath d='M9.5 21v-4h5v4M8.5 7h.01M12 7h.01M15.5 7h.01M8.5 11h.01M12 11h.01M15.5 11h.01'/%3E%3C/svg%3E")
    center / 18px 18px no-repeat;
}

.suggest li button:hover,
.suggest li button:focus {
  background: var(--accent-50);
  outline: none;
}

.suggest li button:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.suggest li small {
  display: block;
  grid-column: 2;
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  line-height: 20px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn .i {
  width: 18px;
  height: 18px;
}

.btn:hover {
  color: #fff;
  background: var(--accent-600);
  border-color: var(--accent-600);
}

.btn:active {
  transform: translateY(1px);
  background: var(--accent-700);
  box-shadow: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Запрос идёт (withBusy в api.js ставит aria-busy): кольцо загрузки рядом с текстом кнопки. */
.btn[aria-busy='true'] {
  opacity: 0.85;
  cursor: progress;
}

.btn[aria-busy='true']::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.secondary {
  color: var(--text-2);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.btn.secondary .i {
  color: var(--muted);
}

.btn.secondary:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: #b9c5d3;
}

.btn.secondary:active {
  background: var(--surface-3);
}

.btn.secondary:focus-visible {
  box-shadow: var(--ring);
}

.btn.ghost {
  color: var(--muted);
  background: none;
  border-color: transparent;
  box-shadow: none;
}

.btn.ghost:hover {
  color: var(--text);
  background: var(--surface-3);
}

.btn.danger {
  color: var(--error);
  background: none;
  border-color: transparent;
  box-shadow: none;
}

.btn.danger .i {
  color: currentColor;
}

.btn.danger:hover {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.btn.link {
  min-height: 0;
  padding: 4px 0;
  color: var(--accent);
  background: none;
  border: 0;
  box-shadow: none;
  font-weight: 600;
}

.btn.link:hover {
  color: var(--accent-600);
  background: none;
  text-decoration: underline;
}

.btn.link:active {
  transform: none;
}

.btn.sm {
  min-height: 36px;
  padding: 0 12px;
  gap: 6px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn.sm .i {
  width: 16px;
  height: 16px;
}

.btn.lg {
  min-height: 48px;
  font-size: 16px;
}

.btn.full {
  width: 100%;
}

/* Кнопка на тёмном фоне (блок кода). */
.btn.on-dark {
  color: #e6edf7;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.btn.on-dark:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

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

/* Кнопки формы: внизу карточки, при прокрутке длинной формы остаются у нижнего края экрана. */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 8px calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad));
  padding: 16px var(--card-pad);
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#abcp-choice .form-actions {
  position: static;
  margin: 4px 0 0;
  padding: 20px 0 0;
  background: none;
}

.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 2;
  justify-content: flex-end;
  margin: 0 0 32px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ---------- Сообщения: ошибка и «готово» (showMessage в api.js), уведомления (toast в ui.js) ---------- */

.form-error,
.form-ok {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--radius);
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 20px;
  animation: rise 0.2s var(--ease) both;
}

.form-error::before,
.form-ok::before {
  content: '';
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: center / 18px 18px no-repeat;
}

.form-error {
  color: var(--error);
  background: var(--error-bg);
  border-color: var(--error-border);
}

.form-error::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b42318' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5v.01'/%3E%3C/svg%3E");
}

.form-ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.form-ok::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2317532a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12.5 2.8 2.8L16.5 9.5'/%3E%3C/svg%3E");
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: #fff;
  background: #13213b;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition:
    opacity 0.2s ease,
    transform 0.25s var(--ease);
}

.toast.in {
  opacity: 1;
  transform: none;
}

.toast .i {
  color: #86efac;
}

.toast.error .i {
  color: #fca5a5;
}

/* Две области aria-live (ui.js): «готово» и ошибки, одна над другой. */
.toasts > div {
  display: grid;
  justify-items: center;
  gap: 8px;
}

/* Ошибку, которой больше нигде на странице не видно, закрывают сами: у неё крестик. */
.toast.sticky {
  padding-right: 6px;
  pointer-events: auto;
}

.toast-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toast-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.toast .toast-close .i {
  color: #fff;
}

/*
 * Липкие кнопки формы у нижнего края: уведомление над ними, а не поверх только что нажатой «Сохранить». На странице
 * виджетов кнопки есть только в открытой форме виджета, у списка уведомление на обычном месте.
 */
html:has(.form-actions, .save-bar):not(:has(#edit-view[hidden])) .toasts {
  bottom: 104px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  padding: 24px 16px 32px;
}

/* ---------- Виджеты: список, статусы, вкладки (widgets.html) ---------- */

.inline-form {
  display: flex;
  gap: 8px;
  flex: 1 1 460px;
  max-width: 600px;
  min-width: 0;
}

.inline-form input {
  flex: 1;
  min-width: 0;
}

.cards {
  display: grid;
  gap: 16px;
}

.cards .card {
  margin: 0;
}

.shop-card {
  padding: 20px 24px;
  animation: rise 0.25s var(--ease) both;
  transition:
    border-color 0.15s ease,
    box-shadow 0.2s ease;
}

.shop-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.shop-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-card);
  color: #fff;
  background: linear-gradient(145deg, #3b7be6, var(--accent) 45%, var(--accent-700));
  box-shadow: var(--shadow-accent);
}

.shop-card.off .shop-icon {
  color: var(--muted);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
}

.shop-title {
  flex: 1;
  min-width: 0;
}

.shop-title h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.shop-meta .i {
  width: 14px;
  height: 14px;
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0 58px;
  padding: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 8px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow-wrap: anywhere;
}

.chip .i {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.chip.none {
  color: var(--muted);
  background: none;
  border-style: dashed;
  border-color: var(--border-strong);
}

.shop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.shop-actions .danger {
  margin-left: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge:empty {
  display: none;
}

.badge.working {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.badge.working::before {
  background: var(--ok-dot);
  animation: pulse 2s ease-out infinite;
}

.badge.disabled {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--border);
}

.badge.disabled::before {
  background: #98a2b3;
}

.badge.pending_abcp {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.badge.pending_abcp::before {
  background: var(--warn-dot);
}

/* Запуск виджета: четыре шага с отметками (widgets.js, onboarding). */
.onboarding {
  padding: 22px 24px 24px;
  background: radial-gradient(520px 160px at 100% 0%, var(--accent-100), rgba(238, 243, 253, 0) 70%), var(--surface);
}

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

.onboarding-head h2 {
  margin: 0;
}

.onboarding-head .lead {
  margin: 2px 0 0;
  font-size: 14px;
}

.onboarding-count {
  flex: none;
  padding: 4px 12px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
  color: var(--accent-700);
  background: var(--accent-100);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 6px;
  margin: 16px 0 18px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 999px;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #4c8bf0);
  transition: width 0.5s var(--ease);
}

.onboarding-steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
}

.onb-step {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.onb-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
}

.onb-mark .i {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.onb-step b {
  font-size: 14px;
  line-height: 20px;
}

.onb-step small {
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.onb-step .btn.link {
  margin-top: auto;
  padding-top: 8px;
  font-size: 14px;
}

.onb-step.done {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.onb-step.done .onb-mark {
  color: #fff;
  background: var(--ok-dot);
  border-color: var(--ok-dot);
}

.onb-step.done small {
  color: var(--ok);
}

/* Вкладки с иконками: подчёркнутая активная вкладка. */
.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-strong);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 46px;
  margin-bottom: -1px;
  padding: 0 14px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.tabs button .i {
  width: 18px;
  height: 18px;
}

.tabs button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.tabs button[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tabs button:focus-visible,
.segmented button:focus-visible {
  outline-offset: -2px;
}

.tab-panel > .card:last-child {
  margin-bottom: 0;
}

.hours {
  display: grid;
  gap: 8px;
}

.hours-row {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background-color 0.15s ease;
}

.hours-row:hover {
  background: var(--surface-2);
}

.hours-row .day {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  font-weight: 650;
  font-size: 14px;
  color: var(--accent-700);
  background: var(--accent-100);
  border-radius: var(--radius-sm);
}

.hours-row input[type='time'] {
  width: 124px;
  min-height: 40px;
  padding: 8px 10px;
}

.hours-row .check {
  margin: 0 0 0 6px;
  color: var(--muted);
}

.hours-row:has(.off:checked) .day {
  color: var(--muted);
  background: var(--surface-3);
}

.hours-row:has(.off:checked) input[type='time'] {
  opacity: 0.45;
}

#w-budget {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ABCP: подсказка про IP, статус проверки, результат проверки списком. */
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 22px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 20px;
  color: var(--accent-700);
  background: var(--accent-50);
  border: 1px solid var(--accent-200);
  border-radius: var(--radius);
}

.callout:empty {
  display: none;
}

.callout::before {
  content: '';
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23123f96' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5M12 7.5v.01'/%3E%3C/svg%3E")
    center / 18px 18px no-repeat;
}

.verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.verified::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.verified.ok {
  color: var(--ok);
  font-weight: 600;
}

.verified.ok::before {
  background: var(--ok-dot);
}

.checks {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.checks li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 20px;
  animation: rise 0.25s var(--ease) both;
}

.checks li + li {
  border-top: 1px solid var(--border);
  animation-delay: 0.08s;
}

.checks li .i {
  width: 22px;
  height: 22px;
  margin-top: -1px;
}

.checks li b {
  display: block;
  font-weight: 600;
}

.checks li.ok .i {
  color: var(--ok-dot);
}

.checks li.fail {
  background: var(--error-bg);
}

.checks li.fail .i,
.checks li.fail b {
  color: var(--error);
}

.checks li .state {
  margin-left: auto;
  padding-left: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.checks li.ok .state {
  color: var(--ok);
}

.checks li.fail .state {
  color: var(--error);
}

.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
  padding: 14px 16px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.checks-grid:empty {
  display: none;
}

#abcp-choice {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Внешний вид: цвет, код цвета, готовые образцы. */
.color-field .row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-field input[type='color'] {
  width: 52px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.hex {
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 6px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch, #fff);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s ease;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch[aria-pressed='true'] {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--accent);
}

.swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Форма слева, рядом — окно браузера с настоящим виджетом (widgets.js переносит виджет в .preview-stage). */
.tab-panel.look:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.look-note .when-overlay {
  display: none;
}

.look-preview {
  position: sticky;
  top: 0;
}

.browser-mock {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.browser-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #f7f9fb, #eef2f6);
  border-bottom: 1px solid var(--border);
}

.browser-dots {
  display: flex;
  gap: 6px;
}

.browser-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f5b5ae;
}

.browser-dots i:nth-child(2) {
  background: #f7d49a;
}

.browser-dots i:nth-child(3) {
  background: #a9dcb8;
}

.browser-address {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
}

.browser-address .i {
  width: 13px;
  height: 13px;
  color: var(--ok-dot);
}

.browser-address span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
 * transform делает блок опорным для position:fixed внутри: окно и кнопка виджета держатся его углов. Высота — с экран:
 * виджет считает свою наибольшую высоту и режим «на весь экран» от окна браузера (apps/widget/src/ui/app/resize.tsx),
 * и в рамке ниже экрана развёрнутое окно чата обрезалось бы сверху вместе с кнопками «свернуть» и «закрыть».
 * Адресная строка лежит внутри рамки: развёрнутое окно чата закрывает её, как закрыло бы шапку сайта.
 */
.preview-stage {
  position: relative;
  height: 100vh;
  min-height: 480px;
  overflow: hidden;
  transform: translateZ(0);
  background: #f6f8fb;
}

.fake-site {
  display: grid;
  gap: 18px;
  padding: 66px 20px 16px;
}

.fake-site i {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: #e3e9f0;
}

.fake-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e8edf3;
}

.fake-nav i {
  width: 48px;
}

.fake-nav .fake-logo {
  width: 72px;
  height: 18px;
  margin-right: auto;
  background: #cfdcf3;
}

.fake-hero {
  display: grid;
  gap: 10px;
  padding: 22px 20px;
  background: #fff;
  border: 1px solid #e8edf3;
  border-radius: var(--radius-card);
}

.fake-hero .w60 {
  height: 16px;
}

.fake-hero .fake-btn {
  width: 110px;
  height: 30px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  background: #cfdcf3;
}

.fake-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.fake-grid i {
  height: 96px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid #e8edf3;
}

.fake-lines {
  display: grid;
  gap: 10px;
}

.preview-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 4px 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

.preview-hint .i {
  width: 16px;
  height: 16px;
}

/* Код для вставки: шаги, тёмный блок кода с кнопкой «Копировать», статус установки. */
.install-steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
}

.install-steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.install-steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-700);
  background: var(--accent-100);
  border-radius: 50%;
}

.code-block {
  overflow: hidden;
  background: #0f1b33;
  border: 1px solid #0b1528;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
}

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  background: #14223f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-lang {
  margin-right: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #9fb3d9;
}

.copied {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #86efac;
  animation: fade-in 0.2s ease both;
}

.copied .i {
  width: 16px;
  height: 16px;
}

pre.code {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #e6edf7;
  background: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 20px;
}

.install {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 20px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

/* Пустая — без рамки и отступов, но в дереве доступности (role=status): первое сообщение будет прочитано. */
.install:empty {
  margin: 0;
  padding: 0;
  border: 0;
}

.install:empty::before {
  display: none;
}

.install::before {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--control);
}

.install.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.install.ok::before {
  background: var(--ok-dot);
  animation: pulse 2s ease-out infinite;
}

/* ---------- Профиль ---------- */

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.section-nav a .i {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.section-nav a:hover {
  color: var(--text);
  background: var(--accent-50);
  border-color: var(--accent-300);
}

.group-head {
  margin: 36px 0 16px;
}

.group-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
}

.group-head .lead {
  margin: 4px 0 0;
}

/* ---------- Широкий экран: форма вида и предпросмотр рядом ---------- */

@media (min-width: 1280px) {
  .tab-panel.look:not([hidden]) {
    grid-template-columns: minmax(0, 1fr) 440px;
  }
}

/*
 * Телефон и планшет с пальцевым вводом: виджет открывается поверх страницы, как на сайте магазина, и сам блокирует
 * прокрутку (apps/widget/src/mobile.ts) — окна-рамки нет. Условие то же, что у виджета (MOBILE_QUERY) и в widgets.js.
 */
@media (max-width: 480px), (pointer: coarse) {
  .look-preview,
  .look-note .when-framed {
    display: none;
  }

  .look-note .when-overlay {
    display: inline;
  }
}

@media (max-width: 1100px) {
  .onboarding-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- До 960 px: меню — шторка слева, форма входа под синей полосой ---------- */

@media (max-width: 960px) {
  html {
    scroll-padding-top: 76px;
  }

  .app {
    display: block;
    background: none;
  }

  .appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .appbar .logo {
    font-size: 17px;
  }

  .appbar .logo::before {
    width: 30px;
    height: 30px;
    background-size: 18px 18px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(280px, 80vw);
    height: auto;
    border-right: 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.25s var(--ease),
      visibility 0s linear 0.25s;
  }

  .drawer-open {
    overflow: hidden;
  }

  .drawer-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.25s var(--ease);
  }

  .sidebar .sidebar-close {
    display: grid;
  }

  .auth-layout {
    display: block;
  }

  .brand {
    position: relative;
    height: auto;
  }

  .brand-inner {
    max-width: none;
    margin: 0;
    padding: 18px 20px 84px;
    gap: 14px;
  }

  .brand-kicker,
  .benefits,
  .chat-demo {
    display: none;
  }

  .brand-title {
    max-width: 22em;
    font-size: 19px;
    line-height: 26px;
  }

  /* Карточка формы наезжает на синюю полосу: position — чтобы рисоваться поверх неё. */
  .auth-side {
    position: relative;
    min-height: 0;
    background: none;
  }

  .auth {
    align-items: flex-start;
    margin-top: -64px;
    padding: 0 16px 8px;
  }

  .auth-card {
    padding: 28px 22px;
  }
}

/* ---------- Узкий экран: до 640 px, проверено от 360 px ---------- */

@media (max-width: 640px) {
  :root {
    --card-pad: 18px;
  }

  .app-main {
    --gutter: 16px;
  }

  h1,
  .page-head h1 {
    font-size: 24px;
    line-height: 32px;
  }

  .page-head {
    margin-bottom: 20px;
    padding: 20px var(--gutter) 18px;
  }

  .page-title {
    flex-basis: 100%;
  }

  .sk-head {
    padding: 24px var(--gutter) 20px;
    margin-bottom: 20px;
  }

  .grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .card {
    margin-bottom: 16px;
  }

  .card-head {
    gap: 12px;
    margin-bottom: 18px;
  }

  .card-icon {
    width: 36px;
    height: 36px;
  }

  .auth-card h1 {
    font-size: 22px;
    line-height: 30px;
  }

  .steps {
    gap: 4px;
  }

  .steps li {
    font-size: 11px;
    line-height: 14px;
  }

  .inline-form {
    flex: 1 1 100%;
    flex-direction: column;
  }

  .form-actions .btn,
  .save-bar .btn {
    flex: 1 1 100%;
  }

  html:has(.form-actions, .save-bar) {
    scroll-padding-bottom: 150px;
  }

  /* Кнопки формы на всю ширину, две — друг под другом. */
  html:has(.form-actions, .save-bar):not(:has(#edit-view[hidden])) .toasts {
    bottom: 156px;
  }

  /*
   * Предпросмотр открыт поверх страницы (виджет в body, см. widgets.js placePreview): его кнопка чата в правом нижнем
   * углу экрана. Липкие кнопки формы уступают ей место справа, иначе кнопка ложится на «Сохранить».
   */
  body:has(> aibot-widget) .form-actions {
    padding-right: 84px;
  }

  .save-bar {
    bottom: 8px;
  }

  .shop-card {
    padding: 16px;
  }

  .shop-icon {
    width: 40px;
    height: 40px;
  }

  /* Название целиком (в две строки, если длинное), статус — под ним. */
  .shop-top {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 8px;
  }

  .shop-top .badge {
    grid-column: 2;
    justify-self: start;
  }

  .shop-title h2 {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .chips {
    margin-left: 0;
  }

  .shop-actions .btn {
    flex: 1 1 auto;
  }

  .shop-actions .danger {
    margin-left: 0;
  }

  /* Четыре вкладки не помещаются в строку: сетка 2×2, все видны без прокрутки. */
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    background: #e6edf3;
    border: 0;
    border-radius: var(--radius-card);
  }

  .tabs button {
    justify-content: center;
    min-height: 42px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: 9px;
  }

  .tabs button[aria-selected='true'] {
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }

  .onboarding {
    padding: 18px 16px;
  }

  .onboarding-steps {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .onb-step {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 0;
    padding: 10px 12px;
  }

  .onb-mark {
    grid-row: 1 / span 2;
    margin: 0;
  }

  .onb-step b,
  .onb-step small {
    grid-column: 2;
  }

  .onb-step .btn.link {
    grid-column: 3;
    grid-row: 1 / span 2;
    margin: 0;
    padding: 0;
  }

  /* День, «с» и «до» в строку, «выходной» — под временем, по левому краю поля «с». */
  .hours {
    gap: 12px;
  }

  .hours-row {
    display: grid;
    grid-template-columns: 36px 1fr auto 1fr;
    gap: 6px 8px;
    padding: 0;
  }

  .hours-row:hover {
    background: none;
  }

  .hours-row input[type='time'] {
    width: 100%;
  }

  .hours-row .check {
    grid-column: 2 / -1;
    margin: 0;
  }

  .code-head {
    padding-left: 12px;
  }

  .section-nav a {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .group-head {
    margin-top: 28px;
  }
}

/* ---------- Статистика (stats.html, docs/Кабинет.md, раздел 14) ---------- */

/* Цвета графиков: синий акцент — вопросы, зелёный — ответы. */
.stats-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.stats-controls select {
  width: auto;
  min-width: 200px;
  max-width: 280px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-card);
}

.stats-gauges,
.stats-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 16px;
}

.stats-gauges .card,
.stats-numbers .card {
  margin-bottom: 16px;
}

.gauge {
  text-align: center;
}

.gauge h2 {
  font-size: 15px;
  line-height: 20px;
  margin-bottom: 8px;
}

.gauge svg {
  width: 100%;
  max-width: 220px;
  display: block;
  margin: 0 auto;
}

.gauge-value {
  font-size: 30px;
  font-weight: 700;
  fill: var(--text);
}

.gauge-caption {
  color: var(--muted);
  margin: 4px 0 8px;
  font-size: 14px;
}

.level {
  display: inline-block;
  font-size: 12px;
  line-height: 18px;
  padding: 0 8px;
  border-radius: 9px;
}

.level.low {
  background: #fdeceb;
  color: #b42318;
}

.level.mid {
  background: #fef4e6;
  color: #93500b;
}

.level.good {
  background: #e8f5ec;
  color: #17532a;
}

/* Итоги периода: карточка с иконкой показателя (stats.js, numbers). */
.number {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 14px;
}

.kpi-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-card);
  color: var(--accent);
  background: var(--accent-100);
}

.kpi-icon.a {
  color: #0f7a4a;
  background: #e3f6ec;
}

.kpi-icon.n {
  color: #a15c07;
  background: #fff1dc;
}

.kpi-icon.o {
  color: #6d28d9;
  background: #f1ebfe;
}

.number b {
  font-size: 28px;
  line-height: 34px;
  font-variant-numeric: tabular-nums;
}

.number span {
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.stats-rings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 16px;
}

.ring svg {
  width: 140px;
  height: 140px;
  display: block;
  margin: 0 auto 12px;
}

.ring-total {
  font-size: 20px;
  font-weight: 700;
  fill: var(--text);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.legend li span {
  flex: 1;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.dot.q {
  background: var(--accent);
}

.dot.a {
  background: #12b76a;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--muted);
  margin: -8px 0 8px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

svg.daily {
  width: 100%;
  height: auto;
  display: block;
}

.daily .axis line {
  stroke: #e4e9ef;
}

.daily text {
  font-size: 11px;
  fill: var(--muted);
}

.daily .bar.q {
  fill: var(--accent);
}

.daily .bar.a {
  fill: #12b76a;
}

.daily .hit {
  fill: transparent;
}

.daily g:hover .hit {
  fill: rgba(29, 95, 209, 0.06);
}

.hbars {
  display: grid;
  gap: 10px;
}

.hbar {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.hbar .name {
  font-size: 14px;
}

.hbar .track {
  height: 12px;
  background: #eef2f6;
  border-radius: 6px;
  overflow: hidden;
}

.hbar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.hbar b {
  min-width: 40px;
  text-align: right;
}

.hbar .conv {
  color: var(--muted);
  min-width: 44px;
  text-align: right;
}

.stats-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.order-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.order-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.order-row div {
  display: flex;
  flex-direction: column;
}

.order-row b {
  font-size: 18px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .stats-gauges,
  .stats-numbers {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-rings,
  .stats-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .stats-gauges,
  .stats-numbers {
    gap: 0 8px;
  }

  .stats-gauges .card,
  .stats-numbers .card {
    margin-bottom: 8px;
    padding: 12px;
  }

  .gauge-value {
    font-size: 34px;
  }

  .number b {
    font-size: 22px;
  }

  .number {
    column-gap: 10px;
  }

  .kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
  }

  .kpi-icon .i {
    width: 18px;
    height: 18px;
  }

  .number span {
    font-size: 13px;
    line-height: 18px;
  }

  .stats-controls {
    width: 100%;
  }

  .stats-controls select {
    flex: 1 1 100%;
    max-width: none;
  }

  .hbar {
    grid-template-columns: 1fr auto auto;
    gap: 4px 8px;
  }

  .hbar .track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ---------- Без анимаций, если так настроена система ---------- */

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

/* ---------- Вход поддержки: баннер над страницей (ui.js, showAccount) ---------- */

.support-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 20px;
  color: #7a2e0e;
  background: #fff4e5;
  border-bottom: 1px solid #f7c48b;
}

.support-banner .i {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
