/* MV-Center — tema escuro no app (como o MultView), login sempre claro
   (padrão Atsun: card de 340px, faixa de 4px no topo, logo grande + nome +
   rodapé de crédito). Sem fontes de terceiros (nada sai pro Google). */
:root {
  color-scheme: dark;
  /* Mesmas cores do MultView. */
  --bg: #0b0d10; --panel: #161a1f; --panel2: #1d2229;
  --border: #2a2f36; --text: #e6e8eb; --muted: #8a929c; --accent: #3b82f6;
  --ok: #22c55e; --err: #ef4444; --warn: #f97316; --laranja: #f97316;
  --l-bg: #ffffff; --l-text: #1a2027; --l-muted: #6b7480; --l-border: #dfe3e8;
  --l-accent: #2563eb; --l-err: #dc2626; --l-ok: #16a34a;
}
* { box-sizing: border-box; }
/* Página como a do MultView: rola inteira, grade com a largura toda. */
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 24px 12px; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
code { background: #0e1116; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 12px; }

/* ---------- login (sempre claro) ---------- */
.login-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: #eef1f5; padding: 16px; overflow-y: auto; }
.login-card { position: relative; width: 340px; max-width: 90vw; margin: auto; background: var(--l-bg); color: var(--l-text);
  border: 1px solid var(--l-border); border-top: 4px solid var(--l-accent); border-radius: 8px;
  padding: 40px 36px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18); }
.login-logo { display: block; max-height: 155px; max-width: 100%; object-fit: contain; margin: -8px auto 16px; }
.login-title { margin: 0 0 4px; font-size: 26px; font-weight: 700; text-align: center; font-family: Georgia, serif; }
.login-sub { margin: 0 0 14px; font-size: 13px; color: var(--l-muted); text-align: center; }
.login-card .field { margin-bottom: 16px; }
.login-card label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--l-muted); }
.login-card input { width: 100%; height: 40px; padding: 8px 10px; border: 1px solid var(--l-border); border-radius: 6px;
  background: #f8fafc; color: var(--l-text); font-size: 14px; }
.login-card input:focus { outline: 2px solid var(--l-accent); outline-offset: 0; border-color: var(--l-accent); }
.login-card button[type="submit"] { width: 100%; height: 42px; margin-top: 4px; background: var(--l-accent); color: #fff;
  border: none; border-radius: 6px; font-size: 14px; font-weight: 600; }
.login-card button[type="submit"]:disabled { opacity: .6; cursor: default; }
.login-card .btn-link { display: block; width: 100%; margin-top: 12px; background: none; border: none; color: var(--l-accent); font-size: 13px; }
.login-card .err-msg { color: var(--l-err); font-size: 13px; margin-bottom: 12px; }
.login-card .ok-msg { color: var(--l-ok); font-size: 13px; margin-bottom: 12px; }
.login-card .err-msg:empty, .login-card .ok-msg:empty { display: none; }
.login-card .pass-toggle { color: var(--l-muted); }
.password-requirements { list-style: none; margin: -8px 0 12px; padding: 0; font-size: 11px; }
.password-requirements li { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.password-requirements .req-unmet { color: var(--l-muted); }
.password-requirements .req-met { color: var(--l-ok); }
.card .password-requirements { margin: 6px 0 0; }
.card .password-requirements .req-unmet { color: var(--muted); }
.card .password-requirements .req-met { color: var(--ok); }
.login-footer { margin-top: 20px; position: relative; text-align: center; color: var(--l-muted); font-size: 11px; }
.login-footer p { margin: 2px 0; }
.login-footer-logo { position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 30px; width: auto; }

/* ---------- mostrar/ocultar senha: 👁 nos dois estados, traço quando revelada ---------- */
.pass-wrap { position: relative; display: block; }
.pass-wrap input { width: 100%; padding-right: 38px; }
.pass-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: none; background: none;
  font-size: 16px; line-height: 1; color: var(--muted); width: auto !important; height: auto !important;
  padding: 4px 6px !important; margin: 0 !important; }
.pass-toggle.revealed::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 2px;
  background: currentColor; transform: translate(-50%, -50%) rotate(-45deg); }


/* ---------- barra superior e menus (padrão Atsun, igual ao MultView) ---------- */
.title-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.topbar { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; flex-wrap: nowrap; }
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; }
.topbar .brand img { height: 32px; width: auto; max-width: 140px; object-fit: contain; border-radius: 4px; }
.topbar .brand .brand-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .topmenu { display: flex; gap: 6px; flex: 1; justify-content: center; align-items: center; min-width: 0; }
.topbar .topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-icon-btn { position: relative; width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: transparent; color: var(--muted); border: 1px solid transparent; }
.topbar-icon-btn:hover { color: var(--text); border-color: var(--border); }
/* Abas: um servidor ou uma grade mista cada. */
.abas { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding: 2px; scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text); white-space: nowrap; font-size: 13px; }
.tab:hover { border-color: var(--accent); }
.tab.ativa { border-color: var(--accent); background: var(--accent); color: #fff; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.tab .dot.ok { background: var(--ok); } .tab .dot.fora { background: var(--err); } .tab .dot.revogado { background: var(--warn); }
.tab.ativa .dot { box-shadow: 0 0 0 1px #fff8; }
.tab-add { padding: 4px 11px; font-size: 16px; line-height: 1; }
.user-menu { position: relative; }
.user-chip-btn { display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 3px 10px 3px 3px; color: var(--text); font-size: 13px; }
.user-chip-btn:hover { border-color: var(--border); }
.avatar-initials { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.user-chip-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 210px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); padding: 6px; }
.user-menu-panel .user-menu-title { margin: 4px 8px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.user-menu-panel .user-menu-item { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; color: var(--text); }
.user-menu-panel .user-menu-item:hover { background: var(--bg); }
.user-menu-panel .user-menu-item.danger { color: var(--err); }
.user-menu-panel hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
/* Menu de câmeras pausadas, centralizado embaixo do botão. */
.paused-menu-btn { height: 34px; border-radius: 999px; padding: 0 14px; background: transparent; color: var(--text); border: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
.paused-menu-panel { left: 50%; right: auto; transform: translateX(-50%); }
.paused-menu-item { display: flex !important; align-items: center; justify-content: space-between; gap: 16px; }
.paused-menu-action { color: var(--accent); font-size: 12px; white-space: nowrap; }
.faixa { width: 100%; background: #3a2a07; color: #fde68a; padding: 6px 12px; font-size: 13px; text-align: center; border-radius: 8px; margin: 0 0 12px; }

/* ---------- grade (igual ao MultView) ---------- */
.aviso-centro { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh;
  color: var(--muted); gap: 14px; text-align: center; padding: 20px; }
.aviso-centro button { padding: 10px 16px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-weight: 600; }
.grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); gap: 0; }
.video-wrap { position: relative; width: 100%; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.cam-label { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.55); padding: 4px 10px; border-radius: 999px; font-size: 12px; z-index: 1; }
video { width: 100%; display: block; aspect-ratio: 16 / 9; background: #000; cursor: pointer; object-fit: fill; }
.status { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,0.55);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; z-index: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--ok); }
.dot.error { background: var(--err); }
/* Gravação em andamento (botão ⏺) — sempre visível, mesmo com os controles escondidos. */
.rec-indicator { color: #ff4d4d; font-weight: 700; letter-spacing: 0.04em; animation: rec-pisca 1.2s ease-in-out infinite; }
.rec-indicator[hidden] { display: none; }
@keyframes rec-pisca { 50% { opacity: 0.35; } }
.layout-active .cam-label, .layout-active .status { cursor: grab; outline: 1px dashed var(--accent); }
.layout-active .video-wrap.drag-over { outline: 2px solid var(--accent); outline-offset: -2px; }
.cam-label[contenteditable="true"] { cursor: text; outline: 1px solid var(--accent); }
/* Pausada pelo ⏸ — fica fora da grade e volta pelo menu "pausadas". */
.video-wrap.cam-paused { display: none; }
.layout-done-btn { position: fixed; top: 16px; right: 16px; z-index: 1001; background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 8px 14px; font-size: 13px; }
.layout-hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; padding-left: 20px; }
.layout-hint li { margin-bottom: 6px; }

/* ---------- ampliada (igual ao MultView) ---------- */
.zoom-overlay { position: fixed; inset: 0; background: #000; z-index: 1000; display: flex; flex-direction: row; }
.zoom-video-area { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.zoom-overlay video { width: 100%; height: 100%; aspect-ratio: unset; object-fit: contain; touch-action: none; }

/* ---------- janelas ---------- */
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 1100; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 10px;
  padding: 22px; width: 100%; max-width: 380px; max-height: calc(100dvh - 32px); overflow: auto; }
.card.largo { max-width: 480px; }
#srvOverlay .card { border-top-color: var(--laranja); }
.card h2 { margin: 0 0 14px; font-size: 18px; text-align: center; }
.card h2.segundo { margin-top: 20px; }
.card p { margin: 0 0 8px; }
.card label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.card input, .config-box input, .config-box select { width: 100%; height: 38px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: #0e1116; color: var(--text); font: inherit; }
.card input[type="checkbox"], .config-box input[type="checkbox"] { width: auto; height: auto; }
.acoes { display: flex; gap: 8px; margin-top: 16px; }
.acoes button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); }
.acoes button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.acoes button.perigo { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
.acoes button:disabled { opacity: .6; cursor: default; }
.erro { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 16px; }
.erro:empty { min-height: 0; margin: 0; }
.dica { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.lista-srv { display: flex; flex-direction: column; gap: 8px; }
.lista-srv.rolagem { max-height: 40vh; overflow: auto; }
.lista-srv .item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.lista-srv .item .nome { font-weight: 600; }
.lista-srv .item .end { color: var(--muted); font-size: 12px; word-break: break-all; }
.lista-srv .item .linha { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.lista-srv .item button { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); font-size: 12px; }
.lista-srv .titulo-srv { color: var(--muted); font-size: 12px; margin-top: 6px; }
.lista-srv .marca { display: flex; gap: 8px; align-items: center; margin: 2px 0; color: var(--text); font-size: 14px; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- Sobre (logo oficial da Atsun, nunca o favicon) ---------- */
.about-box { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-top: 4px solid var(--accent);
  border-radius: 8px; padding: 32px 40px; min-width: 280px; max-width: 340px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; text-align: center; }
.about-box img { width: 80px; height: 80px; border-radius: 16px; margin-bottom: 8px; }
.about-box h2 { margin: 0; font-size: 18px; font-family: Georgia, serif; }
.about-box p { margin: 0; color: var(--muted); font-size: 12px; }
.about-box .about-credit { margin-bottom: 12px; }
.about-box button { padding: 8px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); }

/* ---------- Configurações (administrador) ---------- */
.config-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; width: 100%; max-width: 980px;
  height: min(720px, calc(100dvh - 32px)); display: flex; flex-direction: column; padding: 16px; gap: 12px; }
.config-head { display: flex; justify-content: space-between; align-items: center; }
.config-head h2 { margin: 0; font-size: 16px; }
.config-head button, .config-box button { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); }
.config-box .painel-config { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
/* Apelidos: o bloco abaixo é o mesmo CSS do CartaoConfig.jsx (Financeiro). */
.painel-config { --paper: var(--bg); --paper-raised: var(--panel); --rule: var(--border); --brand: var(--accent);
  --ink: var(--text); --ink-soft: var(--muted); --text-scale: 1; }
.painel-config { display: flex; gap: 20px; align-items: flex-start; }
.painel-config-menu { flex: 0 0 180px; position: sticky; top: 12px; display: flex; flex-direction: column;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.painel-config-menu button { background: none !important; border: none !important; border-left: 3px solid transparent !important;
  border-radius: 0 !important; margin: 0; padding: 10px 14px !important; text-align: left; color: var(--ink); font-size: calc(14px * var(--text-scale)); }
.painel-config-menu button + button { border-top: 1px solid var(--rule) !important; }
.painel-config-menu button:hover { background: var(--paper) !important; }
.painel-config-menu button.ativo { border-left-color: var(--brand) !important; background: var(--paper) !important; font-weight: 700; }
.painel-config-conteudo { flex: 1; min-width: 0; }
.cartao-config { padding: 16px 20px; }
.cartao-config[hidden] { display: none; }
.cartao-config-titulo { margin: 0 0 12px; font-weight: 700; font-size: calc(17px * var(--text-scale)); }
@media (max-width: 860px) {
  .painel-config { flex-direction: column; align-items: stretch; }
  .painel-config-menu { flex: none; position: static; flex-direction: row; flex-wrap: wrap; }
  .painel-config-menu button { border-left: none !important; border-bottom: 3px solid transparent !important; }
  .painel-config-menu button + button { border-top: none !important; }
  .painel-config-menu button.ativo { border-bottom-color: var(--brand) !important; }
}
.tabela { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.tabela th, .tabela td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tabela th { color: var(--muted); font-weight: 600; }
.form-grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 10px 0; }
.form-grade label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.linha-inteira { grid-column: 1 / -1; }
.acoes-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.config-box .erro { margin-top: 6px; }
.config-box .form-grade button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.config-box .pass-toggle { background: none; border: none; }
.dica-inline { color: var(--muted); font-size: 12px; }
.rotulo-teste { display: block; margin: 18px 0 4px; font-size: 13px; color: var(--muted); }
.linha-teste { display: flex; gap: 8px; max-width: 480px; }
.linha-teste button { flex: none; height: 38px; }


/* ---------- ajuda (mesmo cartão do Sobre, mais largo e com rolagem) ---------- */
.about-box.help-box { max-width: 600px; width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow-y: auto; align-items: stretch;
  text-align: left; gap: 6px; font-size: 13px; line-height: 1.5; }
.help-box h2 { text-align: center; font-family: inherit; font-size: 16px; }
.help-box h3 { margin: 12px 0 0; font-size: 14px; }
.help-box ul { margin: 0; padding-left: 20px; }
.help-box p { margin: 0; color: var(--text); font-size: 13px; }
.help-box code { overflow-wrap: anywhere; }
.help-estado { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; text-align: center; }
.help-rec { color: #ff4d4d; }
.help-box .help-nota { color: var(--muted); font-size: 12px; }
#helpPastaBtn, #helpCloseBtn { align-self: center; }
#helpCloseBtn { margin-top: 12px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #000d; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px; z-index: 1200; max-width: 90vw; text-align: center; }

@media (max-width: 600px) {
  .login-card { padding: 32px 22px; }
}
