/* Личный агент — стили кабинета.
   1. Токены (светлая и тёмная тема)   2. Основа   3. Каркас   4. Компоненты
   5. Старые классы экранов: перекрашены токенами, удаляются по мере перевода экранов */

/* --- 1. Токены ---------------------------------------------------------------------------
   Тема: по ОС или выбором пользователя (data-theme на <html>). Каждый токен задан один раз
   парой light-dark(светлая, тёмная). Контраст текста ≥ 4.5:1 в обеих темах. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f7f8, #0f1214);
  --surface: light-dark(#ffffff, #171b1f);
  --surface-2: light-dark(#eef1f3, #13171a);
  --text: light-dark(#161a1e, #e6eaed);
  --muted: light-dark(#5a6670, #9aa6af);
  --border: light-dark(#e0e5e9, #2a3237);
  --border-strong: light-dark(#c9d1d7, #3a444b);
  /* Голубой: заливки с тёмным текстом; ссылки и рамки фокуса — --accent-ink, светлый голубой
     на белом не даёт 4.5:1 */
  --accent: light-dark(#38bdf8, #7dd3fc);
  --accent-hover: light-dark(#7dd3fc, #bae6fd);
  --accent-text: light-dark(#04202f, #04202f);
  --accent-ink: light-dark(#0275b0, #38bdf8);
  --accent-soft: light-dark(#e0f2fe, #0c2a3d);
  --accent-soft-text: light-dark(#075985, #7dd3fc);
  /* --ok — яркая заливка точек и полос (≥ 3:1 к фону), --ok-text — текст на --ok-bg */
  --ok: light-dark(#16a34a, #4ade80);
  --ok-bg: light-dark(#dcfce7, #0f3d22);
  --ok-text: light-dark(#15803d, #4ade80);
  --warn-bg: light-dark(#fff3dc, #3a2a0c);
  --warn-text: light-dark(#875200, #f3c26b);
  --err-bg: light-dark(#fdecec, #3a1417);
  --err-text: light-dark(#b0201b, #ff9aa2);
  /* Единственный красный в навигации — бейдж «Входящих» */
  --badge: light-dark(#d1242f, #f0535c);
  --badge-text: light-dark(#ffffff, #1d0507);
  /* Кнопки действий, которые касаются всего проекта, а не одного клиента */
  --critical: light-dark(#c81e1e, #f05252);
  --critical-hover: light-dark(#a51717, #f87171);
  --critical-text: light-dark(#ffffff, #1d0507);
  --admin: light-dark(#3b5bdb, #8ea2ff);
  --admin-text: light-dark(#ffffff, #0b1033);
  /* Серии графиков: проверены валидатором палитры для обеих тем */
  --series-1: light-dark(#2a78d6, #3987e5);
  --series-2: light-dark(#16a34a, #22c55e);
  --shadow: light-dark(0 8px 24px rgb(16 24 32 / 12%), 0 8px 24px rgb(0 0 0 / 45%));

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-s: 13px;
  --fs-m: 15px;
  --fs-l: 17px;
  --fs-xl: 22px;
  --fs-xxl: 28px;
  --radius: 12px;
  --radius-s: 8px;
  --sidebar: 228px;
  --tabbar: 60px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* --- 2. Основа ---------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-m)/1.5 var(--font);
  min-height: 100vh;
}
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: var(--fs-xl); line-height: 1.25; margin: 0 0 16px; }
h2 { font-size: var(--fs-l); line-height: 1.3; margin: 0; }
h3 { font-size: var(--fs-m); margin: 16px 0 6px; }
p { margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 4px; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.icon.s { width: 16px; height: 16px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }
.ok-text { color: var(--ok-text); }
.warn-text { color: var(--warn-text); }
.err-text { color: var(--err-text); }

/* --- 3. Каркас ---------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 12px 14px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--fs-l); }
.logo-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-size: var(--fs-m);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px;
  border-radius: var(--radius-s); color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 600; }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center;
  background: var(--badge); color: var(--badge-text); font-size: 12px; font-weight: 700; line-height: 20px;
}
.nav-badge:empty { display: none; }
.sidebar-status { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); font-size: var(--fs-s); }
.sidebar-status .status-line { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-m); }
.sidebar-status p { margin: 2px 0 0; color: var(--muted); }
.sidebar-status .button { margin-top: 8px; width: 100%; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.area-link { font-weight: 600; text-decoration: none; }
.sidebar .area-link { padding: 6px 10px; font-size: var(--fs-s); color: var(--admin); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.section-head { padding: 22px 32px 0; background: var(--bg); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title h1 { margin: 0 0 14px; }
.subnav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border);
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 12px 9px;
  color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.subnav .count { font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); line-height: 20px; }
.subnav .count:empty { display: none; }
.page { width: 100%; max-width: 1040px; padding: 24px 32px 48px; flex: 1; }
.page.wide { max-width: 1320px; }
.page.narrow { max-width: 460px; margin: 0 auto; }
.footer { padding: 16px 32px 24px; font-size: var(--fs-s); color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* Меню аккаунта: <details> раскрывается над кнопкой */
.menu { position: relative; }
.menu > summary {
  list-style: none; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px;
  border-radius: var(--radius-s); cursor: pointer; color: var(--text); font-weight: 500;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface); }
.menu > summary .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 6px; background: none; color: var(--text); text-decoration: none; font: inherit; text-align: left; cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.theme-switch { display: flex; gap: 2px; padding: 6px 10px; }
.theme-switch button { flex: 1; white-space: nowrap; justify-content: center; min-height: 32px; padding: 4px; border: 1px solid var(--border); border-radius: 6px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }

/* Нижняя панель на телефоне */
.tabbar { display: none; }

/* Публичные страницы (вход, регистрация): без панелей */
.public-head { padding: 20px 24px 0; }

@media (max-width: 959.98px) {
  .sidebar { display: none; }
  .section-head { padding: 16px 16px 0; }
  .section-title h1 { margin-bottom: 10px; }
  /* Край-градиент: видно, что вкладки прокручиваются */
  .subnav { mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); padding-right: 24px; }
  .page { padding: 16px 16px 32px; }
  .footer { padding: 12px 16px; }
  .shell { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  /* Фокус и якоря не прячутся под нижней панелью (WCAG 2.4.11) */
  html { scroll-padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; min-height: 44px;
  }
  .tabbar a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; }
  .tabbar .nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; font-size: 11px; line-height: 18px; min-width: 18px; }
}

/* --- 4. Компоненты ------------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
@media (max-width: 520px) { .card { padding: 16px; } }

/* Кнопки */
button, .button {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: var(--radius-s); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; text-align: center; font-weight: 500;
}
button:hover, .button:hover { border-color: var(--muted); color: var(--text); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger, .button.danger { color: var(--err-text); border-color: currentColor; background: transparent; }
/* Действие на весь проект (бэкапы, настройки нейросети, тарифы) — заливка красным */
button.critical, .button.critical { background: var(--critical); border-color: var(--critical); color: var(--critical-text); font-weight: 600; }
button.critical:hover, .button.critical:hover { background: var(--critical-hover); border-color: var(--critical-hover); color: var(--critical-text); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent-ink); font-weight: 400; }
button:disabled { opacity: .6; cursor: progress; }
button.small, a.button.small, .small-button { min-height: 30px; padding: 4px 10px; font-size: var(--fs-s); }
form.inline { display: inline; }
/* Индикатор на кнопке во время запроса */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
button.htmx-request { position: relative; color: transparent !important; }
button.htmx-request::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Поля */
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { margin-top: 4px; flex-shrink: 0; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=url], select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); width: 100%;
}
textarea { resize: vertical; }
textarea.mono { font: 13px/1.5 var(--mono); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 0; border-color: transparent; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.hint { font-weight: 400; font-size: var(--fs-s); color: var(--muted); }

/* Переключатель: <label class="switch"><input type="checkbox" role="switch"> текст</label> */
.switch { flex-direction: row; align-items: center; gap: 12px; font-weight: 400; cursor: pointer; }
.switch input {
  appearance: none; flex: none; width: 40px; height: 24px; margin: 0; border-radius: 999px;
  background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* Шкала-сегменты (автономия): радиокнопки в ряд */
.segmented { display: inline-flex; width: fit-content; max-width: 100%; flex-wrap: wrap; padding: 3px; gap: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented label { flex-direction: row; gap: 0; font-weight: 500; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 12%); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent-ink); }

/* Слайдер со шкалой подписей */
.slider { display: flex; flex-direction: column; gap: 4px; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-scale { display: flex; justify-content: space-between; font-size: var(--fs-s); color: var(--muted); font-weight: 400; }

/* «Дополнительно» */
details.more > summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }
details.more { display: flex; flex-direction: column; gap: 14px; }
details.more[open] > fieldset + fieldset { margin-top: 14px; }
details.advanced { border-top: 1px solid var(--border); padding-top: 12px; }
details.advanced > summary { cursor: pointer; font-weight: 600; }

/* Бейджи статуса: всегда с текстом, цвет — только подсказка */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500;
  padding: 1px 8px; border-radius: 999px; margin-left: 8px; white-space: nowrap; line-height: 20px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.ok, .badge.state-interview, .badge.state-invitation, .badge.state-offer, .badge.state-hired { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge.bad, .badge.state-discard { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-soft-text); border-color: transparent; }

/* Точка статуса агента; во время запуска — пульсирует */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn-text); }
.dot.bad { background: var(--err-text); }
.dot.live { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Чипы-фильтры внутри списка */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chips a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none; background: var(--surface); font-size: 14px; white-space: nowrap;
}
.chips a:hover { border-color: var(--border-strong); }
.chips a[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 600; }
.chips .count { background: var(--warn-bg); color: var(--warn-text); border-radius: 999px; padding: 0 6px; font-size: 12px; }
.chips-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 16px; }

/* Плитки-факты */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.tile { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); }
a.tile:hover { border-color: var(--accent); color: var(--text); }
.tile-label { color: var(--muted); font-size: var(--fs-s); }
.tile-value { font-size: var(--fs-xl); font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .small { margin-top: -2px; }

/* Статус-карточка */
.status-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border-left: 4px solid var(--border); }
.status-card p { margin: 4px 0 0; }
.status-card.is-on { border-left-color: var(--ok); }
.status-card.is-off { border-left-color: var(--warn-text); }
.status-card > div:first-child { flex: 1 1 320px; min-width: 0; }
.run-info { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; overflow-wrap: anywhere; }

/* Таблицы. Широкие — прокрутка внутри .table-wrap, первая колонка закреплена */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--fs-s); color: var(--muted); font-weight: 500; padding: 8px 8px; }
.table td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table thead + tbody tr:first-child td { border-top: 1px solid var(--border); }
.table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; padding: 8px 12px; }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
/* .table.cards — на телефоне строки становятся карточками: первая ячейка (.card-title) —
   заголовок, у остальных подпись колонки из data-label */
@media (max-width: 760px) {
  .table.cards thead { display: none; }
  .table.cards tr { display: block; padding: 10px 0; border-top: 1px solid var(--border); }
  .table.cards tbody tr:first-child { border-top: 0; }
  .table.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .table.cards td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: var(--fs-s); text-align: left; }
  .table.cards td.card-title { display: block; text-align: left; }
  .table.cards td:empty { display: none; }
  .table-wrap .table.cards td:first-child { position: static; min-width: 0; max-width: none; box-shadow: none; }
  .table.cards td > div { min-width: 0; text-align: right; }
  .table-wrap .table.cards td.card-title { padding: 2px 0 4px; margin: 0; font-size: inherit; border-top: 0; position: static; min-width: 0; max-width: none; box-shadow: none; }
  .table.cards td.card-title > div { text-align: left; }
}
/* Таблица показателей: заголовки и значения по центру, названия строк слева, столбцы разделены */
.table.metrics th, .table.metrics td { text-align: center; font-variant-numeric: tabular-nums; }
.table.metrics th + th, .table.metrics td + td { border-left: 1px solid var(--border); }
.table.metrics th:first-child, .table.metrics td:first-child { text-align: left; }

/* Строка списка */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 6px 0; }
.list-card { padding: 8px 0; }
.list-card > .muted { padding: 0 20px; }
.neg-list { list-style: none; margin: 0; padding: 0; }
.neg-row { display: flex; justify-content: space-between; gap: 8px 16px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; flex-wrap: wrap; }
a.neg-row:hover, .neg-row:hover { background: var(--surface-2); color: var(--text); }
.neg-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 320px; }
.neg-side { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.neg-side .badge { margin-left: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 12px; }

/* Карточка письма */
.letter-card { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 20px; }
@media (max-width: 760px) { .letter-card { grid-template-columns: minmax(0, 1fr); } }
.letter-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.score { font-weight: 650; color: var(--accent-soft-text); }

/* Переписка: пузыри */
.messages { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(640px, 92%); padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }
.msg .msg-text { margin: 4px 0 0; }
.letter-text, .msg-text { white-space: pre-wrap; font: inherit; margin: 8px 0; overflow-wrap: anywhere; }
.reply { border-top: 1px solid var(--border); padding-top: 16px; }

/* Сообщения у места: что случилось и что сделать */
.alert { padding: 10px 14px; border-radius: var(--radius-s); background: var(--warn-bg); color: var(--warn-text); margin: 0 0 12px; }
.alert.error { background: var(--err-bg); color: var(--err-text); }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); }
.notice { padding: 12px 14px; border-radius: var(--radius-s); background: var(--warn-bg); color: var(--warn-text); font-size: 14px; }
/* Баннер над разделом */
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; background: var(--warn-bg); color: var(--warn-text); }
.banner.info { background: var(--accent-soft); color: var(--accent-soft-text); }
.banner .grow { flex: 1 1 240px; }

/* Пустое состояние: текст и одно действие */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p { max-width: 420px; margin: 0 auto 14px; }

/* Скелетон для загружающихся списков */
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; margin: 10px 0; }
.skeleton.w60 { width: 60%; }
.skeleton.w40 { width: 40%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Тост */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s ease-out;
}
.toast button { min-height: 0; padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 959.98px) {
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); }
}

/* Модальное подтверждение (<dialog>) */
dialog.confirm { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: 420px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog.confirm::backdrop { background: rgb(0 0 0 / 40%); }
dialog.confirm .row-actions { justify-content: flex-end; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- 5. Старые классы экранов ------------------------------------------------------------- */
/* Админка — тот же каркас, что у кабинета: метка «Админка» в боковой панели и над
   заголовком раздела на телефоне (там же ссылка обратно в кабинет) */
.area-badge { font-size: 12px; font-weight: 600; color: var(--admin); border: 1px solid var(--admin); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.sidebar .area-badge { align-self: flex-start; margin: -10px 0 0 46px; }
.area-admin .logo-mark { background: var(--admin); color: var(--admin-text); }
.area-admin .area-link { color: var(--admin); }
.area-switch { display: none; }
@media (max-width: 959.98px) {
  .area-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: var(--fs-s); }
  .area-switch .area-link { display: inline-flex; align-items: center; min-height: 24px; }
}
.area-admin .table th { text-align: center; }
/* Ссылка — единственное в ячейке (клиент в задачах, hh): цель не меньше 24 px (WCAG 2.5.8) */
.area-admin .table td > div > a:only-child { display: inline-block; min-height: 24px; line-height: 24px; }
/* Карточка клиента в админке: шапка с быстрыми действиями, вкладки, проблемы */
.client-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; }
.client-head p { margin: 0 0 6px; }
.client-states { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.client-states .badge { margin: 0; }
.client-head .row-actions form { display: inline; }
.status-line { display: inline-flex; align-items: center; gap: 6px; }
.client-tabs { margin: 0 0 16px; }
.problem-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.problem-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.refund { margin-top: 8px; }
.table.clients td.card-title a, .table.clients td.right { white-space: nowrap; }
label.inline { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filters { margin: 0 0 16px; display: grid; gap: 8px; }
.filters .fields { margin: 0; }
.all-ok { align-items: center; }
.facts .tile .muted { margin-top: 2px; }
.refund .fields { margin-top: 8px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1, .page-head h2 { margin-bottom: 4px; }
h2.page-title { font-size: var(--fs-xl); margin: 0 0 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions { margin-top: 8px; }
.check-cell { width: 32px; }
.captcha { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.captcha img { max-width: 100%; border-radius: 6px; background: #fff; }
.prose ol { padding-left: 20px; }
.prose li { margin-bottom: 8px; }
.prose h2 { margin: 16px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 16px; margin: 16px 0 6px; }
.prose ul { padding-left: 20px; }
.prose code { font-size: 14px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); overflow-wrap: anywhere; }
.help-toc ol { margin: 0; padding-left: 20px; columns: 2 220px; }
.help-toc li { margin-bottom: 4px; }
section[id], .alert[id] { scroll-margin-top: 12px; }
.steps { margin: 8px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.alt-login { margin: 12px 0; }
.alt-login button { width: 100%; }
fieldset.choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.choice legend { font-weight: 600; margin-bottom: 8px; }
.step-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; margin-right: 6px; }
.form > .card { margin-bottom: 0; }
.form > .card h2 { margin-bottom: 4px; }
.model-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.model-row label { flex: 1; min-width: 220px; }
.model-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.model-choices .mono { font: 13px var(--mono); }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; min-width: 0; }
.sync-status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
details.letter { border-top: 1px solid var(--border); padding: 12px 0; }
details.letter summary { cursor: pointer; }

.stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.funnel { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.funnel-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 12px; align-items: center; }
.funnel-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel-bar { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.funnel-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) {
  .funnel-row { grid-template-columns: 1fr auto; }
  .funnel-track { grid-column: 1 / -1; grid-row: 2; }
}
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; margin-top: 12px; }
.chart { margin: 0; }
.chart figcaption { font-weight: 600; margin-bottom: 8px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--border); }
.bar-slot { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; outline: none; }
.bar { display: block; width: 100%; min-height: 1px; border-radius: 4px 4px 0 0; }
.bar.series-1 { background: var(--series-1); }
.bar.series-2 { background: var(--series-2); }
.bar-slot .tip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: 12px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; pointer-events: none; opacity: 0; z-index: 2; }
.bar-slot:hover .tip, .bar-slot:focus .tip { opacity: 1; }
.bar-slot:hover .bar, .bar-slot:focus .bar { filter: brightness(1.15); }
.bar-slot:first-child .tip { left: 0; transform: none; }
.bar-slot:last-child .tip { left: auto; right: 0; transform: none; }
.bar-axis { display: flex; justify-content: space-between; margin-top: 4px; }
.table-view { margin-top: 16px; }
.table-view summary { cursor: pointer; color: var(--muted); }
.stage-reset { margin-top: 12px; }
.digest-lead { font-size: var(--fs-l); line-height: 1.5; margin: 4px 0 16px; }
#digest h3 { margin: 20px 0 4px; }
#digest .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
@media (min-width: 521px) { #digest .funnel-row { grid-template-columns: minmax(160px, 260px) 1fr auto; } }
.resume-text h2 { font-size: 18px; margin: 20px 0 8px; }
.resume-text h2:first-child { margin-top: 0; }
.resume-text h3 { font-size: 15px; margin: 14px 0 4px; }
.chat-preview { color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.chat-preview mark { background: var(--warn-bg); color: inherit; border-radius: 2px; padding: 0 1px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split > .card, .split .chat-pane > .card { margin: 0; }
.vacancy-pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.vacancy-text { overflow-wrap: anywhere; line-height: 1.55; }
.vacancy-text :is(p, ul, ol) { margin: 0 0 10px; }
.vacancy-text :is(ul, ol) { padding-left: 22px; }
.vacancy-text :is(h1, h2, h3, h4) { font-size: 1rem; margin: 14px 0 6px; }
.vacancy-text .pre { white-space: pre-wrap; }
.vacancy-pane h3 { font-size: 1rem; margin: 16px 0 8px; }
.skills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skills li { padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .875rem; background: var(--surface-2); }
@media (max-width: 959.98px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .vacancy-pane { position: static; max-height: 50vh; }
}
.table.ops td.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.ops .mono { font: 13px var(--mono); }
.table.cols th + th, .table.cols td + td { border-left: 1px solid var(--border); }
.table.center td.num { text-align: center; }
.table.center th + th { text-align: center; }
#hh details { margin-top: 14px; }
#hh summary { cursor: pointer; color: var(--muted); }
.resume-archive { margin-top: 16px; }
.resume-archive summary { cursor: pointer; color: var(--muted); }
fieldset.checks { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.checks legend { font-weight: 500; margin-bottom: 6px; padding: 0; }
.check-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.check-row label.check { align-items: center; }
.check-row label.check input { margin-top: 0; }
.picker { display: flex; flex-direction: column; gap: 6px; position: relative; }
.picker-label { font-weight: 500; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.picked:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--accent); border-radius: 999px; font-size: 14px; background: var(--surface); }
.chip-x { border: 0; background: none; padding: 0 6px; min-height: 0; font-size: 16px; line-height: 1; color: var(--muted); cursor: pointer; }
.chip-x:hover { color: var(--err-text); }
.suggest { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); overflow: hidden; }
.suggest:empty { display: none; }
.suggest-item { border: 0; border-radius: 0; justify-content: flex-start; text-align: left; padding: 8px 12px; background: none; font-weight: 400; }
.suggest-item + .suggest-item { border-top: 1px solid var(--border); }
.suggest-item:hover, .suggest-item:focus { background: var(--surface-2); }
.preview-list li { padding: 8px 0; border-top: 1px solid var(--border); }
.preview-list li:first-child { border-top: 0; }
.danger-zone { margin-top: 24px; }
.import { margin-bottom: 16px; }
.draft h2 { font-size: 17px; }
.draft-params { margin: 8px 0 12px; }
.draft-params li { padding: 3px 0; }
.draft-params code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); overflow-wrap: anywhere; }
.rejected-row { display: flex; justify-content: space-between; gap: 8px 16px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.rejected-row .neg-main a { color: var(--text); }
.rejected-intro { padding: 0 20px; }
.facts .fact { padding: 12px 0; border-top: 1px solid var(--border); }
.facts .fact:first-child { border-top: 0; padding-top: 0; }
.fact-text { margin: 0 0 4px; white-space: pre-line; overflow-wrap: anywhere; }
.fact .muted.small { margin: 0 0 6px; }
.fact details.more:not([open]) summary { margin-bottom: 0; }
fieldset.test-answers { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 14px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
fieldset.test-answers legend { font-weight: 600; padding: 0 4px; }
.test-task { display: flex; flex-direction: column; gap: 6px; }
.test-question { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.test-task .badge { margin-left: 6px; }

/* --- Главная и Входящие (этап 2) --- */
.status-card.is-bad { border-left-color: var(--err-text); }
.status-card h2 { margin: 0; }
.run-info .dot { vertical-align: middle; margin-right: 2px; }
/* «Пауза ▾»: меню раскрывается под кнопкой */
.pause-menu > summary.button { display: inline-flex; gap: 6px; }
.pause-menu > .menu-panel { top: calc(100% + 6px); bottom: auto; left: auto; right: 0; min-width: 180px; }
.pause-menu.compact { margin-top: 6px; }
.pause-menu.compact > summary { min-height: 0; padding: 0; gap: 4px; color: var(--accent-ink); font-weight: 400; font-size: var(--fs-s); }
.pause-menu.compact > summary:hover { background: none; text-decoration: underline; }
.pause-menu.compact > .menu-panel { left: 0; right: auto; }
.sidebar-status button.link { font-size: inherit; }
.card-title { font-size: var(--fs-l); margin: 8px 20px 8px; }
.table td.card-title { font-size: inherit; margin: 0; }
.card-foot { padding: 8px 20px 4px; margin: 0; border-top: 1px solid var(--border); }
.neg-row .icon { vertical-align: -3px; }
.checklist .done { color: var(--muted); }
.saved { margin: 16px 0 0; }
.saved .icon { color: var(--accent-ink); vertical-align: -3px; }
/* Карточки во «Входящих» */
.cards:not(table) { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.cards > .card { margin: 0; }
.letter-card h2 { margin: 0 0 4px; font-size: var(--fs-l); }
.letter-card .vacancy-side p { margin: 6px 0; }
.letter-side textarea { min-height: 180px; }
.reply-card .msg { max-width: 100%; margin: 0 0 12px; }
.invite-row .neg-side { align-self: center; }
.invite-row .button.small { margin: 0; }
@media (max-width: 760px) {
  /* «Откликнуться» всегда под рукой: панель кнопок прилипает к низу экрана над нижним меню */
  .sticky-actions {
    position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); z-index: 5;
    background: var(--surface); padding: 10px 0; margin-bottom: -10px; border-top: 1px solid var(--border);
  }
}
/* Строки-ссылки со стрелкой: стрелка всегда справа, текст переносится сам */
:is(.decisions, .checklist, .meetings) .neg-row { flex-wrap: nowrap; align-items: center; }
:is(.decisions, .checklist, .meetings) .neg-main { flex: 1 1 auto; }
:is(.decisions, .checklist, .meetings) .neg-side { flex: 0 0 auto; }

/* --- Отклики (этап 3) --- */
.section-title .sync-status { margin-left: auto; }
.list-intro { padding: 4px 20px 8px; margin: 0; }
.chips a .muted { font-variant-numeric: tabular-nums; }
.stat-filter { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; padding: 12px 20px; }
.stat-filter p { margin: 0; }
.rejected-row .neg-side a.badge { text-decoration: none; color: var(--text); }
.rejected-row .neg-side a.badge:hover { border-color: var(--border-strong); }
/* Карточка отклика */
.back-link { margin: 0 0 8px; }
.back-link a { display: inline-flex; align-items: center; gap: 4px; }
.meta-line { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; padding: 0; margin: -4px 0 16px; }
.meta-line li + li::before { content: "·"; padding: 0 8px; }
.funnel-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: -8px 0 16px; }
.funnel-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; padding: 0; margin: 0; color: var(--muted); }
.funnel-steps li + li::before { content: "→"; padding: 0 8px; color: var(--muted); }
.funnel-steps li.done { color: var(--text); font-weight: 600; }
.funnel-steps li.done .muted { font-weight: 400; }
.chat-pane { display: flex; flex-direction: column; gap: 16px; }
.sent > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.sent > summary h2 { margin: 0; font-size: var(--fs-l); }
.sent[open] > summary { margin-bottom: 12px; }
.sent-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.sent-list dt { color: var(--muted); font-size: var(--fs-s); }
.sent-list dd { margin: 0; }
.sent-list .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.sent-answers { margin: 0; padding-left: 20px; }
.sent-answers li + li { margin-top: 8px; }
@media (max-width: 760px) {
  .sent-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .sent-list dd { margin-bottom: 8px; }
}
/* Статистика: таблицы внутри карточки прокручиваются, первая колонка закреплена */
.card > .table-wrap, .table-view .table-wrap { padding: 0; margin: 0 -4px; }
.table-wrap + .table-wrap { margin-top: 16px; }
.table-wrap .table td:first-child a { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .table-wrap .table th:first-child, .table-wrap .table td:first-child { min-width: 140px; max-width: 45vw; box-shadow: 1px 0 0 var(--border); }
  .section-title .sync-status { margin-left: 0; width: 100%; }
}

/* --- Агент (этап 4) --- */
.settings-block h2 { margin: 0 0 8px; font-size: var(--fs-l); }
.scale { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0; }
.scale-option { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.scale-option:hover { border-color: var(--border-strong); }
.scale-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.scale-option:has(input:focus-visible) { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.scale-option input { position: absolute; opacity: 0; pointer-events: none; }
.inline-field { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left; gap: 8px 12px; }
.inline-field input { width: 9em; }
.inline-field .hint { flex-basis: 100%; }
.advanced > summary { cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.advanced > summary h2 { display: inline; margin: 0; font-size: var(--fs-l); }
.advanced > summary span { font-weight: 400; }
.advanced[open] > summary { margin-bottom: 12px; }
.advanced > .card { margin: 12px 0 0; box-shadow: none; }
.strictness { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin: 8px 0 4px; }
.strictness input[type="range"] { width: 100%; accent-color: var(--accent); }
.rule textarea { min-height: 96px; }
@media (max-width: 760px) {
  .scale { grid-template-columns: minmax(0, 1fr); }
  .strictness { grid-template-columns: 1fr 1fr; }
  .strictness input[type="range"] { grid-column: 1 / -1; grid-row: 1; }
  .strictness span:last-of-type { text-align: right; }
}
.resume-cards { display: grid; gap: 12px; margin-bottom: 16px; }
.resume-card { margin: 0; }
.resume-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap; }
.resume-card-head h2 { margin: 0; font-size: var(--fs-l); }
.resume-card p { margin: 6px 0 0; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.table.searches .switch { display: inline-flex; }
.table.searches td { vertical-align: top; }
tr.is-stale td { background: var(--warn-bg); }
/* Подсказка «?»: <details class="qhint"><summary aria-label="…">?</summary><span>текст</span></details> */
.qhint { display: inline-block; position: relative; font-weight: 400; text-align: left; }
.qhint > summary { list-style: none; cursor: pointer; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--muted); font-size: 12px; line-height: 1; }
.qhint > summary::-webkit-details-marker { display: none; }
.qhint > span { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: min(280px, 80vw); padding: 8px 10px; border-radius: var(--radius-s); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 16px rgb(0 0 0 / 15%); font-size: var(--fs-s); white-space: normal; }

/* --- Подписка (этап 5) --- */
.periods { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0 0 12px; }
.period { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 400; }
.period:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.period-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.period-price { font-size: 22px; font-weight: 700; }
.pay-method { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.pay-method > span { display: inline-flex; align-items: center; gap: 6px; }
details.promo { margin: 0 0 16px; }
details.promo > summary { list-style: none; display: inline-block; padding-block: 2px; cursor: pointer; color: var(--accent-ink); text-decoration: underline; }
details.promo > summary::-webkit-details-marker { display: none; }
details.promo[open] > summary { display: block; margin-bottom: 8px; }
@media (max-width: 760px) {
  .table.payments thead { display: none; }
  .table.payments tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table.payments td { border: 0; padding: 0; }
  .table.payments td[data-label="Что оплачено"] { grid-column: 1 / -1; }
}
button.link.danger { color: var(--err-text); border: 0; }
.help-search input { width: 100%; }
.help-search p { margin: 8px 0 0; }
.help-link { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; vertical-align: middle; }
.help-link:hover { color: var(--accent-ink); border-color: var(--accent); }

/* Мастер первого запуска */
.wizard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.wizard-progress { height: 4px; border-radius: 2px; background: var(--border); margin: 8px 0 20px; overflow: hidden; }
.wizard-progress span { display: block; height: 100%; background: var(--accent); }
.wizard-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }

/* Отклик с отменой во «Входящих» */
.sending-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* WCAG 2.5.8: цели нажатия не меньше 24 px (где рядом другие цели) */
summary { min-height: 24px; }
p.small > a:only-child { display: inline-block; padding-block: 3px; }
/* Админка, форма тарифа: период — строка полей */
fieldset.tariff-period { border: 0; border-top: 1px solid var(--border); margin: 0; padding: 12px 0 4px; min-width: 0; }
fieldset.tariff-period legend { padding: 0 6px 0 0; }
.tariff-period .fields { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 8px; }
/* Разница промптов (страница этапа AI): строки добавлены / убраны / без изменений */
.diff { font-size: 13px; line-height: 1.5; border: 1px solid var(--border); border-radius: var(--radius-s); overflow-x: auto; max-height: 60vh; overflow-y: auto; }
.diff > div { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 10px; }
.diff .add { background: var(--ok-bg); color: var(--ok-text); }
.diff .del { background: var(--err-bg); color: var(--err-text); }
.diff .hunk { background: var(--surface-2); color: var(--muted); padding-top: 2px; padding-bottom: 2px; }
