/* Панель управления воротами.
   Фото-фон (gate/web/bg.svg; положите bg.jpg рядом, чтобы поставить свою фотографию),
   матовое стекло, крупные круглые кнопки. Один оформительский режим: тёмное стекло на картинке. */

:root {
  --text: #f4f6ff;
  --muted: rgba(235, 240, 255, 0.66);
  --glass: rgba(12, 16, 36, 0.46);
  --glass-strong: rgba(12, 16, 36, 0.72);
  --glass-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.09);
  --accent: #7aa2ff;
  --accent-2: #5eead4;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #fb7185;
  --shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7);
  --radius-lg: 28px;
  --radius-md: 18px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  background: #0b1020 url("/static/bg.svg") center / cover no-repeat fixed;
  background-image: url("/static/bg.jpg"), url("/static/bg.svg");
  padding-bottom: env(safe-area-inset-bottom);
}
/* затемнение, чтобы текст читался на любой фотографии */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 9, 22, 0.35) 0%, rgba(6, 9, 22, 0.55) 55%, rgba(6, 9, 22, 0.82) 100%);
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
[hidden] { display: none !important; }

.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic.big { width: 36px; height: 36px; }

kbd {
  font: inherit; font-size: 10.5px; line-height: 16px; padding: 0 5px;
  border-radius: 5px; border: 1px solid currentColor; opacity: 0.4;
}
@media (hover: none) { kbd { display: none; } }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(18px, calc((100vw - 1160px) / 2));
  background: linear-gradient(180deg, rgba(6, 9, 22, 0.55), transparent);
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6c8cff, #3ec6c0);
  box-shadow: 0 10px 26px -8px rgba(80, 140, 255, 0.7);
}
.logo .ic { width: 20px; height: 20px; }
.brand h1 { font-size: 18px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5); }
.sub { color: var(--muted); font-size: 13px; }

.conn { display: flex; align-items: center; gap: 8px; }
.pill {
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line-soft);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.pill.on { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.pill.warn { color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 40%, transparent); }
.link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; margin: 0 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.25); }
#btn-theme { display: none; }
@media (max-width: 720px) { .conn .pill, .sub { display: none; } }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; flex: none;
  border-radius: 11px; border: 1px solid var(--line-soft);
  background: var(--glass-2); color: var(--text);
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: var(--line); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ic { width: 17px; height: 17px; }

/* ---------- Баннер аварии ---------- */
.alert {
  max-width: 1124px; margin: 0 auto 18px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px; border-radius: var(--radius-md);
  color: #ffd1d8; background: rgba(120, 20, 40, 0.62);
  border: 1px solid rgba(251, 113, 133, 0.6);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.alert p { flex: 1; font-weight: 500; }
@media (max-width: 1160px) { .alert { margin-inline: 16px; } }

/* ---------- Раскладка ---------- */
.layout { max-width: 1160px; margin: 0 auto; padding: 0 18px; display: grid; gap: 18px; }
.col { display: contents; }
.scene-card { order: 1; }
.controls { order: 2; }
.cam-card { order: 3; }
.metrics { order: 4; }

@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); align-items: start; gap: 22px; }
  .col { display: flex; flex-direction: column; gap: 22px; }
  .scene-card, .controls, .cam-card, .metrics { order: 0; }
  .col-side { position: sticky; top: 76px; }
}

/* Стеклянная карточка */
.scene-card, .controls, .cam-card, .metrics, .panel {
  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.07) inset;
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

/* ---------- Состояние ---------- */
.scene-card { padding: 24px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.scene-card[data-kind="ok"] { --tone: var(--green); }
.scene-card[data-kind="warn"] { --tone: var(--yellow); }
.scene-card[data-kind="alarm"] { --tone: var(--red); }
#gate-view { display: none; }   /* схема заменена фоном-картинкой; элементы остаются для скриптов */

.scene-info { display: grid; gap: 18px; }
.state {
  display: flex; align-items: center; gap: 14px;
  font-size: clamp(36px, 5vw, 48px); font-weight: 800; line-height: 1.05; letter-spacing: -0.04em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.state::before {
  content: ""; flex: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--tone, #94a3b8);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--tone, #94a3b8) 25%, transparent), 0 0 24px var(--tone, transparent);
}
.scene-card[data-kind="warn"] .state::before { animation: blink 1s ease-in-out infinite; }
.state-sub { color: var(--muted); font-size: 14.5px; margin: 6px 0 0 28px; }

.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--tone, var(--accent)), color-mix(in srgb, var(--tone, var(--accent)) 50%, #fff));
  box-shadow: 0 0 16px var(--tone, var(--accent));
  transition: width 0.5s linear;
}
.bar-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 8px;
  border-radius: 999px; background: var(--glass-2); color: var(--muted); font-size: 12.5px;
}
.badge .ic { width: 14px; height: 14px; }
.badge.on { color: var(--green); background: rgba(74, 222, 128, 0.14); }
.badge.alarm { color: var(--red); background: rgba(251, 113, 133, 0.18); }
#badge-obstacle:not(.alarm), #badge-fault:not(.alarm), #badge-estop:not(.alarm) { display: none; }

/* элементы схемы (скрыта, но скрипты ими пользуются) */
.leaf { transition: transform 0.6s linear; }
.endstop, .lamp { fill: var(--line); }
.endstop.on { fill: var(--green); }
.lamp-halo { opacity: 0; fill: var(--yellow); }
.obstacle-flash { fill: var(--red); opacity: 0; }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Пульт: круглые кнопки ---------- */
.controls { padding: 24px 20px 20px; display: grid; gap: 18px; }
.pads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; justify-items: center; }
.pad {
  --tone: var(--accent);
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: 100%; padding: 0; border: 0; background: none; color: var(--text);
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}
.pad .ic {
  width: 84px; height: 84px; padding: 26px; border-radius: 50%; stroke-width: 2.2; color: #fff;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.55), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--tone) 92%, #fff), color-mix(in srgb, var(--tone) 70%, #000));
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--tone) 18%, transparent),
    0 18px 34px -10px color-mix(in srgb, var(--tone) 90%, transparent),
    inset 0 -6px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s, box-shadow 0.2s;
}
.pad.stop .ic { color: #3a2500; }
.pad kbd { position: absolute; top: 0; right: calc(50% - 56px); }
.pad.open { --tone: #22c55e; }
.pad.stop { --tone: #fbbf24; }
.pad.close { --tone: #4d7cff; }
.pad:hover .ic { transform: translateY(-3px) scale(1.04); box-shadow: 0 0 0 8px color-mix(in srgb, var(--tone) 24%, transparent), 0 24px 40px -10px color-mix(in srgb, var(--tone) 95%, transparent), inset 0 -6px 12px rgba(0, 0, 0, 0.25); }
.pad:active .ic { transform: scale(0.94); }
.pad.is-active .ic { animation: ring 1.4s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tone) 30%, transparent), 0 18px 34px -10px var(--tone), inset 0 -6px 12px rgba(0,0,0,.25); }
  50% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--tone) 6%, transparent), 0 18px 34px -10px var(--tone), inset 0 -6px 12px rgba(0,0,0,.25); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--glass-2); color: var(--text);
  font-weight: 600; font-size: 14.5px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s, filter 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.17); border-color: var(--line); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn .ic { width: 17px; height: 17px; }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, #5b84ff, #3ec6c0); box-shadow: 0 12px 26px -12px rgba(80, 150, 255, 0.9); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--glass-2); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.danger {
  min-height: 48px; border: 0; color: #fff;
  background: linear-gradient(135deg, #f43f5e, #dc2626);
  box-shadow: 0 14px 30px -14px rgba(244, 63, 94, 0.95);
}
.btn.danger:hover { filter: brightness(1.1); background: linear-gradient(135deg, #f43f5e, #dc2626); }
.fob { justify-content: center; background: transparent; border-style: dashed; color: var(--muted); }
.fob:hover { color: var(--text); }
.safety { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.safety .btn.ghost { min-height: 48px; }
.safety kbd { display: none; }

.quick { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 46px; height: 28px; flex: none; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); transition: background-color 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.switch-text { font-weight: 500; }
.inline { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.inline input { width: 84px; }
.inline .btn { margin-left: auto; }

/* ---------- Показатели: только главное ---------- */
.metrics { padding: 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.metric { position: relative; display: grid; gap: 2px; align-content: start; padding: 14px 16px 12px; border-radius: 18px; }
.metric .ic { display: none; }
.metric .k { color: var(--muted); font-size: 12.5px; }
.metric .v { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; order: 1; }
.metric:has(#m-cycles), .metric:has(#m-obstructions), .metric:has(#m-uptime) { display: none; }
.metric.wide { grid-column: auto; }
.metric.wide .v { font-size: 16px; font-weight: 600; padding-top: 3px; }
@media (max-width: 640px) { .metrics { grid-template-columns: 1fr 1fr; } .metric.wide { grid-column: 1 / -1; } }

/* ---------- Камера ---------- */
.cam-card { overflow: hidden; padding: 8px; }
.cam-head { display: flex; align-items: center; gap: 10px; padding: 8px 6px 10px 12px; }
.cam-head h2 { font-size: 15px; font-weight: 700; }
.cam-head > .ic { color: var(--muted); }
.cam-actions { margin-left: auto; display: flex; gap: 6px; }
.cam-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px 3px 9px;
  border-radius: 999px; background: var(--glass-2); color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.cam-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.cam-badge[data-state="live"] { color: var(--green); }
.cam-badge[data-state="live"]::before { animation: blink 1.6s ease-in-out infinite; }
.cam-badge[data-state="connecting"] { color: var(--yellow); }
.cam-badge[data-state="error"] { color: var(--red); }

.cam-view { position: relative; aspect-ratio: 16 / 9; border-radius: 20px; background: #05070d; overflow: hidden; }
.cam-view > img, .cam-view > video, .cam-view > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: contain; background: #05070d; }
.cam-view:fullscreen { aspect-ratio: auto; width: 100vw; height: 100vh; border-radius: 0; }

/* Свой «весь экран» (iPhone и браузеры без Fullscreen API): блок видео поверх страницы. */
.cam-view.cam-max {
  position: fixed; inset: 0; z-index: 1000; aspect-ratio: auto;
  width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; background: #000;
}
.cam-view.cam-max > img, .cam-view.cam-max > video, .cam-view.cam-max > iframe { background: #000; }
html.cam-max-open, html.cam-max-open body { overflow: hidden; overscroll-behavior: none; }
.cam-view.cam-max .ptz { top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); }
.cam-view.cam-max .cam-chip { left: calc(12px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); }
.cam-view.cam-max .cam-clock { right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); }
.cam-exit {
  position: absolute; z-index: 2; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left));
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(6, 9, 18, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff; font-size: 18px; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.cam-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center; color: #a3aec6;
  background: radial-gradient(520px 260px at 50% 0%, rgba(122, 162, 255, 0.22), transparent 70%), rgba(6, 9, 20, 0.88);
}
.cam-art { width: 64px; height: auto; margin-bottom: 4px; fill: none; stroke: #66728a; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.cam-art-lens { fill: #0b0e13; stroke: #94a0b8; }
.cam-art-glint { fill: #94a0b8; stroke: none; }
.cam-art-scan { stroke: #2b3340; stroke-dasharray: 4 6; }
.cam-empty-title { font-size: 17px; font-weight: 700; color: #f1f4fb; }
.cam-empty-text { max-width: 38ch; font-size: 13.5px; margin-bottom: 8px; }
.cam-overlay {
  position: absolute; bottom: 12px; padding: 5px 12px; border-radius: 999px;
  background: rgba(6, 9, 18, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff; font-size: 12px; font-weight: 500; pointer-events: none;
}
.cam-chip { left: 12px; }
.cam-clock { right: 12px; }

.cam-quality {
  height: 34px; padding: 0 28px 0 10px; border-radius: 11px; border: 1px solid var(--line-soft);
  background-color: var(--glass-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.cam-quality option { color: #111; }

/* Поворот и зум (PTZ): крестик и колонка зума поверх видео */
.ptz { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; align-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 38px); gap: 2px; }
.ptz-up { grid-area: 1 / 2; } .ptz-left { grid-area: 2 / 1; } .ptz-right { grid-area: 2 / 3; } .ptz-down { grid-area: 3 / 2; }
.ptz-zoom { display: grid; grid-template-rows: repeat(2, 38px); gap: 6px; }
.ptz-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(6, 9, 18, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff; font-size: 15px; font-weight: 600; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background-color 0.12s, transform 0.08s;
}
.ptz-zoom .ptz-btn { font-size: 20px; }
.ptz-btn:hover { background: rgba(6, 9, 18, 0.75); }
.ptz-btn.active { background: color-mix(in srgb, var(--accent) 70%, transparent); transform: scale(0.94); }
#btn-cam-ptz[aria-pressed="true"] { color: var(--accent-2); }
@media (max-width: 520px) {
  .ptz-pad { grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); }
  .ptz-zoom { grid-template-rows: repeat(2, 34px); }
  .ptz-btn { width: 34px; height: 34px; }
}

/* ---------- Разделы ---------- */
.workspace { max-width: 1160px; margin: 34px auto 0; padding: 0 18px; }
.tabs {
  display: inline-flex; gap: 4px; padding: 5px; max-width: 100%;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--line-soft);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border: 0; border-radius: 999px; background: none; color: var(--muted);
  font-weight: 600; font-size: 14.5px; white-space: nowrap; transition: background-color 0.15s, color 0.15s;
}
.tab .ic { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: #0a1020; background: #fff; box-shadow: 0 6px 18px -8px rgba(255, 255, 255, 0.6); }

.panel { display: none; margin-top: 14px; padding: 26px; }
.panel.is-active { display: block; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.panel h2 { font-size: 22px; font-weight: 750; letter-spacing: -0.025em; }
.panel h3 { font-size: 13.5px; font-weight: 650; color: var(--muted); margin: 28px 0 12px; }
.panel-head + h3, .panel-head + .fields { margin-top: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 16px 18px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 500; }
.field.wide { grid-column: 1 / -1; }
.field.check { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 44px; }
.field.check > span { color: var(--text); font-size: 15px; }

input, select {
  width: 100%; min-height: 44px; padding: 9px 14px;
  background: rgba(255, 255, 255, 0.09); border: 1px solid transparent; border-radius: 14px;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
select option { color: #0b1224; }
input::placeholder { color: rgba(235, 240, 255, 0.4); }
input:hover, select:hover { border-color: var(--line); }
input:focus, select:focus { outline: 0; border-color: var(--accent); background: rgba(255, 255, 255, 0.13); box-shadow: 0 0 0 4px rgba(122, 162, 255, 0.22); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent); }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); box-shadow: none; }
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.7; }
.head-actions select, .head-actions input { width: auto; min-height: 38px; padding: 5px 12px; }

.hint { color: var(--muted); font-size: 13.5px; margin-top: 16px; max-width: 78ch; }
.hint code, .panel code { padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); font-size: 0.92em; }
.status-line { margin-top: 20px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.status-line .k { color: var(--muted); font-size: 13px; }
.status-line .v { font-weight: 650; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.test-result { margin-top: 16px; padding: 11px 15px; border-radius: 14px; border: 1px solid var(--line); max-width: 78ch; }
.test-result.ok { color: var(--green); border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.1); }
.test-result.err { color: var(--red); border-color: rgba(251, 113, 133, 0.5); background: rgba(251, 113, 133, 0.1); }

/* Расписание */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
td { padding: 14px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
td.time { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
tr.off td { opacity: 0.5; }
tr.off td.actions { opacity: 1; }
.act-open { color: var(--green); font-weight: 650; }
.act-close { color: var(--accent); font-weight: 650; }
.chips span { display: inline-block; padding: 1px 8px; margin-right: 3px; border-radius: 7px; background: rgba(255, 255, 255, 0.1); color: var(--muted); font-size: 12.5px; }
.chips span.on { background: var(--accent); color: #0a1020; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button {
  width: 34px; height: 34px; margin-left: 4px; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.09);
}
td.actions button .ic { width: 16px; height: 16px; }
td.actions button:hover { border-color: var(--accent); }
td.actions button.danger:hover { border-color: var(--red); color: var(--red); }
.empty-row { color: var(--muted); padding: 24px 12px; }

.sched-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }
.sched-form input, .sched-form select { width: auto; }
.sched-form #sc-label { flex: 1 1 240px; }
.days { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.days span { display: block; padding: 8px 15px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); font-weight: 500; }
.days input:checked + span { background: #fff; color: #0a1020; }
.days input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

@media (max-width: 720px) {
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { padding: 14px 16px; margin-bottom: 10px; border-radius: 18px; background: rgba(255, 255, 255, 0.07); }
  td { border: 0; padding: 3px 0; }
  td.time { font-size: 26px; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12.5px; }
  td.time::before, td.actions::before { content: none; }
  td.actions { text-align: left; padding-top: 10px; }
  td.actions button { margin: 0 6px 0 0; }
  .panel { padding: 20px 16px; }
}

/* Журнал */
.log { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; border-radius: 18px; background: rgba(255, 255, 255, 0.06); }
.log li { display: grid; grid-template-columns: 70px 120px minmax(0, 1fr); gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.log li:last-child { border-bottom: 0; }
.log li.warn { background: rgba(251, 191, 36, 0.1); }
.log li.alarm { background: rgba(251, 113, 133, 0.15); }
.log li.empty { display: block; color: var(--muted); padding: 24px 16px; }
.log .t, .log .k { color: var(--muted); }
.log li.alarm .k { color: var(--red); }
.log li.warn .k { color: var(--yellow); }
@media (max-width: 640px) { .log li { grid-template-columns: 62px minmax(0, 1fr); } .log .k { display: none; } }

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px); max-width: min(92vw, 520px);
  padding: 13px 20px; border-radius: 999px; border: 0;
  background: #fff; color: #0a1020; font-weight: 600;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #e11d48; color: #fff; }
.toast.ok { background: var(--green); color: #04130c; }

/* ---------- PIN ---------- */
.pin-dialog {
  width: min(92vw, 360px); padding: 28px 24px 24px; color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--line); border-radius: 30px; box-shadow: var(--shadow);
  backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px);
}
.pin-dialog::backdrop { background: rgba(3, 6, 14, 0.7); backdrop-filter: blur(6px); }
.pin-dialog form { display: grid; gap: 12px; text-align: center; }
.pin-dialog .ic { justify-self: center; color: var(--accent-2); width: 28px; height: 28px; }
.pin-dialog h2 { font-size: 22px; font-weight: 750; }
.pin-dialog p { color: var(--muted); font-size: 14px; }
.pin-dialog input { text-align: center; font-size: 20px; letter-spacing: 0.08em; }
.pin-dialog .pin-error { color: var(--red); min-height: 1.2em; }
.pin-dialog .row-actions { justify-content: center; margin-top: 0; }

footer { max-width: 1160px; margin: 30px auto 0; padding: 16px 18px 34px; color: var(--muted); font-size: 12.5px; }

/* Аварийный стоп: рамка вокруг страницы */
body.estop::before { content: ""; position: fixed; inset: 0; border: 4px solid var(--red); pointer-events: none; z-index: 40; }

@media (max-width: 480px) {
  .layout, .workspace { padding-inline: 14px; }
  .scene-card { padding: 20px 18px 16px; }
  .controls { padding: 20px 14px 16px; }
  .pad .ic { width: 76px; height: 76px; padding: 23px; }
  .pad kbd { display: none; }
  .safety { grid-template-columns: 1fr; }
  .state { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
