/* ==========================================================================
   CSS PRINCIPAL - REBT CALC ELEE0109
   Aislamiento visual y diseño premium para simulación eléctrica.
   ========================================================================== */

:root {
  --bg-primary: #070a0e;
  --bg-secondary: #0f1622;
  --bg-sidebar: #0b1019;
  
  --card-bg: rgba(22, 33, 49, 0.4);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-blur: 16px;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --accent-blue: #38bdf8;
  --accent-blue-glow: rgba(56, 189, 248, 0.3);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.3);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.3);
  --accent-yellow: #f59e0b;
  --accent-yellow-glow: rgba(245, 158, 11, 0.3);
  
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-width: 280px;
  --transition-speed: 0.25s;
  
  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 18px;
}

/* Base resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* App container layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
}

.logo-icon {
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.02));
  color: var(--accent-blue);
  border-left: 3px solid var(--accent-blue);
  padding-left: 13px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--card-border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.app-version {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.7;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.app-main {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header / Project info */
.app-header {
  background-color: rgba(11, 16, 25, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.project-summary-bar {
  display: flex;
  gap: 24px;
  flex-grow: 1;
}

.header-info-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-info-field label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-info-field input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-speed);
}

.header-info-field input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 6px var(--accent-blue-glow);
}

.datetime-field span {
  font-size: 13px;
  padding: 7px 0;
  font-weight: 500;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* View switcher */
.view-content {
  padding: 24px;
  flex-grow: 1;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  margin-bottom: 8px;
}

.view-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.view-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.grid-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.card {
  background-color: var(--card-bg);
  backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-body {
  padding: 20px;
}

.border-top {
  border-top: 1px solid var(--card-border);
  padding-top: 20px;
  margin-top: 20px;
}

/* Grid helper utilities */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.col-span-2 {
  grid-column: span 2;
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="text"], select {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all var(--transition-speed) ease;
}

input[type="text"]:focus, select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.input-suffix {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.input-wrapper input {
  padding-right: 40px;
}

/* Checkbox design */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.checkbox-label span {
  font-size: 13px;
  color: var(--text-main);
}

.small-label {
  margin-top: 6px;
}

.small-label span {
  font-size: 11px;
  color: var(--text-muted);
}

.small-text-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-speed) ease;
}

.btn-primary {
  background-color: var(--accent-blue);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px var(--accent-blue-glow);
}

.btn-primary:hover {
  background-color: #7dd3fc;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.btn-secondary-label {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.btn-secondary-label:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.btn-accent {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-accent:hover {
  background-color: rgba(16, 185, 129, 0.25);
}

/* ==========================================================================
   RESULTS & VERIFICATION
   ========================================================================== */
.result-card {
  background: linear-gradient(135deg, rgba(22, 33, 49, 0.6) 0%, rgba(15, 23, 42, 0.6) 100%);
  border-color: rgba(56, 189, 248, 0.15);
}

.status-indicator-badge {
  display: block;
  text-align: center;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--border-radius-md);
  background-color: rgba(56, 189, 248, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.2);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-indicator-badge.elevada {
  background-color: rgba(245, 158, 11, 0.12);
  color: var(--accent-yellow);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-indicator-badge.success {
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator-badge.error {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.result-row span {
  color: var(--text-muted);
}

.result-row strong {
  color: var(--text-main);
  font-weight: 600;
}

.result-row .highlight-text {
  font-size: 18px;
  font-weight: 800;
}

.highlight-box {
  background-color: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
  border-radius: var(--border-radius-md);
  border-left: 4px solid var(--accent-blue);
  margin: 6px 0;
}

.highlight-box.border-top {
  margin-top: 14px;
  border-top: none;
}

.text-blue { color: var(--accent-blue) !important; }
.text-green { color: var(--accent-green) !important; }
.text-red { color: var(--accent-red) !important; }
.text-yellow { color: var(--accent-yellow) !important; }

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 60%;
}

.relevancy-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  margin-top: 8px;
  border-left: 2px solid var(--text-muted);
}

.verification-pill-container {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.verification-pill {
  flex-grow: 1;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
  border-radius: var(--border-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pill-ok {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pill-fail {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.validation-note-box {
  margin-top: 16px;
  padding: 14px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-md);
  border: 1px dashed var(--card-border);
}

.validation-note-box p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* Badge helpers */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-info {
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

/* ==========================================================================
   INTERACTIVE DIN RAIL & CIRCUIT BREAKERS (CGMP)
   ========================================================================== */
.board-card {
  grid-column: span 2;
}

.flex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.din-rail-wrapper {
  background-color: #1a1e27;
  padding: 24px;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
  margin-bottom: 16px;
  position: relative;
  overflow-x: auto;
}

.din-rail-header-lines {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding: 0 4px;
  letter-spacing: 0.5px;
  border-bottom: 1px dashed rgba(255,255,255,0.08);
  padding-bottom: 6px;
}

/* El envolvente físico del Cuadro General de Distribución */
.distribution-board {
  background-color: #0f172a;
  border: 6px solid #334155;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), inset 0 2px 8px rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 16px 0;
  background-image: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
}

/* Fila metálica que simula cada carril DIN */
.din-rail-row {
  background-color: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 8px;
}

.din-rail-row-label {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  padding-left: 4px;
  border-left: 3px solid var(--accent-blue);
}

.din-rail-elements {
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to bottom, #475569 0%, #334155 30%, #1e293b 50%, #334155 70%, #475569 100%);
  border: 1px solid #0f172a;
  border-radius: 4px;
  padding: 16px 12px 4px 12px;
  min-height: 165px;
  gap: 4px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
  position: relative;
  overflow-x: auto;
}

/* El Carril Metálico real dibujado detrás de los aparatos */
.din-rail-elements::before {
  content: "";
  position: absolute;
  top: 45%;
  left: 0;
  right: 0;
  height: 22px;
  background: linear-gradient(to bottom, #94a3b8 0%, #cbd5e1 30%, #64748b 70%, #475569 100%);
  border-top: 1px solid #cbd5e1;
  border-bottom: 1px solid #334155;
  opacity: 0.85;
  z-index: 1;
}

/* MAGNETOTÉRMICO / DIFERENCIAL (Breaker Module) */
.breaker {
  background: linear-gradient(to right, #cfd8dc 0%, #eceff1 30%, #f5f7f8 50%, #eceff1 75%, #cfd8dc 100%);
  border: 1px solid #78909c;
  border-bottom: 4px solid #455a64;
  border-radius: 4px;
  color: #263238;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  height: 140px;
  position: relative;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 6px 12px rgba(0,0,0,0.4);
  transition: all var(--transition-speed) cubic-bezier(0.165, 0.84, 0.44, 1);
  z-index: 2; /* Para quedar encima del carril metálico */
}

.breaker:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 20px rgba(0,0,0,0.6);
  border-color: var(--accent-blue);
  z-index: 10;
}

.breaker.selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow), 0 10px 20px rgba(0,0,0,0.6);
  transform: translateY(-4px);
  z-index: 10;
}

/* Anchos según la modulación estándar carril DIN (ej: 1 módulo = 32px en pantalla) */
.breaker.mod-1  { width: 32px; }
.breaker.mod-2  { width: 64px; }
.breaker.mod-3  { width: 96px; }
.breaker.mod-4  { width: 128px; }
.breaker.mod-5  { width: 160px; }
.breaker.mod-6  { width: 192px; }
.breaker.mod-7  { width: 224px; }
.breaker.mod-8  { width: 256px; }
.breaker.mod-9  { width: 288px; }
.breaker.mod-10 { width: 320px; }
.breaker.mod-11 { width: 352px; }
.breaker.mod-12 { width: 384px; }
.breaker.mod-13 { width: 416px; }
.breaker.mod-14 { width: 448px; }
.breaker.mod-15 { width: 480px; }
.breaker.mod-16 { width: 512px; }
.breaker.mod-17 { width: 544px; }
.breaker.mod-18 { width: 576px; }

/* Tapas ciegas de Reserva (Blanking plates) */
.breaker.reserve-type {
  background: linear-gradient(to bottom, #101726 0%, #080d16 100%);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-bottom: 4px solid #101726;
  box-shadow: none;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.breaker.reserve-type:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.15);
}

.breaker.reserve-type .breaker-brand,
.breaker.reserve-type .breaker-status-led,
.breaker.reserve-type .breaker-type-tag,
.breaker.reserve-type .breaker-switches-container,
.breaker.reserve-type .breaker-rating,
.breaker.reserve-type .breaker-secondary-rating,
.breaker.reserve-type .breaker-terminals,
.breaker.reserve-type .breaker-label {
  display: none !important;
}

.breaker-reserve-content {
  color: rgba(255, 255, 255, 0.2);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  transform: rotate(-90deg);
  white-space: nowrap;
}

/* Tornillos de conexión superiores e inferiores */
.breaker-terminals {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding: 0 4px;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
}

.breaker-terminals.top {
  top: 4px;
}

.breaker-terminals.bottom {
  bottom: 6px;
}

.breaker-terminal-screw {
  width: 8px;
  height: 8px;
  background: radial-gradient(circle, #37474f 30%, #78909c 70%);
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
  position: relative;
}

.breaker-terminal-screw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 1px;
  width: 6px;
  height: 2px;
  background-color: #263238;
  transform: rotate(45deg);
}

/* Marca o Logo */
.breaker-brand {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #78909c;
  text-transform: uppercase;
  margin-top: 6px;
}

/* Etiqueta del circuito (C1, C2, IGA, etc) */
.breaker-label {
  font-size: 9px;
  font-weight: 800;
  background-color: #37474f;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 2px;
  margin: 4px 0 2px 0;
  text-transform: uppercase;
  width: 90%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breaker-type-tag {
  font-size: 7px;
  color: #546e7a;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Contenedor de interruptores (para magnetotérmicos unipolares/multipolares) */
.breaker-switches-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  position: relative;
  margin: 4px 0;
  padding: 2px 4px;
}

/* Palanca mecánica del interruptor */
.breaker-switch-slot {
  width: 12px;
  height: 32px;
  background-color: #263238;
  border-radius: 2px;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.breaker-switch-lever {
  width: 8px;
  height: 18px;
  background: linear-gradient(to bottom, #ef5350 0%, #b71c1c 100%);
  border: 1px solid #b71c1c;
  border-radius: 1px;
  position: absolute;
  left: 2px;
  top: 2px; /* Posición ON */
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  transition: top 0.15s ease-out;
}

/* Barra de unión para interruptores multipolares */
.breaker-switch-link-bar {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 6px;
  background: linear-gradient(to bottom, #37474f 0%, #21272a 100%);
  border: 1px solid #1e293b;
  border-radius: 2px;
  z-index: 5;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transition: transform 0.15s ease-out;
}

/* Diferenciales suelen tener palanca negra o azul */
.breaker.id-type .breaker-switch-lever {
  background: linear-gradient(to bottom, #1e88e5 0%, #0d47a1 100%);
  border-color: #0d47a1;
}

/* Botón de test del Diferencial "T" */
.breaker-test-button {
  width: 14px;
  height: 14px;
  background-color: #ffd54f;
  border: 1px solid #ffb300;
  border-radius: 2px;
  color: #263238;
  font-size: 8px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.breaker-test-button:active {
  transform: scale(0.9);
  background-color: #ffa000;
}

/* Texto de Amperaje / Calibre */
.breaker-rating {
  font-size: 10px;
  font-weight: 700;
  color: #263238;
  margin-top: auto;
  margin-bottom: 12px;
}

.breaker-secondary-rating {
  font-size: 7px;
  color: #546e7a;
  margin-top: -12px;
  margin-bottom: 10px;
  font-weight: 600;
}

/* LED de estado de funcionamiento */
.breaker-status-led {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #4caf50;
  box-shadow: 0 0 4px #4caf50;
  position: absolute;
  top: 10px;
  right: 6px;
}

.breaker.overloaded .breaker-status-led {
  background-color: #f44336;
  box-shadow: 0 0 6px #f44336;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Inspector de elemento del cuadro */
.element-inspector {
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-top: 16px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.element-inspector h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 6px;
  color: var(--accent-blue);
}

.inspector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 13px;
}

.inspector-grid span {
  font-weight: 600;
  color: var(--text-main);
}

.inspector-desc {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   HISTORIAL DE PROYECTOS / TABLA
   ========================================================================== */
.projects-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.actions-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--card-border);
}

.projects-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.projects-table th {
  background-color: rgba(255, 255, 255, 0.03);
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--card-border);
}

.projects-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-main);
}

.projects-table tr:hover {
  background-color: rgba(255,255,255,0.01);
}

.table-btn {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 6px;
  transition: background-color var(--transition-speed);
}

.btn-load {
  color: var(--accent-blue);
  background-color: rgba(56, 189, 248, 0.1);
}
.btn-load:hover { background-color: rgba(56, 189, 248, 0.2); }

.btn-delete {
  color: var(--accent-red);
  background-color: rgba(239, 68, 68, 0.1);
}
.btn-delete:hover { background-color: rgba(239, 68, 68, 0.2); }

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE / TABLET)
   ========================================================================== */
@media (max-width: 1024px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
  .board-card {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .app-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
  }
  
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  
  .nav-item {
    padding: 10px 14px;
    white-space: nowrap;
    border-left: none;
  }
  
  .nav-item.active {
    border-left: none;
    border-bottom: 3px solid var(--accent-blue);
    padding-left: 14px;
    padding-bottom: 7px;
  }
  
  .sidebar-header, .sidebar-footer {
    display: none;
  }
  
  .app-main {
    margin-left: 0;
  }
  
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }
  
  .project-summary-bar {
    flex-direction: column;
    gap: 8px;
  }
  
  .header-actions {
    justify-content: space-between;
    margin-top: 10px;
  }
  
  .grid-2-col {
    grid-template-columns: 1fr;
  }
  .col-span-2 {
    grid-column: span 1;
  }
}

/* ==========================================================================
   SUBTABS & CUSTOM DIN RAIL COMPONENTS (DPS, FILTER, SOCKET)
   ========================================================================== */
/* Subtabs Navigation */
.subtabs-nav {
  display: flex;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  padding: 6px;
  border-radius: var(--border-radius-lg);
  margin-bottom: 24px;
}

.subtab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--border-radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtab-btn:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.subtab-btn.active {
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Subviews */
.subview {
  display: none;
}

.subview.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.3s ease-out;
}

/* DPS (Surge protector) styling */
.breaker.dps-type {
  background: linear-gradient(to right, #b0bec5 0%, #cfd8dc 30%, #e2e8f0 50%, #cfd8dc 75%, #b0bec5 100%);
  border-color: #78909c;
}

.breaker.dps-type .breaker-switch-slot {
  display: none;
}

.breaker-dps-cartridges {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 0 4px;
  margin: 6px 0;
}

.breaker-dps-cartridge {
  flex-grow: 1;
  background: linear-gradient(to bottom, #f59e0b 0%, #d97706 100%);
  border: 1px solid #b45309;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 1px;
  height: 48px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.breaker-dps-label {
  font-size: 6px;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.breaker-dps-window {
  width: 10px;
  height: 6px;
  background-color: #22c55e; /* Green OK */
  border: 1px solid #1e293b;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.4);
}

.breaker-dps-replace {
  font-size: 5px;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}

/* Filter (EMI/EMC filter) styling */
.breaker.filter-type {
  background: linear-gradient(to right, #475569 0%, #64748b 30%, #94a3b8 50%, #64748b 75%, #475569 100%);
  border-color: #334155;
  border-bottom-color: #1e293b;
}

.breaker.filter-type .breaker-switch-slot {
  display: none;
}

.breaker-filter-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 62px;
  margin: 4px 0;
}

.breaker-filter-diagram {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 4px;
}

.breaker-filter-spec {
  font-size: 8px;
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 0.5px;
}

.breaker-filter-frequency {
  font-size: 6px;
  color: #cbd5e1;
  font-weight: 600;
}

/* Receptacle socket styling */
.breaker.socket-type {
  background: linear-gradient(to right, #94a3b8 0%, #cbd5e1 30%, #f1f5f9 50%, #cbd5e1 75%, #94a3b8 100%);
  border-color: #64748b;
}

.breaker.socket-type .breaker-switch-slot {
  display: none;
}

.breaker-socket-outlet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 65px;
  margin: 4px 0;
}

.breaker-socket-inner {
  width: 42px;
  height: 42px;
  background-color: #cbd5e1;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.25);
}

.breaker-socket-earth-clip {
  width: 6px;
  height: 3px;
  background-color: #d97706; /* Copper/brass */
  border-radius: 1px;
}

.breaker-socket-holes-row {
  display: flex;
  justify-content: space-between;
  width: 22px;
}

.breaker-socket-hole {
  width: 5px;
  height: 5px;
  background-color: #1e293b;
  border-radius: 50%;
  box-shadow: 0 1px 1px rgba(255,255,255,0.4);
}

.breaker-socket-label {
  font-size: 6px;
  color: #475569;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* Earth terminal block styling */
.breaker.earth-type {
  background: repeating-linear-gradient(
    -45deg,
    #15803d,
    #15803d 10px,
    #ca8a04 10px,
    #ca8a04 20px
  );
  border-color: #166534;
  border-bottom-color: #14532d;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
}

.breaker.earth-type .breaker-status-led {
  display: none;
}

.breaker.earth-type .breaker-brand {
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.breaker.earth-type .breaker-label {
  color: #15803d;
  font-weight: 800;
  background: #ffffff;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #166534;
  font-size: 0.7rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.breaker.earth-type .breaker-rating,
.breaker.earth-type .breaker-secondary-rating {
  color: #15803d;
  font-weight: bold;
  background: #ffffff;
  padding: 1px 3px;
  border-radius: 2px;
  font-size: 0.55rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.breaker-earth-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60px;
  margin: 4px 0;
}

.breaker-earth-symbol-wrapper {
  background: rgba(255,255,255,0.85);
  border: 1.5px solid #166534;
  border-radius: 4px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.breaker-earth-terminal {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  width: 16px;
}

.breaker-earth-terminal::before {
  content: "";
  width: 2px;
  height: 8px;
  background-color: #15803d;
  margin-bottom: -1px;
}

.breaker-earth-line {
  width: 14px;
  height: 2px;
  background-color: #15803d;
}

.breaker-earth-line:nth-child(2) {
  width: 9px;
}

.breaker-earth-line:nth-child(3) {
  width: 4px;
}

/* Cuadro Info Panels Layout */
.cuadro-info-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--card-border);
  padding-top: 20px;
}

.cuadro-info-panel {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.cuadro-info-icon {
  font-size: 20px;
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent-blue);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.cuadro-info-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cuadro-info-content strong {
  font-size: 13px;
  color: var(--text-main);
}

.cuadro-info-content span {
  font-size: 12px;
  color: var(--accent-blue);
  font-weight: 600;
}

.cuadro-info-content p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Board Summary Bar */
.board-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.board-summary-bar .summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 180px;
}

.board-summary-bar .summary-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.board-summary-bar .summary-value {
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
}

/* Extra spacing for print layout elements */
@media print {
  .subtabs-nav {
    display: none !important;
  }
  .subview {
    display: none !important;
  }
  .subview.active {
    display: block !important;
  }
  .cuadro-info-panels {
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid #000000 !important;
  }
  .cuadro-info-panel {
    border: 1px solid #000000 !important;
    background: none !important;
  }
}

/* ==========================================================================
   PRINT LAYOUT SHEET (@media print)
   ========================================================================== */
@media print {
  body {
    background-color: #ffffff;
    color: #000000;
    font-size: 12pt;
  }
  
  /* Hide UI components not needed in report */
  .app-sidebar,
  .app-header,
  .header-actions,
  .sidebar-footer,
  .board-legend,
  .sidebar-header,
  .btn,
  .btn-secondary-label,
  .relevancy-note {
    display: none !important;
  }
  
  .app-container {
    display: block;
  }
  
  .app-main {
    margin-left: 0 !important;
    padding: 0;
  }
  
  /* Show all calculation views printed on separate pages */
  .view-content {
    padding: 0;
  }
  
  .tab-view {
    display: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .tab-view.active {
    display: block !important;
  }
  
  .view-header {
    border-bottom: 2px solid #000000;
    padding-bottom: 8px;
    margin-bottom: 20px;
  }
  
  .view-header h2 {
    color: #000000;
    font-size: 18pt;
  }
  
  .view-header p {
    color: #555555;
  }
  
  .grid-layout {
    display: block !important;
  }
  
  /* Reset Card Styles for Printing */
  .card {
    background: none !important;
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin-bottom: 20px;
    page-break-inside: avoid;
  }
  
  .card-header {
    background-color: #f0f0f0 !important;
    border-bottom: 1px solid #cccccc !important;
    color: #000000 !important;
  }
  
  .card-header h3 {
    color: #000000 !important;
  }
  
  /* Form components formatting */
  input[type="text"], select {
    border: none !important;
    border-bottom: 1px solid #333333 !important;
    border-radius: 0 !important;
    background: none !important;
    color: #000000 !important;
    font-weight: bold;
    padding: 2px !important;
  }
  
  .checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .checkbox-label {
    margin-bottom: 8px;
  }
  
  .checkbox-label input[type="checkbox"] {
    accent-color: #000000;
  }
  
  /* Results styling */
  .result-card {
    border: 2px solid #000000 !important;
    background-color: #fafafa !important;
  }
  
  .status-indicator-badge {
    border: 2px solid #000000 !important;
    color: #000000 !important;
    background-color: #e0e0e0 !important;
    font-weight: 800;
  }
  
  .result-row strong {
    color: #000000 !important;
    font-size: 12pt !important;
  }
  
  .highlight-box {
    border: 1px solid #666666 !important;
    border-left: 6px solid #000000 !important;
    background-color: #eeeeee !important;
  }
  
  .highlight-text {
    color: #000000 !important;
    font-size: 14pt !important;
  }
  
  .text-blue, .text-green, .text-red, .text-yellow {
    color: #000000 !important;
  }
  
  /* Render DIN Rail in print as standard black-and-white schema */
  .din-rail-wrapper {
    background: none !important;
    border: 1px solid #999999 !important;
    box-shadow: none !important;
  }
  
  .din-rail {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    box-shadow: none !important;
    height: 120px;
    padding-bottom: 0;
  }
  
  .breaker {
    background: #ffffff !important;
    border: 1.5px solid #000000 !important;
    border-bottom: 4px solid #000000 !important;
    color: #000000 !important;
    box-shadow: none !important;
    height: 100px;
  }
  
  .breaker-label {
    background-color: #000000 !important;
    color: #ffffff !important;
  }
  
  .breaker-switch-slot {
    background-color: #dddddd !important;
    box-shadow: none !important;
    height: 20px;
  }
  
  .breaker-switch-lever {
    background: #000000 !important;
    border-color: #000000 !important;
    height: 10px;
  }
  
  .breaker-rating {
    margin-bottom: 4px;
    color: #000000 !important;
  }
  
  .breaker-status-led {
    border: 1px solid #000000 !important;
    background-color: #ffffff !important;
    box-shadow: none !important;
  }
}

/* ==========================================================================
   CHECKLIST & AUDITORÍA DE MTD STYLES
   ========================================================================== */
.progress-bar-container {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--card-border);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue) 0%, #22c55e 100%);
  transition: width 0.3s ease;
  border-radius: 6px;
}

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

@media (max-width: 600px) {
  .checklist-grid {
    grid-template-columns: 1fr;
  }
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--card-border);
  transition: background-color var(--transition-speed) ease;
  cursor: pointer;
}

.checklist-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.checklist-item span {
  font-size: 13px;
  color: var(--text-normal);
}

/* ==========================================================================
   DIAGRAMA UNIFILAR STYLES
   ========================================================================== */
.unifilar-diagram-container {
  background: rgba(15, 22, 34, 0.4);
  border-radius: var(--border-radius-md, 8px);
  border: 1px solid var(--card-border, rgba(255,255,255,0.1));
  padding: 20px;
  overflow-x: auto;
  text-align: center;
}

.unifilar-svg {
  display: block;
  margin: 0 auto;
}

.unifilar-svg line,
.unifilar-svg path {
  stroke: var(--text-main, #f1f5f9);
  stroke-width: 2;
  fill: none;
}

.unifilar-svg rect {
  stroke: var(--text-main, #f1f5f9);
  stroke-width: 2;
  fill: var(--bg-secondary, #0f1622);
}

.unifilar-svg text {
  fill: var(--text-main, #f1f5f9);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 11px;
}

.unifilar-svg .text-bold {
  font-weight: 700;
  font-size: 12px;
}

.unifilar-svg .text-small {
  font-size: 9px;
  fill: var(--text-muted, #94a3b8);
}

.unifilar-svg .pe-line {
  stroke: #22c55e;
  stroke-width: 3;
}

.unifilar-svg .earth-connection {
  stroke: #22c55e;
  stroke-dasharray: 4 3;
  stroke-width: 1.5;
}

/* ==========================================================================
   UNIFILAR ZOOM MODAL STYLES
   ========================================================================== */
.unifilar-screen-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  border: 2px dashed var(--card-border);
  border-radius: var(--border-radius-lg);
  background-color: rgba(0, 0, 0, 0.15);
  margin-top: 12px;
  text-align: center;
  transition: all 0.2s ease;
}

.unifilar-screen-placeholder:hover {
  border-color: var(--accent-blue);
  background-color: rgba(56, 189, 248, 0.05);
}

.unifilar-screen-placeholder p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  max-width: 400px;
}

/* Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(11, 15, 25, 0.85);
  z-index: 3000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(6px);
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

/* Modal Card */
.modal-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  width: 95%;
  max-width: 1280px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--card-border);
  background-color: rgba(0, 0, 0, 0.2);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
  padding: 4px;
}

.btn-close:hover {
  color: #ef4444;
  transform: scale(1.1);
}

.modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow: hidden;
  gap: 16px;
  background-color: var(--body-bg);
}

.modal-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
  align-items: center;
}

.modal-zoom-viewport {
  flex: 1;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  background-color: #080d16; /* Clean blueprint background */
  overflow: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
}

#modal-unifilar-content {
  transform-origin: center center;
  transition: transform 0.15s cubic-bezier(0.1, 0.8, 0.3, 1);
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

#modal-unifilar-content:active {
  cursor: grabbing;
}

#modal-unifilar-content svg {
  background-color: #0b0f19;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  max-width: none !important;
  height: auto;
}

/* Custom load style */
.custom-load-item {
  border: 1px dashed rgba(56, 189, 248, 0.3) !important;
  background-color: rgba(56, 189, 248, 0.03) !important;
  padding-right: 8px !important;
}

.custom-load-item:hover {
  border-color: var(--accent-blue) !important;
  background-color: rgba(56, 189, 248, 0.06) !important;
}

/* Hide on-screen diagram container */
.unifilar-diagram-container {
  display: none;
}

@media print {
  .unifilar-diagram-container {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    padding: 10px !important;
    margin-top: 15px !important;
  }
  .unifilar-svg line,
  .unifilar-svg path {
    stroke: #000000 !important;
  }
  .unifilar-svg rect {
    stroke: #000000 !important;
    fill: #ffffff !important;
  }
  .unifilar-svg text {
    fill: #000000 !important;
  }
  .unifilar-svg .text-small {
    fill: #333333 !important;
  }
  .unifilar-svg .pe-line {
    stroke: #000000 !important;
    stroke-width: 3 !important;
  }
  .unifilar-svg .earth-connection {
    stroke: #000000 !important;
    stroke-dasharray: 4 3 !important;
  }
  /* Prevent page breaks for hidden or inactive unifilar sections */
  .unifilar-section {
    page-break-before: avoid !important;
    break-before: avoid !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  @page landscape-page {
    size: landscape;
    margin: 1cm;
  }
  @page portrait-page {
    size: portrait;
    margin: 1cm;
  }

  /* Page breaks and orientation are ONLY applied to the active tab and active subview's unifilar section */
  .tab-view.active .subview.active .unifilar-section.print-landscape {
    page: landscape-page;
    page-break-before: always !important;
    break-before: page !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100vh !important;
  }
  .tab-view.active .subview.active .unifilar-section.print-portrait {
    page: portrait-page;
    page-break-before: always !important;
    break-before: page !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100vh !important;
  }

  /* Fallbacks for active tabs that might not use subviews but have unifilar section directly */
  .tab-view.active > .unifilar-section.print-landscape,
  .tab-view.active > div > .unifilar-section.print-landscape {
    page: landscape-page;
    page-break-before: always !important;
    break-before: page !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100vh !important;
  }
  .tab-view.active > .unifilar-section.print-portrait,
  .tab-view.active > div > .unifilar-section.print-portrait {
    page: portrait-page;
    page-break-before: always !important;
    break-before: page !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100vh !important;
  }

  /* Hide HTML section headers when printing active */
  .tab-view.active .unifilar-section.print-landscape > div:first-child,
  .tab-view.active .unifilar-section.print-portrait > div:first-child {
    display: none !important;
  }

  .tab-view.active .unifilar-section.print-landscape .unifilar-diagram-container,
  .tab-view.active .unifilar-section.print-portrait .unifilar-diagram-container {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .tab-view.active .unifilar-section.print-landscape .unifilar-svg,
  .tab-view.active .unifilar-section.print-portrait .unifilar-svg {
    width: 100% !important;
    height: auto !important;
    max-height: 90vh !important;
  }

  /* Force page breaks on major sections when printing */
  .tab-view.active .subview.active .board-card,
  .tab-view.active .subview.active .cuadro-info-panels {
    page-break-before: always !important;
    break-before: page !important;
  }

  .unifilar-screen-placeholder {
    display: none !important;
  }

  .unifilar-diagram-container {
    display: block !important;
  }

  /* Individual unifilar print styling */
  body.print-only-unifilar {
    background: #ffffff !important;
    color: #000000 !important;
  }
  body.print-only-unifilar > *:not(#unifilar-modal) {
    display: none !important;
  }
  body.print-only-unifilar #unifilar-modal {
    position: absolute !important;
    display: block !important;
    background: none !important;
    backdrop-filter: none !important;
    width: 100% !important;
    height: auto !important;
    top: 0 !important;
    left: 0 !important;
    padding: 0 !important;
    z-index: 99999 !important;
  }
  body.print-only-unifilar #unifilar-modal .modal-card {
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    overflow: visible !important;
    animation: none !important;
  }
  body.print-only-unifilar #unifilar-modal .modal-header,
  body.print-only-unifilar #unifilar-modal .modal-controls {
    display: none !important;
  }
  body.print-only-unifilar #unifilar-modal .modal-body {
    padding: 0 !important;
    overflow: visible !important;
    background: none !important;
  }
  body.print-only-unifilar #unifilar-modal .modal-zoom-viewport {
    border: none !important;
    background: none !important;
    overflow: visible !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
  }
  body.print-only-unifilar #modal-unifilar-content {
    transform: none !important; /* Force reset zoom transform for print */
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
  }
  body.print-only-unifilar #modal-unifilar-content svg {
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 95vh !important;
  }
  body.print-only-unifilar.print-landscape-mode {
    page: landscape-page;
  }
  body.print-only-unifilar.print-portrait-mode {
    page: portrait-page;
  }
}
