:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #1c2330; --muted: #667085; --line: #e2e6ec;
  --brand: #1f5fbf; --brand-ink: #ffffff; --ok: #157347; --ok-bg: #e4f4ea;
  --warn: #8a5a00; --warn-bg: #fff3d6; --bad: #b42318; --bad-bg: #fde8e6; --code: #f0f2f6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1a1f28; --ink: #e6e9ef; --muted: #98a2b3; --line: #2a303c;
    --brand: #5b9bff; --brand-ink: #0b1220; --ok: #4ade80; --ok-bg: #12301f;
    --warn: #f5c451; --warn-bg: #362b0e; --bad: #ff8a80; --bad-bg: #3b1714; --code: #10141a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }
.auth-shell { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 100px); }
.auth-shell .card.form { width: 100%; max-width: 380px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.top { display: flex; align-items: center; gap: 20px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.top nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.top nav a { color: var(--muted); }
.top nav a:hover, .top nav a.on { color: var(--ink); text-decoration: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.align-end { align-items: flex-end; }
.notify-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.notify-col { min-width: 0; }
.notify-col > .card:last-child { margin-bottom: 0; }
@media (max-width: 900px) { .notify-grid { grid-template-columns: 1fr; } }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 16px; }
.checks label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--muted); }
details.card[open] > summary::before { content: "▾"; }
details.edit-kinds { margin-top: 6px; }
details.edit-kinds > summary { cursor: pointer; color: var(--brand); }
.summary-title { font-size: 16px; font-weight: 700; }
#wa-qr { display: block; width: 260px; height: 260px; margin: 8px auto 0; background: #fff; padding: 8px; border-radius: 8px; }
#wa-qr[hidden] { display: none; }
h2.section { margin-top: 16px; font-size: 14px; color: var(--muted); }
.tunnel { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { border-color: var(--brand); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--muted); padding: 0; }
input:not([type]), input[type=text], input[type=password], input[type=number], select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.check label { display: flex; gap: 8px; font-weight: 400; align-items: center; }
.check input { width: auto; }
.form { max-width: 520px; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
a.pill { text-decoration: none; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.idle { background: var(--code); color: var(--muted); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
pre, code { background: var(--code); border-radius: 6px; font: 13px/1.5 ui-monospace, Consolas, monospace; }
code { padding: 1px 5px; }
pre { padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
.spark { color: var(--brand); vertical-align: middle; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 20px; overflow-wrap: anywhere; }
.cards.centered .stat { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.cards.centered .stat b { font-size: 18px; line-height: 1.25; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.seg { display: flex; gap: 2px; }
.seg label { margin: 0; font-weight: 400; font-size: 13px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { font-weight: 700; }
.seg label:has(input:checked) { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg label.remove:has(input:checked) { background: var(--bad); color: var(--brand-ink); border-color: var(--bad); }
.devlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.devlist label { font-weight: 400; display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; margin: 0; }
.devlist input { width: auto; }
.cell { font-size: 12px; line-height: 1.4; }
.cell b { font-weight: 600; }
.tag { color: var(--brand); }
.untag { color: var(--ok); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.nowrap { white-space: nowrap; }
pre.script { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; white-space: pre; font: 13px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; user-select: all; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
.actions form { display: inline; }
.actions button { padding: 3px 9px; font-size: 13px; }
tr.off td { color: var(--muted); }
tr.off td:not(.actions) { text-decoration: line-through; text-decoration-color: var(--line); }
.mono { font: 13px/1.4 ui-monospace, Consolas, monospace; word-break: break-word; }
select.inline { width: auto; display: inline-block; padding: 2px 6px; }
.sev { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.sev.critico { background: var(--bad-bg); color: var(--bad); }
.sev.atencao { background: var(--warn-bg); color: var(--warn); }
.sev.info { background: var(--code); color: var(--muted); }
.finding { border-left: 4px solid var(--line); }
.finding.critico { border-left-color: var(--bad); }
.finding.atencao { border-left-color: var(--warn); }
.finding ul { margin: 6px 0; padding-left: 18px; }
.finding li { margin: 2px 0; }
.fix { color: var(--muted); }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line-rx { stroke: var(--brand); }
.chart .line-tx { stroke: var(--ok); }
.live-row { cursor: pointer; }
.live-row:hover, .live-row.selected { background: var(--bg); }
.live-filter { width: 220px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.legend .rx { background: var(--brand); }
.legend .tx { background: var(--ok); }
textarea.code { font: 13px/1.5 ui-monospace, Consolas, monospace; min-height: 130px; }
.event { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.filters { margin-bottom: 14px; }
.filters input[type=text] { width: auto; flex: 2 1 220px; }
.filters select { width: auto; flex: 0 1 150px; }
.filters button, .filters a { flex: 0 0 auto; }
.radio-group { display: flex; gap: 18px; align-items: center; height: 38px; }
.radio-group label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 8px; max-width: 620px; }
.chips .chip { color: var(--muted); overflow-wrap: anywhere; }
.chips .chip b { color: var(--ink); font-weight: 600; }
/* "Detalhes" absorve o espaco sobrando da tabela; as demais colunas ficam do tamanho do conteudo,
   sem isso o navegador espalha o vazio antes de "Comentario" em vez de deixar os chips crescerem. */
.col-details { width: 100%; }
.col-comment { width: 1%; max-width: 220px; }
.col-actions { width: 1%; white-space: nowrap; }
.primary-cell { width: 1%; }
.primary-cell { font-weight: 600; white-space: nowrap; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.company-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; color: var(--ink); }
.company-card:hover { border-color: var(--brand); text-decoration: none; }
.company-card.bad, .stat.bad { border-color: var(--bad); }
.stat.bad b { color: var(--bad); }
.company-card h2 { margin: 0 0 10px; font-size: 17px; }
.stat-mini { color: var(--muted); font-size: 14px; }
.stat-mini b { color: var(--ink); font-size: 16px; }
@media (max-width: 640px) { .top { gap: 10px; } th, td { padding: 6px; } }

.pill.warn { background: var(--warn-bg); color: var(--warn); }
.stat.ok { border-color: var(--ok); }
.stat.ok b { color: var(--ok); }
.stat.warn { border-color: var(--warn); }
.stat.warn b { color: var(--warn); }
a.stat { display: block; color: inherit; text-decoration: none; }
.bad-text { color: var(--bad); font-weight: 600; }
tr.lvl-bad td { background: var(--bad-bg); }
tr.lvl-warn td { background: var(--warn-bg); }

.vpn-sec { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 14px; }
.vpn-head h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.vpn-head .count { background: var(--code); color: var(--ink); border-radius: 99px; padding: 0 8px; margin-left: 4px; font-size: 12px; }
.vpn-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.vpn-head + .vpn-item { border-top: 0; }
.vpn-pills { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.vpn-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.vpn-form .field { margin-bottom: 4px; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--code); }
.checks .check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; overflow-wrap: anywhere; }
.checks input[type=checkbox] { width: auto; margin: 0; }

.namebtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.namebtn:hover { text-decoration: underline; border: 0; }
dialog.detail { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(760px, 94vw); max-height: 86vh; background: var(--panel); color: var(--ink); }
dialog.detail::backdrop { background: rgba(0, 0, 0, .45); }
.detail-body { padding: 16px 18px; max-height: 86vh; overflow: auto; }
.detail-body h3 { margin: 0; font-size: 17px; }
table.kv { width: 100%; margin-top: 10px; }
table.kv th { width: 34%; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
table.kv td { overflow-wrap: anywhere; }

/* Explorador: botoes da linha lado a lado (a celula estreita fazia o flex empilhar um embaixo do outro) */
td.col-actions.actions { display: table-cell; white-space: nowrap; text-align: right; }
td.col-actions.actions > form, td.col-actions.actions > a.btn { display: inline-block; vertical-align: middle; margin: 0 0 0 4px; }
td.col-actions.actions .btn, td.col-actions.actions button { padding: 3px 9px; font-size: 13px; }

table.kv td { white-space: pre-wrap; }   /* scripts e valores de varias linhas aparecem com as quebras */

.crumb { margin: 2px 0 8px; }

/* registro unico (recursos, routerboard...): grade de campos em vez de chips */
dl.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 12px 0 0; }
dl.specs .spec { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
dl.specs dt { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
dl.specs dt .mono { font-weight: 400; opacity: .7; margin-left: 4px; }
dl.specs dd { margin: 4px 0 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }

/* assistente de VLAN: modo automatico ou manual (so CSS, a pagina nao aceita script embutido) */
.vlan-modes .panel-auto, .vlan-modes .panel-manual { margin-top: 14px; }
.vlan-modes:has(#mode-auto:checked) .panel-manual { display: none; }
.vlan-modes:has(#mode-manual:checked) .panel-auto { display: none; }
.path { font-size: 17px; }

/* mapa de VLANs: uma VLAN por cartao, portas como etiquetas pequenas */
.vlan-card > summary { gap: 10px; }
.vlan-card .vid { font-size: 16px; }
.vlan-devs { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 4px; }
.vlan-table { margin-top: 10px; }
.ports { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); }
.pchip.t { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.pchip.u { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

/* mapa de VLANs: lista a esquerda, desenho a direita */
.vm-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .vm-layout { grid-template-columns: 1fr; } }
.vm-list { display: flex; flex-direction: column; gap: 6px; max-height: 78vh; overflow: auto; position: sticky; top: 8px; }
.vm-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); text-decoration: none; }
.vm-item:hover { border-color: var(--brand); text-decoration: none; }
.vm-item.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--panel)); }
.vm-main h2 { margin-top: 0; }
.vm-svg { display: block; width: 100%; height: auto; min-height: 460px; max-height: calc(100vh - 210px); }
.vm-edge { fill: none; stroke: var(--line); stroke-width: 2.5; }
.vm-edge.both { stroke: var(--brand); stroke-width: 6; }
.vm-edge.one { stroke: var(--warn); stroke-width: 5; stroke-dasharray: 11 7; }
.vm-node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.vm-node.on rect { fill: color-mix(in srgb, var(--brand) 16%, var(--panel)); stroke: var(--brand); stroke-width: 2.5; }
.vm-node.off { opacity: .55; }
.vm-label { font: 700 20px ui-monospace, Menlo, Consolas, monospace; fill: var(--ink); }
.vm-name { font: 15px system-ui, sans-serif; fill: var(--muted); }
.vm-badge { font: 700 16px ui-monospace, Menlo, Consolas, monospace; fill: var(--brand); }
.vm-port { font: 10.5px ui-monospace, Menlo, Consolas, monospace; fill: var(--muted); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.vm-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 0; }
.vm-key { display: inline-block; width: 28px; height: 0; border-top: 4px solid var(--line); vertical-align: middle; margin-right: 4px; }
.vm-key.both { border-top: 5px solid var(--brand); }
.vm-key.one { border-top: 4px dashed var(--warn); }

/* pagina larga (mapa de VLANs usa toda a largura da tela) */
main.wide { max-width: none; padding-left: 24px; padding-right: 24px; }
.vm-title { display: flex; align-items: baseline; gap: 12px; }
.vm-title h2 { margin: 0 0 8px; }
.vm-card { padding: 12px; }
.vm-node:hover rect { stroke-width: 3.5; }

.vm-title .vm-remove { margin-left: auto; padding: 4px 12px; font-size: 13px; }

/* vizinhos: uma interface por linha, cortada com reticencias (o nome completo fica no tooltip) */
.nb-id { min-width: 170px; }
.nb-if-cell { min-width: 190px; max-width: 260px; }
.nb-if { display: block; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.nb-act { width: 1%; text-align: right; }
.reveal-btn { margin-left: 8px; padding: 1px 10px; font-size: 12px; }
.ignore-box { margin-top: 6px; }
.ignore-box > summary { cursor: pointer; }
.ignored-list .event { justify-content: space-between; align-items: center; }

/* logs remotos */
.logfilter .field.grow, .field.grow { flex: 1 1 220px; }
.logfilter input, .logfilter select { min-width: 130px; }
label.check { display: flex; gap: 6px; align-items: center; font-weight: 400; }
label.check input { width: auto; min-width: 0; }
table.logtable td { vertical-align: top; padding: 4px 8px; }
.nowrap { white-space: nowrap; }
.logmsg { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
tr.sev-critico .logmsg, tr.sev-erro .logmsg { color: var(--bad); }
.presets form { margin-bottom: 6px; }

#equipamento { scroll-margin-top: 12px; }

/* barra de botoes da pagina da empresa: tudo numa linha (grupos separados por um respiro), mesma altura; se faltar largura, quebra alinhada a esquerda */
.company-head { margin-bottom: 4px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 6px 0 18px; }
.tb-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.toolbar form { margin: 0; }
.toolbar .btn, .toolbar button { min-height: 36px; display: inline-flex; align-items: center; padding-left: 12px; padding-right: 12px; white-space: nowrap; }
/* Comandos em massa: formulario em duas colunas (o que aplicar | equipamentos) ocupando a largura toda, com o botao fixo embaixo */
.fleet-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.fleet-grid .card { margin-bottom: 0; }
.fleet-targets { max-height: 60vh; overflow: auto; }
.fleet-targets thead th { position: sticky; top: 0; background: var(--panel); }
.fleet-fields .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fleet-actions { grid-column: 1 / -1; position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); }
@media (max-width: 900px) { .fleet-grid { grid-template-columns: 1fr; } .fleet-fields .two { grid-template-columns: 1fr; } }

/* Comandos em massa: ajustes de uso */
.fleet-actions select, .row select.auto { width: auto; }
.fleet-tools { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 0 0 10px; }
.fleet-tools input { flex: 1 1 180px; min-width: 140px; }
.fleet-tools .count { margin-left: auto; white-space: nowrap; }
.fleet-targets tbody tr:hover { background: var(--code); }
.fleet-targets td, .fleet-targets th { padding-top: 7px; padding-bottom: 7px; }
.fleet-targets label { margin: 0; font-weight: 600; cursor: pointer; }
.fleet-change { min-width: 320px; }
.fleet-change .pill { margin-top: 4px; white-space: normal; }
.fleet-confirm { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.fleet-confirm .grow { flex: 1 1 320px; }
.fleet-grid.single { grid-template-columns: minmax(0, 1fr); }
