/* =========================================================================
   Оформление «ночной пульт» (docs/redesign/DESIGN.md).

   Цвет в разметке задаётся только переменной: захардкоженный #fff в шаблоне —
   баг (инвариант 14). Тёмная тема — значения по умолчанию: ночные кадры
   читаются на тёмном лучше, а именно ночью на сервис и смотрят. Светлая
   приходит либо от системы в режиме «авто», либо явным выбором через
   data-theme на <html>. Порядок правил важен: явный выбор побеждает
   системный.
   ========================================================================= */
@import url("fonts.css");

:root {
  /* Поверхности */
  --bg: #0B0D11;
  --sidebar: #0E1116;
  --panel: #13171D;
  --panel-2: #1A1F27;
  --line: #252B35;
  --field: #0B0D11;

  /* Текст */
  --text: #E9ECF1;
  --text-muted: #9AA3B2;
  --text-dim: #848D9C;

  /* Акцент и семантика. Цвет здесь — это смысл: зелёный «в порядке»,
     янтарный «нужно внимание», красный «опасно», фиолетовый — всё про
     модель, синий — акцент и интерактив. */
  --accent: #86A8FF;
  --accent-bg: rgba(134, 168, 255, .12);
  --on-accent: #0B0D11;
  --ok: #4CD6A0;
  --ok-bg: rgba(76, 214, 160, .12);
  --warn: #F5B84A;
  --warn-bg: rgba(245, 184, 74, .12);
  --err: #FF8080;
  --err-bg: rgba(255, 128, 128, .12);
  --ai: #C3A6FF;
  --ai-bg: rgba(195, 166, 255, .10);
  --warn-line: rgba(245, 184, 74, .30);
  --on-warn: #0B0D11;
  /* Уровни опасности: спокойно, внимание, подозрительно, тревога, не оценено.
     «Подозрительно» — между жёлтым и красным, своего цвета у палитры нет. */
  --risk-odd: #FF9A4D;
  --risk-calm: var(--ok);
  --risk-watch: var(--warn);
  --risk-alarm: var(--err);
  --risk-none: var(--text-dim);
  --osd: rgba(0, 0, 0, .55);
  --video: rgb(0, 0, 0);
  /* Затемнения плеера: он всегда лежит на видео, тема тут ни при чём. */
  --scrim-top: rgba(0, 0, 0, .6);
  --scrim-bottom: rgba(0, 0, 0, .7);
  --osd-hover: rgba(255, 255, 255, .12);
  --on-osd: #FFFFFF;
  --scrim: rgba(0, 0, 0, .50);

  /* Типографика */
  --font-sans: 'Onest', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Форма */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Размеры каркаса */
  --space-page-x: 32px;
  --gap: 20px;
  --sidebar-w: 248px;
  --topbar-h: 72px;
  --tap: 44px;

  /* Имена прежнего набора: страницы ещё верстаются по ним, и переезжают
     постранично. Псевдоним, а не второй источник правды. */
  --surface: var(--panel);
  --surface-sunken: var(--panel-2);
  --border: var(--line);
  --muted: var(--text-muted);
  --error: var(--err);
  --tint: var(--panel-2);
  --tint-accent: var(--accent-bg);
  --tint-ok: var(--ok-bg);
  --tint-error: var(--err-bg);
}

/* Светлая тема: и по явному выбору, и в режиме «авто» на светлой системе. */
:root[data-theme="light"],
:root[data-theme="auto"] {
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F4F6F9;
    --sidebar: #FFFFFF;
    --panel: #FFFFFF;
    --panel-2: #EEF1F5;
    --line: #DDE2E9;
    --field: #FFFFFF;
    --text: #12151A;
    --text-muted: #555E6C;
    --text-dim: #6A7382;
    --accent: #3D63E0;
    --accent-bg: rgba(61, 99, 224, .10);
    --on-accent: #FFFFFF;
    --ok: #148A5C;
    --ok-bg: rgba(20, 138, 92, .10);
    --warn: #A86A00;
    --warn-bg: rgba(245, 184, 74, .18);
    --err: #C93838;
    --err-bg: rgba(201, 56, 56, .10);
    --ai: #7A4FD6;
    --ai-bg: rgba(122, 79, 214, .08);
    --warn-line: rgba(168, 106, 0, .30);
    --on-warn: #FFFFFF;
    --risk-odd: #C25A12;
    --osd: rgba(0, 0, 0, .55);
  --video: rgb(0, 0, 0);
  --scrim-top: rgba(0, 0, 0, .6);
  --scrim-bottom: rgba(0, 0, 0, .7);
  --osd-hover: rgba(255, 255, 255, .12);
    --on-osd: #FFFFFF;
    --scrim: rgba(0, 0, 0, .35);
  }
}

:root[data-theme="light"] {
  --bg: #F4F6F9;
  --sidebar: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #EEF1F5;
  --line: #DDE2E9;
  --field: #FFFFFF;
  --text: #12151A;
  --text-muted: #555E6C;
  --text-dim: #6A7382;
  --accent: #3D63E0;
  --accent-bg: rgba(61, 99, 224, .10);
  --on-accent: #FFFFFF;
  --ok: #148A5C;
  --ok-bg: rgba(20, 138, 92, .10);
  --warn: #A86A00;
  --warn-bg: rgba(245, 184, 74, .18);
  --err: #C93838;
  --err-bg: rgba(201, 56, 56, .10);
  --ai: #7A4FD6;
  --ai-bg: rgba(122, 79, 214, .08);
  --warn-line: rgba(168, 106, 0, .30);
  --on-warn: #FFFFFF;
  --risk-odd: #C25A12;
  --osd: rgba(0, 0, 0, .55);
  --video: rgb(0, 0, 0);
  --scrim-top: rgba(0, 0, 0, .6);
  --scrim-bottom: rgba(0, 0, 0, .7);
  --osd-hover: rgba(255, 255, 255, .12);
  --on-osd: #FFFFFF;
  --scrim: rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
/* Наши display: flex и display: block перебивают браузерный [hidden]:
   у них одинаковая специфичность, а авторский стиль сильнее. Спрятанный
   элемент при этом оставался виден и перехватывал нажатия. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1 { margin: 0; font-size: 19px; font-weight: 600; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
h3 { margin: 0; font-size: 14px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
code, .mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 40;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* --- иконки -------------------------------------------------------------
   Обводка задаётся здесь, а не в самом файле спрайта: при подключении через
   <use> из внешнего файла атрибуты его корневого <svg> не наследуются, и
   иконка нарисовалась бы чёрной заливкой вместо контура. Все эти свойства
   наследуемые, поэтому доходят до содержимого символа.
   ---------------------------------------------------------------------- */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: -.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 22px; height: 22px; }

/* =========================================================================
   Каркас: sidebar + topbar + контент, на телефоне — таббар снизу.
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "side top"
    "side main";
  min-height: 100vh;
}

/* Страница входа: каркаса нет, только карточка по центру. */
.plain { display: block; }

/* --- sidebar ------------------------------------------------------------ */
.sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
}
.brand__name { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.brand__host {
  display: block;
  margin-top: 1px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.navgroup + .navgroup { margin-top: 20px; }
.navgroup__title {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
}
.navlink:hover { background: var(--panel-2); color: var(--text); }
.navlink.is-active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.navlink.is-active .icon { color: var(--accent); }
.navlink__badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.navlink.is-active .navlink__badge { background: var(--bg); color: var(--text-muted); }

.sidebar__foot { margin-top: auto; display: grid; gap: 10px; }

.services {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
}
.services:hover { border-color: var(--accent); color: var(--text); }
.services__dots { display: flex; gap: 5px; margin-left: auto; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.dot--ok { background: var(--ok); }
.dot--bad { background: var(--err); }
.dot--idle { background: var(--text-dim); }
.dot--off { background: var(--line); }

.whoami { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.whoami__name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami__role { display: block; font-size: 11px; color: var(--text-dim); }

/* --- topbar ------------------------------------------------------------- */
/* Не липкая: на ноутбуке она съедала 72 px высоты на каждом экране, а
   ничего, ради чего стоило бы держать её перед глазами, там нет. */
.topbar {
  grid-area: top;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 var(--space-page-x);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar__title { min-width: 0; margin-right: auto; }
.topbar__title p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.search { position: relative; width: 340px; max-width: 34vw; }
.search input {
  width: 100%;
  height: 36px;
  padding: 0 64px 0 34px;
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
.search input::placeholder { color: var(--text-dim); }
.search__icon { position: absolute; left: 10px; top: 9px; color: var(--text-dim); pointer-events: none; }
.search__hint {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--accent { background: var(--accent-bg); color: var(--accent); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--muted { background: var(--panel-2); color: var(--text-muted); }
.pill--err { background: var(--err-bg); color: var(--err); }
.pill--ai { background: var(--ai-bg); color: var(--ai); }

/* «В приложение» — выход из админки на «/». Та же высота, что у иконок
   рядом, чтобы шапка не ехала. */
.backapp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
.backapp:hover { color: var(--text); border-color: var(--accent); }

.iconbutton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}
.iconbutton:hover { color: var(--text); border-color: var(--accent); }
.iconbutton__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--warn);
  color: var(--on-warn);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 17px;
}

.theme { display: flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.theme__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 7px;
  color: var(--text-dim);
  cursor: pointer;
}
.theme__button:hover { color: var(--text); }
.theme__button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.theme__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* --- контент ------------------------------------------------------------ */
.content {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 28px var(--space-page-x) 40px;
  min-width: 0;
}

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* Планшет: двенадцать колонок на 500 px ширины — это не сетка, а давка.
   Карточки идут одна под другой. */
@media (max-width: 1023px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 1; }

  /* Планшет: шапка переносит поиск на свою строку, а «В приложение»
     остаётся одной иконкой — иначе строка не помещается по ширине. */
  .topbar { height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding: 10px var(--space-page-x); }
  .topbar__title { flex: 1 1 auto; }
  .topbar .search { order: 4; width: 100%; max-width: none; }
  .backapp { padding: 0 9px; }
  .backapp span { display: none; }
}

/* --- кнопка разделов (телефон) ------------------------------------------ */
.burger { display: none; }

/* =========================================================================
   Компоненты
   ========================================================================= */
.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card--narrow { max-width: 380px; margin: 8vh auto 0; }
/* Вход: каркаса вокруг нет, поэтому промежутки задаёт сама форма. */
.signin { display: grid; gap: 16px; }
.signin button { justify-self: start; margin-top: 2px; }
.signin__brand { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-weight: 600; }
.card__head { display: flex; align-items: center; gap: 10px; }
.card__head h2 { margin: 0; }
.card__head .card__slot {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--on-accent);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}
button:hover, .button:hover { filter: brightness(1.08); color: var(--on-accent); }
.button--secondary, .button--ghost {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}
.button--secondary:hover, .button--ghost:hover { border-color: var(--accent); color: var(--text); filter: none; }
.button--warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.button--warn:hover { color: var(--warn); filter: brightness(1.1); }
.button--danger { background: transparent; border-color: var(--err); color: var(--err); }
.button--danger:hover { background: var(--err-bg); color: var(--err); filter: none; }
.button--sm { height: 30px; padding: 0 10px; font-size: 12px; }
.button--link {
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-weight: 500;
}
.button--link:hover { background: none; color: var(--text); filter: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.chip--ok { background: var(--ok-bg); color: var(--ok); }
.chip--warn { background: var(--warn-bg); color: var(--warn); }
.chip--err { background: var(--err-bg); color: var(--err); }
.chip--ai { background: var(--ai-bg); color: var(--ai); }
.chip--accent { background: var(--accent-bg); color: var(--accent); }
.chip.is-active { background: var(--accent); color: var(--on-accent); }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.segmented a, .segmented button {
  height: 28px;
  padding: 0 11px;
  background: none;
  border: 0;
  border-radius: 7px;
  color: var(--text-muted);
  font: 500 13px/1 var(--font-sans);
}
.segmented a:hover, .segmented button:hover { color: var(--text); background: none; filter: none; }
.segmented .is-active, .segmented [aria-pressed="true"] {
  background: var(--line);
  color: var(--text);
  font-weight: 600;
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--line);
  transition: background .12s ease;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .12s ease;
}
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(20px); background: var(--panel); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi__label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.kpi__value { font: 700 34px/1.1 var(--font-sans); font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: 12px; color: var(--text-dim); }
.kpi__hint--ok { color: var(--ok); }
.kpi__hint--warn { color: var(--warn); }
.kpi__hint--ai { color: var(--ai); }

.frame { position: relative; display: block; border-radius: var(--radius-md); overflow: hidden; background: var(--bg); }
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame__osd {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--osd);
  color: var(--on-osd);
  font-family: var(--font-mono);
  font-size: 11px;
}
.frame__chip { position: absolute; left: 8px; bottom: 8px; }

.trio { display: flex; gap: 6px; }
.trio__cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text-dim);
}
.trio__cell--ok { background: var(--ok-bg); color: var(--ok); }
.trio__cell--warn { background: var(--warn-bg); color: var(--warn); }
.trio__cell--err { background: var(--err-bg); color: var(--err); }
.trio__cell--busy { background: var(--accent-bg); color: var(--accent); }

.strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-lg);
  color: var(--text);
}
.strip__icon { color: var(--warn); }
.strip__body { min-width: 0; }
.strip__body b { display: block; font-size: 14px; }
.strip__body span { font-size: 12px; color: var(--text-muted); }
.strip__actions { margin-left: auto; display: flex; gap: 8px; }

.heat { display: grid; gap: 3px; }
.heat__cell { height: 22px; border-radius: 5px; background: var(--panel-2); }

/* --- поля --------------------------------------------------------------- */
label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 13px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="text"], input[type="password"] { margin-bottom: 0; }

.alert { padding: 11px 13px; border-radius: var(--radius); background: var(--panel-2); }
.alert--error { background: var(--err-bg); color: var(--err); }
.alert--ok { background: var(--ok-bg); color: var(--ok); }

/* =========================================================================
   Телефон: sidebar уезжает в нижний таббар, «Ещё» открывает лист разделов.
   ========================================================================= */
@media (max-width: 767px) {
  :root { --space-page-x: 16px; --gap: 14px; }

  /* Строка шапки на телефоне высотой по содержимому: с фиксированной
     высотой строки sticky-шапка наезжала на начало страницы. */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top" "main";
  }
  .sidebar { display: none; }
  .content { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); }

  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px var(--space-page-x);
  }
  .topbar__title { order: 1; flex: 1 1 auto; }
  .topbar .theme { order: 2; }
  .topbar .iconbutton { order: 2; }
  .topbar .backapp { order: 2; padding: 0 10px; }
  .topbar .backapp span { display: none; }
  .topbar .pill { order: 3; flex: 1 1 100%; justify-content: center; }
  .search { order: 4; width: 100%; max-width: none; }
  .search__hint { display: none; }

  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 1; }

  .card { padding: 16px; border-radius: var(--radius-md); }

  .burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    margin-right: 2px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
  }

  /* Лист «Ещё» — на чекбоксе: работает без JS и закрывается по ссылке. */
  .sheet__toggle { position: absolute; opacity: 0; pointer-events: none; }
  .sheet {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    background: var(--scrim);
  }
  .sheet__toggle:checked ~ .sheet { display: block; }
  .sheet__panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 86vw);
    overflow-y: auto;
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--sidebar);
    border-right: 1px solid var(--line);
  }
  .sheet__grab { display: none; }
  .sheet__close { display: block; position: absolute; inset: 0; }
}

@media (min-width: 768px) {
  .sheet, .sheet__toggle { display: none; }
}


/* =========================================================================
   Лента событий: тулбар, шкала, список и карточка выбранного события.
   ========================================================================= */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar--quick { font-size: 13px; }
.toolbar__count { margin-left: auto; }
.toolbar--bulk { gap: 12px; font-size: 12px; }

/* Выпадающий фильтр — <details>: раскрывается без скрипта и закрывается
   щелчком по заголовку. Внутри обычные ссылки, поэтому фильтр целиком
   остаётся в адресе страницы. */
.drop { position: relative; }
.drop > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.drop > summary::-webkit-details-marker { display: none; }
.drop > summary:hover { border-color: var(--accent); }
.drop[open] > summary { border-color: var(--accent); }
.drop__panel {
  position: absolute;
  z-index: 15;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px -24px var(--scrim);
}
.drop__panel--list { display: grid; gap: 2px; padding: 6px; }
.drop__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.drop__option:hover { background: var(--panel-2); color: var(--text); }
.drop__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--on-accent);
}
.drop__option.is-active .drop__box { background: var(--accent); border-color: var(--accent); }
.drop__panel form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.drop__panel label { margin: 0; }

/* Две колонки: лента и карточка выбранного события. Карточка липкая —
   при листании списка она остаётся на виду. */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--gap); align-items: start; }
.split__list { gap: 2px; padding: 12px; }
.split__side { position: sticky; top: 16px; }

.hour {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.hour::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.row {
  display: flex;
  gap: 14px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
}
.row:hover { background: var(--panel-2); color: var(--text); }
.row.is-picked { background: var(--panel-2); border-color: var(--accent); }
.row__frame { width: 150px; height: 92px; flex: none; }
.row__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row__head { display: flex; align-items: center; gap: 10px; }
.row__time { font-size: 13px; color: var(--text-muted); }
/* Имя камеры сжимается многоточием: иначе длинное имя выдавливает три
   значка статуса за правый край экрана телефона. */
.row__camera { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__head .trio { margin-left: auto; flex: none; }
.row__text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-muted);
}
.row__text--bad { color: var(--warn); }

.frame__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-dim);
}
.frame__empty--big { flex-direction: column; gap: 8px; min-height: 180px; font-size: 12px; }
/* z-index здесь из-за превью живого просмотра: у него свой слой, и без
   этого кнопки оказывались под кадром. */
.frame__actions { position: absolute; right: 10px; bottom: 10px; z-index: 2; display: flex; gap: 8px; }

.event { gap: 14px; }
.event__frame { min-height: 180px; }
.event__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.event__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.event__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.event__section { display: grid; gap: 8px; }
.event__title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.event__usage { font-size: 12px; }

/* Всё про модель — фиолетовым: так видно, что текст не наш, а её. */
.model { padding: 12px 14px; background: var(--ai-bg); border-radius: var(--radius-md); }
.model__title { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ai); }
.model__text { margin: 0; }
.model__meta { margin: 8px 0 0; font-size: 11px; color: var(--text-dim); }

.path { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.path__step { display: flex; align-items: flex-start; gap: 10px; }
.path__body { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.path__body .muted { font-size: 12px; }
.path__step .mono { margin-left: auto; font-size: 12px; }

.people { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.people__row { display: flex; align-items: center; gap: 8px; }
.people__row .chip { margin-left: auto; }
.people__error { flex: 1 1 100%; font-size: 12px; color: var(--err); }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  /* Карточка выше списка: на узком экране она и есть ответ на вопрос
     «что случилось», а список — навигация к следующему. */
  .split__side { position: static; order: -1; }
}

@media (max-width: 767px) {
  .row { gap: 10px; padding: 8px; }
  .row__frame { width: 96px; height: 62px; }
  .drop__panel { position: static; min-width: 0; box-shadow: none; }
  .toolbar__count { margin-left: 0; }
}


/* =========================================================================
   Сводка.
   ========================================================================= */
.attention { display: grid; gap: 10px; }

.guard { gap: 14px; }
.guard__state { display: flex; align-items: center; gap: 14px; }
.guard__mark { width: 44px; height: 44px; border-radius: var(--radius-md); }
.guard__title { font-size: 26px; font-weight: 700; line-height: 1.2; }
.guard__meta { display: block; margin-top: 2px; font-size: 12px; color: var(--text-dim); }

.chain { display: flex; align-items: center; gap: 10px; }
.chain__step { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; flex: 1; }
.chain__step b { grid-column: 2; font-size: 13px; }
.chain__step .muted { grid-column: 2; font-size: 12px; }
.chain__step .trio__cell { grid-row: span 2; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.kpis .card { gap: 4px; }
.kpi__hint a { color: inherit; text-decoration: underline; }

.latest { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.shot { display: grid; gap: 8px; color: var(--text); }
.shot:hover { color: var(--text); }
.shot:hover .frame { outline: 1px solid var(--accent); }
.shot__frame { height: 150px; }
.shot__text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
}

.heat { display: grid; gap: 3px; }
.heat__row { display: flex; align-items: center; gap: 10px; }
.heat__name { width: 74px; flex: none; font-size: 12px; color: var(--text-muted); }
.heat__cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; flex: 1; }
.heat__cell { height: 22px; border-radius: 5px; background: var(--panel-2); }
.heat__total { width: 28px; flex: none; text-align: right; font-size: 12px; }
.heat__tick { font-size: 10px; color: var(--text-dim); }
.heat__row--ticks .heat__cell { height: auto; background: none; }

.cams { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cams__row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.cams__name { flex: 1; min-width: 0; }
.cams__name b { display: block; font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.cams__bar { display: block; height: 3px; margin-top: 5px; border-radius: 2px; background: var(--panel-2); }
.cams__bar span { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.cams__time { font-size: 12px; }
.cams__count { width: 26px; text-align: right; font-weight: 600; }

@media (max-width: 1100px) {
  .latest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis .kpi__value { font-size: 26px; }
  .latest { grid-template-columns: minmax(0, 1fr); }
  .chain { flex-direction: column; align-items: stretch; }
  .heat__name { width: 56px; }
  .heat__cells { gap: 2px; }
  .heat__cell { height: 16px; border-radius: 4px; }
}


/* =========================================================================
   Политики.
   ========================================================================= */
.now {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--ok-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.now--home { background: var(--accent-bg); }
.now--unknown, .now--not_configured { background: var(--panel); }
.now__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ok);
}
.now--home .now__mark { color: var(--accent); }
.now--unknown .now__mark, .now--not_configured .now__mark { color: var(--text-dim); background: var(--panel-2); }
.now__body { display: grid; gap: 2px; min-width: 0; }
.now__body b { font-size: 16px; }
.now__body .muted { font-size: 13px; }
.now__trio { margin-left: auto; }

.side { display: grid; gap: var(--gap); align-content: start; }

/* Матрица: строка — состояние присутствия, столбцы — три решения. Не таблица:
   на телефоне строка становится карточкой, а ячейки подписываются столбцом. */
.matrix2 { display: grid; gap: 4px; }
.matrix2__head, .matrix2__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 110px;
  align-items: center;
  gap: 10px;
}
.matrix2__head { padding: 0 12px 6px; font-size: 13px; }
.matrix2__col { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 13px; }
.matrix2__row { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.matrix2__row.is-current { border-color: var(--ok); background: var(--ok-bg); }
.matrix2__what { display: grid; gap: 3px; min-width: 0; }
.matrix2__what .muted { font-size: 12px; }
.matrix2__summary { font-size: 12px; color: var(--accent); }
.matrix2__cell { display: flex; justify-content: center; }

.facts2 { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; }
.facts2 span { display: flex; justify-content: space-between; gap: 10px; }
.facts2 b.ok { color: var(--ok); }
.facts2 b.bad { color: var(--err); }

.preset {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  text-align: left;
}
.preset:hover { border-color: var(--accent); filter: none; color: var(--text); }
.preset__body { display: grid; gap: 2px; margin-right: auto; }
.preset__body .muted { font-size: 12px; font-weight: 400; }

.override > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}
.override > summary::-webkit-details-marker { display: none; }
.override > summary .chip { margin-left: auto; }

@media (max-width: 1100px) {
  .matrix2__head { display: none; }
  .matrix2__row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .matrix2__cell { justify-content: space-between; }
  .matrix2__cell::before { content: attr(data-label); font-size: 13px; color: var(--text-muted); }
  .now { flex-wrap: wrap; }
  .now__trio { margin-left: 0; }
}


/* =========================================================================
   Подключения: схема потока и карточка выбранного подключения.
   ========================================================================= */
.flow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: center; }
.flow__lane { display: grid; gap: 10px; }
.flow__link { color: var(--text-dim); }
.flow__core { display: grid; }

.node {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
}
.node:hover { border-color: var(--accent); color: var(--text); }
.node__head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.node__state { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
.node__sub { font-size: 11px; color: var(--text-dim); }
/* Выключенное подключение — не ошибка: пунктир и приглушённый цвет, а не
   красный. */
.node--off { border-style: dashed; opacity: .7; }
.node--bad { border-color: var(--err); }
.node--core { background: var(--accent-bg); border-color: var(--accent); }

@media (max-width: 1023px) {
  .flow { grid-template-columns: minmax(0, 1fr); }
  .flow__link { transform: rotate(90deg); justify-self: center; }
}


/* =========================================================================
   Расход.
   ========================================================================= */
.kpis--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.prices { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-left: auto; }
.prices label { margin: 0; font-size: 12px; }
.prices input { width: 110px; }

.bars { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bars__row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 13px; }
.bars__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { height: 8px; border-radius: 4px; background: var(--panel-2); }
.bars__track span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bars__value { text-align: right; font-weight: 600; }
.bars__extra { grid-column: 2 / -1; font-size: 11px; }

@media (max-width: 1023px) {
  .kpis--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prices { margin-left: 0; }
}


/* =========================================================================
   Обслуживание.
   ========================================================================= */
.storage__total { margin: 0; font: 700 34px/1.1 var(--font-sans); font-variant-numeric: tabular-nums; }
.storage__total .muted { font-size: 16px; font-weight: 500; }
.storage__bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--panel-2); }
.storage__part--snaps { background: var(--ok); }
.storage__part--db { background: var(--accent); }
.storage__legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-muted); }
.storage__legend span { display: flex; align-items: center; gap: 7px; }
.storage__legend .dot--ok { background: var(--ok); }

.ministats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.ministats span { display: grid; gap: 2px; font-size: 12px; color: var(--text-muted); }
.ministats b { font-size: 18px; color: var(--text); }

/* Сегменты на радиокнопках: выбор одним нажатием и без скрипта. */
.segmented--wrap { flex-wrap: wrap; }
.segmented label { display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 7px; margin: 0; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.segmented label.is-active { background: var(--line); color: var(--text); font-weight: 600; }
.segmented label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.action h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.action .muted { font-size: 13px; }

@media (max-width: 767px) {
  .ministats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* =========================================================================
   Пользователи.
   ========================================================================= */
/* Две тишины одной карточкой: общая и личная — строками, кнопки справа. */
.hush { display: grid; gap: 10px; }
.hush__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.hush__what { display: grid; gap: 2px; margin-right: auto; min-width: 0; font-size: 13px; }
.hush__state { color: var(--warn); }
.hush__buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.people2 { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.people2__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
/* Открытая строка помечена: её настройки раскрыты ниже по странице. */
.people2__row.is-open { border-color: var(--accent); background: var(--tint-accent); }
.people2__who { display: grid; gap: 1px; margin-right: auto; min-width: 0; }
.people2__who .mono { font-size: 11px; }
.rights { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; }
.rights legend { padding: 0 6px; font-size: 12px; color: var(--text-muted); }


/* =========================================================================
   Журнал.
   ========================================================================= */
.log { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.log__row { border-radius: 8px; }
.log__row > details > summary,
.log--inline .log__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}
.log--inline .log__row { cursor: default; font-size: 12px; }
.log__row > details > summary::-webkit-details-marker { display: none; }
.log__row > details > summary:hover { background: var(--panel-2); border-radius: 8px; }
/* Уровень — полоской слева: цвет не должен спорить с текстом записи. */
.log__row--warn { box-shadow: inset 2px 0 0 var(--warn); }
.log__row--error { box-shadow: inset 2px 0 0 var(--err); }
.log__time { flex: none; width: 104px; font-size: 12px; color: var(--text-dim); }
.log--inline .log__time { width: 62px; }
.log__component { flex: none; }
.log__message { flex: 1; min-width: 0; }
.log__detail { padding: 4px 10px 12px 124px; font-size: 12px; }
.log__detail .facts dt { min-width: 120px; }
.log__links { display: flex; gap: 12px; margin: 8px 0 0; }

.search--inline { width: 260px; max-width: none; }

@media (max-width: 767px) {
  .log__row > details > summary { flex-wrap: wrap; gap: 6px; }
  .log__time { width: auto; }
  .log__message { flex: 1 1 100%; }
  .log__detail { padding-left: 10px; }
  .search--inline { width: 100%; }
}


/* =========================================================================
   Приложение: mobile-first. Экран отвечает на вопрос «всё ли в порядке и что
   я пропустил» за три секунды, поэтому здесь крупный текст, большие цели
   нажатия и минимум текста-статусов (DESIGN-APP §1).
   ========================================================================= */
.phone { min-height: 100vh; background: var(--bg); }

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px));
}

.screen__head { display: flex; align-items: center; gap: 10px; }
/* Знак сервиса перед заголовком экрана: тот же, что в шапке админки,
   только мельче — заголовку и поиску тоже нужно место. */
.screen__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
}
.screen__logo .icon { width: 18px; height: 18px; }
.screen__head h1 { font-size: 26px; font-weight: 700; }
.screen__head .muted { font-size: 13px; }
.screen__title { display: grid; gap: 2px; }
/* Дата отдельной строкой, а под ней заголовок со статусом и поиском:
   в одну строку дата ломалась на два слова. */
.screen__head--stack { display: grid; gap: 4px; }
.screen__line { display: flex; align-items: center; gap: 10px; }
.screen__line .presence { margin-left: auto; }
.screen__line .seek { margin-left: 0; }
.screen__head form, .screen__head .round { margin-left: auto; }
/* Экран с возвратом: стрелка слева от заголовка, как в просмотре события. */
.screen__head--back .round { margin-left: 0; transform: rotate(180deg); }
.screen__head--back h1 { margin-right: auto; }

.round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
}
.round--sm { width: 38px; height: 38px; }
.round--search { width: auto; padding: 0 8px; }
.round--search input { width: 180px; height: 40px; border: 0; background: none; }

/* Статус охраны — первым экраном и одной строкой. */
.guardline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ok-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
}
.guardline--home { background: var(--accent-bg); }
.guardline--unknown, .guardline--not_configured { background: var(--panel); }
.guardline__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ok);
}
.guardline--home .guardline__mark { color: var(--accent); }
.guardline--unknown .guardline__mark, .guardline--not_configured .guardline__mark { color: var(--text-dim); }
.guardline__body { display: grid; gap: 2px; min-width: 0; }
.guardline__body .muted { font-size: 12px; }
.guardline > .dot { margin-left: auto; }

/* Плитки последних событий: два в ряд, кадр и подпись под ним. */
.panel--quad { display: grid; gap: 10px; }
.quad { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quad__item { display: block; color: var(--text); min-width: 0; }
.quad__frame { height: 104px; }
.quad__item.is-new .quad__frame { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Подписи лежат на кадре: две плитки в ряд и так узкие, а строка под
   кадром спорила со стилем ленты. Чипсы здесь мельче обычных и
   полупрозрачные — кадр важнее подписи. */
.quad .chip {
  /* min-height здесь важен: у админских чипсов он 32px и перебивает height. */
  height: 18px;
  min-height: 0;
  padding: 0 6px;
  gap: 4px;
  border: 0;
  background: var(--osd);
  color: var(--on-osd);
  font-size: 10px;
  line-height: 1;
}
.quad__camera { display: inline-flex; align-items: center; max-width: calc(100% - 54px); }
.quad__camera .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quad__camera .dot { width: 5px; height: 5px; }
.quad .frame__chip { left: 6px; bottom: 6px; }
.quad__time { position: absolute; right: 6px; bottom: 6px; }

/* Подложка под блок: та же карточка, что у остального экрана. */
.panel {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* Живой просмотр камеры над её лентой. Подложка акцентнее обычной панели:
   это не событие, которое было, а камера, которая смотрит прямо сейчас,
   и путать их нельзя. */
.panel--live {
  display: grid;
  gap: 10px;
  background: var(--accent-bg);
}
.panel__head { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
/* Кадр кликается целиком: нажатие на превью — то же «включить live». */
.frame--live { cursor: pointer; }
.frame--live { min-height: 160px; }
.frame--live img, .frame--live .live { max-height: 62vh; }
/* Превью лежит поверх подложки «кадра нет»: не пришёл кадр — видно её.
   Подложка вынута из потока, иначе она не подложка, а строка над кадром. */
.frame__poster { position: relative; z-index: 1; }
.frame__empty--under { position: absolute; inset: 0; min-height: 0; }
.frame.is-live .frame__empty { display: none; }

/* Присутствие в заголовке экрана: цвет иконки — это и есть статус. */
.presence { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 13px; color: var(--text-muted); }
.presence svg { flex: none; color: var(--err); }
.presence--home svg { color: var(--ok); }
.presence--unknown svg, .presence--not_configured svg { color: var(--text-dim); }
.chip--presence svg { color: var(--text-dim); }
.chip--presence-away svg { color: var(--err); }
.chip--presence-home svg { color: var(--ok); }
.presence span { max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Карта «камера × час» на телефоне: подписи мельче, клетки ниже, иначе
   двадцать четыре столбика не помещаются в 360 px. */
.heat--app { font-size: 12px; }
.heat--app .heat__name { width: 56px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat--app .heat__cells { gap: 2px; }
.heat--app .heat__cell { height: 16px; border-radius: 3px; }
.heat--app .heat__name { color: var(--text-muted); }
/* Клетка с событиями — ссылка в ленту: та же камера, тот же час. */
/* Час, который ещё не наступил: место под него занято, но он пустой
   и бледнее пустого прошедшего — иначе непонятно, где «кончается» сегодня. */
.heat__cell--future { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.heat__cell.is-live { cursor: pointer; }
.heat__cell.is-live:hover { outline: 1px solid var(--accent); outline-offset: 1px; }
.heat--app .heat__total { width: 22px; font-size: 11px; }

/* «Ещё из этой камеры» — тот же список, что в ленте, только под карточкой. */
.viewer__more { margin-top: 8px; }
.viewer__more .hour { margin: 12px 0 6px; }

/* Поиск на главной: иконка, из которой выезжает поле. */
.seek { position: relative; margin-left: auto; }
.seek > summary { list-style: none; cursor: pointer; }
.seek > summary::-webkit-details-marker { display: none; }
.seek[open] > summary { border-color: var(--accent); color: var(--accent); }
.seek__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: min(320px, calc(100vw - 32px));
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px -24px var(--scrim);
}
.seek__panel input { width: 100%; margin: 0; }
.seek__hint { margin: 0; font-size: 12px; }

/* Присутствие строкой: справка, а не кнопка. Карточку она занимала зря —
   нажимать там нечего, а место на первом экране дорогое. */
.statusline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.statusline svg { color: var(--ok); flex: none; }
.statusline--home svg { color: var(--accent); }
.statusline--unknown svg, .statusline--not_configured svg { color: var(--text-dim); }
.statusline__quiet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--warn);
}
.statusline__quiet svg { color: inherit; }

/* «Не беспокоить»: подпись и три пресета одной строкой. */
.quiet { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* Подпись отдельной строкой: тогда три пресета встают в один ряд
   даже на 360 px. */
.quiet__title { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; flex: 1 0 100%; }
.quiet button { flex: 1 1 auto; min-width: 72px; }
.quiet__wide { flex: 1 1 100%; }

/* Камеры кружками: где есть новое — акцентное кольцо и счётчик. */
.stories { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.stories::-webkit-scrollbar { display: none; }
.story { display: grid; gap: 6px; justify-items: center; color: var(--text-muted); }
.story__ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid var(--line);
  overflow: hidden;
  background: var(--panel-2);
  color: var(--text-dim);
}
.story.is-new .story__ring { border-color: var(--accent); }
.story__ring img { width: 100%; height: 100%; object-fit: cover; }
.story__badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}
.story__name { font-size: 12px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story.is-new .story__name { color: var(--text); font-weight: 600; }

.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.counts__item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.counts__item .muted {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.25;
  min-height: 2.5em;
}
.counts__item b { font-size: 26px; font-variant-numeric: tabular-nums; }
.counts__item .accent { color: var(--accent); }

.block { display: grid; gap: 12px; }
.block__head { display: flex; align-items: center; gap: 10px; }
.block__head h2 { font-size: 18px; }
.block__head form, .block__head a { margin-left: auto; }

.button--big { height: 52px; font-size: 15px; border-radius: var(--radius-md); }

.bigs { display: grid; gap: 14px; }

.shot--big { display: grid; gap: 8px; color: var(--text); }
.shot--big .shot__frame { height: 196px; }
.shot__head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.shot__head .muted { margin-left: auto; font-size: 13px; }
.shot__text--warn { color: var(--warn); }
.shot--big.is-new .shot__frame { outline: 2px solid var(--accent); outline-offset: 1px; }

.dot--new { background: var(--accent); width: 9px; height: 9px; }

.brief {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
}
.brief.is-new { border-color: var(--accent); }
.brief__frame { width: 88px; height: 60px; flex: none; }
/* flex: 1 — иначе строка сжимается по ширине описания, и время скачет
   то к имени камеры, то к правому краю. */
.brief__body { display: grid; gap: 4px; min-width: 0; flex: 1; }
.brief__head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.brief__head .muted { margin-left: auto; }
.brief__text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-muted);
}
.brief__text--warn { color: var(--warn); }

.more { display: block; padding: 10px; text-align: center; font-size: 13px; }

/* --- главная: сводка суток ------------------------------------------------ */

/* Полоса суток: 24 столбика, час к часу. Читается как циферблат, поэтому
   пустые часы остаются на своих местах, а не схлопываются. */
.daybar {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  gap: 2px;
  height: 72px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.daybar__slot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  border-radius: var(--radius-sm);
}
.daybar__slot.is-now { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.daybar__bar {
  width: 100%;
  min-height: 2px;
  border-radius: var(--radius-sm);
  background: var(--text-dim);
}
.daybar__slot.has-people .daybar__bar { background: var(--accent); }
.daybar__slot:not(.has-people) .daybar__bar { background: color-mix(in srgb, var(--text-dim) 70%, transparent); }
/* Пустой час — тонкая черта у основания, чтобы шкала не рвалась. */
.daybar__slot.is-empty .daybar__bar { height: 2px; background: var(--line); }
.daybar__scale { display: flex; justify-content: space-between; font-size: 11px; margin-top: -6px; }
.day__note { font-size: 13px; }

/* Две кнопки в ряд на телефоне — «досмотреть» и «сдаться». */
.watch { display: grid; gap: 10px; align-items: stretch; }
.watch form { display: flex; }
@media (min-width: 480px) { .watch { grid-template-columns: 1fr auto; } }
.watch .button--big { width: 100%; }
.empty--line { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md); }

/* Камера строкой: кадр, имя и одно слово о состоянии. */
.camline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
}
.camline.is-new { border-color: var(--accent); }
.camline__frame { width: 72px; height: 48px; flex: none; }
.camline__body { display: grid; gap: 2px; min-width: 0; }
.camline__body b { font-size: 15px; }
.camline__body .muted { font-size: 12px; }
.camline__state { margin-left: auto; font-size: 13px; white-space: nowrap; }

.guardline--warn { background: var(--warn-bg); }
.guardline--warn .guardline__mark { color: var(--warn); }
.dot--warn { background: var(--warn); }

.empty { display: grid; gap: 10px; justify-items: center; padding: 28px 16px; color: var(--text-muted); text-align: center; }

/* Лента: полоска дней, чипсы и вертикальная шкала. */
/* Семь дней делят ширину экрана: полоска со скроллом обрезала воскресенье
   у правого края, и выглядело это сломанной вёрсткой, а не прокруткой. */
.days { display: flex; gap: 6px; padding-top: 6px; }
.days__item {
  display: grid;
  gap: 3px;
  justify-items: center;
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 2px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 12px;
}
.days__item.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.days__number { font-size: 16px; font-weight: 600; color: var(--text); }
.days__item.is-active .days__number { color: var(--on-accent); }
.days__item { position: relative; }
/* Пустой день приглушён: смотреть там нечего, и это видно сразу. */
.days__item.is-empty:not(.is-active) { opacity: .45; }
.days__dots { display: flex; gap: 3px; height: 6px; }
.days__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--risk); }
.days__item.is-active .days__dots i { box-shadow: 0 0 0 1.5px var(--on-accent); }
/* Без оценки опасности точки — цвета ленты, а не «спокойно». */
.days__dots--plain { --risk: var(--accent); }
.days__item.is-active .days__dots--plain i { background: var(--on-accent); box-shadow: none; }
/* Бейдж — сколько событий было за день. Синий — если среди них есть
   непросмотренные, нейтральный — если всё уже просмотрено. */
.days__badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
               border-radius: 9px; background: var(--panel-2); color: var(--text-muted);
               border: 1px solid var(--line);
               font: 700 11px/16px var(--font-sans); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.days__badge.is-unseen { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.days__item.is-active .days__badge.is-unseen { background: var(--on-accent); border-color: var(--on-accent);
                                               color: var(--accent); }

/* Фильтры ленты: переключатель «новые» и два выпадающих списка. На телефоне
   панель списка встаёт в поток (общее правило для .drop__panel), поэтому ей
   нужна своя ширина — иначе список сжимается до пары сантиметров. */
.filters { display: flex; flex-wrap: wrap; align-items: start; gap: 8px; }
.segmented--filters a { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; }
.drop--app > summary { height: 34px; gap: 5px; }
.drop--app > summary b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.drop--app .drop__panel { min-width: 200px; max-width: calc(100vw - 32px); }

.timeline { display: grid; gap: 14px; }
.line { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
.line__time { display: grid; gap: 6px; justify-items: center; font-size: 12px; color: var(--text-dim); }
.line__time .dot { width: 8px; height: 8px; }
.line__card { display: grid; gap: 8px; color: var(--text); }
.line__frame { height: 150px; }
.line.is-new .line__frame { outline: 2px solid var(--accent); outline-offset: 1px; }
.line__body { display: grid; gap: 4px; }
.line__text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  color: var(--text-muted);
}
.line__text--warn { color: var(--warn); }

/* Просмотр события: полноэкранный, с нижним листом. */
.viewer { display: grid; gap: 16px; }
.viewer__head { display: flex; align-items: center; gap: 12px; }
.viewer__head .round { transform: rotate(180deg); }
.viewer__title { display: grid; gap: 2px; }
.viewer__title .mono { font-size: 12px; }
.viewer__head > .muted { margin-left: auto; font-size: 12px; }
.viewer__frame { min-height: 250px; }
/* Живое видео занимает то же место, что и кадр: переключение не должно
   дёргать страницу. */
.live { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--video); }
/* Плеер: кнопки лежат на затемнении поверх видео, как в обычном
   видеоплеере, и через три секунды прячутся (класс is-idle ставит
   скрипт). Касание по видео возвращает их. Спрятанные кнопки не
   перехватывают нажатий: касание попадает в кадр и будит их. */
.player {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity .25s ease;
}
.frame.is-idle .player { opacity: 0; }
.frame.is-idle .player * { pointer-events: none !important; }
.frame.is-idle { cursor: none; }
.player__top, .player__bottom {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  color: var(--on-osd);
  pointer-events: auto;
}
.player__top { background: linear-gradient(var(--scrim-top), transparent); }
.player__bottom { padding-top: 28px; background: linear-gradient(transparent, var(--scrim-bottom)); }
/* Имя камеры — только на весь экран: на странице оно и так в заголовке. */
.player__name { display: none; font-size: 14px; font-weight: 600; text-shadow: 0 1px 2px var(--scrim-top); }
.player__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--osd);
  font: 600 11px/1.4 var(--font-mono);
}
.player__badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--err); }
.player__via::before { content: "· "; }
.player__via { font-weight: 500; opacity: .8; }
.player__gap { flex: 1; }
/* Круглые кнопки без подписей — как в любом видеоплеере; подсказки
   в title и aria-label. 40px — палец попадает без прицеливания. */
.player__btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-osd);
}
.player__btn:hover { background: var(--osd-hover); filter: none; }
.player__btn .icon { width: 20px; height: 20px; }
.player__btn[disabled] { opacity: .4; }
/* Звук: один значок из двух — по aria-pressed. */
.player__on { display: none; }
.player__btn[aria-pressed="true"] .player__on { display: grid; }
.player__btn[aria-pressed="true"] .player__off { display: none; }
/* HD — рамкой, а когда включено лучшее качество — залитым. */
.player__hd span {
  padding: 3px 4px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  font: 700 11px/1 var(--font-mono);
}
.player__hd[aria-pressed="true"] span { background: var(--on-osd); border-color: var(--on-osd); color: var(--video); }
/* ✕ нужна только на весь экран: из встроенного плеера выходить некуда. */
.player__exit { display: none; background: var(--osd); }

/* Под кадром — чем запустить и куда ещё перейти. На картинке ничего
   не лежит: раньше три одинаковые кнопки закрывали треть двора. */
.launch { display: grid; gap: 8px; }
.launch__main { width: 100%; }
.launch__main[hidden] { display: none; }
.launch__more { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.launch__more .button { justify-content: center; }

/* На весь экран. Разворачивается кадр целиком, поэтому фон — всегда
   чёрный, видео по центру; сверху ✕, снизу кнопки с отступом от
   системной полосы жестов, которая закрывала их на Android. */
.frame:fullscreen { background: var(--video); display: flex; border-radius: 0; }
.frame:fullscreen .live { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.frame:fullscreen img, .frame:fullscreen .frame__empty { display: none; }
.frame:fullscreen .player__exit { display: grid; }
.frame:fullscreen .player__name { display: block; }
.frame:fullscreen .player__top { padding-top: max(12px, env(safe-area-inset-top)); }
.frame:fullscreen .player__bottom { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
/* Отдельным блоком, а не через запятую: браузер, не знающий одну запись
   из списка селекторов, выбрасывает правило целиком. Это для Safari
   до 16.4, где псевдокласс ещё с префиксом. */
.frame:-webkit-full-screen { background: var(--video); display: flex; border-radius: 0; }
.frame:-webkit-full-screen .live { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.frame:-webkit-full-screen img, .frame:-webkit-full-screen .frame__empty { display: none; }
.frame:-webkit-full-screen .player__exit { display: grid; }
.frame:-webkit-full-screen .player__name { display: block; }
.frame:-webkit-full-screen .player__top { padding-top: max(12px, env(safe-area-inset-top)); }
.frame:-webkit-full-screen .player__bottom { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.sheetcard {
  display: grid;
  gap: 14px;
  padding: 18px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.model__text--big { font-size: 17px; line-height: 1.45; }
.viewer__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.viewer__actions form { display: grid; gap: 8px; width: 100%; }
.viewer__actions form .button--secondary { justify-self: start; }

/* «Модель смотрит на кадр…» — только пока идёт запрос: htmx вешает на
   форму класс htmx-request. Бегущая полоса вместо процентов: сколько
   займёт ответ модели, заранее не знает никто. */
.working { display: none; gap: 6px; }
.htmx-request .working { display: grid; }
.working__bar {
  position: relative;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--panel-2);
}
.working__bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  border-radius: 2px;
  background: var(--accent);
  animation: working 1.1s ease-in-out infinite;
}
@keyframes working {
  from { transform: translateX(-100%); }
  to { transform: translateX(290%); }
}
@media (prefers-reduced-motion: reduce) {
  .working__bar::after { animation: none; width: 100%; opacity: .5; }
}
.working__text { color: var(--text-muted); font-size: 12px; }
/* Новое описание подсвечивается на мгновение — видно, что оно сменилось. */
.description { display: grid; gap: 14px; }
.description.is-fresh .model { animation: fresh 1.6s ease-out; }
@keyframes fresh {
  from { box-shadow: 0 0 0 2px var(--accent); }
  to { box-shadow: 0 0 0 2px transparent; }
}

/* Техническая сторона события — аккордеон: свёрнут, пока не нужен. */
.folds { display: grid; border-top: 1px solid var(--line); }
.fold { border-bottom: 1px solid var(--line); }
.fold:last-child { border-bottom: 0; }
.fold__head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
}
.fold__head::-webkit-details-marker { display: none; }
.fold__hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.fold__head .icon { color: var(--text-muted); transition: transform .15s ease; }
.fold[open] .fold__head .icon { transform: rotate(180deg); }
.fold[open] { padding-bottom: 12px; }

.steps, .notes { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps__row { display: grid; grid-template-columns: 26px 1fr auto; align-items: start; gap: 10px; }
.steps__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-muted);
}
.steps__mark--ok { background: var(--ok-bg); color: var(--ok); }
.steps__mark--warn { background: var(--warn-bg); color: var(--warn); }
.steps__mark--err { background: var(--err-bg); color: var(--err); }
.steps__body { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.steps__body .muted { font-size: 12px; overflow-wrap: anywhere; }
.steps__time { font-size: 11px; padding-top: 4px; }

.notes__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; }
.notes__row--warn { color: var(--warn); }
.notes__row--error { color: var(--err); }
.notes__who { display: grid; gap: 2px; margin-right: auto; }
.notes__who .muted { font-size: 12px; }
.notes__error { flex-basis: 100%; color: var(--err); font-size: 12px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.dot--err { background: var(--err); }
.viewer__nav { display: flex; align-items: center; gap: 10px; }
.viewer__nav .button--big { flex: 1; }
.viewer__hint { font-size: 12px; text-align: center; }

/* Профиль: группы строк, как в системных настройках телефона. */
.who { display: flex; align-items: center; gap: 12px; }
.who__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 22px;
  font-weight: 700;
}
.who__body { display: grid; gap: 2px; margin-right: auto; }
.who__body b { font-size: 20px; }

.adminlink {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-lg);
  color: var(--text);
}
.adminlink__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--warn);
}
.adminlink__body { display: grid; gap: 2px; margin-right: auto; }
.adminlink__body .muted { font-size: 12px; }

.group__title {
  /* Отрицательный отступ подтягивал заголовок под карточку, и «МОИ
     УВЕДОМЛЕНИЯ» налезало на её верхний край. */
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.group {
  display: grid;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.group__row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--text);
}
.group > .group__row:first-child, .group > form:first-child .group__row { border-top: 0; }
/* Иконка держится первой строки: у строки с описанием в две строки она
   уезжала на середину и вставала ниже заголовка. */
.group__icon { display: inline-flex; flex: none; align-self: start; margin-top: 2px; color: var(--text-dim); }
.group__row--one .group__icon { align-self: center; margin-top: 0; }
.group__body { display: grid; gap: 2px; margin-right: auto; min-width: 0; }
.group__body .muted { font-size: 12px; }
.group__hint { margin: 0; padding: 0 16px 12px 48px; font-size: 12px; color: var(--text-dim); }
.group__pair { display: flex; gap: 6px; flex: none; }
/* Строка, которой мало одной линии: подпись сверху, поле под ней. */
.group__row--stack { flex-wrap: wrap; }
.group__row--stack .group__body { flex: 1 0 auto; }
.group__row--stack .group__pair { flex: 1 0 100%; padding-left: 32px; }
.group__row--stack .group__pair input { flex: 1 1 0; width: auto; min-width: 0; }
/* Сегменты внутри строки настроек — компактные: три слова и переключатель
   должны поместиться в 390 px. Кнопке нужен flex: none: у кнопок нет
   автоматического минимального размера, и во flex-строке «Светлая» ужималась
   до трёх букв под многоточием. */
.group__row .segmented { flex: none; }
.group__row .segmented button {
  flex: none;
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}
.group__row .chip { white-space: nowrap; }
.group__pair input { width: 110px; }
.group__row--wide { display: block; }
.group__row--wide summary { display: flex; align-items: center; gap: 12px; min-height: 36px; cursor: pointer; list-style: none; }
.group__row--wide summary::-webkit-details-marker { display: none; }
.group__checks { display: grid; gap: 8px; padding: 12px 0 4px; }
/* Форма — обычный блок внутри сетки экрана, и её собственные промежутки
   в gap не попадают: без отступа кнопка ложилась на карточку выше. */
.group__actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.danger { color: var(--err); }

/* Нижний таббар: всегда на виду, большие цели нажатия. */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--sidebar);
  border-top: 1px solid var(--line);
}
.tabs__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  color: var(--text-dim);
  font-size: 11px;
}
.tabs__item.is-active { color: var(--accent); }
.tabs__mark { position: relative; display: inline-flex; }
.tabs__count {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 11px;
}
.tabs__badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

/* Десктоп: таббар становится верхней панелью, контент остаётся колонкой. */
@media (min-width: 1024px) {
  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    grid-template-columns: repeat(4, auto);
    justify-content: center;
    gap: 8px;
    padding: 8px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }
  .tabs__item { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 18px; font-size: 14px; border-radius: var(--radius); }
  .tabs__item.is-active { background: var(--panel-2); }
  /* В строку иконка и подпись идут рядом, и счётчик, висящий над иконкой,
     наезжал на слово. На широком экране он становится отдельным значком
     после подписи. */
  .tabs__badge { display: none; }
  .tabs__count { display: inline-flex; }
  .phone { display: flex; flex-direction: column-reverse; justify-content: flex-end; }
  .screen { padding-bottom: 40px; }
  .bigs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- page head ---------------------------------------------------------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 6px; }
.page-head form { margin: 14px 0 0; }

/* --- connection cards --------------------------------------------------- */
.card--connection { margin-bottom: 18px; }

.card__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.card__head h2 { margin: 0; font-size: 17px; }

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--border);
  color: var(--muted);
}
.badge--required { color: var(--warn); }

.conn-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.conn-form > .field--textarea, .conn-form > .field--headers, .conn-form > .field--checkbox,
.conn-form > .card__actions, .conn-form > .result-slot, .conn-form > p { grid-column: 1 / -1; }
.check--switch { display: flex; align-items: center; gap: 10px; }
@media (max-width: 767px) { .conn-form { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; }
.field--checkbox { flex-direction: row; flex-wrap: wrap; align-items: center; }
.field--checkbox .field__help, .field--checkbox .field__error { flex: 1 0 100%; margin-top: 4px; }
.field input[type="text"], .field input[type="password"], .field textarea {
  margin-bottom: 0;
}
.field textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.field__help { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.field__error { margin: 5px 0 0; font-size: 13px; color: var(--error); }

.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; margin: 0; }
.check--inline { margin-top: 6px; font-size: 13px; color: var(--muted); }

.card__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.button--secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.button--secondary:hover { border-color: var(--accent); }

/* --- check results ------------------------------------------------------ */
.result-slot:empty { display: none; }
.result {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--border);
  background: var(--tint);
}
.result--ok { border-left-color: var(--ok); }
.result--bad { border-left-color: var(--error); }
.result--idle { border-left-color: var(--muted); }
.result__summary { margin: 0; }
.result__detail {
  margin: 10px 0 0;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.facts { margin: 10px 0 0; display: grid; gap: 4px; }
.facts__row { display: flex; gap: 10px; font-size: 13px; }
.facts dt { color: var(--muted); min-width: 160px; }
.facts dd { margin: 0; }

.check-all { margin-top: 12px; display: grid; gap: 6px; }
.check-all__row {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 7px;
  border-left: 3px solid var(--muted);
  background: var(--tint);
}
.check-all__row.is-ok { border-left-color: var(--ok); }
.check-all__row.is-bad { border-left-color: var(--error); }
.check-all__name { min-width: 120px; color: var(--muted); }

.alert--ok { background: var(--tint-ok); color: var(--ok); }

/* --- dashboard ---------------------------------------------------------- */
.status-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.status-list__item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  border-left: 3px solid var(--muted);
  background: var(--tint);
}
.status-list__item.is-ok { border-left-color: var(--ok); }
.status-list__name { min-width: 170px; }
.status-list__state { color: var(--muted); min-width: 120px; }
.status-list__hint { color: var(--muted); font-size: 13px; }

code { background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

/* --- cameras ------------------------------------------------------------ */
.inline-form { display: flex; gap: 8px; }
.inline-form input[type="text"] { margin-bottom: 0; min-width: 240px; }

.badge--on { color: var(--ok); }

.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.button--link-like {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 7px;
  text-decoration: none;
}

select {
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
}

button[disabled] { opacity: .5; cursor: not-allowed; }

/* --- policies ----------------------------------------------------------- */
.presence-now { font-size: 17px; margin: 0 0 4px; }
.presence-now--home { color: var(--warn); }
.presence-now--away { color: var(--ok); }
.presence-now--unknown, .presence-now--not_configured { color: var(--muted); }

.preview { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
.preview .is-yes { color: var(--ok); }
.preview .is-no { color: var(--muted); }

/* Широкая таблица прокручивается внутри карточки, а не толкает страницу
   вбок: на планшете с боковым меню матрица вылезала за край на 21 px. */
.matrix { width: 100%; border-collapse: collapse; margin: 8px 0 12px; display: block; max-width: 100%; overflow-x: auto; }
.matrix th, .matrix td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.matrix th { color: var(--muted); font-weight: 500; }
.matrix th:not(:first-child), .matrix__cell { text-align: center; width: 130px; }
.matrix tr.is-current { background: var(--tint-accent); }
.matrix .field__help { margin: 4px 0 0; }
.matrix input[type="checkbox"] { width: 18px; height: 18px; }

.camera-policy {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.camera-policy h3 { margin: 0 0 8px; font-size: 15px; }

/* --- timeline ----------------------------------------------------------- */
.filters__row { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; }
.filters__row .field { flex: 1 1 200px; }
.filters select[multiple] { min-height: 92px; }
.filters input[type="date"] {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
}

.day-divider {
  margin: 26px 0 12px;
  padding-bottom: 6px;
  font-size: 15px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.sighting {
  display: flex;
  gap: 16px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sighting__frame { flex: 0 0 200px; }
.sighting__frame img {
  width: 200px;
  border-radius: 7px;
  display: block;
}
.sighting__placeholder {
  width: 200px;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 7px;
}
.sighting__body { flex: 1 1 auto; min-width: 0; }
.sighting__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sighting__time { font-variant-numeric: tabular-nums; color: var(--muted); }
.sighting__camera { font-weight: 600; }
.sighting__description { margin: 10px 0 0; }
.sighting__statuses { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }

.status {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--tint);
  color: var(--muted);
}
.status--analyzed, .status--sent { color: var(--ok); }
.status--failed { color: var(--error); }
.status--pending { color: var(--warn); }

.badge--presence-home { color: var(--warn); }
.badge--presence-away { color: var(--ok); }

.sighting .links { margin: 10px 0 0; }
.load-more { padding: 18px; text-align: center; }

/* --- analysis ----------------------------------------------------------- */
.bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.bulk .field__help { margin: 0; flex: 1 1 260px; }

.sighting__actions { margin: 12px 0 0; }
.sighting__actions form { display: inline; }
.sighting__usage { margin-top: 8px; font-variant-numeric: tabular-nums; }

/* --- dashboard: latest events ------------------------------------------- */
.latest {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.latest__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.latest__item:hover { border-color: var(--accent); }
.latest__item img { width: 100%; border-radius: 6px; display: block; }
.latest__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.latest__caption { color: var(--muted); font-size: 13px; }
.latest__description {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- таблицы ------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 500; }

/* Широкую таблицу прокручиваем внутри контейнера, а не всей страницей. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

img { max-width: 100%; }

/* --- адаптив ------------------------------------------------------------
   Страница не должна ехать вбок ни на одной ширине: всё, что не помещается
   на 360 px, перестраивается в колонку, а не прокручивается горизонтально.
   ---------------------------------------------------------------------- */
@media (max-width: 640px) {
  .content { padding: 16px; }
  .card { padding: 16px; }

  .sighting { flex-direction: column; gap: 12px; }
  .sighting__frame { flex: none; }
  .sighting__frame img, .sighting__placeholder { width: 100%; }

  .latest { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .filters__row { flex-direction: column; gap: 12px; }
  .filters__row .field { flex: 1 1 auto; }

  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input[type="text"] { min-width: 0; }

  .facts__row { flex-direction: column; gap: 2px; }
  .facts dt { min-width: 0; }

  .status-list__item, .check-all__row { flex-direction: column; gap: 4px; }
  .status-list__name, .status-list__state, .check-all__name { min-width: 0; }

  /* Таблицы становятся карточками «поле — значение»: горизонтальная
     прокрутка на телефоне читается хуже, чем столбик. */
  /* display:block обязателен: иначе таблица считает ширину по содержимому
     и уезжает за экран вместе со страницей. */
  .table { display: block; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .table td {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
    padding: 3px 0;
    min-width: 0;
    border: 0;
  }
  .table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
  }
  .table td > * { min-width: 0; }

  .card__actions button { flex: 1 1 auto; min-height: var(--tap); }
}

/* Матрица политик на телефоне: строка состояния становится карточкой,
   а флажки подписываются столбцом, к которому относятся. */
@media (max-width: 640px) {
  .matrix thead { display: none; }
  .matrix tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .matrix td { display: block; padding: 4px 0; border: 0; }
  .matrix th:not(:first-child), .matrix__cell { width: auto; text-align: left; }
  .matrix__cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
  }
  .matrix__cell::before { content: attr(data-label); color: var(--muted); }
}

/* --- пользователи и профиль --------------------------------------------- */
.stack { display: grid; gap: 14px; }

.rights {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.rights legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.rights .check { min-height: 30px; }
.rights .field { margin-bottom: 10px; }

.card--password { border-color: var(--accent); }
.password-value code {
  display: inline-block;
  padding: 10px 14px;
  font-size: 19px;
  letter-spacing: .06em;
  user-select: all;
}

.nav__profile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.nav__profile:hover { background: var(--tint); }

.alert--warn { background: var(--tint-accent); }

@media (min-width: 900px) {
  .nav__profile {
    min-height: 34px;
    margin-left: 8px;
    padding: 0 8px;
    border-left: 1px solid var(--border);
  }
  /* Имя видно во всплывающей подсказке: в строке оно съедает место,
     которого не хватает разделам. */
  .nav__profile span { display: none; }
}

/* --- получатели события -------------------------------------------------- */
.recipients { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 3px; }
.recipients__row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 13px;
}
.recipients__who { color: var(--text); min-width: 140px; }
.recipients__state { color: var(--muted); }

@media (max-width: 640px) {
  .recipients__who { min-width: 0; }
}

/* --- сводка подключений -------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.tile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon title" "icon state" "icon when";
  gap: 0 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.tile:hover { border-color: var(--accent); }
.tile__icon { grid-area: icon; width: 22px; height: 22px; align-self: center; }
.tile__title { grid-area: title; font-weight: 600; }
.tile__state { grid-area: state; font-size: 13px; }
.tile__when { grid-area: when; font-size: 12px; color: var(--muted); }

.tile--ok { border-left-color: var(--ok); }
.tile--ok .tile__state { color: var(--ok); }
.tile--bad { border-left-color: var(--error); }
.tile--bad .tile__state { color: var(--error); }
.tile--idle { border-left-color: var(--muted); }
.tile--idle .tile__state { color: var(--muted); }
.tile--off { border-left-color: var(--border); }
.tile--off .tile__state, .tile--off .tile__title { color: var(--muted); }

/* --- разделы настроек ---------------------------------------------------- */
.settings { display: grid; gap: 16px; }
.settings__rail { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.settings__link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.settings__link:hover { color: var(--text); }
.settings__link.is-current {
  color: var(--text);
  border-color: var(--accent);
  background: var(--tint-accent);
}
.settings__body .card--connection { margin-bottom: 0; }

@media (min-width: 900px) {
  .settings { grid-template-columns: 230px 1fr; align-items: start; }
  .settings__rail {
    flex-direction: column;
    gap: 2px;
    overflow: visible;
    position: sticky;
    top: 16px;
  }
  .settings__link {
    border: 0;
    border-radius: var(--radius-sm);
    min-height: 38px;
    white-space: normal;
  }
  .settings__link.is-current { border: 0; }
}

/* --- дашборд: показатели ------------------------------------------------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.metric {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon value" "icon title" "icon hint";
  gap: 0 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.metric__icon { grid-area: icon; width: 24px; height: 24px; align-self: center; color: var(--muted); }
.metric__value { grid-area: value; font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric__title { grid-area: title; font-size: 13px; color: var(--muted); }
.metric__hint { grid-area: hint; font-size: 12px; color: var(--muted); }

/* --- дашборд: требует внимания ------------------------------------------- */
.attention { border-left: 3px solid var(--warn); }
.attention h2 { display: flex; align-items: center; gap: 8px; margin-top: 0; }
.attention__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.attention__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

/* --- дашборд: активность по часам ---------------------------------------- */
.activity {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding-bottom: 16px;
}
.activity__bar {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--tint);
  border-radius: 3px;
}
.activity__fill {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px;
}
.activity__tick {
  position: absolute;
  bottom: -16px;
  left: 0;
  font-size: 11px;
  color: var(--muted);
}

/* --- таймлайн: шкала времени --------------------------------------------- */
.scale {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 96px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  touch-action: pan-y;
  user-select: none;
}
.scale__bar {
  position: relative;
  flex: 1 1 0;
  min-width: 4px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  /* Дорожка пустого часа — тонкая линия по низу, а не блок во всю высоту:
     иначе редкие события читаются как сплошная заливка. */
  border-bottom: 2px solid var(--border);
  border-radius: 3px 3px 0 0;
  text-decoration: none;
}
.scale__bar:hover { background: var(--tint); }
.scale__bar.is-picked { background: var(--tint-accent); outline: 1px solid var(--accent); }
.scale__fill {
  position: relative;
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px;
}
.scale__bad {
  position: absolute;
  inset: auto 0 0 0;
  background: var(--error);
  border-radius: 0 0 3px 3px;
}
.scale__tick {
  position: absolute;
  bottom: -16px;
  left: 0;
  font-size: 11px;
  color: var(--muted);
}

/* --- таймлайн: чипсы ------------------------------------------------------ */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.chips--group { margin-bottom: 8px; }
.chips__title { color: var(--muted); font-size: 13px; min-width: 96px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.is-active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--tint-accent);
}
.chip--reset { border-style: dashed; }

.filters--dates, .filters--search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters--dates label { margin: 0; }
.filters--dates input[type="date"] { width: auto; margin: 0; }
.filters--search input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}

@media (max-width: 640px) {
  .chips__title { min-width: 0; width: 100%; }
}

/* --- камеры: список и карточка ------------------------------------------- */
.master { display: grid; gap: 16px; }
.master__list { display: grid; gap: 6px; }
.master__back { display: inline-block; margin-right: auto; }

.camera-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.camera-row:hover { border-color: var(--accent); }
.camera-row.is-current { border-color: var(--accent); background: var(--tint-accent); }

.camera-row__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-sunken);
  border-radius: 6px;
}
.camera-row__frame img { width: 100%; height: 100%; object-fit: cover; }
.camera-row__empty { font-size: 11px; color: var(--muted); text-align: center; }

.camera-row__body { display: grid; align-content: center; gap: 2px; min-width: 0; }
.camera-row__name { font-weight: 600; }
.camera-row__state { font-size: 13px; }
.camera-row__state--on { color: var(--ok); }
.camera-row__state--off { color: var(--muted); }
.camera-row__state--missing { color: var(--warn); }
.camera-row__when { font-size: 12px; color: var(--muted); }

@media (min-width: 900px) {
  .master { grid-template-columns: 300px 1fr; align-items: start; }
  .master__back { display: none; }
}

/* На телефоне выбранная камера открывается вместо списка: две колонки друг
   под другом заставили бы прокручивать весь список до формы. */
@media (max-width: 899px) {
  .master.has-detail .master__list { display: none; }
}

/* Уровень опасности. Шкала из четырёх сегментов: заполнено столько, каков
   уровень, цвет — по уровню. Слово рядом, потому что одним цветом уровень
   не прочтёт тот, кто цвета различает плохо. */
.risk { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-md);
        background: var(--panel-2); }
.risk__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.risk__word { font-size: 17px; font-weight: 700; color: var(--risk); }
.risk__why { color: var(--text-muted); font-size: 13px; }
.risk__bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.risk__bars span, .risk-mini span { background: var(--line); }
.risk__bars span { height: 6px; border-radius: 3px; }
.risk__bars .is-on, .risk-mini .is-on { background: var(--risk); }
.risk-mini { display: inline-flex; flex: none; gap: 2px; vertical-align: middle; }
.risk-mini span { width: 4px; height: 12px; border-radius: 2px; }
.risk--calm, .risk-mini--calm { --risk: var(--risk-calm); }
.risk--watch, .risk-mini--watch { --risk: var(--risk-watch); }
.risk--odd, .risk-mini--odd { --risk: var(--risk-odd); }
.risk--alarm, .risk-mini--alarm { --risk: var(--risk-alarm); }
.risk--none, .risk-mini--none { --risk: var(--risk-none); }
.risk--none .risk__word { font-size: 15px; font-weight: 600; }
.chip .risk-mini span { height: 10px; }
.line__head { display: flex; align-items: center; gap: 8px; }
.quad__camera .risk-mini { margin-left: 6px; }

/* Что уходит модели вместе с кадром: текст как есть, без переносов по словам
   сервиса — владелец должен видеть ровно то, что читает модель. */
.prompt-preview { margin-top: 16px; }
.prompt-preview pre { margin: 8px 0 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
                      background: var(--panel-2); border-radius: var(--radius-md); font-size: 13px; }
.prompt-preview ul, .prompt-preview ol { margin: 8px 0 0; padding-left: 18px; }

/* Статус дня на главной: цвет — самый высокий уровень за сегодня. */
.daystate { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius-lg);
            background: color-mix(in srgb, var(--risk) 12%, var(--panel));
            border: 1px solid color-mix(in srgb, var(--risk) 40%, transparent); }
.daystate__top { display: flex; align-items: center; gap: 12px; }
.daystate__mark { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px;
                  background: color-mix(in srgb, var(--risk) 22%, transparent); color: var(--risk); }
.daystate__mark .icon { width: 26px; height: 26px; }
.daystate__title { margin: 0; font-size: 19px; font-weight: 700; color: var(--risk); }
.daystate__sub { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.daystate__bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.daystate__bar span { background: var(--risk); }
.daystate__legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: 12px; color: var(--text-muted); }
.heat__legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }
.heat__legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; background: var(--risk); }
.daystate__legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; background: var(--risk); }
.daystate__last { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center; padding: 8px;
                  border-radius: var(--radius-md); background: var(--panel); color: var(--text); text-decoration: none; }
.daystate__frame { width: 72px; height: 48px; border-radius: 9px; }
.daystate__what { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.daystate__what span { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daystate__more { justify-self: start; }

/* Фильтр ленты по уровню: выбранный уровень красит сам список. */
.drop--risk.is-set > summary { color: var(--risk); border-color: color-mix(in srgb, var(--risk) 60%, transparent);
                               background: color-mix(in srgb, var(--risk) 14%, var(--panel)); }
.drop--risk.is-set > summary .muted { color: inherit; opacity: .8; }
.drop__option--risk .risk-mini { margin-right: 2px; }

/* Ролик события (вариант Г): карточка под кнопками просмотра и шторка. */
.clipcard { margin-top: 10px; }
.clipcard__open, .clipcard__state {
  display: grid; grid-template-columns: 128px 1fr; gap: 12px; align-items: center; width: 100%;
  padding: 8px; border-radius: var(--radius-lg); background: var(--panel); border: 1px solid var(--line);
  color: var(--text); text-align: left; font: inherit;
}
/* Карточка — кнопка, но не выглядит кнопкой: общий стиль button даёт
   высоту 36px и акцентный фон, здесь это всё снимается. */
.clipcard__open { height: auto; justify-content: stretch; font: inherit; cursor: pointer; }
.clipcard__open:hover { border-color: var(--accent); color: var(--text); filter: none; }
.clipcard__frame { position: relative; aspect-ratio: 16 / 9; border-radius: 9px; }
.clipcard__frame--wait { display: grid; align-items: end; padding: 0; background: var(--panel-2); }
.clipcard__frame--wait .working__bar { border-radius: 0; }
.clipcard__video { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--video); }
.clipcard__play {
  position: absolute; top: 6px; left: 6px; display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 50%; background: var(--osd); color: var(--on-osd);
}
.clipcard__len { position: absolute; right: 6px; bottom: 8px; left: auto; }
.clipcard__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--osd); }
.clipcard__bar i { display: block; width: 0; height: 100%; background: var(--accent); }
.clipcard__open:not(.is-playing) .clipcard__bar { display: none; }
.clipcard__body { display: grid; gap: 3px; min-width: 0; font-size: 13px; }
.clipcard__body b { font-size: 14px; }

.clipsheet {
  width: min(720px, 100%); max-width: 100%; max-height: 92vh; margin: auto auto 0; padding: 10px 14px 16px;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  background: var(--panel); color: var(--text);
}
.clipsheet::backdrop { background: var(--scrim); }
.clipsheet[open] { display: grid; gap: 10px; }
.clipsheet__grab { width: 40px; height: 4px; margin: 0 auto; border-radius: 2px; background: var(--line); }
.clipsheet__head { display: flex; align-items: center; justify-content: space-between; }
.clipsheet__video { width: 100%; max-height: 60vh; border-radius: var(--radius-md); background: var(--video); }
.clipsheet__note { margin: 0; font-size: 13px; }
.clipsheet__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.clipsheet__actions [aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
@media (min-width: 900px) {
  .clipsheet { margin: auto; border-radius: 20px; border-bottom: 1px solid var(--line); }
}
.event__clip { display: block; width: 100%; border-radius: var(--radius-md); background: var(--video); }
/* Значок «есть ролик» в строках лент. */
.has-clip { display: inline-flex; color: var(--text-dim); }

/* Место под ролики — подраздел в «Роликах событий». */
.clipstore { display: grid; gap: 12px; margin: 4px 0 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel-2); }
.clipstore h3 { margin: 0; font-size: 14px; font-weight: 600; }
.clipstore .storage__bar { background: var(--line); }
.clipstore .field__help { margin: 0; }
.clipstore .alert { margin: 0; }
.storage__part--full, .dot--clip-full { background: var(--accent); }
.storage__part--preview { background: var(--ok); }
.storage__part--part { background: var(--warn); }
.clipstore__row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12px; color: var(--text-muted); }
.clipstore__status { display: inline-flex; align-items: center; gap: 6px; }
.clipstore__status b { color: var(--text); }
.clipstore__cams { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 12px; }
.clipstore__cams li { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; align-items: center; gap: 10px; }
.clipstore__cams .mono:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clipstore__meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.clipstore__meter span { display: block; height: 100%; background: var(--accent); }
/* Значок «есть ролик» — в правом верхнем углу кадра, там же, где в
   плеерах привыкли видеть длительность. Тёмная подложка — чтобы читался
   на любом кадре, светлом и тёмном. */
.frame__clip {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--osd);
  color: var(--on-osd);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}
.frame__clip .icon { width: 12px; height: 12px; margin-left: 1px; fill: currentColor; }
.brief__frame .frame__clip { top: 4px; right: 4px; width: 20px; height: 20px; }
.brief__frame .frame__clip .icon { width: 10px; height: 10px; }
/* Экран события: метка, присутствие и отправка — в один ряд. Отправка —
   круглая иконка, статус цветом; по нажатию раскрывается в слова. */
.viewer .sheetcard .chip { white-space: nowrap; }
.chip--send {
  height: auto;
  min-width: 32px;
  justify-content: center;
  padding: 0 8px;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip--send:hover { filter: none; }
.chip--send__text { display: none; }
.chip--send.is-open { padding: 0 12px 0 10px; }
.chip--send.is-open .chip--send__text { display: inline; }
.chip--send-ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.chip--send-warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.chip--send-err { color: var(--err); background: var(--err-bg); border-color: transparent; }
.chip--send-idle { color: var(--text-dim); background: transparent; }
.chip--send-ok:hover { color: var(--ok); }
.chip--send-warn:hover { color: var(--warn); }
.chip--send-err:hover { color: var(--err); }
.chip--send-idle:hover { color: var(--text-muted); }

/* Отчёты. Черта под датой — есть ли отчёт: цвет — самое тревожное за день,
   пунктир — отчёта нет, мигает — собирается, красная — не собрался. */
.rmark { display: block; width: 16px; height: 4px; border-radius: 2px; background: var(--risk, var(--accent)); }
.rmark--none { background: none; border-top: 1.5px dashed var(--text-dim); height: 0; }
.rmark--empty { background: var(--text-dim); opacity: .6; }
.rmark--failed { background: var(--err); }
.rmark--active { background: var(--accent); animation: rblink 1.2s ease-in-out infinite; }
.days__item.is-active .rmark { box-shadow: 0 0 0 1.5px var(--on-accent); }
.days__item.is-active .rmark--none { border-color: var(--on-accent); box-shadow: none; }
@keyframes rblink { 50% { opacity: .25; } }

.rcal { gap: 10px; }
.rcal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rcal__head b { text-transform: capitalize; }
.rcal__head .round { margin: 0; }
.rcal__prev .icon { transform: rotate(180deg); }
.round.is-off { visibility: hidden; }
.rcal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.rcal__name { font-size: 11px; color: var(--text-dim); padding-bottom: 2px; }
.rcal__day { display: grid; justify-items: center; gap: 3px; padding: 6px 0 5px; border-radius: 8px;
             font-size: 13px; color: var(--text); }
.rcal__day:hover { background: var(--panel-2); }
.rcal__day.is-active { background: var(--accent); color: var(--on-accent); }
.rcal__day.is-future { color: var(--text-dim); opacity: .5; }
.rcal__day .rmark { width: 12px; height: 3px; }

.report { display: grid; gap: 16px; }
.report__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: 13px; }
.report__count { margin-left: auto; font-size: 13px; }
.report__list { display: grid; gap: 12px; }
.report__note { margin: 0; font-size: 12px; }
.report__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.report__admin { display: flex; justify-content: center; }

.verdict {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--risk) 16%, transparent), var(--panel) 70%);
  border: 1px solid color-mix(in srgb, var(--risk) 40%, transparent);
}
.verdict.risk--plain { --risk: var(--accent); }
.verdict__title { display: inline-flex; align-items: center; gap: 8px; justify-self: start;
                  padding: 5px 12px; border-radius: var(--radius-pill); font-weight: 600; font-size: 14px;
                  background: color-mix(in srgb, var(--risk) 18%, transparent); color: var(--risk); }
.verdict__title i { width: 8px; height: 8px; border-radius: 50%; background: var(--risk); flex: none; }
.verdict__summary { margin: 0; font-size: 17px; line-height: 1.45; }
.verdict__obs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.verdict__obs li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.verdict__obs li > span { flex: none; display: grid; place-items: center; width: 24px; height: 24px;
                          border-radius: 7px; background: var(--accent-bg); color: var(--accent); }

/* Кадр всегда в своей пропорции 16:9: раньше он растягивался на высоту
   текста, и от него оставалась узкая полоска посередине. На телефоне кадр
   сверху во всю ширину, на широком экране — слева, прижат к верху. */
.rshot { display: grid; grid-template-columns: 1fr; border-radius: 14px; overflow: hidden;
         background: var(--panel); border: 1px solid var(--line); }
.rshot__media { border-radius: 0; align-self: start; aspect-ratio: 16 / 9; }
.rshot__media a { display: block; width: 100%; height: 100%; }
.rshot__media img, .rshot__media video { width: 100%; height: 100%; object-fit: cover; }
.rshot__media video { display: block; background: var(--video); }
.rshot__media .frame__empty { height: 100%; }
@media (min-width: 600px) {
  .rshot:not(.rshot--lead) { grid-template-columns: 220px 1fr; }
}
.rshot__opens { display: inline-flex; align-items: center; gap: 3px; }
.report__lead { margin: 0; font-size: 14px; line-height: 1.45; }
.rshot__body { display: grid; gap: 6px; align-content: start; padding: 10px 12px 12px; }
.rshot__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; }
.rshot__body p { margin: 0; font-size: 14px; line-height: 1.45; }
.rshot__open { font-size: 13px; }
.rpill { padding: 3px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600;
         background: color-mix(in srgb, var(--risk) 18%, transparent); color: var(--risk); }

.rlink { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px;
         border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
         color: var(--accent); font-weight: 600; font-size: 14px; }
.rlink small { color: var(--text-muted); font-weight: 500; font-size: 12px; }

.rcat { display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.rcat p { margin: 0; font-size: 14px; line-height: 1.45; }
.rcat__examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rcat__examples a { display: grid; gap: 3px; color: var(--text-muted); }
.rcat__examples .frame { aspect-ratio: 4 / 3; border-radius: 8px; }
.rcat__examples small { font-size: 11px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rempty, .rstatus { display: grid; gap: 6px; padding: 18px 16px; border-radius: 14px;
                    background: var(--panel); border: 1px dashed var(--line); }
.rempty p, .rstatus p { margin: 0; font-size: 13px; }
.rstatus { grid-template-columns: auto 1fr; align-items: center; gap: 14px; border-style: solid; }
.rstatus__spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line);
                 border-top-color: var(--accent); animation: rspin .9s linear infinite; }
@keyframes rspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .rmark--active, .rstatus__spin { animation: none; }
}

/* Админка отчётов. */
.reports-generate { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 10px 0; }
.reports-generate label { width: 100%; }
.reports-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.reports-actions form { margin: 0; }
.reports-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 0; }
.reports-meta dt { color: var(--text-muted); }
.reports-meta dd { margin: 0; }
.reports-json { white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto;
                font: 12px/1.45 var(--font-mono); background: var(--panel-2); padding: 12px;
                border-radius: var(--radius-md); margin: 10px 0 0; }
.reports-status .dot, .card__slot .dot { display: inline-block; vertical-align: middle; margin-right: 4px; }
#reports-prompt_template { min-height: 320px; font: 13px/1.5 var(--font-mono); }
.guardline--report { background: var(--panel); }
.guardline--report .guardline__mark { background: var(--accent-bg); color: var(--accent); }
.guardline--report > .icon { margin-left: auto; color: var(--text-dim); flex: none; }
.guardline--report .guardline__body .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rversions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.rrate { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.rrate__button { min-width: 44px; height: 38px; padding: 0 12px; border-radius: var(--radius-pill);
                 background: var(--panel); border: 1px solid var(--line); font-size: 18px; filter: grayscale(.6); }
.rrate__button.is-on { background: var(--accent-bg); border-color: var(--accent); filter: none; }

/* Недельные сводки: переключатель вида, полоска недель, неделя по дням. */
.rkind { display: grid; grid-template-columns: 1fr 1fr; }
.rkind a { display: flex; align-items: center; justify-content: center; height: 34px; }
.days--weeks .days__number { font-size: 14px; white-space: nowrap; }
.rweek { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 12px;
         border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.rweek__day { position: relative; display: grid; justify-items: center; gap: 3px; font-size: 12px; color: var(--text); }
.rweek__day.risk--plain { --risk: var(--accent); }
.rweek__bar { display: flex; align-items: flex-end; width: 100%; max-width: 28px; height: 72px;
              border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.rweek__bar i { display: block; width: 100%; min-height: 3px; background: var(--risk); border-radius: 6px 6px 0 0; }
.rweek__flag { position: absolute; top: -6px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
               border-radius: 8px; background: var(--risk); color: var(--on-accent);
               font: 700 10px/16px var(--font-sans); text-align: center; }
.viewer__opens { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
