/* ═══════════════════════════════════════════════════════════════════════════
   simulator.css — Simulador Eléctrico Residencial
   Tema: Dark Electric Professional
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset y base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark:       #0D1117;
  --bg-panel:      #161B22;
  --bg-card:       #1C2128;
  --bg-hover:      #21262D;
  --accent:        #2188FF;
  --accent-glow:   #388BFD;
  --accent-green:  #3FB950;
  --accent-red:    #F85149;
  --accent-yellow: #D29922;
  --accent-orange: #DB6D28;
  --text-primary:  #E6EDF3;
  --text-muted:    #8B949E;
  --text-dim:      #484F58;
  --border:        #30363D;
  --border-bright: #484F58;
  --font-mono:     'Courier New', 'Fira Code', monospace;
  --font-ui:       'Segoe UI', system-ui, sans-serif;
  --radius:        6px;
  --shadow-glow:   0 0 12px rgba(33, 136, 255, 0.3);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg-dark);
  color: var(--text-primary);
  user-select: none;
}

/* ─── Layout Principal ─────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: 48px 1fr;
  grid-template-columns: 240px 1fr 220px;
  grid-template-areas:
    "header header header"
    "panel-left canvas panel-right";
  height: 100vh;
  overflow: hidden;
}

/* ─── Header / Toolbar ─────────────────────────────────────────────────────── */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  /* Si el contenido (pestañas + toolbar + enlaces) no cabe en el ancho de
     la ventana, se puede hacer scroll horizontal en vez de recortarlo y
     dejar botones como "Cable" inaccesibles sin ningún aviso. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

#header .logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

#header .logo .bolt {
  font-size: 18px;
  filter: drop-shadow(0 0 6px #FFD700);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  /* No se encoge: antes, con flex:1 + min-width:0, si el resto del header
     (9 pestañas + enlaces) no cabía, esta barra terminaba aplastada a 0px
     de ancho y el botón "Cable" (y los demás) quedaban invisibles. Ahora
     conserva su ancho natural y es el header el que hace scroll (ver
     #header) cuando todo junto no cabe. */
  flex-shrink: 0;
}

.toolbar-sep {
  width: 1px;
  height: 26px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ─── Botón principal: Simular ─────────────────────────────────────────────── */
.btn-simular {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, #1a7a2e, var(--accent-green));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.35);
  letter-spacing: 0.3px;
}
.btn-simular:hover {
  background: linear-gradient(135deg, #238636, #56d364);
  box-shadow: 0 0 16px rgba(63, 185, 80, 0.55);
  transform: translateY(-1px);
}
.btn-simular:active { transform: scale(0.97); }
.btn-simular.running {
  background: linear-gradient(135deg, #9a3412, var(--accent-orange));
  box-shadow: 0 0 10px rgba(219, 109, 40, 0.4);
  animation: pulse-green 0.8s ease-in-out;
}

/* Modo simulación activo */
.btn-simular.active {
  background: linear-gradient(135deg, #145a14, #3fb950);
  box-shadow: 0 0 14px rgba(63,185,80,0.55);
  animation: pulse-live 1.4s ease-in-out infinite;
}

/* Badge "EN VIVO" */
.badge-live {
  display: none;
  align-items: center;
  gap: 5px;
  background: rgba(63,185,80,0.15);
  border: 1px solid #3fb950;
  color: #56d364;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  animation: pulse-live 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-live {
  0%   { box-shadow: 0 0 0  rgba(63,185,80,0.4); }
  50%  { box-shadow: 0 0 16px rgba(63,185,80,0.75); }
  100% { box-shadow: 0 0 4px rgba(63,185,80,0.3); }
}
@keyframes pulse-green {
  0%   { box-shadow: 0 0 0  rgba(63,185,80,0.6); }
  50%  { box-shadow: 0 0 20px rgba(63,185,80,0.8); }
  100% { box-shadow: 0 0 10px rgba(63,185,80,0.35); }
}
.btn-simular .icon { font-size: 13px; }

/* ─── Botones de herramienta ───────────────────────────────────────────────── */
.btn-tool {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-tool:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-bright); }
.btn-tool.active { background: var(--accent); color: #fff; border-color: var(--accent-glow); box-shadow: var(--shadow-glow); }
.btn-tool.danger { border-color: var(--accent-red); }
.btn-tool.danger:hover { background: #2d1117; color: var(--accent-red); }
.btn-tool .icon { font-size: 13px; }

/* Selector AWG */
.awg-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  height: 28px;
  flex-shrink: 0;
}

.awg-selector label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.awg-selector select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  outline: none;
  max-width: 80px;
}
.awg-selector select option { background: var(--bg-card); }

/* Project info */
.project-name {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Enlaces a módulos (Murete/Instalación/Reporte) al final del header:
   que conserven su tamaño en vez de comprimirse — si no caben, se llega
   a ellos con el scroll horizontal del header, no aplastándolos. */
#header > a { flex-shrink: 0; }

/* ─── Panel Izquierdo — Componentes ────────────────────────────────────────── */
#panel-left {
  grid-area: panel-left;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.panel-header {
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.components-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.components-scroll::-webkit-scrollbar { width: 4px; }
.components-scroll::-webkit-scrollbar-track { background: transparent; }
.components-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Categorías */
.cat-header {
  padding: 6px 8px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

/* Tarjetas de componentes arrastrables */
.comp-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: grab;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.comp-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}

.comp-card:hover { background: var(--bg-hover); border-color: var(--border-bright); }
.comp-card:hover::before { opacity: 1; }
.comp-card:active { cursor: grabbing; transform: scale(0.98); }

.comp-card .comp-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-size: 18px;
  flex-shrink: 0;
}

.comp-card .comp-info { flex: 1; min-width: 0; }
.comp-card .comp-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-card .comp-spec { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

/* Colores por tipo */
.comp-card[data-tipo="breaker"]       .comp-icon { background: rgba(33,136,255,0.15); }
.comp-card[data-tipo="foco"]          .comp-icon { background: rgba(210,153,34,0.15); }
.comp-card[data-tipo="tomacorriente"] .comp-icon { background: rgba(63,185,80,0.15); }
.comp-card[data-tipo="interruptor"]   .comp-icon { background: rgba(219,109,40,0.15); }
.comp-card[data-tipo="panel"]         .comp-icon { background: rgba(248,81,73,0.15); }

/* Preview flotante: foto real del componente (al pasar el mouse sobre la tarjeta) */
#comp-foto-preview {
  position: fixed;
  z-index: 500;
  width: 200px;
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
#comp-foto-preview.visible { opacity: 1; visibility: visible; transform: translateY(0); }
#comp-foto-preview img {
  display: block;
  width: 100%;
  height: 150px;
  /* "contain" (no "cover"): las fotos reales son retratos altos y angostos;
     recortarlas ("cover") las hacía verse como un zoom exagerado que se
     salía del recuadro visualmente. Con "contain" se ve la foto completa. */
  object-fit: contain;
  background: var(--bg-dark);
  border-radius: 4px;
  border: 1px solid var(--border);
}
#comp-foto-preview-cap {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Canvas Central ───────────────────────────────────────────────────────── */
#canvas-container {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background: #1A1A2E;
}

#main-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Indicador de herramienta activa sobre el canvas */
#tool-indicator {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s;
}

/* Zoom indicator */
#zoom-indicator {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
}

/* ─── Panel Derecho — Propiedades + Log ────────────────────────────────────── */
#panel-right {
  grid-area: panel-right;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* Tabs del panel derecho */
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.panel-tab:hover { color: var(--text-primary); }
.panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; }

/* ─── Propiedades del componente seleccionado ─────────────────────────────── */
#props-content {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.prop-row:last-child { border-bottom: none; }
.prop-label { color: var(--text-muted); }
.prop-value {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 11px;
}
.prop-value.ok { color: var(--accent-green); }
.prop-value.warn { color: var(--accent-yellow); }
.prop-value.err { color: var(--accent-red); }

/* Medidor de carga (barra) */
.load-bar-wrap { margin: 8px 0; }
.load-bar-label { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; }
.load-bar { height: 6px; border-radius: 3px; background: var(--bg-dark); overflow: hidden; }
.load-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-green);
  transition: width 0.3s ease, background 0.3s ease;
}
.load-bar-fill.medium { background: var(--accent-yellow); }
.load-bar-fill.high   { background: var(--accent-red); }

/* ─── Log de Eventos ───────────────────────────────────────────────────────── */
#log-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

#log-content::-webkit-scrollbar { width: 4px; }
#log-content::-webkit-scrollbar-thumb { background: var(--border); }

.log-entry {
  display: flex;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  font-size: 10px;
  font-family: var(--font-mono);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.log-entry .log-time { color: var(--text-dim); flex-shrink: 0; }
.log-entry .log-msg  { color: var(--text-muted); flex: 1; min-width: 0; word-break: break-word; }
.log-entry.cortocircuito { background: rgba(248,81,73,0.1); }
.log-entry.cortocircuito .log-msg { color: var(--accent-red); }
.log-entry.trip_breaker  { background: rgba(248,81,73,0.07); }
.log-entry.trip_breaker  .log-msg { color: #FF8A80; }
.log-entry.sobrecarga    { background: rgba(210,153,34,0.07); }
.log-entry.sobrecarga    .log-msg { color: var(--accent-yellow); }
.log-entry.conexion_ok   .log-msg { color: var(--accent-green); }
.log-entry.guardado      .log-msg { color: var(--accent); }

.log-clear-btn {
  width: 100%;
  padding: 5px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  margin: 4px 0;
}
.log-clear-btn:hover { background: var(--bg-hover); color: var(--accent-red); }

/* ─── Debug Console Flotante ───────────────────────────────────────────────── */
#debug-console {
  position: absolute;
  bottom: 40px;
  left: 12px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-width: 200px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #76FF03;
  pointer-events: none;
  display: none;
}

#debug-console.visible { display: block; }
#debug-console .debug-title {
  color: var(--accent);
  font-size: 10px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#debug-console .debug-line { color: #76FF03; line-height: 1.6; }
#debug-console .debug-val  { color: #FFD700; }

/* ─── Notificaciones Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-primary);
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.75s forwards;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.warning { border-left: 3px solid var(--accent-yellow); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn  { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateX(20px); } }

/* ─── Menú contextual ─────────────────────────────────────────────────────── */
#context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 9000;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
}

#context-menu.visible { display: block; }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--accent-red); }
.ctx-item.active { background: var(--accent); color: #fff; }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 0; }
.ctx-item-label {
  padding: 6px 10px 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.ctx-hint {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ─── Menú desplegable "Más" (nuevo, practicar fallas, guardar, cargar…) ──── */
.dropdown-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.dropdown-menu {
  /* position:fixed (no absolute) a propósito: el header tiene
     overflow-x:auto (para poder desplazar la toolbar en pantallas
     angostas — ver #header), y eso recorta también cualquier hijo
     posicionado en absoluto que sobresalga verticalmente del header,
     incluido este menú. Con "fixed" ya no depende del contenedor — su
     posición (top/left) se calcula en JS al abrirlo, junto al botón. */
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 9000;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: none;
}
.dropdown-menu.visible { display: block; }

/* ─── Modal de propiedades / guardar ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  display: none;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  width: 380px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal h3 { font-size: 15px; margin-bottom: 16px; color: var(--text-primary); }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font-ui);
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }

.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.btn {
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-glow); }
.btn-secondary { background: transparent; color: var(--text-muted); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Scrollbars globales ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ─── Animaciones de estado ───────────────────────────────────────────────── */
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(248,81,73,0); }
}

.tripped { animation: pulse-red 1s infinite; }

/* ─── Responsive mínimo (tablets) ─────────────────────────────────────────── */
@media (max-width: 900px) {
  #app {
    grid-template-columns: 180px 1fr 0px;
    grid-template-areas: "header header header" "panel-left canvas canvas";
  }
  #panel-right { display: none; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   SECCIÓN DE PESTAÑAS PRINCIPALES (Simulador / Acometida)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Re-estructura #app para acomodar dos secciones */
#app {
  display: flex !important;
  flex-direction: column !important;
  grid-template-rows: unset !important;
  grid-template-columns: unset !important;
  grid-template-areas: unset !important;
}

/* Header con flex */
#header {
  grid-area: unset !important;
  flex-shrink: 0;
  height: 48px;
}

/* Tabs de sección en el header */
.section-tabs-header {
  display: flex;
  gap: 2px;
  padding: 0 4px;
  margin-right: 6px;
  border-right: 1px solid var(--border);
  /* Con 9 pestañas, esta barra sola puede pesar ~950px. Antes tenía
     flex-shrink:0 ("nunca se encoge"), lo que empujaba fuera de la
     ventana a la barra de herramientas (con el botón Cable) sin dejar
     forma de llegar a ella. Ahora se encoge y hace su propio scroll
     horizontal, para que la toolbar — más importante — siempre tenga
     su espacio garantizado y quede visible. */
  flex: 0 1 auto;
  min-width: 90px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.section-tabs-header::-webkit-scrollbar { display: none; }

.section-tab-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.section-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.section-tab-btn.active {
  background: rgba(33,136,255,0.15);
  color: var(--accent);
  border-color: var(--accent);
}


/* ─── Contenedor de vistas ─────────────────────────────────────────────────── */
.main-view {
  flex: 1;
  overflow: hidden;
  display: none;
}

/* Vista del Simulador */
#simulador-view.active {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  grid-template-areas: "panel-left canvas panel-right";
}

/* Asignar áreas al simulador */
#simulador-view #panel-left     { grid-area: panel-left; }
#simulador-view #canvas-container { grid-area: canvas; }
#simulador-view #panel-right    { grid-area: panel-right; }


/* ═══════════════════════════════════════════════════════════════════════════
   SECCIÓN DE ACOMETIDA RESIDENCIAL
   ═══════════════════════════════════════════════════════════════════════════ */

/* Vista de acometida — 3 columnas */
#acometida-view.active {
  display: grid;
  grid-template-columns: 290px 1fr 250px;
  grid-template-areas: "ac-config ac-diagram ac-results";
}

#ac-panel-config  { grid-area: ac-config; }
#ac-panel-diagram { grid-area: ac-diagram; }
#ac-panel-results { grid-area: ac-results; }

/* Paneles laterales de acometida */
#ac-panel-config,
#ac-panel-results {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#ac-panel-results {
  border-right: none;
  border-left: 1px solid var(--border);
}

/* Panel central del diagrama */
#ac-panel-diagram {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0D1117;
}

#acometida-diagrama {
  flex: 1;
  overflow: hidden;
}

/* Header del diagrama */
.ac-diagram-header {
  display: flex !important;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.ac-diagram-subtitle {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-transform: none;
}

/* ─── Formulario de configuración ──────────────────────────────────────────── */
.ac-form-scroll,
.ac-results-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.ac-form-scroll::-webkit-scrollbar,
.ac-results-scroll::-webkit-scrollbar { width: 4px; }
.ac-form-scroll::-webkit-scrollbar-thumb,
.ac-results-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.ac-section-title {
  padding: 8px 0 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  margin-top: 4px;
}

.ac-field {
  margin-bottom: 10px;
}

.ac-field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ac-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 11.5px;
  padding: 6px 8px;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font-ui);
  cursor: pointer;
}

.ac-select:focus { border-color: var(--accent); }
.ac-select option { background: var(--bg-card); }

.ac-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ac-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 6px 8px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.ac-input:focus { border-color: var(--accent); }

.ac-unit {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 36px;
}

.ac-hint {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 3px;
  line-height: 1.4;
}

/* ─── Botón Calcular ────────────────────────────────────────────────────────── */
.btn-calcular {
  width: 100%;
  padding: 10px;
  margin: 12px 0 10px;
  background: var(--accent);
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-glow);
}

.btn-calcular:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(33,136,255,0.4);
}

.btn-calcular:active { transform: translateY(0); }

/* ─── Referencias NEC ────────────────────────────────────────────────────────── */
.ac-nec-ref {
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ac-nec-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.ac-nec-item {
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 0;
  line-height: 1.5;
}

.nec-code {
  color: var(--accent-yellow);
  font-family: var(--font-mono);
  margin-right: 5px;
}

/* ─── Panel de resultados ────────────────────────────────────────────────────── */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  gap: 8px;
}

.result-row:last-child { border-bottom: none; }

.result-label {
  color: var(--text-muted);
  flex-shrink: 0;
  max-width: 50%;
}

.result-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 11px;
  text-align: right;
}

.result-val.ok   { color: var(--accent-green); }
.result-val.warn { color: var(--accent-yellow); }
.result-val.err  { color: var(--accent-red); }

/* ─── Panel de cumplimiento normativo ──────────────────────────────────────── */
.cumpl-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 4px;
  border-radius: 4px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.cumpl-row:hover { background: var(--bg-hover); }

.cumpl-icon { font-size: 13px; flex-shrink: 0; margin-top: 1px; }

.cumpl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cumpl-label {
  font-size: 11px;
  color: var(--text-primary);
}

.cumpl-nec {
  font-size: 9.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONSTRUCTOR DE ACOMETIDA
   ═══════════════════════════════════════════════════════════════════════════ */

#constructor-view.active {
  display: grid;
  grid-template-columns: 200px 1fr 260px;
  grid-template-areas: "ctr-palette ctr-canvas ctr-results";
}

#ctr-palette      { grid-area: ctr-palette; }
#ctr-canvas-wrap  { grid-area: ctr-canvas; }
#ctr-results      { grid-area: ctr-results; }

/* Palette */
#ctr-palette {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ctr-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctr-palette-item {
  background: #1C2128;
  border: 1.5px solid #30363D;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #C9D1D9;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.ctr-palette-item:hover {
  background: #21262D;
  border-color: #388BFD;
  transform: translateX(2px);
}

.ctr-palette-item.used {
  opacity: 0.38;
  pointer-events: none;
}

.ctr-palette-item .ctr-item-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.ctr-palette-item .ctr-item-name {
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.3;
}

.ctr-palette-item .ctr-item-desc {
  font-size: 9.5px;
  color: #8B949E;
  margin-top: 1px;
}

.ctr-palette-hint {
  padding: 8px 12px 12px;
  font-size: 10px;
  color: #6E7681;
  text-align: center;
  border-top: 1px solid #21262D;
}

/* Canvas wrap */
#ctr-canvas-wrap {
  display: flex;
  flex-direction: column;
  background: #0D1117;
  overflow: hidden;
  position: relative;
}

.ctr-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #161B22;
  border-bottom: 1px solid #21262D;
  gap: 10px;
}

.ctr-stage-label {
  font-size: 12px;
  color: #8B949E;
  flex: 1;
}

.ctr-canvas-actions {
  display: flex;
  gap: 8px;
}

.btn-ctr-action {
  background: #21262D;
  border: 1px solid #30363D;
  color: #C9D1D9;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ctr-action:hover { background: #2D333B; }

.btn-ctr-primary {
  background: linear-gradient(135deg, #1F6FEB, #0D3B85);
  border: 1px solid #388BFD;
  color: #fff;
  padding: 5px 18px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: opacity 0.15s;
}
.btn-ctr-primary:hover { opacity: 0.88; }

#ctr-canvas {
  flex: 1;
  display: block;
  width: 100%;
  cursor: default;
}

/* Results panel */
#ctr-results {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ctr-score-box {
  margin: 14px 14px 6px;
  background: #1C2128;
  border: 1px solid #30363D;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.ctr-score-num {
  font-size: 42px;
  font-weight: 800;
  color: #C9D1D9;
  line-height: 1;
  transition: color 0.3s;
}

.ctr-score-num.perfect { color: #3FB950; }
.ctr-score-num.good    { color: #79C0FF; }
.ctr-score-num.bad     { color: #F85149; }

.ctr-score-label {
  font-size: 11px;
  color: #8B949E;
  margin-top: 4px;
}

.ctr-checks-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctr-checks-placeholder {
  color: #6E7681;
  font-size: 11px;
  text-align: center;
  padding: 28px 8px;
  line-height: 1.7;
}

.ctr-check-item {
  background: #1C2128;
  border: 1px solid #30363D;
  border-radius: 7px;
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
}

.ctr-check-item.ok   { border-color: rgba(63, 185, 80, 0.35); }
.ctr-check-item.err  { border-color: rgba(248, 81, 73, 0.40); }
.ctr-check-item.warn { border-color: rgba(210, 153, 34, 0.40); }

.ctr-check-icon { font-size: 14px; flex-shrink: 0; line-height: 1.3; }
.ctr-check-text { flex: 1; }
.ctr-check-title { font-weight: 600; color: #C9D1D9; }
.ctr-check-detail { color: #8B949E; font-size: 10px; margin-top: 2px; }
.ctr-check-nec { color: #388BFD; font-size: 9.5px; margin-top: 2px; font-style: italic; }

.ctr-legend {
  padding: 10px 14px;
  border-top: 1px solid #21262D;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctr-legend-row {
  font-size: 10px;
  color: #8B949E;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GALERÍA DE ACOMETIDAS REALES
   ═══════════════════════════════════════════════════════════════════════════ */

#galeria-view.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0D1117;
}

/* Barra superior */
#gal-topbar {
  background: #161B22;
  border-bottom: 1px solid #21262D;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.gal-title {
  font-size: 13px;
  font-weight: 700;
  color: #E6EDF3;
  white-space: nowrap;
}

.gal-search-wrap {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 240px;
}

.gal-search-input {
  flex: 1;
  background: #0D1117;
  border: 1px solid #30363D;
  border-radius: 6px;
  color: #C9D1D9;
  padding: 5px 12px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.gal-search-input:focus { border-color: #388BFD; }

.gal-search-btn {
  background: #1F6FEB;
  border: 1px solid #388BFD;
  color: #fff;
  padding: 5px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.gal-search-btn:hover { background: #388BFD; }

.gal-filter-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.gal-filter-btn {
  background: #21262D;
  border: 1px solid #30363D;
  color: #8B949E;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.gal-filter-btn:hover  { border-color: #388BFD; color: #79C0FF; }
.gal-filter-btn.active { background: #1F6FEB22; border-color: #388BFD; color: #79C0FF; font-weight: 600; }

/* Grid área */
#gal-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  position: relative;
}

#gal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Tarjeta de foto */
.gal-card {
  background: #161B22;
  border: 1px solid #21262D;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.gal-card:hover {
  transform: translateY(-3px);
  border-color: #388BFD;
  box-shadow: 0 6px 24px rgba(56,139,253,0.18);
}

.gal-card-img-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #0D1117;
  position: relative;
}

.gal-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}
.gal-card:hover .gal-card-img-wrap img { transform: scale(1.04); }

.gal-card-img-wrap .gal-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(13,17,23,0.80) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.gal-card:hover .gal-card-overlay { opacity: 1; }
.gal-card-overlay span {
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.gal-card-info {
  padding: 10px 12px 12px;
}

.gal-card-label {
  font-size: 12px;
  font-weight: 700;
  color: #C9D1D9;
  margin-bottom: 3px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gal-card-desc {
  font-size: 10.5px;
  color: #8B949E;
  line-height: 1.4;
}

.gal-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.gal-tag {
  background: #1C2128;
  border: 1px solid #30363D;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 9.5px;
  color: #79C0FF;
}

.gal-tag.mexico { border-color: #3FB95044; color: #3FB950; }
.gal-tag.nec    { border-color: #D2993244; color: #D29932; }

/* Placeholder de error de imagen */
.gal-img-error {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1C2128;
  font-size: 32px;
  color: #30363D;
}

/* Loading / empty */
.gal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px;
  color: #6E7681;
  font-size: 13px;
}

.gal-spinner {
  width: 32px; height: 32px;
  border: 3px solid #21262D;
  border-top-color: #388BFD;
  border-radius: 50%;
  animation: gal-spin 0.7s linear infinite;
}

@keyframes gal-spin { to { transform: rotate(360deg); } }

.gal-empty {
  text-align: center;
  padding: 48px;
  color: #6E7681;
  font-size: 13px;
}

/* Lightbox */
.gal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gal-lb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  cursor: pointer;
}

.gal-lb-content {
  position: relative;
  z-index: 1;
  background: #161B22;
  border: 1px solid #30363D;
  border-radius: 12px;
  overflow: hidden;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.gal-lb-btn-close {
  position: absolute;
  top: 10px; right: 12px;
  background: rgba(0,0,0,0.6);
  border: 1px solid #30363D;
  color: #C9D1D9;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gal-lb-btn-close:hover { background: #F85149; border-color: #F85149; color: #fff; }

#gal-lb-img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  background: #0D1117;
  display: block;
}

.gal-lb-info {
  padding: 14px 18px 16px;
  background: #161B22;
}

.gal-lb-title {
  font-size: 14px;
  font-weight: 700;
  color: #E6EDF3;
  margin-bottom: 6px;
}

.gal-lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.gal-lb-source {
  font-size: 11px;
  color: #388BFD;
  text-decoration: none;
}
.gal-lb-source:hover { text-decoration: underline; }


/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO GUÍA CFE — Acometida Residencial Paso a Paso
   ═══════════════════════════════════════════════════════════════════════════ */

#guiacfe-view {
  display: none;
  grid-template-columns: 300px 1fr 290px;
  grid-template-rows: 1fr;
  overflow: hidden;
  background: var(--bg-dark);
  /* Span the full second row of #app's grid */
  grid-column: 1 / -1;
  grid-row: 2;
}
#guiacfe-view.active { display: grid; }

/* ── Panel Izquierdo ──────────────────────────────────────────────────────── */
#cfe-panel-izq {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-panel);
}

.cfe-modulo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  background: linear-gradient(135deg, #0D2137 0%, #162447 100%);
  border-bottom: 1px solid #1E3A5F;
}
.cfe-modulo-logo {
  font-size: 28px;
  filter: drop-shadow(0 0 8px #FDD835);
}
.cfe-modulo-titulo {
  font-size: 14px;
  font-weight: 700;
  color: #FDD835;
  letter-spacing: 0.5px;
}
.cfe-modulo-subtitulo {
  font-size: 10px;
  color: #8B949E;
  margin-top: 1px;
}

/* Tabs internos */
.cfe-inner-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-dark);
  flex-shrink: 0;
}
.cfe-itab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.cfe-itab:hover { color: var(--text-primary); }
.cfe-itab.activo {
  color: #FDD835;
  border-bottom-color: #FDD835;
}

/* Contenido de tabs internos */
.cfe-itab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.cfe-itab-content.activo { display: block; }
#cfe-tab-materiales.activo {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 12px;
}
#cfe-materiales-lista {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.cfe-itab-content::-webkit-scrollbar { width: 4px; }
.cfe-itab-content::-webkit-scrollbar-thumb { background: #30363D; border-radius: 2px; }

/* Tab Definición */
.cfe-definicion-bloque {
  margin-bottom: 14px;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border-left: 3px solid #2188FF;
}
.cfe-definicion-bloque h4 {
  font-size: 11px;
  color: #58A6FF;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cfe-definicion-bloque p,
.cfe-definicion-bloque li {
  font-size: 11px;
  color: #C9D1D9;
  line-height: 1.5;
}
.cfe-definicion-bloque ul { padding-left: 16px; }
.cfe-definicion-bloque li { margin-bottom: 4px; }

.cfe-tipo-card {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin: 6px 0;
  background: #0D1117;
  border-radius: 4px;
  border: 1px solid #30363D;
  font-size: 11px;
  color: #C9D1D9;
  line-height: 1.4;
}
.cfe-tipo-icono { font-size: 18px; flex-shrink: 0; }

.cfe-marco-cfe {
  border-left-color: #FDD835 !important;
  background: #1A1400 !important;
  font-size: 11px;
  color: #C9D1D9;
  line-height: 1.5;
}

/* Tab Riesgos */
.cfe-riesgo-card {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: var(--radius);
  border-left: 4px solid;
}
.riesgo-critico {
  border-left-color: #F85149;
  background: #1A0A0A;
}
.riesgo-alto {
  border-left-color: #DB6D28;
  background: #1A0F06;
}
.riesgo-medio {
  border-left-color: #D29922;
  background: #1A1500;
}
.cfe-riesgo-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.cfe-riesgo-icono { font-size: 16px; }
.cfe-riesgo-titulo {
  font-size: 12px;
  font-weight: 700;
  color: #E6EDF3;
  flex: 1;
}
.cfe-nivel-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}
.cfe-nivel-badge.riesgo-critico { background: #F85149; color: #fff; }
.cfe-nivel-badge.riesgo-alto    { background: #DB6D28; color: #fff; }
.cfe-nivel-badge.riesgo-medio   { background: #D29922; color: #000; }
.cfe-riesgo-desc {
  font-size: 10.5px;
  color: #C9D1D9;
  line-height: 1.4;
  margin-bottom: 6px;
}
.cfe-riesgo-prev {
  font-size: 10px;
  color: #8B949E;
  line-height: 1.4;
}
.cfe-riesgo-prev strong { color: #3FB950; }

/* Tab Materiales */
.cfe-mat-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Botón ver diagrama */
.cfe-mat-ver-diagrama-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: #0d2010;
  border: 1px solid #1a4020;
  border-radius: 6px;
  color: #3FB950;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  margin-bottom: 8px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.cfe-mat-ver-diagrama-btn:hover {
  background: #122a18;
  border-color: #3FB950;
}

/* Sección de tarjetas de materiales */
.cfe-mat-cards-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  padding-right: 2px;
  flex: 1;
}

/* Encabezados de sección (cliente / CFE) */
.cfe-mat-seccion-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #58A6FF;
  border-bottom: 1px solid #30363D;
  padding: 3px 0 4px;
  margin-top: 2px;
  flex-shrink: 0;
}
.cfe-mat-seccion-label--cfe { color: #FF7043; margin-top: 6px; }
.cfe-mat-seccion-icon { font-size: 12px; }

/* ── Tarjeta de cada material ──────────────────────────────────────────── */
.cfe-mat-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #161B22;
  border: 1px solid #30363D;
  border-radius: 7px;
  padding: 6px 8px;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.cfe-mat-card:hover {
  background: #1C2128;
  border-color: #58A6FF;
}
.cfe-mat-card--cfe {
  border-color: #4a2a1a;
  background: #1a1210;
}
.cfe-mat-card--cfe:hover { border-color: #FF7043; }

/* Foto + número */
.cfe-mat-card-foto-wrap {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.cfe-mat-foto {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 5px;
  background: #0D1117;
  border: 1px solid #21262D;
  display: block;
  transition: border-color 0.15s, transform 0.15s;
}
.cfe-mat-foto:hover {
  border-color: #58A6FF;
  transform: scale(1.05);
}
.cfe-mat-foto-placeholder {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #0D1117;
  border: 1px solid #21262D;
  border-radius: 5px;
}
.cfe-mat-num-badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background: #1F6FEB;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid #0D1117;
  pointer-events: none;
}
.cfe-mat-card--cfe .cfe-mat-num-badge { background: #FF7043; }
.cfe-mat-zoom-hint {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  background: rgba(0,0,0,0.65);
  border-radius: 3px;
  padding: 1px 3px;
  color: #ccc;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.cfe-mat-card-foto-wrap:hover .cfe-mat-zoom-hint { opacity: 1; }

/* Información textual */
.cfe-mat-card-info { flex: 1; min-width: 0; }
.cfe-mat-card-nombre {
  font-size: 10.5px;
  color: #E6EDF3;
  line-height: 1.35;
  margin-bottom: 3px;
}
.cfe-mat-card-desc {
  font-size: 9px;
  color: #8B949E;
  line-height: 1.4;
  margin-bottom: 4px;
}
.cfe-mat-card-specs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
.cfe-mat-calibre {
  color: #FDD835;
  font-family: var(--font-mono);
  font-size: 9px;
  background: #1c1900;
  border: 1px solid #3a3000;
  border-radius: 3px;
  padding: 1px 4px;
}
.cfe-mat-norma {
  color: #3FB950;
  font-size: 9px;
  background: #0d2010;
  border: 1px solid #1a4020;
  border-radius: 3px;
  padding: 1px 4px;
}

/* ── Lightbox global para fotos y diagrama ─────────────────────────────── */
#cfe-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  cursor: zoom-out;
}
#cfe-lightbox.visible { display: flex; }
#cfe-lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  border: 2px solid #30363D;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  object-fit: contain;
  cursor: default;
}
#cfe-lightbox-caption {
  color: #C9D1D9;
  font-size: 12px;
  max-width: 80vw;
  text-align: center;
}
#cfe-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
}
#cfe-lightbox-close:hover { opacity: 1; }


/* ── Panel Central ────────────────────────────────────────────────────────── */
#cfe-panel-centro {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 12px 8px;
  gap: 8px;
}

.cfe-progreso-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cfe-progreso-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.cfe-progreso-track {
  flex: 1;
  height: 6px;
  background: #21262D;
  border-radius: 3px;
  overflow: hidden;
}
.cfe-progreso-fill {
  height: 100%;
  background: linear-gradient(90deg, #2188FF 0%, #76FF03 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.cfe-progreso-num {
  font-size: 10px;
  color: #76FF03;
  font-family: var(--font-mono);
  min-width: 30px;
  text-align: right;
}

.cfe-diagrama-wrap {
  flex: 1;
  background: #0D1117;
  border: 1px solid #30363D;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: stretch;
}
.cfe-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cfe-nav-controles {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-shrink: 0;
}
.cfe-nav-btn {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.cfe-nav-btn:active { transform: scale(0.97); }
.cfe-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cfe-nav-btn.primary  { background: #2188FF; color: #fff; }
.cfe-nav-btn.primary:hover:not(:disabled) { background: #388BFD; }
.cfe-nav-btn.secondary { background: #21262D; color: #E6EDF3; border: 1px solid #30363D; }
.cfe-nav-btn.secondary:hover:not(:disabled) { background: #30363D; }
.cfe-nav-btn.autoplay { background: #1A3A1A; color: #3FB950; border: 1px solid #3FB950; }
.cfe-nav-btn.autoplay.activo { background: #3FB950; color: #0D1117; }
.cfe-nav-btn.autoplay:hover { background: #3FB950; color: #0D1117; }

/* Barra de pasos numerados */
.cfe-pasos-nav {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.cfe-paso-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  background: #21262D;
  border: 1px solid #30363D;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  min-width: 52px;
}
.cfe-paso-nav-btn:hover { background: #30363D; border-color: #484F58; }
.cfe-paso-nav-btn.activo {
  background: #162447;
  border-color: #2188FF;
  box-shadow: 0 0 8px rgba(33,136,255,0.3);
}
.cfe-paso-nav-btn.completado { background: #0D2F1A; border-color: #3FB950; }
.paso-num {
  font-size: 14px;
  font-weight: 700;
  color: #C9D1D9;
}
.cfe-paso-nav-btn.activo .paso-num    { color: #58A6FF; }
.cfe-paso-nav-btn.completado .paso-num { color: #3FB950; }
.paso-cat {
  font-size: 8px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── Panel Derecho ────────────────────────────────────────────────────────── */
#cfe-panel-der {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-panel);
}

.cfe-paso-detalle-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.cfe-paso-detalle-scroll::-webkit-scrollbar { width: 4px; }
.cfe-paso-detalle-scroll::-webkit-scrollbar-thumb { background: #30363D; }

.cfe-paso-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 30px 16px;
  line-height: 1.6;
}

.cfe-paso-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 10px;
  background: #162447;
  border-radius: var(--radius);
  border: 1px solid #1E3A5F;
}
.cfe-paso-icono { font-size: 28px; flex-shrink: 0; }
.cfe-paso-num-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cfe-paso-titulo {
  font-size: 13px;
  font-weight: 700;
  color: #58A6FF;
  margin: 2px 0;
  line-height: 1.3;
}
.cfe-paso-categoria {
  font-size: 10px;
  color: #FDD835;
  background: #1A1400;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
}

.cfe-paso-desc {
  font-size: 11.5px;
  color: #C9D1D9;
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 4px;
}

.cfe-paso-detalles {
  padding-left: 16px;
  margin-bottom: 10px;
}
.cfe-paso-detalles li {
  font-size: 11px;
  color: #C9D1D9;
  margin-bottom: 5px;
  line-height: 1.4;
}

.cfe-advertencia {
  padding: 8px 10px;
  background: #1A0F06;
  border: 1px solid #DB6D28;
  border-radius: var(--radius);
  font-size: 11px;
  color: #FFA726;
  margin-bottom: 8px;
  line-height: 1.4;
}

.cfe-paso-norma {
  font-size: 10px;
  color: var(--text-muted);
  padding: 5px 8px;
  background: #0D1117;
  border-radius: 3px;
  border-left: 2px solid #3FB950;
}
.cfe-paso-norma strong { color: #3FB950; }

/* Aviso de seguridad fijo */
.cfe-aviso-seguridad {
  flex-shrink: 0;
  padding: 10px 12px;
  background: #1A0A0A;
  border-top: 2px solid #F85149;
}
.cfe-aviso-titulo {
  font-size: 11px;
  font-weight: 700;
  color: #F85149;
  margin-bottom: 4px;
}
.cfe-aviso-texto {
  font-size: 10px;
  color: #C9D1D9;
  line-height: 1.5;
}
.cfe-aviso-texto strong { color: #FFA726; }

/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO ALAMBRADO POR COLORES — Monofásico / Bifásico / Trifásico
   ══════════════════════════════════════════════════════════════════════════= */

/* ── Layout principal (3 columnas) ─────────────────────────────────────── */
#alambrado-view {
  display: none;
  grid-template-columns: 280px 1fr 290px;
  grid-template-rows: 1fr;
  gap: 0;
  height: calc(100vh - 46px);
  background: #010409;
  overflow: hidden;
}
#alambrado-view.active { display: grid; }

/* ── Panel Izquierdo ─────────────────────────────────────────────────────── */
#alm-panel-izq {
  background: #0D1117;
  border-right: 1px solid #21262D;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.alm-tipo-wrap {
  padding: 10px 12px 6px;
  border-bottom: 1px solid #1a1f28;
}
.alm-tipo-label {
  display: block;
  font-size: 10px;
  color: #8B949E;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

/* ── Leyenda ─────────────────────────────────────────────────────────────── */
#alm-leyenda {
  padding: 10px 12px;
  border-bottom: 1px solid #1a1f28;
}
.alm-leyenda-header { margin-bottom: 8px; }
.alm-leyenda-nombre {
  font-size: 13px;
  font-weight: 700;
  color: #58A6FF;
  margin-bottom: 2px;
}
.alm-leyenda-sub {
  font-size: 10px;
  color: #8B949E;
  margin-bottom: 6px;
}
.alm-voltajes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.alm-voltaje-chip {
  background: #0d2040;
  border: 1px solid #1F6FEB40;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 9px;
  color: #79C0FF;
  font-family: monospace;
}
.alm-conductores-lista {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.alm-conductor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #161B22;
  border: 1px solid #21262D;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.alm-conductor-row--ok {
  background: #0d2b0d;
  border-color: #2d6a2d;
}
.alm-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  font-family: monospace;
  border: 2px solid;
  flex-shrink: 0;
  user-select: none;
}
.alm-conductor-info {
  flex: 1;
  min-width: 0;
}
.alm-conductor-nombre {
  font-size: 11px;
  font-weight: 600;
  color: #C9D1D9;
  line-height: 1.3;
}
.alm-conductor-color-tag {
  font-size: 10px;
  margin-top: 1px;
}
.alm-check-badge {
  font-size: 14px;
  color: #56D364;
  font-weight: 800;
}

/* ── Lista de pasos (panel izq) ────────────────────────────────────────── */
#alm-pasos-lista {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.alm-pasos-titulo {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8B949E;
  margin-bottom: 4px;
}
.alm-paso-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.alm-paso-item:hover { background: #161B22; border-color: #30363D; }
.alm-paso-item.activo  { background: #0d2040; border-color: #1F6FEB; }
.alm-paso-item.completado { opacity: 0.7; }
.alm-paso-num-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: #1a1f28;
  color: #8B949E;
  flex-shrink: 0;
  border: 1px solid #30363D;
}
.alm-paso-num-badge.activo { background: #1F6FEB; color: #fff; border-color: #1F6FEB; }
.alm-paso-num-badge.done   { background: #238636; color: #fff; border-color: #238636; }
.alm-paso-item-label {
  font-size: 10px;
  color: #8B949E;
  line-height: 1.3;
}
.alm-paso-item.activo .alm-paso-item-label { color: #79C0FF; font-weight: 600; }
.alm-paso-item.completado .alm-paso-item-label { color: #56D364; }

/* ── Panel Central ───────────────────────────────────────────────────────── */
#alm-panel-centro {
  display: flex;
  flex-direction: column;
  background: #010409;
  overflow: hidden;
}
.alm-centro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #21262D;
  font-size: 12px;
  font-weight: 600;
  color: #8B949E;
}
.btn-alm-reset {
  background: #161B22;
  border: 1px solid #30363D;
  color: #8B949E;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-alm-reset:hover { border-color: #58A6FF; color: #58A6FF; }
#alm-svg-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  padding: 8px;
  min-height: 0;
}
#alm-svg {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: block;
}
.alm-progreso-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 8px;
  border-top: 1px solid #21262D;
}
.alm-progreso-label { font-size: 10px; color: #8B949E; white-space: nowrap; }
.alm-progreso-track {
  flex: 1;
  height: 8px;
  background: #161B22;
  border-radius: 10px;
  border: 1px solid #30363D;
  overflow: hidden;
}
.alm-progreso-bar {
  height: 100%;
  background: linear-gradient(90deg, #1F6FEB, #56D364);
  border-radius: 10px;
  transition: width 0.5s ease;
}
.alm-progreso-texto { font-size: 10px; color: #8B949E; font-family: monospace; }

/* ── Panel Derecho ───────────────────────────────────────────────────────── */
#alm-panel-der {
  background: #0D1117;
  border-left: 1px solid #21262D;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.alm-paso-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}
.alm-controles {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #21262D;
  border-bottom: 1px solid #21262D;
}
.btn-alm {
  flex: 1;
  padding: 7px 6px;
  border-radius: 6px;
  border: 1px solid #30363D;
  background: #161B22;
  color: #8B949E;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-alm:disabled { opacity: 0.4; cursor: default; }
.btn-alm:not(:disabled):hover { background: #21262D; color: #C9D1D9; border-color: #58A6FF; }
.btn-alm-conectar {
  flex: 1.5;
  background: #0d2a0d;
  border-color: #238636;
  color: #56D364;
}
.btn-alm-conectar:not(:disabled):hover { background: #1a3d1a; border-color: #2ea043; }
.btn-alm-conectar:disabled { background: #0a1f0a; opacity: 0.5; }

/* ── Detalle del paso ────────────────────────────────────────────────────── */
.alm-detalle-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alm-tipo-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 4px;
}
.alm-tipo-badge.tipo-seg { background: #2a1500; color: #FF6F00; }
.alm-tipo-badge.tipo-con { background: #0d2040; color: #58A6FF; }
.alm-tipo-badge.tipo-ver { background: #0d2b0d; color: #56D364; }
.alm-paso-counter { font-size: 9px; opacity: 0.7; }

.alm-detalle-titulo {
  font-size: 12px;
  font-weight: 700;
  color: #E6EDF3;
  line-height: 1.4;
}
.alm-cond-preview {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #161B22;
  border: 1px solid #30363D;
  border-radius: 7px;
  padding: 8px;
}
.alm-cond-swatch-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  font-family: monospace;
  border: 3px solid;
  flex-shrink: 0;
}
.alm-cond-preview-info { flex: 1; min-width: 0; }
.alm-cond-preview-nombre { font-size: 11px; font-weight: 700; color: #C9D1D9; margin-bottom: 2px; }
.alm-cond-preview-color  { font-size: 11px; margin-bottom: 3px; }
.alm-cond-preview-nota   { font-size: 10px; color: #8B949E; line-height: 1.4; }

.alm-detalle-desc {
  font-size: 11px;
  color: #C9D1D9;
  line-height: 1.6;
  background: #0D1117;
  border: 1px solid #21262D;
  border-radius: 6px;
  padding: 8px;
}
.alm-detalle-adv {
  font-size: 10.5px;
  color: #FDD835;
  background: #1a1500;
  border: 1px solid #3a3000;
  border-radius: 5px;
  padding: 6px 8px;
  line-height: 1.5;
}
.alm-detalle-norma {
  font-size: 9.5px;
  color: #8B949E;
  font-family: monospace;
  padding: 4px 8px;
  background: #0D1117;
  border-radius: 4px;
  border-left: 2px solid #1F6FEB;
}

/* ── Normas (parte inferior panel der) ─────────────────────────────────── */
.alm-normas-ref {
  padding: 8px 12px 10px;
  border-top: 1px solid #21262D;
}
.alm-normas-titulo {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8B949E;
  margin-bottom: 5px;
}
.alm-norma-item {
  font-size: 9.5px;
  color: #8B949E;
  line-height: 1.4;
  margin-bottom: 2px;
}
.alm-norma-item strong { color: #C9D1D9; }

/* ── SVG Animations ─────────────────────────────────────────────────────── */
@keyframes almWireIn {
  from { stroke-dashoffset: 700; opacity: 0; }
  to   { stroke-dashoffset: 0;   opacity: 1; }
}
.alm-wire-anim {
  stroke-dasharray: 700;
  animation: almWireIn 0.6s ease-out forwards;
}
@keyframes almPreviewDash {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -28; }
}
.alm-wire-preview {
  animation: almPreviewDash 1s linear infinite;
}
@keyframes almTermPulse {
  0%, 100% { r: 11; opacity: 1; }
  50%       { r: 14; opacity: 0.7; }
}
.alm-term-pulse {
  animation: almTermPulse 1.2s ease-in-out infinite;
  cursor: pointer;
}


/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO MURETE DE MEDICIÓN — Alambrado sobre foto real
   ═══════════════════════════════════════════════════════════════════════════ */

#murete-view {
  grid-column: 1 / -1;
  grid-template-columns: 260px 1fr 280px;
  grid-template-rows: 1fr;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
}

#murete-view.active {
  display: grid;
}

/* ── Panel izquierdo: selector + pasos ─────────────────────────────────── */
#mur-panel-izq {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.mur-panel-head {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.mur-modo-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.mur-modo-wrap label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

#mur-modo-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
}

#mur-pasos-lista {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mur-paso-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.mur-paso-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.mur-paso-btn.activo {
  background: rgba(33,136,255,0.12);
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
}

.mur-paso-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ── Panel central: foto + SVG overlay ─────────────────────────────────── */
#mur-panel-centro {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #0a0a0a;
}

.mur-centro-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.mur-centro-toolbar span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.mur-zoom-btn {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.mur-zoom-btn:hover { background: var(--bg-hover); }

#mur-zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 42px;
  text-align: center;
}

.mur-mode-badge {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.mur-mode-badge.bifasico { background: rgba(204,0,0,0.2); color: #ff6666; border: 1px solid #cc0000; }
.mur-mode-badge.monofasico { background: rgba(33,136,255,0.15); color: #88bbff; border: 1px solid #2188ff; }

/* Contenedor exterior (limita el overflow) */
#mur-photo-wrap-outer {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mur-photo-wrap-outer:active { cursor: grabbing; }

/* Contenedor interior (se transforma con zoom/pan) */
#mur-photo-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform-origin: center center;
  will-change: transform;
}

#mur-photo {
  display: block;
  max-width: none;
  height: 480px;
  pointer-events: none;
  user-select: none;
  border-radius: 4px;
}

#mur-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#mur-cables-layer {
  pointer-events: all;
}

/* ── Panel derecho: info del conductor ──────────────────────────────────── */
#mur-panel-der {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

#mur-info-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.mur-info-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.mur-info-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
.mur-info-body p { margin-bottom: 10px; }
.mur-info-body strong { color: var(--text-primary); }

.mur-info-norma {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 10px;
}
.mur-info-norma strong {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-primary);
}
.mur-info-norma ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mur-info-norma li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.mur-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Aviso NOM-001 al fondo */
.mur-aviso-nom {
  margin: 0 14px 14px;
  background: rgba(210,153,34,0.1);
  border: 1px solid rgba(210,153,34,0.4);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 10.5px;
  color: #e6c36e;
  line-height: 1.45;
}
.mur-aviso-nom strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
}

/* ─── Hint de interacción ───────────────────────────────────────────────── */
.mur-hint {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 12px 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}


/* ═══════════════════════════════════════════════════════════════════════════
   MÓDULO ILUMINACIÓN Y CONTACTOS — Diagrama vectorial por capas de color
   ═══════════════════════════════════════════════════════════════════════════ */

#centrocarga-view {
  grid-column: 1 / -1;
  grid-template-columns: 260px 1fr 280px;
  grid-template-rows: 1fr;
  gap: 0;
  height: calc(100vh - 46px);
  background: var(--bg-dark);
}
#centrocarga-view.active { display: grid; }

/* ── Panel izquierdo: capas + circuitos + componentes ──────────────────── */
#cc-panel-izq {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.cc-panel-head {
  padding: 10px 14px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.cc-panel-sub {
  padding: 0 14px 10px;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.45;
  border-bottom: 1px solid var(--border);
}

.cc-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.cc-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* Capas de cableado (checkboxes) */
.cc-capa-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.cc-capa-item:hover { background: var(--bg-hover); }
.cc-capa-item.activa { border-color: var(--accent); }
.cc-capa-item input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.cc-capa-swatch {
  width: 22px; height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cc-capa-info { flex: 1; min-width: 0; }
.cc-capa-nombre { font-size: 11.5px; font-weight: 600; color: var(--text-primary); }
.cc-capa-sub    { font-size: 9.5px; color: var(--text-muted); }

.cc-btn-toggle-all {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10.5px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cc-btn-toggle-all:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Aislar circuito */
#cc-circuitos-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.cc-circ-btn {
  flex: 1 0 calc(50% - 5px);
  padding: 7px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.cc-circ-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.cc-circ-btn.activo {
  background: rgba(33,136,255,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Leyenda de componentes */
#cc-componentes-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cc-comp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.cc-comp-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.cc-comp-swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}

/* ── Panel central: diagrama SVG ───────────────────────────────────────── */
#cc-panel-centro {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #06090d;
}

.cc-centro-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.cc-centro-toolbar span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}
.cc-zoom-btn {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.cc-zoom-btn:hover { background: var(--bg-hover); }
.cc-zoom-btn:first-of-type { margin-left: auto; }
#cc-zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 42px;
  text-align: center;
}

#cc-svg-wrap-outer {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cc-svg-wrap-outer:active { cursor: grabbing; }

#cc-svg-wrap {
  position: relative;
  transform-origin: center center;
  will-change: transform;
}

#cc-svg {
  display: block;
  width: 1100px;
  max-width: none;
  height: auto;
  background: #0d1117;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--border);
}

/* Elementos del diagrama */
.cc-wire { fill: none; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; }
.cc-wire:hover { filter: brightness(1.4); }
.cc-bus-label { font-family: var(--font-ui); font-weight: 700; }
.cc-comp-label { font-family: var(--font-ui); font-weight: 700; text-anchor: middle; }
.cc-comp-sub-label { font-family: var(--font-ui); text-anchor: middle; }
.cc-symbol { cursor: pointer; }
.cc-symbol:hover .cc-symbol-box { filter: brightness(1.3); }

.cc-dim { opacity: 0.12 !important; }

.cc-hint {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 12px 6px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* ── Panel derecho: detalle + foto referencia ───────────────────────────── */
#cc-panel-der {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

#cc-info-panel {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.cc-info-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.cc-info-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.cc-info-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
.cc-info-body p { margin-bottom: 8px; }
.cc-info-body strong { color: var(--text-primary); }

.cc-ref-foto {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cc-ref-foto-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.cc-ref-foto img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}
.cc-ref-foto-nota {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-top: 6px;
}

.cc-aviso-nom {
  margin: 12px 14px;
  background: rgba(210,153,34,0.1);
  border: 1px solid rgba(210,153,34,0.4);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 10.5px;
  color: #e6c36e;
  line-height: 1.45;
}
.cc-aviso-nom strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
}

/* ════════════════════════════════════════════════════════════════════════
   Circuito Básico (Iluminación y Contacto) — foto + overlay SVG
   ════════════════════════════════════════════════════════════════════════ */
#circuitobasico-view {
  grid-column: 1 / -1;
  grid-template-columns: 260px 1fr 280px;
  grid-template-rows: 1fr;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
}

#circuitobasico-view.active {
  display: grid;
}

#cb-panel-izq {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

#cb-panel-centro {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #0a0a0a;
}

#cb-photo-wrap-outer {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cb-photo-wrap-outer:active { cursor: grabbing; }

#cb-photo-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform-origin: center center;
  will-change: transform;
}

#cb-photo {
  display: block;
  max-width: none;
  height: 480px;
  pointer-events: none;
  user-select: none;
  border-radius: 4px;
}

#cb-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#cb-cables-layer {
  pointer-events: all;
}

#cb-panel-der {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

#cb-info-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
