/* ==========================================================================
   ProOps · Pro Networks — folha de estilo única (sem framework, sem build).
   Tema ESCURO por padrão; o claro é alternável no topo e persistido em
   localStorage("proops_theme"). Nenhum componente hardcoda cor: tudo sai
   das variáveis abaixo.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  /* superfícies — do fundo para a frente */
  --bg:            #080B10;
  --bg-elev:       #0C1017;
  --surface:       #11161F;
  --surface-2:     #171E29;
  --surface-3:     #1E2632;
  --border:        #232C3A;
  --border-strong: #33404F;

  /* texto */
  --text:      #E9EEF5;
  --text-dim:  #B4C0CF;
  --muted:     #7E8C9F;

  /* marca Pro Networks */
  --accent:        #4C8DFF;
  --accent-hover:  #6BA1FF;
  --accent-weak:   #14243E;
  --accent-ink:    #0A0E14;
  --accent-2:      #22D3EE;
  --brand-grad:    linear-gradient(135deg, #4C8DFF 0%, #22D3EE 100%);

  /* estados */
  --ok:        #34D399;  --ok-weak:     #0F2C22;
  --warn:      #FBBF24;  --warn-weak:   #2E2410;
  --danger:    #F87171;  --danger-weak: #33161A;
  --info:      #818CF8;  --info-weak:   #1B1D3A;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6);

  --logo: url("/assets/pronetworks-horizontal-white.png");
  --logo-mark: url("/assets/pronetworks-mark-white.png");

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --sidebar:   238px;
  --topbar:    56px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:            #EEF1F5;
  --bg-elev:       #F5F7FA;
  --surface:       #FFFFFF;
  --surface-2:     #F4F6F9;
  --surface-3:     #E9EDF3;
  --border:        #DCE2EA;
  --border-strong: #C2CCD8;

  --text:      #0F141B;
  --text-dim:  #3B4655;
  --muted:     #67748A;

  --accent:        #1F6FEB;
  --accent-hover:  #175FD0;
  --accent-weak:   #E4EEFD;
  --accent-ink:    #FFFFFF;
  --accent-2:      #0891B2;
  --brand-grad:    linear-gradient(135deg, #1F6FEB 0%, #0891B2 100%);

  --ok:        #0E9F6E;  --ok-weak:     #E3F7EF;
  --warn:      #B45309;  --warn-weak:   #FDF2DC;
  --danger:    #DC2626;  --danger-weak: #FCE8E8;
  --info:      #4F46E5;  --info-weak:   #EBEAFD;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow:    0 4px 16px rgba(16,24,40,.10);
  --shadow-lg: 0 18px 50px rgba(16,24,40,.18);

  --logo: url("/assets/pronetworks-horizontal-dark.png");
  --logo-mark: url("/assets/pronetworks-mark-dark.png");
}

/* --------------------------------------------------------------- base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; }
::selection { background: var(--accent); color: var(--accent-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

.boot {
  min-height: 100vh; display: grid; place-items: center;
  color: var(--muted); gap: 16px; text-align: center;
}
.boot .logo-mark { width: 56px; height: 56px; opacity: .5; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: .75; } }

.logo { background: var(--logo) no-repeat left center / contain; }
.logo-mark { background: var(--logo-mark) no-repeat center / contain; }

/* ------------------------------------------------- login / instalação ---- */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, var(--accent-weak) 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 110%, var(--accent-weak) 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 30px 28px; box-shadow: var(--shadow-lg);
}
.auth-card.wide { max-width: 520px; }
.auth-logo { height: 34px; margin-bottom: 22px; }
.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.auth-card button.primary { width: 100%; margin-top: 4px; padding: 10px; font-weight: 600; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }
.auth-steps { display: flex; gap: 6px; margin-bottom: 20px; }
.auth-steps span { display: block; flex: 1; height: 3px; border-radius: 2px; background: var(--surface-3); }
.auth-steps span.on { background: var(--brand-grad); }

/* ------------------------------------------------------------- layout ---- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  grid-template-rows: var(--topbar) 1fr;
  height: 100vh;
}

.topbar {
  grid-column: 1 / 3; display: flex; align-items: center; gap: 14px;
  padding: 0 18px 0 0; background: var(--bg-elev);
  border-bottom: 1px solid var(--border); z-index: 20;
}
.topbar .brandbox {
  width: var(--sidebar); height: 100%; display: flex; align-items: center;
  padding: 0 18px; gap: 11px; border-right: 1px solid var(--border);
}
.topbar .brandbox .logo { height: 22px; width: 100%; }
.topbar .ctx { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar .ctx .net { font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.topbar .ctx .sub { font-size: 11.5px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .iconbtn {
  width: 32px; height: 32px; display: grid; place-items: center; font-size: 15px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer;
}
.topbar .iconbtn:hover { background: var(--surface-2); color: var(--text); }

.whoami { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent; }
.whoami:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-grad); color: #fff; font-size: 11.5px; font-weight: 700;
  letter-spacing: .3px; flex: none;
}
.whoami .who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.whoami .who b { font-size: 12.5px; font-weight: 600; }
.whoami .who span { font-size: 11px; color: var(--muted); }

.menu {
  position: absolute; top: calc(var(--topbar) - 4px); right: 16px; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.menu button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
}
.menu button:hover { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu .meta { padding: 8px 10px; font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------ sidebar ---- */
.sidebar {
  background: var(--bg-elev); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 10px 10px 24px; display: flex; flex-direction: column;
}
.sidebar .group-label {
  padding: 14px 10px 5px; font-size: 10.5px; text-transform: uppercase;
  color: var(--muted); letter-spacing: .8px; font-weight: 600;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 1px;
  color: var(--text-dim); border-radius: var(--radius-sm); font-size: 13.5px;
  transition: background .12s, color .12s;
}
.sidebar a .ico { width: 17px; text-align: center; font-size: 14px; opacity: .8; flex: none; }
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active {
  background: var(--accent-weak); color: var(--accent); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar a.active .ico { opacity: 1; }
.sidebar a .pill {
  margin-left: auto; font-size: 10.5px; padding: 0 6px; border-radius: 999px;
  background: var(--danger); color: #fff; font-weight: 700; line-height: 17px;
}
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 10px; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ------------------------------------------------------------ conteúdo --- */
.content {
  overflow-y: auto; padding: 18px 24px 40px;
  display: flex; flex-direction: column; min-height: 0;
}
.page-title { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; }
.page-title h1 { font-size: 21px; margin: 0; }
.page-title .spacer { flex: 1; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; max-width: 78ch; }

/* -------------------------------------------------------------- botões --- */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  padding: 6px 13px; border-radius: var(--radius-sm);
  transition: background .12s, border-color .12s, filter .12s;
}
button:hover { background: var(--surface-3); border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 4px 8px; }
button.ghost:hover { background: var(--accent-weak); }
button.subtle { background: transparent; border-color: var(--border); color: var(--text-dim); }
button.subtle:hover { background: var(--surface-2); color: var(--text); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.sm { padding: 3px 9px; font-size: 12px; }
button.block { width: 100%; }

/* -------------------------------------------------------- cards/tabelas -- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 12px; font-size: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 14px;
}
.table-scroll { overflow-x: auto; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase;
  color: var(--muted); letter-spacing: .5px; font-weight: 600; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.rowdanger td:first-child { box-shadow: inset 2px 0 0 var(--danger); }
td.actions { text-align: right; white-space: nowrap; }
/* Ações de linha ficam discretas até o hover: uma tabela com um botão vermelho gritando
   em cada linha cansa a vista e faz o destrutivo parecer rotina. */
td.actions button { background: transparent; border-color: var(--border); color: var(--text-dim); }
td.actions button:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
td.actions button.danger { color: var(--danger); border-color: transparent; }
td.actions button.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.empty { padding: 44px 24px; color: var(--muted); text-align: center; }
.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: .5; }
.empty h4 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty p { margin: 0 auto 14px; max-width: 46ch; font-size: 13px; }

/* -------------------------------------------------------------- badges --- */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
  white-space: nowrap; font-weight: 500;
}
.badge.ok     { background: var(--ok-weak);     color: var(--ok);     border-color: transparent; }
.badge.warn   { background: var(--warn-weak);   color: var(--warn);   border-color: transparent; }
.badge.danger { background: var(--danger-weak); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.badge.info   { background: var(--info-weak);   color: var(--info);   border-color: transparent; }
.tag-inherit  { font-size: 11px; color: var(--muted); font-style: italic; margin-left: 6px; }
.tag-explicit { font-size: 11px; color: var(--accent); margin-left: 6px; }
.statedot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }

/* --------------------------------------------------------------- forms --- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; margin-bottom: 5px; color: var(--text-dim); font-weight: 500; }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text);
  font: inherit; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak);
}
.field textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 13px; }
.field .err { color: var(--danger); font-size: 12px; margin-top: 4px; }
.field input.invalid, .field select.invalid { border-color: var(--danger); }
.field .ok-hint { color: var(--ok); font-size: 12px; margin-top: 4px; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; min-width: 0; }
.help { color: var(--muted); font-size: 12px; }
.searchbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.searchbar .input { max-width: 320px; }
.searchbar select { width: auto; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); font: inherit; }

/* medidor de força de senha */
.pwmeter { display: flex; gap: 4px; margin-top: 7px; }
.pwmeter span { display: block; flex: 1; height: 3px; border-radius: 2px; background: var(--surface-3); }
.pwmeter.s1 span:nth-child(1) { background: var(--danger); }
.pwmeter.s2 span:nth-child(-n+2) { background: var(--warn); }
.pwmeter.s3 span:nth-child(-n+3) { background: var(--accent); }
.pwmeter.s4 span { background: var(--ok); }

/* ------------------------------------------------------- banner do cofre - */
.vault-banner {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  border-radius: var(--radius); margin-bottom: 14px; font-size: 13px;
  border: 1px solid transparent; flex-wrap: wrap;
}
.vault-banner.locked   { background: var(--danger-weak); color: var(--danger); border-color: var(--danger); }
.vault-banner.insecure { background: var(--warn-weak);   color: var(--warn); }
.vault-banner.ok       { background: var(--ok-weak);     color: var(--ok); }
.vault-banner code { background: rgba(127,127,127,.16); padding: 2px 7px; border-radius: 5px; font-size: 12px; }
.vault-banner .spacer { flex: 1; }
.vault-banner button { border-color: currentColor; color: inherit; background: transparent; }
.vault-banner button:hover { background: rgba(127,127,127,.16); }
/* O botão de ação do banner usa o accent da marca: `currentColor` no fundo E no texto
   deixaria vermelho sobre vermelho — invisível. */
.vault-banner button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 600;
}
.vault-banner button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* alertas genéricos */
.alert { display: flex; gap: 11px; padding: 11px 14px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 13px; border: 1px solid transparent; align-items: flex-start; }
.alert .ico { font-size: 15px; line-height: 1.3; flex: none; }
.alert .body { flex: 1; min-width: 0; }
.alert b { display: block; margin-bottom: 2px; }
.alert.danger { background: var(--danger-weak); border-color: var(--danger); color: var(--danger); }
.alert.warn   { background: var(--warn-weak);   border-color: var(--warn);   color: var(--warn); }
.alert.info   { background: var(--accent-weak); border-color: var(--accent);  color: var(--accent); }
.alert.ok     { background: var(--ok-weak);     border-color: var(--ok);      color: var(--ok); }
.alert .body span, .alert .body p { color: var(--text-dim); }

/* --------------------------------------------------------------- modal --- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(4,7,12,.68); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; width: min(580px, 96vw); max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  /* `color` explícito: modais abertos de dentro de um contexto colorido (o banner do cofre,
     que é vermelho quando trancado) herdariam aquela cor no título e no texto. */
  color: var(--text);
}
.modal.wide { width: min(1100px, 96vw); }
.modal.xwide { width: 96vw; max-width: 1600px; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }

/* --------------------------------------------------------------- toasts -- */
.toast-host {
  position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column;
  gap: 8px; z-index: 60;
}
.toast {
  padding: 10px 15px; border-radius: var(--radius); color: #fff; box-shadow: var(--shadow-lg);
  max-width: 380px; font-size: 13px; animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }
.toast.info { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------ dashboard -- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-grad);
  opacity: .85;
}
.stat.is-ok::before     { background: var(--ok); }
.stat.is-warn::before   { background: var(--warn); }
.stat.is-danger::before { background: var(--danger); }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; font-weight: 600; }
.stat .v { font-size: 27px; font-weight: 660; letter-spacing: -.02em; margin: 3px 0 1px;
  font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; color: var(--muted); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--border-strong); background: var(--surface-2); }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.dash-grid.wide2 { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 980px) { .dash-grid.wide2 { grid-template-columns: 1fr; } }

/* barra de distribuição (por fabricante, papel, site…) */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 106px 1fr 34px; gap: 10px; align-items: center;
  font-size: 12.5px; }
.bar-row .lbl { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.bar-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
/* display:block explícito: são <span>, e inline ignoraria width/height. */
.bar-track { display: block; height: 7px; background: var(--surface-3); border-radius: 4px;
  overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 3px; background: var(--brand-grad);
  border-radius: 4px; transition: width .3s ease; }

/* lista "precisa de atenção" */
.health { display: flex; flex-direction: column; gap: 8px; }
.health-item {
  display: flex; gap: 11px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); align-items: flex-start;
}
.health-item.danger { border-left: 3px solid var(--danger); }
.health-item.warn   { border-left: 3px solid var(--warn); }
.health-item.info   { border-left: 3px solid var(--accent); }
.health-item .ico { font-size: 15px; flex: none; line-height: 1.3; }
.health-item .body { flex: 1; min-width: 0; }
.health-item b { font-size: 13px; display: block; }
.health-item span { font-size: 12px; color: var(--muted); display: block;
  overflow: hidden; text-overflow: ellipsis; }
.health-empty { display: flex; align-items: center; gap: 10px; color: var(--ok);
  padding: 16px; font-size: 13.5px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }

/* --------------------------------------------------------------- abas ---- */
.tabs {
  display: flex; align-items: stretch; gap: 2px; border-bottom: 1px solid var(--border);
  margin-bottom: 14px; overflow-x: auto;
}
.tabs > button {
  border: none; background: transparent; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; color: var(--muted); white-space: nowrap;
}
.tabs > button:hover { color: var(--text); background: transparent; }
.tabs > button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .tabs-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* --------------------------------------------- markdown / editor / código - */
.md { line-height: 1.65; }
.md h1, .md h2, .md h3 { margin-top: 1.3em; }
.md h1:first-child, .md h2:first-child { margin-top: 0; }
.md pre { background: var(--bg-elev); border: 1px solid var(--border); padding: 12px;
  border-radius: var(--radius-sm); overflow-x: auto; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.md pre code { background: transparent; padding: 0; }
.md table { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.md blockquote { margin: 12px 0; padding: 2px 14px; border-left: 3px solid var(--border-strong);
  color: var(--text-dim); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.md img { max-width: 100%; }

.md-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; gap: 10px; align-items: center; }
.md-readbox { margin: 0; max-height: 64vh; overflow: auto; }
pre.raw {
  font-family: var(--mono); font-size: 12.5px; background: var(--bg-elev);
  border: 1px solid var(--border); color: var(--text); padding: 12px;
  border-radius: var(--radius-sm); overflow: auto; white-space: pre-wrap;
  word-break: break-word; margin: 0; max-height: 64vh;
}
.codearea {
  width: 100%; min-height: 340px; font-family: var(--mono); font-size: 13px; padding: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--text); line-height: 1.55; tab-size: 2;
}
.codearea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* interruptor
   O seletor precisa incluir `.field label.toggle`: o interruptor É um <label>, e dentro de
   um .field a regra `.field label` (mais específica) o transformaria num rótulo de bloco. */
.toggle,
.field label.toggle {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
  margin-bottom: 0; color: var(--text); font-size: 13.5px; font-weight: 400;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { display: block; width: 36px; height: 20px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--border-strong); position: relative;
  transition: background .15s; flex: none; }
.toggle .thumb { display: block; position: absolute; top: 2px; left: 2px; width: 14px;
  height: 14px; border-radius: 50%; background: var(--muted);
  transition: left .15s, background .15s; }
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track .thumb { left: 18px; background: #fff; }
.toggle-label { font-size: 12.5px; color: var(--text-dim); }

.meter { height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; background: var(--accent); transition: width .25s; }
.meter.warn > div { background: var(--warn); } .meter.danger > div { background: var(--danger); }
.spinner { color: var(--muted); padding: 30px; text-align: center; }
.inline-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dangling { color: var(--danger); font-size: 12px; }
.rename-refs { margin: 8px 0; font-size: 12.5px; background: var(--warn-weak);
  border-color: var(--warn); color: var(--warn); }
.rename-refs ul { margin: 6px 0 0; padding-left: 18px; }

/* ------------------------------------------------- faixas de IP (chips) -- */
.range-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.range-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.range-item.invalid { border-color: var(--danger); background: var(--danger-weak); }
.range-item.unsaved { border-color: var(--warn); border-style: dashed; }
.range-item .cidr { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.range-item .desc { font-size: 11.5px; color: var(--muted); }
.range-item .spacer { flex: 1; }
.range-add { display: flex; gap: 8px; }
.range-add .input { flex: 1; font-family: var(--mono); }
/* Barra fixa de "não salvo": o botão de salvar do topo sai da tela quando se rola até a
   lista de faixas — e o operador saía achando que a faixa adicionada já valia. */
.save-bar {
  position: sticky; bottom: 12px; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px; padding: 11px 14px;
  background: var(--surface-2); border: 1px solid var(--warn);
  border-radius: var(--radius); box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
.save-bar .dot {
  width: 8px; height: 8px; border-radius: 999px; background: var(--warn); flex: none;
}
.save-bar .spacer { flex: 1; }
.save-bar .help { display: inline; }

.diff-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.diff-chip { font-family: var(--mono); font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.diff-chip.in  { background: var(--ok-weak); color: var(--ok); }
.diff-chip.out { background: var(--danger-weak); color: var(--danger); }

/* --------------------------------------------------- terminal (xterm.js) - */
.term-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.term-host {
  flex: 1; min-height: 340px; background: #06090D; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 8px 8px 12px; overflow: hidden;
}
.term-host .xterm { height: 100%; }
.term-host .xterm-viewport { background: transparent !important; }

/* --------------------------------------------------- página do assistente */
.cc-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cc-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 0 10px; border-bottom: 1px solid var(--border);
}
.cc-toolbar select { padding: 4px 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); font: inherit; }
.cc-modepick { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 7px; align-items: center; }
.cc-meta { font-size: 11.5px; color: var(--muted); }
.cc-bypass {
  display: flex; gap: 9px; align-items: center; padding: 7px 12px; border-radius: var(--radius-sm);
  background: var(--danger-weak); color: var(--danger); border: 1px solid var(--danger);
  font-size: 12.5px; margin: 8px 0;
}
.cc-transcript {
  flex: 1; min-height: 240px; overflow-y: auto; padding: 14px 4px;
  display: flex; flex-direction: column; gap: 13px;
}
.cc-msg { display: flex; flex-direction: column; gap: 3px; }
.cc-role { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.cc-msg.user { align-self: flex-end; max-width: 80%; align-items: flex-end; }
.cc-usertext {
  background: var(--accent); color: var(--accent-ink); padding: 9px 13px;
  border-radius: 12px 12px 3px 12px; white-space: pre-wrap; word-break: break-word;
}
.cc-msg.assistant { align-self: flex-start; max-width: 92%; }
.cc-msg.assistant .md {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px; padding: 3px 15px;
}
.cc-thinking { font-size: 12px; color: var(--muted); border-left: 2px solid var(--border-strong);
  padding-left: 10px; }
.cc-thinking pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0; font-size: 12px; }
.cc-tool { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 9px 11px; font-size: 12.5px; }
.cc-tool.running { border-color: var(--accent); }
.cc-tool.error { border-color: var(--danger); }
.cc-tool-head { display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; }
.cc-tool-desc { color: var(--muted); word-break: break-all; }
.cc-pre {
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word;
  margin: 7px 0 0; background: var(--bg-elev); border-radius: 6px; padding: 9px;
  max-height: 360px; overflow: auto;
}
.cc-pre.err { color: var(--danger); }
.cc-expand { font-size: 11.5px; margin-top: 5px; padding: 2px 9px; background: transparent;
  border: 1px solid var(--border); color: var(--accent); border-radius: var(--radius-sm); }
.cc-perm { border: 1px solid var(--warn); border-radius: var(--radius); background: var(--surface);
  padding: 11px 13px; }
.cc-perm.resolved { opacity: .7; border-color: var(--border); }
.cc-perm-head { font-size: 13px; margin-bottom: 5px; }
.cc-perm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 9px; }
.cc-perm-done { font-size: 12.5px; margin-top: 6px; }
.cc-perm-done.allow { color: var(--ok); } .cc-perm-done.deny { color: var(--danger); }
.cc-ask { border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface);
  padding: 11px 13px; }
.cc-ask.resolved { opacity: .8; border-color: var(--border); }
.cc-ask-q { margin: 9px 0; }
.cc-ask-title { font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.cc-ask-opts { display: flex; flex-direction: column; gap: 6px; }
.cc-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  text-align: left; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); }
.cc-opt:hover { border-color: var(--accent); }
.cc-opt.sel { border-color: var(--accent); background: var(--accent-weak); }
.cc-opt-desc { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.cc-ask-other { margin-top: 7px; width: 100%; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); }
.cc-sess-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.cc-sess { display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; }
.cc-sess:hover { border-color: var(--accent); }
.cc-sess.atual { border-color: var(--ok); }
.cc-sess-main { flex: 1; min-width: 0; }
.cc-sess-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-sess-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-result { font-size: 11.5px; color: var(--muted); text-align: center; }
.cc-result.err { color: var(--danger); }
.cc-error { color: var(--danger); font-size: 12.5px; background: var(--surface);
  border: 1px solid var(--danger); border-radius: var(--radius-sm); padding: 9px 13px; }
.cc-slash-menu { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 0; }
.cc-slash { font-family: var(--mono); font-size: 11.5px; }
.cc-composer { display: flex; flex-direction: column; gap: 7px; border-top: 1px solid var(--border);
  padding-top: 10px; }
.cc-composer textarea {
  width: 100%; min-height: 66px; max-height: 220px; resize: vertical; font-family: inherit;
  font-size: 14px; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--bg-elev); color: var(--text);
}
.cc-composer textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak); }
.cc-composer-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* ------------------------------------------------------------ responsivo - */
@media (max-width: 860px) {
  :root { --sidebar: 0px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; width: 238px; z-index: 30;
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .topbar .brandbox { width: auto; border-right: none; padding-left: 12px; }
  .topbar .brandbox .logo { width: 118px; }
  .content { padding: 14px 14px 32px; }
  .whoami .who { display: none; }
}
/* O ☰ só existe quando a sidebar vira gaveta. A especificidade precisa bater a de
   `.topbar .iconbtn`, que define display: grid. */
.topbar .navtoggle { display: none; }
@media (max-width: 860px) { .topbar .navtoggle { display: grid; } }
.scrim { position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0,0,0,.5); z-index: 25; }

/* ==========================================================================
   IMPRESSÃO / PDF — relatório executivo
   ==========================================================================
   O botão "Imprimir / PDF" chama window.print() na página inteira. Sem estas
   regras o PDF saía com o menu lateral, a barra do topo, o fundo escuro e —
   o pior — o relatório CORTADO, porque .md-readbox tem max-height: 64vh e
   overflow: auto: o navegador imprime só o que cabia na caixa de rolagem.

   Princípios:
     - papel é claro: força a paleta clara mesmo com o tema escuro na tela;
     - sem cromo: some tudo que não é o documento;
     - legível sem "gráficos de plano de fundo": hierarquia por tipografia,
       linha e peso, não por preenchimento colorido;
     - nada quebrado ao meio: título não fica órfão no rodapé, tabela repete
       o cabeçalho na página seguinte, bloco de código não parte no meio.
   ========================================================================== */

/* O cabeçalho e o rodapé do documento só existem no papel. */
.doc-head, .doc-foot { display: none; }

@media print {
  /* --- página ------------------------------------------------------------ */
  @page { size: A4; margin: 18mm 16mm 16mm; }

  /* Paleta clara à força: o tema escuro no papel queima toner e fica ilegível.
     Como o resto da folha usa estas variáveis, redefini-las converte a UI toda. */
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    --bg: #fff; --bg-elev: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f4f5f7;
    --text: #14181f; --text-dim: #2b323d; --muted: #5d6673;
    --border: #c9ced7; --border-strong: #9aa3b0;
    --accent: #14181f; --accent-ink: #fff; --accent-weak: #eef0f3;
    --ok: #1f6b3a; --warn: #8a5a00; --danger: #a12020;
    --ok-weak: #eef5f0; --warn-weak: #fbf5e8; --danger-weak: #fbeeee;
    --shadow-lg: none; --radius: 3px; --radius-sm: 2px; --radius-lg: 3px;
    --logo: url("/assets/pronetworks-horizontal-dark.png");
    --logo-mark: url("/assets/pronetworks-mark-dark.png");
  }

  html, body { background: #fff !important; color: #14181f; }
  body {
    font-size: 10.5pt; line-height: 1.5;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* --- fora tudo que não é o documento ----------------------------------- */
  .topbar, .sidebar, .scrim, .toast-host, .vault-banner, .menu,
  .modal-actions, .md-toolbar, .save-bar, .cc-composer, .page-sub {
    display: none !important;
  }

  /* A grade do shell vira fluxo normal: em grid com altura 100vh o conteúdo
     não pagina — o navegador imprime uma tela e para. */
  .shell { display: block; height: auto; }
  .content { display: block; overflow: visible; padding: 0; min-height: 0; }

  /* Com um modal aberto — que é o caso do relatório — o que está ATRÁS dele não vai para
     o papel. Sem isto, o título e a tabela da página de Relatórios apareciam no topo da
     primeira página do PDF, antes do cabeçalho do documento. */
  .content:has(.modal-bg) > *:not(:has(.modal-bg)) { display: none !important; }
  .content:has(.modal-bg) > * > *:not(.modal-bg)   { display: none !important; }

  /* O relatório é aberto num modal. No papel ele precisa ser só... o documento. */
  .modal-bg {
    position: static; inset: auto; display: block; padding: 0;
    background: none !important; backdrop-filter: none;
  }
  .modal, .modal.wide, .modal.xwide {
    width: auto; max-width: none; max-height: none; overflow: visible;
    border: none; border-radius: 0; box-shadow: none; padding: 0; background: #fff;
  }
  .modal > h2 { display: none; }          /* o nome do arquivo vai no cabeçalho do doc */

  /* >>> A CORREÇÃO QUE MAIS IMPORTA <<<
     Sem isto o PDF sai com uma página só: o conteúdo restante fica escondido
     dentro da caixa de rolagem. */
  .md-readbox, .card, .table-scroll, .raw {
    max-height: none !important; overflow: visible !important;
  }
  .card { border: none; padding: 0; margin: 0; background: none; }

  /* --- cabeçalho do documento (primeira página) --------------------------- */
  .doc-head {
    display: block; margin: 0 0 10mm; padding-bottom: 5mm;
    border-bottom: 2px solid #14181f;
  }
  .doc-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 7mm; }
  .doc-logo { height: 9mm; width: auto; flex: none; }
  .doc-kicker {
    margin-left: auto; font-size: 8pt; letter-spacing: .14em; text-transform: uppercase;
    color: #5d6673; font-weight: 600;
  }
  .doc-title {
    font-size: 21pt; line-height: 1.15; margin: 0 0 5mm; font-weight: 700;
    letter-spacing: -.01em;
  }
  .doc-meta { display: flex; flex-wrap: wrap; gap: 4mm 10mm; margin: 0; }
  .doc-meta div { display: flex; flex-direction: column; gap: 1px; }
  .doc-meta dt {
    font-size: 7.5pt; letter-spacing: .1em; text-transform: uppercase; color: #5d6673;
    font-weight: 600;
  }
  .doc-meta dd { margin: 0; font-size: 9.5pt; font-weight: 600; }

  /* --- rodapé (uma vez, no fim) ------------------------------------------- */
  .doc-foot {
    display: block; margin-top: 10mm; padding-top: 3mm;
    border-top: 1px solid #c9ced7; font-size: 8pt; color: #5d6673;
  }

  /* --- corpo -------------------------------------------------------------- */
  .md { line-height: 1.55; }
  .md h1, .md h2, .md h3, .md h4 {
    break-after: avoid; page-break-after: avoid;   /* título não fica órfão no pé */
    break-inside: avoid; page-break-inside: avoid;
    color: #14181f;
  }
  .md h1 { font-size: 16pt; margin: 8mm 0 3mm; padding-bottom: 1.5mm;
           border-bottom: 1px solid #c9ced7; }
  .md h2 { font-size: 13pt; margin: 7mm 0 2.5mm; }
  .md h3 { font-size: 11pt; margin: 5mm 0 2mm; }
  .md h4 { font-size: 10pt; margin: 4mm 0 1.5mm; color: #2b323d; }
  .md h1:first-child, .md h2:first-child { margin-top: 0; }
  .md p, .md li { orphans: 3; widows: 3; }        /* nada de uma linha solta virando página */
  .md ul, .md ol { padding-left: 6mm; }
  .md li { margin-bottom: 1mm; }

  /* Tabelas: é aqui que um relatório executivo se ganha ou se perde. */
  .md table {
    width: 100%; border-collapse: collapse; margin: 3mm 0; font-size: 9pt;
    border: 1px solid #9aa3b0; border-radius: 0;
  }
  .md thead { display: table-header-group; }      /* repete o cabeçalho a cada página */
  .md tfoot { display: table-footer-group; }
  .md tr { break-inside: avoid; page-break-inside: avoid; }
  .md th {
    background: #eef0f3 !important; text-align: left; font-weight: 700;
    border-bottom: 1px solid #9aa3b0;
  }
  .md th, .md td {
    border: 1px solid #c9ced7; padding: 1.6mm 2.4mm; vertical-align: top;
  }

  /* Código: quebrar em vez de rolar — barra de rolagem não existe no papel. */
  .md pre, .raw {
    background: #f4f5f7 !important; border: 1px solid #c9ced7; border-radius: 0;
    padding: 2.5mm 3mm; font-size: 8.5pt; line-height: 1.4;
    white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
    break-inside: avoid; page-break-inside: avoid;
  }
  .md code { background: #f4f5f7 !important; font-size: 8.5pt; padding: 0 1px; }
  .md pre code { font-size: inherit; }

  .md blockquote {
    border-left: 2.5px solid #9aa3b0; padding: 1mm 4mm; margin: 3mm 0; color: #2b323d;
    break-inside: avoid;
  }
  .md hr { border-top: 1px solid #c9ced7; margin: 6mm 0; }
  .md img { max-width: 100%; break-inside: avoid; }

  /* Link: no papel a cor sozinha não informa nada; sublinhado sim. URL externa
     entre parênteses, porque no PDF impresso não há o que clicar. */
  .md a { color: #14181f; text-decoration: underline; }
  .md a[href^="http"]::after {
    content: " (" attr(href) ")"; font-size: 7.5pt; color: #5d6673; word-break: break-all;
  }

  /* Selos e chips continuam legíveis sem preenchimento colorido. */
  .badge {
    border: 1px solid #9aa3b0 !important; background: none !important; color: #14181f !important;
    font-weight: 600;
  }
}
