:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1d2330; --muted: #6b7385; --border: #dfe3ea;
  --accent: #2f6fde; --accent-text: #fff; --danger: #c73a3a; --ok: #1f8a4c; --warn: #b7791f;
  --plate-bg: #fff; --plate-text: #111;
  --gutter: 16px; --tabbar-h: 0px; --tap: 36px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --surface: #1d2129; --text: #e6e8ee; --muted: #9aa2b2; --border: #2e3440;
    --accent: #5b8ff0; --accent-text: #fff; --danger: #ef6b6b; --ok: #4cc27f; --warn: #e0a84a;
    color-scheme: dark;
  }
}
/* на сенсорных экранах — крупные цели для пальца */
@media (pointer: coarse) { :root { --tap: 44px; } }

* { box-sizing: border-box; }
/* страница прокручивается, но не масштабируется щипком — приближаются только окна с кадрами (.zoom) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: pan-x pan-y; overflow-x: hidden;
  background: var(--bg); }                       /* и при полной перезагрузке экран не вспыхивает белым */
/* clip, а не hidden: body не становится прокручиваемым контейнером, и липкая шапка продолжает работать */
body { overflow-x: hidden; overflow-x: clip; max-width: 100%; margin: 0; background: var(--bg); color: var(--text); font-size: 15px; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
a { color: var(--accent); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; }

button, .button, input, select {
  font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px;
  background: var(--surface); color: var(--text); min-height: var(--tap);
}
input, select { max-width: 100%; min-width: 0; }
/* flex: none — длинная подпись рядом не сжимает галочку (иначе на телефоне она становилась шириной в пару пикселей) */
input[type=checkbox], input[type=radio] { min-height: 0; padding: 0; flex: none; }
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; touch-action: manipulation; }
@media (hover: hover) { button:hover, .button:hover { border-color: var(--accent); } }
button:active, .button:active { filter: brightness(.94); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link { border: none; background: none; color: var(--accent); padding: 4px 6px; }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }   /* свой ✕ — .clear-btn */
.clear-wrap { position: relative; display: block; min-width: 0; }
.filters > .clear-wrap { flex: 1 1 180px; }                 /* в строке фильтров поле тянется (своё flex у поля — важнее) */
.clear-wrap > input { width: 100%; padding-right: 36px; }
.clear-btn { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center;
  width: 30px; height: 30px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; }
.clear-btn:hover { background: var(--border); color: var(--text); }
.clear-wrap:has(> input:placeholder-shown) > .clear-btn { display: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); }
.login-card { width: min(360px, 100%); display: grid; gap: 12px; }
.login-card label, .stack label { display: grid; gap: 4px; }
/* колонка сетки = ширина карточки или окна: без minmax(0, …) она растягивается по самому широкому содержимому — поля
   машин в окне Safari, <select> с длинным вариантом («Ворота → Брелоки») — и всё в карточке уезжает за край телефона */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: min(340px, 80vw); }
.row { display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ шапка */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l));
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: none; font-weight: 600; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--text); white-space: nowrap; }
.tabs a svg, .icon-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg { fill: currentColor; stroke: none; }
.tabs a.active { background: var(--accent); color: var(--accent-text); }
/* число на пункте меню (заявки ждут решения) */
.nav-badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
/* свёрнутый пункт (у модератора «Пропуска» — вкладка «Моего места»): страница есть, отдельного пункта нет */
.tabs a[data-nav-parent] { display: none; }
/* «Ещё» — только в нижней панели телефона */
.nav-more { display: none; }
@media (hover: hover) { .tabs a:not(.active):hover { background: color-mix(in srgb, var(--accent) 10%, transparent); } }
.icon-btn { display: none; border: none; background: none; padding: 0; width: var(--tap); min-width: 44px; height: 44px; border-radius: 50%; color: var(--text); }
.user { display: flex; align-items: center; gap: 4px; color: var(--muted); }

main { padding: var(--gutter) calc(var(--gutter) + var(--safe-r)) calc(var(--gutter) + var(--tabbar-h) + var(--safe-b)) calc(var(--gutter) + var(--safe-l));
  max-width: 1400px; margin: 0 auto; }

/* ------------------------------------------------------------------ журнал */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { flex: 1 1 240px; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--muted); }

/* фильтры журнала (как в каталоге магазина): колонка слева на широком экране, на узком — лист по кнопке */
.journal-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.journal-bar input[name=q], .journal-bar > .clear-wrap { flex: 1 1 auto; min-width: 0; }
.journal-bar input[name=q] { text-overflow: ellipsis; }      /* узкий экран: подсказка — с «…», а не обрезана посреди слова */
.evf-open { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.evf-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.evf-active { margin-bottom: 8px; align-items: center; }
.evf-active:empty { display: none; }
.evf-chip { min-height: 32px; padding: 2px 8px 2px 12px; font-size: 13px; background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--text); }
.evf-x { color: var(--muted); font-size: 11px; }

.ev-filters { padding: 16px; }
.ev-filters form { display: grid; gap: 14px; }
.evf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.evf-head h2 { margin: 0; font-size: 17px; outline: none; }   /* окно ставит фокус на заголовок, не на «Сбросить всё» */
.evf-group { border: none; border-top: 1px solid var(--border); border-radius: 0; padding: 12px 0 0; gap: 8px; }
.evf-group legend { float: left; width: 100%; padding: 0; margin-bottom: 8px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.evf-group legend + * { clear: both; }
.evf-periods button { min-height: 32px; padding: 2px 10px; border-radius: 999px; font-size: 13px; }
.evf-periods button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.evf-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.evf-dates label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.evf-dates input { width: 100%; min-width: 0; }
.evf-options { display: grid; gap: 0; }
.evf-opt { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 4px 6px; margin: 0 -6px; border-radius: 6px;
  cursor: pointer; }
.evf-opt input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; }
.evf-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.evf-n { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.evf-opt.evf-empty { color: var(--muted); opacity: .6; }
@media (hover: hover) { .evf-opt:hover { background: var(--hover); } }
.evf-note { margin: 0; }
.evf-foot { display: none; }

/* чья машина — под номером в журнале; машиноместо — ссылка на его записи */
.owner-line { margin-top: 2px; font-size: 12px; color: var(--muted); }
.owner-line .owner-space { padding: 0; min-height: 0; font-size: 12px; }
.owner-guest { color: var(--warn); }

/* колонка фильтров — только там, где таблице журнала (~900–1100 px) остаётся место: 1440 и масштаб Windows 150–175 %
   на 2560 — уже лист по кнопке «Фильтры» */
@media (min-width: 1501px) {
  .journal { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
  .journal-main { grid-column: 2; grid-row: 1; }
  /* окно открыто без затемнения (show) и стоит в сетке колонкой */
  .ev-filters[open]:not(:modal) { position: sticky; top: 16px; inset-inline: auto; display: block; width: auto; max-width: none;
    max-height: calc(100dvh - 32px); margin: 0; box-shadow: var(--shadow-sm); scrollbar-width: thin; }
  .evf-open { display: none; }
}
@media (max-width: 1500px) {
  .ev-filters { width: min(420px, 95vw); }
  .ev-filters .evf-foot { display: block; position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 12px 16px;
    background: var(--surface); border-top: 1px solid var(--border); }
  .evf-foot button { width: 100%; }
}
/* время и надёжность — в две строки, если таблице тесно */
@media (min-width: 761px) { .events td.c-time, .events td.c-rel { white-space: normal; } }
.hint { margin-top: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; -webkit-overflow-scrolling: touch; }
table.events { width: 100%; border-collapse: collapse; }
.events th, .events td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.events th { font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
.events tr:last-child td { border-bottom: none; }
.events img { display: block; border-radius: 4px; cursor: zoom-in; background: #000; }
.events img.car { height: 72px; max-width: 110px; object-fit: cover; }
.events img.plate { height: 36px; max-width: 160px; object-fit: contain; image-rendering: pixelated; }

/* журнал ворот: таблица, на телефоне — карточки */
table.gl-table { width: 100%; border-collapse: collapse; }
.gl-table th, .gl-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.gl-table th { font-weight: 600; color: var(--muted); font-size: 13px; white-space: nowrap; }
.gl-table tr:last-child td { border-bottom: none; }
.gl-table tr.failed { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.gl-table .link { padding: 0; min-height: 0; text-align: left; }
.gl-table .plate-link { padding: 0; min-height: 0; border: none; background: none; }
.gl-table td.empty { text-align: center; padding: 16px; }
.gl-photos { display: flex; gap: 4px; flex-wrap: wrap; }
/* журнал ворот — карточками одного вида (1.124.4): цикл (glCycleRows), пара блокировки и одиночная запись (glCard) —
   заголовок «ворота · время» с меткой, строка подробностей, кадры в ряд; записи раскрытого цикла — под ним с отступом */
.gl-table tr.gl-cyc-row > td { padding-left: 34px; background: color-mix(in srgb, var(--accent) 3%, var(--surface)); }
.gl-table tr.failed > td { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.gl-card-head { cursor: default; }
.gl-card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.gl-table .gl-gate { font-weight: 700; color: var(--text); }       /* как название ворот в заголовке цикла */
.gl-cyc-arrow { display: inline-block; width: 0.8em; text-align: center; }   /* «▸» цикла и «·» записи — одной ширины */
.gl-who > div, .gl-car > div { display: inline; }
.gl-car { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.gl-photos-row { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; max-width: 100%; }
.gl-cyc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.gl-cyc-toggle { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 2px; align-items: baseline;
  border: none; background: none; padding: 2px 0; text-align: left; color: var(--text); min-height: 0; flex: 1 1 320px; cursor: pointer; }
.gl-cyc-toggle > :not(.gl-cyc-arrow) { grid-column: 2; }
.gl-cyc-arrow { grid-row: 1 / span 3; transition: transform .15s; color: var(--muted); }
.gl-cyc-head.open .gl-cyc-arrow { transform: rotate(90deg); }
.gl-cyc-meta { font-size: 13px; color: var(--muted); }
.gl-cycle.live { color: var(--accent); }
.gl-table tr.gl-cyc-row td:first-child { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
.gl-photos img { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; cursor: zoom-in; background: var(--border); }
.gate-line { margin-top: 2px; font-size: 12px; }
.gate-line .link { padding: 0; min-height: 0; font-size: 12px; }
.gate-line.error .link { color: var(--danger); }
@media (max-width: 700px) {
  .gl-table, .gl-table tbody, .gl-table tr { display: block; }
  .gl-table td { display: block; padding: 8px 10px; min-width: 0; }
  .gl-table tr.gl-cyc-row > td { padding-left: 22px; }
  .journal-bar #gl-export { display: none; }
  /* журнал ворот: поиск во всю ширину, под ним порядок и «Фильтры» — в одну строку порядок сжимался до «Сначала н…»,
     а поиск — до «Номер, воро…» */
  .journal-bar:has(select[name=sort]) { flex-wrap: wrap; }
  .journal-bar:has(select[name=sort]) > input[name=q], .journal-bar:has(select[name=sort]) > .clear-wrap { flex-basis: 100%; }
  .journal-bar select[name=sort] { flex: 1 1 auto; }
}
.nowrap { white-space: nowrap; }
.check-hit { display: inline-grid; place-items: center; min-width: var(--tap); min-height: var(--tap); cursor: pointer; }

.plate-text {
  display: inline-block; font-family: "DIN Alternate", "Roboto Mono", ui-monospace, monospace; font-weight: 700;
  font-size: 17px; letter-spacing: .5px; padding: 2px 8px; border: 2px solid #111; border-radius: 5px;
  background: var(--plate-bg); color: var(--plate-text); white-space: nowrap;
}
.plate-text .region { border-left: 2px solid #111; margin-left: 6px; padding-left: 6px; font-size: 14px; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; }
.events-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin: 8px 0; }
.events-head p { margin: 0; }
.events-head .pager-top { margin: 0; gap: 8px; }
.events-head .pager-top button { flex: none; min-width: 44px; min-height: 40px; }

/* ------------------------------------------------------------------ сводка */
/* цвета рядов — опорная палитра dataviz (проверена на различимость при дальтонизме), свои шаги для тёмной темы */
:root { --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #8b95a7; --grid: #e6e8ec; }   /* c5 — «прочее» */
@media (prefers-color-scheme: dark) { :root { --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #6f7a8d; --grid: #2e3440; } }
.sum-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 4px 0 12px; }
.sum-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.sum-tile { padding: 12px 14px; display: grid; gap: 2px; }
.sum-tile .n { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sum-tile .t { font-size: 13px; color: var(--muted); }
.sum-tile .s { font-size: 12px; color: var(--muted); }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; margin-bottom: 12px; }
.sum-chart { padding: 12px 14px; min-width: 0; }
.sum-chart h2 { margin: 0 0 2px; font-size: 16px; }
.sum-chart .sub { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.sum-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.sum-chart svg text { fill: var(--muted); font-size: 11px; }
.sum-chart svg .grid { stroke: var(--grid); stroke-width: 1; }
.sum-chart svg .hit { fill: transparent; cursor: default; }
.sum-chart svg .hit:hover, .sum-chart svg .hit.on { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.sum-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 6px; font-size: 13px; color: var(--text); }
.sum-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sum-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 240px; }
.sum-tip b { display: block; margin-bottom: 2px; }
.sum-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.sum-table-wrap { padding: 10px 14px; }
.sum-table-wrap summary { cursor: pointer; font-weight: 600; }
.table-scroll { overflow-x: auto; margin-top: 8px; }
.sum-table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-table th, .sum-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: right; }
.sum-table th:first-child, .sum-table td:first-child { text-align: left; }

/* ------------------------------------------------------------------ живой просмотр */
.live { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .live { grid-template-columns: 1fr; } }
.live-video { background: #000; border-radius: 10px; overflow: hidden; min-height: 200px; display: grid; place-items: center; }
.live-video .zoom { width: 100%; }
.live-video img { width: 100%; display: block; }
.live-video p { color: #ccc; padding: 24px; }
.status { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.status dt { color: var(--muted); }
/* переносы — по словам (anywhere рвал «включено» по буквам в узкой колонке); длинное слово без пробелов всё равно перенесётся */
.status dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: break-word; }
#live-status { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }   /* узкая колонка: подпись и значение поровну */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--danger); }

/* ------------------------------------------------------------------ разметка */
#lab-groups { display: grid; gap: 12px; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  display: grid; gap: 10px; min-width: 0; }
.group.done { opacity: .45; }
.group.focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.group .crops { display: flex; flex-wrap: wrap; gap: 8px; }
.group .crops img { height: 56px; image-rendering: pixelated; border-radius: 4px; background: #000; cursor: zoom-in; }
.group .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.group .controls input { font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 1px; width: 200px; text-transform: uppercase; }
.group .meta { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ зона */
.zone-editor { background: #000; border-radius: 10px; line-height: 0; -webkit-touch-callout: none; touch-action: none; }
.zone-editor img { width: 100%; display: block; }
.zone-editor canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.zone-msg { margin: -4px 0 12px; min-height: 1.2em; }
.zone-msg:empty { display: none; }

/* ------------------------------------------------------------------ окна */
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); max-width: 95vw; max-height: 90dvh; overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgba(0,0,0,.6); }
#viewer { padding: 8px; }
#clip-viewer { padding: 8px; max-width: min(calc(100vw - 16px), 1100px); }
#clip-viewer video { display: block; width: min(calc(100vw - 50px), 1060px); max-height: calc(85dvh - 108px); background: #000; }
#clip-viewer .row { margin: 6px 0; gap: 8px; }
.clip-link { display: inline-block; margin-top: 2px; }
/* поле номера: основная часть | регион с RUS — как табличка (plateField в js/inputs.js) */
.plate-field { display: inline-flex; align-items: stretch; max-width: 100%; min-height: var(--tap); border: 1px solid var(--border);
  border-radius: 6px; background: var(--plate-bg, #fff); color: var(--plate-text, #111); overflow: hidden; vertical-align: middle; }
.stack > label > .plate-field, label > .plate-field { display: flex; width: 100%; }
.plate-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.plate-field input:focus { outline: none; }
.plate-field:has(input[aria-invalid=true]) { border-color: var(--danger); }
.plate-field input { border: none; border-radius: 0; background: transparent; color: inherit; min-height: 0; outline: none;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.plate-field input::placeholder { color: var(--muted); font-weight: 400; opacity: .6; }
.plate-field .pf-main { flex: 1 1 auto; width: 9ch; min-width: 7.5ch; padding: 6px 8px 6px 10px; }
.plate-field .pf-reg { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-left: 2px solid currentColor; padding: 2px 6px 1px; }
.plate-field .pf-region { width: 4.2ch; padding: 0; text-align: center; font-size: 15px; letter-spacing: .02em; }
.plate-field .pf-rus { font-size: 7px; font-weight: 700; letter-spacing: .3px; line-height: 1; }
.plate-field.free .pf-main { width: 14ch; }
/* заставка до запуска приложения (index.html #boot) */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 24px; text-align: center; background: var(--bg); color: var(--text); }
.boot[hidden] { display: none; }
.boot img { border-radius: 16px; }
.boot-error { display: grid; gap: 10px; justify-items: center; max-width: 340px; }
.boot-error[hidden] { display: none; }
.boot-slow { opacity: 0; animation: boot-slow 0s 12s forwards; max-width: 320px; }
@keyframes boot-slow { to { opacity: 1; } }
.boot:has(#boot-error:not([hidden])) .boot-slow { display: none; }
.hint-block { display: block; font-weight: 400; margin-top: 2px; }
.cam-card fieldset { gap: 10px; }
.cam-card .cam-floors { border: none; padding: 0; }
.cam-card .cam-sub { font-weight: 600; }
.cam-card .cam-sec-off > :not(legend):not(.cam-off) { opacity: .55; }
.cam-off { margin: 0; color: var(--muted); font-style: italic; }
.cam-pick { padding: 2px 0; }
.cam-pick .cam-tab { background: var(--card, transparent); color: var(--text); font: inherit; cursor: pointer; }
.cam-pick .cam-tab.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.cam-pick .cam-tab .dot { margin-right: 0; }
.cam-pick .cam-tab .dot:not(.ok):not(.bad) { background: var(--muted); }
/* вкладки разделов карточки настроек (app/admin/card-tabs.js, 1.201.9): камеры, домофоны */
.card-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.card-tab { background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 12px; min-height: 36px;
  color: var(--muted); font: inherit; cursor: pointer; }
.card-tab:hover { color: var(--text); }
.card-tab.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 600; }
.card-tab.off { opacity: .55; }
/* раздел один на вкладке — его заголовок уже на вкладке (в разметке остаётся: читалки экрана, тесты) */
.tabbed > fieldset.tab-solo { border: none; padding: 4px 0 0; }
.tabbed > fieldset.tab-solo > legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
details.more > summary { cursor: pointer; color: var(--accent); font-size: 13px; width: fit-content; }
details.more > div { margin-top: 6px; max-width: 72ch; }
.ic-badges .badge.warn { background: var(--warn, #d97706); border-color: var(--warn, #d97706); color: #fff; }
#cam-add { cursor: pointer; font: inherit; }
.clip-line { display: flex; flex-wrap: wrap; gap: 4px 12px; }
#viewer-zoom { touch-action: none; width: fit-content; max-width: 100%; margin: 0 auto 8px; border-radius: 6px; background: #000; }
/* маленькие кадры номеров (от 103×38) открываются крупно, вытянутые снимки вписываются без искажений */
#viewer img { min-width: min(calc(100vw - 50px), 520px); max-width: 100%; max-height: 70vh; max-height: calc(85dvh - 108px); display: block; object-fit: contain; image-rendering: auto; }
/* кнопки масштаба — под снимком, а не на нём */
#viewer > .zoom-ui { position: static; width: fit-content; margin: 0 auto 8px; opacity: 1; }
#viewer-zoom:not(.zoomed) + .zoom-ui .zoom-reset { display: none; }

/* ------------------------------------------------------------------ масштаб кадров */
.zoom { position: relative; overflow: hidden; touch-action: pan-y; }
.zoom.zoomed { touch-action: none; cursor: grab; }
.zoom.zoomed:active { cursor: grabbing; }
.zoom-stage { position: relative; transform-origin: 0 0; user-select: none; -webkit-user-select: none; }
.zoom-stage img { -webkit-user-drag: none; }
.zoom-ui {
  position: absolute; right: 8px; bottom: 8px; z-index: 2; display: flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; line-height: normal;
  transition: opacity .15s;
}
.zoom-ui button { min-height: 32px; min-width: 32px; padding: 0 6px; border: none; border-radius: 7px; background: none; color: #fff; font-size: 18px; }
.zoom-ui button:hover { background: rgba(255,255,255,.18); }
.zoom-ui .zoom-reset { font-size: 12px; }
.zoom:not(.zoomed) .zoom-reset { display: none; }
.zoom-level { font-size: 12px; min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .zoom-ui button { min-width: 40px; min-height: 40px; } }
/* с мышью кнопки появляются при наведении, чтобы не закрывать кадр */
@media (hover: hover) {
  .zoom-ui { opacity: 0; }
  .zoom:hover .zoom-ui, .zoom.zoomed .zoom-ui, .zoom-ui:focus-within { opacity: 1; }
}

.center { text-align: center; }
.small { font-size: 12px; }
.events input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; margin: 0; }
.events tr.verified td { background: color-mix(in srgb, var(--ok) 8%, transparent); }
.plate-cell { white-space: nowrap; }
.plate-line { display: inline-flex; align-items: center; white-space: nowrap; }
.plate-link { padding: 0; min-height: 0; border: 0; border-radius: 4px; background: none; cursor: pointer; vertical-align: middle; }
.plate-link:hover .plate-text { box-shadow: 0 0 0 3px var(--accent-soft); }
.plate-cell button.plate-link { margin-right: 0; }
.plate-cell .edit { margin-left: 4px; font-size: 16px; }
.plate-cell .plate-input { width: 200px; margin-right: 4px; }
.plate-cell button { margin-right: 4px; }
.link.danger { color: var(--danger); font-size: 16px; }
.live-badge { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--ok); color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ реле */
.relay-module { max-width: 640px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 label { display: grid; gap: 4px; align-content: end; }
.row2 input, .row2 select { width: 100%; }
/* галочка — напротив первой строки подписи (а не посреди абзаца); отступы дают ту же высоту пальцу, что и min-height */
label.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; min-height: var(--tap); padding-block: 10px; }
/* галочка: название строкой, подсказка — под ним, обычным шрифтом */
label.check .check-body { display: grid; gap: 2px; min-width: 0; }
label.check .check-hint { font-weight: 400; font-size: 13px; line-height: 1.35; color: var(--muted); }
label.check input { min-height: 0; width: 20px; height: 20px; margin: 2px 0 0; margin: calc((1lh - 20px) / 2) 0 0; }   /* 2px — Safari до 16.4 без lh */
.row.wrap { flex-wrap: wrap; }
.status.flat { border: none; padding: 0; background: none; }
.hint-card ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
pre { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.push-box { max-width: 480px; }
.hint-box { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* ================================================================== телефон */
@media (max-width: 760px) {
  :root { --gutter: 12px; --tabbar-h: 60px; }
  body { font-size: 15px; }
  /* 16px в полях ввода — иначе iOS увеличивает страницу при фокусе */
  input, select, textarea { font-size: 16px; }
  h2 { font-size: 17px; }
  .card { padding: 16px; }

  /* шапка: название раздела + меню; вкладки — внизу, как в приложении */
  .topbar { padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) 6px calc(16px + var(--safe-l)); min-height: 52px; }
  .brand { display: block; }
  .icon-btn { display: inline-flex; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 0; flex-wrap: nowrap;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabs a {
    flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 3px;
    padding: 6px 2px; border-radius: 0; font-size: 11px; color: var(--muted);
  }
  .tabs a svg { width: 24px; height: 24px; }
  .tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs a.active { background: none; color: var(--accent); font-weight: 600; }
  .tabs a { position: relative; }
  .tabs a .nav-badge { position: absolute; top: 4px; left: calc(50% + 5px); max-width: none; overflow: visible; }
  .tabs a.in-more { display: none; }
  .tabs .nav-more:not([hidden]) {
    display: flex; flex: 1 1 0; min-width: 0; min-height: 0; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 2px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 11px; position: relative;
  }
  .tabs .nav-more svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
  .tabs .nav-more.active { color: var(--accent); font-weight: 600; }
  .tabs .nav-more.has-badge::after { content: ""; position: absolute; top: 7px; left: calc(50% + 9px); width: 9px; height: 9px;
    border-radius: 50%; background: var(--danger); }

  .user {
    display: none; position: absolute; top: calc(100% + 4px); right: calc(8px + var(--safe-r));
    flex-direction: column; align-items: stretch; gap: 0; min-width: 220px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
  }
  .menu-open .user { display: flex; }
  .user #username { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .user button.link { justify-content: flex-start; padding: 10px 12px; min-height: 44px; color: var(--text); border-radius: 8px; }
  .user button.link:active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  #btn-logout { color: var(--danger); }

  /* фильтры журнала: лист снизу во всю ширину, кнопка «Показать» прилипает к низу */
  .ev-filters { width: 100%; }
  .ev-filters .evf-foot { bottom: calc(-16px - var(--safe-b)); margin-bottom: calc(-16px - var(--safe-b));
    padding-bottom: calc(12px + var(--safe-b)); }
  .journal-bar #events-export { display: none; }          /* CSV на телефоне не нужен — место строке поиска */
  /* только вертикальная прокрутка: свайп вбок ничего не сдвигает */
  html { touch-action: pan-y; overscroll-behavior-x: none; }

  /* iOS не даёт полю даты стать уже встроенной ширины, пока не снят системный вид */
  input[type=date] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; width: 100%; text-align: left; }
  input[type=date]::-webkit-date-and-time-value { text-align: left; min-height: 1.4em; }
  .events .c-car .pimg-views { flex-wrap: wrap; max-width: 112px; }   /* четыре вида снимка — в две строки */

  /* журнал: строки таблицы превращаются в карточки. Только у таблиц-карточек (журнал, журнал ворот): до 1.255.1 правило
     было на всех .table-wrap — таблицы кодов двери, событий датчиков, предпросмотра брелоков теряли прокрутку и
     распирали карточку шире экрана (у html overflow-x: hidden — правый край просто не виден на телефоне) */
  .table-wrap.table-cards { overflow: visible; background: none; border: none; border-radius: 0; }
  table.events, .events tbody { display: block; }
  .events thead { display: none; }
  .events tr {
    display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px;
    grid-template-areas:
      "car  plate del"
      "car  time  chk"
      "car  stay  chk"
      "pimg cam   cam"
      "pimg rel   rel";
    align-items: center; padding: 10px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  }
  .events tr.verified { background: color-mix(in srgb, var(--ok) 9%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
  .events tr.verified td { background: none; }
  .events td { display: block; padding: 0; border: none; min-width: 0; }
  .events td.empty { grid-column: 1 / -1; padding: 12px; text-align: center; }
  .events .c-car { grid-area: car; align-self: start; }
  .events .c-plate { grid-area: plate; white-space: normal; }
  .events .c-time { grid-area: time; font-size: 13px; color: var(--muted); }
  .events .c-stay { grid-area: stay; font-size: 13px; white-space: normal; }
  .events .c-pimg { grid-area: pimg; padding-top: 8px; }
  .events .c-cam { grid-area: cam; font-size: 13px; padding-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .events .c-rel { grid-area: rel; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .events .c-del { grid-area: del; justify-self: end; }
  .events .c-check { grid-area: chk; justify-self: end; }
  .events td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  .events img.car { width: 112px; height: 84px; max-width: none; }
  .events img.plate { height: 32px; max-width: 112px; }
  .events .link.danger { min-width: 44px; min-height: 44px; margin: -8px -8px 0 0; }
  .events .check-hit { margin-right: -8px; }
  .events input[type=checkbox] { width: 22px; height: 22px; }
  .plate-text { font-size: 16px; }
  .plate-cell .edit { min-width: 40px; min-height: 40px; vertical-align: middle; }
  .plate-cell .plate-input { width: 100%; margin: 0 0 6px; }
  .plate-cell button.primary, .plate-cell button:not(.link) { margin: 0 4px 4px 0; }

  .pager { margin: 12px 0 4px; }
  .pager button { flex: 1; }
  .events-head .pager-top button { flex: none; }

  /* разметка */
  .group .crops img { height: 48px; }
  .group .controls input { flex: 1 1 100%; width: auto; }
  .group .controls button { flex: 1 1 auto; }

  /* зона */
  .zone-tools button { flex: 1 1 calc(50% - 4px); }
  .zone-tools #zone-save { flex-basis: 100%; }

  /* реле */
  .row2 { grid-template-columns: 1fr; }
  .row.wrap > button { flex: 1 1 auto; }

  /* окна на телефоне выезжают снизу на всю ширину */
  dialog.sheet {
    margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh;
    border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 20px calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  }
  dialog.sheet .stack { min-width: 0; }
  dialog.sheet .row button, dialog.sheet .row.wrap button, dialog.sheet form[method=dialog] button { flex: 1 1 auto; }
  dialog.sheet form[method=dialog] { display: flex; }
  /* лист выезжает снизу и смахивается вниз (js/viewer.js): ручка сверху — подсказка, что его можно тянуть */
  dialog.sheet[open] { animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
  dialog.sheet::before { content: ""; display: block; width: 36px; height: 5px; margin: -10px auto 12px; border-radius: 3px;
    background: var(--border); }
  dialog.sheet.sheet-back { transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
  dialog.sheet.sheet-dragging { transition: none; }
  dialog.sheet::backdrop { opacity: calc(1 - var(--sheet-drag, 0) * .8); }   /* фон светлеет, пока лист тянут */
  @keyframes sheet-in { from { transform: translateY(100%); } }
  #viewer { max-width: calc(100vw - 16px); }
}

/* очень узкие экраны */
@media (max-width: 380px) {
  .events tr { grid-template-columns: 92px minmax(0, 1fr) auto; column-gap: 10px; }
  .events img.car { width: 92px; height: 70px; }
  .events img.plate { max-width: 92px; }
  .filter-actions > * { font-size: 14px; }
}

/* альбомная ориентация телефона: экран низкий, видео важнее */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .live { grid-template-columns: minmax(0, 1fr) 240px; }
  .live-video img { max-height: calc(100dvh - 140px); object-fit: contain; }
}

/* ------------------------------------------------------------------ двухфакторная защита */
.totp-box { max-width: 480px; }
.totp-box p { margin: 0; }
.totp-qr { display: block; width: 220px; height: 220px; margin: 0 auto; background: #fff; border-radius: 8px; image-rendering: pixelated; }
.totp-secret { font-size: 13px; letter-spacing: .5px; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
#login-code-row input, .totp-box input[name=code] { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: 4px; }

/* ------------------------------------------------------------------ зоны: имена */
.zone-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.zone-list li { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.zone-list li.selected { border-color: #ffd400; box-shadow: 0 0 0 1px #ffd400; }
.zone-list input { flex: 1 1 auto; min-width: 0; }
.zone-pick { min-width: var(--tap); font-weight: 600; }

/* ------------------------------------------------------------------ общие элементы форм устройств */
.row.between { justify-content: space-between; align-items: center; }
.row.between h2 { margin: 0; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.row3 label { display: grid; gap: 4px; }
.row3 select, .row3 input { width: 100%; }
.save-bar { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); z-index: 4; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 10px; min-width: 0; }
legend { padding: 0 6px; font-weight: 600; }
.gate-form label:not(.check):not(.chip):not(.inline) { display: grid; gap: 4px; }
.gate-form { max-width: 560px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
.danger-btn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* нажатый чип-кнопка (быстрый фильтр) — заметно; до 1.252 у простых .chips отметки не было вовсе («Звонки», «Счётчики») */
.chips > button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; min-height: 36px; border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.chip input { min-height: 0; margin: 0; width: 18px; height: 18px; }
.slots { display: grid; gap: 8px; }
.slot { display: grid; gap: 8px; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; }

/* ------------------------------------------------------------------ ворота */
.gate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-bottom: 12px; }
.gate { display: grid; gap: 10px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badges:empty { display: none; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.gate-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
/* ворота и двери — группами; у двери одна кнопка во всю ширину, карточки уже, полоса слева — другого цвета */
.kind-groups { display: grid; gap: 20px; margin-bottom: 12px; }
.kind-group { display: grid; gap: 10px; }
.kind-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; color: var(--muted);
              padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.kind-count { font-size: 12px; font-weight: 600; min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
              background: var(--hover, var(--bg)); color: var(--muted); }
.kind-group .gate-grid { margin-bottom: 0; }
.gate-grid.kind-door { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.card.gate, .card.gate-cfg { border-left: 4px solid var(--accent); }
.card.gate.door, .card.gate-cfg.door { border-left-color: var(--ok); }
.card.gate.door .gate-buttons { grid-template-columns: 1fr; }
.gate-btn { flex-direction: column; gap: 2px; min-height: 64px; font-weight: 600; }
.gate-icon { font-size: 18px; line-height: 1; }
.gate-btn.sent { background: var(--ok); border-color: var(--ok); color: #fff; }
.gate-last { margin: 0; }
/* положение ролеты: открыта — красным, закрыта — зелёным, между положениями — нейтрально; долго между — моргающая точка */
.roll-pos { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 8px 12px; border-radius: 8px; font-size: 16px;
            border: 1px solid var(--border); background: var(--bg); }
.roll-pos-icon { font-size: 14px; line-height: 1; }
.roll-pos.open { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent);
                 background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.roll-pos.closed { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent);
                   background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.roll-pos.fault { color: var(--danger); border-style: dashed; }
.roll-pos-sub, .roll-pos-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.roll-pos-alarm { display: none; width: 12px; height: 12px; margin-left: auto; border-radius: 50%; background: var(--danger); }
.roll-pos.long { border-color: var(--danger); }
.roll-pos.long .roll-pos-alarm { display: inline-block; animation: roll-alarm 1s steps(1) infinite; }
@keyframes roll-alarm { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .roll-pos.long .roll-pos-alarm { animation-duration: 2s; } }
/* шторка «Включённые настройки» на пульте */
.gate-info { border-top: 1px solid var(--border); padding-top: 6px; }
.gate-info > summary { cursor: pointer; font-size: 14px; color: var(--muted); min-height: 32px; display: flex; align-items: center; gap: 6px; }
.gate-info[open] > summary { margin-bottom: 6px; }
.gate-info > :not(summary) + :not(summary) { margin-top: 8px; }
.gate-info-count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.gate-stop { margin: 0; padding: 6px 10px; border-radius: 8px; font-size: 14px; border-left: 4px solid var(--border); background: var(--bg); }
.gate-stop.held { border-left-color: var(--warn); }
.gate-stop.free { border-left-color: var(--ok); }
.gate-stop.soon { border-left-color: var(--warn); }
.block-countdown { font-variant-numeric: tabular-nums; }
.block-buttons { gap: 8px; margin-top: -4px; }
.block-btn:disabled { opacity: .45; cursor: default; }
.gate-stop.error { border-left-color: var(--danger); color: var(--danger); }

/* «Как ворота защищены»: схема положений и правила под каждым */
.gate-logic summary { cursor: pointer; list-style: none; }
.gate-logic summary::-webkit-details-marker { display: none; }
.gate-logic summary h2 { display: inline; }
.gate-logic summary::after { content: " ▾"; color: var(--muted); }
.gate-logic:not([open]) summary::after { content: " ▸"; }
.gate-logic-svg { width: 100%; height: auto; max-height: 180px; margin: 8px 0; }
.gl-box { fill: var(--surface); stroke-width: 2.5; }
.gl-box.gl-closed { stroke: var(--ok); } .gl-box.gl-between { stroke: var(--warn); } .gl-box.gl-open { stroke: var(--accent); }
.gl-title { font: 700 16px system-ui, sans-serif; fill: var(--text); text-anchor: middle; }
.gl-sub { font: 13px system-ui, sans-serif; fill: var(--muted); text-anchor: middle; }
.gl-line { stroke: var(--muted); stroke-width: 2; fill: none; }
.gl-ink { fill: var(--muted); }
.gate-logic-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.gate-logic-cols.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gl-col { border: 1px solid var(--border); border-top: 4px solid var(--border); border-radius: 10px; padding: 8px 10px;
  font-size: 14px; background: var(--bg); }
.gl-col ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.gl-col p { margin: 6px 0 0; }
.gl-col.gl-closed { border-top-color: var(--ok); } .gl-col.gl-between { border-top-color: var(--warn); }
.gl-col.gl-open { border-top-color: var(--accent); } .gl-col.gl-car { border-top-color: var(--danger); }
.gl-col.gl-unknown { border-top-color: var(--muted); }
.gate-logic-svg.narrow { display: none; max-height: 300px; }
.gl-sub.gl-end { text-anchor: end; } .gl-sub.gl-start { text-anchor: start; }
@media (max-width: 700px) {
  .gate-logic-cols, .gate-logic-cols.two { grid-template-columns: 1fr; }
  .gate-logic-svg { display: none; }
  .gate-logic-svg.narrow { display: block; }
}
.gates-actions { margin-bottom: 16px; }
#page-gates > .card { margin-bottom: 16px; }
.wl-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.wl-form label { display: grid; gap: 4px; color: var(--muted); }
.wl-form .chips, .wl-form .row, .wl-form .error { grid-column: 1 / -1; }
.wl-list { list-style: none; margin: 0; padding: 0; display: grid; }
.wl-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.wl-list li:last-child { border-bottom: none; }
.wl-list li.off .wl-main { opacity: .5; }
.wl-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.wl-main .small { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .row3 { gap: 8px; }
  .wl-form { grid-template-columns: 1fr; }
  .tabs a, .tabs .nav-more:not([hidden]) { font-size: 10px; }
  .tabs a svg, .tabs .nav-more svg { width: 22px; height: 22px; }
}
/* чипы внутри форм, где label по умолчанию — сетка «подпись над полем» */
.stack label.chip, .wl-form label.chip { display: inline-flex; grid-template-columns: none; color: var(--text); }

/* ------------------------------------------------------------------ жильцы и пропуска */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.person { display: grid; gap: 8px; align-content: start; }
.person.off { opacity: .6; }
.person h2 { margin: 0; }
.owners { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.owners a { text-decoration: none; white-space: nowrap; }
.person-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.person-line .badge { font-size: 11px; }
.tg-link { text-decoration: none; white-space: nowrap; }
.messengers { display: grid; gap: 6px; }
.badge.bad { background: var(--danger); border-color: var(--danger); color: #fff; }
.person-form { max-width: 560px; }
.person-form label:not(.check) { display: grid; gap: 4px; }
.person-form .row2 input { width: 100%; }
#people-q { flex: 1 1 260px; }
.pass-form, .wl-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.pass-form label { display: grid; gap: 4px; color: var(--muted); }
.pass-form label.check { display: flex; color: var(--text); }
.pass-form input[name=plate] { text-transform: uppercase; }
.pass-form input[aria-invalid=true] { border-color: var(--danger, #d33); }
#pass-plate-hint.error { color: var(--danger, #d33); }
.pass-form .chips, .pass-form button[type=submit], .pass-form .error, .pass-form .pass-foreign, .wl-form .wl-hint { grid-column: 1 / -1; }
.pass-cards-card { gap: 12px; }
.page > .card + .card { margin-top: 8px; }        /* карточки подряд не слипаются — зазор как на «Воротах» жильца */
#pass-limit { margin: 0; }
.pass-cards .sc-track { margin: 0 -6px; border-radius: 0; }
.pass-cards .sc-slide { display: block; padding: 2px 6px 6px; background: none; }
.pass-card .pass-left { font-size: 20px; font-weight: 650; }
.pass-card.upcoming { background: var(--surface-2, var(--bg)); border: 1px dashed var(--border); }
.pass-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pass-card .pass-cancel { padding-left: 0; }
.pass-form button[type=submit] { margin-top: 12px; }               /* кнопка отделена от выбора срока */
.pass-past summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.pass-cards .sc-view:has(.sc-arrow) .sc-slide { padding-left: 6px; }
.pass-form .pass-plate, .pass-form .pass-guest { align-self: start; }
@media (min-width: 761px) { #page-passes .card { max-width: 560px; } }       /* обе карточки — одной ширины */
.pass-quick button { border-radius: 999px; padding: 4px 12px; }
.pass-quick button[hidden] { display: none; }
.pass-form .pass-repeat, .pass-form .pass-days { grid-column: 1 / -1; }
.pass-days { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px 10px; margin: 0; display: grid; gap: 8px; }
.pass-days[hidden] { display: none; }
.pass-days legend { padding: 0 4px; }
.pass-hours { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#pass-weekdays .chip { padding: 4px 10px; }
.pass-schedule { font-weight: 600; }
.floor-pick { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px 8px; margin: 0; display: grid; gap: 6px; }
.floor-pick legend { padding: 0 4px; color: var(--muted); }
#person-gates .chip.exception { border-color: var(--accent); }
.plate-req-open { margin-top: 8px; width: 100%; }
.my-plate-reqs { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.my-plate-reqs h3 { margin: 0 0 6px; font-size: 15px; }

.plate-req-what label { color: var(--text); }
#plate-req-new-label[hidden] { display: none; }
.cam-stream { display: grid; gap: 10px; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cam-stream legend { padding: 0 6px; font-weight: 600; }
.cam-stream p { margin: 0; }
.pass-quick button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.wl-hint { margin: 0; }
#my-card h2 { margin: 0; }
@media (max-width: 760px) {
  .pass-form { grid-template-columns: 1fr; }
}

/* ================================================================== современный облик (общие токены) */
:root {
  --bg: #f4f6fb; --surface: #fff; --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  --accent: #2563eb; --accent-text: #fff; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --hover: #f1f5f9; --sidebar-bg: #fff; --radius: 14px; --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1018; --surface: #121926; --text: #e5e9f0; --muted: #94a3b8; --border: #223047;
    --accent: #60a5fa; --accent-text: #0b1018; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
    --hover: #1a2334; --sidebar-bg: #0f1521;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 12px 32px -12px rgba(0, 0, 0, .6);
  }
}
body { line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.005em; }
.card { border-radius: var(--radius); box-shadow: var(--shadow-sm); border-color: var(--border); }
button, .button, input, select { border-radius: var(--radius-sm); transition: border-color .15s, background-color .15s, box-shadow .15s; }
input, select { background: var(--surface); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* свой вид списка: родной select в iOS не слушается min-height и выходит ниже соседних полей; стрелка — из градиентов (без картинок) */
select { -webkit-appearance: none; appearance: none; padding-right: 30px; background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select:disabled { opacity: .6; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { font-weight: 600; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent); }
@media (hover: hover) {
  button:not(.primary):not(.link):not(:disabled):hover, .button:hover { background: var(--hover); border-color: var(--border); }
  button.primary:not(:disabled):hover { filter: brightness(1.07); }
}
.table-wrap, dialog { border-radius: var(--radius); }
.table-wrap { box-shadow: var(--shadow-sm); }
.events th { background: var(--hover); text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em; }
@media (hover: hover) { .events tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); } }
dialog { box-shadow: var(--shadow); border-color: var(--border); }
fieldset legend, .row.between legend { font-weight: 650; padding: 0 6px; }
.row.between > legend { padding: 0; }
.badge { background: var(--hover); border-color: transparent; }
.status { box-shadow: var(--shadow-sm); border-radius: var(--radius); }

/* вход */
.login { background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); padding: 28px; box-shadow: var(--shadow); }
.login-org { display: block; padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.login-org img { display: block; width: min(250px, 100%); height: auto; margin: 0 auto; }
.login-org[hidden] { display: none; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand img { width: 44px; height: 44px; border-radius: 12px; }
.login-brand h1 { margin: 0; font-size: 22px; }
/* второй шаг входа: код из приложения-аутентификатора */
.login-code { gap: 18px; }
.login-back { justify-self: start; margin: -8px 0 -6px -4px; padding: 4px; font-size: 15px; }
.login-code-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.login-code-head h1 { margin: 4px 0 0; font-size: 22px; }
.login-code-head p { margin: 0; overflow-wrap: anywhere; }
.login-code-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.login-code-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-code-hint { margin: 0; text-align: center; }

/* поле кода по ячейкам (input[data-otp] → .otp, app/common/inputs.js): настоящее поле — прозрачное поверх ячеек */
.otp { position: relative; display: block; width: 100%; max-width: 340px; justify-self: center; }
/* не opacity: 0 — у полностью прозрачного поля iPhone не показывает меню «Вставить»; текст и курсор и так прозрачные */
.otp-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .01; border: 0; padding: 0;
  font-size: 16px; color: transparent; caret-color: transparent; background: transparent; z-index: 1; cursor: text; }
.otp-cells { display: grid; grid-template-columns: repeat(3, 1fr) 10px repeat(3, 1fr); gap: 8px; align-items: center; }
.otp-gap { width: 10px; height: 2px; border-radius: 1px; background: var(--border); justify-self: center; }
.otp-cell { height: 56px; display: grid; place-items: center; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text);
  transition: border-color .15s, box-shadow .15s; }
.otp-cell.filled { border-color: color-mix(in srgb, var(--text) 35%, var(--border)); }
.otp-cell.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.otp-cell.active:empty::after { content: ""; width: 2px; height: 26px; border-radius: 1px; background: var(--accent);
  animation: otp-caret 1s steps(1) infinite; }
@keyframes otp-caret { 50% { opacity: 0; } }
.otp.otp-error .otp-cell { border-color: var(--danger); }
.otp.otp-error { animation: otp-shake .4s; }
@keyframes otp-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .otp.otp-error { animation: none; } .otp-cell.active:empty::after { animation: none; } }
@media (max-width: 380px) { .otp-cells { gap: 6px; } .otp-cell { height: 50px; font-size: 22px; } }
.stack label .otp { margin-top: 2px; justify-self: start; }
.otp-paste { justify-self: center; margin-top: 4px; min-height: var(--tap); }
/* первый вход жильца (app/user/onboarding.js) */
.onb-step { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.onb-step h3 { margin: 0; font-size: 16px; }
.onb-step p { margin: 0; }
.onb-how { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.onb-icon { display: inline-block; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; }
.onb-done { color: var(--ok); font-weight: 600; }
/* регистрация по приглашению (app/common/invite.js) */
.invite-card { width: min(420px, 100%); }
.invite-who { border: 0; padding: 0; margin: 0; }
.invite-who legend { padding: 0; margin-bottom: 4px; }
.invite-roles { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.invite-join-object { font-weight: 600; margin: 0; }
/* экран заявителя (1.206): его заявки со статусом, правка на месте */
.reg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.reg-item { border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: var(--radius-sm, 10px);
            padding: 10px 12px; display: grid; gap: 4px; }
.reg-item.approved { border-left-color: var(--ok); }
.reg-item.rejected { border-left-color: var(--danger); }
.reg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reg-reply { margin: 2px 0 0; font-size: 14px; }
.reg-item-actions { gap: 12px; }
.reg-edit { margin-top: 6px; }
.reg-actions { justify-content: space-between; }
.invite-consent { align-items: start; }
.login-brand p { margin: 0; }

/* блок пользователя (боковая панель и меню на телефоне) */
.user-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-text { display: grid; min-width: 0; }
.user-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#username { color: var(--text); font-weight: 600; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: var(--accent); background: var(--accent-soft); }
.user button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-brand, .page-head { display: none; }

/* ================================================================== десктоп: меню слева */
@media (min-width: 761px) {
  :root { --sidebar-w: 248px; }
  .topbar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar-w);
    flex-direction: column; align-items: stretch; gap: 6px;
    padding: calc(18px + var(--safe-t)) 14px 14px calc(14px + var(--safe-l));
    background: var(--sidebar-bg); border: none; border-right: 1px solid var(--border); overflow-y: auto;
  }
  .brand, .icon-btn { display: none !important; }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; color: var(--text); text-decoration: none;
    font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
  .sidebar-brand img { width: 34px; height: 34px; border-radius: 10px; flex: none; }
  .tabs { flex-direction: column; flex-wrap: nowrap; gap: 2px; flex: 1 1 auto; }
  .tabs a { position: relative; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 550; }
  .tabs a svg { width: 20px; height: 20px; }
  .tabs a.active { background: var(--accent-soft); color: var(--accent); }
  .tabs a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
  @media (hover: hover) { .tabs a:not(.active):hover { background: var(--hover); color: var(--text); } }
  .tabs a .nav-badge { margin-left: auto; }
  /* модератор: своё как жильца — под чертой, после разделов администрации */
  .tabs a.nav-personal { margin-top: 13px; }
  .tabs a.nav-personal::after { content: ""; position: absolute; left: 8px; right: 8px; top: -7px; border-top: 1px solid var(--border); }
  .user-id { border-radius: var(--radius-sm); text-decoration: none; color: inherit; }
  @media (hover: hover) { .user-id:hover { background: var(--hover); } }
  .user { flex-direction: column; align-items: stretch; gap: 2px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); }
  .user-id { padding: 4px 8px 10px; }
  .user button.link { justify-content: flex-start; gap: 12px; padding: 9px 12px; color: var(--muted); border-radius: var(--radius-sm); font-weight: 500; }
  @media (hover: hover) { .user button.link:hover { background: var(--hover); color: var(--text); } }
  #btn-logout:hover { color: var(--danger); }
  main { margin-left: var(--sidebar-w); max-width: none; padding: 28px 32px 48px; }
  /* формы — 1320; видео и журналы (широкие таблицы) — на большом мониторе шире; заголовок — по ширине страницы */
  main { --page-w: 1320px; }
  main:has(> #page-live:not([hidden]), > #page-events:not([hidden]), > #page-summary:not([hidden]), > #page-intercoms:not([hidden])) { --page-w: 1900px; }
  main > .page, .page-head { max-width: var(--page-w); margin-left: auto; margin-right: auto; }
  .page-head { display: block; margin-bottom: 20px; }
  .page-head h1 { margin: 0; }
  .save-bar { bottom: 12px; }
}

/* планшет: узкая полоса значков с короткой подписью под каждым — на сенсорном экране подсказок при наведении нет,
   а одинаковые значки без подписи не различить. Ширина — под самую длинную подпись («Аналитика», «Настройки»)
   полужирным DejaVu Sans (системный шрифт Linux, ≈66 px): при 64 px она обрезалась (UI-тест nav в CI) */
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --sidebar-w: 92px; }
  .topbar { padding-left: 8px; padding-right: 8px; align-items: center; }
  .sidebar-brand { padding: 2px 0 14px; }
  .sidebar-brand span, .user-text, .user button.link span { display: none; }
  .tabs { width: 100%; }
  .tabs a, .user button.link { justify-content: center; padding: 11px 0; }
  .tabs a { flex-direction: column; gap: 3px; padding: 8px 0 7px; font-size: 10.5px; line-height: 1.15; }
  .tabs a > span:not(.nav-badge) { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs a .nav-badge { position: absolute; top: 2px; left: calc(50% + 5px); margin: 0; }
  .tabs a.active::before { left: -8px; }
  .user { width: 100%; }
  .user-id { justify-content: center; padding: 4px 0 10px; }
  main { padding: 22px 24px 40px; }
}

/* ================================================================== меню: группы сервисов (1.204, shell.buildNavGroups)
   Группа — заголовок сервиса и его страницы. Групп одна (один сервис) — контейнер прозрачен, заголовка нет: меню как до
   сервисов. Групп больше (класс grouped): на компьютере — заголовки над пунктами групп; на планшете и телефоне вместо
   пунктов группы — один пункт сервиса (заголовок), страницы сервиса — вкладками над страницей (#svc-tabs). */
.nav-group { display: contents; }
.tabs .nav-group-head { display: none; }
@media (min-width: 1101px) {
  .tabs.grouped .nav-group { display: flex; flex-direction: column; gap: 2px; }
  .tabs.grouped .nav-group:not(:first-child) { margin-top: 12px; }
  .tabs.grouped .nav-group + a[data-page] { margin-top: 12px; }               /* общие разделы — отдельно от групп */
  .tabs.grouped .nav-group-head { display: flex; padding: 4px 12px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); background: none; }
  .tabs.grouped .nav-group-head svg { display: none; }
  /* на компьютере подсвечен пункт страницы, заголовок — нет */
  .tabs.grouped .nav-group-head.active { background: none; color: var(--muted); }
  .tabs.grouped .nav-group-head.active::before { content: none; }
  .tabs.grouped .nav-group-head:hover { background: none; color: var(--text); }
  .svc-tabs { display: none !important; }
}
@media (max-width: 1100px) {
  .tabs.grouped .nav-group > a[data-page] { display: none; }
  .tabs.grouped .nav-group-head { display: inline-flex; }
  /* число на странице свёрнутой группы — точкой на пункте сервиса */
  .tabs .nav-group-head.has-badge::after { content: ""; position: absolute; top: 6px; left: calc(50% + 9px); width: 9px; height: 9px;
    border-radius: 50%; background: var(--danger); }
  .svc-tabs { margin: 0 0 12px; }
  /* четыре страницы парковки — в ширину телефона без прокрутки и широким шрифтом: Verdana (≈ DejaVu Sans в CI) при 15 px
     и прежних отступах — 385 px из 375 (1.204.0 упал в CI), при 14 px / 8 px / 4 px — 346 (с жирной активной ~352).
     Класс subtabs — общий вид вкладок, он ниже в файле */
  .svc-tabs.subtabs { gap: 4px; }
  .svc-tabs.subtabs a { font-size: 14px; padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 760px) {
  .tabs.grouped .nav-group-head.in-more { display: none; }                    /* ушёл в «Ещё» — как обычный пункт */
}

/* телефон: блок пользователя в выпадающем меню */
@media (max-width: 760px) {
  .user .user-id { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .user .user-id { text-decoration: none; color: inherit; }
  .user .user-id::after { content: "›"; margin-left: auto; padding-left: 8px; font-size: 22px; color: var(--muted); }   /* имя — вход в профиль */
  .user #username { padding: 0; border: none; margin: 0; font-size: 14px; }
  .user button.link { gap: 10px; }
  .topbar { box-shadow: var(--shadow-sm); border-bottom-color: transparent; }
  .tabs { box-shadow: 0 -1px 0 var(--border); border-top: none; }
}

/* жилец: кнопки своих створок */
body:not(.ui-v2) .my-gates { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
body:not(.ui-v2) .gate-open { min-height: 64px; font-size: 16px; gap: 10px; }
body:not(.ui-v2) .gate-open.sent { background: var(--ok); border-color: var(--ok); }

/* жилец: кнопки своих створок */
body.ui-v2 .my-gates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; }
#person-moderator-row .muted { font-weight: 400; }
.person-form label.chip { display: inline-flex; color: var(--text); }
#my-gates-msg:empty { display: none; }

/* показать пароль */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 46px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 0; width: 38px; height: 34px; padding: 0;
  border: none; background: none; color: var(--muted); border-radius: 8px; }
.pw-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .pw-eye:hover { color: var(--text); background: var(--hover) !important; } }

/* доступ в карточке */
.lock-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.person-form fieldset label.check .muted { font-weight: 400; }

/* фильтры белого списка */
.wl-types button { border-radius: 999px; padding: 4px 14px; min-height: 34px; }
.wl-types button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* жилец: состояние доступа на вкладке «Ворота» — тихие строки под кнопками, когда всё работает */
.my-status { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.my-status:not(:has(> :not([hidden]))) { display: none; }
.my-status-line { color: var(--ok); }
/* …и плашка над кнопками, когда что-то не так */
.my-notice { display: grid; gap: 2px; margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  border: 1px solid var(--accent); background: var(--accent-soft); }
.my-notice.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.my-notice.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.my-notice-reason { font-weight: 400; }
/* короткая строка вместо плашки; полный текст — по нажатию */
body.ui-v2 .my-notice.compact { padding: 6px 10px; font-size: 13px; }
body.ui-v2 .my-notice.compact summary { cursor: pointer; }
body.ui-v2 .my-notice.compact details > div { margin-top: 4px; font-weight: 400; }
#my-announce { white-space: pre-line; margin-bottom: 8px; }
.announce-form { margin-top: 4px; }
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 12px;
             line-height: 18px; text-align: center; background: var(--accent); color: #fff; }
.tab-count[hidden] { display: none; }
.announce-form textarea { width: 100%; resize: vertical; font: inherit; }

/* кнопки створок жильца: значок, подпись, пауза с полосой */
body:not(.ui-v2) .gate-open { position: relative; overflow: hidden; flex-direction: column; gap: 4px; min-height: 92px; padding: 12px; font-size: 18px; }
body:not(.ui-v2) .gate-emoji { font-size: 28px; line-height: 1; letter-spacing: 2px; }
body:not(.ui-v2) .gate-label { font-weight: 700; }
/* положение по датчику — плашкой под подписью */
body:not(.ui-v2) .gate-pos { font-size: 13px; font-weight: 600; line-height: 18px; padding: 0 8px; border-radius: 9px;
            background: rgb(0 0 0 / .18); }
body:not(.ui-v2) .gate-pos[hidden] { display: none; }

/* кнопки створок жильца: ворота — плитки, двери и скрытые — строки. Высота не зависит от состояния: кнопка не прыгает под пальцем */
body.ui-v2 .gate-open { position: relative; overflow: hidden; display: flex; justify-content: flex-start; text-align: left; font-size: 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); }
body.ui-v2 .gate-tile { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 108px; padding: 12px; }
body.ui-v2 .gate-row { flex-direction: row; align-items: center; gap: 12px; min-height: 58px; padding: 8px 12px; }
body.ui-v2 .gate-glyph { display: block; flex: none; width: 26px; height: 26px; }
body.ui-v2 .gate-glyph svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.ui-v2 .gate-text { display: grid; gap: 2px; min-width: 0; width: 100%; }
body.ui-v2 .gate-label { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* строка состояния: место есть всегда, положение уступает паузе и подсказке */
body.ui-v2 .gate-sub { display: block; height: 18px; font-size: 13px; line-height: 18px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ui-v2 .gate-pos[hidden], body.ui-v2 .gate-cd:empty, body.ui-v2 .gate-sub:has(.gate-cd:not(:empty)) .gate-pos { display: none; }
/* у строки пустой статус не занимает места: подпись по центру, высоту держит min-height */
body.ui-v2 .gate-row .gate-sub:not(:has(.gate-pos:not([hidden]), .gate-cd:not(:empty))) { display: none; }
body.ui-v2 .gate-pos::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--muted); vertical-align: 1px; }
body.ui-v2 .gate-pos.open::before { background: var(--ok); }
body.ui-v2 .gate-pos.moving::before, body.ui-v2 .gate-pos.between::before { background: var(--warn); }
body.ui-v2 .gate-pos.moving { animation: gate-pos-blink 1.2s ease-in-out infinite; }
@keyframes gate-pos-blink { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { body.ui-v2 .gate-pos.moving { animation: none; } }
.pass-share { width: 100%; margin-top: 4px; }
.gate-open.pointed { animation: gate-pointed 1s ease-in-out 3; }
@keyframes gate-pointed { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .gate-open.pointed { animation: none; outline: 3px solid var(--accent); } }
body:not(.ui-v2) .gate-pos.open::before { content: "● "; color: #7CFC9A; }
body:not(.ui-v2) .gate-pos.moving { animation: gate-pos-blink 1.2s ease-in-out infinite; }
body:not(.ui-v2) .gate-pos.between::before { content: "⏸ "; }
@media (prefers-reduced-motion: reduce) { body:not(.ui-v2) .gate-pos.moving { animation: none; } }
body:not(.ui-v2) .gate-cd { font-size: 13px; font-weight: 500; line-height: 18px; height: 18px; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; opacity: .95; }   /* место под «Держите… 1 с» есть всегда — кнопка не растёт */
body:not(.ui-v2) .gate-open.cooling:disabled { opacity: 1; cursor: progress; }
body:not(.ui-v2) .gate-open.cooling:not(.sent) { background: color-mix(in srgb, var(--accent) 55%, var(--muted)); border-color: transparent; }
body:not(.ui-v2) .gate-open.cooling::before {
  content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .28); transform-origin: left;
  transform: scaleX(var(--cd-left, 1)); transition: transform .25s linear; pointer-events: none;
}
body:not(.ui-v2) .gate-open.cooling::after {          /* тонкая полоса снизу — читается даже на ярком фоне */
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: rgba(255, 255, 255, .85);
  transform-origin: left; transform: scaleX(var(--cd-left, 1)); transition: transform .25s linear; pointer-events: none;
}
body:not(.ui-v2) .gate-open.sent { background: var(--ok); border-color: var(--ok); }
/* своя машина у ворот */
body.ui-v2 .gate-open.gate-open.car { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
body.ui-v2 .gate-open.car .gate-cd { color: var(--accent); font-weight: 600; }
/* пауза: заливка и полоса тают */
body.ui-v2 .gate-open.cooling:disabled { opacity: 1; cursor: progress; }
body.ui-v2 .gate-open.cooling:not(.sent) { background: var(--hover); }
body.ui-v2 .gate-open.cooling::before {
  content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--muted) 14%, transparent); transform-origin: left;
  transform: scaleX(var(--cd-left, 1)); transition: transform .25s linear; pointer-events: none;
}
body.ui-v2 .gate-open.cooling::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(var(--cd-left, 1)); transition: transform .25s linear; pointer-events: none;
}
body.ui-v2 .gate-open.sent { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: var(--ok); }
body.ui-v2 .gate-open.sent .gate-cd { color: var(--ok); font-weight: 600; }
body.ui-v2 .gate-open.sent::after { background: var(--ok); }
@media (prefers-reduced-motion: reduce) { .gate-open.cooling::before, .gate-open.cooling::after { transition: none; } }

/* списки машиномест и машин в карточке собственника */
.list-rows { display: grid; gap: 8px; }
.list-row { display: flex; align-items: center; gap: 8px; }
.list-row input { flex: 1 1 auto; min-width: 0; }
.list-row select { flex: 0 0 120px; }
#person-spaces .list-row input { flex: 0 0 110px; }
/* место человека: номер, этаж, роль (1.203), ✕ — одной строкой, на телефоне роль с ✕ переносятся на вторую */
#person-spaces .list-row { flex-wrap: wrap; }
#person-spaces .list-row .space-role { flex: 1 1 140px; }
.list-row .link.danger { min-width: 36px; }


/* кнопки створок: отправка (крутилка + бегущая полоса), пауза у всех кнопок, заметная ошибка */
.gate-open.sending:disabled { opacity: 1; cursor: progress; }
body:not(.ui-v2) .gate-open .gate-spinner { display: none; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: gate-spin .8s linear infinite; }
body.ui-v2 .gate-open .gate-spinner { display: none; flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: gate-spin .8s linear infinite; }
.gate-open.sending .gate-spinner { display: block; }
body:not(.ui-v2) .gate-open.sending .gate-emoji { display: none; }
body:not(.ui-v2) .gate-open.sending::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 40%; background: rgba(255, 255, 255, .9);
  animation: gate-run 1.1s ease-in-out infinite; pointer-events: none;
}
body.ui-v2 .gate-open.sending .gate-glyph { display: none; }
body.ui-v2 .gate-open.sending::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 40%; background: var(--accent);
  animation: gate-run 1.1s ease-in-out infinite; pointer-events: none;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }
@keyframes gate-run { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.gate-open:disabled:not(.sending):not(.cooling) { opacity: .55; }
.gate-open.shake { animation: gate-shake .45s ease-in-out; }
@keyframes gate-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.gate-alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border: 1.5px solid var(--danger); color: var(--text); }
.gate-alert.pop { animation: gate-pop .25s ease-out; }
@keyframes gate-pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.gate-alert-icon { font-size: 26px; line-height: 1; }
.gate-alert b { display: block; font-size: 17px; color: var(--danger); margin-bottom: 2px; }
.gate-alert p { margin: 0; font-size: 14px; }
.gate-alert > div { flex: 1 1 auto; }
.gate-alert .link { min-height: 0; padding: 2px 6px; color: var(--muted); }
/* сообщение скрывается само: полоса внизу тает за --alert-ms, пока палец на сообщении — стоит */
.gate-alert { position: relative; overflow: hidden; }
.gate-alert-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--danger); opacity: .55;
  transform-origin: left; animation: gate-alert-time var(--alert-ms, 6s) linear forwards; pointer-events: none; }
.gate-alert.paused .gate-alert-bar { animation-play-state: paused; }
@keyframes gate-alert-time { from { transform: scaleX(1); } to { transform: scaleX(0); } }
/* уход: тает и сворачивается по высоте (с зазором сетки) — кнопки под ним подъезжают плавно, без скачка */
.gate-alert.leaving { animation: gate-leave .35s ease-in forwards; pointer-events: none; }
@keyframes gate-leave {
  0% { opacity: 1; max-height: var(--alert-h); transform: none; }
  40% { opacity: 0; transform: translateY(-6px) scale(.98); }
  100% { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; margin-bottom: -12px;
         transform: translateY(-6px) scale(.98); }
}
@media (prefers-reduced-motion: reduce) {
  .gate-open .gate-spinner, .gate-open.sending::after, .gate-open.shake, .gate-alert.pop { animation: none; }
  .gate-alert-bar { animation: none; display: none; }
}

/* двери жильца — карусель, по кнопке на слайд (держать кнопку — как у ворот; листать — свайпом) */
body:not(.ui-v2) .my-gates:empty { display: none; }
body:not(.ui-v2) .my-doors .sc-track { margin: 0 -6px; border-radius: 0; }
body:not(.ui-v2) .my-doors .sc-slide { display: block; padding: 2px 6px 6px; background: none; }
body:not(.ui-v2) .my-doors .sc-view:has(.sc-arrow) .sc-slide { padding-left: 6px; }
body:not(.ui-v2) .my-doors .gate-open { width: 100%; }
body:not(.ui-v2) .my-doors .sc-arrow.prev { left: -6px; } body:not(.ui-v2) .my-doors .sc-arrow.next { right: -6px; }

/* удержание кнопки створки 3 с: полоса заполняется слева направо */
body:not(.ui-v2) .gate-open { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
body:not(.ui-v2) .gate-open.holding::before {
  content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .32); transform-origin: left;
  transform: scaleX(var(--hold, 0)); pointer-events: none;
}
body:not(.ui-v2) .gate-open.holding { box-shadow: 0 0 0 3px var(--accent-soft); }

/* двери и скрытые кнопки жильца — строками; на широком экране в несколько колонок */
body.ui-v2 .my-gates:empty { display: none; }
body.ui-v2 .my-doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 8px; }
body.ui-v2 .my-doors[hidden] { display: none; }
body.ui-v2 .my-gates-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
body.ui-v2 .my-gates-foot [hidden] { display: none; }
body.ui-v2 .my-gates-foot:not(:has(> :not([hidden]))) { display: none; }
body.ui-v2 .my-gates-foot #my-arrange { margin-left: auto; font-size: 13px; color: var(--muted); }
/* удержание: кнопка заполняется цветом слева направо */
body.ui-v2 .gate-open { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
body.ui-v2 .gate-open.holding { border-color: var(--accent); }
body.ui-v2 .gate-open.holding::before {
  content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 34%, transparent); transform-origin: left;
  transform: scaleX(var(--hold, 0)); transition: transform .05s linear; pointer-events: none;
}
.hold-hint { margin: -4px 0 0; }
body:not(.ui-v2) .gate-open.holding::before { transition: transform .05s linear; }

/* камеры: выбор на «Онлайн» и «Зона», список камер */
.cam-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cam-chips button { border-radius: 999px; padding: 6px 16px; }
.cam-chips button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.chip-n:empty { display: none; }
.active > .chip-n { color: inherit; }
/* две пары переключателей: пара не разрывается, между парами — линия (на узком экране пары — строками) */
.sp-chips { column-gap: 0; }
.chip-pair { display: inline-flex; gap: 6px; padding-right: 10px; margin-right: 10px; border-right: 1px solid var(--border); }
.chip-pair:last-child { padding-right: 0; margin-right: 0; border-right: 0; }
.sp-chips button { white-space: nowrap; }
@media (max-width: 560px) {
  .chip-pair { padding-right: 0; margin-right: 0; border-right: 0; }
  .sp-chips button { padding: 6px 11px; }
}
/* боковая колонка «Онлайн» фиксированной ширины: карточкам внутри — её ширина, а не минимальная ширина стека (340 px) */
.live-side { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.live-side .stack { min-width: 0; }
.cams-form { max-width: 720px; }
.cam-row input:nth-child(1) { flex: 0 0 120px; }
.cam-row input:nth-child(3) { flex: 1 1 200px; }
/* выбор камеры не шире экрана: иначе <select> по длинному названию камеры раздвигал всю страницу «Зоны» */
.zone-camera label { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.zone-camera select { flex: 1 1 auto; min-width: 0; }
@media (min-width: 761px) { .zone-camera label, .zone-camera select { flex-grow: 0; } }
@media (max-width: 760px) { .cam-row { flex-wrap: wrap; } .cam-row input { flex: 1 1 100% !important; } }

/* потянуть вниз — обновить (PWA): страницу вместе с шапкой тянет «пружина» iOS, кружок — над шапкой (в открывшейся
   полосе); пока идёт загрузка, вся страница опущена на --ptr (отступ у body, а не transform: иначе нижняя панель
   вкладок внутри шапки перестала бы быть fixed), кружок крутится над шапкой */
:root { --ptr: 0px; --ptr-o: 0; }
body { transition: padding-top .25s ease; }
.ptr-loading body { padding-top: var(--ptr); }
.ptr { position: fixed; left: 50%; top: var(--safe-t); z-index: 30; pointer-events: none;   /* над шапкой (z 20) */
  opacity: var(--ptr-o);
  transform: translate(-50%, calc(var(--ptr) / 2 - 16px)); transition: transform .25s ease, opacity .25s ease; }
.ptr-pulling .ptr { transition: none; }
.ptr-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; font-weight: 700;
  background: var(--surface); color: var(--accent); box-shadow: var(--shadow); transition: transform .1s linear, background .15s; }
.ptr.ready .ptr-icon { background: var(--accent); color: var(--accent-text); }
.ptr-loading .ptr-icon { font-size: 0; transform: none !important; }
.ptr-loading .ptr-icon::before { content: ""; width: 18px; height: 18px; border-radius: 50%; box-sizing: border-box;
  border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: gate-spin .8s linear infinite; }
@media (prefers-reduced-motion: reduce) { body, .ptr { transition: none; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } dialog.sheet.sheet-back { transition: none; } }
@media (min-width: 761px) { .ptr { display: none; } }

/* номер с флагом: под регионом «RUS» и триколор — как на настоящем номере */
.plate-text.flagged { display: inline-flex; align-items: stretch; padding-top: 1px; padding-bottom: 1px; }
.plate-text.flagged > :first-child, .plate-text.flagged { line-height: 1.25; }
.plate-text .region-flag { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  line-height: 1; }
.region-num { font-size: 15px; }
.region-rus { display: inline-flex; align-items: center; gap: 2px; font-size: 7px; font-weight: 700; letter-spacing: .3px; }
.rus-flag { display: inline-block; width: 10px; height: 7px; border: .5px solid #555;
  background: linear-gradient(to bottom, #fff 0 33.3%, #0039a6 33.3% 66.6%, #d52b1e 66.6% 100%); }
.plate-text.flagged { align-items: center; }
.plate-text.flagged .region-flag { align-self: stretch; }

.dot.warn { background: var(--warn); }
.badge.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.gate-open.off:disabled { opacity: 1; background: var(--hover); border-color: var(--border); color: var(--muted); cursor: not-allowed; }
body:not(.ui-v2) .gate-open.off .gate-emoji { filter: grayscale(1); opacity: .6; }
body.ui-v2 .gate-open.off .gate-glyph { filter: grayscale(1); opacity: .6; }
.gate-open.off .gate-cd { color: var(--danger); font-weight: 600; }

/* «Ещё» на телефоне: разделы, которым не хватило места в нижней панели (app/common/shell.js openMore) */
.nav-more-list { display: grid; margin: 0 0 12px; }
.nav-more-list a { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 10px 4px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--border); font-size: 16px; }
.nav-more-list a > span:not(.nav-badge) { flex: 1 1 auto; }
.nav-more-list a svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; color: var(--muted); }
.nav-more-list a::after { content: "›"; color: var(--muted); font-size: 22px; line-height: 1; }
.nav-more-list a.active, .nav-more-list a.active svg { color: var(--accent); }
.nav-more-list a.active { font-weight: 600; }
.nav-more-sheet { min-width: min(360px, 100vw); }

/* ================================================================== настройки и вкладки разделов */
.link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 4px 6px; color: var(--accent);
  text-decoration: none; font-weight: 500; }
.subtabs { margin-bottom: 16px; }
.subtabs a { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); text-decoration: none;
  background: var(--surface); min-height: var(--tap); display: inline-flex; align-items: center; }
.subtabs a.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
#page-people [data-ptab="fobs"] { display: grid; gap: 16px; }

.settings { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { display: grid; gap: 18px; position: sticky; top: 20px; }
.sn-group { display: grid; gap: 2px; }
.sn-group h3 { margin: 0 0 4px 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.settings-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.settings-nav a svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; color: var(--muted); }
.sn-text { display: grid; min-width: 0; }
.sn-text b { font-weight: 600; }
.sn-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-nav a.active { background: var(--accent-soft); }
.settings-nav a.active svg, .settings-nav a.active b { color: var(--accent); }
@media (hover: hover) { .settings-nav a:not(.active):hover { background: var(--hover); } }
/* одна колонка = ширина раздела (как у .stack): неявная колонка auto не ужимается уже самого широкого содержимого —
   <select> камеры с длинным названием раздвигал «Зоны» за край телефона */
.settings-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.sub { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; align-content: start; }
.sub > .muted.small:first-child { margin: 0; }
.settings-back { display: none; justify-self: start; text-decoration: none; font-weight: 600; min-height: var(--tap); align-items: center; }
.settings-back.always { display: inline-flex; }

.cam-cards, .gate-cfg-list, .profile-list { display: grid; gap: 12px; }
.cam-card .row3 label, .cam-card .tune-grid label { display: grid; gap: 4px; align-content: start; }
.cam-card input:not([type=checkbox]) { width: 100%; }
.cam-state { margin: -4px 0 0; }
.cam-state .dot { margin-right: 6px; }
.tuning summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: var(--tap); }
.tune-grid, .sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 14px 16px; margin-top: 8px; }
.sys-field { display: grid; gap: 4px; align-content: start; }
.sys-field input { width: 100%; }
.sys-field textarea { width: 100%; resize: vertical; font: inherit; }
.sys-field.sys-wide { grid-column: 1 / -1; }
.gate-cfg { display: grid; gap: 8px; color: var(--text); text-decoration: none; }
.gate-cfg h2 { margin: 0; }
.gate-cfg .chev { font-size: 22px; color: var(--muted); }
@media (hover: hover) { .gate-cfg:hover { border-color: var(--accent); } }
.profile-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.profile-item h2 { margin: 0 0 2px; }
.profile-item p { margin: 0; }
#devices-card h2 { margin: 0 0 2px; }
#devices-card p { margin: 0; }
.devices { list-style: none; margin: 0; padding: 0; display: grid; }
.devices li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.devices li:first-child { border-top: 0; }
.devices .dev-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.devices .dev-name { font-weight: 600; }
.devices .dev-here { color: var(--ok); font-weight: 600; }
.devices .dev-meta { overflow-wrap: anywhere; }
.devices button { flex: none; }
#devices-drop-others { justify-self: start; }
.about-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 17px; }
.about-card p { margin: 0; }

#sub-gate .gate-form { max-width: 720px; }
#sub-gate .gate-form > .card { gap: 12px; }

/* планшет: подменю уже */
@media (min-width: 761px) and (max-width: 1100px) {
  .settings { grid-template-columns: 230px minmax(0, 1fr); gap: 20px; }
  .sn-text .small { display: none; }
}
/* телефон: список разделов или один раздел целиком */
@media (max-width: 760px) {
  .settings { grid-template-columns: 1fr; gap: 12px; }
  .settings-nav { position: static; gap: 16px; }
  .settings.has-sub .settings-nav { display: none; }
  .settings:not(.has-sub) .settings-body { display: none; }
  .settings-back { display: inline-flex; }
  .settings.single .settings-back:not(.always) { display: none; }
  .sn-group { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .sn-group h3 { margin: 12px 14px 6px; }
  .settings-nav a { border-radius: 0; padding: 12px 14px; border-top: 1px solid var(--border); min-height: 56px; }
  .settings-nav a::after { content: "›"; margin-left: auto; font-size: 22px; color: var(--muted); }
  .settings-nav a.active { background: none; }
  /* вкладки раздела — во всю ширину (их 2–3 — помещаются); не поместились — прокрутка вбок, без переноса */
  .subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)) 12px; padding: 0 var(--gutter); }
  .subtabs a { white-space: nowrap; flex: 1 0 auto; justify-content: center; }
  /* «Онлайн»: «Сохранить видео» и ⚙ — одной строкой под камерами */
  .cam-actions { width: 100%; }
  .cam-actions .save-video { flex: 1 1 auto; }
  .cam-actions .link-btn { min-width: var(--tap); justify-content: center; font-size: 20px; }
  .cam-actions .link-btn-text { display: none; }
  .cam-card .row3, .ic-card .row3 { grid-template-columns: 1fr; }
  .profile-item button { flex: 1 1 100%; }
}

/* место вместе со своим этажом */
.space-chip { display: inline-flex; align-items: baseline; gap: 2px; padding: 3px 10px; border-radius: 999px; font-size: 14px;
  background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.space-chip b { font-weight: 700; }
button.space-chip { border: none; min-height: 0; cursor: pointer; font: inherit; font-size: 14px; }
.space-chip.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.person-head { display: grid; gap: 6px; min-width: 0; }
/* карточка человека в «Людях» (1.203.2): имя и контакты, разделы мест и помещений (строка на объект — его машины и
   кто ещё на нём), внизу — вход и права */
.person-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.person-top > button { flex: none; white-space: nowrap; }
button.person-name { border: none; background: none; padding: 0; min-height: 0; font: inherit; color: inherit; text-align: left;
  cursor: pointer; }
@media (hover: hover) { button.person-name:hover { color: var(--accent); text-decoration: underline; } }
/* имя человека в реестрах мест и помещений и в окне объекта — ссылкой: по нажатию — его карточка */
.sp-people button.person-name, .obj-person button.person-name { color: var(--accent); }
.person-contacts { gap: 2px 14px; }
.person-objs { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.person-objs > h3 { margin: 0; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.person-obj { display: grid; gap: 4px; }
.person-obj-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.person-obj-cars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.person-badges { padding-top: 10px; border-top: 1px solid var(--border); }
.ps-houses { margin: 0 0 10px; }
.ps-houses[hidden] { display: none; }
.person > .row.between { align-items: flex-start; }
.person > .row.between > button { flex: none; white-space: nowrap; }       /* «✎ Изменить» — одной строкой при любом числе мест */

/* машиноместо жильца на «Воротах» — строкой, полная карточка (карусель мест) — в окне */
.my-spaces { margin-top: 8px; }
.my-spaces:empty { display: none; }
.my-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 16px;
  text-align: left; font-weight: 400; border-radius: var(--radius); background: var(--surface); }
.my-summary-text { display: grid; gap: 2px; min-width: 0; }
.my-summary-text b { font-size: 17px; }
.my-summary-text span { overflow-wrap: anywhere; }
.my-summary-more { font-size: 26px; line-height: 1; color: var(--muted); }
.my-card-dialog { width: 520px; }
.my-card-dialog .my-spaces-card { padding: 0; border: none; box-shadow: none; background: none; }
.my-spaces-card { display: grid; gap: 12px; }
.my-spaces-card > h2 { margin: 0; }
.my-owners { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.my-owners p { margin: 0; }
@media (min-width: 761px) { .my-spaces { max-width: 560px; } }       /* на широком экране карточка — размером с карту, не во всю ширину */
.my-spaces-card .sc-track { margin: 0 -6px; border-radius: 0; }          /* зазор между карточками — поля слайда */
.my-spaces-card .sc-slide { display: block; padding: 2px 6px 6px; background: none; }
.my-spaces-card .sc-view:has(.sc-arrow) .sc-slide { padding-left: 6px; }
.space-card { display: grid; gap: 12px; height: 100%; padding: 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.space-card p { margin: 0; }
.space-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.space-card-num { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.space-card-plates { display: flex; flex-wrap: wrap; gap: 10px; }
.space-card-plates .plate-text { font-size: 22px; }
.my-spaces-card .sc-arrow { top: 50%; }
.my-spaces-card .sc-arrow.prev { left: -6px; } .my-spaces-card .sc-arrow.next { right: -6px; }
/* min-width: 0 и колонка minmax(0, 1fr): иначе сетка карточки растягивается на ширину всех слайдов сразу */
.person { grid-template-columns: minmax(0, 1fr); }
.sc { display: grid; gap: 6px; min-width: 0; }
.sc-view { min-width: 0; }
.sc-view { position: relative; }
.sc-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
  touch-action: pan-x pan-y; border-radius: var(--radius-sm); outline-offset: 2px; }
.sc-track::-webkit-scrollbar { display: none; }
.sc-slide { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; align-items: baseline; gap: 10px;
  padding: 12px 16px; background: var(--accent-soft); }
.sc-num { font-size: 26px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.sc-floor { color: var(--muted); font-weight: 600; white-space: nowrap; }
/* полоса под каруселью: полупрозрачная во всю ширину, бегунок — одна карточка; части полосы — цели для пальца */
.sc-bar { position: relative; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); height: 4px; margin: 6px 0 4px;
  border-radius: 2px; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.sc-thumb { position: absolute; inset: 0 auto 0 0; width: calc(100% / var(--n)); border-radius: 2px; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 85%, transparent); will-change: transform; }
.sc-thumb.jump { transition: transform .3s ease; }
@media (prefers-reduced-motion: reduce) { .sc-thumb.jump { transition: none; } }
.sc-seg { position: relative; z-index: 1; height: 24px; min-height: 0; margin-top: -10px; padding: 0; border: none; border-radius: 0;
  background: none; cursor: pointer; }
.sc-seg:focus-visible { outline: 2px solid var(--accent); outline-offset: -6px; border-radius: 6px; }
.sc-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 32px; height: 32px; min-height: 0; padding: 0;
  border-radius: 50%; font-size: 20px; line-height: 1; background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.15); display: none; }
.sc-arrow.prev { left: 6px; } .sc-arrow.next { right: 6px; }
.sc-arrow:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .sc-arrow { display: inline-flex; } .sc-view:has(.sc-arrow) .sc-slide { padding-left: 46px; } }
@media (pointer: coarse) { .sc-seg { height: 32px; margin-top: -14px; } }     /* под палец — цель выше самой полосы */

/* форма собственника: машиноместо и его машины одним блоком */
.space-blocks { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.space-block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.space-plates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 8px; }
.space-plates .plate-field { display: flex; width: 100%; }
.space-plates input::placeholder { text-transform: none; }

/* ------------------------------------------------------------------ журнал: номер как в кадре / выровненный */
.pimg { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pimg-views { display: flex; gap: 2px; }
.pimg-views button { min-height: 0; padding: 1px 6px; font-size: 11px; line-height: 16px; border-radius: 4px; color: var(--muted); }
.pimg-views button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.viewer-views { justify-content: center; margin-bottom: 8px; }
.viewer-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.viewer-nav[hidden] { display: none; }
.viewer-nav button { min-width: 56px; min-height: 40px; font-size: 22px; line-height: 1; }
.viewer-nav span { text-align: center; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) {                              /* на телефоне — свайп, стрелки не нужны */
  .viewer-nav button { display: none; }
  .viewer-nav { justify-content: center; }
}
.viewer-views button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.info-box { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* ------------------------------------------------------------------ «Онлайн → Тепловая карта» */
.heat-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.heat-hours { display: flex; align-items: center; gap: 6px; }
.heat-hours select { width: auto; min-width: 84px; }
.heat-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .heat-main { grid-template-columns: minmax(0, 1fr); } }
.heat-map { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; }
.heat-map img, .heat-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.heat-map img { object-fit: fill; }
.heat-map img.dim { opacity: .55; }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.heat-scale { width: 160px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, rgb(0 0 255), rgb(0 200 255), rgb(0 220 0), rgb(255 220 0), rgb(255 0 0)); }
.heat-side { min-width: 0; grid-template-columns: minmax(0, 1fr); padding: 16px; }
@media (min-width: 901px) { .heat-side { max-height: calc(100dvh - 200px); overflow-y: auto; } }
.heat-list { display: grid; gap: 6px; }
.heat-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left;
  padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.heat-item.active { border-color: var(--accent); background: var(--accent-soft); }
.heat-item img, .heat-item .heat-noimg { width: 96px; height: 72px; object-fit: cover; border-radius: 4px; background: var(--bg); display: block; }
.heat-item .heat-noimg { display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.heat-item b { display: block; overflow-wrap: anywhere; }
.heat-item .muted { font-size: 12px; }

/* линии ворот под тепловой картой */
.heat-map.drawing { cursor: crosshair; }
.heat-lines { padding: 16px; margin-top: 4px; }
.heat-lines h2 { margin: 0; }
.line-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.line-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.line-list input { flex: 1 1 140px; min-width: 0; }
.line-swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.heat-item .badge { display: inline-block; margin: 4px 0 0 6px; }
.badge.cross-in { color: var(--ok); border-color: var(--ok); }
.badge.cross-out { color: var(--warn); border-color: var(--warn); }

/* «Онлайн → Поток»: дни недели × часы. Шкала — один синий тон ступенями: мало — светлее (на тёмной теме — темнее,
   ближе к фону), больше всего — контрастнее всего; текст в клетке — тёмный или белый по ступени */
:root {
  --flow-1: #e3eefc; --flow-2: #cde2fb; --flow-3: #9ec5f4; --flow-4: #6da7ec; --flow-5: #3987e5; --flow-6: #256abf; --flow-7: #184f95;
  --flow-ink-light: #0f172a; --flow-ink-dark: #fff; --flow-peak: #e8590c; --flow-none: repeating-linear-gradient(135deg,
    transparent 0 4px, color-mix(in srgb, var(--muted) 22%, transparent) 4px 5px);
}
@media (prefers-color-scheme: dark) {
  :root { --flow-1: #172a46; --flow-2: #104281; --flow-3: #184f95; --flow-4: #256abf; --flow-5: #3987e5; --flow-6: #6da7ec;
    --flow-7: #9ec5f4; --flow-ink-light: #fff; --flow-ink-dark: #0f172a; --flow-peak: #ff8a3d; }
}
.flow-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 28px; margin-bottom: 12px; }
.ff { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.ff select { width: auto; min-width: 12em; color: var(--text); }
.ff .chips { font-size: 14px; }
@media (max-width: 560px) { .flow-filters { gap: 12px; } .ff, .ff select { width: 100%; } }
.flow-card { padding: 12px; }
.flow-wrap { overflow-x: auto; max-width: 100%; }
.flow-grid { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.flow-grid th { font-weight: 600; color: var(--muted); padding: 2px 4px; text-align: center; white-space: nowrap; border-radius: 4px; }
.flow-grid th[scope=row] { text-align: right; padding-right: 8px; }
.flow-grid th.hl { background: var(--accent-soft); color: var(--accent); }
.flow-grid td { height: 30px; min-width: 28px; text-align: center; border-radius: 4px; color: var(--flow-ink-light);
  background: color-mix(in srgb, var(--border) 45%, transparent); }
.flow-grid td.zero { background: color-mix(in srgb, var(--border) 45%, transparent); }
.flow-grid td.nodata { background: var(--flow-none); }
.flow-grid td.s1 { background: var(--flow-1); } .flow-grid td.s2 { background: var(--flow-2); }
.flow-grid td.s3 { background: var(--flow-3); } .flow-grid td.s4 { background: var(--flow-4); }
.flow-grid td.s5 { background: var(--flow-5); color: #fff; font-weight: 600; }        /* средняя ступень — белый в обеих темах */
.flow-grid td.s6 { background: var(--flow-6); color: var(--flow-ink-dark); font-weight: 600; }
.flow-grid td.s7 { background: var(--flow-7); color: var(--flow-ink-dark); font-weight: 700; }
.flow-grid td.peak { box-shadow: inset 0 0 0 2px var(--flow-peak); }
.flow-grid td[data-d]:hover { outline: 2px solid var(--text); outline-offset: -2px; }
.flow-grid .g6 { border-left: 6px solid transparent; background-clip: padding-box; }    /* часы — группами по 6 */
.flow-grid tr.wk > * { border-top: 8px solid transparent; background-clip: padding-box; }     /* выходные — отдельно */
.flow-grid td.wk, .flow-grid th.wk { border-left: 8px solid transparent; background-clip: padding-box; }
.flow-grid td.sum, .flow-grid tr.sum td, .flow-grid th.sum-h { font-weight: 600; color: var(--text); background: transparent; }
.flow-grid tr.avg-row > * { border-top: 8px solid transparent; color: var(--muted); font-weight: 500; }
.flow-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 10px; font-size: 12px; }
.flow-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.flow-scale i { width: 18px; height: 12px; border-radius: 3px; margin: 0 -4px; }
.flow-scale i { display: inline-block; } .flow-scale .s1 { background: var(--flow-1); } .flow-scale .s2 { background: var(--flow-2); }
.flow-scale .s3 { background: var(--flow-3); } .flow-scale .s4 { background: var(--flow-4); } .flow-scale .s5 { background: var(--flow-5); }
.flow-scale .s6 { background: var(--flow-6); } .flow-scale .s7 { background: var(--flow-7); }
.flow-scale > .muted:first-child { margin-right: 6px; } .flow-scale > .muted:last-child { margin-left: 6px; }
.peak-key, .nodata-key { display: inline-block; width: 18px; height: 12px; border-radius: 3px; }
.peak-key { box-shadow: inset 0 0 0 2px var(--flow-peak); }
.nodata-key { background: var(--flow-none); box-shadow: inset 0 0 0 1px var(--border); }
.gc-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.gc-table th, .gc-table td { padding: 4px 8px; text-align: right; border-bottom: 1px solid var(--border, #8884); white-space: nowrap; }
.gc-table th:first-child, .gc-table td:first-child { text-align: left; }
.flow-peaks { display: grid; gap: 10px; padding: 12px 14px; margin-bottom: 12px; }
.flow-peaks h2 { margin: 0; font-size: 17px; }
#flow-thr-note { margin: 0; color: var(--muted); }
.flow-wins { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.flow-wins li { padding: 4px 0 4px 10px; border-left: 3px solid var(--flow-peak); }
.flow-win-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.flow-apply { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.flow-apply label { display: grid; gap: 4px; color: var(--muted); }
.flow-apply select { min-width: 12em; }
.flow-apply p { flex-basis: 100%; margin: 0; }

/* функции камеры деревом: потомок работает, только когда включены предки */
.ftree, .ftree ul { list-style: none; margin: 0; padding: 0; }
.ftree ul { margin-left: 9px; padding-left: 18px; border-left: 2px solid var(--border); }
.ftree li { position: relative; }
.ftree ul > li::before { content: ""; position: absolute; left: -18px; top: 17px; width: 14px; border-top: 2px solid var(--border); }
.ftree ul > li:last-child::after { content: ""; position: absolute; left: -20px; top: 19px; bottom: 0; width: 2px;
  background: var(--surface); }                  /* линия ветки обрывается на последнем потомке */
.ftree label.check { padding-block: 6px; }
.ftree label.check > span { display: grid; gap: 2px; }
.ftree-hint { font-weight: 400; }
.ftree-off { color: var(--warn); font-weight: 600; }
.ftree li.ftree-blocked > label > input, .ftree li.ftree-blocked > label > span > :not(.ftree-off) { opacity: .5; }
.ftree li:has(> label > input:checked:not(:disabled):hover) > ul {
  background: color-mix(in srgb, var(--warn) 12%, transparent); border-left-color: var(--warn); border-radius: 0 6px 6px 0; }
.ftree-flat > ul { margin-left: 0; padding-left: 0; border-left: 0; }
.ftree-flat > ul > li::before, .ftree-flat > ul > li::after { display: none; }
.zone-points { white-space: nowrap; }

/* Поток: сейчас на парковке */
.occ { display: grid; gap: 8px; padding: 14px 16px; margin-bottom: 12px; max-width: 640px; }
.occ p { margin: 0; }
.occ-main { display: flex; align-items: center; gap: 14px; }
.occ-n { font-size: 40px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent); min-width: 1.2em; }
.occ-warn { color: var(--warn); }
.occ-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.occ-form input { width: 6em; margin-left: 6px; }
.occ > .link { justify-self: start; }

/* Жильцы → неизвестные машины, которые часто бывают */
.unk-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.unk-list { display: grid; gap: 10px; }
.unk { display: grid; grid-template-columns: 132px 1fr; gap: 6px 14px; align-items: start; padding: 12px 14px; }
.unk-body { display: grid; gap: 6px; min-width: 0; }
.unk-photo { width: 132px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--border); cursor: zoom-in; }
.unk-photo.none { cursor: default; }
.unk-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.unk p { margin: 0; }
.unk-similar { color: var(--warn); margin: 4px 0; }
.unk-similar p { margin: 0 0 6px; }
.unk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.unk-actions input { width: 7em; }
.unk.done { opacity: .6; }
.gl-cycle { font-size: .8em; margin-top: 2px; color: var(--muted); }
.gl-cycle.noplate { color: var(--warn); font-weight: 600; }
.unk.inside { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.unk-inside { justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: .85em; font-weight: 600;
              color: var(--warn); border: 1px solid var(--warn); }
.unk-inside::before { content: "● "; }
@media (max-width: 560px) {
  .unk { grid-template-columns: 96px 1fr; padding: 10px; }
  .unk-photo { width: 96px; }
}
.ok-text { color: var(--ok); font-weight: 600; }
.refused-text { color: var(--warn); }             /* отказ по защите в журнале ворот — не сбой, без красного */

/* Жильцы → машина по фото */
.photo-pick { position: relative; display: grid; place-items: center; gap: 8px; min-height: 120px; padding: 12px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 10px; text-align: center; font-weight: 600; color: var(--accent); }
.photo-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.photo-pick img { max-width: 100%; max-height: 220px; border-radius: 6px; object-fit: contain; }
.photo-read { display: grid; gap: 8px; justify-items: start; }
.photo-zone { max-width: min(100%, 320px); border-radius: 4px; border: 1px solid var(--border); background: #fff; }
.photo-done { display: grid; gap: 6px; padding: 12px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.photo-done p { margin: 0; }
.warn-text { color: var(--warn); }

/* «Главная» администрации (1.205): поиск сверху, ниже — что требует внимания карточками (сбой — красная полоса слева,
   ждёт решения — жёлтая), под ними — что проверено и в порядке */
#page-overview > .clear-wrap { margin-bottom: 16px; }
#page-overview .ov-search { font-size: 16px; }             /* 16 px — iPhone не увеличивает страницу при вводе */
.ov-title { font-size: 17px; margin: 0 0 10px; }
.ov-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.ov-grid:empty { display: none; }
.ov-item { padding: 14px 16px; border-left: 4px solid var(--border); display: grid; gap: 8px; min-width: 0; }
.ov-item.bad { border-left-color: var(--danger); }
.ov-item.warn { border-left-color: var(--warn); }
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ov-head h3 { margin: 0; font-size: 15px; }
.ov-lines { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; overflow-wrap: anywhere; }
.ov-link { justify-self: start; font-weight: 600; }
.ov-calm { color: var(--ok); font-weight: 600; margin: 0; }
.ov-oks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.ov-journal { margin: 0; font-weight: 600; }

/* Жильцы: меню как в «Настройках», поиск над ним, в разделе — строка поиска, «Фильтры» и «+» */
#page-people .settings-body { position: relative; }
#people-nav > .clear-wrap { margin-bottom: 2px; }
#page-people.searching [data-ptab], #page-people.searching .settings-back { display: none; }
.ps-results { display: grid; gap: 10px; min-width: 0; }
.ps-results > p:empty { display: none; }
.ps-title { margin: 6px 0 0; font-size: 15px; }
.ps-tools { flex-wrap: nowrap; }
.ps-tools > .clear-wrap { flex: 1 1 180px; }
.ps-tools button { flex: none; white-space: nowrap; }
.evf-open.ps-open { display: inline-flex; }                   /* у журнала на компьютере кнопки нет — там фильтры колонкой */
.ps-tools-end { justify-content: flex-end; }
.ps-help { margin-bottom: 12px; }
.ps-help summary { cursor: pointer; list-style: none; }
.ps-help summary::-webkit-details-marker { display: none; }
.ps-help p { margin: 8px 0 0; }
.ps-i { color: var(--accent); white-space: nowrap; }
.ps-filters .sp-chips { flex-wrap: wrap; row-gap: 8px; }
.ps-filters .link { justify-self: start; }
@media (min-width: 761px) {
  .ps-filters { width: min(460px, 95vw); padding: 16px; }
  .ps-filters form[method=dialog] button { width: 100%; }
  /* поиск над меню рядом — второй такой же у «Собственников» не нужен */
  [data-ptab="owners"] .ps-tools { justify-content: flex-end; }
  [data-ptab="owners"] .ps-tools > .clear-wrap { display: none; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  #people-nav .sn-text .small { display: block; }             /* на планшете строка состояния нужна: в этом её смысл */
}
@media (max-width: 760px) {
  #page-people.searching .settings-body { display: grid; }    /* результаты — под строкой поиска, вместо списка разделов */
  /* 8 разделов «Жильцов» (1.203: + «Квартиры и кладовые») — на первом экране телефона, над нижней панелью */
  #people-nav { gap: 10px; }
  #people-nav .sn-group h3 { margin: 8px 14px 4px; }
  #people-nav a { padding-top: 10px; padding-bottom: 10px; min-height: 52px; }
  #page-people.searching .sn-group { display: none; }
  .ps-add { position: absolute; top: 0; right: 0; min-width: var(--tap); font-size: 22px; line-height: 1; }
  .ps-add-text { display: none; }
}

/* Жильцы → реестр машиномест */
.sp-new { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; padding: 12px 14px; margin-bottom: 10px; }
.sp-new input { width: 7em; }
.sp-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.sp-card { display: grid; gap: 8px; padding: 12px 14px; }
.sp-card p { margin: 0; }
.sp-nobody { border-style: dashed; }
.sp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.sp-head b { font-size: 17px; }
.sp-head select { width: auto; min-height: 32px; padding: 2px 30px 2px 8px; }
.sp-plates { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.sp-plate { display: inline-flex; align-items: center; gap: 2px; }
.sp-owner { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.sp-tools, .sp-bind { display: grid; gap: 8px; }
.sp-addplate, .sp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sp-addplate .plate-field { flex: 1 1 12em; min-width: 0; }
.sp-actions .link.danger { font-size: 14px; margin-left: auto; }
.sp-gone { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; opacity: .85; }
.sp-gone .muted { flex: 1 1 auto; }
.sp-deleted { margin-top: 16px; }
.sp-deleted summary { cursor: pointer; padding: 6px 0; }
.sp-deleted .sp-list { margin-top: 8px; }
.sp-note:not([hidden]) { margin: 0 0 8px; }
.sp-found { display: grid; gap: 4px; }
.sp-found-item { text-align: left; justify-content: flex-start; }
.sp-head .sp-open { margin-left: auto; }
.sp-people { display: flex; flex-wrap: wrap; gap: 4px 12px; }
/* карточка объекта (1.203): люди места или помещения с ролями */
.obj-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.obj-person { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.obj-person-name { flex: 1 1 12em; min-width: 0; }
.obj-person select { width: auto; }
.obj-find { gap: 6px; }
.space-others:not([hidden]) { margin: 4px 0 0; }
.unk-actions select { width: auto; }
@media (max-width: 560px) { .sp-list { grid-template-columns: 1fr; } }

/* Настройки → Датчики */
.sens-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px 18px; margin: 0; }
.sens-facts dt { color: var(--muted); font-size: 13px; }
.sens-facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.sens-facts dd.bad, .sens-pos b.bad { color: var(--danger); }
.sens-facts dd.warn, #sens-diag-state.warn { color: var(--warn); }
.sens-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.sens-item { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.sens-item > :first-child { flex: 1 1 auto; min-width: 0; }   /* <select> ворот с длинными названиями — не шире строки */
.sens-item > .sens-pos { flex: none; }
.sens-item:first-child { border-top: 0; padding-top: 0; }
.sens-pos { text-align: right; font-variant-numeric: tabular-nums; }
.sens-now { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 12px 0; font-variant-numeric: tabular-nums; }
.sens-now-item { display: flex; align-items: center; gap: 8px; }
.sens-swatch { width: 12px; height: 12px; border-radius: 3px; }
.sens-swatch.s0 { background: var(--accent); } .sens-swatch.s1 { background: var(--warn); }
.sens-chart { display: block; width: 100%; height: 240px; }
.sens-events { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sens-events th, .sens-events td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.sens-events th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* Онлайн: режим оператора */
.op-switch { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 12px; cursor: pointer; min-height: 32px; }
.op-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.op-track { position: relative; width: 40px; height: 22px; border-radius: 11px; background: var(--border); transition: background .15s; flex: none; }
.op-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.op-switch input:checked + .op-track { background: var(--accent); }
.op-switch input:checked + .op-track::after { transform: translateX(18px); }
.op-switch input:focus-visible + .op-track { outline: 2px solid var(--accent); outline-offset: 2px; }
#page-live.op-on > :not(#op-view):not(#op-switch) { display: none !important; }
.op-view { display: grid; gap: 16px; }
.op-cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.op-cam { display: grid; gap: 12px; min-width: 0; }
.op-cam h2 { margin: 0; }
.op-video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.op-video img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* видео go2rtc (live-video.js): пропорции — по кадру камеры */
.lv { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.lv-video { display: block; width: 100%; height: 100%; object-fit: fill; }
.op-video .lv { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; }
/* «Дом» (app/staff/home.js): домофоны по домам, у каждого — живое видео */
/* 1.201.5: одна сетка домофонов на всю ширину (на телефоне — колонка), коды двери — разделом под ней */
/* «Дом» администрации: видео домофонов крупнее (1.203.1: колонка от 520 px, на большом мониторе — две; было от 360 — три
   узкие) */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
/* «Дом» жильца (1.256, решение владельца 26.11: «перегружен и нелогичен» — как в современных приложениях домофонов):
   сверху выбор квартиры, под ним вкладки по задачам (Домофон · Звонки · Счётчики), под ними — одна колонка выбранной
   вкладки. До 1.256 — две колонки (видео и двери слева; счётчики, коды, звонки сбоку), на телефоне всё одной лентой, и
   счётчики стояли между видео двери и журналом звонков. Колонка не шире 960 px: на мониторе карточки не растягиваются */
.home-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 8px; max-width: 960px; }
.home-places { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0; }
.home-places::-webkit-scrollbar { display: none; }
.home-places[hidden] { display: none; }
.home-places button { flex: none; }
.hm-tabs { margin-bottom: 0; }          /* по бокам — как у вкладок журнала (на телефоне — от края до края) */
.hm-tabs[hidden], .hm-tabs a[hidden] { display: none; }
.hm-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.hm-panel[hidden] { display: none; }
.home-ic-tabs { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0; }
.home-ic-tabs::-webkit-scrollbar { display: none; }
.home-ic-tabs button { flex: none; }
.home-intercoms { display: grid; gap: 12px; min-width: 0; }
.home-intercoms[hidden], .hm-doors[hidden], .home-empty[hidden] { display: none; }
.home-empty { margin: 0; }
.home-root[hidden] { display: none; }
.hm-codes { display: grid; gap: 12px; }
.hm-codes:empty { display: none; }
/* видео — по ширине колонки, но не выше 70 % экрана: на ноутбуке под ним видна кнопка двери */
.hm-door .home-ic .lv { width: min(100%, calc(70vh * 4 / 3)); margin-inline: auto; }
.home-ic { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.home-ic h3 { margin: 0; font-size: 1rem; }
.home-ic-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.home-filter { margin-bottom: 14px; }
.home-ic-head h3 { font-size: 1.1rem; }
.home-codes { margin-top: 28px; display: grid; gap: 16px; }
.home-codes h2 { margin: 0; font-size: 1.05rem; }
.home-ic .lv { aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; }
.home-note { margin: 0; }
.ic-card .row3 label { display: grid; gap: 4px; align-content: start; }
.ic-card h3 { margin: 4px 0 0; font-size: 0.95rem; }
.op-off { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; color: #fff; }
.op-gates { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.op-gate { display: grid; gap: 8px; align-content: start; }
.op-gate h3 { margin: 0; }
.op-gate { min-width: 0; }
.op-cam h2, .op-gate h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* длинное название не сдвигает кнопки */
@media (max-width: 760px) {     /* на телефоне ворота в одну колонку — выравнивать не с чем, название целиком */
  .op-cam h2, .op-gate h3 { white-space: normal; overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { .op-track, .op-track::after { transition: none; } }
.sens-manage { margin-top: 6px; }
.sens-manage select { max-width: 100%; }

/* Онлайн: текущий и последний номер */
.plate-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.plate-card { display: grid; gap: 6px; align-content: start; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.plate-card h3 { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.plate-card.none { color: var(--muted); }
.plate-card.none p { margin: 0; }
.plate-block { display: grid; justify-items: center; gap: 2px; padding: 8px; border-radius: var(--radius-sm); background: var(--hover); text-align: center; }
.plate-big { font-size: 24px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.plate-photos { display: grid; gap: 6px; }
.plate-photos img { display: block; width: 100%; border-radius: 4px; cursor: zoom-in; background: #000; }
.plate-photos img.car { aspect-ratio: 16 / 9; object-fit: contain; }
.plate-photos img.plate { max-height: 64px; object-fit: contain; }
.owner-card { display: grid; gap: 2px; padding-top: 6px; border-top: 1px solid var(--border); }
.owner-card.unknown b { color: var(--warn); }
.owner-card .badge { margin-left: 8px; }
.owner-card .link { justify-self: start; }

/* «Сохранить видео за 5 мин» (app/operator/save-video.js) и «Ворота → Сохранённые видео» (app/staff/saved-videos.js) */
.cam-actions { gap: 8px; align-items: center; }
.save-video-status { flex-basis: 100%; margin: 0; }
.gates-actions + .save-video-status { margin: -8px 0 16px; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved-item { border-top: 1px solid var(--line); padding-top: 10px; }
.saved-item:first-child { border-top: 0; padding-top: 0; }
.saved-clips { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.saved-clips li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.saved-cam { min-width: 7em; }
/* «Ворота → Брелоки» (app/staff/fobs.js) */
.fob-filters > * { flex: 1 1 16em; }
.fob-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fob-item { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.fob-item:first-child { border-top: 0; padding-top: 0; }
/* номер · держатель · ссылки в строку; на телефоне держатель — под номером во всю ширину */
.fob-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "key holder act";
  gap: 2px 12px; align-items: baseline; }
.fob-head .fob-key { grid-area: key; }
.fob-head .fob-holder { grid-area: holder; }
.fob-head .fob-act { grid-area: act; justify-self: end; gap: 4px 12px; }
.fob-key { font-variant-numeric: tabular-nums; min-width: 6.5em; }
.fob-edit input { flex: 1 1 12em; min-width: 0; }
.fob-edit .fob-space { flex: 0 0 5em; }
.fob-preview { font-size: 0.9em; }
@media (max-width: 760px) {
  .fob-head { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "key act" "holder holder"; }
  .fob-edit input[name=name], .fob-edit input[name=note] { flex-basis: 100%; }
  .fob-edit .fob-space { flex: 1 1 5em; }
  /* предпросмотр выгрузки — таблица со своей прокруткой вбок (у журнала строки — карточки, здесь столбцы нужны все) */
  .fob-preview-wrap { overflow-x: auto; }
  .fob-preview td:nth-child(-n+3) { white-space: nowrap; }      /* строка и номера брелка — не рвать */
  .fob-preview td:nth-child(4) { min-width: 10em; }
}
.gl-fob { font-variant-numeric: tabular-nums; }
.save-video.sent { background: var(--ok); border-color: var(--ok); color: #fff; }

/* журнал ворот блоками (1.123.0): чем открыли цикл, строка времени ролеты, пара блокировки, совпавшие с фильтром */
.gl-cyc-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 0.9em; color: var(--muted); flex-basis: 100%; padding-left: 22px;
  min-width: 0; overflow-wrap: anywhere; }
.gl-chip { display: inline-block; justify-self: start; padding: 1px 8px; border-radius: 999px; font-size: 0.85em;
  background: var(--chip, rgba(127, 127, 127, 0.15)); white-space: nowrap; }
.gl-chip.block { background: rgba(200, 140, 30, 0.18); }
.gl-opened.fob { background: rgba(46, 125, 210, 0.16); }
.gl-opened.plate { background: rgba(46, 160, 90, 0.16); }
.gl-opened.app, .gl-opened.manual { background: rgba(140, 90, 200, 0.16); }
.gl-opened.unknown { background: rgba(200, 140, 30, 0.18); }
.gl-timeline { font-variant-numeric: tabular-nums; }
.gl-pos { white-space: nowrap; }
.gl-cyc-toggle { white-space: normal; min-width: 0; }
.gl-cyc-title { overflow-wrap: anywhere; }
.gl-cyc .gl-photos { min-width: 0; max-width: 100%; }
@media (max-width: 700px) {
  .gl-table tr.gl-cyc-head td { min-width: 0; }
  .gl-cyc-toggle { flex: 1 1 100%; }
  .gl-cyc-meta { padding-left: 16px; }
  .gl-cyc .gl-photos { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-left: 16px; }
  .gl-cyc .gl-photos img { flex: none; }
  .gl-photos-row { flex-wrap: nowrap; overflow-x: auto; padding-left: 16px; }
  .gl-photos-row .gl-photos { padding-left: 0; overflow: visible; flex: none; }
}
.gl-pos.open { color: var(--danger); }
.gl-pos.closed { color: var(--ok); }
/* смена положения ролеты внутри цикла (1.181): одна строка — время, «Датчик», что сделали ворота */
.gl-pos-row .gl-pos { font-size: 0.9em; }
.gl-cyc-toggle[disabled] { cursor: default; opacity: 1; }
tr.gl-match > td { box-shadow: inset 3px 0 0 var(--accent); }
.gl-new { position: sticky; top: 8px; z-index: 3; margin: 0 auto 8px; display: block; border-radius: 999px; padding: 6px 14px; }
.gl-new[hidden] { display: none; }

/* «Машина в кадре» (app/operator/arrivals.js): карточки внизу справа — только на компьютере; висят, пока не закроют */
.arrivals { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: flex; flex-direction: column; gap: 6px;
  width: 420px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); pointer-events: none; }
.arrivals[hidden] { display: none; }
.arr-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 6px; margin: -6px; min-height: 0; }
.arr-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 12px; pointer-events: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow); font-size: 13px; }
.arr-bar[hidden] { display: none; }
.arr-bar .link { padding: 0; min-height: 0; font-weight: 600; }
.arr-card { flex: none; overflow: hidden; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius-sm);
  box-shadow: 0 14px 36px -10px rgba(15, 23, 42, .45); cursor: pointer; pointer-events: auto; animation: arr-in .25s ease-out; }
.arr-card.unknown { border-color: var(--warn); }
.arr-top { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: var(--accent); color: var(--accent-text); }
.arr-card.unknown .arr-top { background: var(--warn); color: #fff; }
.arr-title { font-weight: 700; white-space: nowrap; }
.arr-when { flex: 1; min-width: 0; font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr-close { flex: none; display: grid; place-items: center; width: 30px; height: 30px; min-height: 0; padding: 0; border: none;
  border-radius: 8px; background: rgba(255, 255, 255, .2); color: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.arr-close:hover, .arr-close:focus-visible { background: rgba(255, 255, 255, .38); }
.arr-main { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px 12px; }
.arr-main img, .arr-noimg { width: 150px; height: 100px; object-fit: cover; border-radius: 8px; background: var(--border); }
.arr-noimg { display: grid; place-items: center; font-size: 34px; }
.arr-body { display: grid; gap: 6px; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.arr-wait { color: var(--muted); font-size: 15px; }
.arr-unknown { color: var(--warn); font-weight: 700; }
.arr-card .gate-line { margin: 0; }
.arr-card.fresh { animation: arr-in .25s ease-out, arr-glow 1.2s ease-out 2; }
.arr-card.unknown.fresh { animation: arr-in .25s ease-out, arr-glow-warn 1.2s ease-out 3; }
.arr-cams { display: grid; gap: 4px; border: none; padding: 0; margin: 0; }
@keyframes arr-in { from { transform: translateY(16px); opacity: 0; } }
@keyframes arr-glow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes arr-glow-warn { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 75%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; } }
@media (prefers-reduced-motion: reduce) { .arr-card, .arr-card.fresh, .arr-card.unknown.fresh { animation: none; } }
@media (max-width: 760px) { .arrivals, #arrivals-card { display: none; } }

/* обязательные поля (app/common/required.js): звёздочка у подписи, красная рамка у незаполненного после попытки
   сохранить, строка «Заполните: …» над кнопкой */
.req-mark { color: var(--danger); font-weight: 700; margin-left: .15em; cursor: help; }
label:not(.req) .req-mark { display: none; }
.lbl { min-width: 0; }
input.field-invalid, select.field-invalid, textarea.field-invalid, .plate-field.field-invalid { border-color: var(--danger); }
input.field-invalid:focus, select.field-invalid:focus, textarea.field-invalid:focus, .plate-field.field-invalid:focus-within {
  border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.form-req { font-weight: 600; }
/* подсказка в пустом поле — бледным курсивом: образец («например admin») не должен выглядеть введённым значением (1.184) */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; font-style: italic; }

/* управление звуком поверх видео (live-video.js, домофоны «Дома»): кнопка звука и ползунок громкости */
.lv-sound { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 2px; padding: 2px 10px 2px 2px;
  border-radius: 999px; background: rgb(0 0 0 / .55); color: #fff; }
.lv-sound:has(.lv-volume[hidden]) { padding-right: 2px; }
.lv-mute { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit; }
.lv-mute:hover { background: rgb(255 255 255 / .15); }
.lv-mute svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lv-volume { width: 96px; min-height: 0; margin: 0; padding: 0; border: 0; background: transparent; accent-color: #fff; }
.lv-volume:focus { box-shadow: none; }
.lv-mute:focus-visible, .lv-volume:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* «Продолжить» — видео остановил не плеер (телефон, системные кнопки, звонок): по центру поверх застывшего кадра (1.203.4) */
.lv-resume { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center;
  justify-content: center; width: 64px; height: 64px; min-height: 0; padding: 0; border: 0; border-radius: 50%;
  background: rgb(0 0 0 / .55); color: #fff; }
.lv-resume:hover { background: rgb(0 0 0 / .7); }
.lv-resume svg { width: 32px; height: 32px; margin-left: 4px; fill: currentColor; }
.lv-resume:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* «Главная» жильца при нескольких сервисах (app/user/resident.js, 1.187): кнопки группами по сервисам */
.my-groups { display: grid; gap: 16px; }
.my-groups[hidden] { display: none; }
.my-group-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.my-group .my-doors { margin-top: 10px; }
/* «Пропуска гостям» — ссылка в виде строки машиноместа */
a.my-summary { color: inherit; text-decoration: none; border: 1px solid var(--border); }

/* оформление площадки (app/admin/system.js, 1.192): цвет — строка и палитра, логотипы — светлая и тёмная тема */
.sys-color { display: flex; gap: 8px; align-items: center; }
.sys-color input[type=text] { flex: 1; min-width: 0; }
.sys-color input[type=color] { width: 44px; height: var(--tap); min-height: 0; padding: 2px; flex: none; }
.logo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.logo-slot { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
/* поле выбора файла шире экрана телефона (в Chromium CI — шире, чем локально): ужимается по ширине карточки */
.logo-slot input[type=file] { width: 100%; min-width: 0; max-width: 100%; }
.logo-dark { background: #121926; color: #e5e9f0; }
.logo-preview { max-width: 100%; max-height: 90px; object-fit: contain; justify-self: start; }

/* «Открыть дверь» домофона (app/common/door.js, 1.192.4): удержание — полоска заполняется слева направо */
.door-box { display: grid; gap: 6px; }
.door-btn { position: relative; overflow: hidden; width: 100%; min-height: 52px; font-weight: 600; background: var(--accent);
  border-color: var(--accent); color: var(--accent-text); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.door-fill { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: rgb(255 255 255 / .28); pointer-events: none; }
.door-btn.holding .door-fill { transform: scaleX(1); transition: transform var(--hold-ms, .6s) linear; }
.door-label { position: relative; }
.door-btn.ok { background: var(--ok); border-color: var(--ok); }
.door-btn.bad { background: var(--danger); border-color: var(--danger); }
.door-msg { margin: 0; color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .door-btn.holding .door-fill { transition: none; } }

/* «Главная» сводки (app/user/resident.js, 1.193.1): строки сервисов; двери домофонов — в группе «Дом» */
.my-tiles { display: grid; gap: 8px; }
.my-tiles[hidden] { display: none; }
.my-intercom-doors { display: grid; gap: 8px; margin-top: 10px; }

/* Звонок домофона (app/common/call.js, 1.194): экран поверх приложения — видео, состояние, крупные круглые кнопки */
dialog.call-sheet { width: min(720px, 100vw); max-width: 100vw; max-height: 100dvh; padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  border: 0; border-radius: 16px; display: flex; flex-direction: column; gap: 12px; }
dialog.call-sheet:not([open]) { display: none; }
dialog.call-sheet::backdrop { background: rgba(0, 0, 0, .75); }
.call-head { text-align: center; }
.call-head h2 { margin: 2px 0 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.call-kicker { margin: 0; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
/* видео звонка (1.203.1: окно на компьютере шире — 720 px вместо 440): не выше 58 % экрана, под ним — кнопки */
.call-video .lv { aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; width: min(100%, calc(58vh * 4 / 3)); margin-inline: auto; }
.call-novideo { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 10px; background: var(--surface-2, rgba(127, 127, 127, .12)); }
.call-novideo svg { width: 64px; height: 64px; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.call-status { margin: 0; text-align: center; font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.call-note { margin: 0; text-align: center; color: var(--danger); }
.call-actions { display: flex; justify-content: center; gap: 28px; min-height: 0; }
.call-actions:empty { display: none; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--text);
  font-size: .9rem; min-width: 84px; }
.call-btn-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: var(--surface-2, rgba(127, 127, 127, .18)); }
.call-btn-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.call-answer .call-btn-icon { background: var(--ok); color: #fff; }
.call-decline .call-btn-icon { background: var(--danger); color: #fff; }
.call-decline .call-btn-icon svg { transform: rotate(135deg); }
.call-mute.on .call-btn-icon { background: var(--text); color: var(--surface); }
.call-answer .call-btn-icon { animation: call-pulse 1.6s ease-in-out infinite; }
@keyframes call-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
@media (prefers-reduced-motion: reduce) { .call-answer .call-btn-icon { animation: none; } }
@media (max-width: 520px) { dialog.call-sheet { width: 100vw; height: 100dvh; border-radius: 0; justify-content: center; } }

/* Коды двери (app/common/door-codes.js, 1.195; на дом — 1.196): отдельная карточка дома в «Доме» */
.door-codes { display: grid; gap: 8px; align-content: start; }
.door-codes[hidden] { display: none; }
.door-codes h3 { margin: 0; font-size: 1rem; }
.door-codes p { margin: 0; }
/* 1.201.7: свои коды по домам — пустой блок (квартиры в этом доме нет) места в разделе не занимает; все коды — таблицей
   как журнал (раньше колонки слипались — у таблицы не было стилей) */
.door-codes-house:empty { display: none; }
.door-codes-all { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.door-codes-all h3 { margin: 0; font-size: 1rem; }
table.codes-table { width: 100%; border-collapse: collapse; }
.codes-table th, .codes-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.codes-table th { font-weight: 600; color: var(--muted); font-size: 13px; }
.codes-table tr:last-child td { border-bottom: none; }
/* вводы кодов на панелях (1.222, entriesBox): «Что» — длинная строка, переносится; неверный ввод — цветом */
.door-entries { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.door-entries h3 { margin: 0; font-size: 1rem; }
.door-entries .codes-table td:last-child { white-space: normal; }
.codes-table tr.entry-failed td { color: var(--danger); }
/* 1.255.1: на телефоне строки таблиц кодов — карточки (как журнал): таблица в 4–5 колонок без переноса была шире экрана
   (снимки владельца 26.11 — «Срок» и текст справа обрезаны). Все коды: «46к3 · кв. 1» и «Удалить» — сверху, ниже чей и
   вид, затем срок; вводы: время и дверь — строкой, ниже что введено */
@media (max-width: 760px) {
  table.codes-table, .codes-table tbody { display: block; }
  .codes-table thead { display: none; }
  .codes-table tr { display: grid; gap: 2px 10px; align-items: baseline; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .codes-table tr:last-child { border-bottom: none; }
  .codes-table td, .codes-table tr:last-child td { padding: 0; border: none; white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  .door-codes-all .codes-table tr { grid-template-columns: fit-content(50%) minmax(0, 1fr) auto;    /* длинное имя — не шире половины */
    grid-template-areas: "place place del" "who kind kind" "term term term"; }
  .door-codes-all .codes-table td:nth-child(1) { grid-area: place; font-weight: 600; }
  .door-codes-all .codes-table td:nth-child(2) { grid-area: who; }
  .door-codes-all .codes-table td:nth-child(3) { grid-area: kind; color: var(--muted); }
  .door-codes-all .codes-table td:nth-child(4) { grid-area: term; color: var(--muted); font-size: 13px; }
  .door-codes-all .codes-table td:nth-child(5) { grid-area: del; justify-self: end; }
  .door-entries .codes-table tr { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "when where" "what what"; }
  .door-entries .codes-table td:nth-child(1) { grid-area: when; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
  .door-entries .codes-table td:nth-child(2) { grid-area: where; font-weight: 600; }
  .door-entries .codes-table td:nth-child(3) { grid-area: what; }
  .codes-table tr.entry-failed td:nth-child(3) { color: var(--danger); }
}

/* «Дом → Звонки» (1.247, app/staff/calls.js): журнал звонков домофонов для администрации — строками, на телефоне —
   карточкой в две колонки (когда / исход, где и квартира, кто ответил или почему) */
.cj-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; }
.cj-bar input[type=search] { width: 11em; }
.cj-list { display: grid; gap: 6px; margin-bottom: 10px; }
.cj-row { display: grid; grid-template-columns: 7.5em minmax(0, 1.3fr) 5.5em minmax(0, 1fr) minmax(0, 1.3fr); gap: 2px 14px;
          align-items: baseline; padding: 8px 12px; }
.cj-row > * { min-width: 0; overflow-wrap: anywhere; }
.cj-status.missed, .cj-status.failed { color: var(--danger); }
.cj-status.done { color: var(--ok); }
@media (max-width: 700px) {
  .cj-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cj-row .cj-where { grid-column: 1; }
  .cj-row .cj-apt { grid-column: 2; grid-row: 2; }
  .cj-row .cj-status { grid-column: 2; grid-row: 1; text-align: right; }
  .cj-row .cj-more { grid-column: 1 / -1; }
}

/* «Дом → Счётчики» (1.248, app/staff/meters.js): строка счётчика — квартира, номер, состояние опроса (не прочитан —
   красным), показание у супер-администратора */
.mt-export { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0 8px; }
.mt-export input[type=date] { width: auto; }
.mt-houses { margin-bottom: 8px; }
.mt-row { display: grid; grid-template-columns: minmax(6em, auto) 3.5em 8.5em minmax(0, 1fr) auto; gap: 2px 14px;
          align-items: baseline; padding: 8px 12px; }
.mt-row > *, .mt-head > * { min-width: 0; overflow-wrap: anywhere; }
.mt-head { display: contents; }
.mt-res { font-size: 13px; font-weight: 600; }
.mt-res-heat { color: var(--warn); } .mt-res-cold { color: var(--accent); } .mt-res-hot { color: var(--danger); }
.mt-row.mt-stale .mt-state, .mt-row.mt-never .mt-state { color: var(--danger); }
.mt-row.mt-off .mt-state { color: var(--muted); }
.mt-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 700px) {
  .mt-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mt-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; grid-column: 1 / -1; }
  .mt-value { justify-self: end; font-weight: 600; }
}

/* «Дом» жильца — счётчики квартиры (1.248, app/user/meters.js): накоплено и расход по месяцам, вода — списком */
/* 1.255.1 (снимки владельца 26.11): счётчики разделены линией; блок счётчика — кнопка экрана счётчика на всю площадь
   (.meter-open::after поверх блока; разметка остаётся корректной — в кнопке только ресурс и номер), справа «›»; показание
   крупно, когда — рядом мелко; расход месяца — всегда справа, без переноса */
.home-meters.stack { gap: 0; }
.home-meters h3 { margin: 0 0 4px; font-size: 1rem; }
.meter-block { position: relative; display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--border); }
.home-meters h3 + .meter-block { border-top: none; padding-top: 6px; }
.meter-block p { margin: 0; }
.meter-head { display: flex; align-items: baseline; gap: 8px; }
.meter-open { display: flex; align-items: baseline; gap: 8px; min-width: 0; min-height: 0; padding: 0; border: none; border-radius: 0;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.meter-open::after { content: ""; position: absolute; inset: 0; border-radius: 8px; }
.meter-open:focus-visible { outline: none; }
.meter-open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; }
.meter-res { font-weight: 600; }
.meter-chev { margin-left: auto; color: var(--muted); font-size: 1.25rem; line-height: 1; }
@media (hover: hover) { .meter-link:hover .meter-chev { color: var(--accent); } }
.meter-total { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.meter-total b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.meter-note { margin: 8px 0 0; }
.meter-months, .meter-off { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
/* Экран счётчика жильца (1.254): одно крупное число, плитки, столбцы по правилам dataviz — один ряд одним цветом
   (акцент, проверен в обеих темах), закраска не шире 24 px и по центру полосы (полоса целиком — зона нажатия), скругление
   4 px сверху, зазор 2 px, три волосяные линии сетки цветом границы, подсказка по наведению и фокусу, рядом — таблица */
.meter-detail > * { min-width: 0; }
.meter-detail h2 { margin: 0; font-size: 1.15rem; }
.meter-detail h3 { margin: 0 0 6px; font-size: .95rem; }
.meter-hero { margin: 0; display: grid; gap: 2px; }
.meter-hero b { font-size: 48px; font-weight: 600; line-height: 1.05; }
.meter-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.stat-tile { display: grid; gap: 2px; align-content: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.stat-label, .stat-note { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 600; }
.mbar-chart { display: grid; gap: 4px; min-width: 0; }
.mbar-wrap { position: relative; display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 6px; padding-top: 30px; }
.mbar-axis { position: relative; height: 140px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mbar-axis span { position: absolute; right: 0; transform: translateY(-50%); line-height: 1; }
.mbar-axis span:nth-child(1) { top: 0; } .mbar-axis span:nth-child(2) { top: 50%; } .mbar-axis span:nth-child(3) { top: 100%; }
.mbar-plot { height: 140px; display: flex; align-items: stretch; gap: 2px; min-width: 0;
  background: linear-gradient(var(--border), var(--border)) 0 0 / 100% 1px no-repeat,
              linear-gradient(var(--border), var(--border)) 0 50% / 100% 1px no-repeat,
              linear-gradient(var(--border), var(--border)) 0 100% / 100% 1px no-repeat; }
.mbar { flex: 1 1 0; min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: none;
  display: flex; align-items: flex-end; justify-content: center; cursor: default; }
/* width 100% + max-width, а не min(100%, 24px): с min() браузер считал каждый столбец за 24 px в наименьшей ширине и 30
   столбцов распирали лист на телефоне шире экрана */
.mbar-fill { display: block; width: 100%; max-width: 24px; height: calc(var(--h) * 100%); background: var(--accent); border-radius: 4px 4px 0 0; }
.mbar-note .mbar-fill { opacity: .45; }
.mbar:hover .mbar-fill, .mbar:focus-visible .mbar-fill { filter: brightness(1.15); }
.mbar:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mbar-tip { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; font-size: 13px; padding: 3px 8px;
  border-radius: 6px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 8px rgb(0 0 0 / .12);
  pointer-events: none; z-index: 1; }
.mbar-tip[hidden] { display: none; }
.mbar-x { display: flex; justify-content: space-between; padding-left: calc(3.2em + 6px); font-size: 11px; color: var(--muted); }
.mbar-table summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.mbar-table table { width: 100%; margin-top: 4px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.mbar-table td { padding: 2px 8px 2px 0; }
.meter-months li, .meter-off li { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.meter-months li b { font-variant-numeric: tabular-nums; }
.code-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.code-row { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.code-row.code-fresh { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.code-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.code-value { font-size: 1.25rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.code-actions { gap: 8px; }
.code-form { border: 1px dashed var(--border); border-radius: 8px; padding: 10px; }
.code-form[hidden] { display: none; }
.code-dates label { display: grid; gap: 2px; }
/* идёт запрос (создание или удаление кода — секунды): кнопка с вращающимся кружком, остальные кнопки блока недоступны */
button.busy { cursor: progress; }
button.busy::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: .4em; vertical-align: -.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: code-spin .8s linear infinite; }
@keyframes code-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { button.busy::before { animation-duration: 2.4s; } }


/* Журнал звонков домофона (1.198, common/call-log.js): строка — фото у двери, домофон, чем кончилось, когда */
.call-log h3 { margin: 0; font-size: 1rem; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.call-log p { margin: 0; }
.call-log-list { display: grid; gap: 6px; }
/* карусель по 5 звонков (1.200): страницы рядом, свайп — прокрутка с привязкой к странице, полосы прокрутки не видно */
.call-log-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.call-log-track::-webkit-scrollbar { display: none; }
.call-log-page { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; align-content: start; }
.call-log-nav { justify-content: center; align-items: center; gap: 12px; }
.call-log-nav button { min-width: 44px; padding-inline: 0; font-size: 1.2rem; line-height: 1; }
.call-log-readall { margin-left: auto; font-weight: 400; }
/* использованные за сутки одноразовые коды (1.200) */
.code-used { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.code-used li { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--muted); }
.code-used .code-value { font-size: 1rem; text-decoration: line-through; }
button.call-log-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; justify-content: stretch; align-items: center;
  gap: 10px; width: 100%; padding: 6px 10px 6px 6px; text-align: left; font-weight: 400; background: var(--surface); }
button.call-log-row.missed { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.call-log-thumb { position: relative; display: grid; place-items: center; width: 88px; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 6px; background: var(--hover); }
.call-log-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.call-log-play { position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px; font-size: 10px;
  background: rgba(0, 0, 0, .6); color: #fff; }
.call-log-text { display: grid; gap: 1px; min-width: 0; }
.call-log-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.call-entry { width: min(820px, 100vw); }      /* звонок из журнала: видео крупнее (1.203.1: было 560) */
.call-entry-head h3 { margin: 2px 0; }
.call-entry-head p { margin: 0; }
.call-entry-video, .call-entry-photo { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 65vh; object-fit: contain; border-radius: 8px;
  background: #000; }
.call-entry-jump { justify-self: start; }
.call-missed { justify-self: start; margin-top: 2px; }
