/* Paleta y estilos de FTA Web Studio */
:root {
  --azul-noche: #0f2740;
  --azul: #1f4e79;
  --azul-claro: #2e6da4;
  --cian: #17a2b8;
  --ambar: #f0a500;
  --rojo: #c0392b;
  --verde: #1e8449;
  --gris-fondo: #eef3f8;
  --gris-borde: #c3d3e2;
  --texto: #16232f;
  --blanco: #ffffff;
  --sombra: 0 2px 10px rgba(15, 39, 64, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--texto);
  background: var(--gris-fondo);
}

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(120deg, var(--azul-noche), var(--azul) 60%, var(--azul-claro));
  color: var(--blanco);
  box-shadow: var(--sombra);
}

header.app-header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.4px;
}

header.app-header .usuario {
  font-size: 13px;
  opacity: 0.9;
}

header.app-header .marca {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

header.app-header .marca-vr {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--blanco);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

header.app-header .marca-vr:hover { background: rgba(255, 255, 255, 0.26); }

header.app-header .enlace-cab {
  font-size: 12px;
  font-weight: 600;
  color: var(--blanco);
  text-decoration: none;
  opacity: 0.9;
  white-space: nowrap;
}

header.app-header .enlace-cab:hover { opacity: 1; text-decoration: underline; }

header.app-header .enlace-cab.patreon {
  background: #f96854;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  opacity: 1;
}

header.app-header .enlace-cab.patreon:hover { background: #e85a46; text-decoration: none; }

button {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  background: var(--azul);
  color: var(--blanco);
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover { background: var(--azul-claro); }
button:active { transform: translateY(1px); }
button.secundario { background: var(--blanco); color: var(--azul); border-color: var(--gris-borde); }
button.secundario:hover { background: var(--gris-fondo); }
button.peligro { background: var(--rojo); }
button.exito { background: var(--verde); }
button.ambar { background: var(--ambar); color: #2b1d00; }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  background: var(--blanco);
  color: var(--texto);
  width: 100%;
}

label { font-size: 12px; font-weight: 600; color: var(--azul); display: block; margin-bottom: 3px; }

.login-pantalla {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1f4e79, #0f2740 70%);
}

.login-caja {
  width: 340px;
  background: var(--blanco);
  border-radius: 12px;
  padding: 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-caja h2 { margin: 0 0 4px; color: var(--azul); font-size: 20px; }
.login-caja p.sub { margin: 0 0 18px; font-size: 12px; color: #5b6b7b; }
.login-caja .campo { margin-bottom: 12px; }
.login-caja .error { color: var(--rojo); font-size: 12px; min-height: 16px; }
.login-caja .pista-login { font-size: 12px; color: #5b6b7b; margin: 0 0 16px; line-height: 1.5; }
.login-caja .pista-login.centrado { text-align: center; margin: 14px 0 0; }
.login-caja .pista-login a { color: var(--azul); text-decoration: none; font-weight: 600; }
.login-caja .pista-login a:hover { text-decoration: underline; }
.login-caja .boton-entrar {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--blanco);
  background: var(--verde);
  border-radius: 6px;
  padding: 11px 12px;
  transition: background 0.15s ease;
}
.login-caja .boton-entrar:hover { background: #176e3a; }
.login-caja .separador-login {
  border: 0;
  border-top: 1px solid var(--gris-borde);
  margin: 16px 0 14px;
}

.layout { display: flex; height: calc(100vh - 52px); }

aside.paleta {
  width: 210px;
  background: var(--blanco);
  border-right: 1px solid var(--gris-borde);
  padding: 12px;
  overflow-y: auto;
}

aside.paleta h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--azul);
  margin: 14px 0 8px;
}

.paleta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  margin-bottom: 6px;
  border: 1px dashed var(--gris-borde);
  border-radius: 8px;
  background: #fbfdff;
  cursor: grab;
  font-size: 12.5px;
}

.paleta-item:hover { border-color: var(--azul-claro); background: #f2f8ff; }
.paleta-icono { flex: 0 0 28px; display: inline-flex; justify-content: center; align-items: center; }
.paleta-icono svg { display: block; }

main.lienzo-zona { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.barra-herramientas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--blanco);
  border-bottom: 1px solid var(--gris-borde);
}

.barra-herramientas .nombre-arbol { min-width: 200px; max-width: 280px; }

#lienzo {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f7fafd;
  background-image: radial-gradient(#d6e3ef 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
}

#lienzo.panning { cursor: grabbing; }

#lienzo-contenido {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

#svg-arbol { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
#svg-arbol .arista { fill: none; stroke: var(--azul); stroke-width: 2; }
#svg-arbol .arista.activa { stroke: var(--ambar); stroke-width: 3; }
#svg-arbol .arista.condicion { stroke-dasharray: 5 3; }
#svg-arbol .arista.seleccionada { stroke: var(--ambar); stroke-width: 3; }
#svg-arbol .arista.fantasma { stroke-dasharray: 4 4; stroke: var(--ambar); }
#svg-arbol .arista-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
#svg-arbol .etiqueta-entrada { font: 600 10px "Segoe UI", sans-serif; fill: var(--azul); paint-order: stroke; stroke: #fff; stroke-width: 3px; }

/* símbolos IEC 61025 */
.simb .cuerpo  { fill: #eaf1f8; stroke: var(--azul); stroke-width: 2; stroke-linejoin: round; }
.simb .cuerpo.top { fill: #fdecea; stroke: var(--rojo); }
.simb .linea   { fill: none; stroke: var(--azul); stroke-width: 2; }
.simb .burbuja { fill: #fff; stroke: var(--azul); stroke-width: 2; }
.simb .texto-kn { fill: var(--azul); font: 700 9px "Segoe UI", sans-serif; }
.simb.invalido .cuerpo { stroke: var(--rojo); }

.nodo {
  position: absolute;
  width: 150px;
  height: 94px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  cursor: move;
  user-select: none;
}

.nodo .caja {
  height: 48px;
  padding: 4px 6px;
  background: #fff;
  border: 2px solid var(--azul);
  border-radius: 4px;
  box-shadow: var(--sombra);
  overflow: hidden;
  text-align: center;
}

.nodo .titulo { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--azul-noche); }
.nodo .meta { font-size: 10px; color: #5b6b7b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nodo .simbolo { height: 46px; display: flex; justify-content: center; position: relative; }
.nodo .simbolo::before { content: ""; position: absolute; top: -2px; left: 50%; width: 2px; height: 4px; background: var(--azul); }
.nodo.top .caja { border-color: var(--rojo); }
.nodo.seleccionado .caja { border-color: var(--ambar); box-shadow: 0 0 0 3px rgba(240, 165, 0, 0.28); }
.nodo.resaltado .caja { background: #fff8e6; border-color: var(--ambar); box-shadow: 0 0 0 4px rgba(240, 165, 0, 0.45); }
.nodo.destino-ok .caja { box-shadow: 0 0 0 4px rgba(30, 132, 73, 0.45); }
.nodo.destino-ko .caja { box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.45); cursor: not-allowed; }

.puerto { position: absolute; left: 67px; width: 16px; height: 16px; border-radius: 50%;
          background: #fff; border: 2px solid var(--azul); opacity: 0; transition: opacity .1s; }
.puerto-entrada { top: 82px; cursor: crosshair; }
.puerto-salida { top: -8px; pointer-events: none; }
.nodo:hover .puerto, #lienzo.conectando .puerto-salida { opacity: 1; }

.toast { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
         padding: 6px 12px; border-radius: 6px; background: var(--azul-noche); color: #fff; font-size: 12px; z-index: 10; }
.toast.error { background: var(--rojo); }
.toast.ok { background: var(--verde); }

.arbol-estructura, .lista-enlaces, .lista-entradas { list-style: none; margin: 4px 0 10px; padding: 0; font-size: 12px; }
.arbol-estructura li, .lista-enlaces li, .lista-entradas li { margin-bottom: 3px; }
.lista-enlaces a, .arbol-estructura a, .lista-entradas a { color: var(--azul); text-decoration: none; }
.lista-enlaces a:hover, .arbol-estructura a:hover, .lista-entradas a:hover { text-decoration: underline; }
.lista-entradas li { display: flex; align-items: center; gap: 6px; }
.lista-entradas .rol { flex: 0 0 auto; color: #5b6b7b; font-size: 10.5px; }
.lista-entradas a { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-entradas .botones { flex: 0 0 auto; display: inline-flex; gap: 2px; }
.lista-entradas .botones button { font-size: 10px; padding: 2px 5px; border-radius: 4px; }
.seccion { margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; color: var(--azul); border-top: 1px dashed var(--gris-borde); padding-top: 8px; }

.panel-derecho {
  width: 340px;
  background: var(--blanco);
  border-left: 1px solid var(--gris-borde);
  padding: 12px;
  overflow-y: auto;
}

.panel-derecho h3 { font-size: 12px; text-transform: uppercase; color: var(--azul); margin: 4px 0 10px; }
.panel-derecho .campo { margin-bottom: 10px; }

.pestanas { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }

.pestana {
  background: var(--gris-fondo);
  color: var(--azul);
  border: 1px solid var(--gris-borde);
  padding: 5px 9px;
  font-size: 11.5px;
}

.pestana.activa { background: var(--azul); color: var(--blanco); border-color: var(--azul); }

.panel { display: none; }
.panel.activo { display: block; }

.barra-herramientas.segunda { border-top: 1px dashed var(--gris-borde); }
.barra-herramientas .separador { width: 1px; height: 22px; background: var(--gris-borde); }
.barra-herramientas .buscador { min-width: 180px; max-width: 240px; }
.barra-herramientas .zoom-nivel { font-size: 12px; color: var(--azul); min-width: 48px; text-align: center; }

.cabecera-derecha { display: flex; align-items: center; gap: 10px; }

.insignia {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.acciones-estado { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.acciones-estado button { flex: 1 1 45%; font-size: 11.5px; padding: 6px 8px; }

.resultados .pista { font-size: 11.5px; color: #5b6b7b; }
.resultados ul.lista { margin: 4px 0 10px 16px; padding: 0; }
.resultados ul.lista li { margin-bottom: 3px; }
.resultados table.ordenable th { cursor: pointer; user-select: none; }
.resultados table.ordenable th:hover { background: #dbe8f5; }
.resultados tr.fila-corte { cursor: pointer; }
.resultados tr.fila-corte:hover { background: #fff8e6; }

.estado-salud { font-weight: 700; padding: 6px 8px; border-radius: 6px; }
.estado-salud.ok { background: #e8f6ee; color: var(--verde); }
.estado-salud.aviso { background: #fdf3e0; color: #8a6100; }
.estado-salud.error { background: #fdecea; color: var(--rojo); }

.resultados { font-size: 12px; }
.resultados table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.resultados th, .resultados td { border: 1px solid var(--gris-borde); padding: 4px 6px; text-align: left; }
.resultados th { background: #eaf1f8; color: var(--azul); }
.resultados .aviso { color: var(--ambar); }
.resultados .error { color: var(--rojo); }

.oculto { display: none !important; }
