:root {
  color-scheme: dark;
  --fundo: #0b0d14;
  --fundo-2: #11141e;
  --cartao: #161a26;
  --cartao-2: #1c2130;
  --borda: rgba(255,255,255,0.08);
  --texto: #eef0f6;
  --texto-2: #9aa1b5;
  --texto-3: #6b7287;
  --acento: #7c83ff;
  --acento-2: #5b61f0;
  --ok: #0aac23;
  --ok-fundo: rgba(10,172,35,0.14);
  --aten: #fbb315;
  --aten-fundo: rgba(251,179,21,0.14);
  --fora: #dc3c3d;
  --fora-fundo: rgba(220,60,61,0.16);
  --cinza: #6b7287;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --grade: #262b3a;
  --eixo: #474747;
  --sombra: 0 8px 30px rgba(0,0,0,0.35);
  --raio: 18px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --fundo: #f3f4f8; --fundo-2: #eceef4; --cartao: #ffffff; --cartao-2: #f6f7fb;
  --borda: rgba(11,11,11,0.09); --texto: #191b24; --texto-2: #5d6375; --texto-3: #8a90a2;
  --acento: #4f46e5; --acento-2: #4338ca;
  --ok: #0a8a1f; --ok-fundo: rgba(10,138,31,0.10); --aten: #b77d00; --aten-fundo: rgba(242,166,0,0.14);
  --fora: #dc3c3d; --fora-fundo: rgba(220,60,61,0.10);
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --grade: #e7e7e7; --eixo: #c2c2c2; --sombra: 0 6px 24px rgba(20,24,40,0.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --fundo: #f3f4f8; --fundo-2: #eceef4; --cartao: #ffffff; --cartao-2: #f6f7fb;
    --borda: rgba(11,11,11,0.09); --texto: #191b24; --texto-2: #5d6375; --texto-3: #8a90a2;
    --acento: #4f46e5; --acento-2: #4338ca;
    --ok: #0a8a1f; --ok-fundo: rgba(10,138,31,0.10); --aten: #b77d00; --aten-fundo: rgba(242,166,0,0.14);
    --fora: #dc3c3d; --fora-fundo: rgba(220,60,61,0.10);
    --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
    --grade: #e7e7e7; --eixo: #c2c2c2; --sombra: 0 6px 24px rgba(20,24,40,0.08);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; overflow-x: hidden; }
a { color: var(--acento); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
.mudo { color: var(--texto-2); }
.mudo-3 { color: var(--texto-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.carregando { display: grid; place-items: center; min-height: 100vh; color: var(--texto-2); text-align: center; }
.logo-anim { font-size: 44px; color: var(--acento); animation: pulso 1.4s infinite; }
@keyframes pulso { 50% { opacity: .35; transform: scale(.92); } }

/* ---------- Estrutura ---------- */
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--fundo) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--borda); }
.marca { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.marca .bolinha { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--acento), #b46cff); color: #fff; font-size: 15px; }
.ao-vivo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--texto-2);
  padding: 4px 9px; border-radius: 99px; background: var(--cartao); border: 1px solid var(--borda); }
.ao-vivo i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: vivo 2s infinite; }
.ao-vivo.parado i { background: var(--fora); animation: none; }
@keyframes vivo { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } }
.espaco { flex: 1; }
.btn-icone { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--borda); background: var(--cartao);
  display: grid; place-items: center; font-size: 17px; }
.btn-icone:active { transform: scale(.95); }

.conteudo { max-width: 1240px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--fundo-2) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--borda); }
.nav button { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--texto-3); padding: 6px 0; border-radius: 12px; position: relative; }
.nav button span.ic { font-size: 20px; filter: grayscale(.7); opacity: .8; }
.nav button.ativo { color: var(--texto); }
.nav button.ativo span.ic { filter: none; opacity: 1; }
.nav button .badge { position: absolute; top: 2px; right: calc(50% - 20px); min-width: 17px; height: 17px; border-radius: 9px;
  background: var(--fora); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
@media (min-width: 900px) {
  .nav { top: 64px; bottom: auto; left: max(16px, calc(50% - 620px)); right: auto; flex-direction: row; gap: 4px;
    border: 1px solid var(--borda); border-radius: 14px; position: sticky; margin: 14px auto 0; width: max-content; padding: 4px; }
  .nav button { flex-direction: row; gap: 7px; font-size: 14px; padding: 8px 14px; }
  .nav button span.ic { font-size: 16px; }
  .nav button.ativo { background: var(--cartao-2); }
  .nav button .badge { position: static; }
  .conteudo { padding-bottom: 40px; }
}

/* ---------- Cartões ---------- */
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.cartao.clicavel { cursor: pointer; transition: transform .12s, border-color .12s; }
.cartao.clicavel:hover { border-color: color-mix(in srgb, var(--acento) 45%, var(--borda)); }
.cartao.clicavel:active { transform: scale(.985); }
.grade { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.gp { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.secao { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.secao .mais { margin-left: auto; font-size: 13px; }
.linha { display: flex; align-items: center; gap: 10px; }
.linha.entre { justify-content: space-between; }
.coluna { display: flex; flex-direction: column; gap: 6px; }

/* Herói */
.heroi { position: relative; overflow: hidden; padding: 20px; }
.heroi::after { content: ""; position: absolute; inset: auto -60px -80px auto; width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--cor-heroi, var(--ok)), transparent); opacity: .18; pointer-events: none; }
.heroi .grande { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.heroi .icone-status { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; font-size: 28px;
  background: color-mix(in srgb, var(--cor-heroi, var(--ok)) 18%, transparent); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; font-size: 13px;
  background: var(--cartao-2); border: 1px solid var(--borda); white-space: nowrap; }
button.chip.ativo { background: var(--acento); color: #fff; border-color: transparent; }
.chip.ok { color: var(--ok); background: var(--ok-fundo); border-color: transparent; }
.chip.aten { color: var(--aten); background: var(--aten-fundo); border-color: transparent; }
.chip.fora { color: var(--fora); background: var(--fora-fundo); border-color: transparent; }

/* Status */
.pilula { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pilula.ok { color: var(--ok); background: var(--ok-fundo); }
.pilula.atencao { color: var(--aten); background: var(--aten-fundo); }
.pilula.fora { color: var(--fora); background: var(--fora-fundo); }
.pilula.sem_dados, .pilula.info { color: var(--texto-2); background: var(--cartao-2); }
.ponto { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--cinza); }
.ponto.ok { background: var(--ok); } .ponto.atencao { background: var(--aten); } .ponto.fora { background: var(--fora); }
.ponto.pisca { animation: piscar 1.2s infinite; }
@keyframes piscar { 50% { opacity: .3; } }

/* Alertas */
.alerta { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--borda); background: var(--cartao); }
.alerta + .alerta { margin-top: 8px; }
.alerta.fora { border-left: 4px solid var(--fora); }
.alerta.atencao { border-left: 4px solid var(--aten); }
.alerta .t { font-weight: 600; }
.alerta .d { font-size: 13px; color: var(--texto-2); white-space: pre-line; }

/* Servidor mini */
.srv .nome { font-weight: 650; font-size: 16px; }
.medidores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.medidor { text-align: center; }
.medidor svg { width: 100%; max-width: 70px; display: block; margin: 0 auto; }
.medidor .v { font-weight: 700; font-size: 14px; }
.medidor .r { font-size: 11px; color: var(--texto-3); }
.sparkline { height: 44px; margin-top: 10px; }

/* Projetos */
.proj { display: flex; flex-direction: column; gap: 8px; min-height: 108px; }
.proj .topo-p { display: flex; align-items: center; gap: 10px; }
.proj .emoji { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; background: var(--cartao-2); flex: none; }
.proj .nm { font-weight: 620; line-height: 1.25; }
.proj .sub { font-size: 12px; color: var(--texto-3); }
.proj.fora { border-color: color-mix(in srgb, var(--fora) 55%, var(--borda)); }
.proj.atencao { border-color: color-mix(in srgb, var(--aten) 45%, var(--borda)); }
.barra-uptime { display: flex; gap: 2px; height: 22px; align-items: stretch; margin-top: 4px; }
.barra-uptime i { flex: 1; border-radius: 3px; background: var(--ok); opacity: .85; }
.barra-uptime i.atencao { background: var(--aten); } .barra-uptime i.fora { background: var(--fora); }
.barra-uptime i.sem { background: var(--cartao-2); }
.busca { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--borda); background: var(--cartao);
  color: var(--texto); font: inherit; outline: none; }
.busca:focus { border-color: var(--acento); }
.rolagem-x { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.rolagem-x::-webkit-scrollbar { display: none; }

/* Atalhos */
.atalho { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--cartao);
  border: 1px solid var(--borda); color: var(--texto); font-size: 14px; }
.atalho .ic { font-size: 20px; }
.atalho:active { transform: scale(.97); }

/* Eventos */
.evento { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borda); cursor: pointer; }
.evento:last-child { border-bottom: 0; }
.evento .quando { font-size: 12px; color: var(--texto-3); width: 76px; flex: none; }
.evento .t { font-size: 14px; font-weight: 550; }
.evento .d { font-size: 12px; color: var(--texto-2); }

/* Clima */
.clima .temp { font-size: 40px; font-weight: 750; letter-spacing: -.03em; }
.clima .ic { font-size: 46px; }
.dias { display: flex; gap: 8px; margin-top: 10px; }
.dias div { flex: 1; text-align: center; background: var(--cartao-2); border-radius: 12px; padding: 8px 4px; font-size: 12px; }

/* Barras */
.barra { height: 8px; border-radius: 99px; background: var(--cartao-2); overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 99px; background: var(--s1); }
.barra > i.aten { background: var(--aten); } .barra > i.fora { background: var(--fora); }

/* Tabelas/listas */
.lista > div { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--borda); }
.lista > div:last-child { border-bottom: 0; }
.lista .nm { font-weight: 560; overflow-wrap: anywhere; }
.lista .dt { font-size: 12px; color: var(--texto-3); overflow-wrap: anywhere; }
.lista .acoes { margin-left: auto; display: flex; gap: 6px; flex: none; }
.btn { border: 1px solid var(--borda); background: var(--cartao-2); color: var(--texto); padding: 8px 13px; border-radius: 11px;
  font-size: 13px; font-weight: 560; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:active { transform: scale(.96); }
.btn.prim { background: var(--acento); color: #fff; border-color: transparent; }
.btn.perigo { color: var(--fora); }
.btn.peq { padding: 6px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.segmento { display: inline-flex; background: var(--cartao-2); border: 1px solid var(--borda); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmento button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-size: 13px; color: var(--texto-2); }
.segmento button.ativo { background: var(--cartao); color: var(--texto); box-shadow: 0 1px 4px rgba(0,0,0,.2); font-weight: 600; }

/* Gráficos */
.grafico { position: relative; height: 190px; }
.grafico.alto { height: 240px; }
.grafico.baixo { height: 120px; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--texto-2); margin-top: 6px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.kpi { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.kpi small { font-size: 14px; font-weight: 500; color: var(--texto-2); }

/* Câmeras */
.cam { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 16/9; cursor: pointer; border: 1px solid var(--borda); }
.cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .rot { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: #fff; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cam .rot b { font-weight: 650; text-transform: capitalize; }
.cam .rot .fps { margin-left: auto; font-size: 11px; opacity: .85; }
.cam .det { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 99px; }

/* Aparelhos */
.aparelho { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 12px; background: var(--cartao-2); font-size: 13px; min-width: 0; }
.aparelho .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aparelho .ip { margin-left: auto; font-size: 11px; color: var(--texto-3); flex: none; }
.aparelho.off { opacity: .55; }

/* Sheet (detalhe) */
.sheet-fundo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; backdrop-filter: blur(2px); }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--fundo-2); border-radius: 22px 22px 0 0; border: 1px solid var(--borda); padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  animation: subir .22s ease-out; }
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 900px) {
  .sheet { left: auto; right: 16px; top: 16px; bottom: 16px; width: 560px; max-height: none; border-radius: 22px; }
}
.sheet .alca { position: sticky; top: 0; background: var(--fundo-2); padding: 10px 0 12px; z-index: 2; display: flex; align-items: center; gap: 10px; }
.sheet .alca::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--borda); }
.sheet .alca h2 { font-size: 19px; margin-top: 10px; }
.sheet .fechar { margin-left: auto; margin-top: 10px; }
.bloco { margin-top: 18px; }
.bloco > h3 { margin-bottom: 8px; color: var(--texto-2); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; font-weight: 650; }
.log { background: #07080c; color: #cfd3df; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px; border-radius: 12px;
  max-height: 55vh; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.log .er { color: #ff7b7b; } .log .av { color: #ffd166; }

/* Formulários */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.campo label { font-size: 13px; color: var(--texto-2); }
.campo input, .campo select { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--borda); background: var(--cartao);
  color: var(--texto); font: inherit; outline: none; }
.campo input:focus { border-color: var(--acento); }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borda); }
.interruptor input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--cartao-2); border: 1px solid var(--borda);
  position: relative; cursor: pointer; transition: background .2s; flex: none; }
.interruptor input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; }
.interruptor input:checked { background: var(--ok); }
.interruptor input:checked::after { left: 21px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--acento) 25%, transparent), transparent),
              radial-gradient(700px 400px at 110% 110%, rgba(180,108,255,.18), transparent), var(--fundo); }
.login .caixa { width: 100%; max-width: 380px; }
.login .marca { justify-content: center; font-size: 22px; margin-bottom: 6px; }
.login .marca .bolinha { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
.login .btn.prim { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }
.erro-msg { color: var(--fora); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.ok-msg { color: var(--ok); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--texto); color: var(--fundo); padding: 11px 16px; border-radius: 14px; font-size: 14px; box-shadow: var(--sombra);
  max-width: calc(100vw - 32px); }
.vazio { text-align: center; padding: 26px 10px; color: var(--texto-2); }
.vazio .ic { font-size: 34px; display: block; margin-bottom: 6px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--cartao-2); color: var(--texto-2); white-space: nowrap; }
.oculto-mob { display: none; }
@media (min-width: 700px) { .oculto-mob { display: initial; } }
table.tab { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tab td, table.tab th { padding: 7px 6px; border-bottom: 1px solid var(--borda); text-align: left; }
table.tab th { color: var(--texto-3); font-weight: 600; }
