/* Painel central: navegação, folhas de administração, mosaico, login. */

#nav { display: flex; gap: 2px; height: 100%; }
#nav a {
  display: flex; align-items: center; padding: 0 10px;
  color: var(--muted); text-decoration: none; box-shadow: inset 0 -2px 0 transparent;
}
#nav a:hover { color: var(--ink); }
#nav a.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
#who { font-size: 13px; text-align: right; line-height: 1.25; }
#who small { display: block; color: var(--faint); font-size: 12px; }
.brand-logo { height: 24px; width: auto; }

/* ---- páginas de administração ---- */
#view > h2 { margin: 4px 0 16px; }
h3 { margin: 28px 0 10px; }
.card { background: var(--surface); border-radius: 12px; padding: 4px 20px; margin-bottom: 20px; }
form.card { padding: 16px 20px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
form label input, form label select { color: var(--ink); font-size: 14px; min-width: 200px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; color: var(--ink); font-size: 14px; }
input.small { min-width: 0; width: 84px; }
input.host { min-width: 0; width: 190px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 14px 12px 10px; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td a { color: var(--ink); font-weight: 500; text-decoration: none; }
td a:hover { text-decoration: underline; }
td .muted { font-size: 12px; }
td:last-child { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 28px 0; }
.motion-cell select { margin-left: 6px; padding: 3px 6px; }

/* Status: texto com um ponto, sem pílula. */
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.ok::before { background: var(--ok); }
.pill.rec::before { background: var(--live); }
.pill.warn::before { background: var(--warn); }
.pill.off { color: var(--off); }
.pill.off::before { background: var(--off); }
.pill.idle { color: var(--muted); }

.error { color: var(--off); min-height: 1.2em; margin: 0; font-size: 13px; }
.install { margin-top: 4px; width: 100%; }
.install p { margin: 6px 0; }
.install code, code.copy {
  display: block; white-space: pre-wrap; word-break: break-all;
  background: var(--sunk); border-radius: var(--radius); padding: 10px 12px; font-size: 13px;
}
code.copy { cursor: copy; }
#push { padding: 16px 20px; }
#push h2 { font-size: 16px; margin: 0 0 8px; }
#push p { margin: 10px 0; }
#hookInfo { padding: 14px 20px; font-size: 13px; }

/* ---- mosaico ---- */
.mosaic-bar { align-items: end; margin-bottom: 14px; }
.mosaic-wrap { background: var(--bg); }
.mosaic-wrap:fullscreen { display: grid; place-items: center; background: var(--stage); }
.mosaic-wrap:fullscreen .mosaic { width: min(100vw, 177.78vh); }
.mosaic { display: grid; gap: 6px; }
.mosaic.L1 { grid-template-columns: 1fr; }
.mosaic.L4 { grid-template-columns: repeat(2, 1fr); }
.mosaic.L9 { grid-template-columns: repeat(3, 1fr); }
.mosaic.L16 { grid-template-columns: repeat(4, 1fr); }
.mosaic.L1p5 { grid-template-columns: repeat(3, 1fr); }
.mosaic.L1p5 .tile.big { grid-column: span 2; grid-row: span 2; }
.mosaic.L1p7 { grid-template-columns: repeat(4, 1fr); }
.mosaic.L1p7 .tile.big { grid-column: span 3; grid-row: span 3; }
.tile { position: relative; background: var(--stage); aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; }
.tile.big { aspect-ratio: auto; min-height: 0; } /* altura = linhas que ocupa */
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; } /* o vídeo não define a altura do quadro */
.tile.empty { background: transparent; border: 1px dashed var(--line); }
.tile.edit { background: var(--surface); border: 1px dashed var(--faint); display: grid; place-items: center; cursor: grab; }
.tile.edit select { max-width: 90%; }
.tile-pos { position: absolute; left: 10px; top: 8px; font-size: 12px; color: var(--faint); }
.tile-name { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
.tile-err { position: absolute; left: 10px; top: 8px; font-size: 12px; color: #ffb4ad; }
.tile.empty .tile-err { color: var(--muted); }

/* ---- login ---- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { width: 320px; background: none; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.login p.sub { margin: -8px 0 10px; color: var(--muted); }
.login label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.login input { background: var(--surface); padding: 10px 12px; font-size: 15px; color: var(--ink); }
.login button { justify-content: center; padding: 10px; margin-top: 6px; }
.row > .error:empty { display: none; }
.hook-msg:empty { display: none; }
form label input[type="color"] { min-width: 0; width: 56px; height: 34px; padding: 3px; cursor: pointer; }
input[type="file"] { background: none; padding: 4px 0; }

/* ---- tabela de câmeras ---- */
.motion-cell { white-space: nowrap; }
.motion-cell .switch { vertical-align: middle; }
.motion-cell select { margin-left: 10px; vertical-align: middle; }
td.src { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td > div.muted { margin-top: 1px; }
td:last-child button + button { margin-left: 2px; }

/* ---- painel lateral de edição ---- */
dialog.sheet {
  margin: 0 0 0 auto; height: 100vh; max-height: none; width: min(420px, 100vw);
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  box-shadow: -1px 0 0 var(--line);
}
dialog.sheet[open] { animation: sheet-in 0.18s ease-out; }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
dialog.sheet::backdrop { background: rgba(24, 33, 36, 0.28); }
.sheet-body { display: flex; flex-direction: column; gap: 20px; padding: 24px 28px; min-height: 100%; }
.sheet-body h2 { font-size: 18px; margin-bottom: 4px; }
.sheet-body > label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.sheet-body > label input:not([type=range]), .sheet-body > label select { color: var(--ink); font-size: 14px; padding: 9px 11px; }
.sheet-body .hint { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.switch-row strong { font-weight: 500; }
.sens output { color: var(--ink); font-weight: 600; margin-left: 4px; }
.sens input[type=range] { padding: 0; background: none; accent-color: var(--accent); width: 100%; }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }
.sheet-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }

/* ---- gravadores ---- */
.card.rec { padding: 18px 22px 14px; }
.rec-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-head h3 { margin: 0; font-size: 16px; }
.rec-head .muted { font-size: 12px; }
.rec-cfg { font-size: 13px; }
.metrics {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0;
  margin: 16px 0 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.metric { padding: 14px 16px 12px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric:first-child { padding-left: 0; }
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-value .dir { color: var(--faint); font-weight: 400; margin-right: 2px; }
.metric-sub { font-size: 12px; color: var(--muted); margin-top: 1px; min-height: 2.5em; }
.spark { display: block; width: 100%; height: 30px; margin-top: 8px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark polyline.s1 { stroke: var(--faint); stroke-dasharray: 3 2; }
.meter { height: 6px; border-radius: 3px; background: var(--sunk); margin-top: 20px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.metrics-empty { margin: 14px 0; font-size: 13px; }
.rec-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.rec-foot label.inline { color: var(--muted); font-size: 13px; gap: 10px; }
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(4) { border-left: 0; padding-left: 0; }
  .metric:nth-child(n+4) { border-top: 1px solid var(--line); }
}

/* ---- cabeçalho de página com ação ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 16px; }
.page-head h2 { margin: 0; }
.page-error:empty { display: none; }
.page-error { margin: -6px 0 12px; }

/* ---- painel lateral: opções e textos ---- */
.sheet-body > p { margin: 0; color: var(--ink); }
.sheet-body > p.hint { color: var(--muted); font-size: 13px; }
.sheet-body code.copy { font-size: 12px; }
.sheet-body .error:empty { display: none; }
fieldset.choice { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
fieldset.choice legend { color: var(--muted); font-size: 13px; padding: 0; margin-bottom: 6px; }
form label.option, label.option {
  display: flex; flex-direction: row; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); font-size: 14px;
}
label.option:hover { border-color: var(--faint); }
label.option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
form label.option input, label.option input { margin: 2px 0 0; accent-color: var(--accent); width: 16px; min-width: 0; height: 16px; padding: 0; flex: none; }
label.option strong { font-weight: 500; display: block; }

/* ---- painel: grupos, seletor segmentado, listas de escolha ---- */
.sheet-group { display: flex; flex-direction: column; gap: 14px; }
.sheet-group > label:not(.option):not(.check) { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.sheet-group > label input:not([type=radio]):not([type=checkbox]) { color: var(--ink); font-size: 14px; padding: 9px 11px; min-width: 0; }
.segmented { display: flex; background: var(--sunk); border-radius: var(--radius); padding: 3px; gap: 3px; }
.segmented label { flex: 1; display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 7px 8px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(24, 33, 36, 0.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.row-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-actions button { background: var(--sunk); }
.row-actions button:hover:not(:disabled) { background: #e7ecea; }
.row-actions .muted { font-size: 13px; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice-list:empty { display: none; }
form label.option.compact, label.option.compact { padding: 9px 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.pair input { color: var(--ink); font-size: 14px; padding: 9px 11px; min-width: 0 !important; width: 100%; }
.sheet-body .warn-hint { color: var(--warn); margin-top: -6px; }
form label.check { flex-direction: row; display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
form label.check input { min-width: 0; }
dialog.sheet { overflow-y: auto; }
.segmented input { width: 0; height: 0; min-width: 0 !important; }
dialog.sheet { overflow-x: hidden; }

/* ---- Telegram ---- */
.card.tg { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.card.tg h4 { margin: 0; font-size: 15px; font-weight: 600; }
.card.tg p { margin: 0; }
.tg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.tg-head p { margin-top: 2px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.steps code { background: var(--sunk); padding: 1px 5px; border-radius: 4px; }
.tg-form { align-items: end; }
.tg-form label.grow { flex: 1; }
.tg-form label.grow input { min-width: 0; width: 100%; font-family: ui-monospace, monospace; font-size: 13px; }
.card.tg .switch-row { padding-top: 12px; }
.card.tg .switch-row .hint { display: block; font-size: 12px; color: var(--muted); }
.tg-cd { color: var(--muted); font-size: 13px; gap: 10px; }
.tg-msg:empty { display: none; }
.tz-row { align-items: center; } .tz-row .tz-msg { font-size: 13px; }

/* ---- recursos ligados na câmera (ícones) ---- */
td.feats { white-space: nowrap; }
.feat {
  display: inline-flex; align-items: center; gap: 3px; margin-right: 10px;
  color: var(--accent); font-size: 12px; font-weight: 600;
}
.feat svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- origem: etiqueta do protocolo ---- */
.tag {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 6px; border-radius: 4px; background: var(--sunk); color: var(--ink); margin-right: 8px;
}
td.src { max-width: 240px; }
td.src .muted { font-size: 13px; }
.field-label { color: var(--muted); font-size: 13px; }
.link-row { display: flex; flex-direction: column; gap: 4px; }
code.copy.copied { outline: 2px solid var(--accent); }
.video-info { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--sunk); border-radius: var(--radius); font-size: 13px; }

/* ---- esqueletos (carregando) e painéis de vazio/erro ---- */
.sk {
  display: block; border-radius: 6px;
  background: linear-gradient(90deg, #dbe2e1 0%, #e8edec 50%, #dbe2e1 100%);
  background-size: 200% 100%; animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-wrap { pointer-events: none; }
.sk-item { height: 54.75px; padding: 11px 12px; display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.sk-line { height: 12px; }
.sk-line.thin { height: 9px; }
.w60 { width: 60%; } .w40 { width: 40%; }
.sk-stage { background: var(--stage); }
.sk-stage::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
  background-size: 200% 100%; animation: sk-shimmer 1.6s ease-in-out infinite;
}
.sk-toolbar { height: 52px; }
.sk-pill { width: 92px; height: 32px; }
.sk-icons { width: 190px; height: 32px; margin-left: 8px; }
.sk-timeline { height: 110px; padding: 0; }
.sk-block { height: 100%; border-radius: 0; }

.state-panel {
  max-width: 520px; margin: 12vh auto 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.state-panel h2 { font-size: 20px; }
.state-panel p { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.state-panel.is-error h2 { color: var(--off); }

/* ---- faixas de horário da detecção ---- */
.range-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.range-row .days { display: flex; gap: 4px; flex-wrap: wrap; }
.day { cursor: pointer; }
.day input { position: absolute; opacity: 0; width: 0; height: 0; min-width: 0 !important; }
.day span { display: inline-block; min-width: 40px; text-align: center; padding: 5px 6px; border-radius: 6px; background: var(--sunk); font-size: 12px; color: var(--muted); }
.day input:checked + span { background: var(--accent); color: #fff; font-weight: 600; }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.range-row .times { display: flex; align-items: center; gap: 8px; }
.range-row .times input { min-width: 0 !important; width: 110px; padding: 6px 8px; }
.range-row .times .danger { margin-left: auto; }
.range-note:empty { display: none; }
.feat-sub svg { width: 13px; height: 13px; margin-left: 1px; vertical-align: -2px; }
.rec-foot .au { gap: 8px; color: var(--muted); font-size: 13px; }
.upd-err { margin: 8px 0 0; }
fieldset.alerts { border: 0; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset.alerts legend { color: var(--muted); font-size: 13px; padding: 0; margin-bottom: 4px; }
.switch-row.compact { padding-top: 8px; border-top: 0; align-items: center; }
.switch-row.compact strong { font-weight: 500; }
.switch-row.compact .hint { display: block; font-size: 12px; color: var(--muted); }
.switch-row.top { border-top: 0; padding-top: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
