/* MOLNI — design system.
   Тёмно-графитовый/пихтовый по умолчанию + бирюзовый primary + янтарный accent.
   Осознанно НЕ используем стоковый Tailwind indigo/blue и Inter/Roboto. */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@500;600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  /* Тёмная тема — теперь основная (не только через prefers-color-scheme),
     см. раздел 15 ТЗ ребрендинга MOLNI. */
  --color-bg: #0e1917;
  --color-surface: #16241f;
  --color-surface-2: #1b2c26;
  --color-border: #2f423a;
  --color-ink: #e9f2ef;
  --color-ink-muted: #9fb3ac;
  --color-primary: #49b195;
  --color-primary-hover: #5cc4a8;
  --color-primary-tint: #17332b;
  --color-accent: #f0ad4e;
  --color-accent-hover: #f6c169;
  --color-accent-tint: #3a2c14;
  --color-danger: #e0876a;
  --color-danger-tint: #3a231d;
  --color-warning: #f0ad4e;
  --color-success: #5cc4a8;

  /* Ребрендинг OfferFlow (2026-08-24): цвета фирменной молнии/wordmark.
     Единственный источник этих трёх hex — переиспользуются и в градиенте
     SVG-молнии (app/templates/_offerflow_mark.html, через var() в stop),
     и в тексте "Flow" (.ofl-wordmark__flow). Намеренно НЕ зависят от темы
     (light/dark) — фирменный градиент остаётся собой на любом фоне. */
  --color-flow-turquoise: #45e6c2;
  --color-flow-violet: #8067ff;
  --color-flow-orange: #ffb347;

  --font-display: 'Unbounded', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28), 0 1px 1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 18px -4px rgba(0, 0, 0, 0.4), 0 2px 8px -2px color-mix(in srgb, var(--color-primary) 25%, transparent);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.55), 0 8px 20px -8px color-mix(in srgb, var(--color-accent) 18%, transparent);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: dark;
}

/* Светлая тема — только по явному системному предпочтению пользователя,
   не дефолт. Прежняя тёплая "бумага" сохранена как есть. */
@media (prefers-color-scheme: light) {
  :root {
    --color-bg: #f6f3ec;
    --color-surface: #ffffff;
    --color-surface-2: #fbf9f3;
    --color-border: #e3dcc9;
    --color-ink: #14231f;
    --color-ink-muted: #52645d;
    --color-primary: #1f5c4f;
    --color-primary-hover: #164a3f;
    --color-primary-tint: #e5efea;
    --color-accent: #d98e2b;
    --color-accent-hover: #b97a20;
    --color-accent-tint: #faedd7;
    --color-danger: #b3432d;
    --color-danger-tint: #f7e7e2;
    --color-warning: #b45309;
    --color-success: #2e7d5b;

    --shadow-sm: 0 1px 2px rgba(20, 35, 31, 0.07), 0 1px 1px rgba(20, 35, 31, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(20, 35, 31, 0.14), 0 2px 6px -2px rgba(20, 35, 31, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(20, 35, 31, 0.22), 0 6px 14px -6px rgba(20, 35, 31, 0.1);

    color-scheme: light;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  /* Раздел 15 ТЗ: мягкий радиальный градиент в сторону бирюзового + тёплое
     свечение в зоне акцентных элементов — фон, а не главный элемент. */
  background-image:
    radial-gradient(circle at 14% -12%, color-mix(in srgb, var(--color-primary) 20%, transparent), transparent 46%),
    radial-gradient(circle at 100% 6%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 42%),
    radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--color-primary) 12%, transparent), transparent 50%);
  background-attachment: fixed;
}

/* Раздел 16 ТЗ: появление страницы — opacity + небольшой translate. */
@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page {
  animation: page-enter 220ms var(--ease-spring) both;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
  font-weight: 600;
  /* Раздел "Дополнение: защита интерфейса от длинного контента"
     (2026-08-26) — заголовки часто показывают domain_display напрямую
     (job_status.html, semantics_detail.html и т.д.); длинный домен без
     дефисов (>100 символов, IDN/punycode) иначе визуально переполняет
     страницу по горизонтали. */
  overflow-wrap: anywhere;
}

p {
  margin: 0 0 var(--space-4, 16px);
}

a {
  color: var(--color-primary);
}

::selection {
  background: var(--color-accent-tint);
}

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

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

/* --- Layout --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 82%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

/* --- Раздел "ребрендинг OfferFlow, доработка логотипа-молнии" (2026-08-24)
   Фирменная молния: 6 слоёв (тело/грань/кант/свечение/след/блик — раздел 5
   ТЗ), разметка — app/templates/_offerflow_mark.html (macro offerflow_mark),
   используется в шапке (base.html, 40x40) и на login (login.html, крупнее,
   .ofl-mark--load). Один макрос — одна геометрия молнии на оба места,
   вместо трёх независимых копий пути, как было при MOLNI. --- */

.ofl-mark {
  flex-shrink: 0;
  display: block;
  overflow: visible;
  box-shadow: var(--shadow-sm);
  border-radius: 8px;
  transition: transform 200ms var(--ease-spring);
}

.ofl-mark__badge {
  fill: #12211d;
}

.ofl-mark__glow {
  opacity: 0.4;
  animation: ofl-glow-breathe 6.4s ease-in-out infinite;
}

.ofl-mark__streak {
  opacity: 0;
  animation: ofl-streak-fade 6.4s ease-in-out infinite;
}

.ofl-mark__spectrum {
  animation: ofl-hue-drift 7s ease-in-out infinite;
}

.ofl-mark__facet {
  fill: #ffffff;
  opacity: 0.22;
}

.ofl-mark__sheen {
  fill: #ffffff;
  opacity: 0;
  animation: ofl-sheen-sweep 6.4s ease-in-out infinite;
}

.ofl-mark__edge {
  fill: none;
  stroke: #f4fbf8;
  stroke-opacity: 0.4;
  stroke-width: 0.8;
}

@keyframes ofl-glow-breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.68; }
}

@keyframes ofl-streak-fade {
  0%, 100% { opacity: 0; }
  45% { opacity: 0.4; }
}

@keyframes ofl-hue-drift {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(12deg); }
}

@keyframes ofl-sheen-sweep {
  0% { transform: translateY(-18px); opacity: 0; }
  8% { opacity: 0.55; }
  26% { opacity: 0.55; }
  38%, 100% { transform: translateY(46px); opacity: 0; }
}

@keyframes ofl-sheen-sweep-fast {
  0% { transform: translateY(-18px); opacity: 0; }
  22% { opacity: 0.8; }
  100% { transform: translateY(46px); opacity: 0; }
}

/* Первая загрузка (login) — раздел 8 ТЗ: молния "заряжается" снизу вверх
   (clip-path на группе body/facet/sheen/edge — не влияет на layout, форма
   входа не сдвигается), затем проявляется контур (stroke-dashoffset,
   pathLength=100 в разметке макроса), затем wordmark. Суммарно ~820ms —
   в допуске 700-900ms. */
.ofl-mark--load .ofl-mark__spectrum {
  clip-path: inset(0 0 0 0);
  animation:
    ofl-charge-reveal 520ms var(--ease-spring) both,
    ofl-hue-drift 7s ease-in-out 820ms infinite;
}

.ofl-mark--load .ofl-mark__edge {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: ofl-contour-draw 480ms ease-out 160ms both;
}

.ofl-mark--load .ofl-mark__glow,
.ofl-mark--load .ofl-mark__streak,
.ofl-mark--load .ofl-mark__sheen {
  animation-delay: 520ms;
}

@keyframes ofl-charge-reveal {
  from { clip-path: inset(100% 0 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes ofl-contour-draw {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: 0; }
}

/* Наведение — только в шапке (.topbar__brand — ссылка), на login молния не
   кликабельна. Раздел 8 ТЗ: сдвиг <=2px, ярче свечение, один быстрый блик,
   wordmark немного ярче. Заменяет прежний .topbar__brand:hover{opacity:.9},
   который бы гасил и молнию, и wordmark — противоречит "ярче". */
.topbar__brand:hover .ofl-mark,
.topbar__brand:focus-visible .ofl-mark {
  transform: translateX(2px);
}

.topbar__brand:hover .ofl-mark__glow,
.topbar__brand:focus-visible .ofl-mark__glow {
  animation-play-state: paused;
  opacity: 0.75;
}

.topbar__brand:hover .ofl-mark__sheen,
.topbar__brand:focus-visible .ofl-mark__sheen {
  animation: ofl-sheen-sweep-fast 480ms ease-out;
}

.topbar__brand:hover .ofl-wordmark,
.topbar__brand:focus-visible .ofl-wordmark {
  filter: brightness(1.12);
}

/* --- Wordmark "OfferFlow": "Offer" — обычный ink, "Flow" — фирменный
   бирюзово-фиолетовый градиент текста (раздел 7 ТЗ). white-space:nowrap —
   слово не должно распадаться на две строки (раздел 7, 11 ТЗ). --- */
.ofl-wordmark {
  white-space: nowrap;
}

.ofl-wordmark__offer {
  color: var(--color-ink);
}

.ofl-wordmark__flow {
  color: var(--color-flow-turquoise); /* фолбэк для браузеров без background-clip:text */
  background: linear-gradient(90deg, var(--color-flow-turquoise), var(--color-flow-violet));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ofl-wordmark--load {
  animation: ofl-wordmark-in 320ms ease-out 560ms both;
}

@keyframes ofl-wordmark-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* login.html — крупный размер wordmark рядом с 72px молнией. Раньше был
   инлайновым style="font-size:28px" прямо на элементе — инлайн-стиль
   побеждает ЛЮБОЕ правило из класса независимо от media query, поэтому
   мобильный @media(max-width:640px) .ofl-wordmark ниже никогда не
   применялся к login: на узких экранах nowrap-текст "OfferFlow" не мог
   сжаться и раздвигал страницу (горизонтальный скролл, обнаружено на
   production при проверке после деплоя). Обычный класс вместо инлайна —
   .ofl-wordmark { font-size: 15px } на <=640px (см. ниже) применяется
   к login так же, как к шапке, без отдельного переопределения. */
.ofl-login-heading {
  font-size: 28px;
}

/* Раздел 4 ТЗ: компактный переключатель-меню вместо скучных текстовых
   ссылок — сегментированная группа с мягкой заливкой активного пункта. */
.topbar__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
}

.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-ink-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.topbar__link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.topbar__link:hover {
  color: var(--color-ink);
}

.topbar__link--active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border-color: color-mix(in srgb, var(--color-primary) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 14%, transparent);
}

.topbar__link--active:hover {
  color: var(--color-primary);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__user span {
  font-size: 13px;
  color: var(--color-ink-muted);
}

/* Багфикс ТЗ "окончательно исправить списки..." (2026-08-26), раздел 6 —
   на 768px (НЕ ловился прежним порогом 640px) .topbar__nav (десктопные,
   немного более широкие пункты) + .topbar__user (имя пользователя +
   "Выйти") конкурировали за 768px и суммарно не помещались — тот же класс
   бага, что и nav-пункты на 390px: несжимаемое (min-width:auto по
   умолчанию) содержимое во flex-ряду. Порог поднят до 800px — переиспользует
   уже готовую компактную вёрстку ниже без новой отдельной "промежуточной"
   раскладки; 1024px и выше по-прежнему используют исходную широкую вёрстку
   (реально проверено — не переполняется). */
@media (max-width: 800px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 10px;
    padding: 12px 16px;
  }
  .topbar__nav {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }
  .topbar__nav .topbar__link {
    flex: 1;
    justify-content: center;
    /* Раздел 7 ТЗ "Сбор семантики" (2026-08-24): третий пункт меню длиннее
       двух прежних ("Сбор семантики" против "Создать КП"/"История") — на
       узкой ширине компактнее padding/шрифт/иконка, чтобы подпись умещалась
       в одну строку и не разъезжалась по высоте с соседними пунктами.

       Багфикс ТЗ "окончательно исправить списки «Сбор семантики» и
       «Прогноз ПФ»" (2026-08-26), раздел 6 — обязательная проверка
       scrollWidth<=clientWidth на 390px реально нашла: flex-item по
       умолчанию min-width:auto = ширина его nowrap-контента ("Сбор
       семантики" не умещается) — сумма таких минимумов шире 390px, что и
       раздвигало ВСЮ страницу (не только .topbar) — тот же класс бага,
       что и "дата пересекается с названием" в .list-grid выше: nowrap без
       запрета сжатия/переноса раздувает контейнер. min-width:0 разрешает
       сжиматься; text-wrap:balance вместо снятого nowrap — при нехватке
       места подпись переносится на 2 строки РОВНО и по центру.

       Этот единый ряд из 5 пунктов используется в диапазоне 641-800px
       (реально проверено — влезает без переноса на этих ширинах); на
       ≤640px — отдельная сетка 3+2 ниже (раздел 4 ТЗ "встроенная страница
       «Инструкция»", 2026-08-27: "первая строка — три пункта, вторая —
       два пункта одинаковой ширины" — на 390px 5 пунктов в один ряд даже
       с переносом выглядели тесно и неровно по высоте, см. итоговый
       отчёт). */
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
    gap: 4px;
    text-align: center;
    text-wrap: balance;
  }
  .topbar__nav .topbar__link svg {
    width: 13px;
    height: 13px;
  }
  .topbar__user {
    margin-left: auto;
  }
  /* Раздел 7, 11 ТЗ ребрендинга OfferFlow: на мобильном wordmark чуть
     меньше, а на очень узкой ширине остаётся только молния — иначе шапка
     переносится/ломает меню (раздел 11: "нет горизонтального скролла"). */
  .ofl-wordmark {
    font-size: 15px;
  }
}

/* Раздел 4 ТЗ "встроенная страница «Инструкция»" (2026-08-27) — "на
   мобильном меню перестраивается в компактную сетку в две строки...
   первая строка — три пункта; вторая строка — два пункта одинаковой
   ширины". CSS Grid на 6 колонок: первые 3 пункта — span 2 (заполняют
   ряд 1 целиком, по 1/3 каждый), последние 2 — span 3 (заполняют ряд 2
   целиком, по 1/2 каждый) — простые целочисленные span'ы вместо дробных
   ширин. Переопределяет flex-ряд из блока 641-800px выше именно на этой,
   более узкой границе. */
@media (max-width: 640px) {
  .topbar__nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
  }
  .topbar__nav .topbar__link {
    padding: 8px 4px;
  }
  .topbar__nav .topbar__link:nth-child(1),
  .topbar__nav .topbar__link:nth-child(2),
  .topbar__nav .topbar__link:nth-child(3) {
    grid-column: span 2;
  }
  .topbar__nav .topbar__link:nth-child(4),
  .topbar__nav .topbar__link:nth-child(5) {
    grid-column: span 3;
  }
}

@media (max-width: 380px) {
  .ofl-wordmark {
    display: none;
  }
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

.page--wide {
  max-width: 1120px;
}

/* Раздел "финальная очистка UI" (2026-08-24) — login: единственная страница
   с одной центрированной карточкой, а не поток контента сверху вниз, как у
   .page. min-height:100vh + flex-центрирование работает и на desktop, и на
   mobile (без нижней подписи, которая раньше "прижимала" карточку к верху
   визуально); width:100% на wrap — узкие вьюпорты не переполняются
   горизонтально, только сужается сама карточка. */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: page-enter 220ms var(--ease-spring) both;
}

.auth-card-wrap {
  width: 100%;
  max-width: 420px;
}

/* --- Buttons --- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
  text-decoration: none;
  min-height: 44px;
}

/* Раздел 16 ТЗ: hover кнопок — подъём на 1-2px. */
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

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

.btn-primary {
  background: var(--color-accent);
  color: #211505;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-ink);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--color-danger-tint);
}

.btn-block {
  width: 100%;
}

/* --- Cards / surfaces --- */

.surface {
  /* Раздел 15 ТЗ: полупрозрачные поверхности карточек + тонкие светлые
     границы — без тяжёлого blur, чтобы не портить читаемость. */
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.surface-flat {
  background: color-mix(in srgb, var(--color-surface-2) 92%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 200ms ease;
}

/* --- Forms --- */

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-ink);
}

.field .hint {
  font-size: 12.5px;
  color: var(--color-ink-muted);
  margin-top: 6px;
}

.field .error {
  font-size: 12.5px;
  color: var(--color-danger);
  margin-top: 6px;
  font-weight: 600;
}

.required::after {
  content: ' *';
  color: var(--color-accent-hover);
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

/* Раздел 8 ТЗ: один согласованный chevron вместо кривого нативного
   оформления — одинаково в Safari/Chrome/Firefox, клавиатурное управление
   не затронуто (обычный <select>). */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239fb3ac' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  cursor: pointer;
}

select::-ms-expand {
  display: none;
}

input.field--invalid, textarea.field--invalid {
  border-color: var(--color-danger);
}

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

/* --- Chips (приоритетные услуги) --- */

.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
  font-weight: 700;
}

.chip button {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.chip button:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

/* --- Method cards (шаг 2) --- */

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.method-card {
  text-align: left;
  cursor: pointer;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 180ms ease, border-color 180ms ease;
}

.method-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.method-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.method-card__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}

.method-card__caption {
  font-size: 13.5px;
  color: var(--color-ink-muted);
  line-height: 1.5;
}

.method-card__fit {
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 700;
  margin-top: auto;
}

.method-card--other {
  border-style: dashed;
  background: var(--color-surface-2);
}

.method-card--other .method-card__icon {
  background: var(--color-accent-tint);
  color: var(--color-accent-hover);
}

/* "Другой регион" -> подсветка альтернативных методов (раздел 58 ТЗ) */
.method-card--highlight {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

/* --- Region grid --- */

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

.region-btn {
  cursor: pointer;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-weight: 700;
  font-size: 14px;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.region-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.region-btn[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

/* --- Stepper --- */

.stepper {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.stepper__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-ink-muted);
}

.stepper__dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--color-surface);
}

.stepper__item--done .stepper__dot {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.stepper__item--current {
  color: var(--color-ink);
}

.stepper__item--current .stepper__dot {
  border-color: var(--color-accent);
  color: var(--color-accent-hover);
  box-shadow: 0 0 0 3px var(--color-accent-tint);
}

.stepper__connector {
  width: 20px;
  height: 1.5px;
  background: var(--color-border);
  align-self: center;
}

@media (max-width: 480px) {
  .stepper { flex-direction: column; align-items: flex-start; }
  .stepper__connector { display: none; }
}

/* --- Table (history) --- */

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

table.history {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--color-surface);
}

table.history th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

table.history td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  vertical-align: middle;
}

table.history tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
}

.badge--success { color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 40%, var(--color-border)); }
.badge--danger { color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 40%, var(--color-border)); }
.badge--pending { color: var(--color-accent-hover); border-color: color-mix(in srgb, var(--color-accent) 40%, var(--color-border)); }
/* Доп. ТЗ "Прогноз ПФ: доработка" (2026-08-26), часть E — "Требует
   внимания" (PARTIAL/UNCERTAIN/ошибка расчёта без смены статуса), 4-й
   укрупнённый статус общей истории, отдельный от badge--danger. */
.badge--warning { color: var(--color-warning); border-color: color-mix(in srgb, var(--color-warning) 40%, var(--color-border)); }

/* --- Общая история (доп. ТЗ "Прогноз ПФ: доработка", 2026-08-26), часть E --- */

.history-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.history-type-chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-type-chip--proposal .history-type-chip__dot { background: var(--color-accent); }
.history-type-chip--semantics .history-type-chip__dot { background: var(--color-primary); }
.history-type-chip--forecast .history-type-chip__dot { background: var(--color-flow-violet); }

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.history-filters__search {
  flex: 1;
  min-width: 220px;
  max-width: 340px;
}

.history-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-ink-muted);
}

/* Раздел "На мобильном экране строки должны превращаться в карточки" */
@media (max-width: 720px) {
  table.history--unified,
  table.history--unified thead,
  table.history--unified tbody,
  table.history--unified tr,
  table.history--unified td {
    display: block;
    width: 100%;
  }
  table.history--unified thead {
    position: absolute;
    left: -9999px;
  }
  table.history--unified tr {
    border-bottom: 1px solid var(--color-border);
    padding: 14px 16px;
  }
  table.history--unified tr:last-child { border-bottom: none; }
  table.history--unified td {
    border-bottom: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
  }
  table.history--unified td::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-ink-muted);
    font-weight: 700;
    text-align: left;
  }
  table.history--unified td[data-label=""]::before { display: none; }
}

/* --- Дополнение: защита интерфейса от длинного контента (2026-08-26) ---
   Корень бага: table.history раньше не задавал table-layout (по
   умолчанию auto) — единственный неразрывный длинный токен в ячейке
   (например, ID Google Таблицы) заставлял браузер расширять КОЛОНКУ (и
   тем самым всю таблицу) под содержимое, т.к. в auto-режиме width:100%
   задаёт только МИНИМУМ, не потолок; .table-scroll{overflow-x:auto}
   технически даёл прокрутку, но т.к. ничего не ограничивало саму
   таблицу колонкой-потолком, "Действия" визуально уезжали за пределы
   карточки. table-layout:fixed (см. выше) фиксирует ширины колонок по
   <th> — переполнение теперь остаётся ВНУТРИ ячейки и обрабатывается
   этими классами, а не раздувает всю таблицу. Переиспользуются на
   /forecasts, /semantics, /history — везде, где есть table.history. */

.table-shell {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.cell-primary {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cell-secondary {
  color: var(--color-ink-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell .row {
  min-width: 0;
  flex-wrap: nowrap;
}

.actions-cell .btn {
  flex-shrink: 0;
}

.numeric-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Раздел "иконка-корзина вместо текстовой кнопки на планшете" — общий
   вид у обеих кнопок действий, aria-label обязателен (см. .btn-icon в
   разметке). */
.btn-icon {
  display: none;
}

@media (max-width: 1024px) and (min-width: 721px) {
  .actions-cell .btn-text-delete { display: none; }
  .actions-cell .btn-icon { display: inline-flex; }
}

/* --- .list-grid — ТЗ "окончательно исправить списки «Сбор семантики» и
   «Прогноз ПФ»" (2026-08-26) ---

   Область действия ТОЛЬКО /forecasts и /semantics (раздел 1 ТЗ) — table.
   history/.table-shell выше НЕ трогаются, /history остаётся на старой
   разметке. Подтверждённая живым Chrome-замером (раздел 2 ТЗ) причина
   бага "дата пересекается с названием": table.history td НЕ задаёт
   overflow — nowrap-содержимое колонки "Дата" (её fixed-ширина по
   table-layout:fixed была тесной) при overflow:visible (умолчание)
   рисовалось ПОВЕРХ соседней ячейки, а не обрезалось/переносилось.
   Пример живого замера (26.08.2026, /forecasts, 1440px, строка «БМВ 4»):
   ячейка "Дата" — CSS-ширина 117.7px, scrollWidth текста — 132px (+14px
   "вылета" ровно на территорию соседней ячейки "Название", которая
   начиналась в той же X-координате, где заканчивалась "Дата").

   Решение — раздел 4 ТЗ: одна CSS Grid-сетка (не table) с ОДИНАКОВЫМ
   grid-template-columns у заголовка и всех строк — каждая колонка получает
   либо фиксированную, либо minmax()-нижнюю границу ширины, которую грид
   не сжимает ниже указанной (в отличие от table-layout:fixed, где
   заданная ширина колонки — не гарантия, а желаемая величина, которую
   узкое nowrap-содержимое соседней ячейки может продавить визуально).
   "Действия" — гарантированный минимум 220px (раздел 4 ТЗ), поэтому
   отдельного icon-only варианта кнопки "Удалить" на планшете (как у
   .btn-icon выше) здесь не нужно — обе текстовые кнопки помещаются на
   всех ширинах ≥390px.

   .list-grid__row — display:contents на desktop/tablet: сама обёртка не
   создаёт бокс, её дети становятся ПРЯМЫМИ элементами грида (тот же приём,
   что и настоящая table-строка) — только так возможна ОДНА сетка сразу для
   заголовка и всех строк. На мобильном (раздел 5 ТЗ, ≤767px) переопределяется
   обратно в display:block — превращается в реальную карточку. role="table"/
   "row"/"columnheader"/"cell" в разметке — ARIA-эквивалент таблицы, который
   div+display:contents сам по себе не даёт (раздел "Accessibility" ui-ux-pro-max). */

.list-grid {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  background: var(--color-surface);
}

.list-grid--forecasts {
  grid-template-columns:
    minmax(140px, max-content)
    minmax(170px, 1.5fr)
    minmax(170px, 1.5fr)
    minmax(150px, 1.2fr)
    minmax(120px, 0.9fr)
    minmax(220px, max-content);
}

.list-grid--semantics {
  grid-template-columns:
    minmax(140px, max-content)
    minmax(180px, 1.6fr)
    minmax(140px, 1fr)
    minmax(110px, 0.8fr)
    minmax(120px, 0.9fr)
    minmax(220px, max-content);
}

.list-grid__row {
  display: contents;
}

.list-grid__head,
.list-grid__cell {
  min-width: 0;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

.list-grid__head {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-muted);
  background: var(--color-surface-2);
}

.list-grid__cell {
  font-size: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.list-grid__row:last-child > .list-grid__cell {
  border-bottom: none;
}

/* Раздел 4 ТЗ — "дата: отдельная колонка, white-space:nowrap" — ГАРАНТИЯ
   не сжимается ниже контента (minmax(...,max-content) выше) убирает саму
   возможность "вылета" текста за пределы ячейки, поэтому overflow:visible
   тут больше не опасен. */
.list-grid__cell--date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Раздел 4 ТЗ — "название/источник: максимум две строки, перенос длинных
   слов". */
.list-grid__cell--clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-grid__cell--name {
  font-weight: 600;
}

/* Раздел 4 ТЗ — "показатели: компактный вертикальный блок". */
.list-grid__cell--metrics {
  gap: 2px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.list-grid__cell--metrics .cell-secondary {
  margin-top: 0;
}

/* Раздел 4 ТЗ — "статус: не сжимается" — просто не участвует в фикс-сжатии
   (minmax нижняя граница), плюс бейдж сам умеет переноситься на 2 строки. */
.list-grid__cell--status {
  align-items: flex-start;
}

/* Раздел 4 ТЗ — "действия: гарантированная ширина не менее 220px", "Открыть
   и Удалить расположить рядом", "не использовать абсолютное позиционирование
   кнопок" — обычный flex-ряд внутри уже гарантированно широкой ячейки. */
.list-grid__cell--actions {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.list-grid__cell--actions .btn {
  flex-shrink: 0;
}

/* Раздел 3 ТЗ доп. — плавное исчезновение при удалении строки. Анимация —
   на ДЕТЯХ .list-grid__row, не на самой обёртке: под display:contents
   обёртка не создаёт бокс и transition на ней визуально не сработал бы
   (transitionend от детей всё равно всплывает до обработчика на row). */
.list-grid__row--removing > * {
  transition: opacity 200ms ease, transform 200ms ease;
  opacity: 0;
  transform: translateX(8px);
}

@media (prefers-reduced-motion: reduce) {
  .list-grid__row--removing > * {
    transition: none;
  }
}

/* Раздел 5 ТЗ — 768-1279px: та же 6-колоночная сетка, скролл — только
   внутри .table-scroll (раздел ТЗ буквально это разрешает), не всей
   страницы. Никакого отдельного "компактного" grid-template тут не нужно —
   расчётная сумма минимумов (см. константы grid-template-columns выше)
   помещается без скролла уже от ~1000px полезной ширины (.page--wide
   ограничивает контент 1120px минус padding); скролл реально включается
   только у самого нижнего края диапазона (768px). На этой ширине "Действия"
   ОБЯЗАНЫ оставаться полностью видимыми ("действия остаются полностью
   видимыми" — раздел 5 ТЗ), а не уезжать за правый край вместе со
   скроллом — поэтому колонка "Действия" прижата (position:sticky) к
   правому краю СКРОЛЛИРУЕМОГО контейнера .table-scroll: скроллятся только
   Дата/Название/Источник/Показатели/Статус, действия видны всегда. */
@media (min-width: 768px) {
  .list-grid__row--head > .list-grid__head:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--color-surface-2);
  }
  .list-grid__cell--actions {
    position: sticky;
    right: 0;
    z-index: 1;
    background: var(--color-surface);
    box-shadow: -8px 0 12px -8px color-mix(in srgb, var(--color-ink) 18%, transparent);
  }
}

/* Раздел 5 ТЗ — до 767px: карточки. */
@media (max-width: 767px) {
  .list-grid {
    display: block;
  }
  .list-grid__row {
    display: block;
  }
  .list-grid__row--head {
    display: none;
  }
  .list-grid__row + .list-grid__row {
    border-top: 1px solid var(--color-border);
  }
  /* Раздел "Показатели" — многострочное значение (запросы/частотность/
     трафик, каждая на своей строке) не помещалось рядом с подписью в
     схеме "label слева / value справа" (одна строка на пару) — цифры
     переносились некрасиво посреди слова ("запросо" + "в"). Подпись
     СВЕРХУ, значение ПОД ней (обычная мобильная карточка) — работает
     одинаково опрятно и для однострочных, и для многострочных значений,
     без отдельного частного случая под "Показатели". */
  .list-grid__cell {
    display: block;
    padding: 6px 16px;
    border-bottom: none;
    text-align: left;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
  .list-grid__row:first-child > .list-grid__cell:first-of-type {
    padding-top: 14px;
  }
  .list-grid__row > .list-grid__cell:last-of-type {
    padding-bottom: 14px;
  }
  .list-grid__cell::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-ink-muted);
    font-weight: 700;
    margin-bottom: 2px;
  }
  .list-grid__cell[data-label=""]::before {
    display: none;
  }
  .list-grid__cell--metrics {
    text-align: left;
  }
  .list-grid__cell--actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
  }
}

/* --- Toast --- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--color-ink);
  color: var(--color-bg);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 50;
}

.toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- Misc --- */

.muted { color: var(--color-ink-muted); }
.mt-0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }

.callout {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  /* Раздел "Дополнение: защита интерфейса от длинного контента"
     (2026-08-26) — ошибки могут содержать длинные технические сообщения/
     URL без пробелов. */
  overflow-wrap: anywhere;
}

.callout--warning {
  background: var(--color-accent-tint);
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  color: var(--color-warning);
}

.callout--danger {
  background: var(--color-danger-tint);
  border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border));
  color: var(--color-danger);
}

.callout--success {
  background: var(--color-primary-tint);
  border-color: color-mix(in srgb, var(--color-success) 45%, var(--color-border));
  color: var(--color-success);
}

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}

.skip-link:focus {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 100;
  background: var(--color-ink);
  color: var(--color-bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}

/* --- Progress (раздел 12 ТЗ: один прогресс-блок вместо 7 шагов) --- */

.progress-block__label {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.progress-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 400ms var(--ease-spring);
}

/* Мягкая анимация внутри заполненной части во время долгих AI-этапов —
   не увеличивает процент, только "дышит" внутри уже занятой ширины. */
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    100deg,
    transparent 30%,
    color-mix(in srgb, white 35%, transparent) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: progress-shimmer 1.8s ease-in-out infinite;
}

@keyframes progress-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-ink-muted);
}

.progress-caption {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--color-ink-muted);
}

/* --- Persistent page-level alert (раздел 14 ТЗ) --- */

.page-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: alert-in 200ms var(--ease-spring) both;
}

.page-alert__text {
  flex: 1;
  margin: 0;
}

.page-alert__close {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.page-alert__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

@keyframes alert-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- History row delete (раздел 9 ТЗ) --- */

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink-muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease, transform 160ms var(--ease-spring);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover:not(:disabled) {
  color: var(--color-danger);
  border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border));
  background: var(--color-danger-tint);
  transform: translateY(-1px);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.history-row--removing {
  transition: opacity 200ms ease, transform 200ms ease;
  opacity: 0;
  transform: translateX(8px);
}

/* Дополнение "постраничное раскрытие запросов в прогнозе" (2026-08-26) —
   короткая ненавязчивая анимация появления для новых строк, добавленных
   кнопкой "Показать ещё" (только transform/opacity — раздел "Анимация"
   ui-ux-pro-max). */
@keyframes row-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.row-enter {
  animation: row-enter 180ms ease-out both;
}

/* --- Сбор семантики (раздел "Сбор семантики" ТЗ, 2026-08-24) --- */

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

.segmented__btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--color-ink-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms var(--ease-spring);
}

.segmented__btn:hover:not(.segmented__btn--active) {
  color: var(--color-ink);
}

.segmented__btn--active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.segmented__count {
  opacity: 0.7;
  font-weight: 600;
}

.stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  min-width: 96px;
}

.stat-pill__value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.stat-pill__label {
  font-size: 12px;
  color: var(--color-ink-muted);
}

.stat-pill--kept .stat-pill__value { color: var(--color-success); }
.stat-pill--reserve .stat-pill__value { color: var(--color-accent-hover); }
.stat-pill--stop .stat-pill__value,
.stat-pill--manual .stat-pill__value { color: var(--color-danger); }

.query-list {
  display: flex;
  flex-direction: column;
}

.query-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 160ms ease;
}

.query-row:last-child {
  border-bottom: none;
}

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

.query-row__text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow-wrap: break-word;
}

.query-row--cut .query-row__text {
  color: var(--color-ink-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--color-danger) 55%, transparent);
}

.query-row__stopword {
  display: inline-block;
  margin-left: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-danger);
  background: var(--color-danger-tint);
  border-radius: 999px;
  padding: 2px 8px;
}

.query-row__stopword--reserve {
  color: var(--color-accent-hover);
  background: var(--color-accent-tint);
}

.query-row__metrics {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  color: var(--color-ink-muted);
  white-space: nowrap;
}

.query-row__metrics strong {
  color: var(--color-ink);
  font-weight: 700;
}

.query-row__toggle {
  flex-shrink: 0;
}

/* --- Панель создания сбора: чекбоксы устройств/групп минус-слов --- */

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

.check-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.check-tile:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
}

.check-tile input {
  margin-top: 2px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.check-tile__title {
  font-size: 13.5px;
  font-weight: 700;
}

.check-tile__hint {
  font-size: 12px;
  color: var(--color-ink-muted);
  margin-top: 2px;
}

/* --- Прогноз ПФ: сравнение сценариев (доп. ТЗ "Arsenkin Wordstat +
   Прогноз ПФ", 2026-08-26) --- */

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.scenario-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  padding: 26px 24px 20px;
  box-shadow: var(--shadow-md);
}

.scenario-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
}

.scenario-card--neutral::before { background: var(--color-primary); }
.scenario-card--optimistic::before {
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-hover));
}

.scenario-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.scenario-card__title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.scenario-card--neutral .scenario-card__title { color: var(--color-primary); }
.scenario-card--optimistic .scenario-card__title { color: var(--color-accent-hover); }

.scenario-card__positions {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-ink-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.scenario-card__rate {
  font-size: 13px;
  color: var(--color-ink-muted);
  margin: 4px 0 18px;
}

.scenario-funnel {
  display: flex;
  flex-direction: column;
}

.scenario-metric {
  padding: 11px 0;
}

.scenario-metric + .scenario-metric {
  border-top: 1px dashed var(--color-border);
}

.scenario-metric__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-ink-muted);
  font-weight: 700;
}

.scenario-metric__value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 3px;
  color: var(--color-ink);
}

.scenario-metric__unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink-muted);
  margin-left: 4px;
}

.scenario-metric__arrow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--color-ink-muted);
  opacity: 0.65;
  font-size: 11px;
}

.scenario-metric__arrow svg { width: 13px; height: 13px; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
  .progress-fill::after { animation: none; }
  .row-enter { animation: none; }

  /* Раздел 8 ТЗ ребрендинга OfferFlow: блок 133-139 выше уже гасит
     ДЛИТЕЛЬНОСТЬ всех анимаций почти до нуля — для infinite-циклов
     (свечение/блик/градиент) этого недостаточно самого по себе, они бы
     осели на случайном кадре цикла. Явно фиксируем ИМЕННО тот статичный
     вид, который просит ТЗ: движение градиента откл., блик откл.,
     пульсация откл., яркая статичная молния остаётся, логотип не
     скрывается — тот же приём, что уже применён к .progress-fill::after
     выше. */
  .ofl-mark__spectrum {
    animation: none;
    filter: none;
  }
  .ofl-mark__glow {
    animation: none;
    opacity: 0.55;
  }
  .ofl-mark__streak {
    animation: none;
    opacity: 0;
  }
  .ofl-mark__sheen,
  .topbar__brand:hover .ofl-mark__sheen,
  .topbar__brand:focus-visible .ofl-mark__sheen {
    animation: none;
    opacity: 0;
  }
  .ofl-mark--load .ofl-mark__spectrum {
    clip-path: none;
  }
  .ofl-mark--load .ofl-mark__edge {
    animation: none;
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
  .ofl-wordmark--load {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* --- Страница «Инструкция» (/guide) — ТЗ "встроенная страница «Инструкция»
   в OfferFlow" (2026-08-27). Раздел 7 ТЗ: существующий тёмный фон,
   фирменные акценты, текущие радиусы карточек, существующие стили кнопок и
   типографику — ни одного нового цвета/шрифта, только новая композиция из
   уже существующих токенов (:root выше). --- */

/* Раздел 7 ТЗ — "допускается... плавная прокрутка", раздел
   prefers-reduced-motion должен соблюдаться (единственный потребитель —
   якорная быстрая навигация /guide, но глобально безвредно: другие
   страницы якорей внутри себя не используют). */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

.guide-hero {
  margin-bottom: 28px;
}

.guide-hero__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.guide-hero__subtitle {
  color: var(--color-ink-muted);
  font-size: 15px;
  margin-top: 6px;
  max-width: 60ch;
}

/* Раздел 5 ТЗ — быстрая навигация из карточек-якорей, прокрутка к разделу
   с учётом sticky-шапки (scroll-margin-top на самих секциях ниже). */
.guide-quicknav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.guide-quicknav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-surface-2) 92%, transparent);
  border: 1px solid var(--color-border);
  color: var(--color-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  transition: transform 180ms var(--ease-spring), border-color 180ms ease, box-shadow 180ms ease;
}

.guide-quicknav__item:hover,
.guide-quicknav__item:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
  box-shadow: var(--shadow-sm);
}

.guide-quicknav__icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.guide-quicknav__icon svg {
  width: 18px;
  height: 18px;
}

/* Раздел 5 ТЗ — "заголовки не должны прятаться под фиксированной шапкой".
   .topbar — position:sticky, реальная высота ~64px (десктоп) до ~132px
   (шапка перенеслась на 2 ряда, см. @media выше) — запас с большим
   расчётом на компактный режим намеренно один на все ширины (простое,
   предсказуемое поведение важнее точной подгонки по px). */
.guide-section {
  scroll-margin-top: 148px;
  padding: 28px;
  margin-bottom: 22px;
}

.guide-section__eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--color-primary-tint);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.guide-section__title {
  font-size: 20px;
  margin-bottom: 6px;
}

.guide-lead {
  color: var(--color-ink-muted);
  font-size: 14.5px;
  line-height: 1.7;
  margin-bottom: 18px;
}

.guide-subhead {
  font-size: 15px;
  margin: 22px 0 12px;
}

/* Раздел 7 ТЗ — "шаги — нумерованный список". */
.guide-steps {
  list-style: none;
  counter-reset: guide-step;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-steps li {
  counter-increment: guide-step;
  display: flex;
  gap: 12px;
  align-items: baseline;
  line-height: 1.6;
}

.guide-steps li::before {
  content: counter(guide-step);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-bg);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-top: 2px;
}

.guide-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-bullets li {
  position: relative;
  padding-left: 20px;
  line-height: 1.6;
}

.guide-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-flow-turquoise);
}

/* Раздел 7 ТЗ — "варианты выбора — компактные карточки... не делать
   декоративные таблицы там, где достаточно списка": сравнения "способ /
   когда выбирать / что понадобится" и т.п. оформлены карточками, не
   <table>. */
.guide-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.guide-choice-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-surface-2) 92%, transparent);
  border: 1px solid var(--color-border);
}

.guide-choice-card__title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--color-primary);
}

.guide-choice-card__row {
  font-size: 13px;
  color: var(--color-ink-muted);
  line-height: 1.6;
}

.guide-choice-card__row strong {
  color: var(--color-ink);
  font-weight: 600;
}

/* Раздел "Частые вопросы" — раздел 6.5 ТЗ: без аккордеонов, просто
   вопрос+ответ. */
.guide-faq {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guide-faq__q {
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 4px;
}

.guide-faq__a {
  color: var(--color-ink-muted);
  font-size: 14px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .guide-section {
    padding: 20px;
  }
}
