/**
 * APOLO FV — SISTEMA DE DISEÑO INDUSTRIAL ERGONÓMICO (BLANCO CLARO & SOLAR AMBER)
 * Diseñado para máxima claridad visual en campo, bajo luz solar directa o interiores técnicos.
 *
 * 1. TONO NEUTRO (Fondo y Superficie): Blanco Claro Puro (#f8fafc / #ffffff / #f1f5f9) + Texto (#0f172a / #1e293b)
 * 2. TONO PRIMARIO (Energía Solar y Acción): Oro Fotovoltaico / Solar Amber (#d97706 / #f59e0b)
 * 3. ACENTO DE DATOS Y RED: Cyber Teal / Cyan (#0891b2 / #0e7490)
 * 4. TONO DE ESTADO: Esmeralda (#047857) / Ámbar Advertencia (#b45309) / Coral Alerta (#be123c)
 */

:root {
  /* TONO 1: ESCALA DE BLANCOS Y NEUTROS ERGONÓMICOS (DESCANSO RETINIANO) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-white: #0f172a;
  --text-primary: #334155;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  /* TONO 2: PRIMARIO SOLAR CONTROLADO (UN SOLO ACENTO ELEGANTE) */
  --primary-glow: rgba(217, 119, 6, 0.10);
  --primary-subtle: rgba(217, 119, 6, 0.08);
  --primary-border: rgba(217, 119, 6, 0.20);
  --primary-base: #d97706;
  --primary-light: #b45309;
  --primary-hover: #92400e;

  /* ACENTO TÉCNICO DE TELEMETRÍA (SUAVE Y CONTENIDO) */
  --tech-cyan: #0284c7;
  --tech-cyan-light: #0369a1;
  --tech-cyan-subtle: rgba(2, 132, 199, 0.08);
  --tech-cyan-border: rgba(2, 132, 199, 0.20);

  /* TONO 3: ESTADOS SEMÁNTICOS CONTROLADOS (FONDO PASTEL TRANQUILO) */
  --status-ok-bg: #f0fdf4;
  --status-ok-border: #bbf7d0;
  --status-ok-text: #166534;

  --status-warn-bg: #fefce8;
  --status-warn-border: #fef08a;
  --status-warn-text: #854d0e;

  --status-err-bg: #fef2f2;
  --status-err-border: #fecaca;
  --status-err-text: #991b1b;

  /* TIPOGRAFÍA */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* GEOMETRÍA */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* RESET */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* CONTENEDOR PRINCIPAL ERGONÓMICO */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 900px) {
  .app-layout {
    padding-bottom: 30px;
  }
}

/* HEADER MINIMALISTA INDUSTRIAL ERGONÓMICO */
.app-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 10px;
  user-select: none;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-icon {
  background: #f8fafc;
  color: var(--primary-base);
  border: 1px solid var(--border-subtle);
  font-size: 15px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.brand-text-block {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-white);
  white-space: nowrap;
  line-height: 1.2;
}

.accent-text {
  color: var(--primary-light);
  font-weight: 800;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* BADGE DE ESTADO REFINADO */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-optimal {
  background: var(--status-ok-bg);
  border: 1px solid var(--status-ok-border);
  color: var(--status-ok-text);
}

.status-warning {
  background: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
  color: var(--status-warn-text);
}

.status-fatal {
  background: var(--status-err-bg);
  border: 1px solid var(--status-err-border);
  color: var(--status-err-text);
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-text-full {
  display: inline;
}

.badge-text-compact {
  display: none;
}

/* BOTONES PROFESIONALES DE ACCIÓN RÁPIDA */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.95);
}

.btn-icon {
  font-weight: 700;
  font-size: 13px;
}

.btn-primary {
  background: #0f172a;
  color: #ffffff;
  font-weight: 600;
  border: 1px solid #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.btn-primary:hover {
  background: #1e293b;
  border-color: #1e293b;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12);
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

/* RESPONSIVE HEADER PARA PANTALLAS MÓVILES */
@media (max-width: 768px) {
  .app-header {
    padding: 8px 12px;
    gap: 6px;
  }

  .brand-container {
    gap: 7px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .brand-title {
    font-size: 14.5px;
  }

  .brand-subtitle {
    display: none; /* Eliminar texto largo innecesario en móvil */
  }

  .status-badge {
    padding: 4px 8px;
    font-size: 10px;
    gap: 4px;
  }

  .badge-text-full {
    display: none;
  }

  .badge-text-compact {
    display: inline;
    font-weight: 700;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .btn {
    padding: 6px 9px;
    font-size: 11px;
    gap: 4px;
  }
}

@media (max-width: 380px) {
  .header-actions .btn-label {
    display: none; /* En pantallas ultra estrechas, dejar solo icono */
  }

  .header-actions .btn {
    padding: 6px 8px;
  }
}

/* BARRA DE PRESETS SOBRIA Y ERGONÓMICA CON SCROLL FLUIDO */
.presets-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #eef3f8;
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
  /* Máscara de degradado hacia la derecha para indicar contenido deslizable */
  mask-image: linear-gradient(to right, black 0%, black calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 0%, black calc(100% - 24px), transparent 100%);
}

.presets-label-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.presets-icon {
  font-size: 12px;
  color: var(--primary-base);
}

.presets-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.presets-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-right: 20px;
}

.presets-scroll::-webkit-scrollbar {
  display: none;
}

.preset-chip {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: start;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.preset-chip:active {
  transform: scale(0.95);
}

.preset-chip:hover {
  color: var(--primary-light);
  border-color: var(--primary-base);
  background: #fffbeb;
}

.preset-chip.active {
  color: #ffffff;
  border-color: #0f172a;
  background: #0f172a;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* NAVEGACIÓN PRINCIPAL */
.desktop-nav {
  display: none;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
}

@media (min-width: 900px) {
  .desktop-nav {
    display: flex;
    gap: 4px;
  }
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-base);
  background: rgba(245, 158, 11, 0.09);
  font-weight: 600;
}

/* KPIS */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px 16px;
}

@media (min-width: 768px) {
  .kpis-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px 24px;
  }
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  min-width: 0;
}

.kpi-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.2;
}

/* CONTENIDO Y CARDS */
.main-content {
  padding: 0 14px 20px;
  flex: 1;
}

@media (min-width: 768px) {
  .main-content {
    padding: 0 24px 24px;
  }
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

@media (min-width: 768px) {
  .card {
    padding: 20px;
    margin-bottom: 20px;
  }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-white);
  line-height: 1.3;
  min-width: 0;
}

.card-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--primary-subtle);
  color: var(--primary-light);
  border: 1px solid var(--primary-border);
  white-space: nowrap;
  flex-shrink: 0;
}

/* FORMULARIOS Y CONTROLES */
.config-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 900px) {
  .config-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  letter-spacing: 0.15px;
}

.form-control {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  color: #0f172a;
  padding: 9.5px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-control:focus {
  border-color: var(--primary-base);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: #ffffff;
}

.form-control:disabled {
  background: #f1f5f9;
  opacity: 0.65;
  cursor: not-allowed;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mppt-block {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.mppt-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: 8px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary-base);
}

/* SOC BAR */
.soc-explainer {
  margin-top: 14px;
}

.soc-bar {
  display: flex;
  height: 14px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
}

.soc-seg-shutdown { background: var(--status-err-text); }
.soc-seg-backup { background: var(--primary-base); }
.soc-seg-active { background: var(--status-ok-text); }

.soc-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
}
.legend-dot.shutdown { background: var(--status-err-text); }
.legend-dot.backup { background: var(--primary-base); }
.legend-dot.active { background: var(--status-ok-text); }

/* TABLAS DE LA HOJA DEL INSTALADOR (CLARA, PRECISA, PROFESIONAL) */
.installer-banner {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary-light);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.installer-banner strong {
  color: var(--text-white);
  font-weight: 700;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.installer-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  overflow: hidden;
}

.installer-section-title {
  background: var(--bg-surface-elevated);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-white);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.installer-section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 12px;
  background: var(--primary-base);
  border-radius: 2px;
}

.table-responsive {
  overflow-x: auto;
}

.installer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.installer-table th {
  text-align: left;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-subtle);
}

.installer-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.installer-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.installer-table tbody tr:hover {
  background: rgba(245, 158, 11, 0.04);
}

.col-label {
  font-weight: 500;
  color: var(--text-white);
  font-size: 13px;
}

.col-label-pin {
  font-weight: 600;
  color: #0f172a;
  display: block;
}

.col-key code {
  font-family: var(--font-mono);
  color: var(--primary-light);
  font-size: 11px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  display: inline-block;
}

.col-val {
  color: var(--text-white);
  font-weight: 500;
}

.val-content {
  color: var(--text-white);
  font-weight: 500;
}

/* ESQUEMA VISUAL DEL CONECTOR (A PRUEBA DE FALLOS) */
.foolproof-pinout-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 12px 0 16px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.foolproof-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.foolproof-icon {
  font-size: 20px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.foolproof-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 0.2px;
}

.foolproof-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.com-connector-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  padding: 10px;
  border-radius: var(--radius-xs);
  margin-bottom: 14px;
}

.pin-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: var(--radius-xs);
  min-height: 48px;
  text-align: center;
}

.pin-cell .num {
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.pin-cell .tag {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
  letter-spacing: 0.2px;
}

.pin-cell.pin-active {
  background: var(--primary-subtle);
  border: 1.5px solid var(--primary-base);
  color: var(--text-white);
}

.pin-cell.pin-active .num {
  color: var(--primary-light);
}

.pin-cell.pin-active .tag {
  color: var(--text-white);
}

.pin-cell.pin-empty {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--text-muted);
  opacity: 0.7;
}

.foolproof-rules {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  background: #f8fafc;
  border-left: 3px solid var(--primary-base);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .foolproof-rules {
    grid-template-columns: repeat(3, 1fr);
  }
}

.rule-item strong {
  color: var(--text-white);
  display: block;
  margin-bottom: 2px;
}

/* =========================================================
   EXPLORADOR DE CONEXIÓN DE PINES (MOBILE-FIRST INDUSTRIAL)
   ========================================================= */

.pinout-card {
  padding: 16px;
}

@media (min-width: 768px) {
  .pinout-card {
    padding: 24px;
  }
}

.pinout-header-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pinout-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BARRA DE FILTROS TÁCTILES HORIZONTALES */
.pinout-filters-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.pinout-filters-container::-webkit-scrollbar {
  display: none;
}

.pinout-filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.4px;
}

.pinout-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.pinout-chip {
  background: var(--bg-app);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pinout-chip:hover {
  color: var(--text-white);
  border-color: var(--primary-border);
}

.pinout-chip.active {
  background: var(--primary-base);
  color: var(--text-white);
  border-color: var(--primary-light);
  box-shadow: 0 0 12px var(--primary-glow);
}

/* CONTENEDOR VISUAL DEL CONECTOR */
.connector-visual-box {
  background: #ffffff;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.connector-visual-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.connector-info-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 8px;
}

.connector-badge-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pin-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pin-badge-blue,
.pin-badge-cyan {
  background: var(--tech-cyan-subtle);
  border: 1px solid var(--tech-cyan-border);
  color: var(--tech-cyan-light);
}

.pin-badge-green {
  background: var(--status-ok-bg);
  border: 1px solid var(--status-ok-border);
  color: var(--status-ok-text);
}

.pin-badge-purple {
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #7e22ce;
}

.pin-badge-amber {
  background: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
  color: var(--status-warn-text);
}

.pin-badge-danger {
  background: var(--status-err-bg);
  border: 1px solid var(--status-err-border);
  color: var(--status-err-text);
}

/* LEYENDA DEL CONECTOR */
.connector-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* GRID RESPONSIVE DE PINES PARA 16 Y 24 PINES */
.responsive-pin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (min-width: 600px) {
  .responsive-pin-grid.grid-16 {
    grid-template-columns: repeat(8, 1fr);
  }
  .responsive-pin-grid.grid-24 {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (min-width: 1024px) {
  .responsive-pin-grid.grid-24 {
    grid-template-columns: repeat(12, 1fr);
  }
}

.touch-pin-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  position: relative;
}

.touch-pin-cell:hover, .touch-pin-cell:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.touch-pin-cell .p-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.touch-pin-cell .p-name {
  font-size: 9.5px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.touch-pin-cell .p-target {
  font-size: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ESTADOS SEMÁNTICOS DE PIN */
.touch-pin-cell.state-meter {
  background: #ecfeff;
  border-color: #0891b2;
  color: #0e7490;
}

.touch-pin-cell.state-battery {
  background: #ecfdf5;
  border-color: #059669;
  color: #047857;
}

.touch-pin-cell.state-parallel {
  background: #faf5ff;
  border-color: #9333ea;
  color: #7e22ce;
}

.touch-pin-cell.state-backup {
  background: #fffbeb;
  border-color: #d97706;
  color: #b45309;
}

.touch-pin-cell.state-forbidden {
  background: #fff1f2;
  border-color: #e11d48;
  color: #be123c;
  opacity: 0.85;
}

.touch-pin-cell.state-empty {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #64748b;
  opacity: 0.85;
}

.touch-pin-cell.selected-pin {
  outline: 2px solid var(--primary-base);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: scale(1.06);
  z-index: 5;
}

/* CONECTOR VISUAL RJ45 CON CÓDIGO DE COLORES T568B */
.rj45-visual-wrapper {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 16px;
}

.rj45-top-tab {
  width: 44px;
  height: 10px;
  background: #cbd5e1;
  margin: 0 auto 6px auto;
  border-radius: 3px 3px 0 0;
}

.rj45-plug-body {
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-xs);
  background: #ffffff;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.rj45-pin-lane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border-radius: 3px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
  min-height: 72px;
}

.rj45-wire-stripe {
  width: 12px;
  height: 24px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.rj45-pin-lane .p-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-white);
}

.rj45-pin-lane .p-signal {
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.1;
}

.rj45-pin-lane.active-lane {
  background: var(--primary-subtle);
  border: 1.5px solid var(--primary-base);
  transform: translateY(-2px);
}

.rj45-pin-lane.active-lane .p-signal {
  color: var(--primary-light);
  font-weight: 800;
}

/* COLORES ESTÁNDAR T568B */
.color-stripe-wo { background: repeating-linear-gradient(45deg, #ffffff, #ffffff 4px, #ea580c 4px, #ea580c 8px); }
.color-stripe-o  { background: #ea580c; }
.color-stripe-wg { background: repeating-linear-gradient(45deg, #ffffff, #ffffff 4px, #16a34a 4px, #16a34a 8px); }
.color-stripe-bl { background: #2563eb; }
.color-stripe-wbl{ background: repeating-linear-gradient(45deg, #ffffff, #ffffff 4px, #2563eb 4px, #2563eb 8px); }
.color-stripe-g  { background: #16a34a; }
.color-stripe-wbr{ background: repeating-linear-gradient(45deg, #ffffff, #ffffff 4px, #854d0e 4px, #854d0e 8px); }
.color-stripe-br { background: #854d0e; }

/* SECCIÓN DE DETALLE DEL PIN PULSADO */
.pin-detail-panel {
  background: var(--bg-surface-elevated);
  border-left: 3px solid var(--primary-base);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* LISTA DE CONEXIONES PUNTO A PUNTO (WIRE RUNS) */
.wire-runs-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-white);
  margin: 18px 0 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wire-runs-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wire-run-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease;
}

.wire-run-item:hover {
  border-color: var(--border-strong);
}

.wire-run-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.wire-run-category {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.wire-run-wiretag {
  font-family: var(--font-mono);
  font-size: 11px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  color: var(--primary-light);
}

.wire-run-endpoints {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (min-width: 650px) {
  .wire-run-endpoints {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.endpoint-box {
  background: #f4f7fa;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  flex: 1;
}

.endpoint-role {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 2px;
}

.endpoint-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-white);
}

.endpoint-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  font-weight: 800;
  font-size: 16px;
  padding: 0 4px;
}

.wire-run-notes {
  font-size: 11.5px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
  margin-top: 2px;
}

/* CAJA DE PINES PROHIBIDOS */
.forbidden-box {
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.28);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 20px;
}

.forbidden-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--status-err-text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.forbidden-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.forbidden-chips-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.forbidden-chip-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: #fff1f2;
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: var(--status-err-text);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}

/* CAJA DE RESISTENCIA TERMINAL */
.resistor-box {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.resistor-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.resistor-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--status-warn-text);
  margin-bottom: 2px;
}

.resistor-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* TOAST DE COPIADO */
.pinout-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #10b981;
  border: 1px solid #059669;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.pinout-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* VALIDACIONES LIST */
.validations-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.validation-empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-secondary);
}

.check-icon {
  width: 44px;
  height: 44px;
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
  border: 1px solid var(--status-ok-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin: 0 auto 12px;
}

.validation-item {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--bg-surface-elevated);
  border-left: 3px solid;
}

.severity-fatal {
  border-left-color: var(--status-err-text);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.severity-error {
  border-left-color: var(--status-err-text);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.severity-warning {
  border-left-color: var(--status-warn-text);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.severity-info {
  border-left-color: var(--primary-light);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.validation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.severity-tag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

.severity-fatal .severity-tag, .severity-error .severity-tag {
  background: var(--status-err-text);
  color: #ffffff;
}

.severity-warning .severity-tag {
  background: var(--status-warn-text);
  color: #ffffff;
}

.severity-info .severity-tag {
  background: var(--tech-cyan);
  color: #ffffff;
}

.issue-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.validation-msg {
  font-size: 13px;
  color: var(--text-white);
  margin-bottom: 4px;
}

.validation-remedy {
  font-size: 12px;
  color: var(--text-secondary);
}

/* DIAGRAMA */
.diagram-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.diagram-svg {
  width: 100%;
  max-width: 920px;
  height: auto;
  display: block;
}

/* CATÁLOGO */
.catalog-group {
  margin-bottom: 24px;
}

.catalog-group h3 {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-white);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.catalog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .catalog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.catalog-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.catalog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.catalog-brand {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
}

.catalog-badge {
  font-size: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
}

.catalog-model {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  margin-bottom: 8px;
}

.catalog-specs {
  list-style: none;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.catalog-specs strong {
  color: var(--text-primary);
}

/* ==========================================================================
   NAVEGACIÓN MÓVIL INFERIOR ERGONÓMICA (BOTTOM BAR PWA)
   Optimizada para zona del pulgar (Thumb Zone), con soporte nativo de área
   segura (iOS Home Bar / Android Gestures) y dianas táctiles ≥ 48px.
   ========================================================================== */
.mobile-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(203, 213, 225, 0.85);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06), 0 -1px 3px rgba(15, 23, 42, 0.03);
  z-index: 100;
  align-items: stretch;
  justify-content: space-around;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 900px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px 2px 4px 2px;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1), color 0.15s ease;
  min-height: 48px;
}

.mobile-nav-btn:active {
  transform: scale(0.92);
}

/* Envoltorio de icono con píldora ergonómica */
.nav-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 14px;
  margin-bottom: 2px;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-icon-svg {
  width: 20px;
  height: 20px;
  stroke: #64748b;
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.nav-text {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 1.2;
  transition: color 0.15s ease, font-weight 0.15s ease;
}

/* ESTADO ACTIVO ILUMINADO Y SOBRIO (CALMA VISUAL) */
.mobile-nav-btn.active {
  color: #0f172a;
}

.mobile-nav-btn.active .nav-icon-wrap {
  background: #f1f5f9;
  box-shadow: none;
}

.mobile-nav-btn.active .nav-icon-svg {
  stroke: #0f172a;
  transform: scale(1.06);
}

.mobile-nav-btn.active .nav-text {
  font-weight: 700;
  color: #0f172a;
}

/* INSIGNIA DINÁMICA DE AVISOS Y ERRORES (PULSE NOTIFICATION) */
.nav-badge-count {
  position: absolute;
  top: -3px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  border: 1.5px solid #ffffff;
}

.nav-tab .nav-badge-count {
  position: static;
  margin-left: 6px;
}

.nav-badge-count.badge-fatal {
  background: #ef4444;
  color: #ffffff;
  animation: nav-badge-pulse 2s infinite ease-in-out;
}

.nav-badge-count.badge-warning {
  background: #f59e0b;
  color: #ffffff;
}

.nav-badge-count.badge-ok {
  background: #10b981;
  color: #ffffff;
  font-size: 8.5px;
}

.nav-badge-count.hidden {
  display: none !important;
}

@keyframes nav-badge-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}
