/* Sem isso, qualquer elemento com [hidden] dentro de um container com sua
   própria regra de display (ex: .inline-form label { display: flex }) fica
   com mais especificidade que o [hidden] padrão do navegador e nunca some
   de verdade — bug real visto no formulário de Tipos de ponto de acesso,
   onde campos condicionais por categoria (ícone/PON/splitter) apareciam
   todos juntos. */
[hidden] {
  display: none !important;
}

body {
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background: #f0f2f5;
}

body.app-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  background: #ececec;
  justify-content: flex-start;
  align-items: stretch;
}

.app-navbar {
  flex-shrink: 0;
  background: #2c2c2c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 48px;
  font-size: 0.9rem;
}

.app-navbar .brand {
  font-weight: bold;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: #fff;
  flex-shrink: 0;
  margin-right: 1.5rem;
}

.app-navbar nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  /* Com 11 links o menu passou a encostar na marca; deixa rolar em vez de espremer. */
  overflow-x: auto;
  min-width: 0;
}

.app-navbar nav a {
  white-space: nowrap;
}

.app-navbar nav a {
  color: #cfd8d4;
  text-decoration: none;
}

.app-navbar nav a:hover,
.app-navbar nav a.active {
  color: #fff;
}

.app-navbar .logout-btn {
  background: #c0392b;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.app-navbar .logout-btn:hover {
  background: #a3291d;
}

.breadcrumb {
  flex-shrink: 0;
  padding: 0.6rem 1.25rem;
  background: #f4f4f4;
  border-bottom: 1px solid #ddd;
  font-size: 0.85rem;
  color: #555;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.action-bar button.primary {
  width: 100%;
  padding: 0.65rem;
  background: #1e88b8;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.action-bar button.primary:hover {
  background: #16729a;
}

.search-input-full {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  font-size: 0.9rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: #f7f7f7;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
}

.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.9rem;
  color: #333;
}

.data-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

.data-table .empty-row td {
  text-align: center;
  color: #888;
  padding: 1.5rem;
}

.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  vertical-align: middle;
}

.table-actions button {
  background: #1e88b8;
  color: white;
  border: none;
  border-radius: 3px;
  width: 28px;
  height: 26px;
  cursor: pointer;
  margin-right: 4px;
  font-size: 0.8rem;
}

.table-actions button:hover {
  background: #16729a;
}

.inline-form {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.inline-form[hidden] {
  display: none;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: #555;
  gap: 0.3rem;
}

.inline-form input,
.inline-form select {
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.inline-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
}

.inline-form .form-actions button[type="submit"] {
  background: #2b7a4b;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.inline-form .form-actions button[type="button"] {
  background: #eee;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.inline-form .span-2 {
  grid-column: span 2;
}

.inline-form textarea {
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.image-preview-wrap {
  display: flex;
  align-items: flex-end;
}

.image-preview {
  max-width: 80px;
  max-height: 80px;
  border-radius: 4px;
  border: 1px solid #ddd;
  object-fit: cover;
}

.table-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
  vertical-align: middle;
}

.kit-item-picker {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.kit-item-picker select {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.kit-item-picker input[type="number"] {
  width: 70px;
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.kit-item-picker button {
  background: #1e88b8;
  color: white;
  border: none;
  border-radius: 4px;
  width: 36px;
  height: 34px;
  cursor: pointer;
  font-size: 1rem;
}

.color-list-section h4 {
  font-size: 0.8rem;
  color: #555;
  margin: 0 0 0.5rem;
}

.color-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.color-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.75rem;
  color: #555;
}

.color-slot input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
}

.color-list-buttons {
  display: flex;
  gap: 0.4rem;
}

.color-list-buttons button {
  background: #eee;
  border: none;
  border-radius: 4px;
  width: 30px;
  height: 28px;
  cursor: pointer;
}

.swatch-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.color-swatch.numbered {
  width: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.55);
  font-size: 0.65rem;
  font-weight: bold;
}

.profile-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.profile-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
  color: #222;
}

.profile-card p {
  margin: 0.25rem 0;
  color: #555;
  font-size: 0.9rem;
}

.level-badge {
  display: inline-block;
  background: #1e88b8;
  color: white;
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.login-box {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 280px;
}

.login-box input, .login-box button {
  padding: 0.6rem;
  font-size: 1rem;
}

.login-box button {
  background: #2b7a4b;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.error {
  color: #c0392b;
  min-height: 1.2em;
}

#map {
  flex: 1;
  position: relative;
}

.cable-selected {
  outline: 2px solid #2b7a4b;
}

/* Pino do resultado de busca: mesmo problema dos marcadores antigos — emoji no tamanho
   de fonte padrao, que sumia. Sem `overflow: visible` a sombra sai cortada. */
.node-search {
  font-size: 26px; line-height: 1; overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #1f2d26;
  color: #e6ece8;
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
  font-size: 0.9rem;
}

.sidebar-header {
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #3a4d43;
}

.tool-group {
  margin-bottom: 1.25rem;
}

.tool-group h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8fae9c;
  margin: 0 0 0.5rem;
}

.tool-group label {
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.tool-group label:hover {
  background: #2b3e34;
}

.tool-group input[type="radio"] {
  margin-right: 0.5rem;
}

#map-search-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#map-search-input {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid #4a5d52;
  border-radius: 4px;
  background: #16201b;
  color: #e6ece8;
  box-sizing: border-box;
}

#map-search-box button {
  width: 100%;
  padding: 0.5rem;
  background: #2b7a4b;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  box-sizing: border-box;
}

#map-search-box button:hover {
  background: #256b41;
}

.tab-bar {
  display: flex;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab-btn {
  flex: 1;
  padding: 0.65rem;
  background: #1e88b8;
  color: rgba(255,255,255,0.75);
  border: none;
  border-right: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn:last-child {
  border-right: none;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: #16729a;
  color: #fff;
  font-weight: bold;
}

.port-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.port-row {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  gap: 0.4rem;
  align-items: center;
  padding: 0.4rem;
  background: #f7f7f7;
  border-radius: 4px;
}

.port-row label {
  font-size: 0.75rem;
  color: #555;
}

.port-row select {
  width: 100%;
  padding: 0.35rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Tela Valores Default — tabela de parâmetros (rótulo à esquerda, valor + unidade à direita) */
.default-values-table td.dv-label {
  font-size: 1rem;
  color: #333;
}

.default-values-table td.dv-input {
  width: 160px;
  white-space: nowrap;
  text-align: right;
}

.default-values-table td.dv-input input {
  width: 70px;
  padding: 0.3rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.9rem;
  text-align: right;
}

.default-values-table .dv-unit {
  margin-left: 0.4rem;
  color: #666;
  font-size: 0.85rem;
}

.default-values-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}

.default-values-actions button.primary {
  width: auto;
  min-width: 180px;
  padding: 0.7rem 2rem;
  background: #1e88b8;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.default-values-actions button.primary:hover {
  background: #16729a;
}

.success-message {
  background: #e6f4ea;
  border: 1px solid #b7dfc4;
  color: #1e6b39;
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

/* Ícones das categorias de ponto de acesso (mesmas 6 do Tomodat) */
/* Marcador do mapa. A cor e a forma vivem no SVG gerado no map.js; aqui fica só o que
   e apresentacao: a sombra que descola a placa do mapa e o realce ao passar o mouse.
   O `overflow: visible` importa — sem ele a sombra e o selo de implantado sao cortados. */
.node-marker { background: none; border: 0; overflow: visible; }
.node-marker svg { display: block; transition: transform .12s ease; }
.node-marker:hover svg { transform: scale(1.12); }
/* O seletor de cor precisa de altura propria: `<input type=color>` renderiza como uma
   caixinha minuscula quando herda a altura de texto. */
#no-cor { width: 100%; height: 34px; padding: 2px; cursor: pointer; }
/* `.dg-modal-corpo label` empilha rotulo e campo; esta linha e caixa+texto lado a lado,
   entao precisa da mesma especificidade pra vencer. */
.dg-modal-corpo .no-linha-check { display: flex; flex-direction: row; align-items: center;
  gap: 7px; font-size: 12px; margin-top: 2px; }
.dg-modal-corpo .no-linha-check input { width: auto; margin: 0; }

/* Aviso de traçado de cabo em andamento */
.map-ajuda {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.9);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  font-size: 0.85rem;
  z-index: 1000;
  pointer-events: none;
}

/* ---- Diagrama de emendas da caixa ---- */
.diagrama-overlay {
  position: fixed;
  inset: 0;
  background: #eceff1;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.diagrama-barra {
  background: #5c9c3f;
  color: #fff;
  padding: 0.7rem 1rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.diagrama-barra button {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 3px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
}

.diagrama-aviso {
  background: #fff;
  border-bottom: 1px solid #dcdcdc;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: #444;
  flex-shrink: 0;
}

.diagrama-corpo {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
  position: relative;
}

.diagrama-zoom { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.diagrama-zoom button { min-width: 34px; }
.diagrama-zoom span { min-width: 44px; text-align: center; font-size: 0.82rem; color: #425466; }

@media print {
  body { background: #fff; }
  .diagrama-overlay { position: static; display: block; }
  .diagrama-barra, .diagrama-ferramentas, .diagrama-aviso, .dg-modal { display: none !important; }
  .diagrama-corpo { overflow: visible; padding: 0; }
  .diagrama-canvas { zoom: 0.65 !important; }
}

.diagrama-vazio,
.diagrama-sem-fibras {
  color: #777;
  font-size: 0.9rem;
  padding: 0.5rem;
}

/* Canvas livre: cada bloco tem (x, y) próprio, como no Tomodat — não há colunas. O
   tamanho é calculado no desenho (`ajustarCanvas`) pra caber o bloco mais distante. */
.diagrama-canvas { position: relative; }

.diagrama-canvas > [data-lado] { position: absolute; }

.diagrama-cabo {
  background: #8fd18f;
  border-radius: 10px;
  padding: 0.5rem;
  min-width: 260px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Alça de arrasto do cabeçalho (o Tomodat não arrasta pelo bloco inteiro). */
.bloco-arrastar {
  cursor: grab;
  padding: 0 0.25rem;
  opacity: 0.85;
  touch-action: none;
  user-select: none;
}

.bloco-arrastar:hover { opacity: 1; }

/* Virar o bloco pro outro lado da caixa. */
.bloco-virar {
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.85;
  user-select: none;
}

.bloco-virar:hover { opacity: 1; }
.arrastando .bloco-arrastar { cursor: grabbing; }
.arrastando { opacity: 0.85; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }

.diagrama-cabo-titulo .bloco-arrastar,
.diagrama-cabo-titulo .bloco-virar { float: right; }

.diagrama-cabo-titulo {
  background: #2f3640;
  color: #fff;
  border-radius: 5px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.diagrama-cabo-titulo.splitter { background: #6d4c9f; }
.diagrama-cabo-titulo small { display: block; opacity: 0.75; font-size: 0.75rem; }

.diagrama-fibras { display: flex; flex-direction: column; }

.diagrama-fibra {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 3px;
}

.diagrama-fibra:hover { background: rgba(255, 255, 255, 0.55); }
.diagrama-fibra.selecionada { background: #ffe08a; outline: 2px solid #e0a800; }
.diagrama-fibra.lado-left { justify-content: flex-end; }

.fibra-num {
  background: #4b4b4b;
  color: #fff;
  border-radius: 3px;
  font-size: 0.72rem;
  padding: 0.1rem 0.3rem;
  min-width: 22px;
  text-align: center;
}

.fibra-traco {
  display: inline-block;
  width: 46px;
  height: 6px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.fibra-selo {
  background: #2b7a4b;
  color: #fff;
  font-size: 0.7rem;
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}

.fibra-perda {
  background: #1e88b8;
  color: #fff;
  font-size: 0.7rem;
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}

/* ---- Splitter em funil (mesmo desenho do Tomodat) ---- */
.bloco-splitter { background: #fdfdfd; }

.splitter-corpo {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* Do lado direito da caixa o funil espelha: a ponta continua virada pra fora. */
.splitter-corpo.lado-right { flex-direction: row-reverse; }

.splitter-entradas {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.splitter-funil { flex: none; }

.splitter-portas {
  border-left: 2px dotted #4a90d9;
  padding-left: 5px;
}

.splitter-corpo.lado-right .splitter-portas {
  border-left: 0;
  border-right: 2px dotted #4a90d9;
  padding-left: 0;
  padding-right: 5px;
}

.fibra-num.porta,
.fibra-num.entrada {
  border-radius: 9px;
  min-width: 26px;
  font-weight: 600;
}

.fibra-num.porta { background: #1e88b8; }
.fibra-num.entrada { background: #2e9e5b; }


/* O SVG das ligações é uma camada por cima das duas colunas inteiras — as pontas de
   uma emenda podem estar na mesma coluna, ou recuadas dentro do funil do splitter.
   Ele não intercepta clique nenhum; só a tesoura volta a ser clicável. */
.diagrama-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.diagrama-tesoura { cursor: pointer; pointer-events: auto; }

/* ---- Fibra ativa ----
   Classes e animação copiadas do `css/custom.css` do Tomodat (v2.17.59). Fibra sem
   sinal é linha contínua; fibra energizada é tracejada e corre no sentido do fluxo.
   A tesoura é um `<g>` irmão dos traços, não filho, então não herda nada disso — no
   Tomodat ela ficava dentro do grupo animado e precisou de um `!important` pra escapar. */
.fiber-path-still { stroke-linecap: round; }

.fiber-path-animate-in {
  stroke-linecap: round;
  stroke-dasharray: 36, 15;
  animation: dash 23s linear infinite;
}

.fiber-path-animate-out {
  stroke-linecap: round;
  stroke-dasharray: 36, 15;
  animation: dash 23s linear infinite;
  animation-direction: reverse;
}

@keyframes dash {
  to { stroke-dashoffset: 2000; }
}
.diagrama-tesoura:hover circle { fill: #ffe08a; }

/* ---- Painel "Adicionar cabo" (fica aberto enquanto se traça o cabo) ---- */
.cabo-painel {
  position: absolute;
  top: 70px;
  right: 24px;
  width: 320px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  z-index: 1200;
  font-size: 0.9rem;
}

.cabo-painel-titulo {
  background: #5c9c3f;
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 4px 4px 0 0;
  font-size: 1rem;
}

.cabo-painel-corpo { padding: 0.9rem; }

.cabo-painel-corpo label {
  display: block;
  margin-bottom: 0.7rem;
  color: #444;
  font-size: 0.85rem;
}

.cabo-painel-corpo input,
.cabo-painel-corpo select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.9rem;
  box-sizing: border-box;
  margin-top: 0.2rem;
}

.cabo-rotulo { display: block; color: #444; font-size: 0.85rem; margin-bottom: 0.2rem; }

.cabo-tipo-linha { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.cabo-tipo-linha select { margin-top: 0; }

.cabo-contador {
  margin: 0.9rem 0;
  color: #555;
  font-size: 0.85rem;
  line-height: 1.5;
}

.cabo-painel-acoes {
  border-top: 1px solid #e4e4e4;
  padding-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.cabo-painel-acoes button {
  border: none;
  border-radius: 3px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  background: #1e88b8;
  color: #fff;
}

.cabo-painel-acoes button.confirmar { background: #2f7fb8; }
.cabo-painel-acoes button.confirmar:disabled { background: #9bbdd2; cursor: not-allowed; }
.cabo-painel-acoes button.cancelar { background: #c0392b; }

/* Botões de vista do mapa */
.vista-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.5rem;
  background: #3f4b54;
  color: #e6e6e6;
  border: 1px solid #56646f;
  border-radius: 3px;
  font-size: 0.85rem;
  cursor: pointer;
}

.vista-btn:hover { background: #4d5b66; }

/* Ferramentas do diagrama */
.diagrama-ferramentas {
  background: #f4f6f7;
  border-bottom: 1px solid #dcdcdc;
  padding: 0.4rem 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.diagrama-ferramentas button {
  background: #1e88b8;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Bloco do equipamento (OLT/switch/router) dentro da caixa — paridade visual com o Tomodat */
.diagrama-host { background: #8a8a8a; border-radius: 3px; }
.diagrama-host-titulo {
  background: #3B3B3B; color: #fff; font-weight: bold; font-size: 12px;
  padding: 4px 6px; display: flex; justify-content: space-between; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.diagrama-host-titulo .host-acoes button {
  background: none; border: 0; color: #fff; cursor: pointer; font-size: 12px; padding: 0 2px;
}
.diagrama-host-titulo .host-apagar { color: #e74c3c; }
.diagrama-host-portas { padding: 6px; }
.diagrama-porta { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.diagrama-porta.selecionada { background: #ffe08a; outline: 2px solid #e0a800; }
.porta-alias {
  background: #cfcfcf; color: #222; font-size: 11px; min-width: 110px;
  padding: 1px 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.porta-pontilhado { border-left: 2px dotted #444; height: 100%; margin: 0 2px; }
.porta-potencia {
  background: #008CBA; color: #fff; font-size: 11px; padding: 1px 6px; cursor: pointer; min-width: 34px;
  text-align: center;
}
/* Janela óptica: cinza porque é atributo, não medida — a potência (azul) é que é
   medida. Porta sem janela mostra "--" e fica apagada, porque a árvore óptica vai
   assumir 1490 nm por ela: o estado precisa ser visivelmente diferente de escolhido. */
.porta-janela {
  background: #6b6b6b; color: #fff; font-size: 10px; padding: 1px 4px; cursor: pointer;
  min-width: 30px; text-align: center;
}
.porta-janela.sem-janela { background: #d5d5d5; color: #555; font-style: italic; }
.porta-num {
  background: #111; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 9px; min-width: 22px;
  text-align: center;
}
.diagrama-porta.ligada .porta-num { outline: 2px solid #4CAF50; }

/* Nota do destino da fibra */
.fibra-nota {
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.45;
  filter: grayscale(1);
}

.fibra-nota:hover { opacity: 1; filter: none; }
.fibra-nota.tem { opacity: 1; filter: none; }

.fibra-nota-texto {
  font-size: 0.72rem;
  color: #2f3640;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modais do diagrama (nota e splitter) */
.dg-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2100;
}

.dg-modal-caixa {
  background: #fff;
  border-radius: 4px;
  width: 340px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.dg-modal-titulo {
  background: #5c9c3f;
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: 4px 4px 0 0;
}

.dg-modal-corpo { padding: 0.9rem; }
.dg-modal-onde { margin: 0 0 0.6rem; font-size: 0.8rem; color: #666; }

.dg-modal-corpo label {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
  color: #444;
}

.dg-modal-corpo input,
.dg-modal-corpo select,
.dg-modal-corpo textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.9rem;
  box-sizing: border-box;
  margin-top: 0.2rem;
  font-family: inherit;
}

.dg-duas-colunas { display: flex; gap: 0.5rem; }

.dg-modal-acoes {
  border-top: 1px solid #e4e4e4;
  padding: 0.7rem 0.9rem;
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* O padrão é o botão secundário (Cancelar, Alternar TX/RX): cinza com texto branco.
   Ter fundo aqui, e não só nas variantes, é o que impede um botão sem classe de sair
   com texto branco sobre o fundo cinza-claro do navegador — invisível. Foi assim que
   os botões de "Adicionar equipamento" e "Editar porta" ficaram apagados. */
.dg-modal-acoes button {
  border: none;
  border-radius: 3px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #fff;
  background: #6b7075;
}

.dg-modal-acoes button:hover { filter: brightness(1.12); }

/* Azul = a ação principal do modal. Vermelho = apaga alguma coisa, e só isso —
   Cancelar não destrói nada e por isso não é vermelho. */
/* Um tom mais escuro que o azul do resto da tela: com texto branco, #2f7fb8 dava
   4,33:1 de contraste, logo abaixo do mínimo de 4,5:1. */
.dg-modal-acoes button.ok { background: #2c78ae; }
.dg-modal-acoes button.perigo { background: #c0392b; }

/* checkbox e aviso dentro dos modais do diagrama */
.dg-check { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; font-size: 0.85rem; }
.dg-check input { width: auto; margin: 0; }
.dg-aviso {
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.5rem;
  background: #fff4d6;
  border-left: 3px solid #e0a800;
  font-size: 0.8rem;
  color: #6b5200;
}

/* lápis e lixeira no título do splitter */
.spl-acoes { float: right; display: flex; gap: 0.25rem; }
.spl-acoes button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.15rem;
  line-height: 1;
}
.spl-acoes button:hover { color: #ffd479; }


/* ---- Diagrama de emendas e níveis ópticos (árvore óptica) ---- */
.arvore-pagina { display: flex; flex-direction: column; gap: 0.6rem; }

.arvore-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
}

.arvore-origem { font-size: 0.95rem; color: #222; }

.arvore-opcoes {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.85rem;
  color: #444;
}

.arvore-opcoes label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }

.arvore-zoom { display: flex; align-items: center; gap: 0.35rem; }

.arvore-zoom button {
  width: 26px;
  height: 26px;
  border: 1px solid #bbb;
  background: #f7f7f7;
  border-radius: 3px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.arvore-zoom button:hover { background: #ececec; }
.arvore-zoom span { min-width: 44px; text-align: center; }

.arvore-avisos {
  background: #fff8e1;
  border: 1px solid #e6c86a;
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  color: #6b5300;
}

.arvore-resumo { font-size: 0.85rem; color: #666; padding: 0 0.2rem; }

.arvore-tela {
  flex: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 420px;
}

.arvore-no { cursor: default; }
.arvore-no:hover rect:first-child { stroke: #1f4e79; stroke-width: 1.5; }

/* Atalho pra árvore, na linha da porta do equipamento dentro do diagrama da caixa. */
.porta-arvore {
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.8;
  text-decoration: none;
}

.porta-arvore:hover { opacity: 1; }

.porta-em-foco { outline: 3px solid #0478bd !important; box-shadow: 0 0 0 6px #bbdefb; }
