/* SHIELD-3D Estilos Modernos - Modo Oscuro de Alta Gama */
:root {
  --bg-main: #090d16;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-sidebar: #0b1120;
  --border-color: rgba(51, 65, 85, 0.6);
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --accent: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-width: 560px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
}

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* HEADER MULTINIVEL REACTIVO (3 CORRIDAS) */
.app-header {
  height: auto;
  min-height: 56px;
  background: linear-gradient(180deg, #0d1527 0%, #080d19 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.22);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 1.15rem;
  z-index: 20;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

/* FILAS / CORRIDAS DEL MENÚ */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
}

/* CORRIDA 1: MARCA Y ESTADO */
.header-row-brand {
  border-bottom: 1px solid rgba(51, 65, 85, 0.35);
  padding-bottom: 0.35rem;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
  flex-shrink: 0;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.brand-title-wrap h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #f8fafc;
  line-height: 1.2;
}

.badge-version {
  font-size: 0.64rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-edition {
  font-size: 0.62rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.brand-subtitle {
  font-size: 0.71rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 75vw;
}

.header-top-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(51, 65, 85, 0.5);
  color: #cbd5e1;
}

.status-ready .status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.btn-help-header {
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
}

/* CORRIDA 2 & 3: GRUPOS FUNCIONALES (RIBBON) */
.header-row-project,
.header-row-operations {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.menu-group {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.55);
  border-radius: 7px;
  padding: 0.2rem 0.45rem;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.menu-group.flex-grow {
  flex-grow: 1;
  min-width: 280px;
}

.menu-group-label {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.71rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-right: 0.2rem;
  white-space: nowrap;
}

.menu-v-divider {
  width: 1px;
  height: 24px;
  background: rgba(51, 65, 85, 0.45);
  margin: 0 0.1rem;
  flex-shrink: 0;
}

.header-select {
  flex: 1;
  min-width: 200px;
  max-width: 440px;
  height: 28px;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
}

/* BOTÓN PRINCIPAL DE CÁLCULO EN CORRIDA 3 */
.primary-action-group {
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
}

.btn-calculate-main {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.95rem;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
  letter-spacing: 0.01em;
}

.btn-calculate-main:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
}

/* TELEMETRÍA EN CABECERA */
.header-telemetry-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.telemetry-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.telemetry-chip.highlight {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.chip-label {
  color: #94a3b8;
}

.chip-value {
  font-weight: 600;
}

/* BOTONES GLOBALES */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(148, 163, 184, 0.45);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(51, 65, 85, 0.4);
}

.btn-outline-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fff;
}

.btn-sm {
  padding: 0.24rem 0.52rem;
  font-size: 0.73rem;
}

.btn-icon {
  padding: 0.38rem;
  background: rgba(30, 41, 59, 0.6);
  border-color: var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
}
.btn-icon:hover {
  color: #fff;
  background: rgba(51, 65, 85, 0.8);
}

/* WORKSPACE FLEX CON RESIZE DINÁMICO */
.workspace-grid {
  display: flex;
  flex-direction: row;
  flex: 1 1 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.sidebar-panel {
  width: var(--sidebar-width);
  min-width: 360px;
  max-width: 80vw;
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: width 0.05s ease-out;
}

.workspace-grid.analysis-panel .sidebar-panel {
  width: min(72vw, 960px) !important;
}

#table-audit-results,
#tab-studies .data-table {
  min-width: 760px;
}

#table-audit-results td:not(:first-child),
#tab-studies .data-table td:not(:first-child) {
  white-space: nowrap;
}

/* BARRA SPLITTER ARRASTRABLE CON EL MOUSE */
.panel-resizer {
  width: 8px;
  cursor: col-resize;
  background: #090e1a;
  border-left: 1px solid rgba(51, 65, 85, 0.4);
  border-right: 1px solid rgba(51, 65, 85, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  z-index: 15;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.panel-resizer:hover,
.panel-resizer.is-dragging {
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.resizer-handle {
  width: 2px;
  height: 32px;
  background: rgba(148, 163, 184, 0.4);
  border-radius: 2px;
  transition: all 0.15s ease;
}

.panel-resizer:hover .resizer-handle,
.panel-resizer.is-dragging .resizer-handle {
  background: var(--accent);
  height: 48px;
  box-shadow: 0 0 8px var(--accent);
}

body.is-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.tabs-nav {
  display: flex;
  background: #070b14;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 0.55rem 0.35rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(56, 189, 248, 0.05);
}

/* ÁREA DE CONTENIDO COMPACTA Y ERGONÓMICA */
.tab-content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.55rem 0.65rem;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  backdrop-filter: blur(10px);
}

.section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 0.65rem;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.form-input, .form-select {
  width: 100%;
  background: #070b14;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
}

.radio-group {
  display: flex;
  gap: 0.85rem;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.calc-results-box {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.3);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}
.result-row:last-child {
  margin-bottom: 0;
}

/* TABLAS */
.table-responsive {
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  text-align: left;
}

.data-table th {
  background: #070b14;
  padding: 0.3rem 0.28rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.73rem;
}

.data-table td {
  padding: 0.22rem 0.25rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
  vertical-align: middle;
}

/* Inputs en tablas: numeros legibles y sin flechas spinner que tapen el valor */
.data-table input.form-input {
  padding: 0.22rem 0.32rem;
  font-size: 0.78rem;
  height: 26px;
}

.data-table input[type="text"].form-input {
  min-width: 75px;
  width: 100%;
}

.data-table input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.data-table input[type="number"]::-webkit-inner-spin-button,
.data-table input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Anchos utilitarios para inputs en tablas */
.w-coord {
  width: 3.4rem !important;
  min-width: 46px !important;
  max-width: 58px !important;
  padding: 0.2rem 0.25rem !important;
  text-align: right !important;
}

.btn-delete-row {
  padding: 0.16rem 0.36rem !important;
  font-size: 0.7rem !important;
  line-height: 1 !important;
  min-width: 22px !important;
}

.w-12 { width: 3.4rem !important; min-width: 48px; }
.w-14 { width: 3.8rem !important; min-width: 54px; }
.w-16 { width: 4.4rem !important; min-width: 62px; }
.w-20 { width: 5.6rem !important; min-width: 78px; }

/* VIEWPORT 3D (FLEXIBLE Y REACTIVO) */
.viewport-area {
  flex: 1 1 0;
  min-width: 280px;
  position: relative;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewport-toolbar {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(11, 17, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  backdrop-filter: blur(12px);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

.btn-tool {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tool:hover {
  color: #fff;
  background: rgba(51, 65, 85, 0.4);
}

.btn-tool.active {
  background: var(--primary);
  color: #fff;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.slider-control input[type="range"] {
  width: 70px;
}

.threejs-canvas-wrapper {
  width: 100%;
  height: 100%;
}

.telemetry-badge {
  position: absolute;
  bottom: 45px;
  left: 14px;
  z-index: 10;
  background: rgba(11, 17, 32, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  backdrop-filter: blur(12px);
  min-width: 260px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.viewport-legend {
  position: absolute;
  bottom: 12px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 0.85rem;
  background: rgba(11, 17, 32, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  backdrop-filter: blur(10px);
  font-size: 0.72rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.bg-amber-400 { background-color: #fbbf24; }
.bg-emerald-600 { background-color: #059669; }
.bg-pink-500 { background-color: #ec4899; }
.bg-red-500 { background-color: #ef4444; }
.bg-green-500 { background-color: #22c55e; }
.bg-blue-500 { background-color: #3b82f6; }

/* BADGES DE AUDITORÍA */
.audit-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
}
.audit-badge.protected {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}
.audit-badge.critical {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
}
.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-warning {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}
.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* TOAST NOTIFICATION */
.toast-notification {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s ease;
}
.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* FOOTER */
.app-footer {
  height: 28px;
  background-color: #070b14;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 580px;
  max-width: 90vw;
  padding: 1.5rem;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-footer {
  margin-top: 1.25rem;
  text-align: right;
}

/* =========================================================
   REGLAS REACTIVAS Y AUTOAJUSTE DE PANTALLA (RESPONSIVE RIBBON)
   ========================================================= */

@media (max-width: 1400px) {
  .brand-subtitle {
    max-width: 55vw;
  }
  .header-select {
    max-width: 320px;
  }
}

@media (max-width: 1200px) {
  .app-header {
    padding: 0.4rem 0.85rem;
    gap: 0.3rem;
  }
  .header-row-project,
  .header-row-operations {
    gap: 0.35rem;
  }
  .menu-group {
    padding: 0.18rem 0.38rem;
    gap: 0.25rem;
  }
  .menu-group.flex-grow {
    min-width: 220px;
  }
  .header-select {
    min-width: 160px;
    max-width: 260px;
  }
  .brand-subtitle {
    display: none; /* Oculta subtítulo secundario en resoluciones medianas para dar espacio al menú */
  }
  .header-telemetry-bar {
    margin-left: 0;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 480px;
  }
  .menu-group-label {
    font-size: 0.67rem;
  }
  .btn-sm {
    padding: 0.2rem 0.45rem;
    font-size: 0.71rem;
  }
  .telemetry-chip {
    font-size: 0.68rem;
    padding: 0.15rem 0.4rem;
  }
}

@media (max-width: 860px) {
  .header-row-brand {
    overflow-x: auto;
  }
  .brand-area,
  .header-top-status {
    flex-shrink: 0;
  }
  .brand-title-wrap {
    flex-wrap: nowrap;
  }
  .brand-title-wrap h1 {
    white-space: nowrap;
  }
  .badge-edition,
  .brand-subtitle {
    display: none;
  }
  .header-row-project,
  .header-row-operations {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .header-row-project .menu-group,
  .header-row-operations .menu-group {
    flex-shrink: 0;
  }
  .workspace-grid {
    flex-direction: column;
  }
  .sidebar-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .workspace-grid.analysis-panel .sidebar-panel {
    width: 100% !important;
  }
  .panel-resizer {
    display: none;
  }
  .menu-v-divider {
    display: none;
  }
  .header-telemetry-bar {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ESTADOS DINÁMICOS DEL PROYECTO (COHERENCIA Y REVISIONES) */
.status-pill.status-pending-calc {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}
.status-pill.status-pending-calc .status-indicator-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-dot 1.5s infinite ease-in-out;
}

.status-pill.status-calculating {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  color: #38bdf8;
}
.status-pill.status-calculating .status-indicator-dot {
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
  animation: pulse-dot 0.8s infinite ease-in-out;
}

.status-pill.status-error {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}
.status-pill.status-error .status-indicator-dot {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* BANNER DE ESCENA DESACTUALIZADA DENTRO DEL VISOR 3D */
.scene-outdated-banner {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(41, 15, 3, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(245, 158, 11, 0.7);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px rgba(245, 158, 11, 0.25);
  color: #fef08a;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  animation: fadeInBanner 0.3s ease;
}

.audit-outdated-alert {
  background: rgba(120, 53, 15, 0.35);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #fde047;
  font-size: 0.76rem;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

@keyframes fadeInBanner {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* FILTROS Y RESUMEN KPI EN TABLA DE AUDITORÍA */
.audit-kpi-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.audit-filter-group {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  width: 100%;
}

.btn-filter {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(71, 85, 105, 0.6);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-filter:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #f8fafc;
}

.btn-filter.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.4);
}

.btn-filter.filter-exposed.active {
  background: #be123c;
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.4);
}

.btn-filter.filter-marginal.active {
  background: #b45309;
  border-color: #f59e0b;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.4);
}

.btn-filter.filter-protected.active {
  background: #047857;
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(4, 120, 87, 0.4);
}

/* BOTÓN DE LOCALIZAR EN 3D DENTRO DE TABLA DE AUDITORÍA */
.btn-locate-3d {
  background: rgba(2, 132, 199, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  font-size: 0.68rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-locate-3d:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

/* VALIDACIÓN Y ERRORES EN INPUTS */
.input-error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.14) !important;
  color: #fca5a5 !important;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4) !important;
}

/* GRUPO DE COORDENADAS DE CABLE */
.wire-coord-inputs {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.wire-coord-inputs .w-coord-mini {
  width: 44px !important;
  min-width: 40px !important;
  max-width: 50px !important;
  padding: 0.15rem 0.2rem !important;
  font-size: 0.68rem !important;
  text-align: right;
}

/* TOAST CON BOTÓN DE DESHACER (UNDO) */
.toast-notification {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.btn-toast-undo {
  background: #38bdf8;
  color: #080e1a;
  border: none;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.22rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-toast-undo:hover {
  background: #7dd3fc;
}

/* BOTÓN PARA COLAPSAR/EXPANDIR EL PANEL LATERAL */
.sidebar-panel.is-collapsed {
  display: none !important;
}
.panel-resizer.is-collapsed {
  display: none !important;
}

/* ACCESIBILIDAD Y FOCO VISIBLE */
:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

/* ESTADO DE ARCHIVO (GUARDADO VS MODIFICADO) */
.status-pill.status-saved {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.status-pill.status-dirty {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}
.dot-saved {
  background: #22c55e !important;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6) !important;
}
.dot-dirty {
  background: #f59e0b !important;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6) !important;
}

/* MODAL ASISTENTE DXF E INSPECTOR DE EQUIPOS */
.modal-card-lg {
  max-width: 680px !important;
  width: 95% !important;
}

.stat-pill {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.stat-pill .stat-num {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: monospace;
}
.stat-pill .stat-lbl {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

/* RESPONSIVIDAD Y AJUSTE EN 1024x680 */
.viewport-toolbar {
  flex-wrap: wrap !important;
  gap: 0.35rem !important;
}

@media (max-width: 1100px) {
  .header-telemetry-bar {
    gap: 0.3rem !important;
  }
  .telemetry-chip {
    padding: 0.2rem 0.45rem !important;
    font-size: 0.68rem !important;
  }
  .btn-calculate-main {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.78rem !important;
  }
}

@media (max-width: 1024px) {
  .app-header {
    padding: 0.4rem 0.75rem !important;
  }
  .header-row {
    gap: 0.4rem !important;
  }
  .brand-subtitle {
    display: none;
  }
  .viewport-toolbar {
    padding: 0.35rem 0.5rem !important;
  }
  .viewport-legend {
    bottom: 6px;
    right: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
  }
}


/* Edición de conjuntos y estudios de alternativas */
.model-row-selected { outline: 2px solid #38bdf8; outline-offset: -2px; background: #17304a; }
.bulk-select { width: 18px; height: 18px; margin-right: 8px; accent-color: #38bdf8; }
.study-controls { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.study-controls label { flex: 1; min-width: 95px; }
.study-controls input, .study-controls select { width: 100%; }
.study-output { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 'JetBrains Mono', monospace; color: #cbd5e1; margin-top: 14px; }
#tab-studies .btn { margin: 6px 0; }
#tab-studies .table-responsive { margin: 12px 0; }
.structure-list { max-height: 180px; overflow: auto; padding: 8px; }
.structure-selection { display: flex; align-items: center; padding: 4px; font-size: 12px; }

/* MODAL DE AUDITORÍA AMPLIADA (MODAL-CARD-XL) */
.modal-card-xl {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
}
.modal-card-xl .modal-body {
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}
#table-audit-expanded th {
  position: sticky;
  top: 0;
  background: #0f172a;
  z-index: 2;
}

/* PERFIL DE CORTE 2D (CROSS SECTION) */
#cs-svg-container {
  background: radial-gradient(circle at 50% 50%, #090d16 0%, #020617 100%);
  border: 1px solid #1e293b;
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
  min-height: 290px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cs-svg-canvas {
  width: 100%;
  height: 280px;
  display: block;
}
.cs-axis-line {
  stroke: #334155;
  stroke-width: 1;
}
.cs-grid-line {
  stroke: #1e293b;
  stroke-width: 0.75;
  stroke-dasharray: 2 2;
}
.cs-mesh-line {
  stroke: #facc15;
  stroke-width: 2.5;
  fill: none;
}
.cs-mesh-area {
  fill: rgba(250, 204, 21, 0.08);
}
.cs-ground-line {
  stroke: #475569;
  stroke-width: 2;
}
.cs-eq-box {
  stroke-width: 1.5;
  transition: all 0.2s ease;
}
.cs-eq-box.protected {
  fill: rgba(34, 197, 94, 0.35);
  stroke: #22c55e;
}
.cs-eq-box.exposed {
  fill: rgba(244, 63, 94, 0.35);
  stroke: #f43f5e;
}
.cs-eq-box.marginal {
  fill: rgba(245, 158, 11, 0.35);
  stroke: #f59e0b;
}
.cs-ds-bound {
  stroke-dasharray: 3 3;
  fill: none;
}
.cs-mast-line {
  stroke: #38bdf8;
  stroke-width: 3;
  stroke-linecap: round;
}
.cs-wire-point {
  fill: #e879f9;
  stroke: #a855f7;
  stroke-width: 1.5;
}

/* TARJETA DE RECOMENDACIÓN Y MITIGACIÓN EN INSPECTOR */
#insp-mitigation-card {
  transition: all 0.3s ease;
}
#insp-mitigation-card.has-mitigation {
  background: rgba(15, 23, 42, 0.85);
  border-color: #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
}
.mitigation-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
}
.mitigation-badge.mast {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid #0284c7;
}
.mitigation-badge.franklin {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid #d97706;
}

/* CONTROLES DE CORTE EN TOOLBAR 3D */
#clipping-controls-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.7);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(51, 65, 85, 0.6);
}
#slider-clipping-pos {
  width: 70px;
  accent-color: #38bdf8;
  cursor: pointer;
}



/* ===== Ajustes de encabezado (2026-10-15) ===== */
/* Fila superior: permite pasar a una segunda línea en vez de desbordar */
.header-row-brand { flex-wrap: wrap; row-gap: 0.35rem; }
.brand-area { min-width: 0; }
.header-top-status { flex-wrap: wrap; justify-content: flex-end; flex-shrink: 1; min-width: 0; row-gap: 0.3rem; }
.status-pill { white-space: nowrap; }
.btn-portal { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-weight: 600; }

/* Selector de modelo: altura suficiente para que el texto no se corte */
.header-select {
  height: auto;
  min-height: 30px;
  line-height: 1.3;
  padding: 0.25rem 1.9rem 0.25rem 0.55rem;
  text-overflow: ellipsis;
}

/* Elementos decorativos que ceden espacio en pantallas medianas */
@media (max-width: 1600px) {
  .status-pill.status-gl { display: none; }
}
@media (max-width: 1500px) {
  .brand-subtitle { display: none; }
  .badge-edition { display: none; }
}

/* Funciones que requieren la versión de escritorio (modo web) */
.web-static-mode .needs-desktop { opacity: 0.5; cursor: help; filter: grayscale(0.4); }
.web-static-mode .needs-desktop:hover { opacity: 0.75; transform: none; }
