/* ===== Onest — самохост (Google Fonts блокирует часть РФ-сетей; без локалки шрифт «плавает»). */
/* Onest на gstatic — variable font: один woff2 на 4 unicode-range, веса 400/500/600/700 берутся из одного файла. */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/onest/onest-cyr-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/onest/onest-cyr.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/onest/onest-lat-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('assets/fonts/onest/onest-lat.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --brand-primary: #0046B9;
  --brand-accent:  #0073DB;
  --brand-soft:    #e8eef9;
  --bg:            #f5f7fb;
  --surface:       #ffffff;
  --border:        #d6dde8;
  --text:          #1a2233;
  --text-muted:    #5b6878;
  --success:       #2ea44f;
  --error:         #d83b3b;
  --warning:       #ffba08;
  --shadow:        0 2px 8px rgba(20, 35, 70, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Onest', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  height: 52px;
  background: var(--brand-primary);
  color: #fff;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
/* Логотип — ссылка на сайт Интеграл Плюс */
.brand-link { display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }
.brand-link:hover { opacity: 0.85; }
/* Название текущего прибора — вынесено из колонки в шапку (освобождает место под фото). */
.brand-device {
  margin-left: 2px; padding: 3px 11px; border-radius: 20px;
  background: rgba(255,255,255,0.16); font-size: 13px; font-weight: 600; white-space: nowrap;
}
/* Логотип Интеграл+ (simple monogram): синий → переводим в белый CSS-фильтром для синего топбара */
.brand-mark {
  display: inline-block;
  height: 22px;
  width: auto;
  filter: brightness(0) invert(1);
  object-fit: contain;
}
.stage-pill {
  background: rgba(255,255,255,0.15);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Шапка колонки «План»: заголовок + кнопка «Задание» + селектор планировки в одной строке */
.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 4px 0;
}
.plan-header .col-title { margin: 0; }
.plan-header-actions { display: flex; align-items: center; gap: 6px; }

/* Кнопка «Задание» — слева от селектора локации */
.task-show-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.task-show-btn:hover { border-color: var(--brand-accent); background: var(--brand-soft); }
.task-show-btn .ui-icon { width: 14px; height: 14px; color: var(--brand-primary); }
/* «Тест датчиков» в активном состоянии — подсветка. */
#sensor-test-btn.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
#sensor-test-btn.active .ui-icon { color: #fff; }
body.sensor-test { /* маркер режима теста (хук для будущей подсветки зон/датчиков) */ }

/* Описание задания в модалке task-info */
.task-info-desc { color: var(--text); font-size: 14px; line-height: 1.5; text-align: left; margin: 0 0 18px 0; }
/* Кастомный dropdown планировки: trigger с SVG-иконкой + раскрывающийся список */
.layout-dd { position: relative; }
.layout-dd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.layout-dd-toggle:hover { border-color: var(--brand-accent); background: var(--brand-soft); }
.layout-dd-toggle[aria-expanded="true"] {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
}
.layout-dd-icon { width: 20px; height: 20px; display: block; object-fit: contain; }
.layout-dd-label { white-space: nowrap; }
.layout-dd-caret { font-size: 10px; color: var(--text-muted); margin-left: 2px; }

.layout-dd-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  margin: 0;
  padding: 4px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(20,35,70,0.15);
  list-style: none;
  z-index: 50;
}
.layout-dd-menu.hidden { display: none; }
.layout-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.12s;
}
.layout-dd-item:hover { background: var(--brand-soft); }
.layout-dd-item.active { background: var(--brand-soft); color: var(--brand-primary); font-weight: 600; }
.layout-dd-item img { width: 22px; height: 22px; display: block; object-fit: contain; }
.dev-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dev-btn:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.5); }
.dev-btn:active { transform: translateY(1px); }

/* Экзаменационный режим: кнопка тумблера + счётчик ошибок */
.exam-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.exam-btn:hover { background: rgba(255,255,255,0.22); }
.exam-btn.active {
  background: #ffba08;
  color: #1a2233;
  border-color: #ffba08;
}
.exam-counter {
  background: rgba(216,59,59,0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
}
.exam-counter.hidden { display: none; }
/* Топбар во время экзамена окрашивается полосой жёлтого, чтобы помнили: подсказок нет */
body.exam-mode .topbar {
  background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-primary) 70%, #ffba08 100%);
}

/* ===== Layout: 3 columns ===== */
.layout {
  display: grid;
  grid-template-columns: 1.0fr 0.7fr 1.5fr;
  gap: 12px;
  padding: 12px;
  /* vh — fallback для iOS Safari ≤15.3, dvh — модерн с учётом скрытых тулбаров. */
  height: calc(100vh - 52px);
  height: calc(100dvh - 52px);
  overflow: hidden;
}

.col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.col-title { margin: 0 0 4px 0; font-size: 16px; font-weight: 600; color: var(--text); }
.col-sub { margin: 0 0 12px 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

/* ===== Plan column ===== */
.plan-wrap {
  flex: 1;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid var(--border);
  position: relative;
  min-height: 0;
}
#apartment-svg { width: 100%; height: 100%; display: block; cursor: default; }

/* ===== План квартиры ===== */
.apartment-outline {
  fill: #ffffff;            /* белый фон под квартиру */
  stroke: none;
}
.room-floor {
  fill: #ffffff;            /* пол комнаты — белый */
  stroke: none;
}
.room-walls {
  fill: none;
  stroke: #1a2233;
  stroke-width: 0.9;
  pointer-events: none;
}
.outer-wall {
  fill: none;
  stroke: #1a2233;
  stroke-width: 1.0;
  pointer-events: none;
  rx: 0.6;
}

/* Двери: проём, дуга-распах, створка */
.door-gap {
  fill: #ffffff;            /* «вырезаем» стену под цвет пола */
  stroke: none;
}
.door-arc {
  fill: none;
  stroke: #d98a3d;
  stroke-width: 0.3;
  stroke-dasharray: 0.7 0.5;
  pointer-events: none;
}
.door-leaf {
  stroke-linecap: round;
  pointer-events: none;
}
.door-leaf.closed { stroke: #d98a3d; stroke-width: 1.0; }   /* закрыто — светло-коричневая полоса в проёме */
.door-leaf.open   { stroke: #d98a3d; stroke-width: 0.6; }   /* открыто — распахнутая створка */
/* Подсказка-мерцание на двери при запуске (одна дверь) */
.door-leaf.hint, .door-arc.hint { animation: door-hint-blink 0.9s ease-in-out infinite; }
@keyframes door-hint-blink { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.15; } }

/* Окна */
.window {
  fill: #aed4ff;
  stroke: #2c3e50;
  stroke-width: 0.2;
  pointer-events: none;
}

/* Металлический шкаф — синий контур + две створки (открываются на 45°) */
.cabinet-body {
  fill: rgba(10, 91, 208, 0.06);
  stroke: #0a5bd0;
  stroke-width: 0.5;
  pointer-events: none;
}
.cabinet-leaf {
  stroke: #0a5bd0;
  stroke-width: 0.7;
  stroke-linecap: round;
  pointer-events: none;
}
.cabinet-leaf.open { stroke-width: 0.6; }
.cabinet-arc {
  fill: none;
  stroke: #0a5bd0;
  stroke-width: 0.25;
  stroke-dasharray: 0.6 0.5;
  opacity: 0.7;
  pointer-events: none;
}
.cabinet-hit {
  fill: transparent;
  cursor: pointer;
  pointer-events: auto;
  transition: fill 0.15s;
}
.cabinet-hit:hover { fill: rgba(10, 91, 208, 0.16); }
/* Размещение: створка под МК и корпус под датчик подсвечиваются как доступные цели */
.cabinet-hit.available {
  fill: rgba(255, 186, 8, 0.28);
  stroke: var(--warning);
  stroke-width: 0.3;
}
.cabinet-hit.available:hover { fill: rgba(255, 186, 8, 0.5); }
.cabinet-inside-hit {
  fill: transparent;
  cursor: pointer;
  pointer-events: auto;
  transition: fill 0.15s;
}
/* Режим размещения датчика в шкаф — жёлтая подсветка цели */
.cabinet-inside-hit.available {
  fill: rgba(255, 186, 8, 0.12);
  stroke: var(--warning);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
}
.cabinet-inside-hit.available:hover { fill: rgba(255, 186, 8, 0.3); }
/* Под охраной — клик по шкафу имитирует тревогу внутреннего датчика */
.cabinet-inside-hit.live:hover { fill: rgba(216, 59, 59, 0.14); }
.cabinet-body.available { stroke: var(--warning); }
.cabinet-label {
  fill: #0a5bd0;
  font-size: 1.4px;
  font-weight: 600;
  pointer-events: none;
}

/* Мебель */
.furniture-rect {
  fill: rgba(20,35,70,0.04);
  stroke: rgba(20,35,70,0.18);
  stroke-width: 0.18;
  pointer-events: none;
}
.furniture-icon {
  font-size: 2.97px;
  pointer-events: none;
  user-select: none;
}

/* Названия комнат — внизу комнаты */
.room-label {
  fill: var(--text-muted);
  font-size: 2.21px;
  font-family: 'Onest', sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

/* Кликовая зона комнаты — прозрачная сверху */
.room-click {
  fill: transparent;
  cursor: default;
  transition: fill 0.15s;
}
.room-click.hover {
  fill: rgba(0, 70, 185, 0.10);
  cursor: pointer;
}
.room-click.armable {
  cursor: pointer;
}
.room-click.armable.hover {
  fill: rgba(216, 59, 59, 0.16);  /* красноватая подсветка — намёк на тревогу */
}
.room-click.disabled {
  pointer-events: none;
}
.room-click.floor-available {
  fill: rgba(0, 115, 219, 0.08);
  cursor: pointer;
  animation: floor-available-pulse 1.8s ease-in-out infinite;
}
.room-click.floor-available.hover {
  fill: rgba(0, 115, 219, 0.22);
}
@keyframes floor-available-pulse {
  0%, 100% { fill: rgba(0, 115, 219, 0.06); }
  50%      { fill: rgba(0, 115, 219, 0.18); }
}

/* Размещённые устройства — кружок-подложка отключён.
   Анимации «под охраной» и «тревога» рисуют свою обводку поверх иконки. */
.placed-circle {
  fill: transparent;
  stroke: transparent;
  stroke-width: 0.4;
  pointer-events: none;
}
.placed-circle.armed {
  animation: placed-pulse 1.6s ease-in-out infinite;
}
.placed-circle.alarming {
  stroke: var(--error);
  stroke-width: 0.7;
  animation: placed-alarm 0.8s ease-in-out infinite;
}
/* Выводной TM — мягко пульсирует синим, когда блок запитан и готов принять ключ. */
.placed-circle.tm-active {
  stroke: var(--brand-primary);
  stroke-width: 0.45;
  animation: tm-reader-pulse 1.8s ease-in-out infinite;
}
@keyframes tm-reader-pulse {
  0%, 100% { stroke-opacity: 0.55; stroke-width: 0.4; }
  50%      { stroke-opacity: 1;    stroke-width: 0.7; }
}
/* Прозрачная хит-зона TM-считывателя поверх иконки — ловит клики. */
.tm-reader-hit {
  fill: rgba(0, 70, 185, 0);
  stroke: none;
  cursor: pointer;
  transition: fill 0.15s;
}
.tm-reader-hit:hover {
  fill: rgba(0, 70, 185, 0.12);
}
/* КТС — тревожную кнопку нажимают именно на ней, а не кликом по комнате */
.ktc-hit {
  fill: rgba(214, 40, 40, 0);
  stroke: none;
  cursor: pointer;
  transition: fill 0.15s;
}
.ktc-hit:hover {
  fill: rgba(214, 40, 40, 0.18);
}
@keyframes placed-pulse {
  0%, 100% { stroke: var(--brand-primary); stroke-width: 0.4; }
  50%      { stroke: var(--error);          stroke-width: 0.6; }
}
@keyframes placed-alarm {
  0%, 100% { stroke-width: 0.7; }
  50%      { stroke-width: 1.2; }
}

/* Сирена в тревоге — красное мигание */
.placed-circle.siren-alarming {
  fill: rgba(216, 59, 59, 0.35);
  stroke: var(--error);
  stroke-width: 0.7;
  animation: siren-blink 0.35s ease-in-out infinite;
}
@keyframes siren-blink {
  0%, 100% { fill: rgba(216, 59, 59, 0.30); stroke-width: 0.6; }
  50%      { fill: rgba(216, 59, 59, 0.90); stroke-width: 1.1; }
}

/* Маяк (свет) сирены — мигает янтарём, когда блок взят и реле «света» настроено верно. */
.siren-beacon-glow {
  fill: #ffcc33;
  stroke: #ff9500;
  stroke-width: 0.5;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(255, 180, 0, 0.9));
  animation: siren-beacon 0.85s steps(1) infinite;
}
@keyframes siren-beacon {
  0%, 49%   { opacity: 0.95; }
  50%, 100% { opacity: 0.12; }
}

/* Звуковые волны от сирены — расходятся из иконки */
.siren-wave {
  fill: none;
  stroke: #ff3b30;
  stroke-width: 1.5;
  opacity: 0;
  pointer-events: none;
  animation: siren-wave 1.2s ease-out infinite;
  filter: drop-shadow(0 0 0.4px rgba(255,59,48,0.5));
}
@keyframes siren-wave {
  0%   { r: 4;  opacity: 1.0; stroke-width: 1.5; }
  60%  { opacity: 0.6; }
  100% { r: 22; opacity: 0;   stroke-width: 0.2; }
}

/* ИК-датчик в режиме охраны: мягкие волны сканирования, ограниченные комнатой
   через clipPath по комнате. */
.pir-wave {
  fill: none;
  stroke: #4caf50;
  stroke-width: 0.35;
  opacity: 0;
  pointer-events: none;
  animation: pir-wave 5s ease-out infinite;
}
@keyframes pir-wave {
  0%   { r: 2;  opacity: 0.85; stroke-width: 0.45; }
  60%  { opacity: 0.35; }
  100% { r: 80; opacity: 0;    stroke-width: 0.1; }
}
.placed-icon {
  font-size: 3.82px;
  pointer-events: none;
  user-select: none;
}
.placed-svg-icon {
  pointer-events: none;
  user-select: none;
}

/* [Кабели на плане выпилены — см. _archived/plan-cables-routing.js] */

/* Двери — клик-зоны (видимы только при размещении МК) */
.door-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
  transition: fill 0.15s, stroke 0.15s;
}
.door-click.available {
  fill: rgba(255, 186, 8, 0.15);
  stroke: var(--warning);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.door-click.available:hover { fill: rgba(255, 186, 8, 0.45); }
/* Дверь кликабельна для открытия/закрытия (вне режима размещения) */
.door-click.toggleable { pointer-events: auto; cursor: pointer; }
.door-click.toggleable:hover { fill: rgba(138, 90, 43, 0.20); }
@keyframes door-available-pulse {
  0%, 100% { stroke-opacity: 0.6; }
  50%      { stroke-opacity: 1.0; }
}

/* Окна — клик-зоны для датчика разбития */
.window-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
  transition: fill 0.15s, stroke 0.15s;
}
.window-click.available {
  fill: rgba(174, 212, 255, 0.45);
  stroke: #0073db;
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.window-click.available:hover { fill: rgba(0, 115, 219, 0.55); }
/* Окно с датчиком разбития под охраной — клик «разбивает стекло» */
.window-click.breakable { pointer-events: auto; cursor: pointer; }
.window-click.breakable:hover { fill: rgba(127, 196, 240, 0.30); }

/* Анимация осколков при разбитии стекла */
.glass-shards { pointer-events: none; }
.glass-shard {
  fill: #cfeaff;
  stroke: #7fc4f0;
  stroke-width: 0.08;
  animation: glass-fly 0.7s ease-out forwards;
}
@keyframes glass-fly {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1);   opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.4); opacity: 0; }
}

/* Углы комнат — клик-зоны для ИК и датчика разбития */
.corner-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
}
.corner-click.available {
  fill: rgba(46, 164, 79, 0.20);
  stroke: var(--success);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.corner-click.available:hover { fill: rgba(46, 164, 79, 0.55); }

/* Фиксированная точка установки (БРО, ИБП) — единственный клик-маркер у стены прихожей */
.fixed-spot-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
}
.fixed-spot-click.available {
  fill: rgba(0, 70, 185, 0.20);
  stroke: var(--brand-primary);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.fixed-spot-click.available:hover { fill: rgba(0, 70, 185, 0.55); }

/* Доп. места под вибродатчики у стены (КХО) */
.wall-spot-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
}
.wall-spot-click.available {
  fill: rgba(46, 164, 79, 0.20);
  stroke: var(--success);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.wall-spot-click.available:hover { fill: rgba(46, 164, 79, 0.55); }

/* Спец-место под КТС (справа от БРО) */
.ktc-spot-click {
  fill: transparent;
  stroke: transparent;
  pointer-events: none;
}
.ktc-spot-click.available {
  fill: rgba(216, 59, 59, 0.20);
  stroke: var(--error);
  stroke-width: 0.3;
  stroke-dasharray: 0.6 0.4;
  pointer-events: auto;
  cursor: pointer;
  animation: door-available-pulse 1.6s ease-in-out infinite;
}
.ktc-spot-click.available:hover { fill: rgba(216, 59, 59, 0.5); }

/* Бэдж с номером ШС под иконкой датчика */
.shleif-badge {
  fill: var(--brand-primary);
  stroke: #fff;
  stroke-width: 0.3;
  pointer-events: none;
}
.shleif-badge-text {
  fill: #fff;
  font-size: 1.55px;   /* −30% от 2.21 */
  font-weight: 700;
  font-family: 'Onest', sans-serif;
  pointer-events: none;
  user-select: none;
}

/* ===== Devices column ===== */
.col-devices { position: relative; }
/* col-bro нужен relative как якорь для абсолютной wires-panel под фото. */
.col-bro { position: relative; }
.device-list {
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}
.device-card {
  flex: 1 1 calc(50% - 3px);     /* 2 в ряд (минус половина gap'а) */
  min-width: 0;
  display: flex;
  align-items: flex-start;       /* иконка — по верху, к названию */
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;              /* содержимое не выходит за пределы карточки */
}
.device-card:hover:not(.locked):not(.done) { border-color: var(--brand-accent); transform: translateX(2px); }
.device-card.active { border-color: var(--brand-primary); background: var(--brand-soft); border-width: 2px; }
.device-card.placed { border-color: var(--warning); }
.device-card.done { border-color: var(--success); background: #f1f9f3; opacity: 0.85; cursor: default; }
.device-card.locked { opacity: 0.45; cursor: not-allowed; background: #f7f9fc; }
.device-icon {
  font-size: 22px;
  width: 36px;
  flex-shrink: 0;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.device-icon .dev-svg-icon {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
}
.device-info { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.device-name { font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.device-state { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
/* Тип шлейфа — отдельной строкой (переносится, если длинный), не выходит за карточку. */
.device-shs {
  align-self: flex-start;
  max-width: 100%;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-soft);
  padding: 1px 7px;
  border-radius: 6px;
  white-space: normal;
  line-height: 1.25;
}
/* Индикатор статуса и удаление — своя строка снизу, по правому краю. */
.device-actions { display: flex; align-items: center; gap: 2px; margin-top: 5px; justify-content: flex-end; }
.device-status { font-size: 16px; display: inline-flex; align-items: center; }

.device-delete {
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  opacity: 0.55;
  transition: all 0.12s;
  flex-shrink: 0;
}
.device-card:hover .device-delete { opacity: 0.9; }
.device-delete:hover {
  background: #fff4f4;
  color: var(--error);
  opacity: 1;
}

/* Кнопки «+ Добавить» датчики — по 2 в ряд, как и карточки устройств. */
.add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  padding: 0;
  width: 100%;
  flex-shrink: 0;
}
.add-btn {
  flex: 1 1 calc(50% - 2.5px);   /* 2 в ряд (gap 5px между ними) */
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 8px;
  background: var(--surface);
  border: 1.5px dashed var(--brand-accent);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: var(--brand-primary);
  transition: all 0.15s;
}
.add-btn:hover:not(:disabled) {
  background: var(--brand-soft);
  border-style: solid;
  transform: translateY(-1px);
}
.add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-style: dotted;
}
.add-btn .add-icon {
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.add-btn .add-icon .dev-svg-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}
.add-btn .add-label { font-weight: 500; }

/* ===== Wires panel =====
   В потоке колонки БРО под фото — не закрывает плату. Стейдж выше шринкает,
   панель занимает свою высоту по контенту. */
.wires-panel {
  position: static;
  flex: 0 1 auto;
  margin-top: 12px;
  background: var(--surface);
  border: 2px solid var(--brand-primary);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(0, 70, 185, 0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 5;
}
.wires-panel.hidden { display: none; }
.wires-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--brand-primary);
}
.wires-head .dev-svg-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 4px;
}
.close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}
.close-btn:hover { color: var(--text); }
.wires-list { display: flex; flex-direction: column; gap: 8px; }
.wire-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  background: var(--surface);
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none;
}
.wire-row:hover:not(.connected):not(.active) {
  border-color: var(--brand-accent);
  background: #fafcff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,70,185,0.08);
}
.wire-row.active {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  box-shadow: 0 0 0 4px rgba(0,70,185,0.12);
}
.wire-row.active::after {
  content: 'выбран → клик по клемме';
  position: absolute;
  right: 12px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--brand-primary);
  background: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--brand-primary);
}
.wire-row.connected {
  border-color: var(--success);
  background: #f1f9f3;
  cursor: default;
}
.wire-row.connected .wire-label { color: var(--success); }
.wire-swatch {
  width: 32px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.1);
}
.wire-label { flex: 1; }
.wire-status { font-size: 18px; line-height: 1; flex-shrink: 0; }
.wire-row.active .wire-status { display: none; }

/* ===== BRO column ===== */
.cover-toggle {
  display: inline-flex;
  align-self: center;
  gap: 0;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 12px;
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 2px rgba(20,35,70,0.04);
}
.toggle-btn {
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.toggle-btn:hover:not(.active) { color: var(--text); background: var(--brand-soft); }
.toggle-btn.active {
  background: var(--brand-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,70,185,0.25);
}
.toggle-btn::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}
.toggle-btn.active::before { background: #fff; opacity: 1; }

.bro-stage {
  flex: 1 1 0;                  /* шринкает, чтобы освободить место под wires-panel */
  position: relative;
  display: flex;
  align-items: center;          /* фото по центру по вертикали — без пустоты снизу */
  justify-content: center;
  min-height: 0;
  padding: 0;
  container-type: size;         /* чтобы рамку считать в cqw/cqh — аспект фото не искажается */
}
/* Контейнер фото подбирается под аспект-ратио изображения,
   так что SVG-клеммы попадают в правильные пиксели платы.
   max-width/max-height: 100% — фото никогда не выйдет за колонку.
   Браузер сам решает: упереться в ширину или в высоту, сохраняя пропорции. */
.bro-img-frame {
  position: relative;
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 10px;
  /* overflow: visible — иначе пульсирующее кольцо маркера XP5 и тултип
     режутся границами рамки. Скруглённые углы фото обеспечиваются
     border-radius: inherit на самом img ниже. */
  overflow: visible;
  margin: 0 auto;
  /* Целевая аспект-пропорция задаётся ниже на конкретный фрейм. */
}
.bro-cover-frame {
  /* Фото обрезано — антенна частично убрана, ориентация горизонтальная (614×550). */
  aspect-ratio: 614 / 550;
  width: 97%;                                /* фолбэк для браузеров без cq-юнитов */
  width: min(97cqw, 97cqh * 614 / 550);      /* влезаем в обе оси, аспект сохранён */
  height: auto;
}
.bro-naked-frame {
  aspect-ratio: 1588 / 1384;
  width: 97%;
  width: min(97cqw, 97cqh * 1588 / 1384);
  height: auto;
}
.bro-img-frame.hidden { display: none; }

/* Фолбэк для браузеров без aspect-ratio (iOS Safari ≤ 15.3, старые Android WebView):
   сайзим элементы по ширине через padding-bottom. Касается фрейма фото и квадратных
   маркеров (LED, перемычка). */
@supports not (aspect-ratio: 1) {
  .bro-cover-frame, .bro-naked-frame {
    height: 0;
    width: 100%;
  }
  .bro-cover-frame { padding-bottom: 89.58%; }
  .bro-naked-frame { padding-bottom: 87.15%; }
  /* LED и перемычка — квадратные, ширина задана в %, fallback-высоту делаем тем же %. */
  .led          { height: 0; padding-bottom: 1.5%; }
  .jumper-marker{ height: 0; padding-bottom: 6.5%; }
}
.bro-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;  /* контейнер уже соответствует аспекту фото — fill даёт точные координаты без crop */
  display: block;
  /* Скругление берём с рамки, чтобы при .bro-img-frame { overflow: visible }
     углы фото были такие же, как у бордера рамки. */
  border-radius: inherit;
}
#terminals-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ===== Wire paths (анимированные провода) ===== */
.wire-path {
  fill: none;
  stroke-width: 0.55;
  stroke-linecap: round;
  filter: drop-shadow(0 0.15px 0.3px rgba(0,0,0,0.45));
  pointer-events: none;
}
/* Эффект «прокладки» провода: рисуется dasharray-маской.
   stroke-dasharray больше длины любой реальной кривой → стартуем с offset = той же длины
   и анимируем offset до 0, провод «выезжает» из точки входа. */
.wire-path.animate-draw {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: wire-draw 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes wire-draw {
  to { stroke-dashoffset: 0; }
}
/* Ethernet — светло-серый патч-корд, ~×4 толще обычного провода (0.55).
   Конец плоский (butt) и обрывается по центру маркера-разъёма — будто кабель вошёл в разъём. */
.eth-cable {
  fill: none;
  stroke: #c3c8d1;
  stroke-width: 2.2;
  stroke-linecap: butt;
  filter: drop-shadow(0 0.2px 0.6px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}
.wire-cap {
  pointer-events: none;
  filter: drop-shadow(0 0.1px 0.2px rgba(0,0,0,0.5));
  animation: cap-fade 0.35s ease-out 0.4s backwards;
}
@keyframes cap-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Провода других устройств — приглушены, чтобы не отвлекали при работе с текущим */
.wire-path.dimmed { opacity: 0.18; transition: opacity 0.25s; }
.wire-cap.dimmed  { opacity: 0.25; transition: opacity 0.25s; }

/* Резистор-перемычка: тонкая металлическая палочка между ШС и GND + корпус-прямоугольник в центре */
.resistor-bar {
  stroke: #6b7280;
  stroke-width: 0.55;
  stroke-linecap: round;
  pointer-events: none;
  filter: drop-shadow(0 0.1px 0.2px rgba(0,0,0,0.4));
}
.resistor-body {
  fill: #efd6a9;
  stroke: #0f2754;
  stroke-width: 0.18;
  pointer-events: none;
  filter: drop-shadow(0 0.15px 0.25px rgba(0,0,0,0.35));
}
.resistor-bar.dimmed  { opacity: 0.25; transition: opacity 0.25s; }
.resistor-body.dimmed { opacity: 0.4;  transition: opacity 0.25s; }

.terminal-hot {
  fill: rgba(0, 115, 219, 0.0);
  stroke: rgba(0, 115, 219, 0);
  stroke-width: 0.4;
  cursor: pointer;
  transition: all 0.2s;
}
.terminal-hot.highlight {
  fill: rgba(0, 70, 185, 0.55);        /* тёмно-синий бренда */
  stroke: var(--brand-primary);
  stroke-width: 0.5;
  animation: pulse 1.4s ease-in-out infinite;
}
.terminal-hot.connected {
  fill: rgba(46, 164, 79, 0.55);
  stroke: var(--success);
  stroke-width: 0.5;
}
/* Общая шина уже занята, но открыта для дополнительных подключений: */
.terminal-hot.highlight.connected {
  fill: rgba(0, 70, 185, 0.55);
  stroke: var(--brand-primary);
  stroke-width: 0.5;
  animation: pulse 1.4s ease-in-out infinite;
}
.terminal-hot:hover.highlight { fill: rgba(0, 70, 185, 0.85); }

/* Пульсация «внутрь»: заливка дышит, контур остаётся стабильным.
   Размер кружка не меняется (без transform), пульсирует только цвет. */
@keyframes pulse {
  0%, 100% { fill-opacity: 0.45; }
  50%      { fill-opacity: 0.95; }
}

.terminal-label {
  font-size: 1.9px;
  fill: var(--text);
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 0.5px;
  stroke-linejoin: round;
  font-family: 'Onest', sans-serif;
  pointer-events: none;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s;
}
.terminal-label.visible { opacity: 1; }

.hint {
  margin: 10px 0 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  min-height: 32px;
}

/* ===== Журнал событий, переданных в АРМ ПЦН ===== */
.arm-log {
  margin-top: 10px;
  background: #0e1726;
  color: #cdd6e3;
  border-radius: 8px;
  padding: 8px 10px 6px 10px;
  font-family: 'Onest', sans-serif;
  flex-shrink: 0;
}
.arm-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8a96a8;
  padding-bottom: 5px;
  border-bottom: 1px solid #1f2c41;
  margin-bottom: 5px;
}
.arm-log-clear {
  background: transparent;
  border: none;
  color: #8a96a8;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.arm-log-clear:hover { color: #fff; }
.arm-log-list {
  max-height: 130px;
  overflow-y: auto;
  font-size: 12px;
  font-family: 'Onest', monospace;
}
.arm-log-empty {
  color: #5d6a80;
  font-size: 11.5px;
  text-align: center;
  margin: 8px 0;
}
.arm-log-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  line-height: 1.35;
}
.arm-log-item:last-child { border-bottom: none; }
.arm-log-time {
  flex-shrink: 0;
  color: #5d6a80;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.arm-log-text { flex: 1; }
.arm-log-arm    .arm-log-text { color: #80c9ff; }
.arm-log-disarm .arm-log-text { color: #b8e6c1; }
.arm-log-alarm  .arm-log-text { color: #ff9696; font-weight: 600; }
.arm-log-info   .arm-log-text { color: #cdd6e3; }

/* ===== LED индикаторы на плате ===== */
#leds-overlay, #leds-overlay-cover {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

/* ===== Клик-зоны на фото с крышкой: TM-считыватель и клавиатура ===== */
.cover-zone {
  position: absolute;
  cursor: pointer;
  background: rgba(0, 70, 185, 0.0);
  border: 2px dashed transparent;
  transition: background 0.15s, border-color 0.15s;
  z-index: 4;
  /* iOS Safari: убираем 300ms-задержку тапа и «ghost click» (когда первый тап
     показывает hover, а второй уже срабатывает как click). */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* Hover-стили — только для мыши/трекпада. На тач-устройствах их не применяем,
   иначе iPad залипает в hover-состоянии после тапа. */
@media (hover: hover) {
  .cover-zone:hover {
    background: rgba(0, 70, 185, 0.12);
    border-color: rgba(0, 70, 185, 0.55);
  }
}
.cover-tm-zone {
  border-radius: 50%;
  /* Гарантируем КРУГ (а не овал) во фрейме с произвольным аспектом: aspect-ratio 1 + центр через transform */
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
}
/* В фазах ожидания (armed_idle, armed, entry_timer) — зоны мягко пульсируют, как намёк */
.bro-cover-frame.bro-active .cover-zone,
.bro-naked-frame.bro-active .cover-zone {
  border-color: rgba(0, 70, 185, 0.35);
  animation: cover-zone-pulse 2s ease-in-out infinite;
}
@keyframes cover-zone-pulse {
  0%, 100% { border-color: rgba(0, 70, 185, 0.25); background: rgba(0, 70, 185, 0.0); }
  50%      { border-color: rgba(0, 70, 185, 0.6);  background: rgba(0, 70, 185, 0.08); }
}

/* ===== Клавиатура крышки: 4×3 кнопок поверх изображения + табло ввода ===== */
.cover-keypad-zone {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0;
  padding: 0;
  /* Контейнер прозрачен для тачей — иначе iPad ловит тап на родителе и
     не пробрасывает его на конкретную кнопку (клавиатура «горит как один прямоугольник»,
     но нажатие не срабатывает). Кнопки внутри возвращают себе pointer-events: auto. */
  pointer-events: none;
}
.cover-keypad-zone .keypad-key {
  pointer-events: auto;
}
/* Приборы с собственной калибровкой клавиш (GAME_KEYPAD_COVER_KEYS_*, напр. БРО-6GSM+4G с рядом
   замков под цифрами) — точное позиционирование каждой кнопки вместо равномерного грида:
   left/top/width/height в % ставит JS (renderCoverZones) по данным самого прибора. */
.cover-keypad-zone.keys-absolute {
  display: block;
}
.cover-keypad-zone.keys-absolute .keypad-key {
  position: absolute;
}
/* Замки — есть только у части приборов; видны и позиционированы, только когда для текущего
   прибора заданы координаты (JS снимает display:none через style.display). */
.keypad-key-lock {
  display: none;
}
@media (hover: hover) {
  .cover-keypad-zone:hover {
    /* Перекрываем подсветку «всей зоны» — теперь подсвечиваются только отдельные клавиши. */
    background: transparent;
  }
}
.keypad-key {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 0;
  margin: 0;
  border-radius: 12%;
  transition: background 0.12s, border-color 0.12s;
  font: inherit;
  /* iPad / iOS Safari: tap-задержка и ghost-click */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
}
@media (hover: hover) {
  .keypad-key:hover {
    background: rgba(0, 70, 185, 0.18);
    border-color: rgba(0, 70, 185, 0.6);
  }
}
.keypad-key.flash {
  animation: keypad-flash 0.22s ease-out;
}
@keyframes keypad-flash {
  0%   { background: rgba(0, 70, 185, 0.55); border-color: rgba(0, 70, 185, 0.9); }
  100% { background: rgba(0, 70, 185, 0.0);  border-color: rgba(0, 70, 185, 0.0); }
}

/* Табло ввода кода — внутри зоны клавиатуры, у самого низа, слегка перекрывает
   её нижний край. Абсолютное позиционирование → вёрстка не «скачет» при показе.
   pointer-events: none — клавиши под табло остаются нажимаемыми. */
.keypad-display {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 55%);
  z-index: 8;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(20, 35, 70, 0.96);
  color: #fff;
  padding: 3px 11px;
  border-radius: 999px;
  font-family: 'Onest', sans-serif;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}
.keypad-display.hidden { display: none; }
.keypad-display .keypad-buffer {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}
.keypad-display .keypad-hint {
  font-size: 10.5px;
  color: #cfd6e4;
  font-weight: 400;
}

/* ===== Кнопка датчика вскрытия (снять/закрыть крышку) — в углу фото БРО =====
   top: -2% — у «плюсовых» БРО название модели напечатано на фото с y≈6.4% до 15.3%
   высоты кадра; кнопка должна заканчиваться выше этой отметки, чтобы не закрывать текст
   (запас посчитан и под маленький экран, где фрейм меньше, а кнопка той же высоты в px). */
.tamper-btn, .ppu-connect-btn {
  position: absolute;
  top: -2%;
  left: 4%;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(20, 35, 70, 0.10);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.tamper-btn:hover, .ppu-connect-btn:hover {
  background: #fff;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(0, 70, 185, 0.18);
}
.tamper-btn .ui-icon, .ppu-connect-btn .ui-icon { width: 14px; height: 14px; }
/* «Закрыть крышку» + «Подключить ППУ» — общий флекс-ряд: вторая кнопка всегда
   встаёт сразу после первой с фиксированным зазором, без риска наехать друг
   на друга при разной ширине экрана (раньше позиционировались отдельно через %,
   что приводило к наложению на узких карточках). */
.bro-tamper-row {
  position: absolute;
  top: -2%;
  left: 4%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bro-tamper-row .tamper-btn, .bro-tamper-row .ppu-connect-btn {
  position: static;
}

/* Плашка статуса SIM — справа от «Подключить ППУ». Компактная, в две строки, у БРО-4GSM+. */
.bro-sim-badge {
  position: absolute; top: -2%; right: 3%; z-index: 6;
  display: none; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: 8px;
  background: rgba(20, 130, 60, 0.94); color: #fff;
  font-size: 8.5px; font-weight: 600; line-height: 1.1; text-align: left;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.bro-sim-badge svg { width: 12px; height: 12px; flex: none; }
body.device-bro4plus #bro-sim-badge { display: inline-flex; }

/* ===== Таймер на вход/выход поверх фото БРО ===== */
.bro-timer {
  position: absolute;
  top: 6%;
  right: 6%;
  background: rgba(20, 35, 70, 0.92);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Onest', sans-serif;
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.bro-timer.hidden { display: none; }
.bro-timer.entry { background: rgba(216, 59, 59, 0.92); }
.bro-timer.exit  { background: rgba(255, 186, 8, 0.92); color: #1a2233; }
.led {
  position: absolute;
  transform: translate(-50%, -50%);
  /* фиксированные пиксели, чтобы не зависеть от aspect-ratio (старый iOS Safari) */
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.led.green {
  opacity: 1;
  background: radial-gradient(circle at 35% 30%, #b2ffb0 0%, #4caf50 50%, #1b5e20 100%);
  box-shadow:
    0 0 4px 1.5px rgba(76,175,80,.85),
    0 0 10px 2px rgba(76,175,80,.45),
    inset 0 0 3px rgba(255,255,255,.6);
}
.led.red {
  opacity: 1;
  background: radial-gradient(circle at 35% 30%, #ffc2bc 0%, #e53935 50%, #8b0000 100%);
  box-shadow:
    0 0 4px 1.5px rgba(229,57,53,.85),
    0 0 10px 2px rgba(229,57,53,.45),
    inset 0 0 3px rgba(255,255,255,.6);
}
.led.off { opacity: 0; }

@keyframes led-pulse-full   { 0%,49.9% { opacity: 1; } 50%,100% { opacity: .05; } }
@keyframes led-pulse-brief  { 0%,89%   { opacity: 1; } 90%,100% { opacity: .1;  } }

.led.blink-red-05 {
  animation: led-pulse-full 2s infinite;
  background: radial-gradient(circle at 35% 30%, #ffc2bc 0%, #e53935 50%, #8b0000 100%);
  box-shadow: 0 0 4px 1.5px rgba(229,57,53,.85), 0 0 10px 2px rgba(229,57,53,.45), inset 0 0 3px rgba(255,255,255,.6);
}
.led.blink-red-1 {
  animation: led-pulse-full 1s infinite;
  background: radial-gradient(circle at 35% 30%, #ffc2bc 0%, #e53935 50%, #8b0000 100%);
  box-shadow: 0 0 4px 1.5px rgba(229,57,53,.85), 0 0 10px 2px rgba(229,57,53,.45), inset 0 0 3px rgba(255,255,255,.6);
}
.led.blink-green-05 {
  animation: led-pulse-full 2s infinite;
  background: radial-gradient(circle at 35% 30%, #b2ffb0 0%, #4caf50 50%, #1b5e20 100%);
  box-shadow: 0 0 4px 1.5px rgba(76,175,80,.85), 0 0 10px 2px rgba(76,175,80,.45), inset 0 0 3px rgba(255,255,255,.6);
}
.led.blink-green-1 {
  animation: led-pulse-full 1s infinite;
  background: radial-gradient(circle at 35% 30%, #b2ffb0 0%, #4caf50 50%, #1b5e20 100%);
  box-shadow: 0 0 4px 1.5px rgba(76,175,80,.85), 0 0 10px 2px rgba(76,175,80,.45), inset 0 0 3px rgba(255,255,255,.6);
}
.led.blink-vz-red {
  animation: led-pulse-brief 1s infinite;
  background: radial-gradient(circle at 35% 30%, #ffc2bc 0%, #e53935 50%, #8b0000 100%);
  box-shadow: 0 0 4px 1.5px rgba(229,57,53,.85), 0 0 10px 2px rgba(229,57,53,.45), inset 0 0 3px rgba(255,255,255,.6);
}

/* ===== Указатель на джампер XP5 ===== */
#jumper-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
}
.jumper-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  /* фиксированные пиксели для совместимости со старым iOS Safari */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  z-index: 6;
}
.jumper-marker::before, .jumper-marker::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #ffba08;
  animation: jumper-ring 1.4s ease-out infinite;
}
.jumper-marker::after { animation-delay: 0.7s; }
@keyframes jumper-ring {
  0%   { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
.jumper-marker:hover { background: rgba(255,186,8,0.18); }
/* Установленная перемычка — субтильная зелёная отметка без пульсации;
   клик по ней снимает питание с блока. */
.jumper-marker.installed { width: 22px; height: 22px; }
.jumper-marker.installed::before,
.jumper-marker.installed::after {
  animation: none;
  border-color: rgba(46, 204, 113, 0.55);
  border-width: 1.5px;
}
.jumper-marker.installed::after { display: none; }
.jumper-marker.installed:hover { background: rgba(229, 57, 53, 0.18); }
.jumper-marker.installed:hover::before { border-color: #e53935; }
.jumper-tooltip {
  position: absolute;
  /* Тултип слева от маркера на той же высоте: справа от перемычки XP5
     на плате стоят диоды выпрямителя, подпись там на них и ложится. */
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1a2233;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.jumper-tooltip::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -5px;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #1a2233;
}

/* ===== Action panel — кнопка следующего шага ===== */
.action-panel {
  margin-top: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--brand-soft) 0%, #f8fafd 100%);
  border: 1.5px solid var(--brand-accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,70,185,0.08);
}
.action-panel.hidden { display: none; }
.action-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.action-text strong { color: var(--brand-primary); }
.action-btn {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(0,70,185,0.25);
}
.action-btn:hover { background: var(--brand-accent); transform: translateY(-1px); }
.action-btn:active { transform: translateY(0); }
.action-btn.danger { background: var(--error); box-shadow: 0 2px 6px rgba(216,59,59,0.3); }
.action-btn.danger:hover { background: #c52e2e; }
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.action-btn-secondary {
  background: transparent;
  color: var(--brand-primary);
  border: 1.5px solid var(--brand-accent);
  box-shadow: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 400;
}
.action-btn-secondary:hover { background: var(--brand-soft); color: var(--brand-primary); transform: none; }
.action-btn-secondary.hidden { display: none; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  /* left устанавливается inline JS-функцией toast() — центруется над колонкой плана */
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 360px;
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.hidden { opacity: 0; visibility: hidden; }
.toast.error { background: var(--error); }
.toast.success { background: var(--success); }

/* ===== Success overlay ===== */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 70, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.success-overlay.hidden { display: none; }
.success-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 36px 40px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.success-icon { font-size: 64px; margin-bottom: 12px; }
/* Баннер режима «Обучение» — текущий шаг сценария, фиксирован сверху поверх ППУ. */
.train-banner {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 2100; width: min(560px, 94vw);
  background: #0b2a52; color: #fff; border: 1px solid #1e4e8c;
  border-radius: 12px; padding: 11px 16px; box-shadow: 0 14px 44px rgba(0,0,0,.38);
}
.train-banner.hidden { display: none; }
.train-banner.collapsed {
  width: auto; padding: 0; background: transparent; border: none; box-shadow: none;
}
.train-close {
  position: absolute; top: 6px; right: 8px; width: 24px; height: 24px;
  border: none; background: transparent; color: #9cc1ed; font-size: 18px; line-height: 1;
  cursor: pointer; border-radius: 6px;
}
.train-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.train-collapse {
  position: absolute; top: 6px; right: 8px; width: 24px; height: 24px;
  border: none; background: transparent; color: #9cc1ed; font-size: 16px; line-height: 1;
  cursor: pointer; border-radius: 6px;
}
.train-collapse:hover { background: rgba(255,255,255,.12); color: #fff; }
.train-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #0b2a52; color: #fff; border: 1px solid #1e4e8c;
  border-radius: 999px; padding: 8px 18px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,.32);
}
.train-pill:hover { background: #123a6e; }
.train-head { font-size: 11.5px; font-weight: 600; color: #7fb2ff; text-transform: uppercase; letter-spacing: .04em; }
.train-title { font-size: 16px; font-weight: 700; margin: 3px 0 4px; }
.train-text { font-size: 12.5px; line-height: 1.45; color: #cfe0f5; }
.train-progress { height: 4px; background: rgba(255,255,255,.15); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.train-progress span { display: block; height: 100%; background: #3b82f6; border-radius: 2px; transition: width .3s ease; }
/* Затемнение экрана + увеличенная центрированная карточка для финального сообщения об окончании обучения. */
.train-banner-backdrop {
  position: fixed; inset: 0; z-index: 2099;
  background: rgba(6,14,30,.6); backdrop-filter: blur(2px);
}
.train-banner-backdrop.hidden { display: none; }
.train-banner.done {
  top: 50%; transform: translate(-50%, -50%);
  width: min(480px, 92vw); padding: 32px 32px 28px; text-align: center;
  background: linear-gradient(160deg, #123a6e, #0b2a52); border-color: #2f6fd1;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  animation: train-done-in .35s ease;
}
.train-banner.done .train-head,
.train-banner.done .train-title,
.train-banner.done .train-text { text-align: center; }
.train-banner.done .train-title { font-size: 22px; margin: 6px 0 10px; }
.train-banner.done .train-text { font-size: 14px; }
.train-done-icon {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 50%;
  background: linear-gradient(160deg, #34d399, #16a34a); color: #fff;
  font-size: 30px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(22,163,74,.45);
}
@keyframes train-done-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.train-done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.train-done-btn {
  flex: 1 1 auto; min-width: 140px;
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all .15s;
  border: 1px solid #2f6fd1; background: transparent; color: #cfe0f5;
}
.train-done-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.train-done-btn.primary {
  background: linear-gradient(160deg, #3b82f6, #2563eb); color: #fff; border-color: transparent;
}
.train-done-btn.primary:hover { filter: brightness(1.1); }
/* Таблица типов шлейфов — широкая карточка со скроллом. */
.shs-types-card { max-width: 760px; width: 92vw; text-align: left; }
#shleif-types-body { max-height: 62vh; overflow-y: auto; margin: 6px 0 16px; border: 1px solid #e8eef9; border-radius: 8px; }
.shs-types-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shs-types-table th { position: sticky; top: 0; background: var(--brand-primary); color: #fff; padding: 8px 10px; font-weight: 600; text-align: left; }
.shs-types-table td { padding: 6px 10px; border-bottom: 1px solid #eef2f8; vertical-align: top; color: #1a2233; line-height: 1.4; }
.shs-types-table tr:last-child td { border-bottom: none; }
.shs-types-table tr:nth-child(even) td { background: #f8fafd; }
.shs-types-table .shs-n { text-align: center; font-weight: 700; color: var(--brand-primary); width: 36px; }
.shs-types-table .shs-name { font-weight: 600; white-space: nowrap; }
.success-card h2 { margin: 0 0 8px 0; color: var(--brand-primary); font-size: 20px; }
.success-card p { color: var(--text-muted); line-height: 1.5; margin: 0 0 20px 0; }
.success-card button {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
}
.success-card button:hover { background: var(--brand-accent); }

/* ===== Модалка выбора задания экзамена ===== */
.exam-picker-card {
  max-width: 560px;
  padding: 30px 32px;
  text-align: left;
}
.exam-picker-card h2 {
  text-align: center;
  margin: 0 0 8px 0;
  font-size: 22px;
  color: var(--brand-primary);
}
.exam-picker-intro {
  margin: 0 0 18px 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}
.exam-step { margin-top: 14px; }
.exam-step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.exam-locations {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.exam-picker-card .exam-loc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}
.exam-picker-card .exam-loc-btn:hover { border-color: var(--brand-accent); background: var(--brand-soft); }
.exam-picker-card .exam-loc-btn.active {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  font-weight: 600;
}
.exam-picker-card .exam-loc-btn img { width: 26px; height: 26px; object-fit: contain; }
.exam-tasks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
}
.exam-tasks-hint {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 4px 0 0 0;
}
.exam-picker-card .exam-task-card {
  display: block;
  text-align: left;
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.exam-picker-card .exam-task-card:hover { border-color: var(--brand-accent); background: var(--brand-soft); }
.exam-picker-card .exam-task-card.active {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(0, 70, 185, 0.12);
}
.exam-task-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 3px; }
.exam-task-desc  { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }
.exam-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.exam-picker-card .exam-start-btn, .exam-picker-card .exam-cancel-btn {
  border: none;
  padding: 9px 18px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.exam-picker-card .exam-start-btn { background: var(--brand-primary); color: #fff; box-shadow: 0 2px 6px rgba(0,70,185,0.25); }
.exam-picker-card .exam-start-btn:hover:not(:disabled) { background: var(--brand-accent); transform: translateY(-1px); }
.exam-picker-card .exam-start-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.exam-picker-card .exam-cancel-btn { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.exam-picker-card .exam-cancel-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* Блокировка селектора локации во время экзамена */
.layout-dd-toggle.locked,
.layout-dd-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--surface);
}
.layout-dd-toggle.locked:hover { border-color: var(--border); background: var(--surface); }

/* Заголовок результатов экзамена */
.exam-results-title {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 14px 0;
  color: var(--brand-primary);
}

/* Строки результатов экзамена */
.exam-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 14px;
  text-align: left;
  margin-bottom: 4px;
}
.exam-row.ok   { background: #f1f9f3; color: var(--success); }
.exam-row.fail { background: #fff4f4; color: var(--error); }
.exam-row-icon { width: 22px; height: 22px; display: inline-flex; flex-shrink: 0; }
.exam-row-icon .ui-icon { width: 22px; height: 22px; }
.exam-row-text strong { color: var(--text); }
.exam-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 10px 0;
}
.exam-stat {
  font-size: 14px;
  text-align: left;
  color: var(--text-muted);
  padding: 4px 10px;
}
.exam-stat strong { color: var(--text); font-size: 16px; }

.hidden { display: none !important; }

/* ===== Универсальные UI-иконки (SVG, currentColor) ===== */
.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.15em;
  line-height: 1;
}
.ui-icon svg, svg.ui-icon { width: 100%; height: 100%; display: block; }
.device-status .ui-icon  { width: 18px; height: 18px; }
.wire-status .ui-icon    { width: 18px; height: 18px; }
.exam-btn .ui-icon       { width: 14px; height: 14px; }
.dev-btn .ui-icon        { width: 14px; height: 14px; }
.success-icon svg        { width: 64px; height: 64px; }
.exam-btn, .dev-btn { display: inline-flex; align-items: center; gap: 5px; }

/* ===== Подсказки: цветовое «моргание» внутрь элемента ===== */
/* Меняется только интенсивность внутренней окантовки и градиента — без скейла и без внешних теней. */
@keyframes hint-blink {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1.5px rgba(0, 70, 185, 0.25),
      inset 0 0 10px 2px rgba(0, 70, 185, 0.08);
  }
  50% {
    box-shadow:
      inset 0 0 0 2px   rgba(0, 70, 185, 0.80),
      inset 0 0 18px 4px rgba(0, 70, 185, 0.32);
  }
}
.hint-pulse {
  animation: hint-blink 1.6s ease-in-out infinite;
  position: relative;
  z-index: 10;
}

/* Для SVG-элементов (хитзоны на плане, клеммы) — без анимаций, чуть толще обводка.
   Базовые анимации .available (door/window/corner/floor) сами привлекают внимание. */
.hint-pulse-stroke {
  stroke-opacity: 1;
}

/* Плашка-подсказка над пульсирующим элементом — всплывает через задержку.
   Крепится к body с position:fixed, чтобы не клипнулась overflow:hidden у колонок.
   После проявления — пульсирует синим ореолом (через outline, чтобы не конфликтовать
   с inline-transform: translateX(-50%) для центровки). */
.hint-tip {
  position: fixed;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  max-width: 220px;
  white-space: normal;
  line-height: 1.35;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation:
    hint-tip-fade  0.4s ease-out 4.5s forwards,
    hint-tip-pulse 1.6s ease-in-out 4.9s infinite;
}
@keyframes hint-tip-pulse {
  0%, 100% {
    outline: 0px solid rgba(0, 115, 219, 0);
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  }
  50% {
    outline: 5px solid rgba(0, 115, 219, 0.40);
    box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  }
}
.hint-tip::after {
  content: '';
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}
.hint-tip.below {
  /* стрелка снизу, плашка над целью — стандарт; below = плашка под целью */
}
/* Крестик закрытия подсказки (родитель — pointer-events:none, тут возвращаем клики) */
.hint-tip-close {
  position: absolute; top: -8px; right: -8px;
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%;
  background: #fff; color: var(--text); font-size: 14px; line-height: 1; cursor: pointer;
  pointer-events: auto; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
}
.hint-tip-close:hover { background: var(--error); color: #fff; }
.hint-tip.below::after {
  left: var(--arrow-x, 50%);
  bottom: auto;
  top: -5px;
  border-top-color: transparent;
  border-bottom-color: var(--text);
}
/* Плашка слева от целевого элемента — стрелка на правом краю, указывает вправо. */
.hint-tip.left-of::after {
  left: auto;
  right: -5px;
  bottom: auto;
  top: var(--arrow-y, 50%);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-left-color: var(--text);
}
/* Плашка справа от целевого элемента — стрелка на левом краю, указывает влево. */
.hint-tip.right-of::after {
  left: -5px;
  bottom: auto;
  top: var(--arrow-y, 50%);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-right-color: var(--text);
}
@keyframes hint-tip-fade {
  to { opacity: 1; }
}

/* Scrollbar polish */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #c8d2e0; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Адаптив: media queries в конце файла, чтобы их переопределения
   гарантированно били базовые правила .bro-*-frame и др. при той же
   специфичности (CSS cascade — last wins).
   ============================================================ */

/* Планшет в ландшафте (≈900–1400px): план сверху-слева, устройства горизонтальной
   полосой под ним, БРО — на всё правое полполотна. */
@media (min-width: 901px) and (max-width: 1400px) {
  .layout {
    grid-template-columns: 1.4fr 1.6fr;
    grid-template-rows: minmax(0, 1.4fr) minmax(180px, 1fr);
    grid-template-areas:
      "plan    bro"
      "devices bro";
    gap: 10px;
    padding: 10px;
  }
  .col-plan    { grid-area: plan; }
  .col-devices { grid-area: devices; }
  .col-bro     { grid-area: bro; }

  /* Устройства строго в 2 столбца — карточки шире и читаемее.
     min-height: 0 у flex-children обязателен, иначе scroll внутри flex не работает. */
  .col-devices { position: relative; min-height: 0; overflow: hidden; }
  .device-list {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .device-card {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    max-width: none;
    padding: 8px 10px;
  }
  .add-row { width: 100%; margin-top: 2px; flex-shrink: 0; }

  /* БРО-колонка: фото — сразу под переключателем «С крышкой/Без крышки»,
     минимальный зазор. На планшете фото во всю ширину (без 90%-ограничения). */
  .col-bro .cover-toggle { margin-bottom: 4px; }
  .bro-stage { align-items: flex-start; margin-top: 0; }
  .bro-cover-frame,
  .bro-naked-frame {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
  }
  /* В планшете панель — обычный блок под фото (база уже static), регулируем
     только максимальную высоту, чтобы при многих жилах в TM не уезжало. */
  .wires-panel { max-height: 240px; }
}

/* iPad Pro 12.9" портрет (1024×1366) и аналогичные планшеты в вертикали.
   Композиция: план + устройства слева стопкой, БРО + панель проводов справа стопкой. */
@media (min-width: 901px) and (max-width: 1100px) and (orientation: portrait) {
  /* Используем landscape-style 2-col grid: план сверху-слева, устройства снизу-слева,
     БРО — на всю правую колонку (там же снизу появляется wires-panel под фото). */
  /* Унаследовано от блока @media 901-1400, но повторяем здесь для надёжности кэскада. */

  /* Карточки устройств: иконка шире, текст крупнее, между ними больше воздуха. */
  .device-card  { padding: 10px 14px; gap: 18px; }
  .device-icon  { width: 44px; }
  .device-icon .dev-svg-icon { width: 30px; height: 30px; }
  .device-name  { font-size: 13.5px; padding-left: 2px; }
  .device-state { font-size: 11.5px; padding-left: 2px; }

  /* Кнопки «+ Добавить» — крупнее, чтобы пальцем попадать. */
  .add-btn { padding: 10px 8px; font-size: 12.5px; }
  .add-btn .add-icon .dev-svg-icon { width: 22px; height: 22px; }

  /* Сетка: чуть сужаем БРО-колонку. Высоту рядов выравниваем (1:1) — план меньше,
     устройства больше, чтобы все карточки помещались без скролла. */
  .layout {
    grid-template-columns: 1.55fr 1.45fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  /* Подсказки-плашки прячем — на узком вертикальном экране они закрывают панели. */
  .hint-tip { display: none; }

  /* Панель проводов: чуть выше потолок, чтобы все 5 проводов TM влезли. */
  .wires-panel { max-height: 320px; }

  /* Колонка БРО: bro-stage берёт только размер фото (не растёт), arm-log не клипается у низа.
     Если контент не влезает — col-bro прокручивается. */
  .col-bro { overflow-y: auto; overflow-x: hidden; }
  .bro-stage { flex: 0 0 auto; }

  /* Журнал АРМ компактнее в портрете */
  .arm-log { margin-top: 8px; padding: 6px 10px; }
  .arm-log-list { max-height: 90px; font-size: 11.5px; }

  /* Терминалы на плате: подписи помельче (фото меньше). */
  .terminal-label { font-size: 2.05px; }
}

/* Узкий экран (планшет в портрете / телефон): план + устройства в строку,
   БРО уезжает на второй ряд во всю ширину. Страница становится прокручиваемой. */
@media (max-width: 900px) {
  /* Глобальный html/body { overflow:hidden; height:100% } из десктопа запирает
     прокрутку — на узких экранах размер контента больше viewport, поэтому
     обязательно открываем вертикальный скролл всей страницы. */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .layout {
    grid-template-columns: 1.0fr 0.8fr;
    grid-template-rows: minmax(360px, 56vh) auto;
    grid-template-rows: minmax(360px, 56dvh) auto;
    height: auto;
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
    overflow: visible;
  }
  .col-bro { grid-column: 1 / -1; }
  .col { overflow: visible; }
  /* На узких экранах 1 карточка в ряд — иначе становится совсем тесно. */
  .device-list { max-height: none; flex-direction: column; flex-wrap: nowrap; }
  .device-card { flex: 0 0 auto; }
  /* В узком режиме высота .col-bro не задана сеткой (auto). Сайзим фрейм по ширине
     через padding-bottom hack — работает даже там, где aspect-ratio не поддержан
     (старые iOS Safari, Android WebView). */
  .bro-stage { flex: none; }
  /* Используем base aspect-ratio + явная ширина. max-width здесь убран намеренно:
     совмещение max-width с padding-bottom (% от родителя, не от фрейма) ломает аспект. */
  .bro-cover-frame,
  .bro-naked-frame {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
  }
  /* Подсказки-плашки скрываем — узкий экран и так перегружен, пульсация остаётся. */
  .hint-tip { display: none; }
  /* Панель проводов в узком режиме встаёт обычным блоком, может расти выше базы. */
  .wires-panel { max-height: none; }
}

/* ===== Телефон (≤ 600px): одна колонка, страница прокручивается =====
   Цель — чтобы интерфейс хотя бы открывался: все три блока встают стопкой,
   страница скроллится вертикально. Никаких фиксированных высот колонок. */
@media (max-width: 600px) {
  /* На корне глобально стоят height: 100% + overflow: hidden — это запирает
     скролл всей страницы. Снимаем именно на телефоне, иначе .layout сколько
     ни ставь auto, прокрутки не будет. */
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Топбар компактнее: бренд-имя и pill этапа прячем, у кнопок оставляем иконки. */
  .topbar { padding: 0 10px; gap: 6px; }
  .brand { gap: 6px; min-width: 0; }
  .brand-name { display: none; }
  .stage-pill { display: none; }
  .topbar-right { gap: 4px; }
  .exam-btn span, .dev-btn span { display: none; }
  .exam-btn, .dev-btn { padding: 6px 8px; }

  /* Сетка → одна колонка во всю ширину; высоту не фиксируем — пусть страница скроллится. */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: none;
    height: auto;
    min-height: 0;
    gap: 8px;
    padding: 8px;
    overflow: visible;
  }
  /* Сбрасываем любые grid-area из планшетных брейкпоинтов (на случай каскада). */
  .col {
    grid-column: 1 / -1;
    grid-area: auto;
    overflow: visible;
    padding: 10px 12px;
    min-height: 0;
  }

  /* План: даём явную пропорцию, иначе SVG схлопывается до 0 (родитель без высоты). */
  .plan-wrap { aspect-ratio: 4 / 3; flex: 0 0 auto; min-height: 240px; }
  .plan-header { flex-wrap: wrap; gap: 6px; }

  /* Устройства: одна карточка в ряд, без внутреннего скролла — листаем страницу целиком. */
  .device-list {
    flex-direction: column;
    flex-wrap: nowrap;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .device-card { flex: 0 0 auto; padding: 10px 12px; }
  .add-row { flex-wrap: wrap; }
  .add-btn { flex: 1 1 calc(50% - 3px); }

  /* БРО-колонка: фото во всю ширину, без max-width. Сцена не растягивается по флексу. */
  .bro-stage { flex: none; margin-top: 0; }
  .bro-cover-frame,
  .bro-naked-frame {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
  }
  .cover-toggle { margin-bottom: 8px; }
  .toggle-btn { padding: 6px 12px; font-size: 12px; }

  /* Журнал АРМ: оставляем компактный внутренний скролл, чтобы он не съедал всю страницу. */
  .arm-log { margin-top: 8px; padding: 6px 10px; }
  .arm-log-list { max-height: 160px; font-size: 11.5px; }

  /* Панель проводов — обычный блок под фото, по высоте контента. */
  .wires-panel { max-height: none; position: static; }

  /* Тоаст: на узком экране растягиваем во всю ширину с отступами. */
  .toast { left: 8px; right: 8px; max-width: none; }

  /* Модалки: ужимаем padding и кнопки. */
  .success-card { padding: 22px 18px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
}

/* ===== ППУ (пульт программирования) ===== */
.ppu-overlay { position: fixed; inset: 0; background: rgba(8,18,38,.55);
  display: flex; align-items: center; justify-content: center; z-index: 2000; }
.ppu-overlay.hidden { display: none; }
/* Режим «Найти ключ»: оверлей становится «сквозным» (клик доходит до клавиатуры блока),
   пульт остаётся кликабельным, правая панель подсказок прячется (место сохраняем — пульт не съезжает). */
.ppu-overlay.findkey-mode { pointer-events: none; background: rgba(8,18,38,.12); }
.ppu-overlay.findkey-mode .ppu-device { pointer-events: auto; }
.ppu-overlay.findkey-mode .ppu-menu-list { visibility: hidden; }
/* Подсказка: зона клавиатуры блока мигает, пока ППУ ждёт ввод с неё. */
@keyframes ppu-keypad-hint { 0%, 100% { box-shadow: 0 0 0 0 rgba(0,115,219,0); } 50% { box-shadow: 0 0 0 4px rgba(0,115,219,.75); } }
body.ppu-findkey #cover-keypad-zone, body.ppu-findkey #cover-keypad-zone .keypad-key,
body.ppu-findkey #naked-keypad-zone, body.ppu-findkey #naked-keypad-zone .keypad-key {
  animation: ppu-keypad-hint 1.1s ease-in-out infinite; border-radius: 8px;
}
/* Сцена: пульт + обучающий список пунктов меню справа */
.ppu-stage { display: flex; align-items: flex-start; gap: 20px; max-width: 96vw; }
.ppu-menu-list { background: #fff; border-radius: 14px; padding: 14px 12px;
  width: 230px; max-height: 70vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 40px rgba(0,0,0,.3); font-family: 'Onest', sans-serif; }
.ppu-menu-list-title { flex-shrink: 0; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted); margin: 2px 8px 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.ppu-menu-list-items { overflow-y: auto; flex: 1; }   /* скроллится только список, заголовок закреплён */
.ppu-menu-item { padding: 8px 11px; border-radius: 9px; font-size: 14px; line-height: 1.3;
  color: var(--text); white-space: normal; word-break: break-word; }
.ppu-menu-item + .ppu-menu-item { margin-top: 2px; }
.ppu-menu-item.active { background: var(--brand-primary); color: #fff; font-weight: 600; }
.ppu-menu-item.is-back { color: var(--text-muted); font-size: 13px; }
.ppu-menu-item.is-back.active { color: #fff; }
/* Раздел «Подключаемые устройства» без RS-485 — пункты в меню есть, но реально подключить нечего:
   красная обводка-сигнал (inset, без сдвига вёрстки). */
.ppu-menu-item.is-inert { box-shadow: inset 0 0 0 1.5px #d83b3b; color: #b32525; }
.ppu-menu-item.is-inert.active { color: #fff; }
@media (max-width: 720px) { .ppu-menu-list { display: none; } }
/* Левая панель: краткое описание текущего пункта/раздела (зачем и что делает) */
.ppu-info { background: #fff; border-radius: 14px; padding: 16px;
  width: 250px; max-height: 70vh; overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,.3); font-family: 'Onest', sans-serif; }
.ppu-info-title { font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 9px; padding-bottom: 9px; border-bottom: 1px solid var(--border); }
.ppu-info-text { font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.ppu-info-line { margin: 0 0 7px; }
.ppu-info-line:last-child { margin-bottom: 0; }
.ppu-info-head { text-transform: capitalize; color: var(--text); font-weight: 600; }
.ppu-info-empty { font-size: 13px; line-height: 1.55; color: var(--text-muted); font-style: italic; }
@media (max-width: 980px) { .ppu-info { display: none; } }
.ppu-device { position: relative; width: min(560px, 92vw); background: #7DAEE8;
  border: 14px solid #111; border-radius: 22px; padding: 22px 26px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4); font-family: 'Onest', sans-serif; }
.ppu-close { position: absolute; top: -14px; right: -14px; width: 34px; height: 34px;
  border-radius: 50%; border: none; background: #111; color: #fff; font-size: 20px;
  cursor: pointer; line-height: 1; }
/* Кнопка «Отключить ППУ» — сверху пульта, отсоединяет от XP1 */
.ppu-disconnect { position: absolute; top: -18px; right: 18px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  background: #111; color: #fff; border: none; border-radius: 9px; padding: 8px 13px;
  font-family: 'Onest', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 5px 14px rgba(0,0,0,.35); }
.ppu-disconnect:hover { background: #c0392b; }
.ppu-disconnect .ui-icon { width: 15px; height: 15px; }
.ppu-head { display: flex; justify-content: space-between; align-items: flex-start; }
.ppu-title { font-weight: 800; font-size: 20px; line-height: 1.15; color: #111; }
.ppu-title span { font-weight: 500; font-size: 13px; }
.ppu-logo { height: 18px; opacity: .9; }
/* Пиксельный шрифт «из квадратиков» (как на старых ЖК-дисплеях). Кириллица + латиница. */
@font-face {
  font-family: 'Handjet'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('assets/fonts/handjet/handjet-cyrillic-400.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Handjet'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('assets/fonts/handjet/handjet-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* LCD — как на реальном пульте: ярко-зелёная подсветка, 16 знакомест-ячеек в строке */
.ppu-lcd { margin: 18px 0; background: #a2c11f; border-radius: 5px; padding: 12px;
  border: 3px solid #2c3a10;
  box-shadow: inset 0 3px 12px rgba(40,60,0,.4), inset 0 0 24px rgba(60,80,0,.2); }
.ppu-lcd-line { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; }
.ppu-lcd-line + .ppu-lcd-line { margin-top: 3px; }
.ppu-cell { height: 36px; display: flex; align-items: center; justify-content: center;
  text-align: center; line-height: 1;
  font-family: 'Handjet', 'Consolas', monospace; font-size: 30px; font-weight: 500;
  color: #16270a; background: rgba(22,39,10,.05);
  border: 1px solid rgba(22,39,10,.18); border-radius: 1px; overflow: hidden; }
.ppu-cell-cursor { background: #16270a; color: #a2c11f; animation: ppu-blink 1s steps(1) infinite; }
@keyframes ppu-blink { 50% { background: transparent; color: #16270a; } }
/* Приплюснутый треугольник-маркер подменю (▶) и «назад» (◄) — рисуем, а не глифом */
.ppu-tri { display: inline-block; width: 0; height: 0;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-left: 11px solid currentColor; }
.ppu-tri-l { display: inline-block; width: 0; height: 0;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-right: 11px solid currentColor; }
/* Символ входа в раздел «↵» (как на реальном ППУ) — рисуем глифом, шрифт его не содержит. */
.ppu-enter { width: 24px; height: 24px; color: currentColor; }
/* Стрелка ↕ при правке числа (→ больше, ← меньше). */
.ppu-updown { width: 22px; height: 26px; color: currentColor; }

/* ===== Разъём Ethernet RJ45 на плате (резервный канал) ===== */
.ethernet-jack-marker {
  position: absolute; transform: translate(-50%, -50%);
  width: 22px; height: 17px; border-radius: 3px;
  border: 2px solid var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(0, 70, 185, 0.14);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
  cursor: pointer; z-index: 6; pointer-events: auto;
  transition: background 0.15s, border-color 0.15s;
}
.ethernet-jack-marker:hover { background: rgba(0, 70, 185, 0.3); }
.ethernet-jack-marker.targeting { border-color: var(--warning); color: var(--warning); animation: ethJackPulse 1.1s infinite; }
.ethernet-jack-marker.plugged {
  border-color: var(--success); color: var(--success); background: rgba(46, 164, 79, 0.32);
}
.ethernet-jack-marker.has-hotspot {
  transform: none;
  border-radius: 4px;
  background: rgba(0, 70, 185, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45),
              0 0 0 2px rgba(255, 255, 255, 0.55);
}
.ethernet-jack-marker.has-hotspot:hover {
  background: rgba(0, 70, 185, 0.18);
}
.ethernet-jack-marker.has-hotspot.plugged {
  background: rgba(46, 164, 79, 0.16);
}
@keyframes ethJackPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 0 0 4px rgba(255,186,8,0.55); }
  50%      { box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 0 0 10px rgba(255,186,8,0); }
}

/* ===== Дисплей БРО-4GSM+ (2×16) — поверх ЖК-зоны платы ===== */
/* Раскладка ячеек как у ППУ, но размер тянется под зону дисплея на фото. */
.bro-lcd {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: center; gap: 2.5%;
  padding: 2.5% 2%;
  background: #9fbe1c;
  border: 2px solid #2c3a10;
  border-radius: 3px;
  box-shadow: inset 0 2px 8px rgba(40,60,0,.45), inset 0 0 14px rgba(60,80,0,.25);
  container-type: size;
  overflow: hidden;
}
.bro-lcd.hidden { display: none; }
/* Прибор выключен — экран не светится (тёмный, без подсветки и символов). */
.bro-lcd.bro-lcd-off {
  background: #1f2710;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .55), inset 0 0 14px rgba(0, 0, 0, .35);
}
.bro-lcd.bro-lcd-off .bro-lcd-cell {
  background: rgba(255, 255, 255, .015);
  border-color: rgba(255, 255, 255, .03);
  color: transparent;
}
.bro-lcd-line { display: grid; grid-template-columns: repeat(16, 1fr); gap: 0.5cqw; flex: 1; }
/* Знакоместа — вертикальные прямоугольники (как у ЖК-индикатора): выше, чем шире.
   Пиксельная буква заполняет ячейку по высоте; свободное место — промежуток между ячейками. */
.bro-lcd-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: 'Handjet', 'Consolas', monospace; font-weight: 600;
  font-size: min(8.5cqw, 52cqh); line-height: 1;
  color: #16270a; overflow: hidden;
  background: rgba(22, 39, 10, .06);
  border: 1px solid rgba(22, 39, 10, .14);
  border-radius: 1px;
}
.bro-lcd-cell-cursor { background: #16270a; color: #9fbe1c; animation: ppu-blink 1s steps(1) infinite; }
.bro-lcd-tri { width: 0; height: 0;
  border-top: 0.28em solid transparent; border-bottom: 0.28em solid transparent;
  border-left: 0.5em solid currentColor; }
.bro-lcd-tri-l { width: 0; height: 0;
  border-top: 0.28em solid transparent; border-bottom: 0.28em solid transparent;
  border-right: 0.5em solid currentColor; }
/* Символ входа в раздел «↵» на ЖК — рисуем глифом (шрифт его не содержит). */
.bro-lcd-enter { width: 0.95em; height: 0.95em; color: currentColor; }
/* Индикатор уровня GSM-сигнала — 1-3 палочки в ячейке дежурного экрана. */
.bro-lcd-signal { width: 0.82em; height: 0.86em; color: currentColor; }
.ppu-buttons { display: flex; justify-content: center; gap: 56px; margin-top: 10px; }
.ppu-btn { width: 56px; height: 56px; border-radius: 50%; border: none; background: #111;
  color: #fff; font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 0 #000, 0 6px 10px rgba(0,0,0,.35); transition: transform .05s; }
.ppu-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.ppu-legend { margin-top: 16px; min-height: 18px; text-align: center; font-size: 13px;
  color: #0d2a52; font-weight: 600; }
.ppu-legend.hidden { visibility: hidden; }
/* Колонка: пульт + подсказка клавиатуры под ним (подсказка НЕ внутри пульта) */
.ppu-col { display: flex; flex-direction: column; align-items: center; }
/* Подсказка управления с клавиатуры — отдельным блоком ПОД пультом, на тёмном фоне оверлея */
.ppu-kbd { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.ppu-kbd-key { display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; font-family: 'Onest', sans-serif; font-weight: 700; }
.ppu-kbd-arrows { display: grid; grid-template-columns: repeat(3, 26px);
  grid-template-rows: repeat(2, 26px); gap: 4px; }
.ppu-kbd-arrows .ppu-kbd-key { width: 26px; height: 26px; font-size: 14px; }
.ppu-kbd-up   { grid-area: 1 / 2; }
.ppu-kbd-left { grid-area: 2 / 1; }
.ppu-kbd-down { grid-area: 2 / 2; }
.ppu-kbd-right{ grid-area: 2 / 3; }
/* ↑ и ↓ — серые (просто чтобы кластер читался как клавиши); ← → — подсвечены */
.ppu-kbd-dim { background: rgba(255,255,255,.16); color: rgba(255,255,255,.55); }
.ppu-kbd-act { background: #fff; color: #111; box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.ppu-kbd-note { display: inline-flex; align-items: center; gap: 8px;
  color: #fff; font-family: 'Onest', sans-serif; font-size: 13px; font-weight: 600; }
.ppu-kbd-enter { background: #fff; color: #111; padding: 0 9px; height: 24px; font-size: 12px;
  box-shadow: 0 2px 0 rgba(0,0,0,.4); }

/* Яркость индикации ППУ = 1: приглушённые светодиоды */
.leds-dim .led { opacity: .45; }

/* ===== Приветственное окно-маршрутизатор ===== */
.welcome-overlay {
  /* Выше всех окон (подсказки .hint-tip — 1000, ППУ — 2000), чтобы всплывающие
     подсказки не налипали на меню выбора прибора и локации. */
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 26, 56, 0.55); backdrop-filter: blur(2px);
  padding: 16px;
}
.welcome-overlay.hidden { display: none; }
.welcome-box {
  width: min(920px, 96vw); max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(10, 30, 70, 0.35);
  overflow: hidden;
}
.welcome-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; background: var(--brand-primary); color: #fff;
}
.welcome-logo { height: 30px; width: auto; filter: brightness(0) invert(1); }
.welcome-close {
  margin-left: auto; flex: none;
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: rgba(255, 255, 255, 0.12); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.welcome-close:hover { background: rgba(255, 255, 255, 0.22); }
.welcome-title { margin: 0; font-size: 19px; font-weight: 700; }
.welcome-sub { margin: 2px 0 0; font-size: 12.5px; opacity: 0.85; }
.welcome-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.welcome-section { display: flex; flex-direction: column; gap: 8px; }
.welcome-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.welcome-modes { display: flex; gap: 8px; }
.welcome-mode {
  flex: 1; padding: 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; color: var(--text);
}
.welcome-mode:hover { border-color: var(--brand-accent); }
.welcome-mode.active { border-color: var(--brand-primary); background: var(--brand-soft); color: var(--brand-primary); }

.welcome-locs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.welcome-loc {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; transition: all 0.15s;
}
.welcome-loc { position: relative; }
.welcome-loc:hover:not(.is-disabled) { border-color: var(--brand-accent); }
.welcome-loc.active { border-color: var(--brand-primary); background: var(--brand-soft); }
.welcome-loc.is-disabled { color: var(--text-muted); opacity: 0.65; cursor: not-allowed; }
.welcome-loc img { width: 34px; height: 34px; object-fit: contain; }
.welcome-loc svg { width: 34px; height: 34px; color: var(--text-muted); }
.welcome-loc span { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.15; }

.welcome-tasks { display: flex; flex-direction: column; gap: 6px; }
.welcome-hint { margin: 0; font-size: 12px; color: var(--text-muted); }
.welcome-task {
  text-align: left; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--surface); cursor: pointer; transition: all 0.15s;
}
.welcome-task:hover { border-color: var(--brand-accent); }
.welcome-task.active { border-color: var(--success); background: #f1f9f3; }
.welcome-task-title { font-size: 13px; font-weight: 600; }
.welcome-task-desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
/* Метка сложности задания: Простое / Среднее / Сложное. */
.welcome-task-level {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  padding: 1px 7px; border-radius: 9px; color: #fff;
}
.welcome-task-level.lvl-0 { background: var(--success); }   /* Простое */
.welcome-task-level.lvl-1 { background: #e08a00; }          /* Среднее */
.welcome-task-level.lvl-2 { background: #d23b3b; }          /* Сложное */

/* Глобальный канал связи (IP / радио) — сегмент-переключатель над приборами. */
.welcome-channels { display: flex; gap: 8px; margin-bottom: 10px; }
.welcome-channel {
  position: relative; flex: 1; padding: 9px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; color: var(--text);
}
.welcome-channel:hover:not(.is-disabled) { border-color: var(--brand-accent); }
.welcome-channel.active { border-color: var(--brand-primary); background: var(--brand-soft); color: var(--brand-primary); }
.welcome-channel.is-disabled { color: var(--text-muted); opacity: 0.65; cursor: not-allowed; }
.welcome-radio-note { padding: 14px 4px; }

.welcome-devices { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
/* Столбцы приборов/блоков. Зазор крупнее — под плашки «скоро» на нижней обводке. */
.welcome-device-col { display: flex; flex-direction: column; gap: 13px; }
.welcome-device-col .welcome-device { width: 100%; }
.welcome-device {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  max-width: 200px; text-align: center; line-height: 1.2;
}
.welcome-device:hover:not(.is-disabled) { border-color: var(--brand-accent); }
.welcome-device.active { border-color: var(--brand-primary); background: var(--brand-soft); color: var(--brand-primary); }
.welcome-device.is-disabled { color: var(--text-muted); opacity: 0.65; cursor: not-allowed; }
/* Подпись-ключевые особенности под названием прибора */
.welcome-device-tag {
  font-size: 9.5px; font-weight: 600; text-transform: none; letter-spacing: 0;
  color: var(--text-muted);
}
.welcome-device.active .welcome-device-tag { color: var(--brand-primary); }
/* Маленькая плашка по центру нижней обводки прибора */
.welcome-device-soon {
  position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%);
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  background: var(--brand-accent); color: #fff; padding: 1px 8px; border-radius: 10px;
  white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
/* Бета-метка у пункта «Программирование с ППУ» */
.welcome-beta {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  background: rgba(0, 70, 185, 0.12); color: var(--brand-primary);
  padding: 1px 7px; border-radius: 10px;
}

.welcome-opts { display: flex; flex-direction: column; gap: 8px; }
.welcome-opt { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.welcome-opt input { width: 16px; height: 16px; cursor: pointer; }
.welcome-opt.is-disabled { color: var(--text-muted); cursor: not-allowed; }
.welcome-opt.is-disabled input { cursor: not-allowed; }
.welcome-soon {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  background: var(--brand-accent); color: #fff; padding: 1px 7px; border-radius: 10px;
}

.welcome-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.welcome-start {
  padding: 11px 28px; border: none; border-radius: 10px;
  background: var(--brand-primary); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all 0.15s;
}
.welcome-start:hover { filter: brightness(1.08); }
.welcome-start:disabled { background: var(--border); cursor: not-allowed; }

/* Чекбокс ППУ снят — скрываем кнопку «Подключить ППУ» */
body.no-ppu .ppu-connect-btn { display: none; }

/* В режиме экзамена авто-разводка недоступна (монтаж — только вручную) */
body.exam-mode #auto-wire { display: none; }

/* Кнопку «Экзамен» в шапке не показываем — режим выбирается в стартовом окне.
   В режиме экзамена она остаётся как «Завершить задание» (для сдачи/оценки). */
body:not(.exam-mode) #exam-toggle { display: none; }

/* ===== БРО-4GSM+ =====
   Накладки на ФОТО С КРЫШКОЙ (LED-индикаторы, зоны TM/клавиатуры) откалиброваны
   под альбомный БРО-4 GSM и не совпадают с портретной крышкой «плюса» — прячем их.
   Кнопку «Снять крышку» оставляем: у «плюса» есть своя плата (bro4plus-naked.jpg). */
/* LED-индикаторы крышки у «плюса» нет (статус на ЖК-экране) — прячем накладку.
   Зоны TM и клавиатуры теперь откалиброваны под крышку «плюса» — оставляем рабочими. */
body.device-bro4plus #leds-overlay-cover { display: none; }
/* Обложка «плюса» портретная (630×900). Рамка держит тот же аспект — фото заполняет
   её целиком, и ЖК-зона (координаты в % фото) попадает в нужные пиксели. */
body.device-bro4plus #bro-cover-img { object-fit: fill; }
body.device-bro4plus .bro-cover-frame {
  aspect-ratio: 630 / 900;
  width: 76%;
  width: min(97cqw, 97cqh * 630 / 900);
}
@supports not (aspect-ratio: 1) {
  body.device-bro4plus .bro-cover-frame { padding-bottom: 142.8%; }
}
/* Плата «плюса» обрезана по краям и вписана в окно (800×1053, ПОРТРЕТ). Рамка держит
   тот же аспект, иначе клеммы/зоны (координаты в % фото) уедут. Ширину тоже считаем
   по портретному аспекту, иначе высокая плата вылезает за блок (на кнопку «Заглушить GSM»). */
body.device-bro4plus .bro-naked-frame {
  aspect-ratio: 800 / 1053;
  width: 76%;                                /* фолбэк для браузеров без cq-юнитов */
  width: min(97cqw, 97cqh * 800 / 1053);     /* упираемся в меньшую из осей блока */
}
@supports not (aspect-ratio: 1) {
  body.device-bro4plus .bro-naked-frame { padding-bottom: 131.6%; }
}
/* У БРО-6GSM+ свои фото (assets/bro6plus-*) с другими пропорциями, чем у 4GSM+ —
   переопределяем аспект, иначе object-fit: fill (см. выше) растянет картинку. */
body.device-bro6plus .bro-cover-frame {
  aspect-ratio: 1818 / 2659;
  width: 76%;
  width: min(97cqw, 97cqh * 1818 / 2659);
}
@supports not (aspect-ratio: 1) {
  body.device-bro6plus .bro-cover-frame { padding-bottom: 146.3%; }
}
body.device-bro6plus .bro-naked-frame {
  aspect-ratio: 1159 / 1721;
  width: 76%;
  width: min(97cqw, 97cqh * 1159 / 1721);
}
@supports not (aspect-ratio: 1) {
  body.device-bro6plus .bro-naked-frame { padding-bottom: 148.5%; }
}
/* У БРО-6GSM+4G свои фото (assets/bro6plus4g-*, 1710×1744 с крышкой, 1773×1632 плата). */
body.device-bro6plus4g .bro-cover-frame {
  aspect-ratio: 1710 / 1744;
  width: 76%;
  width: min(97cqw, 97cqh * 1710 / 1744);
}
@supports not (aspect-ratio: 1) {
  body.device-bro6plus4g .bro-cover-frame { padding-bottom: 101.99%; }
}
body.device-bro6plus4g .bro-naked-frame {
  aspect-ratio: 1773 / 1632;
  width: 76%;
  width: min(97cqw, 97cqh * 1773 / 1632);
}
@supports not (aspect-ratio: 1) {
  body.device-bro6plus4g .bro-naked-frame { padding-bottom: 92.05%; }
}

/* ===== Подавление GSM-сигнала (диверсия «джаммер») ===== */
.gsm-channel {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px; padding: 7px 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.gsm-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.gsm-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--success); box-shadow: 0 0 0 3px rgba(46,164,79,0.18); }
.gsm-status-ok      { color: var(--success); }
.gsm-status-backup  { color: #b07a00; }
.gsm-status-backup .gsm-dot { background: var(--warning); box-shadow: 0 0 0 3px rgba(255,186,8,0.22); }
.gsm-status-down    { color: #e5484d; }
.gsm-status-down   .gsm-dot { background: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,0.20); animation: gsmPulse 1s infinite; }
@keyframes gsmPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.gsm-jam-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1.5px solid var(--border); border-radius: 999px;
  background: var(--surface); font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text); cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.gsm-jam-btn .ui-icon { width: 15px; height: 15px; }
.gsm-jam-btn:hover { border-color: #e5484d; color: #e5484d; }
.gsm-jam-btn.active { background: #e5484d; border-color: #e5484d; color: #fff; }
.gsm-jam-btn.active:hover { background: #d3383d; }

/* Строка статуса канала в тёмной панели АРМ */
.arm-channel-status {
  display: flex; align-items: center; gap: 7px;
  margin: 4px 0 6px; padding: 5px 9px; border-radius: 7px;
  font-size: 11.5px; font-weight: 600;
}
.arm-channel-ok     { background: rgba(46,164,79,0.14); color: #b8e6c1; }
.arm-channel-backup { background: rgba(255,186,8,0.16); color: #ffd980; }
.arm-channel-down   { background: rgba(229,72,77,0.18); color: #ff9696; }
.arm-channel-down .gsm-dot { animation: gsmPulse 1s infinite; }

/* Недоставленные события в журнале АРМ */
.arm-log-blocked .arm-log-text { color: #ff8a8a; text-decoration: line-through; opacity: 0.9; font-weight: 600; }
