/* Админка DomService. Строгий, плотный интерфейс: нейтральные серые, один
   фирменный синий (#0291CC, с вывески компании) - только логотип, полоса над
   меню, выбранный пункт, главные кнопки и ссылки. Красный - только то, что
   требует действия. Без теней, без эмодзи, блок занимает столько места,
   сколько нужно его содержимому. После правок поднять STATIC_VERSION в admin.py. */

:root {
  --brand: #0291cc;
  --brand-ink: #0270a0;       /* синий для текста ссылок - на белом читается лучше, чем --brand */
  --brand-soft: #e7f4fa;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f6f4;       /* шапки таблиц, поля ввода в покое, наведение */
  --side: #f6f6f4;
  --side-hover: #ececea;
  --ink: #1c1c1a;
  --ink-dim: #5f5f5a;
  --ink-faint: #8e8e88;
  --border: #e5e5e1;
  --border-strong: #d2d2cd;

  --accent: var(--brand-ink); /* старое имя - используется по всему коду */
  --accent-ink: #ffffff;
  --accent-soft: var(--brand-soft);
  --good: #2e7d46;
  --good-soft: #e9f4ec;
  --warn: #b42318;
  --warn-soft: #fbeeec;

  --radius: 6px;
  --row-pad: 7px;
  --shadow: none;
}

:root[data-theme="dark"] {
  --brand: #2fa8de;
  --brand-ink: #5cbde8;
  --brand-soft: #14313f;
  --bg: #161615;
  --surface: #1c1c1b;
  --surface-2: #232321;
  --side: #121211;
  --side-hover: #22221f;
  --ink: #e8e8e4;
  --ink-dim: #a6a6a0;
  --ink-faint: #7a7a74;
  --border: #2c2c29;
  --border-strong: #3a3a36;
  --accent-ink: #0b1a21;
  --good: #5cbf7c;
  --good-soft: #1b2a20;
  --warn: #f07a6c;
  --warn-soft: #351c19;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2fa8de;
    --brand-ink: #5cbde8;
    --brand-soft: #14313f;
    --bg: #161615;
    --surface: #1c1c1b;
    --surface-2: #232321;
    --side: #121211;
    --side-hover: #22221f;
    --ink: #e8e8e4;
    --ink-dim: #a6a6a0;
    --ink-faint: #7a7a74;
    --border: #2c2c29;
    --border-strong: #3a3a36;
    --accent-ink: #0b1a21;
    --good: #5cbf7c;
    --good-soft: #1b2a20;
    --warn: #f07a6c;
    --warn-soft: #351c19;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 228px 1fr;
  min-height: 100vh;
}

/* ---------- Меню ---------- */
/* sticky + своя прокрутка: меню не уезжает со страницей, а если пунктов станет
   больше высоты экрана - прокручивается само. */
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  color: var(--ink-dim);
  padding: 0 8px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: block; padding: 14px 10px 14px; }
.brand-logo { display: block; width: 124px; height: auto; }

.nav-group { margin-top: 10px; }

.nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: none;
  padding: 4px 10px 3px;
  font: inherit;
  font-size: 12px;
  color: var(--ink-faint);
  cursor: pointer;
  text-align: left;
}
.nav-label:hover { color: var(--ink); }
.nav-label::after { content: "−"; font-size: 13px; margin-left: 6px; }
.nav-group.collapsed .nav-label::after { content: "+"; }
.nav-group-total { margin-left: auto; color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; display: none; }
.nav-group.collapsed .nav-group-total:not(:empty) { display: inline; }
.nav-group.collapsed .nav-group-items { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 5px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--side-hover); color: var(--ink); }
.nav-item.active {
  background: var(--surface);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand);
  border-radius: 0 5px 5px 0;
}

/* Счётчик «ждёт реакции» у пункта - просто красное число справа. */
.nav-badge {
  margin-left: auto;
  color: var(--warn);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.nav-foot {
  margin-top: auto;
  padding: 12px 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}
.nav-foot span { flex-basis: 100%; color: var(--ink-dim); }
.nav-foot-link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--ink-faint);
  cursor: pointer; text-decoration: none;
}
.nav-foot-link:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Шапка страницы ---------- */
.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 16px 28px 0;
}

.topbar-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.topbar-main { min-width: 0; }

/* Второстепенная сводка справа от заголовка: «подпись число» в строку. */
.topbar-extra { display: flex; gap: 6px 20px; flex-wrap: wrap; align-items: baseline; }

.mini-stat { display: inline-flex; align-items: baseline; gap: 6px; }
.mini-stat .label { font-size: 12.5px; color: var(--ink-dim); }
.mini-stat .value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-stat .value.warn { color: var(--warn); }
.mini-stat .value.good { color: var(--ink); }

.eyebrow { font-size: 12px; color: var(--ink-faint); margin: 0 0 2px; }

h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
  text-wrap: balance;
}

h2 { font-size: 14px; font-weight: 600; margin: 0; }

.subline { color: var(--ink-dim); margin: 0 0 14px; font-size: 13px; }
.topbar > .subline { margin: 8px 0 0; }

.content { padding: 16px 28px 48px; }

/* ---------- Блоки ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-body { padding: 12px 14px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  min-height: 44px;
}
.panel-head h2 { display: flex; align-items: baseline; gap: 8px; }

/* Кнопки «переставить блок» на карточке объекта (reorderable_blocks_html):
   справа от блока, видны только при наведении - не занимают отдельную строку. */
#reorderable-blocks { padding-right: 30px; }
.block { position: relative; }
.block-toolbar {
  position: absolute; top: 9px; right: -30px;
  display: flex; flex-direction: column; gap: 3px;
  opacity: 0; transition: opacity .12s;
}
.block:hover .block-toolbar, .block-toolbar:focus-within { opacity: 1; }
.block-move-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-faint);
  border-radius: 4px;
  width: 24px;
  height: 20px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.block-move-btn:hover:not(:disabled) { color: var(--brand-ink); border-color: var(--brand); }
.block-move-btn:disabled { opacity: .35; cursor: default; }

/* ---------- Формы ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; color: var(--ink-dim); }

input[type="text"], input[type="date"], input[type="file"], input[type="password"],
input[type="number"], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  min-height: 30px;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-faint); }
textarea { width: 100%; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, .nav-item:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.btn {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 5px;
  padding: 5px 12px;
  min-height: 30px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.35;
}
.btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  font-weight: 500;
}
.btn.ghost:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--surface); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 3px 10px; min-height: 26px; font-size: 12.5px; }
.btn.danger { background: var(--warn); border-color: var(--warn); color: #fff; }

/* ---------- Таблицы ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 500;
  padding: 7px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

td {
  padding: var(--row-pad) 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.table-scroll { overflow-x: auto; }

.num { font-variant-numeric: tabular-nums; }

a.link { color: var(--brand-ink); text-decoration: none; }
a.link:hover { text-decoration: underline; }

/* Статус: цветная точка + текст, без «пилюли»-заливки. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink-dim);
}
.pill.good { color: var(--good); }
.pill.warn { color: var(--warn); }
.pill.neutral { color: var(--ink-faint); font-weight: 400; }
.pill .swatch { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
h2 .pill, h1 .pill { font-size: 13px; font-weight: 400; }

.reason-list { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Сводные цифры ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
}
.stat-row .stat-tile { border: 0; border-left: 1px solid var(--border); border-radius: 0; }
.stat-row .stat-tile:first-child { border-left: 0; }

.stat-tile .label { font-size: 12px; color: var(--ink-dim); margin-bottom: 2px; }
.stat-tile .value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile .value.warn { color: var(--warn); }
.stat-tile .value.good { color: var(--ink); }

/* Плитки-счётчики (обзор кадров): строка ячеек с общей рамкой. */
.attention-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.attention-tile {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit;
  border: 0; border-radius: 0; box-shadow: inset 1px 0 0 var(--border);
}
.attention-tile:hover { background: var(--surface-2); }
.attention-tile.is-zero .value { color: var(--ink-faint); font-weight: 400; }

/* ---------- Главная: «Требует внимания» ---------- */
.attention-list { display: flex; flex-direction: column; }
.attention-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 120px;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.attention-row:first-child { border-top: 0; }
.attention-row:hover { background: var(--surface-2); }
.attention-row .hint { color: var(--ink-faint); font-size: 12.5px; margin-left: 8px; }
.attention-row .n { text-align: right; font-weight: 600; color: var(--warn); font-variant-numeric: tabular-nums; }
.attention-row .go { text-align: right; color: var(--brand-ink); }
.attention-calm { padding: 9px 14px; border-top: 1px solid var(--border); color: var(--ink-faint); font-size: 12.5px; }
.attention-calm:first-child { border-top: 0; }
.attention-calm strong { color: var(--good); font-weight: 600; }
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.home-columns .panel { margin-bottom: 0; }
@media (max-width: 1150px) { .home-columns { grid-template-columns: 1fr; } .home-columns .panel { margin-bottom: 16px; } }

.rating-dots { display: inline-flex; gap: 2px; vertical-align: middle; }
.rating-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: inline-block; }
.rating-dots span.on { background: var(--brand); }

.card-address { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

/* Пустое состояние - одна неброская строка; у пустой таблицы шапка колонок не нужна. */
.empty-note { color: var(--ink-faint); padding: 9px 14px; font-size: 13px; }
table:has(> tbody > tr:only-child > td.empty-note) > thead { display: none; }
tbody tr:has(> td.empty-note):hover { background: none; }

.qr-box { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px 14px; }
.qr-box img { border-radius: var(--radius); border: 1px solid var(--border); background: #fff; padding: 10px; }

/* ---------- Вход ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  background: var(--side);
  border-top: 3px solid var(--brand);
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 340px;
}
.login-logo { display: block; width: 150px; margin: 0 auto 6px; }
.login-card h1 { font-size: 18px; text-align: center; }
.login-card .subline { text-align: center; margin-bottom: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .btn { width: 100%; justify-content: center; padding: 7px; }
.login-card input { width: 100%; }
.login-error {
  background: var(--warn-soft); color: var(--warn);
  border-radius: 5px; padding: 7px 10px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- Окна ---------- */
.qr-modal-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 20, 18, 0.45);
  align-items: center; justify-content: center;
  padding: 20px;
}
.qr-modal-backdrop.open { display: flex; }
.qr-modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 22px;
  width: 100%; max-width: 340px;
  text-align: center;
  position: relative;
}
.qr-modal-close {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 15px; line-height: 1; color: var(--ink-faint);
  padding: 6px;
}
.qr-modal-close:hover { color: var(--ink); }
.qr-modal-box img {
  width: 100%; max-width: 260px; height: auto;
  border-radius: 4px; background: #fff; padding: 8px;
  border: 1px solid var(--border);
}
.qr-modal-address { margin: 12px 0 4px; font-weight: 600; color: var(--ink); }
.qr-modal-hint { color: var(--ink-dim); font-size: 13px; margin: 0 0 14px; }

/* Окно с формой (form_modal_html): шире и по левому краю. */
.form-modal-box { max-width: 500px; text-align: left; max-height: 90vh; overflow-y: auto; }
.form-modal-box h2 { margin: 0 0 4px; font-size: 16px; }
.form-modal-box .subline { margin: 0 0 14px; }
.form-modal-box .toolbar .field { flex: 1 1 160px; min-width: 0; }
.form-modal-box .toolbar .field input { width: 100%; box-sizing: border-box; }
.form-modal-box hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Два QR рядом (регистрация уборщика/бригадира). */
.qr-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qr-pair-item { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.qr-pair-item img {
  width: 100%; max-width: 190px; aspect-ratio: 1; background: #fff;
  border: 1px solid var(--border); border-radius: 4px; padding: 6px; box-sizing: border-box;
}

/* hidden прячет элемент, даже если класс задаёт ему display. */
[hidden] { display: none !important; }

/* Список галочек (районы бригадира и т.п.). */
.check-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px;
}
.check-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.field .check-item { font-size: 13px; color: var(--ink); }
.check-item input { width: auto; margin: 0; min-height: 0; }

/* Опасные действия: неприметная ссылка внизу страницы открывает подтверждение. */
.page-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.link-danger {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--ink-faint);
}
.link-danger:hover { color: var(--warn); text-decoration: underline; }
.row-delete {
  background: none; border: none; padding: 0; margin-left: 10px; cursor: pointer;
  font: inherit; color: var(--warn);
}
.row-delete:hover { text-decoration: underline; }

/* Кнопки-ссылки в формах (например, «напечатать заново»). */
button.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--brand-ink); cursor: pointer;
}
button.link:hover { text-decoration: underline; }

.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Вкладки раздела (статистика и т.п.). */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 6px 10px; margin-bottom: -1px; color: var(--ink-dim); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }

/* Фильтр одной строкой над содержимым страницы (без отдельного блока). */
.filter-line { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; margin-bottom: 14px; }
.filter-line .hint, .hint { color: var(--ink-faint); font-size: 12.5px; }
.filter-line > .link, .filter-line > .hint { align-self: center; padding-top: 16px; }
.preset-group { display: flex; gap: 0; }
.preset-group .btn { border-radius: 0; margin-left: -1px; }
.preset-group .btn:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
.preset-group .btn:last-child { border-radius: 0 5px 5px 0; }

/* «Выгрузить в Excel» - свёрнутая строка (export_panel_html). */
.export-line { overflow: visible; }
.export-line > summary {
  cursor: pointer; padding: 8px 14px; color: var(--brand-ink); list-style: none; user-select: none;
}
.export-line > summary::-webkit-details-marker { display: none; }
.export-line > summary::before { content: "+"; display: inline-block; width: 14px; color: var(--ink-faint); }
.export-line[open] > summary::before { content: "−"; }
.export-line > summary .hint { margin-left: 8px; }
.export-line > form { margin: 0; padding: 4px 14px 12px; }

/* Ожидаемый состав района по кадрам (expected_staff_line) и пометка «требует внимания». */
.expected-line { margin: 0 0 10px; color: var(--ink-dim); }
.expected-line strong { color: var(--ink); font-weight: 600; }
.expected-line .pill, .expected-line .hint { margin-left: 6px; }
.attention-banner {
  border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: var(--radius);
  padding: 8px 14px; margin-bottom: 16px; background: var(--surface);
}
.attention-banner strong { color: var(--warn); font-weight: 600; }

/* Короткое пояснение под шапкой блока. */
.panel-note { margin: 0; padding: 8px 14px 0; color: var(--ink-faint); font-size: 12.5px; }

/* Строка фильтров под шапкой списка. */
.filter-bar {
  display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.filter-bar .field.grow { flex: 1 1 260px; }
.filter-bar .field.grow input { width: 100%; box-sizing: border-box; }

/* «Первые строки + Показать все»: развёрнутая таблица прокручивается внутри блока. */
.list-scroll.expanded { max-height: 70vh; overflow-y: auto; }
.list-scroll.expanded thead th { position: sticky; top: 0; z-index: 1; }
.list-footer {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 8px 14px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--ink-faint);
}
.list-footer:empty { display: none; }

.ajax-feedback {
  display: inline-block; margin-left: 10px; font-size: 12px;
  color: var(--good); opacity: 0; transition: opacity 0.2s;
  white-space: nowrap;
}
.ajax-feedback.show { opacity: 1; }

.photo-modal-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 20, 18, 0.75);
  align-items: center; justify-content: center;
  padding: 20px;
}
.photo-modal-backdrop.open { display: flex; }
.photo-modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  max-width: min(90vw, 640px);
  max-height: 90vh;
  text-align: center;
  position: relative;
}
.photo-modal-stage { display: flex; align-items: center; justify-content: center; gap: 10px; }
.photo-modal-stage img {
  max-width: 100%; max-height: 75vh; border-radius: 4px;
  display: block; background: var(--surface-2);
}
.photo-nav-btn {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 5px; width: 32px; height: 32px; flex: 0 0 auto;
  font-size: 16px; line-height: 1; cursor: pointer; color: var(--ink);
}
.photo-nav-btn:hover { border-color: var(--brand); color: var(--brand-ink); }
.photo-modal-counter { margin: 8px 0 0; color: var(--ink-dim); font-size: 13px; }

/* ---------- Раздел «Кадры» (hr_admin.py) ---------- */
.hr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 1100px) { .hr-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.hr-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.hr-columns .panel { margin-bottom: 0; }

/* Путь человека: собеседование → стажировка → работа → увольнение. */
.hr-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
@media (max-width: 900px) { .hr-steps { grid-template-columns: 1fr 1fr; row-gap: 18px; } }
.hr-step { position: relative; padding: 0 12px 0 0; }
.hr-step::before { content: ""; position: absolute; top: 6px; left: 14px; right: 0; height: 1px; background: var(--border-strong); }
.hr-step:last-child::before { display: none; }
.hr-step.done::before { background: var(--good); }
.hr-step-dot {
  position: relative; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface); box-sizing: border-box;
}
.hr-step.done .hr-step-dot { background: var(--good); border-color: var(--good); }
.hr-step.current .hr-step-dot { border-color: var(--brand); background: var(--brand); }
.hr-step.stopped .hr-step-dot { background: var(--ink-faint); border-color: var(--ink-faint); }
.hr-step-body { margin-top: 8px; }
.hr-step-title { font-weight: 600; font-size: 13.5px; }
.hr-step.todo .hr-step-title { color: var(--ink-faint); }
.hr-step-line { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }
.hr-step-action { margin-top: 8px; }

/* «Следующий шаг» над карточкой человека. */
.hr-callout {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 13.5px;
}
.hr-issues { display: flex; gap: 4px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.hr-kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 18px; }
.hr-kv { display: flex; flex-direction: column; gap: 2px; }
.hr-kv span { font-size: 12px; color: var(--ink-faint); }
.hr-kv strong { font-weight: 500; font-size: 13.5px; }
.hr-comment { white-space: pre-wrap; }

/* Формы кадров во всплывающих окнах - две колонки полей. */
.hr-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 520px) { .hr-form-grid { grid-template-columns: 1fr; } }
.hr-form-grid .field input, .hr-form-grid .field select, .hr-form-grid .field textarea { width: 100%; box-sizing: border-box; }
.hr-form-grid .hr-wide, .hr-form-section { grid-column: 1 / -1; }
.hr-form-section { font-weight: 600; font-size: 13px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.hr-form-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.hr-form-actions { margin-top: 14px; display: flex; justify-content: flex-end; }
.hr-hint { font-size: 12px; color: var(--ink-faint); }
.form-modal-box:has(.hr-form-section) { max-width: 640px; }
.hr-filter-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 9px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px;
}
.hr-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.panel-head .hr-chips { margin-bottom: 0; }
.hr-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hr-suggest .subline { margin: 0; display: inline; font-size: 12px; }
.hr-quick { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
/* Справочники кадров - список вариантов с маленькими кнопками действий. */
.hr-option-list { list-style: none; margin: 0 0 12px; padding: 0; }
.hr-option {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.hr-option.is-hidden > span:first-child { color: var(--ink-faint); text-decoration: line-through; }
.hr-option-actions { display: flex; gap: 2px; flex-shrink: 0; }
.hr-icon-btn {
  background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer;
  padding: 1px 6px; font: inherit; font-size: 12.5px; color: var(--ink-faint);
}
.hr-icon-btn:hover { border-color: var(--border-strong); color: var(--ink); }
.hr-used {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--ink-faint); font-size: 11.5px;
}
.hr-option-add { display: flex; gap: 6px; }
.hr-option-add input { flex: 1; min-width: 0; }
/* Сортировка по клику на заголовок (TABLE_TOOLS_SCRIPT в hr_admin.py). */
th.hr-sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.hr-sort-th:hover { color: var(--ink); }
th.hr-sort-th::after { content: " ↕"; opacity: .35; font-size: 10px; }
th.hr-sort-th[data-dir="asc"]::after { content: " ▲"; opacity: 1; }
th.hr-sort-th[data-dir="desc"]::after { content: " ▼"; opacity: 1; }
.hr-table-search { min-width: 200px; }
.hr-more-filters { flex-basis: 100%; }
.hr-more-filters summary { cursor: pointer; font-size: 12.5px; color: var(--brand-ink); }
.hr-more-grid { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 10px; align-items: flex-end; }

/* ---------- Узкий экран ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .topbar, .content { padding-left: 14px; padding-right: 14px; }
}
