/* G3 Cameras — tema dark tecnológico */
:root {
  --bg: #05070d;
  --bg-2: #0a0f1a;
  --panel: rgba(13, 20, 34, 0.78);
  --panel-solid: #0d1422;
  --line: rgba(0, 229, 255, 0.14);
  --line-strong: rgba(0, 229, 255, 0.35);
  --text: #e6f1ff;
  --muted: #7d8ca8;
  --accent: #00e5ff;
  --accent-2: #7c4dff;
  --ok: #19e68c;
  --warn: #ffb020;
  --danger: #ff3d6e;
  --radius: 14px;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 77, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(0, 229, 255, 0.12), transparent 60%),
    var(--bg);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.045) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: rgba(5, 7, 13, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .5px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 34px; height: 34px; }
.brand small { display: block; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; }
.topbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }
.page-title { margin: 8px 0 4px; font-size: 26px; letter-spacing: .3px; }
.page-sub { margin: 0 0 24px; color: var(--muted); }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent); }

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .03);
}
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.panel h2 + p { margin-top: 0; color: var(--muted); font-size: 14px; }
.corners::before, .corners::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--accent); border-style: solid; opacity: .8;
}
.corners::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; border-top-left-radius: var(--radius); }
.corners::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; border-bottom-right-radius: var(--radius); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Formulários ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.input, select.input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(3, 6, 12, .7);
  border: 1px solid rgba(125, 140, 168, .25);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 229, 255, .15); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select.input option { background: var(--panel-solid); }
select.input option:disabled { color: #4a566d; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 46px; }
.input-wrap .eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 8px;
}
.input-wrap .eye:hover { color: var(--accent); }
.otp { font-family: var(--mono); font-size: 28px; letter-spacing: 12px; text-align: center; }

.check { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; cursor: pointer; color: var(--text); font-size: 14px; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 20px; height: 20px; flex: none; border-radius: 6px;
  border: 1px solid var(--line-strong); background: rgba(3, 6, 12, .7);
  display: grid; place-items: center; transition: all .15s;
}
.check .box::after { content: ""; width: 10px; height: 6px; border: 2px solid #001318; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px rgba(0, 229, 255, .5); }
.check input:checked + .box::after { opacity: 1; }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px rgba(0, 229, 255, .3); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: #1a2336; border: 1px solid rgba(125, 140, 168, .3); position: relative; transition: all .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: all .2s; }
.switch input:checked + .track { background: rgba(0, 229, 255, .2); border-color: var(--accent); }
.switch input:checked + .track::after { left: 21px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 229, 255, .06);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover { border-color: var(--accent); background: rgba(0, 229, 255, .12); box-shadow: 0 0 18px rgba(0, 229, 255, .15); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00a3ff 60%, var(--accent-2));
  border-color: transparent; color: #001318;
  box-shadow: 0 8px 24px rgba(0, 229, 255, .25);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 10px 30px rgba(0, 229, 255, .4); background: linear-gradient(135deg, var(--accent), #00a3ff 60%, var(--accent-2)); }
.btn-danger { border-color: rgba(255, 61, 110, .45); background: rgba(255, 61, 110, .08); color: #ffd0dc; }
.btn-danger:hover { border-color: var(--danger); background: rgba(255, 61, 110, .18); box-shadow: 0 0 18px rgba(255, 61, 110, .25); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, .05); border-color: transparent; box-shadow: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn-icon { padding: 9px; border-radius: 10px; }
.btn.active { background: var(--accent); color: #001318; border-color: var(--accent); box-shadow: 0 0 18px rgba(0, 229, 255, .5); }
.btn.active-danger { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 0 18px rgba(255, 61, 110, .5); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* ---------- Alertas e toasts ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; margin: 14px 0 0; }
.alert-error { color: #ffd0dc; background: rgba(255, 61, 110, .08); border-color: rgba(255, 61, 110, .35); }
.alert-warn { color: #ffe1a8; background: rgba(255, 176, 32, .08); border-color: rgba(255, 176, 32, .35); }
.alert-ok { color: #c4ffe3; background: rgba(25, 230, 140, .08); border-color: rgba(25, 230, 140, .35); }
.alert a { font-weight: 600; }

#toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  padding: 12px 16px; border-radius: 10px; background: var(--panel-solid); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: 14px; animation: toast-in .25s ease-out;
}
.toast.error { border-color: rgba(255, 61, 110, .6); }
.toast.ok { border-color: rgba(25, 230, 140, .6); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 99px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  border: 1px solid var(--line-strong); color: var(--accent); background: rgba(0, 229, 255, .06);
}
.badge.live { color: #fff; background: rgba(255, 61, 110, .85); border-color: transparent; }
.badge.live::before, .dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.badge.ok { color: var(--ok); border-color: rgba(25, 230, 140, .4); background: rgba(25, 230, 140, .07); }
.badge.warn { color: var(--warn); border-color: rgba(255, 176, 32, .4); background: rgba(255, 176, 32, .07); }
.badge.off { color: var(--muted); border-color: rgba(125, 140, 168, .3); background: transparent; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; overflow: hidden; }
.auth-card .scan {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 3.5s linear infinite; opacity: .7;
}
@keyframes scan { 0% { top: 0; } 100% { top: 100%; } }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .logo { width: 64px; height: 64px; filter: drop-shadow(0 0 18px rgba(0, 229, 255, .45)); }
.auth-head h1 { margin: 10px 0 2px; font-size: 22px; letter-spacing: .5px; }
.auth-foot { margin-top: 18px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.auth-foot span { color: var(--ok); }

/* ---------- Escolha de modo ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 760px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-card {
  display: block; padding: 32px 26px; color: var(--text); text-decoration: none !important;
  transition: transform .2s, border-color .2s, box-shadow .2s; overflow: hidden;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 20px 50px rgba(0, 229, 255, .12); }
.mode-card .icon {
  width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(0, 229, 255, .18), rgba(124, 77, 255, .18)); border: 1px solid var(--line-strong);
}
.mode-card .icon svg { width: 32px; height: 32px; color: var(--accent); }
.mode-card h2 { font-size: 22px; margin: 0 0 6px; }
.mode-card p { color: var(--muted); margin: 0 0 18px; }
.mode-card ul { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.mode-card li { padding: 3px 0; }
.mode-card li::before { content: "▸ "; color: var(--accent); }
.mode-card .go { margin-top: 20px; font-weight: 700; color: var(--accent); }

/* ---------- Vídeo ---------- */
.video-box {
  position: relative; background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 9; border: 1px solid var(--line);
}
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-box .overlay-top, .video-box .overlay-bottom {
  position: absolute; left: 0; right: 0; padding: 10px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  pointer-events: none;
}
.video-box .overlay-top { top: 0; background: linear-gradient(rgba(0, 0, 0, .65), transparent); justify-content: space-between; }
.video-box .overlay-bottom { bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
.video-box .overlay-top > *, .video-box .overlay-bottom > * { pointer-events: auto; }
.video-box .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted);
  font-family: var(--mono); font-size: 13px; padding: 20px;
}
.video-box .hud-corner { position: absolute; width: 22px; height: 22px; border-color: rgba(0, 229, 255, .7); border-style: solid; pointer-events: none; }
.video-box .hud-corner.tl { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.video-box .hud-corner.tr { top: 8px; right: 8px; border-width: 2px 2px 0 0; }
.video-box .hud-corner.bl { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; }
.video-box .hud-corner.br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }
.stats { font-family: var(--mono); font-size: 11px; color: #bfefff; text-shadow: 0 1px 2px #000; letter-spacing: .5px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(0, 229, 255, .15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Câmera (transmissor) ---------- */
.cam-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .cam-layout { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-family: var(--mono); font-size: 12px; margin-top: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); text-align: right; }
.talk-indicator { display: none; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; margin-top: 14px; background: rgba(124, 77, 255, .14); border: 1px solid rgba(124, 77, 255, .5); color: #dccfff; font-weight: 600; }
.talk-indicator.on { display: flex; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.bars i { width: 3px; background: currentColor; animation: bars .8s infinite ease-in-out; }
.bars i:nth-child(2) { animation-delay: .15s; } .bars i:nth-child(3) { animation-delay: .3s; } .bars i:nth-child(4) { animation-delay: .45s; }
@keyframes bars { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* ---------- Monitor (visualizador) ---------- */
.viewer-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .viewer-layout { grid-template-columns: 1fr; } }
.cam-list { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 960px) { .cam-list { flex-direction: row; overflow-x: auto; padding-bottom: 6px; } .cam-item { min-width: 230px; } }
.cam-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px; border-radius: 12px; cursor: pointer;
  background: rgba(3, 6, 12, .55); border: 1px solid rgba(125, 140, 168, .18); color: var(--text); font: inherit;
  transition: all .15s;
}
.cam-item:hover { border-color: var(--accent); background: rgba(0, 229, 255, .06); }
.cam-item.watching { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.cam-item .ic { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; background: rgba(0, 229, 255, .1); color: var(--accent); }
.cam-item .ic svg { width: 22px; height: 22px; }
.cam-item .meta { min-width: 0; flex: 1; }
.cam-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-item .sub { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 14px; }
.empty svg { width: 40px; height: 40px; color: var(--line-strong); margin-bottom: 8px; }

.tiles { display: grid; gap: 16px; grid-template-columns: 1fr; }
.tiles.n2, .tiles.n3, .tiles.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles.n5, .tiles.n6, .tiles.many { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .tiles.n5, .tiles.n6, .tiles.many { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .tiles[class] { grid-template-columns: 1fr; } }
.tile { padding: 10px; }
.tile .controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tile .controls select.input { width: auto; padding: 8px 34px 8px 12px; font-size: 13px; }
.tile .controls .spacer { flex: 1; }
.tile .title { font-weight: 600; font-size: 14px; text-shadow: 0 1px 3px #000; }
.video-box:fullscreen { border-radius: 0; border: 0; }
.talk-btn.active { animation: glow 1.2s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 28px rgba(255, 61, 110, .8); } }

/* ---------- Configurações ---------- */
.qr-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.qr-box img { width: 180px; height: 180px; border-radius: 12px; background: #fff; padding: 8px; }
.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; padding: 10px; border-radius: 8px; background: rgba(3, 6, 12, .7); border: 1px dashed var(--line-strong); color: var(--accent); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(125, 140, 168, .12); vertical-align: top; }
th { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 500; }
td .ua { color: var(--muted); font-size: 12px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .brand small { display: none; }
  .topbar .btn .lbl { display: none; }
  .container { padding: 16px 12px 40px; }
  .page-title { font-size: 22px; }
  .panel { padding: 16px; }
  .auth-card { padding: 26px 20px; }
}

/* Utilitários (CSP proíbe atributos style inline) */
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; } .mt-28 { margin-top: 28px; }
.m0 { margin: 0 0 6px; } .center { text-align: center; } .hl { color: var(--text); }

/* Medidor de nível do microfone */
.mic-meter { height: 6px; margin-top: 8px; border-radius: 99px; background: rgba(125, 140, 168, .15); overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--accent) 60%, var(--danger)); transition: width .08s linear; }

/* Zoom digital no monitor */
.tile .video-box { touch-action: pan-y; }
.tile .video-box video { transform-origin: 0 0; will-change: transform; }
.tile .video-box.zoomed { touch-action: none; }
.tile .video-box.zoomed video { cursor: grab; }
.tile .video-box.dragging video { cursor: grabbing; }
.zoom-ctl { display: inline-flex; align-items: center; gap: 4px; }
.zoom-ctl .zoom-val { min-width: 52px; font-size: 12px; padding: 9px 6px; }

/* Controle deslizante (zoom óptico) */
.range { width: 100%; accent-color: var(--accent); height: 28px; cursor: pointer; }
.ozoom { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 6px 12px; border-radius: 10px; background: rgba(0, 229, 255, .05); border: 1px solid var(--line); font-size: 13px; }
.ozoom svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.ozoom-lbl { color: var(--muted); white-space: nowrap; }
.ozoom .range { flex: 1; min-width: 80px; }
.ozoom-val { min-width: 42px; text-align: right; color: var(--accent); font-size: 12px; }
#zoomTxt { color: var(--accent); margin-left: 6px; }

/* Foco */
.focus-row { display: flex; gap: 8px; }
.focus-row select { flex: 1; }
.range-ends { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ofocus { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding: 6px 12px; border-radius: 10px; background: rgba(0, 229, 255, .05); border: 1px solid var(--line); font-size: 13px; }
.ofocus svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.ofocus select.input { width: auto; padding: 6px 30px 6px 10px; font-size: 13px; }
.ofocus .range { flex: 1; min-width: 100px; }
.ofocus .btn { padding: 6px 12px; font-size: 13px; }

/* Cabeçalho do bloco de vídeo no monitor (fora da imagem) */
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.tile-head .title { font-weight: 600; font-size: 14px; text-shadow: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Gravações ---------- */
.rec-box { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 6, 12, .45); }
.rec-info { font-size: 13px; margin-top: 6px; }
.seg-select { width: auto; min-width: 180px; flex: 1; }
.disk-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: rgba(25, 230, 140, .25); margin-top: 6px; }
.disk-bar span:first-child { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.disk-bar span:last-child { background: #3a4660; }
.disk-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.disk-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-rec { background: var(--accent); } .lg-other { background: #3a4660; } .lg-free { background: rgba(25, 230, 140, .45); }
.rec-toolbar .cam-filter { width: auto; min-width: 200px; }
.m-0 { margin: 0; }
.small { font-size: 12px; }
.day-title { font-size: 13px; font-family: var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin: 22px 0 10px; font-weight: 500; }
.day-title:first-child { margin-top: 4px; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.rec-card { border-radius: 12px; overflow: hidden; border: 1px solid rgba(125, 140, 168, .18); background: rgba(3, 6, 12, .55); transition: border-color .15s; }
.rec-card:hover { border-color: var(--accent); }
.rec-thumb { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; background: #000; border: 0; padding: 0; cursor: pointer; color: var(--line-strong); }
.rec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-thumb > svg { width: 42px; height: 42px; }
.rec-thumb .rec-dur { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .75); color: #fff; font-size: 11px; }
.rec-thumb .rec-status { position: absolute; left: 8px; top: 8px; }
.rec-thumb .rec-play { position: absolute; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 229, 255, .85); color: #001318; opacity: 0; transform: scale(.85); transition: all .15s; }
.rec-thumb .rec-play svg { width: 22px; height: 22px; margin-left: 3px; }
.rec-thumb:hover .rec-play, .rec-thumb:focus-visible .rec-play { opacity: 1; transform: none; }
.rec-meta { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.rec-txt { min-width: 0; }
.rec-txt .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-txt .sub { font-size: 11px; color: var(--muted); }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .78); backdrop-filter: blur(6px); }
.modal-card { width: 100%; max-width: 1100px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--panel-solid); }
.player-video { width: 100%; max-height: 70dvh; background: #000; border-radius: 10px; display: block; }
body.no-scroll { overflow: hidden; }
.tile-badges { gap: 6px; flex-wrap: nowrap; }
.rec-btn.active-danger { animation: glow 1.2s infinite; }
@media (max-width: 600px) { .rec-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .rec-meta { padding: 8px; } }
.mode-card-wide { display: flex; align-items: center; gap: 20px; padding: 22px 26px; }
.mode-card-wide .icon { margin: 0; flex: none; }
.mode-card-wide p { margin: 0; }
.mode-card-wide .go { margin: 0 0 0 auto; white-space: nowrap; }
@media (max-width: 600px) { .mode-card-wide { flex-wrap: wrap; } .mode-card-wide .go { margin: 0; } }

/* ===== Ajustes de layout (monitor com várias câmeras / celular) ===== */
/* Itens de grid não podem crescer além da tela por causa do conteúdo */
.viewer-layout { grid-template-columns: 300px minmax(0, 1fr); }
.viewer-layout > *, .tiles > *, .cam-layout > * { min-width: 0; }
@media (max-width: 960px) { .viewer-layout, .cam-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .tiles[class] { grid-template-columns: minmax(0, 1fr); } }

/* Vídeo do monitor com a proporção real da câmera (em pé ou deitada) */
.tile .video-box { --ar: 1.7778; --max-h: 70dvh; aspect-ratio: var(--ar); width: min(100%, calc(var(--max-h) * var(--ar))); margin-inline: auto; }
.tiles.n2 .tile .video-box, .tiles.n3 .tile .video-box, .tiles.n4 .tile .video-box { --max-h: 55dvh; }
.tile .video-box:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; }

/* Ajustes de lente recolhíveis */
.tile:not(.lens-open) .ozoom, .tile:not(.lens-open) .ofocus { display: none !important; }

.tile-head .close-btn { padding: 6px; margin-right: -4px; }
.tile-head .close-btn:hover { color: var(--danger); }
.tile-head .tile-badges { flex: none; }
.tile-head .title { min-width: 0; flex: 1; }

@media (max-width: 700px) {
  .topbar { gap: 8px; }
  .brand { gap: 8px; white-space: nowrap; font-size: 15px; }
  .brand .logo { width: 30px; height: 30px; }
  .topbar nav { flex-wrap: nowrap; gap: 2px; }
  .topbar nav .btn { padding: 8px; }
  .topbar nav .badge { padding: 2px 7px; font-size: 10px; }
  .hide-mobile { display: none; }
  .page-title { font-size: 20px; margin-bottom: 12px; }

  /* Lista de câmeras compacta, rolando para o lado */
  .viewer-layout { gap: 14px; }
  .viewer-layout > aside.panel { padding: 12px; }
  .viewer-layout > aside h2 { font-size: 15px; }
  .cam-list { margin-top: 10px; gap: 8px; scroll-snap-type: x mandatory; }
  .cam-item { min-width: 200px; max-width: 240px; padding: 8px 10px; gap: 10px; scroll-snap-align: start; }
  .cam-item .ic { width: 32px; height: 32px; }
  .cam-item .ic svg { width: 18px; height: 18px; }
  .cam-item .badge { display: none; }

  /* Blocos de vídeo compactos */
  .tiles { gap: 14px; }
  .tile { padding: 8px; }
  .tile-head { padding: 0 2px 8px; }
  .tile .controls { gap: 6px; margin-top: 8px; }
  .tile .controls .lbl { display: none; }
  .tile .controls .btn-icon { padding: 8px; }
  .tile .controls select.input { max-width: 120px; padding: 7px 28px 7px 10px; font-size: 12px; }
  .tile .controls .spacer { display: none; }
  .zoom-ctl .zoom-in, .zoom-ctl .zoom-out { display: none; } /* no celular usa-se a pinça */
  .zoom-ctl .zoom-val { min-width: 44px; }
  .ozoom, .ofocus { padding: 6px 10px; gap: 8px; }
}
@media (max-width: 380px) { .brand span { display: none; } }
.tile-head .fs-btn { padding: 6px; }
.tile-head .tile-badges { gap: 2px; }
.tile-head .badge.state { margin-right: 4px; }
@media (max-width: 700px) {
  .tile .controls { flex-wrap: nowrap; }
  .tile .controls select.input { flex: 1 1 auto; min-width: 0; max-width: none; text-overflow: ellipsis; }
  .tile .controls .btn-icon { flex: none; }
  .zoom-ctl .zoom-val:not(.active) { display: none; } /* aparece só com zoom aplicado */
}
/* Compactação pelos controles conforme a largura de cada bloco (vale para celular e grade no PC) */
.tiles { align-items: start; }
.tile { container-type: inline-size; }
@container (max-width: 560px) {
  .controls { flex-wrap: nowrap; gap: 6px; }
  .controls .lbl { display: none; }
  .controls .btn-icon { padding: 8px; flex: none; }
  .controls select.input { flex: 1 1 auto; min-width: 0; max-width: 150px; padding: 7px 28px 7px 10px; font-size: 12px; }
  .controls .zoom-ctl .zoom-in, .controls .zoom-ctl .zoom-out { display: none; }
  .controls .zoom-val:not(.active) { display: none; }
}
#previewBox { --ar: 1.7778; aspect-ratio: var(--ar); width: min(100%, calc(65dvh * var(--ar))); margin-inline: auto; }
.clean-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
@media (max-width: 600px) { .clean-grid { grid-template-columns: minmax(0, 1fr); } }
.rec-lock { margin-left: auto; font-size: 16px; padding: 4px 6px; opacity: .45; flex: none; }
.rec-lock.on, .rec-lock:hover { opacity: 1; }
.switch { align-items: flex-start; line-height: 1.4; }
.switch .track { margin-top: 1px; }
.panel > p { color: var(--muted); font-size: 14px; }
