:root {
  --bg: #0d1526; --surface: #141f36; --surface2: #1c2b47; --border: #29385a;
  --text: #e6edf7; --muted: #9fb0c8; --dim: #6b7d99;
  --accent: #5b9bff; --accent-dk: #3b82f6;
  --ok: #34d399; --ok-bg: rgba(52,211,153,.14);
  --warn: #fbbf24; --warn-bg: rgba(251,191,36,.14);
  --crit: #f87171; --crit-bg: rgba(248,113,113,.14);
  --acc-bg: rgba(91,155,255,.14);
  --f: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Consolas", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--f); line-height: 1.5; }
button { font-family: inherit; cursor: pointer; }
code { font-family: var(--mono); background: var(--surface2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* LOGIN */
#tela-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(900px 400px at 50% -10%, rgba(91,155,255,.12), transparent 60%); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; box-shadow: 0 12px 48px rgba(0,0,0,.4); }
.login-brand { font-size: 1.3rem; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.login-sub { color: var(--muted); font-size: .85rem; margin-bottom: 22px; }
.login-card label { display: block; font-size: .78rem; color: var(--muted); margin: 14px 0 5px; text-transform: uppercase; letter-spacing: .04em; }
.login-card input { width: 100%; height: 44px; padding: 0 13px; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--acc-bg); }
#btn-entrar { width: 100%; height: 46px; margin-top: 22px; background: var(--accent-dk); color: #fff; border: none;
  border-radius: 10px; font-weight: 700; font-size: 15px; }
#btn-entrar:active { background: var(--accent); }
.erro { color: var(--crit); font-size: .85rem; min-height: 1.2em; margin: 12px 0 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--acc-bg); display: inline-block; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 9px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.atualizado { color: var(--dim); font-size: .78rem; font-family: var(--mono); }
.top-actions button { background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-size: .85rem; }
.top-actions button:active { color: var(--text); }
#btn-refresh { font-size: 1rem; width: 38px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px; }

/* CARDS */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.kpi .n { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .l { color: var(--muted); font-size: .8rem; margin-top: 6px; text-transform: uppercase; letter-spacing: .04em; }
.kpi.alerta .n { color: var(--warn); }
.kpi.off .n { color: var(--crit); }
.kpi.on .n { color: var(--ok); }

.sec-titulo { margin: 28px 0 12px; font-size: 1.05rem; font-weight: 700; }

/* TABLE */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 680px; font-size: .9rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface2); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }
.cli-nome { font-weight: 600; }
.cli-cnpj { color: var(--dim); font-size: .78rem; font-family: var(--mono); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* PILLS */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-family: var(--mono); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.crit { color: var(--crit); background: var(--crit-bg); }
.pill.acc { color: var(--accent); background: var(--acc-bg); }
.pill.neutro { color: var(--muted); background: var(--surface2); }

.vazio { color: var(--muted); margin-top: 16px; }

/* MODAL */
#overlay { position: fixed; inset: 0; background: rgba(5,10,20,.6); display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 20; }
#overlay[hidden] { display: none; }
.modal { width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); }
.modal-titulo { font-size: 1.15rem; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: .82rem; font-family: var(--mono); margin-top: 3px; }
#btn-fechar { background: none; border: none; color: var(--muted); font-size: 1.2rem; }
.modal-body { padding: 20px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kv .item { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kv .item .l { color: var(--dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.kv .item .v { font-weight: 600; margin-top: 3px; }
.ind-titulo { margin: 20px 0 10px; font-weight: 700; font-size: .95rem; }
.ind { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ind:last-child { border-bottom: none; }
.ind .h { font-family: var(--mono); font-size: .85rem; }
.ind .t { color: var(--dim); font-size: .75rem; }

/* TABS (Frota / Versões) */
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 9px; padding: 7px 16px; font-size: .9rem; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.ativo { color: var(--text); background: var(--surface2); border-color: var(--border); }
#view-frota[hidden], #view-versoes[hidden], #view-equipe[hidden], #view-instalacoes[hidden] { display: none; }
.sec-hint { font-size: .78rem; font-weight: 400; color: var(--dim); margin-left: 8px; }

/* VERSÕES */
#versoes-lista { display: flex; flex-direction: column; gap: 14px; }
.ver-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.ver-card.liberada { border-color: rgba(52,211,153,.4); }
.ver-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ver-tag { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.ver-data { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.ver-hint { color: var(--dim); font-size: .78rem; margin-top: 8px; }
.lib-btn { flex: none; background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 14px; font-size: .82rem; font-weight: 600; }
.lib-btn:hover { color: var(--text); }
.lib-btn.on { color: var(--ok); background: var(--ok-bg); border-color: rgba(52,211,153,.4); }
.lib-btn:disabled { opacity: .5; cursor: default; }
.ver-assets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.asset-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; font-size: .85rem; font-family: var(--mono); }
.asset-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.asset-btn:disabled { opacity: .45; cursor: default; }
.asset-btn .dl { color: var(--accent); font-family: var(--f); }
.asset-btn .sz { color: var(--dim); font-size: .78rem; }
.ver-notas { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: .85rem; max-height: 160px; overflow-y: auto; white-space: normal; }

/* PAGINAÇÃO */
.pag { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.pag[hidden] { display: none; }
.pag-btn { background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 16px; font-size: .85rem; font-weight: 600; }
.pag-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pag-btn:disabled { opacity: .4; cursor: default; }
.pag-info { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }

/* ASSINATURA (kill-switch no detalhe) */
.assinatura { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.ass-topo { display: flex; align-items: center; gap: 10px; }
.ass-lbl { font-weight: 700; font-size: .95rem; }
.ass-topo .t, .ass-motivo .t { color: var(--dim); font-size: .78rem; }
.ass-motivo { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.ass-input { width: 100%; height: 38px; margin-top: 12px; padding: 0 12px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 9px; color: var(--text); font-size: .88rem; font-family: var(--f); }
.ass-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--acc-bg); }
.ass-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* LIMITE DE DISPOSITIVOS */
.lim-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.lim-info { font-size: .9rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lim-acao { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.lim-acao .ass-input { max-width: 120px; }
.est-btn { border: 1px solid var(--border); border-radius: 9px; padding: 8px 15px; font-size: .84rem; font-weight: 600;
  background: var(--surface2); color: var(--text); }
.est-btn.ok:hover { color: var(--ok); border-color: var(--ok); }
.est-btn.acc:hover { color: var(--accent); border-color: var(--accent); }
.est-btn.crit:hover { color: var(--crit); border-color: var(--crit); }
.est-btn.neutro:hover { color: var(--muted); border-color: var(--muted); }
.est-btn:disabled { opacity: .5; cursor: default; }
.ass-input.erro-campo { border-color: var(--crit); box-shadow: 0 0 0 3px var(--crit-bg); }
.ass-erro { color: var(--crit); font-size: .8rem; margin-top: 8px; }

/* MODAL DE CONFIRMAÇÃO (design da Central, substitui o confirm() nativo) */
#confirm-overlay { position: fixed; inset: 0; background: rgba(5,10,20,.7); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 40; }
#confirm-overlay[hidden] { display: none; }
.confirm-box { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.confirm-titulo { font-size: 1.1rem; font-weight: 700; }
.confirm-msg { color: var(--muted); font-size: .92rem; margin-top: 10px; line-height: 1.55; }
.confirm-acoes { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.btn-sec { background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 18px; font-size: .88rem; font-weight: 600; }
.btn-sec:hover { color: var(--text); }
.btn-pri { background: var(--accent-dk); color: #fff; border: none; border-radius: 9px;
  padding: 9px 18px; font-size: .88rem; font-weight: 700; }
.btn-pri:hover { background: var(--accent); }
.btn-pri.perigo { background: var(--crit); }
.btn-pri.perigo:hover { background: #ef4444; }

/* SENHA-OVERLAY (mesma moldura do confirm) */
#senha-overlay { position: fixed; inset: 0; background: rgba(5,10,20,.7); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 40; }
#senha-overlay[hidden] { display: none; }
#senha-nova { margin-top: 16px; }

/* EQUIPE (usuários do painel) */
.novo-usuario { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 20px; }
.nu-titulo { font-weight: 700; font-size: .95rem; margin-bottom: 12px; }
.nu-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.nu-campo { display: flex; flex-direction: column; gap: 5px; flex: 1 1 180px; }
.nu-campo label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.nu-campo input, .nu-campo select { height: 40px; padding: 0 12px; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: .9rem; font-family: var(--f); }
.nu-campo input:focus, .nu-campo select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--acc-bg); }
.novo-usuario .btn-pri { height: 40px; flex: none; }
.nu-ok { color: var(--ok); font-size: .84rem; margin-top: 10px; }

#tbl-equipe tbody tr { cursor: default; }
#tbl-equipe tbody tr:hover { background: transparent; }
.col-acoes { white-space: nowrap; text-align: right; }
.mini { background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 11px; font-size: .78rem; font-weight: 600; margin-left: 6px; }
.mini:hover { color: var(--text); border-color: var(--accent); }
.mini.perigo:hover { color: var(--crit); border-color: var(--crit); }
.tag-eu { font-size: .68rem; font-weight: 600; color: var(--accent); background: var(--acc-bg);
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }

/* ZONA DE PERIGO (excluir cliente no detalhe) */
.perigo-box { background: var(--crit-bg); border: 1px solid rgba(248,113,113,.4); border-radius: 12px; padding: 16px; }
.perigo-box .t { color: var(--muted); font-size: .84rem; margin-bottom: 12px; line-height: 1.55; }

/* INSTALAÇÕES (relatórios dos instaladores) */
.chk { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; margin-bottom: 12px; cursor: pointer; }
.chk input { accent-color: var(--accent-dk); width: 16px; height: 16px; }
.inst-motivo { color: var(--muted); font-size: .8rem; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-etapa { font-size: .85rem; }
.modal.largo { max-width: 880px; }
.res-box { border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--bg); }
.res-box.crit { background: var(--crit-bg); border-color: rgba(248,113,113,.4); }
.res-box.warn { background: var(--warn-bg); border-color: rgba(251,191,36,.4); }
.res-box.ok { background: var(--ok-bg); border-color: rgba(52,211,153,.4); }
.res-box .res-etapa { font-weight: 700; font-size: .92rem; }
.res-box .res-msg { color: var(--text); font-size: .88rem; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.verif { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.verif:last-child { border-bottom: none; }
.verif .pill { flex: none; margin-top: 1px; }
.verif .vt { font-size: .86rem; font-weight: 600; }
.verif .vd { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.verif .vs { color: var(--text); font-size: .8rem; margin-top: 3px; overflow-wrap: anywhere; }
.verif .vs::before { content: "→ "; color: var(--accent); }
details.verif-ok summary { cursor: pointer; color: var(--muted); font-size: .84rem; padding: 8px 0; }
.log-acoes { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; }
.log-acoes .ind-titulo { margin: 0; }
.log-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0;
  font-family: var(--mono); font-size: .74rem; line-height: 1.5; color: var(--muted); max-height: 420px; overflow: auto; white-space: pre; }

/* HISTÓRICO DE ASSINATURA (auditoria no detalhe) */
.aud-item { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border); }
.aud-item:last-child { border-bottom: none; }
.aud-txt { font-size: .85rem; }
.aud-meta { color: var(--dim); font-size: .74rem; font-family: var(--mono); white-space: nowrap; }
