/* Бело-жёлтая палитра в духе 1С. Жёлтый — акцент, текст на нём тёмный:
   белый по жёлтому нечитаем, контраст падает ниже допустимого. */
:root {
  --bg: #fffdf3;
  --surface: #ffffff;
  --text: #2b2b2b;
  --muted: #7d7566;
  --border: #e6dcc2;
  --accent: #ffcc00;
  --accent-hover: #f2bd00;
  --accent-ink: #2b2416;
  --danger-bg: #fdecea;
  --danger-text: #7f1d1d;
  --danger-border: #f5c6c2;
  --shadow: 0 10px 30px rgba(120, 95, 0, .12);
  /* Цвета рисунка одинаковы в светлой и тёмной теме: это картинка,
     а не элемент интерфейса, и она должна читаться в обеих. */
  --ink: #2b2b2b;
  --cat-fur: #ffcf1f;
  --ball: #d64535;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a14;
    --surface: #262319;
    --text: #efeade;
    --muted: #a89e8a;
    --border: #3b3627;
    --accent: #ffcc00;
    --accent-hover: #ffd633;
    --accent-ink: #2b2416;
    --danger-bg: #3a1f1f;
    --danger-text: #f2a5a2;
    --danger-border: #6b3333;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

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

/* ---------- Страницы входа ---------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.auth-title {
  margin: 6px 0 24px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

button[type="submit"] {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:hover { background: var(--accent-hover); }

.lead {
  margin: -12px 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.alert {
  margin: 0 0 16px;
  padding: 9px 11px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  font-size: 13.5px;
}

.hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Кот на коробке ---------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Ролик с котом. Фон у него светлый, поэтому в тёмной теме он читается
   как отдельная карточка — скругляем и подкладываем рамку, чтобы это
   выглядело намеренно, а не как непрозрачная заплатка. */
.hero,
.hero-still {
  display: block;
  width: 100%;
  height: auto;
  margin: -4px 0 16px;
  border-radius: 10px;
  background: #f2f2f0;
}

.hero-still { display: none; }

/* Векторная сцена оставлена в шаблоне как запасной вариант: чтобы
   вернуть её вместо ролика, достаточно убрать этот класс. */
.scene--fallback { display: none; }

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

/* Надпись на картоне — не чёрная, а тёмно-коричневая с прозрачностью:
   краска на картоне всегда чуть впитывается, чистый чёрный выглядит
   наклейкой поверх. */
.box-label {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 1px;
  fill: #5f4527;
  opacity: .82;
}

/* Все части сцены живут на одном такте: кот доходит до клубка, бьёт по
   нему лапой, разворачивается и идёт обратно. */
.stroll { animation: stroll 11s ease-in-out infinite; }

.facing {
  transform-box: fill-box;
  transform-origin: center;
  animation: facing 11s steps(1, end) infinite;
}

.legs-front, .legs-back {
  transform-box: fill-box;
  transform-origin: 50% 0;
}

.legs-front { animation: step-a .55s ease-in-out infinite; }
.legs-back  { animation: step-b .55s ease-in-out infinite; }

.tail {
  transform-box: fill-box;
  transform-origin: 100% 100%;
  animation: tail-sway 2.4s ease-in-out infinite;
}

.eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 6s infinite;
}

.ball {
  transform-box: fill-box;
  transform-origin: center;
  animation: ball-hit 11s ease-in-out infinite;
}

@keyframes stroll {
  0%,  4%   { transform: translateX(0); }
  38%, 50%  { transform: translateX(70px); }
  84%, 100% { transform: translateX(0); }
}

/* steps(1) — разворот происходит мгновенно, без зеркального «растекания». */
@keyframes facing {
  0%,  49%  { transform: scaleX(1); }
  50%, 99%  { transform: scaleX(-1); }
  100%      { transform: scaleX(1); }
}

@keyframes step-a {
  0%, 100% { transform: rotate(16deg); }
  50%      { transform: rotate(-16deg); }
}

@keyframes step-b {
  0%, 100% { transform: rotate(-16deg); }
  50%      { transform: rotate(16deg); }
}

@keyframes tail-sway {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-14deg); }
}

@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  96%           { transform: scaleY(0.1); }
}

@keyframes ball-hit {
  0%, 36%   { transform: translate(0, 0) rotate(0deg); }
  40%       { transform: translate(6px, -9px) rotate(-40deg); }
  44%       { transform: translate(2px, 0) rotate(20deg); }
  47%       { transform: translate(4px, -4px) rotate(-14deg); }
  52%, 100% { transform: translate(0, 0) rotate(0deg); }
}

/* Анимация — украшение. Тем, кому движение мешает, она не нужна:
   ролик убираем совсем и показываем тот же кадр неподвижно. */
@media (prefers-reduced-motion: reduce) {
  .stroll, .facing, .legs-front, .legs-back,
  .tail, .eyes, .ball { animation: none; }

  .hero { display: none; }
  .hero-still { display: block; }
}

/* ---------- Кабинет ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.company {
  padding: 2px 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.spacer { flex: 1; }

/* ---------- Значок профиля и меню ---------- */

.usermenu { position: relative; }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
}

.avatar:hover { background: var(--accent-hover); }

.avatar:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 210px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.menu form { margin: 0; }

.menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.menu-name { font-weight: 600; font-size: 14px; }
.menu-sub { color: var(--muted); font-size: 12.5px; }

.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover { background: var(--bg); }
.menu-item--muted { color: var(--muted); }

/* ---------- Каркас: шапка, меню разделов, рабочая область ---------- */

/* Сетка задана на body, а не на .shell с вычетом высоты шапки:
   иначе любая правка отступов в шапке ломала бы высоту меню. */
.cabinet {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: 216px 1fr;
  align-items: stretch;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.nav-item:hover { background: var(--bg); }

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* min-width: 0 обязателен: без него ячейка сетки не даёт содержимому
   сжиматься уже своей «естественной» ширины, и на узком экране страница
   уезжает вбок вместе с карточками. */
.work {
  max-width: 900px;
  min-width: 0;
  padding: 28px 32px;
}

.work-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.work-head h1 {
  margin: 0;
  font-size: 20px;
}

/* На узком экране колонка меню не помещается: разделы уезжают в строку
   под шапкой, прокручиваемую вбок. */
@media (max-width: 720px) {
  /* Строка меню — по содержимому, остальное отдаём работе: иначе полоса
     разделов растягивается на пол-экрана вместе с подсветкой активного. */
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-item { white-space: nowrap; }
  .work { padding: 22px 16px; }
}

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

.btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

/* Форма входа задаёт button[type="submit"] на всю ширину. У кнопки в
   строке заголовка и в окне это неуместно, а специфичность там выше,
   чем у одного класса, — поэтому селектор с именем тега. */
button.btn {
  width: auto;
  margin-top: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Объявлено после button.btn и с той же специфичностью — иначе акцентная
   кнопка-отправка теряет жёлтый фон, а обычная его получает. */
button.btn--accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

button.btn--accent:hover { background: var(--accent-hover); }

.btn:hover { background: var(--bg); }

.btn--accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

.btn--accent:hover { background: var(--accent-hover); }

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

.btn:disabled:hover { background: var(--accent); }

/* ---------- Список баз и пустое состояние ---------- */

.db-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.db {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.db-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.db-name { font-weight: 600; }
.db-state { color: var(--muted); font-size: 13px; }

.db-states {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 4px;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.db-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

/* Кнопки карточки прижаты к правому краю и переносятся под текст, когда
   места не хватает: на узком экране иначе сжимается название базы. */
.db-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.db-actions form { margin: 0; }

/* Адрес может быть длинным и без пробелов: без переноса по любому месту
   он растягивает карточку и выталкивает страницу за край экрана. */
.db-url {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* ---------- Модальное окно ---------- */

.modal {
  width: min(430px, calc(100vw - 32px));
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(20, 16, 4, .45); }

.modal form,
.modal-body { padding: 20px 22px 18px; }

/* Список инструментов длиннее формы: даём ширину и потолок по высоте,
   чтобы окно не уезжало за пределы экрана. */
.modal--wide { width: min(640px, calc(100vw - 32px)); }

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  margin: 14px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.tool {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tool-head { display: flex; align-items: center; gap: 8px; }

.tool-name {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

.tool-desc { color: var(--muted); font-size: 13px; line-height: 1.45; }

.tag {
  padding: 1px 7px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Кнопка, которая по виду часть текста: открывает окно со списком
   инструментов прямо из строки состояния. */
.linklike {
  padding: 0;
  background: none;
  border: 0;
  color: #9a6f00;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) { .linklike { color: var(--accent); } }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  margin-left: auto;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

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

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.field-error {
  margin: -10px 0 12px;
  color: var(--danger-text);
  font-size: 12.5px;
}

.hint--left { text-align: left; margin-top: 4px; }

/* Кружок состояния — только подсказка рядом с текстом: состояние
   названо словами, поэтому цвет не остаётся единственным признаком. */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex: none;
}

/* Зелёный — сервис ответил, жёлтый — ответил, но не принял логин с
   паролем, красный — связи нет. Серый по умолчанию — ещё не проверяли.
   Оттенки взяты насыщенные: акцентный #ffcc00 на белой карточке в виде
   кружка почти не виден. */
.dot--ok { background: #3f9d58; }
.dot--warn { background: #d99400; }
.dot--down { background: #d64535; }

.empty {
  padding: 28px 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  text-align: center;
}

.empty-title { margin: 0 0 6px; font-weight: 600; }

.empty-text {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--muted);
  font-size: 13.5px;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 24px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }

code {
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

a { color: #9a6f00; }
@media (prefers-color-scheme: dark) { a { color: var(--accent); } }

/* ---------- Отчёты ---------- */

/* Параметры отчёта в один ряд с переносом: на широком экране помещаются
   в строку, на узком встают друг под друга. */
.report-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}

.field--wide { min-width: 260px; flex: 1; }

.field-label { color: var(--muted); font-size: 12.5px; }

.input {
  max-width: 100%;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

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

/* Своя прокрутка у таблицы: ведомость шире узкого экрана, и ехать вбок
   должна она, а не вся страница. */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  /* Мельче остального текста: восемь колонок ведомости иначе не помещаются
     в рабочую область, и сальдо на конец уезжает под горизонтальную
     прокрутку — а это последнее, ради чего отчёт открывают. */
  font-size: 12.5px;
}

/* Переносить разрешено только наименованиям: без этого строка вроде
   «Расчеты с покупателями и заказчиками (в валюте)» растягивает таблицу
   так, что сальдо на конец уезжает за край экрана. Ширину задаём явно —
   иначе браузер отдаёт всё место числам, а название рвёт по одному слову. */
/* Ширину не фиксируем: числовые колонки берут своё, наименованию
   достаётся остаток — так оно переносится лишь когда места правда нет. */
.sheet th:nth-child(2),
.sheet td:nth-child(2) {
  min-width: 18ch;
  white-space: normal;
}

.sheet th,
.sheet td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.sheet thead th {
  background: var(--bg);
  font-size: 12.5px;
  font-weight: 600;
}

/* Верхний ярус шапки объединяет пары колонок — вертикальная линия
   показывает, где кончается одна пара и начинается следующая. */
.sheet thead tr:first-child th[colspan] {
  text-align: center;
  border-left: 1px solid var(--border);
}

/* Селектор с классом таблицы: правило выравнивания у .sheet th сильнее
   одиночного .num и перебило бы его. */
.sheet th.num,
.sheet td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sheet th.col-code,
.sheet td.col-code { white-space: nowrap; }

.sheet td.col-code { font-weight: 600; }

.sheet tbody tr:hover { background: var(--bg); }

.sheet tfoot td {
  background: var(--bg);
  border-top: 2px solid var(--border);
  border-bottom: 0;
  font-weight: 600;
}

/* Разрезы отчёта — набор флажков внутри общей строки параметров. */
.field--breakdown {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: auto;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding-bottom: 9px;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  cursor: pointer;
}

.check input { margin: 0; accent-color: var(--accent); }

.report-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
}

/* Ссылки-кнопки выгрузки: у .btn оформление задано для button, ссылке
   нужно снять подчёркивание и выровнять по высоте. */
a.btn {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

@media (prefers-color-scheme: dark) { a.btn { color: var(--text); } }

/* Промежуточный итог по группе: строк при развороте по контрагентам
   сотни, и без выделения границу группы глазом не поймать. */
.sheet tr.row-total td {
  background: var(--bg);
  font-weight: 600;
}

/* Пояснение под кнопками выгрузки: экран и файл показывают разное,
   и об этом нужно сказать прямо, а не оставлять на догадку. */
.report-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Анализ ---------- */

.picker {
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.picker-head {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12.5px;
}

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

/* Карточка базы целиком служит переключателем: попасть в маленький
   квадратик флажка труднее, чем нажать на название. */
.chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: inherit;
  cursor: pointer;
}

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

/* Выбранная база подсвечивается рамкой, а не только галочкой: при выборе
   двух баз из пяти взглядом должно быть видно, какие именно отмечены. */
.chip:has(input:checked) {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chip input { margin: 3px 0 0; accent-color: var(--accent); }
.chip-body { display: flex; flex-direction: column; gap: 3px; }
.chip-name { font-weight: 600; }

.chip-state {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.picker-period {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

/* Плитки проверок: широкие карточки в ряд, на узком экране — столбцом. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tile--soon { opacity: .72; }

.tile-title { margin: 0; font-size: 16px; }
.tile-summary { margin: 0; font-size: 13.5px; }

.tile-details {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.tile-need {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* Кнопка прижата к низу, чтобы у соседних плиток они были на одной линии
   независимо от длины описания. */
.tile .btn, .tile .tag { margin-top: auto; align-self: flex-start; }

.runs-head { margin: 26px 0 10px; font-size: 15px; }

.runs { margin: 0; padding: 0; list-style: none; }

.run + .run { margin-top: 6px; }

.run-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
}

.run-link:hover { border-color: var(--accent); }
.run-when { color: var(--muted); white-space: nowrap; }
.run-what { flex: 1; min-width: 0; }
.run-status { white-space: nowrap; font-weight: 600; }
.run-status--running { color: #9a6f00; }
.run-status--failed { color: var(--danger-text); }

/* ---------- Выбор активной базы в шапке ---------- */

.dropdown { position: relative; }

/* Кнопка-индикатор: показывает текущую базу и открывает список. Название
   видно всегда — при десятке баз важнее всего не перепутать, где работаешь. */
.basebtn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

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

.basebtn[aria-expanded="true"] {
  background: var(--surface);
  border-color: var(--accent);
}

.basebtn-label { color: var(--muted); font-size: 12px; }
.basebtn-name { font-weight: 600; }
.basebtn-caret { color: var(--muted); font-size: 10px; }

.menu--wide { min-width: 280px; }

/* Пункт списка баз: название и состояние связи в две строки. */
.baseitem {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  text-align: left;
}

.baseitem--on {
  background: var(--bg);
  font-weight: 600;
}

.baseitem-state {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* Текущая база в разделе — напоминание, а не выбор. */
.picker-current {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.picker-hint { color: var(--muted); font-size: 12.5px; }

/* Пункты меню — кнопки внутри форм, а форма входа красит все submit
   в акцентный жёлтый и растягивает на всю ширину. Специфичность у
   button[type="submit"] выше, чем у одного класса, поэтому переопределяем
   с явным указанием тега — и обязательно после того правила. */
button.menu-item {
  width: 100%;
  margin: 0;
  padding: 9px 14px;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--text);
  font-weight: 400;
}

button.menu-item:hover { background: var(--bg); }
button.menu-item.menu-item--muted { color: var(--muted); }

button.baseitem--on,
button.baseitem--on:hover {
  background: var(--bg);
  font-weight: 600;
}

/* ---------- Плавность и скругления ---------- */

/* Переходы только по цвету, рамке и тени: анимировать размеры дороже и
   заметно дёргает вёрстку. */
.btn,
a.btn,
button.btn,
.basebtn,
.avatar,
.nav-item,
.chip,
.tile,
.run-link,
.menu-item,
button.menu-item,
.input,
.db,
.linklike {
  transition: background-color .16s ease,
              border-color .16s ease,
              box-shadow .16s ease,
              color .16s ease;
}

/* Скругления крупнее: мелкий радиус выглядит как рамка таблицы, крупный —
   как карточка. */
.btn, a.btn, button.btn, .input, .field-error { border-radius: 10px; }
.menu { border-radius: 14px; }
.tile, .modal, .table-wrap, .picker, .report-form, .empty { border-radius: 14px; }
.db, .run-link, .chip { border-radius: 12px; }

/* Тень у всплывающих слоёв мягче и глубже — они должны читаться как
   приподнятые над страницей, а не приклеенные к ней. */
.menu {
  box-shadow: 0 14px 38px rgba(120, 95, 0, .16);
  border-color: var(--border);
}

@media (prefers-color-scheme: dark) {
  .menu { box-shadow: 0 14px 38px rgba(0, 0, 0, .5); }
}

/* Появление меню: короткий сдвиг сверху вниз. Элемент до этого скрыт
   атрибутом hidden, поэтому анимация проигрывается ровно при показе. */
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.menu:not([hidden]) { animation: menu-in .16s ease-out; }

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

.btn:focus-visible,
a.btn:focus-visible,
.basebtn:focus-visible,
.chip:focus-within,
.run-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Движение — украшение. Тем, кому оно мешает, оставляем мгновенную смену. */
@media (prefers-reduced-motion: reduce) {
  .menu:not([hidden]) { animation: none; }
  .btn, a.btn, button.btn, .basebtn, .avatar, .nav-item, .chip, .tile,
  .run-link, .menu-item, button.menu-item, .input, .db, .linklike {
    transition: none;
  }
}

/* ---------- Каталог проверок ---------- */

.ops {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

/* Плитка операции: знак, название, одна строка о сути. Подробности и
   запуск — внутри, здесь только выбор. */
.op {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.op:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 26px rgba(120, 95, 0, .1);
}

@media (prefers-color-scheme: dark) {
  .op:hover { box-shadow: 0 10px 26px rgba(0, 0, 0, .4); }
}

.op--soon { opacity: .7; }
.op--soon:hover { border-color: var(--border); box-shadow: none; }

.tile-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  color: var(--muted);
}

.op:hover .tile-icon { color: var(--text); }

.op-title { font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.op-summary { color: var(--muted); font-size: 13px; line-height: 1.45; }
.op .tag { align-self: flex-start; }

/* Описание проверки над формой запуска. */
.op-about {
  margin: 0 0 18px;
  max-width: 76ch;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

/* База в форме запуска только показывается — меняют её в шапке. */
.field-static {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 0;
  font-weight: 600;
}

/* ---------- История запусков ---------- */

.run-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13.5px;
}

.run-when { display: flex; flex-direction: column; white-space: nowrap; }
.run-ago { color: var(--muted); font-size: 12px; }
.run-found { white-space: nowrap; }

.run-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.run-error {
  margin: 6px 0 0 14px;
  color: var(--danger-text);
  font-size: 12.5px;
}

/* Кнопки в строке истории мельче: их две в каждой строке, и полноразмерные
   перетягивали бы внимание с самих находок. */
.run-actions .btn {
  padding: 5px 11px;
  font-size: 12.5px;
}

/* Выбор справочников для поиска дублей. */
.catalogs {
  flex: 1 0 100%;
  margin: 6px 0 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* Справочники ровной сеткой: у каждого своё число полей, и в общую
   строку они складывались бы рвано. */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.catalog {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.catalog-title { margin: 0; font-size: 13.5px; font-weight: 600; }

.catalog-why {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.catalog-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: auto;
}

.catalog-fields .check { font-size: 12.5px; }

/* Галочка на самом справочнике. Выключенный гаснет целиком — видно, что
   искать в нём не будут, а выбор полей внутри при этом сохраняется. */
.catalog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}

.catalog-head input { margin: 0; accent-color: var(--accent); }
.catalog-title { font-weight: 600; }

.catalog:has(.catalog-head input:checked) {
  background: var(--surface);
  border-color: var(--accent);
}

.catalog:has(.catalog-head input:not(:checked)) .catalog-why,
.catalog:has(.catalog-head input:not(:checked)) .catalog-fields {
  opacity: .45;
}

/* Галочки полей блокирует скрипт, но и без него менять их бессмысленно —
   поля выключенного справочника на сервере всё равно не берутся. */
.catalog:has(.catalog-head input:not(:checked)) .catalog-fields {
  pointer-events: none;
}

.catalog-fields input:disabled + *,
.catalog-fields .check:has(input:disabled) { cursor: default; }

/* Две ступени выбора не должны выглядеть одинаково: галочка справочника —
   главная, акцентная и чуть крупнее; галочки полей внутри приглушены. */
.catalog-head input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.catalog-fields .check input {
  accent-color: var(--muted);
  width: 13px;
  height: 13px;
}

/* Идущая проверка заметна сама по себе — пунктир и акцентная рамка, чтобы
   не путать обновление страницы с новым запуском. */
.empty--running {
  border-style: solid;
  border-color: var(--accent);
  background: var(--bg);
}

.runs-count {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.pager {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
}
