:root {
  --bg: #0E1114; --panel: #151A1F; --panel-2: #1A2026; --line: #252C34; --line-2: #2A3139;
  --text: #E7EAEE; --muted: #8C96A3; --dim: #6B7581;
  --accent: #F2B23A; --accent-ink: #1A1206; --ok: #3FB97C; --err: #FF8A80; --rec: #D6453D;
  --a-bg: #F4F5F7; --a-panel: #FFFFFF; --a-line: #DDE1E7; --a-text: #1B2027; --a-muted: #5B6573;
  --font: 'IBM Plex Sans', system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- темна тема: вхід і пульт */
body.dark { background: var(--bg); color: var(--text); }
.dark a { color: var(--accent); }
.dark input { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 12px; color: var(--text); width: 100%; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: #A3241C; border-color: #E8B7B3; background: #fff; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 0; }
.err { color: var(--err); }
.light .err { color: #A3241C; }

.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth .side { flex: 1 1 440px; background: #12161A; border-right: 1px solid var(--line); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth .side h1 { margin: 0; font-size: 38px; line-height: 1.15; font-weight: 600; max-width: 460px; }
.auth .side p { color: var(--muted); font-size: 16px; max-width: 460px; }
.auth .main { flex: 1 1 440px; display: grid; place-items: center; padding: 40px 20px; }
.auth form { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth h2 { margin: 0; font-size: 24px; }
.auth label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #B5BDC7; }
.auth .row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.auth .sep { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; }
.auth .sep::before, .auth .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.code-input { font-family: var(--mono) !important; font-size: 18px !important; letter-spacing: 3px; text-transform: uppercase; }
/* маска кодів: комплекс — бурштиновий, користувач — синій */
.code-mask { position: relative; display: block; }
.code-mask input { width: 100%; box-sizing: border-box; }
.code-ghost { position: absolute; inset: 0; display: flex; align-items: center; pointer-events: none; color: #4A525C; white-space: pre; overflow: hidden; text-transform: uppercase; }
.code-ghost i { font-style: normal; color: transparent; }
.code-mask[data-kind="complex"] input { border-color: #D9A441 !important; box-shadow: 0 0 0 1px #D9A441; }
.code-mask[data-kind="user"] input { border-color: #5B8DEF !important; box-shadow: 0 0 0 1px #5B8DEF; }
.code-mask[data-kind="bad"] input { border-color: #E5534B !important; box-shadow: 0 0 0 1px #E5534B; }
.code-mask[data-kind="user"] input:focus-visible { outline-color: #5B8DEF; }
.code-mask[data-kind="bad"] input:focus-visible { outline-color: #E5534B; }
.code-hint { font-size: 12px; color: var(--muted); min-height: 1.3em; margin-top: -2px; }
.code-hint[data-kind="complex"] { color: #E3B65A; }
.code-hint[data-kind="user"] { color: #7FA8F5; }
.code-hint[data-kind="bad"] { color: #FF7B72; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .5px; color: inherit; text-decoration: none; }
.logo b { color: var(--accent); font-weight: 700; }

/* ---------- пульт */
.pult { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.seg { display: flex; gap: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { min-width: 44px; min-height: 34px; padding: 0 10px; border-radius: 7px; border: 0; background: transparent; color: #B5BDC7; font-family: var(--mono); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.body { flex: 1; display: flex; flex-wrap: wrap; min-height: 0; }
.list { flex: 1 1 240px; max-width: 280px; background: #12161A; border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.cap { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.cam-row { display: flex; align-items: center; border-radius: 10px; }
.cam-row.sel { background: #1F262E; box-shadow: inset 0 0 0 1px var(--accent); }
.cam-row .pick { flex: 1; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; text-align: left; padding: 8px 4px 8px 10px; min-height: 44px; }
.cam-row .x { width: 36px; min-height: 44px; background: none; border: 0; color: var(--dim); border-radius: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.dot.on { background: var(--ok); }
.sub { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.add { min-height: 44px; border: 1px dashed #3A434D; background: transparent; color: var(--accent); border-radius: 10px; font-weight: 600; }
.hint { margin: 0; font-size: 12px; color: var(--dim); }
.stage { flex: 999 1 560px; min-width: 0; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 10px; }
.tile { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #07090B; border: 2px solid #1F262E; }
.tile.sel { border-color: var(--accent); }
.tile.focus { aspect-ratio: auto; flex: 1; min-height: 420px; }
.tile video-stream, .tile video { width: 100%; height: 100%; display: block; }
.tile video { object-fit: contain; background: #07090B; }
.tile .label { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; pointer-events: none; z-index: 2; }
.tile .label span { background: rgba(10,12,14,.8); border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.tile .label .rec { background: var(--rec); color: #fff; font-family: var(--mono); font-weight: 600; }
.tile .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 12px; z-index: 1; }
.tile .tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; z-index: 2; }
.tile .tools button { width: 36px; height: 36px; border-radius: 8px; border: 0; background: rgba(10,12,14,.8); color: var(--text); display: grid; place-items: center; }
.tile .hit { position: absolute; inset: 0; background: transparent; border: 0; z-index: 1; }
.ctrl { flex: 1 1 280px; max-width: 320px; background: #12161A; border-left: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.pad { display: grid; grid-template-columns: repeat(3, 52px); grid-auto-rows: 44px; gap: 5px; justify-content: center; user-select: none; touch-action: none; }
.pad button { min-height: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 18px; padding: 0; }
.pad button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pad .stop { font-size: 11px; font-weight: 700; background: #2A1E0A; color: var(--accent); }
.seg2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg2 button { min-height: 36px; border: 0; background: var(--panel-2); color: #B5BDC7; }
.seg2 button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.recbtn { min-height: 40px; border-radius: 10px; font-weight: 600; background: transparent; color: var(--err); border: 1px solid #6A2A26; display: flex; align-items: center; justify-content: center; gap: 10px; }
.recbtn.on { background: var(--rec); color: #fff; border-color: var(--rec); }
.recbtn i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.status { font-size: 12px; min-height: 1.4em; color: var(--muted); }
.status.err { color: var(--err); }
input[type=range] { width: 100%; accent-color: var(--accent); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; padding: 24px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(5,7,9,.72); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 18px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 900px) { .list, .ctrl { max-width: none; } }

/* ---------- профіль */
.account { width: min(720px, 100%); margin: 0 auto; padding: 28px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.account h1 { margin: 0; font-size: 26px; font-weight: 600; }
.acc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.acc-card h2 { margin: 0; font-size: 17px; }
.acc-form { display: flex; flex-direction: column; gap: 14px; }
.acc-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #B5BDC7; }
.acc-form .row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.facts > div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.acc-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-actions form { margin: 0; }
@media (max-width: 560px) { .acc-form .row2, .facts { grid-template-columns: 1fr; } }

/* ---------- бокова панель профілю */
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(440px, 100vw); border-radius: 0; border: 0; border-left: 1px solid var(--line-2); padding: 0; background: #12161A; overflow-y: auto; }
dialog.drawer[open] { display: flex; flex-direction: column; gap: 14px; padding: 18px; animation: slide-in .22s ease-out; }
dialog.drawer::backdrop { background: rgba(5,7,9,.55); }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.drawer[open] { animation: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 20px; }
.x-close { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--text); font-size: 16px; }
.drawer .acc-card { padding: 16px; gap: 12px; }
.drawer h3 { margin: 0; font-size: 15px; }
.form-msg { font-size: 13px; min-height: 1.2em; color: var(--ok); }
.form-msg.err { color: var(--err); }

/* ---------- світла тема: адмінка */
body.light { background: var(--a-bg); color: var(--a-text); }
.light a { color: #8A5A00; }
.admin { min-height: 100vh; display: flex; flex-wrap: wrap; }
.admin > nav { flex: 1 1 220px; max-width: 240px; background: #151A1F; color: var(--text); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.admin > nav a { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 8px; color: #B5BDC7; text-decoration: none; }
.admin > nav a[aria-current="page"] { background: #2A3139; color: #fff; font-weight: 600; }
.admin > nav .to-pult { margin-top: auto; color: var(--accent); }
.admin > nav form { margin: 0; }
.admin > nav .logout { width: 100%; text-align: left; min-height: 40px; padding: 0 12px; border-radius: 8px; background: none; border: 0; color: #B5BDC7; }
.admin main { flex: 999 1 560px; min-width: 0; padding: 24px 28px; display: flex; flex-direction: column; gap: 18px; }
.admin h1 { margin: 0; font-size: 26px; font-weight: 600; }
.admin h2 { margin: 0 0 10px; font-size: 18px; }
.card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: 12px; padding: 18px; }
.light input, .light select, .light textarea { border: 1px solid #D5DAE1; border-radius: 8px; padding: 9px 10px; background: #fff; color: var(--a-text); }
.light .btn { background: #fff; border-color: #D5DAE1; color: var(--a-text); min-height: 40px; }
.light .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.light .btn.dark { background: #1B2027; border-color: #1B2027; color: #fff; }
.light .btn.danger { color: #A3241C; border-color: #E8B7B3; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #3D4652; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--a-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; padding: 10px 12px; }
td { padding: 10px 12px; border-top: 1px solid #EEF0F3; vertical-align: middle; }
td form { display: inline; margin: 0; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #EEF0F3; color: #3D4652; white-space: nowrap; }
.badge.ok { background: #E3F4EA; color: #1D6B43; }
.badge.wait { background: #FFF1D6; color: #7A4F00; }
.badge.bad { background: #FBE3E1; color: #A3241C; }
.code { font-family: var(--mono); letter-spacing: 1.5px; background: #FFFBF0; border: 1px dashed #C9A45A; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.code.user { background: #EEF4FF; border-color: #5B8DEF; color: #1F4FB0; }
.flash { background: #FFF8E6; border: 1px solid #F0D9A4; border-radius: 10px; padding: 12px 14px; font-weight: 500; }
.dark .flash { background: #2A1E0A; border-color: #5A4316; color: var(--text); }
.muted { color: var(--a-muted); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.flash { white-space: pre-line; }
.setup-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.setup-form > label, .setup-step .form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #3D4652; }
.setup-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.setup-form legend { font-size: 13px; color: #3D4652; margin-bottom: 6px; }
.radio { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--a-line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.radio:has(input:checked) { border-color: #F0D9A4; background: #FFF8E6; }
.radio input { accent-color: #C98A12; margin-top: 3px; }
.setup-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.setup-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.stepper li, .stepper a { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 12px; border-radius: 10px; background: #fff; border: 1px solid var(--a-line); color: #3D4652; text-decoration: none; }
.stepper li:has(a) { padding: 0; border: 0; background: none; }
.stepper a { flex: 1; }
.stepper span { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #EEF0F3; }
.stepper .done span, .stepper li.done:not(:has(a)) span { background: #E3F4EA; color: #1D6B43; }
.stepper .view a { background: #1B2027; color: #fff; border-color: #1B2027; font-weight: 600; }
.stepper .view span { background: #F2B23A; color: #1A1206; }
@media (max-width: 760px) { .stepper { grid-template-columns: 1fr; } }
.setup-step { display: flex; flex-direction: column; gap: 14px; }
.setup-step h3 { margin: 6px 0 0; font-size: 15px; }
.howto { margin: 0; padding-left: 20px; line-height: 1.8; }
.live { display: flex; flex-direction: column; gap: 8px; }
.live-row { display: flex; align-items: center; gap: 10px; border: 1px solid #EEF0F3; border-radius: 10px; padding: 10px 12px; }
.live-row .muted { margin-left: auto; }
.light .dot { background: #C9CFD8; }
.light .dot.on { background: #1D6B43; }
.snap { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.snap img { max-width: 520px; width: 100%; border-radius: 10px; border: 1px solid var(--a-line); background: #0E1114; }
.snap figcaption { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--a-muted); }
/* майстер: зліва кроки, справа ілюстрація */
.setup-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.setup-main { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.illus { flex: 1 1 380px; min-width: 0; position: sticky; top: 16px; }
.setup-main .setup-form { max-width: none; }
.wiring .screen { fill: #EAF1FB; stroke: #9FB9E4; }
.tip { display: block; background: #FFF8E6; border: 1px solid #F0D9A4; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #5E3D00; }
.cam-wizard { border: 1px solid var(--a-line); border-radius: 12px; background: #FAFBFC; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cw-title { font-weight: 600; }
.cam-wizard ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cam-wizard li { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #EEF0F3; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.cw-n { width: 22px; height: 22px; flex: none; border-radius: 50%; background: #1B2027; color: #F2B23A; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.cw-act { margin-left: auto; font-family: var(--mono); font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #EEF0F3; color: #3D4652; white-space: nowrap; }
.cw-act.ok { background: #E3F4EA; color: #1D6B43; }
.cw-act.no { background: #FBE3E1; color: #A3241C; }
.cw-act.key { background: #FFF1D6; }

.step-nav { display: flex; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--a-muted); text-decoration: underline; cursor: pointer; font-size: 13px; }
.rebuild { margin: 0; }
.link-btn.danger-link { color: #A3241C; }
.building { display: flex; gap: 14px; align-items: center; background: #FFF4D6; border: 2px solid #F2B23A; border-radius: 12px; padding: 14px 16px; color: #3D2A00; }
.building .spinner { width: 24px; height: 24px; border-width: 3px; color: #B07A00; }
.building b { display: block; }
.building.sm { padding: 8px 10px; border-width: 1px; gap: 8px; font-size: 13px; }
.building.sm .spinner { width: 16px; height: 16px; border-width: 2px; }
.flasher { display: flex; flex-direction: column; gap: 12px; }
.fsteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fsteps > li { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--a-line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.fsteps > li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fsteps > li { transition: opacity .2s, transform .2s; }
.fsteps > li.active { border: 2px solid #F2B23A; box-shadow: 0 0 0 4px #FFF1D6; transform: scale(1.01); animation: pulse-ring 1.8s ease-in-out infinite; }
.fsteps > li.active > div > b { font-size: 17px; }
.fsteps > li.needs-you.active > div > b::before { content: "👉 Зробіть зараз"; display: block; width: max-content; margin-bottom: 6px; padding: 2px 10px; border-radius: 999px; background: #F2B23A; color: #1A1206; font-size: 12px; }
.fsteps > li.done { padding: 8px 14px; }
.fsteps > li.done > div > :not(b) { display: none; }
.fsteps > li:not(.active):not(.done):not(.error) { opacity: .55; }
.attention { animation: pulse-ring 1.2s ease-in-out 4; }
@keyframes pulse-ring { 0%, 100% { box-shadow: 0 0 0 4px #FFF1D6; } 50% { box-shadow: 0 0 0 9px #FFE3A3; } }
@media (prefers-reduced-motion: reduce) { .fsteps > li.active, .attention { animation: none; } .fsteps > li.active { transform: none; } }
.fsteps > li.done { background: #F3FAF6; border-color: #A9D8BD; }
.fsteps > li.error { background: #FDF2F1; border-color: #E8B7B3; }
.fsteps .st { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #EEF0F3; color: #3D4652; }
.fsteps li.active .st { background: none; color: #B07A00; }
.fsteps li.done .st { background: #1D6B43; color: #fff; }
.fsteps li.error .st { background: #C2382F; color: #fff; }
.fsteps .checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fsteps .checks li { display: flex; gap: 8px; align-items: center; }
.fsteps .checks .muted { margin-left: auto; }
.step-note:empty { display: none; }
.bar { height: 10px; border-radius: 5px; background: #EEF0F3; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: #F2B23A; transition: width .3s; }

.fallback { border: 1px solid var(--a-line); border-radius: 10px; padding: 10px 12px; background: #FAFBFC; }
.fallback summary { cursor: pointer; font-weight: 600; }
.invite-box { border: 1px dashed #C9CFD8; border-radius: 12px; padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; background: #FAFBFC; }
.invite-box b { display: block; margin-bottom: 2px; }
.instr { display: flex; flex-direction: column; gap: 12px; border-color: #F0D9A4; background: #FFFBF0; }
.qr-dlg { width: min(440px, calc(100% - 32px)); background: #fff; color: var(--a-text); border: 1px solid var(--a-line); border-radius: 14px; padding: 20px; }
.qr-dlg[open] { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.qr-dlg::backdrop { background: rgba(15,17,20,.55); }
.qr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qr-head h2 { margin: 0; font-size: 18px; }
.qr-dlg .x-close { color: var(--a-text); border-color: var(--a-line); }
.qr-dlg #qrImg { align-self: center; width: 300px; max-width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--a-line); border-radius: 10px; padding: 8px; background: #fff; }
.qr-dlg .form-msg { color: #1D6B43; }
.qr { position: relative; }
.qr summary { list-style: none; cursor: pointer; }
.qr summary::-webkit-details-marker { display: none; }
.qr img { position: absolute; right: 0; top: 46px; z-index: 5; width: 260px; height: 260px; background: #fff; border: 1px solid var(--a-line); border-radius: 10px; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); image-rendering: pixelated; }
.result { border-radius: 10px; padding: 12px 14px; border: 1px solid; }
.result.ok { background: #E3F4EA; border-color: #A9D8BD; color: #14532D; }
.result.bad { background: #FBE3E1; border-color: #E8B7B3; color: #7F1D1D; }
.result ul { margin: 6px 0 0; padding-left: 0; list-style: none; line-height: 1.7; }
.callout { display: flex; gap: 14px; align-items: flex-start; background: #FFF4D6; border: 2px solid #F2B23A; border-radius: 12px; padding: 14px 16px; color: #3D2A00; }
.callout svg { flex: none; color: #B07A00; margin-top: 2px; }
.callout b { display: block; font-size: 17px; line-height: 1.35; }
.callout span { display: block; margin-top: 4px; font-size: 13px; color: #5E3D00; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.btn.loading { cursor: progress; opacity: .85; }
.spinner.sm { width: 12px; height: 12px; vertical-align: -1px; }
.light .dot.bad { background: #C2382F; }
.snap-ph { aspect-ratio: 16 / 9; max-width: 520px; display: grid; place-items: center; border: 2px dashed #C9CFD8; border-radius: 10px; color: var(--a-muted); text-align: center; padding: 12px; }
.light .btn.big { min-height: 52px; padding: 0 22px; font-size: 16px; font-weight: 600; border-radius: 12px; box-shadow: 0 2px 0 #C98A12; }
.light .btn.big:hover { filter: brightness(1.05); }
.light .btn.big:active { transform: translateY(1px); box-shadow: none; }

/* схема підключення */
.wiring { margin: 0; border: 1px solid var(--a-line); border-radius: 12px; background: #FAFBFC; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; max-width: 820px; }
.wiring svg { width: 100%; height: auto; }
.wiring .box { fill: #fff; stroke: #C9CFD8; stroke-width: 1.5; }
.wiring .box.main { stroke: #1B2027; stroke-width: 2; }
.wiring .t { font: 600 14px var(--font); fill: #1B2027; text-anchor: middle; }
.wiring .t.big { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.wiring .s { font: 11px var(--font); fill: #5B6573; text-anchor: middle; }
.wiring .p { font: 600 12px var(--mono); fill: #fff; text-anchor: middle; }
.wiring .p.sm { font-size: 10px; }
.wiring .port.wan { fill: #2B6FD6; }
.wiring .port.lan { fill: #1D6B43; }
.wiring .port.poe { fill: #C98A12; }
.wiring .wire { fill: none; stroke: #1B2027; stroke-width: 3; stroke-linecap: round; }
.wiring .poe-wire { stroke: #C98A12; }
.wiring .wifi { fill: none; stroke: #2B6FD6; stroke-width: 2.5; stroke-dasharray: 6 6; }
.wiring .w { font: 11px var(--font); fill: #3D4652; text-anchor: middle; }
.wiring figcaption ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.wiring[data-uplink="cable"] .wifi-only { display: none; }
.wiring[data-uplink="wifi"] .cable-only { display: none; }
.wiring[data-hw="mango"] .hw-r2s, .wiring[data-hw="r2s"] .hw-mango { display: none; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--a-line); background: #fff; color: var(--a-text); text-decoration: none; }
.tabs a span { font-family: var(--mono); font-size: 12px; color: var(--a-muted); }
.tabs a[aria-current="page"] { background: #1B2027; border-color: #1B2027; color: #fff; font-weight: 600; }
.tabs a[aria-current="page"] span { color: #F2B23A; }

/* картка покупця: пристрої VPN у таблиці користувачів */
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.dev { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 4px 0; }
.dev + .dev { border-top: 1px dashed #E3E7EC; }
.users-tbl td { vertical-align: top; }
.copy-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: 4px; vertical-align: middle; border: 1px solid #D5DAE1; border-radius: 8px; background: #fff; color: #5A6470; cursor: pointer; }
.copy-btn:hover { color: #111; border-color: #9AA4B0; }
.copy-btn.done { color: #1E7B3C; border-color: #1E7B3C; background: #EAF7EE; }
.copy-btn.done svg { display: none; }
.copy-btn.done::after { content: "✓"; font-weight: 700; }

/* підтвердження дій (static/confirm.js) */
dialog.confirm-dlg { width: min(440px, calc(100% - 32px)); padding: 24px; display: none; }
dialog.confirm-dlg[open] { display: flex; flex-direction: column; gap: 10px; animation: cf-in .14s ease-out; }
dialog.confirm-dlg h2 { margin: 0; font-size: 18px; line-height: 1.3; }
dialog.confirm-dlg p { margin: 0; color: var(--muted); line-height: 1.5; }
dialog.confirm-dlg .actions { margin-top: 12px; }
.cf-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 20px; background: #3A1D1B; color: #FF8A80; }
dialog.confirm-dlg[data-tone="primary"] .cf-icon { background: #3A2F12; color: var(--accent); }
.btn.danger-fill { background: #C8352B; border-color: #C8352B; color: #fff; font-weight: 600; }
.light dialog.confirm-dlg { background: #fff; color: var(--a-text); border-color: var(--a-line); box-shadow: 0 20px 50px rgba(15, 20, 25, .25); }
.light dialog.confirm-dlg::backdrop { background: rgba(20, 25, 32, .45); }
.light dialog.confirm-dlg p { color: var(--a-muted); }
.light .cf-icon { background: #FDECEA; color: #C8352B; }
.light dialog.confirm-dlg[data-tone="primary"] .cf-icon { background: #FFF4D6; color: #9A6B00; }
.light .btn.danger-fill { background: #C8352B; border-color: #C8352B; color: #fff; }
@keyframes cf-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.confirm-dlg[open] { animation: none; } }

/* збережений пароль камери */
.pw-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 6px; }
.pw-box { display: inline-flex; align-items: center; gap: 6px; }
.pw-val { min-width: 96px; padding: 3px 8px; border: 1px solid var(--a-line); border-radius: 6px; background: #F7F8FA; letter-spacing: 1px; user-select: all; }
.pw-val.shown { background: #FFFBF0; border-color: #C9A45A; }
.pw-change { margin-top: 6px; font-size: 13px; }
.pw-change summary { cursor: pointer; color: var(--a-muted); width: max-content; }
.pw-change summary:hover { color: var(--a-text); }

/* вікно «Інструкція» — підключення пристрою оператора через Tailscale */
.ts-dlg { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.ts-facts { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--a-line); border-radius: 10px; background: #F7F8FA; }
.ts-facts > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ts-facts > div > .muted:first-child { min-width: 118px; font-size: 13px; }
.ts-facts .code { white-space: normal; word-break: break-all; }
.ts-key { font-size: 12px; }
.ts-tabs button { min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--a-line); background: #fff; color: var(--a-text); cursor: pointer; }
.ts-tabs button[aria-selected="true"] { background: #1B2027; border-color: #1B2027; color: #fff; font-weight: 600; }
.ts-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.ts-steps li.cmd { list-style: none; margin-left: -22px; display: flex; gap: 6px; align-items: flex-start; }
.ts-steps code { flex: 1; display: block; padding: 8px 10px; border-radius: 8px; background: #1B2027; color: #E8ECF1; font: 12px/1.5 var(--mono); word-break: break-all; }
.ts-approve { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed #C9A45A; border-radius: 10px; background: #FFFBF0; }
.ts-approve label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ts-approve[hidden] { display: none; }

/* пряме підключення до камер: картка покупця і вікно в пульті */
.direct-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.direct-row > div { flex: 1 1 420px; }
dialog.direct-dlg { width: min(560px, calc(100% - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
dialog.direct-dlg[open] { display: flex; flex-direction: column; gap: 10px; }
dialog.direct-dlg h3 { margin: 12px 0 4px; font-size: 14px; }
.direct-facts { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; }
.direct-facts > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.direct-facts dt { color: var(--muted); font-size: 13px; }
.direct-facts dd { margin: 0; display: flex; align-items: center; gap: 6px; }
.direct-steps { margin: 0; padding-left: 20px; line-height: 1.6; }
.direct-url { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }
.direct-url code { flex: 1; padding: 8px 10px; border-radius: 8px; background: #0B0E11; border: 1px solid var(--line-2); font: 12px/1.5 var(--mono); word-break: break-all; }
.direct-dlg .copy-btn { background: transparent; border-color: var(--line-2); color: var(--muted); }
.direct-dlg .btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }

/* кабінет власника */
.team-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--a-line); }
.team-nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.team-nav form { margin: 0; }
.team { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.team h1 { margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--a-line); border-radius: 999px; padding: 4px 12px; background: #F7F8FA; font-size: 13px; }
.cams { border: 1px solid var(--a-line); border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0; }
.cams legend { font-size: 13px; color: var(--a-muted); padding: 0 4px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.cams-form { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.light .code-input { background: #fff; color: var(--a-text); }

/* публічна сторінка: пристрій підключено / інструкція */
.start-done { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.start-done h1 { margin: 8px 0 0; font-size: 26px; }
.sd-card { border: 1px solid var(--line-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--panel); }
.sd-facts { display: flex; flex-direction: column; gap: 10px; }
.sd-facts > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.sd-facts code, .sd-plat code { font: 13px/1.5 var(--mono); background: #0B0E11; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
.sd-key { font-size: 12px !important; }
.sd-plat { border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; }
.sd-plat summary { cursor: pointer; font-weight: 600; }
.sd-plat ol { padding-left: 20px; line-height: 1.6; }
.sd-plat li.cmd { list-style: none; margin-left: -20px; display: flex; gap: 6px; align-items: flex-start; }
.sd-plat li.cmd code { flex: 1; }
.sd-approve { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed #C9A45A; border-radius: 10px; }
.sd-approve label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.start-done .copy-btn { background: transparent; border-color: var(--line-2); color: var(--muted); }
.danger-zone { border-color: #E8B7B3; }
.danger-zone h2 { color: #A3241C; }
.cn-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; line-height: 1.6; }
.cn-steps .btn { margin: 6px 0 2px; }
.btn.disabled { opacity: .4; pointer-events: none; }

.ts-link { display: flex; gap: 6px; align-items: flex-start; }
.ts-link code { flex: 1; padding: 8px 10px; border-radius: 8px; background: #1B2027; color: #E8ECF1; font: 12px/1.5 var(--mono); word-break: break-all; }
.ts-ref summary { cursor: pointer; font-size: 13px; color: var(--a-muted); }
.start-done .ts-ref summary { color: var(--muted); }
.ts-ref .ts-facts, .ts-ref .sd-facts { margin-top: 8px; }

.cn-state { margin: 8px 0; padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.cn-state.ok { background: #12301F; color: #6FE3A0; border: 1px solid #1E7B3C; }
.cn-state.wait { background: #2A2412; color: #F2B23A; border: 1px solid #5A4A1A; }
.cn-state.bad { background: #3A1D1B; color: #FF8A80; border: 1px solid #7A2E28; }
.taskbar { margin: 10px 0 0; max-width: 520px; }
.taskbar figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.device-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 18px; background: #2A2412; color: #F2D79A; border-bottom: 1px solid #5A4A1A; font-size: 13px; }
.device-hint form { margin: 0; }

/* кабінет: комплекси — рівні рядки і окремий блок «Додати комплекс» */
.cx-list { display: flex; flex-direction: column; }
.cx-row { display: grid; grid-template-columns: max-content minmax(0, 420px) auto; justify-content: start; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--a-line); }
.cx-row:first-child { border-top: 1px solid var(--a-line); }
.cx-serial { font-weight: 600; }
.cx-row input, .cx-add input { height: 42px; box-sizing: border-box; width: 100%; }
.cx-row .btn, .cx-add .btn { min-height: 42px; }
.cx-add { margin-top: 18px; padding: 16px; border: 1px solid var(--a-line); border-radius: 12px; background: #FAFBFC; }
.cx-add h3 { margin: 0 0 12px; font-size: 15px; }
.cx-add-grid { display: grid; grid-template-columns: minmax(200px, 240px) minmax(0, 320px) auto; justify-content: start; gap: 12px; align-items: start; }
.cx-add .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--a-muted); }
.cx-add .code-input { font-size: 16px !important; letter-spacing: 2px; }
.cx-add .code-hint { font-size: 12px; }
@media (max-width: 720px) {
  .cx-row { grid-template-columns: minmax(0, 1fr) auto; justify-content: stretch; }
  .cx-row .cx-serial { grid-column: 1 / -1; }
  .cx-add-grid { grid-template-columns: 1fr; justify-content: stretch; }
  .cx-add .field > span[aria-hidden] { display: none; }
}
.go-links { display: flex; flex-wrap: wrap; gap: 8px; }
.go #checking { max-width: 420px; }

/* кабінет: «Новий оператор» у спливаючому вікні */
dialog.op-dlg { width: min(460px, calc(100% - 32px)); padding: 24px; }
dialog.op-dlg[open] { animation: cf-in .14s ease-out; }
dialog.op-dlg .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
dialog.op-dlg .cams { margin: 0; }
dialog.op-dlg .actions { margin-top: 4px; }
.light dialog.op-dlg { background: #fff; color: var(--a-text); border-color: var(--a-line); box-shadow: 0 20px 50px rgba(15, 20, 25, .25); }
.light dialog.op-dlg::backdrop { background: rgba(20, 25, 32, .45); }
.light dialog.op-dlg .field { color: var(--a-muted); }
@media (prefers-reduced-motion: reduce) { dialog.op-dlg[open] { animation: none; } }

/* прямe підключення комплексу (P2P) */
.p2p-tag { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 600; line-height: 1.6; vertical-align: 1px; }
.p2p-tag.on { background: #12301F; color: #6FE3A0; border: 1px solid #1E7B3C; }
.p2p-tag.off { background: #3A1D1B; color: #FF8A80; border: 1px solid #7A2E28; }
.badge.p2p { margin-left: 4px; }

/* адмінка: детекція на камері */
.det { display: flex; flex-direction: column; gap: 16px; }
.det-msg { padding: 10px 12px; border-radius: 10px; background: #FFF1D6; color: #7A4F00; font-weight: 600; margin-bottom: 12px; }
.det-msg.bad { background: #FBE3E1; color: #A3241C; }
.det-smd { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.det-smd .chk { font-size: 14px; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.det-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.det-frame { position: relative; border-radius: 10px; overflow: hidden; background: #0B0E11; aspect-ratio: 16 / 9; }
.det-frame img, .det-frame svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.det-frame img { object-fit: fill; }
.det-frame svg { cursor: crosshair; }
.det-refresh { position: absolute; right: 8px; bottom: 8px; }
.det-rules { display: flex; flex-direction: column; gap: 10px; }
.det-rule { border: 1px solid var(--a-line); border-left: 4px solid var(--c); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; background: #fff; }
.det-rule.cur { box-shadow: 0 0 0 2px var(--c); }
.det-rule-head, .det-rule-body { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.det-rule .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.det-rule .nm { flex: 1; min-width: 120px; }
.det-rule .rm { margin-left: auto; }
.det-rule .pts { font-size: 12px; flex-basis: 100%; }
.det-add { display: flex; gap: 8px; }
.det-save { display: flex; gap: 12px; align-items: center; }
@media (max-width: 900px) { .det-grid { grid-template-columns: 1fr; } }

/* пульт: події камер */
.ev-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--rec); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tile.alarm { border-color: var(--rec); animation: alarm-pulse 1s ease-in-out infinite; }
.tile .label .alarm-tag { background: var(--rec); color: #fff; font-weight: 700; }
.cam-row.alarm { box-shadow: inset 0 0 0 1px var(--rec); background: #2A1716; }
@keyframes alarm-pulse { 50% { box-shadow: 0 0 0 3px rgba(214, 69, 61, .45); } }
@media (prefers-reduced-motion: reduce) { .tile.alarm { animation: none; } }
.ev-list { display: flex; flex-direction: column; gap: 8px; }
.ev-item { display: flex; gap: 10px; align-items: center; text-align: left; background: #1A1F25; border: 1px solid var(--line); border-left: 3px solid var(--rec); border-radius: 10px; padding: 6px; color: var(--text); }
.ev-item.ev-vehicle { border-left-color: #4EA8FF; }
.ev-item:hover { background: #222932; }
.ev-img { flex: 0 0 112px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #07090B; }
.ev-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-txt .sub { font-size: 12px; color: var(--muted); }

/* підказки клавіш */
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid #3A434D; border-bottom-width: 2px; border-radius: 5px; background: #1A1F25; color: var(--text); font: 600 11px/16px var(--mono); text-align: center; vertical-align: 1px; }
.btn kbd, .recbtn kbd { margin-left: 4px; opacity: .8; }
.tile .fs-keys { display: none; position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2; background: rgba(10,12,14,.75); color: var(--muted); font-size: 12px; padding: 5px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap; }
.tile:fullscreen .fs-keys { display: block; }
.tile:fullscreen { border: 0; border-radius: 0; }
.tile.snapped::after { content: "Знімок збережено"; position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none;
  background: rgba(255,255,255,.18); color: #fff; font-weight: 700; font-size: 15px; text-shadow: 0 1px 4px #000; animation: snap-flash .9s ease-out forwards; }
@keyframes snap-flash { to { opacity: 0; } }
.det-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.det-mode { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--a-line); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; }
.det-mode:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #FFFBF0; }
.det-mode input { margin-top: 3px; }
.det-mode span { display: flex; flex-direction: column; gap: 2px; }
.det-mode small { color: var(--a-muted); font-size: 12px; }
.det-off { opacity: .5; }
.det-off::before { content: "Неактивно в обраному режимі — налаштування збережуться, але не діятимуть"; display: block; font-size: 12px; color: var(--a-muted); margin-bottom: 8px; }
.pad-wrap { display: flex; justify-content: center; align-items: flex-start; gap: 10px; }
.pad-side { display: flex; flex-direction: column; gap: 5px; }
.pad-tool { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 20px; padding: 0; }
.pad-tool:hover, .pad button:hover { border-color: #3A434D; }
.pad-tool:disabled { opacity: .5; }
.direct-note { margin: 0 0 6px; padding: 8px 10px; border-radius: 8px; background: #2A2412; border: 1px solid #5A4A1A; color: #F2D79A; font-size: 13px; line-height: 1.5; }

#soundBtn.snd-on { background: #12301F; color: #6FE3A0; border-color: #1E7B3C; }
#soundBtn.snd-off { background: #3A1D1B; color: #FF8A80; border-color: #7A2E28; }
.snd-group { display: inline-flex; align-items: stretch; gap: 0; }
.snd-group #soundBtn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.snd-group select { min-height: 36px; border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; background: var(--panel-2); color: var(--text); padding: 0 8px; font-size: 13px; }
.btn.alarm-off { min-height: 36px; background: var(--rec); border-color: var(--rec); color: #fff; font-weight: 700; animation: alarm-pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .btn.alarm-off { animation: none; } }

/* адмінка «Комплекси»: компактні колонки */
.st-cell { white-space: nowrap; }
.st-cell .badge { display: block; width: max-content; }
.st-cell .badge + .badge, .st-cell .badge.p2p { margin: 6px 0 0; }
.fw-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.fw-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fw-row form { margin: 0; }
select.sm { min-height: 32px; padding: 0 8px; font-size: 13px; border-radius: 8px; }
.cam-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.icon-btn { display: inline-grid; place-items: center; }
.icon-btn[aria-pressed="true"] { color: #9A6B00; border-color: #C9A45A; }

.seg3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg3 button { min-height: 34px; border: 0; background: var(--panel-2); color: #B5BDC7; font-size: 13px; }
.seg3 button + button { border-left: 1px solid var(--line); }
.seg3 button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg3 button:disabled { opacity: .5; }

.seg2.seg-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.light-state { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 1.4em; }
.light-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4A525C; flex: none; }
.light-state:empty::before { display: none; }
.light-state.on { color: #F2D79A; }
.light-state.on::before { background: #FFD45C; box-shadow: 0 0 6px 2px rgba(255, 212, 92, .7); }
.light-state.auto::before { background: var(--ok); }
.light-state.busy::before { background: var(--accent); animation: alarm-pulse 1s infinite; }
