/* =============================================================================
   Himura PBX — Design system v3.1 "flat enterprise"
   Estrutura no estilo de consoles corporativos reais (Stripe/GitHub/Linear):
   conteúdo direto na página branca, seções separadas por filetes e espaço —
   NÃO por caixas arredondadas com sombra. Métricas em linha com divisores,
   tabelas full-bleed, listas com réguas. Painéis só onde fazem sentido
   (modais, login, blocos técnicos).
   ============================================================================= */

:root {
  /* Marca Himura (logo branca sobre azul institucional) */
  --navy:        #0a3a6a;   /* azul do logo Himura */
  --sidebar-bg:  #111923;
  --navy-2:      #0c4478;
  --primary:     #1265c8;   /* azul de ação (família do GIF Access) */
  --primary-dk:  #0e4f9e;
  --primary-hi:  #1265c8;   /* links (nome mantido p/ compat) */

  /* Superfícies */
  --bg:          #f5f7fb;
  --bg-raised:   #f8f9fb;
  --bg-card:     #ffffff;
  --bg-hover:    #f5f6f8;
  --border:      #d3d8e0;
  --border-soft: #e8eaef;

  /* Texto */
  --text:        #1a2332;
  --text-mute:   #4a5568;
  --text-dim:    #6f7887;

  /* Estados (tons -700, legíveis sobre claro) */
  --ok:          #15803d;
  --warn:        #b45309;
  --danger:      #b91c1c;

  --radius:      6px;
  --radius-sm:   5px;
  --shadow:      0 12px 34px rgba(16, 24, 40, .18);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* o atributo hidden vence qualquer display de classe */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(29, 78, 216, .16); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #ccd2db; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b3bac6; }
::-webkit-scrollbar-track { background: transparent; }

code, .mono {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  font-size: .9em;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
  color: #313a4d;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  color: #cfd7e6;
}

.sidebar-brand {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

/* Logo Himura PBX — arte em faixa horizontal. A sidebar usa fundo grafite para
   evitar azul sobre azul e deixar a marca funcionar como assinatura visual. */
.brand-logo {
  display: block;
  width: 216px;
  max-width: 100%;
  height: auto;
  flex-shrink: 0; /* nao deixa o flexbox (sidebar horizontal no mobile) esmagar */
  border-radius: 4px;
}
.brand-logo-login { width: 290px; }

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; }

.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #9fb0ca;
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background .13s, color .13s;
}

.sidebar-nav a svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; opacity: .9; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #e8edf6; }
/* Item ativo: barra de acento à esquerda (padrão Linear/GitHub) + fundo */
.sidebar-nav a.active {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #6ea8e8;
}
.sidebar-nav a:focus-visible { outline: 2px solid #6ea8e8; outline-offset: -2px; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }

.user-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; margin-bottom: 8px;
  background: rgba(255, 255, 255, .05); border-radius: var(--radius-sm);
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-nome { color: #e8edf6; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-perfil { color: #9fb0ca; font-size: 11px; }
.user-logout {
  background: none; border: none; color: #9fb0ca; cursor: pointer;
  width: 28px; height: 28px; border-radius: 5px; display: grid; place-items: center; flex-shrink: 0;
}
.user-logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.user-logout svg { width: 17px; height: 17px; fill: currentColor; }

.check-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; padding: 8px; border: 1px solid var(--border-soft); border-radius: var(--radius); }

/* ── Assistente (wizard) ─────────────────────────────────────────────────── */
.wiz-steps { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.wiz-step { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.wiz-step.atual { color: var(--primary); }
.wiz-step.feito { color: var(--ok); }
.wiz-num {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-raised); border: 1.5px solid var(--border); font-size: 12px; flex-shrink: 0;
}
.wiz-step.atual .wiz-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wiz-step.feito .wiz-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.wiz-sep { flex: 1; height: 1px; background: var(--border-soft); min-width: 12px; }
.wiz-erro { color: var(--danger); font-size: 12.5px; min-height: 16px; margin-bottom: 6px; }

.wiz-resumo { border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.wiz-linha { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.wiz-linha:last-child { border-bottom: none; }
.wiz-linha > span { color: var(--text-dim); }
.wiz-sec { padding: 8px 12px; background: var(--bg-raised); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); font-weight: 700; border-bottom: 1px solid var(--border-soft); }

.wiz-avisos { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.wiz-aviso { font-size: 12.5px; color: var(--text-mute); padding: 8px 11px; background: #fbf7ea; border: 1px solid #f0e6c8; border-radius: var(--radius); }
.wiz-aviso strong { color: var(--text); }

/* Perfil somente-leitura: esconde acoes de escrita (backend tambem barra) */
body.perfil-leitura #btn-aplicar,
body.perfil-leitura .content .btn-primary,
body.perfil-leitura .content .btn-danger,
body.perfil-leitura .content .btn-warn,
body.perfil-leitura [data-aedit], body.perfil-leitura [data-adel],
body.perfil-leitura [data-edit], body.perfil-leitura [data-del],
body.perfil-leitura [data-uedit], body.perfil-leitura [data-udel] { display: none !important; }

.conn-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #9fb0ca;
  padding: 7px 11px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .05);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 40px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
}

.topbar h2 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.trunk-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-mute);
  padding: 4px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-raised);
}

.content { padding: 28px 40px 72px; max-width: 1180px; width: 100%; }

/* ── Dots / badges ──────────────────────────────────────────────────────── */

/* Status: cor + halo — sinal duplo, legível de canto de olho e para daltônicos
   (online tem "aura", offline é chapado). */
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3c9d4; flex-shrink: 0; }
.dot.online, .dot.ok { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .14); }
.dot.offline, .dot.err { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.dot.warn { background: #d97706; }

/* Na lista de infraestrutura, o online "respira" — sistema vivo, sem alarde */
.endpoint-name .dot.online { animation: dot-pulse 2.6s ease-in-out infinite; }
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22, 163, 74, .14); }
  50%      { box-shadow: 0 0 0 5px rgba(22, 163, 74, .07); }
}
@media (prefers-reduced-motion: reduce) {
  .endpoint-name .dot.online { animation: none; }
}

.badge {
  display: inline-block; padding: 1.5px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  background: #eef0f4; color: var(--text-mute);
}
.badge.ok      { background: #e8f7ee; color: var(--ok); }
.badge.warn    { background: #fdf3e1; color: var(--warn); }
.badge.danger  { background: #fdecec; color: var(--danger); }
.badge.primary { background: #e9effc; color: var(--primary); }

/* ── Métricas em linha (sem caixas) ─────────────────────────────────────── */

.stats {
  display: flex; flex-wrap: wrap;
  gap: 0;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 20px;
}

.stat-card {
  padding: 2px 32px 2px 0;
  margin-right: 32px;
  border-right: 1px solid var(--border-soft);
  min-width: 130px;
}
.stat-card:last-child { border-right: none; margin-right: 0; }

.stat-card .stat-label {
  font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .07em; font-weight: 650;
}
.stat-card .stat-value {
  font-size: 26px; font-weight: 700; margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.stat-card .stat-sub { font-size: 11.5px; color: var(--text-dim); }
.stat-card.accent-ok   .stat-value { color: var(--ok); }
.stat-card.accent-warn .stat-value { color: var(--warn); }
.stat-card.accent-err  .stat-value { color: var(--danger); }

/* ── Seções (ex-cards): filete + espaço, sem caixa ──────────────────────── */

.card {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  padding: 24px 0;
  margin: 0;
  box-shadow: none;
}
.content > .card:first-child,
.content > .stats + .card,
.grid-2 .card { border-top: none; padding-top: 0; }
.grid-2 { border-top: 1px solid var(--border-soft); padding-top: 24px; }
.content > .grid-2:first-child { border-top: none; padding-top: 0; }

.card > h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 3px; letter-spacing: -.01em; }
.card .card-desc { font-size: 12.5px; color: var(--text-mute); margin-bottom: 14px; max-width: 640px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 40px; align-items: start; }

/* ── Painéis operacionais ───────────────────────────────────────────────── */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.panel-wide { margin-top: 18px; }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h3 { font-size: 14.5px; line-height: 1.25; }
.section-head p { margin-top: 2px; color: var(--text-dim); font-size: 12.5px; }

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  font-weight: 750;
  margin-bottom: 6px;
}

.ops-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.ops-hero.ok { border-left-color: var(--ok); }
.ops-hero.attention { border-left-color: var(--warn); }
.ops-hero.loading { border-left-color: var(--primary); }
.ops-hero h1 {
  font-size: 25px;
  line-height: 1.16;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.ops-hero p { color: var(--text-mute); max-width: 620px; font-size: 13.5px; }

.ops-score {
  min-width: 130px;
  text-align: right;
}
.ops-score strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.ops-score span {
  color: var(--text-dim);
  font-size: 12px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}

.ops-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 14px;
}
.ops-label {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 720;
  margin-bottom: 6px;
}
.ops-tile strong {
  display: block;
  font-size: 21px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.ops-tile small {
  display: block;
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(360px, 1.15fr);
  gap: 16px;
}

.inline-action {
  display: flex;
  gap: 10px;
  align-items: center;
}
.inline-action input { min-width: 0; }

.ops-hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.ops-layout,
.device-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.ops-main-stack,
.ops-side-stack,
.device-main,
.device-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.infra-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.infra-card,
.cond-health-card,
.ata-card,
.terminal-summary-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-raised);
}

.infra-card {
  padding: 13px;
  border-left: 3px solid var(--border);
}
.infra-card.online { border-left-color: var(--ok); }
.infra-card.offline { border-left-color: var(--danger); }
.infra-card-top,
.ata-card-head,
.cond-health-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.infra-card-top { margin-bottom: 8px; }
.infra-card > strong,
.ata-card strong,
.cond-health-card strong,
.terminal-summary-card strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.25;
}
.infra-card-sub,
.ata-card small,
.cond-health-card small,
.terminal-summary-card small {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}
.endpoint-details {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
}
.endpoint-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 650;
}
.endpoint-details div {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.cond-health-grid,
.terminal-status-grid,
.ata-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.cond-health-card {
  padding: 12px;
  border-left: 3px solid var(--border);
}
.cond-health-card.ok,
.terminal-summary-card.ok { border-left-color: var(--ok); }
.cond-health-card.warn,
.terminal-summary-card.warn { border-left-color: var(--warn); }
.cond-health-card.danger,
.terminal-summary-card.danger { border-left-color: var(--danger); }
.cond-health-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 12px;
}
.cond-health-metrics b { color: var(--text); font-variant-numeric: tabular-nums; }

.incident-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.incident {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-raised);
}
.incident strong {
  display: block;
  font-size: 12.8px;
}
.incident small {
  display: block;
  color: var(--text-dim);
  font-size: 11.8px;
  margin-top: 2px;
}

.device-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.device-hero h1 {
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.device-hero p {
  color: var(--text-mute);
  margin-top: 4px;
  font-size: 13.5px;
}
.device-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
  min-width: 420px;
}
.device-summary div {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg-raised);
}
.device-summary span {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 720;
}
.device-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.ata-card {
  padding: 13px;
}
.port-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}
.port-line {
  display: grid;
  grid-template-columns: 10px minmax(44px, .35fr) minmax(92px, .8fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text-dim);
  font-size: 12px;
}
.port-line strong { font-size: 12px; color: var(--text); }

.edit-drawer {
  margin-top: 16px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}
.edit-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  margin-bottom: 12px;
}
.edit-drawer summary::-webkit-details-marker { display: none; }
.edit-drawer summary span {
  font-weight: 700;
  font-size: 13px;
}
.edit-drawer summary small {
  color: var(--text-dim);
  font-size: 12px;
}
.khomp-cond-cell {
  min-width: 240px;
}
.khomp-cond-select {
  min-width: 240px;
}

.terminal-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-left: 3px solid var(--border);
}
.terminal-summary-card > span {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.terminal-table {
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.ops-checklist,
.quick-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ops-checklist div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.ops-checklist strong { color: var(--text); }
.ops-checklist span {
  color: var(--text-dim);
  text-align: right;
  overflow-wrap: anywhere;
}

/* ── Provisionamento de campo ────────────────────────────────────────────── */

.config-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  background: #0f2f53;
  color: #f8fbff;
  border-radius: 8px;
  padding: 22px 24px;
  box-shadow: 0 10px 30px rgba(10, 58, 106, .16);
}
.config-hero .eyebrow { color: #a9c4df; }
.config-hero h1 {
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.config-hero p {
  color: #d6e2ef;
  margin-top: 4px;
  font-size: 13.5px;
}
.config-hero-ref {
  min-width: 210px;
  text-align: right;
}
.config-hero-ref span {
  display: block;
  color: #a9c4df;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 750;
}
.config-hero-ref strong {
  display: block;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.provision-selects {
  max-width: 760px;
  margin-bottom: 4px;
}

.provision-kit {
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
  padding-top: 16px;
}

.kit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.kit-header h3 {
  font-size: 18px;
  line-height: 1.25;
  margin-top: 7px;
}
.kit-header p {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 2px;
}
.kit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.kit-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.kit-row span {
  color: var(--text-dim);
  font-size: 12px;
}
.kit-row strong {
  min-width: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.kit-row small {
  grid-column: 2;
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: -5px;
}

.field-checklist {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-raised);
}
.field-checklist .cond-section-title {
  grid-column: 1 / -1;
  margin-top: 0;
}
.field-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-mute);
}
.field-checklist input { width: auto; accent-color: var(--primary); }
.kit-contact { margin-top: 12px; }

.advanced-drawer {
  margin-top: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
}
.advanced-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  cursor: pointer;
  list-style: none;
}
.advanced-drawer summary::-webkit-details-marker { display: none; }
.advanced-drawer summary span {
  font-weight: 700;
  font-size: 14px;
}
.advanced-drawer summary small {
  color: var(--text-dim);
  font-size: 12px;
  text-align: right;
}
.advanced-drawer[open] summary { border-bottom: 1px solid var(--border-soft); }
.advanced-drawer > .grid-2 { border-top: none; padding: 18px; gap: 18px; }
.advanced-drawer .card { padding: 0; border-top: none; }

/* ── Botões ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6.5px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px; font-weight: 570;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.btn:hover { background: var(--bg-hover); border-color: #b9c0cc; }
.btn:active { background: #eceef2; transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn .ico { width: 14px; height: 14px; fill: currentColor; }

/* Ação primária ganha leve profundidade — hierarquia clara sem gritar */
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }
.btn-primary:active { background: var(--primary-dk); }
.btn-success { background: #15803d; border-color: #15803d; color: #fff; }
.btn-success:hover { background: #166534; }
.btn-warn    { background: #b45309; border-color: #b45309; color: #fff; }
.btn-warn:hover { background: #92400e; }
.btn-danger  { background: #fff; border-color: #ecc8c8; color: var(--danger); }
.btn-danger:hover { background: #fdf5f5; }
.btn-ghost   { background: transparent; border-color: transparent; }
.btn-sm      { padding: 3.5px 10px; font-size: 12.5px; }
.btn-block   { width: 100%; justify-content: center; }

/* Estado "PBX em dia" do botão Aplicar (sempre visível, desabilitado) */
.btn-emdia { background: transparent; border-color: transparent; color: var(--ok); }
.btn-emdia:disabled { opacity: 1; cursor: default; }

/* ── Formulários ────────────────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

label { font-size: 12px; font-weight: 600; color: var(--text-mute); }

input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7.5px 11px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  transition: border-color .13s, box-shadow .13s;
}

input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: #b9c0cc; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .1);
}

input::placeholder, textarea::placeholder { color: #9aa2b1; }

textarea.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.55; }

.form-hint { font-size: 11.5px; color: var(--text-dim); }

.form-fieldset {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 13px;
}
.form-fieldset legend {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  padding: 0 7px; text-transform: uppercase; letter-spacing: .07em;
}

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-mute); }
.check-row input { width: auto; accent-color: var(--primary); }

/* ── Olho de senha ──────────────────────────────────────────────────────── */

.senha-wrap { position: relative; width: 100%; }
.senha-wrap input { padding-right: 36px; }

.senha-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  border-radius: 5px;
}
.senha-eye:hover { color: var(--text); }
.senha-eye svg { width: 16px; height: 16px; fill: currentColor; }

td .senha-wrap { min-width: 150px; }

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Tabelas full-bleed (sem moldura) ───────────────────────────────────── */

.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  text-align: left; padding: 8px 14px 8px 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  /* Cabeçalho acompanha o scroll em listas longas (ex.: 40+ aptos) */
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}

td {
  padding: 9.5px 14px 9.5px 0;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
th:last-child, td:last-child { padding-right: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg-raised); }

.cell-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.empty {
  text-align: center; color: var(--text-dim);
  padding: 36px 16px; font-size: 13.5px;
}

/* ── Lista de endpoints (visão geral): linhas, não mini-cards ───────────── */

.cond-group { margin-bottom: 26px; }

.cond-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.cond-group-header .nome { font-weight: 700; font-size: 13.5px; }
.cond-group-header .contagem { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.endpoint-grid { display: flex; flex-direction: column; }

.endpoint {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}

.endpoint-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; min-width: 200px; }
.endpoint-title { font-weight: 700; }
.endpoint-code {
  display: inline-flex; align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
  background: var(--bg-raised);
  color: var(--text-mute);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}
.endpoint-meta { font-size: 12px; color: var(--text-dim); margin-top: 0; word-break: break-all; }
.endpoint-cond { font-weight: 400; font-size: 12px; color: var(--text-dim); }

/* Apartamentos compactados: fechado por padrao, expande por condominio */
.apto-group { border-bottom: 1px solid var(--border-soft); }
.apto-group summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.apto-group summary::-webkit-details-marker { display: none; }
.apto-group summary::before {
  content: '▸';
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 8px;
  transition: transform .12s;
}
.apto-group[open] summary::before { transform: rotate(90deg); }
.apto-group summary .nome { font-weight: 600; font-size: 13px; flex: 1; }
.apto-group summary .contagem { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.apto-group summary:hover { background: var(--bg-raised); }
.apto-group summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.apto-group[open] > .apto-chips { animation: fade-in .18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-2px); } }

.apto-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 14px 19px; }
.apto-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
  background: var(--bg);
}
.apto-chip.online { color: var(--text); border-color: var(--ok); }
.apto-chip:hover { border-color: #b9c0cc; background: var(--bg-hover); }
.apto-chip .dot { width: 6px; height: 6px; box-shadow: none; }

/* ─── Chamadas ao vivo ───────────────────────────────────────────────────── */

.live-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.live-calls {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.live-call {
  padding: 9px 0 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  border-left: 2px solid transparent;
}
/* Chamada em andamento ganha filete verde — destaca o "agora" do histórico */
.live-call:has(.dot.online) { border-left-color: #16a34a; background: #fbfdfb; }

.live-main,
.live-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-main {
  font-size: 13px;
  font-weight: 650;
}

.live-route {
  word-break: break-word;
}

.live-meta {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ── Condomínios: lista com réguas, não grid de cards ───────────────────── */

.cond-cards { display: flex; flex-direction: column; }

.cond-card {
  padding: 22px 0;
  border-bottom: 1px solid var(--border-soft);
}
.cond-card:first-child { padding-top: 4px; }

.cond-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.cond-card-header h3 { font-size: 15px; font-weight: 700; }
.cond-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-mute); margin-bottom: 8px; }

.cond-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); font-weight: 750;
  margin: 14px 0 5px;
}

.sip-credentials { display: flex; flex-direction: column; gap: 3px; max-width: 560px; }
.sip-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.sip-label { width: 78px; color: var(--text-dim); flex-shrink: 0; }
.sip-value { word-break: break-all; }

.sip-password { cursor: pointer; filter: blur(4px); transition: filter .15s; user-select: none; }
.sip-password.revealed { filter: none; user-select: text; }

.cond-terminal-item { font-size: 12.5px; color: var(--text-mute); padding: 2px 0; }

/* ── Import ─────────────────────────────────────────────────────────────── */

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.arrastando {
  border-color: var(--primary);
  background: #f6f8fe;
  color: var(--text-mute);
}

.import-resumo { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }

/* ── Modal (painel de verdade — aqui caixa faz sentido) ─────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13, 31, 60, .42);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade-in .12s ease-out;
}

.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 560px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: modal-in .16s ease-out;
  overflow: hidden;
}

.modal.wide { max-width: 760px; }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 { font-size: 15.5px; font-weight: 700; }

.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-raised);
}

/* ── Terminais editor ───────────────────────────────────────────────────── */

.terminal-row { display: grid; grid-template-columns: 1.1fr 1.1fr .9fr .55fr 1fr 1fr 30px; gap: 7px; margin-bottom: 7px; align-items: center; }
.terminal-labels { display: grid; grid-template-columns: 1.1fr 1.1fr .9fr .55fr 1fr 1fr 30px; gap: 7px; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.btn-remove { background: none; border: none; color: var(--danger); font-size: 17px; cursor: pointer; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--navy);
  color: #e8edf6;
  border-radius: var(--radius);
  border-left: 3px solid #6ea8e8;
  box-shadow: var(--shadow);
  padding: 11px 15px;
  font-size: 13px;
  animation: toast-in .2s ease-out;
}
.toast.error { background: #7c1d1d; border-left-color: #f1a8a8; }
.toast.warn  { background: #7c4a03; border-left-color: #f5c97b; }

@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--navy);
  display: grid; place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%; max-width: 350px;
  background: #fff;
  border-radius: 10px;
  padding: 36px 30px;
  text-align: center;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
}

/* No cartão branco do login, a logo (branca) vai sobre um bloco azul da marca */
.login-brandbox {
  margin: 0 auto 8px;
  display: flex; justify-content: center;
}
.login-card p { font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.login-erro { color: var(--danger); font-size: 12.5px; min-height: 18px; }

/* ── Config preview (bloco técnico escuro) ──────────────────────────────── */

.config-preview {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 45vh;
  overflow: auto;
  white-space: pre;
  color: #b9c6dd;
}

/* ── Responsivo ─────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    overflow-x: auto;
  }

  .sidebar-brand { border: none; padding: 10px 12px; flex-shrink: 0; }
  .sidebar-brand .brand-logo { width: 160px; }

  .sidebar-nav { flex-direction: row; padding: 6px; }
  .sidebar-nav a { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }

  .sidebar-footer { display: none; }

  .content { padding: 16px 16px 50px; }
  .topbar { padding: 12px 16px; }
  .grid-2, .form-row { grid-template-columns: 1fr; }
  .ops-hero, .config-hero, .kit-header, .device-hero { flex-direction: column; align-items: stretch; }
  .ops-score, .config-hero-ref { text-align: left; min-width: 0; }
  .ops-hero-actions { margin-left: 0; flex-wrap: wrap; }
  .ops-grid, .workbench, .kit-grid, .field-checklist,
  .ops-layout, .device-shell, .infra-board, .cond-health-grid,
  .ata-board, .terminal-status-grid, .device-summary { grid-template-columns: 1fr; }
  .device-summary { min-width: 0; }
  .inline-action { flex-direction: column; align-items: stretch; }
  .port-line { grid-template-columns: 10px 48px minmax(90px, 1fr); }
  .port-line span:last-child { grid-column: 2 / -1; }
  .kit-row { grid-template-columns: 1fr; gap: 2px; }
  .kit-row small { grid-column: 1; margin-top: 0; }
  .advanced-drawer summary { flex-direction: column; align-items: flex-start; }
  .advanced-drawer summary small { text-align: left; }

  .stats { gap: 0; }
  .stat-card { padding-right: 18px; margin-right: 18px; min-width: 100px; }
}
