:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6fed;
  --pass: #128a4d;
  --pass-bg: #e6f5ec;
  --fail: #c02626;
  --fail-bg: #fdecec;
  --partial: #9a6700;
  --partial-bg: #fdf3e0;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2027;
    --ink: #e8eaed;
    --muted: #9aa3ad;
    --line: #2c323a;
    --accent: #6ea0ff;
    --pass: #57d08c;
    --pass-bg: #17321f;
    --fail: #ff8a8a;
    --fail-bg: #3a1c1c;
    --partial: #e2b258;
    --partial-bg: #372a13;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 650; color: var(--ink); text-decoration: none; }
.breadcrumbs { flex: 1; color: var(--muted); font-size: 14px; }
.breadcrumbs a { color: var(--accent); text-decoration: none; }
.breadcrumbs > *:not(:first-child)::before { content: " / "; color: var(--line); }

.view { padding: 24px; max-width: 1400px; margin: 0 auto; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 16px; }

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

.pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.pill.pass { color: var(--pass); background: var(--pass-bg); border-color: transparent; }
.pill.fail { color: var(--fail); background: var(--fail-bg); border-color: transparent; }
.pill.partial { color: var(--partial); background: var(--partial-bg); border-color: transparent; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
/* Адрес вебхука длинный — поле тянется на всю свободную ширину строки. */
.field.grow { flex: 1 1 420px; min-width: 320px; }
.field label { font-size: 12px; color: var(--muted); }

/* ⚠️ Тип поля нужно ДОБАВЛЯТЬ в этот список. Всё, чего здесь нет, браузер
   рисует по умолчанию, и оно выбивается из остального интерфейса: так до
   09.09.2026 выглядели числовые поля таймаута у проверки сценариев. */
select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  min-width: 180px;
}

/* Числовое поле в 180px рядом с подписью «Попыток доставки» выглядит пустым:
   ширину задаём по содержимому, а не по общему минимуму. */
input[type="number"] { min-width: 0; width: 110px; }

select:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="number"]:focus-visible,
input[type="url"]:focus-visible,
input[type="search"]:focus-visible,
input[type="time"]:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

select:disabled,
input:disabled,
textarea:disabled { opacity: 0.55; cursor: not-allowed; }

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

button {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 7px 13px;
  font: inherit;
  cursor: pointer;
  background: var(--panel);
  color: var(--ink);
}

button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: none; }

.q { font-weight: 550; }
.answer { white-space: pre-wrap; color: var(--muted); font-size: 14px; max-height: 12em; overflow: auto; }
.answer.empty { font-style: italic; }
.verdict-buttons { display: flex; gap: 6px; }
.verdict-buttons button { padding: 4px 9px; font-size: 13px; }
.verdict-buttons button[aria-pressed="true"].v-pass { background: var(--pass-bg); color: var(--pass); border-color: var(--pass); }
.verdict-buttons button[aria-pressed="true"].v-fail { background: var(--fail-bg); color: var(--fail); border-color: var(--fail); }
.verdict-buttons button[aria-pressed="true"].v-partial { background: var(--partial-bg); color: var(--partial); border-color: var(--partial); }

.banner {
  background: var(--partial-bg);
  color: var(--partial);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.banner.error { background: var(--fail-bg); color: var(--fail); }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 20px;
  min-width: 340px;
}

dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog input { width: 100%; }

.row-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
/* Кнопки в ячейке таблицы — без нижнего отступа ряда (30.10.2026) */
.cell-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Сводка по прогонам в работе (14.08.2026) */
.runs-panel { margin: 0 0 20px; }
.runs-panel h2 { margin: 0 0 4px; font-size: 16px; }
.runs-panel p { margin: 0 0 10px; }
.runs-panel table { font-size: 14px; }
.runs-panel th, .runs-panel td { padding: 9px 12px; vertical-align: middle; }
.runs-panel td button { padding: 4px 10px; font-size: 13px; white-space: nowrap; }

/* Разделы проекта (28.08.2026)
   Страница проекта разрослась: чеклист, прогоны, инстансы, расписание — всё
   подряд одним свитком. Теперь это отдельные страницы, а здесь — навигация. */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 14px 0 20px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  white-space: nowrap;
}

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

.tab.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 550;
}

.tab .pill { margin-left: 6px; }

/* Карточка раздела: та же плитка, что на списке проектов, но с описанием */
.section-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.section-cards .card p { margin: 6px 0 0; }

/* Панель настройки: заголовок, поля, действия */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel-head h3 { margin: 0; font-size: 15px; }
.panel .field { margin-right: 14px; }
.panel-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

input[type="time"] {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
}

/* Чекбоксы дней недели — плитками, а не строкой мелких квадратиков */
.daybox { display: flex; gap: 6px; flex-wrap: wrap; }

.daybox label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.daybox label:has(input:checked) { color: var(--ink); border-color: var(--accent); background: var(--panel); }
.daybox input { accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { accent-color: var(--accent); }

textarea.message { width: 100%; min-height: 150px; font-family: inherit; line-height: 1.5; }
.panel textarea { display: block; }


/* Шапка проекта: имя и вкладки живут вне сменяемого содержимого (28.08.2026).
   Раньше они перерисовывались вместе с разделом и на время загрузки исчезали;
   теперь остаются на месте и не уезжают при прокрутке длинной таблицы. */
.project-header {
  position: sticky;
  top: var(--topbar-h, 53px);
  z-index: 9;
  background: var(--bg);
  padding: 20px 24px 0;
  max-width: 1400px;
  margin: 0 auto;
}

.project-header h1 { margin-bottom: 0; }
.project-header .tabs { margin-bottom: 0; }
.project-header:not([hidden]) + .view { padding-top: 20px; }

/*
   Режим чтения: на странице документа шапки НЕ закреплены.
 
   В инструменте закреплённые шапки полезны — в чеклисте на сотни строк из них
   видно, где ты и куда переключиться. Документ же читают сверху вниз, и там те
   же полторы сотни пикселей просто съедают текст. Класс ставится в `render()`
   ровно на время показа документа.
*/
body.reading .topbar,
body.reading .project-header {
  position: static;
}

/* ---------- документы команды ---------- */
/*
   Разборы и планы работ читаются подряд, а не сканируются как таблица, поэтому
   колонка узкая: длинная строка на широком мониторе нечитаема. Цвета берём из
   общих переменных — тёмная тема получается сама.
*/

.doc { max-width: 760px; }
.doc-head { margin-bottom: 20px; }
.doc-head h1 { margin-bottom: 6px; }

.doc-standfirst { font-size: 17px; line-height: 1.55; margin: 0 0 20px; }

.doc-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 13px;
  color: var(--muted);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.doc-facts b { font-weight: 550; color: var(--ink); }

.doc h2.doc-h2 {
  font-size: 19px;
  margin: 36px 0 10px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.doc h3.doc-h3 { font-size: 15px; margin: 24px 0 8px; }
.doc p { margin: 0 0 14px; }
.doc-sub { margin-top: -4px; }

.doc-list { margin: 0 0 16px; padding-left: 20px; }
.doc-list li { margin-bottom: 8px; }

.doc code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Таблицы шире колонки текста: прокручиваем их, а не страницу. */
.doc-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.doc-table table { min-width: 560px; border-radius: 0; }
.doc-table td { font-size: 14px; }
.doc-table tr:last-child td { border-bottom: 0; }
.doc-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.doc-callout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 18px 0;
}
.doc-callout p:last-child { margin-bottom: 0; }
.doc-callout-risk { border-left-color: var(--fail); }

.doc-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.doc-callout-risk .doc-label { color: var(--fail); }

/* Этапы — настоящая последовательность, поэтому нумерованный список. */
.doc-stages { list-style: none; padding: 0; margin: 18px 0 0; counter-reset: stage; }
.doc-stages > li {
  counter-increment: stage;
  border-top: 1px solid var(--line);
  padding: 18px 0 18px 76px;
  position: relative;
}
.doc-stages > li:last-child { border-bottom: 1px solid var(--line); }
.doc-stages > li::before {
  content: "Этап " counter(stage);
  position: absolute;
  left: 0;
  top: 20px;
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}
.doc-stages h3 { font-size: 16px; margin: 0 0 6px; }
.doc-stages p:last-of-type { margin-bottom: 0; }

.doc-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.doc-meta b { font-weight: 550; color: var(--ink); }

.doc-checks { list-style: none; padding: 0; margin: 14px 0 0; }
.doc-checks li { position: relative; padding-left: 26px; margin-bottom: 10px; }
.doc-checks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--line);
  border-radius: 3px;
}

.doc-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

@media (max-width: 600px) {
  .doc-stages > li { padding-left: 0; padding-top: 34px; }
  .doc-stages > li::before { top: 14px; }
}

/* ---------- журнал обращений ---------- */

.log-table { overflow-x: auto; }
.log-table table { min-width: 720px; }
.log-row { cursor: pointer; }
.log-row:hover td { background: var(--bg); }
.log-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.log-events { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/*
   Решение сервиса и то, что ушло клиенту, различаются полосой слева: при
   разборе первым делом сравнивают именно эту пару, и глазами она должна
   разделяться без чтения подписей.
*/
.log-event {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.log-event.is-plan { border-left-color: var(--accent); }
.log-event.is-commit { border-left-color: var(--pass); }

.log-event-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.log-kind { font-size: 13px; font-weight: 550; }
.log-msg { font-size: 14px; margin-bottom: 6px; }
.log-answer { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.log-event.is-failed { border-left-color: var(--fail); }
.log-ids { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* Событие SmartBot как пришло: свёрнуто, разворачивается кнопкой. */
.log-source-wrap { margin-top: 8px; }
.log-source {
  margin: 8px 0 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 420px;
  overflow: auto;
}

/* ---------- состояние установки ---------- */

.health-card { cursor: default; }
.health-card:hover { border-color: var(--line); }
.health-card.is-down { border-left: 3px solid var(--fail); }
.health-issues { margin: 10px 0 0; padding-left: 18px; font-size: 13px; }
.health-issues li { margin-bottom: 6px; }
