/* =========================================================================
   trustsell.ru — Кабинет. Бренд-тема (гибрид): тёмная индиго-«рама»
   (topbar + фиксированный градиент-фон) + светлые рабочие карточки ради
   читаемости данных. Токены/палитра — из лендинга (wordpress-theme/trustsell).
   ========================================================================= */

/* Дисплейный шрифт заголовков (самохост, без CDN) — как на лендинге. */
@font-face{font-family:'Unbounded';font-style:normal;font-weight:500 800;font-display:swap;
  src:url(fonts/unbounded-cyrillic.woff2) format('woff2');
  unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Unbounded';font-style:normal;font-weight:500 800;font-display:swap;
  src:url(fonts/unbounded-latin.woff2) format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}

:root {
  /* --- Бренд-палитра лендинга --- */
  --ts-indigo-900:#161452; --ts-indigo-800:#1e1c74; --ts-indigo-700:#2b2a89;
  --ts-indigo-600:#3a38b8; --ts-indigo-500:#4b4aef; --ts-indigo-400:#6a69f0;
  --ts-lav:#9190ff; --ts-lav-100:#c9c8ff; --ts-lav-200:#a7a6f2;
  --ts-yellow:#ffc23c; --ts-yellow-600:#f4a700; --ts-teal:#17e39b; --ts-teal-600:#0fbf82;
  --ts-white:#fff; --ts-ink:#12123a;
  --ts-line-dark:rgba(255,255,255,.14);
  --ts-radius:16px; --ts-radius-sm:11px;
  --ts-font:'Inter','Segoe UI',system-ui,-apple-system,Roboto,Arial,sans-serif;
  --ts-font-display:'Unbounded','Inter','Segoe UI',system-ui,sans-serif;

  /* --- Семантика кабинета (светлые поверхности) --- */
  --panel: #ffffff;
  --surface-2: #f4f5ff;          /* суб-карточки, KPI, шапки таблиц */
  --text: #22233f;               /* тёмный индиго-ink для тела */
  --muted: #6c6f8a;
  --line: #e6e7f5;               /* светлая индиго-граница */
  --primary: #4b4aef;            /* индиго — ссылки/акценты */
  --primary-strong: #3a38b8;
  --danger: #c0362c;
  --ok: #0f9d6c;
}

* { box-sizing: border-box; }
/* Атрибут hidden должен побеждать любые author-правила display (иначе .field{display:grid}
   и т.п. «раскрывают» скрытые элементы, напр. dev-поле «API base URL»). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ts-font);
  color: var(--text);
  background: #191660;
  background-image:
    radial-gradient(85% 48% at 12% -8%, rgba(96,90,236,.55) 0%, rgba(96,90,236,0) 60%),
    radial-gradient(65% 42% at 100% -2%, rgba(23,227,155,.15) 0%, rgba(23,227,155,0) 55%),
    radial-gradient(75% 45% at 50% 108%, rgba(58,56,184,.4) 0%, rgba(58,56,184,0) 60%),
    linear-gradient(180deg, #221f74 0%, #151248 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--ts-font-display); letter-spacing: -.02em; line-height: 1.14; }

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 16px 44px;
  display: grid;
  /* minmax(0, 1fr), а НЕ дефолтный auto: у auto-колонки максимум = max-content, поэтому одна широкая
     карточка (таблица отзывов, длинный URL) растягивала колонку — и вместе с ней ВСЕ карточки и весь
     экран становились шире других страниц, а .table-wrap{overflow-x:auto} не срабатывал. С minmax(0,1fr)
     колонка не превышает контейнер, широкое содержимое скроллится внутри своего блока. */
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

/* ---------- Тёмная «рама»: topbar ---------- */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(40,38,120,.86), rgba(28,26,104,.74));
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border: 1px solid var(--ts-line-dark);
  border-radius: var(--ts-radius);
  padding: 16px 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 24px 50px -34px rgba(6,5,40,.72);
}
.topbar h1 { margin: 0; font-size: 24px; color: #fff; }
.topbar h1 .accent, .topbar .brand-accent { color: var(--ts-teal); }
.muted { color: var(--muted); }
/* На тёмной раме muted/крошки — светло-лавандовые */
.topbar .muted, #crumbs { color: var(--ts-lav-100); }

/* Хлебные крошки (в шапке под заголовком) */
#crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.crumb-link { background: none; border: none; color: var(--ts-lav); padding: 0; min-height: auto; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; box-shadow: none; }
.crumb-link:hover { background: none; text-decoration: underline; color: #fff; }
.crumb-sep { color: var(--ts-lav-200); user-select: none; }
.crumb-current { color: #fff; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }

/* Переключатель продукта (товарные / гео) под брендом в шапке; оба кабинета делят сессию */
.product-switch { display: inline-flex; gap: 4px; margin: 8px 0 6px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--ts-line-dark); }
.product-switch a { padding: 5px 14px; border-radius: 999px; color: var(--ts-lav-100); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.product-switch a:hover { color: #fff; background: rgba(255,255,255,.1); }
.product-switch a.current { color: var(--ts-ink); background: var(--ts-teal); }

/* ---------- Светлые рабочие карточки ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--ts-radius);
  padding: 18px 20px;
  box-shadow: 0 24px 50px -36px rgba(6,5,40,.55), 0 2px 0 rgba(255,255,255,.6) inset;
}

.card h2, .card h3 { margin: 0 0 10px; color: var(--ts-ink); }
.card h4 { margin: 16px 0 8px; font-family: var(--ts-font); font-weight: 700; color: var(--ts-ink); }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }

.field { display: grid; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: var(--ts-radius-sm);
  min-height: 40px;
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(75,74,239,.16);
}
.field.inline { display: inline-flex; align-items: center; gap: 8px; }
.field input[type="checkbox"] { min-height: auto; width: 16px; height: 16px; padding: 0; accent-color: var(--primary); }
.field.grow { flex: 1 1 100%; }
.field.grow textarea { width: 100%; min-height: 92px; resize: vertical; }

/* ---------- Экраны входа / регистрации / сброса пароля ----------
   Узкая центрированная карточка-«окно» вместо рабочей карточки во всю ширину. */
.card.auth {
  width: 100%;
  max-width: 440px;
  margin: 5vh auto 0;
  padding: 26px 26px 20px;
}
.card.auth h2 { font-size: 26px; margin-bottom: 6px; }
.auth-lead { margin: 0 0 20px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.card.auth .grid { gap: 14px; }
/* Тихая подсказка под формой входа: у заявки с лендинга пароля ещё нет. */
.auth-hint { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
/* Плашка-подсказка над формой (напр. «пароль отправлен на почту» после заявки с лендинга) */
.auth-note {
  margin: 0 0 18px;
  padding: 11px 14px;
  border: 1px solid #cfe9dc;
  border-left: 3px solid var(--ok);
  border-radius: var(--ts-radius-sm);
  background: #f0fbf6;
  color: #1c5c45;
  font-size: 13px;
  line-height: 1.5;
}
.card.auth button[type="submit"] { width: 100%; margin-top: 4px; }
.auth-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
/* Единственная ссылка в подвале (регистрация/сброс) — по центру */
.auth-foot > :only-child { margin: 0 auto; }

/* Поле пароля с кнопкой «Показать» внутри */
.pwd { position: relative; display: grid; }
.pwd input { padding-right: 92px; }
.pwd-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  min-height: 0;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  border-radius: 8px;
  box-shadow: none;
}
.pwd-toggle:hover { background: var(--surface-2); color: var(--primary-strong); transform: none; box-shadow: none; }

.card.sub {
  margin-top: 14px;
  background: var(--surface-2);
  box-shadow: none;
  border-style: dashed;
  border-color: #d7d8ef;
}

.row-end { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row { display: flex; }

/* ---------- Кнопки: primary = жёлтый бренд-CTA, ghost = светлая ---------- */
button {
  appearance: none;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #ffd15a, #ffbe33);
  color: var(--ts-ink);
  min-height: 40px;
  padding: 0 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  font-size: 15px;
  box-shadow: 0 14px 30px -14px rgba(255,178,40,.55), inset 0 1px 0 rgba(255,255,255,.4);
  transition: transform .12s ease, background .16s ease, box-shadow .16s ease;
}
button:hover { background: linear-gradient(180deg, #ffca4a, #f7a913); transform: translateY(-1px); box-shadow: 0 20px 40px -16px rgba(255,178,40,.62), inset 0 1px 0 rgba(255,255,255,.4); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* Вторичная кнопка на светлой карточке */
button.ghost {
  background: #fff;
  color: var(--primary);
  border-color: #d9daf3;
  box-shadow: none;
}
button.ghost:hover { background: #f2f2ff; border-color: var(--primary); color: var(--primary-strong); transform: translateY(-1px); }
button.link { background: none; border: none; color: var(--primary); padding: 0; min-height: auto; text-decoration: underline; font-weight: 600; box-shadow: none; }
button.link:hover { background: none; color: var(--primary-strong); transform: none; }
button.link.danger { color: var(--danger); }
button.ghost.danger { color: var(--danger); border-color: #f3c4bd; background: #fff; }
button.ghost.danger:hover { background: #fff1ef; border-color: var(--danger); color: var(--danger); }

/* Вторичные кнопки в тёмной раме (topbar) — «стеклянные» */
.topbar-actions button, .topbar-actions button.ghost {
  background: rgba(255,255,255,.06);
  color: #fff;
  border: 1px solid var(--ts-line-dark);
  box-shadow: none;
}
.topbar-actions button:hover, .topbar-actions button.ghost:hover {
  background: rgba(255,255,255,.12);
  border-color: var(--ts-lav);
  color: #fff;
}

/* Фокус-ринг — тил, как на лендинге */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--ts-teal);
  outline-offset: 2px;
}

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

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--surface-2); text-align: left; font-size: 12px; color: #4a4c6b; font-weight: 700; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 11px; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f6f6ff; }

/* Плашки-сообщения. Тема кабинета гибридная: тёмная рама плюс СВЕТЛЫЕ карточки, а .message
   был написан только под раму (белый текст на полупрозрачном). Внутри белой карточки такой
   текст почти сливался с фоном: сильнее всего это било по «Тарифам», где на плашках про конец
   тестового периода и переход на Free держится вся мотивация оплатить. Базовый вариант теперь
   светлый и читаемый, а тёмный оставлен там, где он и нужен: у #globalMessage над карточками. */
.message { margin: 0; padding: 10px 14px; border-radius: 12px; border: 1px solid #d7d9f2; background: var(--surface-2); color: var(--text); line-height: 1.5; }
.message.ok { border-color: #a8e3ca; background: #eafbf3; color: #0a5b3f; }
.message.error { border-color: #f3bdb5; background: #fff0ed; color: #8c2214; }
.message strong { color: inherit; }

/* Над карточками фон тёмный, поэтому глобальная плашка сохраняет светлый текст. */
#globalMessage { border-color: var(--ts-line-dark); background: rgba(255,255,255,.08); color: #fff; backdrop-filter: blur(6px); }
#globalMessage.ok { border-color: rgba(23,227,155,.5); background: rgba(23,227,155,.16); color: #d7fff0; }
#globalMessage.error { border-color: rgba(255,120,110,.5); background: rgba(255,120,110,.16); color: #ffdcd7; }

/* Статус-бейджи — светлые пастельные наборы (бренд-акценты) */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #ececff; color: var(--primary-strong); white-space: nowrap; }
.status-queued, .status-not_started { background: #eaf0ff; color: #2b3fb8; }
.status-processing, .status-running, .status-matching_required { background: #efeaff; color: #5b21b6; }
.status-completed, .status-success, .status-active { background: #e3fbef; color: #0c8f5f; }
.status-completed_with_errors, .status-catalog_required, .status-installation_required, .status-preview_ready, .status-connected { background: #fff4e2; color: #9a6412; }
.status-failed { background: #ffece9; color: var(--danger); }
.status-disabled { background: #eef0f6; color: #64748b; }
/* Приглашённый сотрудник (ТЗ 20): письмо ушло, ссылка ещё не открыта — состояние ожидания. */
.status-invited { background: #fff4e2; color: #9a6412; }
/* Источник подключён, но сбор по нему заблокирован биллингом (лимит тарифа / пауза подписки). */
.status-blocked { background: #fff4e2; color: #9a6412; }
.status-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 800; color: var(--ts-ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.attention { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.attention li { border-radius: 12px; border: 1px solid #f3dea1; background: #fffaec; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.attention li.done { border-color: #b7f0d3; background: #ecfdf4; }

/* Wizard */
.wizard-steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; padding: 0; list-style: none; counter-reset: step; }
.wizard-steps li {
  flex: 1 1 150px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font-size: 13px;
  color: var(--muted);
  position: relative;
}
.wizard-steps li::before {
  counter-increment: step;
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ececff; color: var(--primary-strong);
  font-weight: 700; margin-right: 8px;
}
.wizard-steps li.active { border-color: var(--primary); color: var(--text); box-shadow: 0 8px 22px -12px rgba(75,74,239,.4); }
.wizard-steps li.active::before { background: var(--primary); color: #fff; }
.wizard-steps li.done::before { background: var(--ts-teal-600); color: #fff; content: "✓"; }
.wizard-steps li.soon { opacity: 0.7; }

/* Wizard: подробные шаги с инструкцией, видео и галочкой выполнения */
.setup-step { border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-top: 10px; overflow: hidden; }
.setup-step.active { border-color: var(--primary); box-shadow: 0 8px 22px -14px rgba(75,74,239,.45); }
.setup-step.done { border-color: #b7f0d3; background: #fbfffd; }
.setup-step > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--text);
}
.setup-step > summary::-webkit-details-marker { display: none; }
.setup-step > summary:hover { background: var(--surface-2); }
.setup-check {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: #ececff; color: var(--primary-strong); font-weight: 700; font-size: 13px;
}
.setup-check.on { background: var(--ts-teal-600); color: #fff; }
.setup-title { flex: 1 1 auto; }
.setup-state { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--muted); }
.setup-step.done .setup-state { color: var(--ts-teal-600); }
.setup-step.active .setup-state { color: var(--primary-strong); }
.setup-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.setup-body > p { margin: 12px 0 8px; }
.setup-list { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.setup-list li { line-height: 1.45; }
.setup-note { font-size: 13px; color: var(--muted); border-left: 3px solid #f3dea1; background: #fffaec; padding: 8px 12px; border-radius: 0 8px 8px 0; }
/* Видео узкое: примерно треть ширины шага. min-width — чтобы на средних экранах не схлопнулось до нечитаемого. */
.setup-video { margin: 12px 0; max-width: 33%; min-width: 260px; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.setup-video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.setup-video.empty { padding: 18px; text-align: center; border-style: dashed; }

.nav-links { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: #ececff; color: var(--primary-strong); font-size: 12px; font-weight: 600; }

.dropzone {
  border: 2px dashed #c4c6ec;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  background: #f8f8ff;
}

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

/* Подключение мессенджера (bind): шаги + QR */
.bind-steps { margin: 8px 0; padding-left: 20px; }
.bind-steps li { margin: 4px 0; }
.qr-box { margin: 10px 0; }
.qr { display: inline-block; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 12px; line-height: 0; }
.qr svg { display: block; width: 132px; height: 132px; }

code { background: #eef0fb; color: var(--ts-ink); padding: 1px 6px; border-radius: 6px; font-size: 92%; }
pre.code { background: var(--ts-indigo-900); color: #e5e7ff; border-radius: 12px; padding: 12px; overflow: auto; font-size: 12px; }

@media (max-width: 1100px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 20px; }
  .topbar { top: 6px; padding: 14px 16px; }
}

/* ---------- Подсказки-тултипы (ТЗ 21 §3.4) ---------- */
/* Иконка «?» рядом с подписью поля. Полный сброс базовой кнопки: та — жёлтая градиентная. */
.hint-dot {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  min-height: 0;
  margin-left: 5px;
  padding: 0;
  /* Индиго-заливка, а не --surface-2: та почти сливалась с белой карточкой (#f4f5ff на #fff),
     и подсказки просто не находили. Фиксированные hex, а не var(): если переменная почему-то
     не разрешится, background станет прозрачным — снова белое на белом. */
  /* 3.08:1 к белой карточке — порог WCAG 1.4.11 для границ нетекстовых элементов.
     С более светлым контуром кружок терялся: глиф видно, а саму «кнопку» — нет. */
  border: 1px solid #8a89e8;
  border-radius: 50%;
  background: #e8e8ff;
  color: #4b4aef;
  font: 700 11px/1 var(--ts-font);
  cursor: help;
  box-shadow: none;
  transform: none;
  vertical-align: middle;
  flex: 0 0 auto;
}
.hint-dot:hover, .hint-dot.on, .hint-dot:focus-visible {
  background: #4b4aef;
  border-color: #4b4aef;
  color: #fff;
  transform: none;
  box-shadow: none;
}
.hint-dot:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Подпись поля — grid-ячейка с мелким шрифтом; иконка не должна ломать базовую линию. */
.field span .hint-dot { margin-left: 4px; }

.hint-pop {
  position: fixed;
  z-index: 10000; /* выше модалок (9999 — оверлей медиа) */
  max-width: 330px;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--ts-radius-sm);
  box-shadow: 0 18px 42px -14px rgba(18,18,58,.34);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.hint-pop[hidden] { display: none; }
.hint-pop strong { display: block; margin-bottom: 5px; font-size: 12px; color: var(--ts-ink); }
.hint-pop p { margin: 0; color: var(--muted); }
/* Ссылка из подсказки в статью базы знаний: открывается новой вкладкой. */
.hint-pop .hint-more { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--primary); text-decoration: none; }
.hint-pop .hint-more:hover { text-decoration: underline; }
.kb-link { color: var(--primary); text-decoration: none; }
.kb-link:hover { text-decoration: underline; }
.setup-kb-row { margin: 10px 0 0; font-size: 14px; }
.hint-pop p + p { margin-top: 7px; }

/* Узкий экран: не целимся в якорь — нижний лист на всю ширину. */
@media (max-width: 640px) {
  .hint-pop.sheet {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    max-width: none;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: var(--ts-radius) var(--ts-radius) 0 0;
    padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px -10px rgba(18,18,58,.4);
  }
  .hint-pop.sheet p { font-size: 14px; }
  .hint-dot { width: 20px; height: 20px; font-size: 12px; }
}

/* ---------- Контекстные коуч-марки (ТЗ 21 §4.3) ---------- */
/* Карточка в потоке страницы, а не оверлей со стрелкой: стрелки ломаются при перевёрстке
   и на узких экранах, а карточка одинаково работает и на десктопе, и на мобильном. */
.coach-mark {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 13px 15px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-left: 3px solid var(--primary);
  border-radius: var(--ts-radius-sm);
}
.coach-body { flex: 1 1 320px; min-width: 0; }
.coach-mark strong { display: block; margin-bottom: 3px; font-size: 13px; color: var(--ts-ink); }
.coach-mark p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text); }
.coach-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; flex-wrap: wrap; }
.coach-actions button { min-height: 34px; padding: 0 14px; font-size: 13px; }

@media (max-width: 640px) {
  /* align-self, а не width:100%: родитель с align-items:flex-start не растягивает элемент,
     и правило ширины было мёртвым — кнопки оставались узкими. */
  .coach-mark { flex-direction: column; gap: 10px; }
  .coach-actions { align-self: stretch; }
  .coach-actions button { flex: 1 1 auto; min-height: 40px; }
  /* На узком экране треть ширины нечитаема — отдаём видео всю доступную. */
  .setup-video { max-width: 100%; min-width: 0; }
}

/* Экран «Правила», блок «Настройки отображения» (ТЗ 36): переключатели и поля двумя ровными сетками. */
.settings-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.settings-checks .field.inline { display: flex; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 20px; align-items: start; margin-top: 8px; }
.settings-grid .field.wide { grid-column: 1 / -1; max-width: 560px; }
/* Ячейка не растёт от содержимого: селект с длинным пунктом иначе вылезал на соседа. */
.settings-grid .field { min-width: 0; }
.settings-grid .field > select, .settings-grid .field > input { width: 100%; min-width: 0; box-sizing: border-box; }
.settings-grid .row-inline { min-width: 0; }
.settings-grid .row-inline > input[type="text"] { min-width: 0; flex: 1 1 90px; }
.settings-grid .row-inline > select { min-width: 0; flex: 1 1 120px; }
.settings-grid input[type="range"] { flex: 1; min-height: auto; padding: 0; border: 0; background: none; }
