/* =========================================================
   DUNAMIS AI STUDIO - SISTEMA DE DISEÑO EMPRESARIAL
   Soporte Completo para Tema Claro (Predeterminado) y Tema Oscuro
   ========================================================= */

:root, [data-theme="light"] {
  --bg: #F8FAFC;
  --bg-gradient: linear-gradient(180deg, #F8FAFC 0%, #EEF2F6 100%);
  --card: #FFFFFF;
  --card-hover: #F8FAFC;
  --card-light: #F1F5F9;
  --card-subtle: #F8FAFC;
  --header-bg: rgba(255, 255, 255, 0.92);
  --line: #E2E8F0;
  --line-active: #6366F1;
  --text: #0F172A;
  --text-muted: #475569;
  --text-dim: #64748B;
  --primary: #6366F1;
  --primary-glow: rgba(99, 102, 241, 0.2);
  --pink: #E11D48;
  --pink-glow: rgba(225, 29, 72, 0.2);
  --teal: #0D9488;
  --teal-glow: rgba(13, 148, 136, 0.2);
  --amber: #D97706;
  --danger: #DC2626;
  --input-bg: #FFFFFF;
  --input-border: #CBD5E1;
  --input-text: #0F172A;
  --input-placeholder: #94A3B8;
  --tabs-bg: #EEF2F6;
  --code-bg: #F8FAFC;
  --overlay-bg: rgba(15, 23, 42, 0.55);
  --bg-dark: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-panel: #F1F5F9;
  --border: #E2E8F0;
  --text-light: #0F172A;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 30px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --bg: #0D0117;
  --bg-gradient: radial-gradient(1200px 700px at 30% 20%, #2A0F52 0%, #0D0117 75%);
  --card: #17082A;
  --card-hover: #1F0C38;
  --card-light: #240E42;
  --card-subtle: #080011;
  --header-bg: rgba(13, 1, 23, 0.92);
  --line: #34195C;
  --line-active: #8B5CF6;
  --text: #F3F0FF;
  --text-muted: #C4B5FD;
  --text-dim: #8B7AB8;
  --primary: #8B5CF6;
  --primary-glow: rgba(139, 92, 246, 0.35);
  --pink: #E8658A;
  --pink-glow: rgba(232, 101, 138, 0.35);
  --teal: #00C896;
  --teal-glow: rgba(0, 200, 150, 0.35);
  --amber: #F59E0B;
  --danger: #EF4444;
  --input-bg: #090013;
  --input-border: #34195C;
  --input-text: #FFFFFF;
  --input-placeholder: #8B7AB8;
  --tabs-bg: #080011;
  --code-bg: #080011;
  --overlay-bg: rgba(6, 4, 15, 0.92);
  --bg-dark: #0D0117;
  --bg-card: #17082A;
  --bg-panel: #17082A;
  --border: #34195C;
  --text-light: #F3F0FF;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.7);
}

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

body {
  background: var(--bg-gradient);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 60px;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Header */
header {
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 28px;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.marca-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.marca-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px var(--primary-glow);
  overflow: hidden;
  padding: 4px;
}

.marca-titulo h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.marca-titulo p {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* Pestañas de Navegación */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--tabs-bg);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.nav-tab.active {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-icon {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  border-color: var(--primary);
  background: var(--card-light);
  transform: translateY(-1px);
}

/* Botón Conmutador de Tema Claro / Oscuro */
.btn-theme-toggle {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-theme-toggle:hover {
  border-color: var(--primary);
  background: var(--card-light);
}

/* KPIs */
.kpis-bar {
  max-width: 1440px;
  margin: 20px auto 0;
  padding: 0 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-active);
  box-shadow: var(--shadow-md);
}

.kpi-card .kpi-num {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-card.teal .kpi-num { color: var(--teal); }
.kpi-card.pink .kpi-num { color: var(--pink); }
.kpi-card.primary .kpi-num { color: var(--primary); }
.kpi-card.amber .kpi-num { color: var(--amber); }

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin-top: 4px;
}

/* Layout Principal */
.main-container {
  max-width: 1440px;
  margin: 24px auto 0;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1080px) {
  .main-container {
    grid-template-columns: 1fr;
  }
}

/* Panel de Creación */
.panel-creacion {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.panel-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--input-text);
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--input-placeholder);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: all 0.25s ease;
  margin-top: 20px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Barra de Progreso */
.fabricando-box {
  display: none;
  background: var(--card-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 18px;
  animation: fadeIn 0.3s ease;
}

.fabricando-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, var(--teal), var(--primary));
  transition: width 0.4s ease;
}

/* Hangar / Blueprint */
.hangar-seccion {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
}

.hangar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.hangar-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.vacio-box {
  text-align: center;
  padding: 60px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--text-dim);
  background: var(--card-light);
}

.vacio-box p {
  font-size: 15px;
  margin-top: 10px;
}

/* Blueprint Card */
.blueprint-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px;
  animation: fadeIn 0.4s ease;
  box-shadow: var(--shadow-sm);
}

.blueprint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.blueprint-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.badge-agentes-count {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
}

.blueprint-justificacion {
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.blueprint-agentes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.agente-mini-card {
  background: var(--card-light);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.agente-mini-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agente-mini-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.agente-mini-nombre {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.agente-mini-rol {
  font-size: 12px;
  color: var(--text-muted);
}

.io-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--text);
}

.io-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

.io-pill.in { background: rgba(13, 148, 136, 0.12); color: var(--teal); }
.io-pill.out { background: rgba(225, 29, 72, 0.12); color: var(--pink); }

/* PESTAÑA VISUAL: ESCENA ISOMÉTRICA */
.oficina-visual-container {
  max-width: 1440px;
  margin: 20px auto 0;
  padding: 0 28px;
}

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

.oficina-visual-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.vis-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.escena-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  min-height: 580px;
}

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

.escena-svg-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

#svgOficina {
  width: 100%;
  height: 100%;
  max-height: 580px;
}

/* =========================================================
   ANIMACIONES Y ESTILOS INTERACTIVOS DE LOS AGENTES
   (Movimiento en Reposo, Hover Interactivo y Estado Trabajando)
   ========================================================= */
.workstation {
  cursor: pointer;
  outline: none;
}

/* Efecto Hover sobre la estación de trabajo */
.workstation:hover .robot-avatar-group {
  transform: translateY(-9px) scale(1.04);
}

.workstation:hover .robot-shadow {
  transform: scale(0.9) translateY(4px);
  opacity: 0.15;
}

.workstation:hover .workstation-glow-ring {
  opacity: 0.85;
  transform: scale(1.06);
}

.workstation:hover .name-tag-group {
  transform: translateY(-4px);
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.18));
}

.workstation:hover .robot-eye {
  filter: drop-shadow(0 0 8px currentColor);
  animation: eyeBlink 0.4s ease;
}

@keyframes eyeBlink {
  0%, 100% { ry: 3.5; }
  50% { ry: 0.6; }
}

/* Animaciones en Reposo (Idle) */
.robot-avatar-group {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: robotIdleFloat 3.8s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes robotIdleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.robot-shadow {
  transition: transform 0.35s ease, opacity 0.35s ease;
  animation: shadowBreathe 3.8s ease-in-out infinite;
  transform-origin: center center;
}

@keyframes shadowBreathe {
  0%, 100% { transform: scale(1); opacity: 0.22; }
  50% { transform: scale(0.93); opacity: 0.14; }
}

.antenna-orb {
  animation: antennaGlow 2.2s ease-in-out infinite alternate;
}

@keyframes antennaGlow {
  0% { filter: drop-shadow(0 0 2px currentColor); opacity: 0.8; }
  100% { filter: drop-shadow(0 0 8px currentColor); opacity: 1; }
}

.core-reactor {
  animation: reactorPulse 2.4s ease-in-out infinite;
}

@keyframes reactorPulse {
  0%, 100% { r: 3.5; opacity: 0.8; }
  50% { r: 4.8; opacity: 1; filter: drop-shadow(0 0 7px currentColor); }
}

.steam-path {
  animation: steamRise 2.2s infinite ease-out;
}

@keyframes steamRise {
  0% { transform: translateY(0); opacity: 0.6; }
  50% { opacity: 0.85; }
  100% { transform: translateY(-7px); opacity: 0; }
}

.name-tag-group {
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* Estado Trabajando (.working): Cuando el agente procesa tareas */
.workstation.working .robot-avatar-group {
  animation: robotWorkingBounce 0.35s ease-in-out infinite alternate;
}

@keyframes robotWorkingBounce {
  0% { transform: translateY(0) rotate(-1.5deg); }
  100% { transform: translateY(-6px) rotate(1.5deg); }
}

.workstation.working .hand-left {
  animation: typingLeft 0.18s infinite alternate ease-in-out;
}

.workstation.working .hand-right {
  animation: typingRight 0.18s 0.09s infinite alternate ease-in-out;
}

@keyframes typingLeft {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

@keyframes typingRight {
  0% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

.workstation.working .screen-display {
  animation: screenActiveStream 0.5s infinite alternate;
}

@keyframes screenActiveStream {
  0% { filter: drop-shadow(0 0 4px #38BDF8) brightness(1); }
  100% { filter: drop-shadow(0 0 16px #818CF8) brightness(1.35); }
}

.workstation.working .workstation-glow-ring {
  opacity: 1;
  animation: spinRing 3s linear infinite;
}

@keyframes spinRing {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 48; }
}

.workstation.working .robot-eye {
  filter: drop-shadow(0 0 10px currentColor);
  animation: scanningEyes 0.4s infinite alternate ease-in-out;
}

@keyframes scanningEyes {
  0% { transform: translateX(-2px); }
  100% { transform: translateX(2px); }
}

/* Bus de Datos Interdepartamental (Líneas animadas entre puestos) */
.data-bus-path {
  fill: none;
  stroke: var(--line-active);
  stroke-width: 2.5;
  stroke-dasharray: 8 6;
  opacity: 0.4;
  animation: dataBusFlow 1.8s linear infinite;
}

@keyframes dataBusFlow {
  from { stroke-dashoffset: 28; }
  to { stroke-dashoffset: 0; }
}

.data-bus-packet {
  filter: drop-shadow(0 0 8px var(--teal));
}

#canvasConfeti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

#bannerCelebracion {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -150%);
  background: var(--teal);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  padding: 12px 28px;
  border-radius: 14px;
  box-shadow: 0 10px 40px var(--teal-glow);
  transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

#bannerCelebracion.show {
  transform: translate(-50%, 0);
}

/* Feed en Vivo */
.feed-operaciones-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 600px;
  box-shadow: var(--shadow-md);
}

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

.feed-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.feed-lista {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  padding-right: 6px;
}

.feed-item {
  background: var(--card-light);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
  color: var(--text);
}

.feed-time {
  color: var(--teal);
  font-weight: 700;
  font-size: 11px;
}

.pipeline-preview {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.pipeline-preview h4 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pipeline-nodes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.node-item {
  background: var(--card-light);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
}

/* DASHBOARD */
.dashboard-container {
  max-width: 1440px;
  margin: 20px auto 0;
  padding: 0 28px;
}

.dashboard-header h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

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

.dash-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 20px;
  box-shadow: var(--shadow-md);
}

.dash-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

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

.tabla-operaciones {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.tabla-operaciones th {
  background: var(--card-light);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-weight: 700;
}

.tabla-operaciones td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.tabla-operaciones tr:hover td {
  background: var(--card-hover);
}

.io-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.io-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.io-card h4 {
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--teal);
}

/* MARCA BLANCA */
.marca-container {
  max-width: 760px;
  margin: 30px auto 0;
  padding: 0 20px;
}

.marca-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.marca-card h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.marca-card p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 24px;
}

/* Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.modal-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: min(850px, 94vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
  color: var(--text);
}

.modal-body pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-card {
  background: var(--card-light);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-card:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-card.full {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  border: none;
}

.btn-card.full:hover {
  filter: brightness(1.1);
}

.badge-version {
  font-size: 11px;
  background: var(--card-light);
  border: 1px solid var(--line);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px var(--teal-glow);
  z-index: 999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.btn-manual {
  background: rgba(13, 148, 136, 0.1);
  border: 1px solid var(--teal);
  color: var(--teal);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-manual:hover {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 0 14px var(--teal-glow);
  transform: translateY(-1px);
}

/* Indicador de Complejidad y Conmutación Dinámica de Modelos */
.badge-complejidad {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-complejidad.alta {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.badge-complejidad.media {
  background: rgba(217, 119, 6, 0.12);
  border: 1px solid var(--amber);
  color: var(--amber);
}

.badge-complejidad.baja {
  background: rgba(13, 148, 136, 0.12);
  border: 1px solid var(--teal);
  color: var(--teal);
}

.indicador-modelo-en-vivo {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--teal);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100;
  transition: all 0.3s ease;
}

.icon-pulsing {
  display: inline-block;
  animation: pulseRotate 1.5s infinite ease-in-out;
}

@keyframes pulseRotate {
  0% { transform: scale(1); filter: drop-shadow(0 0 2px var(--teal)); }
  50% { transform: scale(1.25); filter: drop-shadow(0 0 8px var(--teal)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 2px var(--teal)); }
}

/* =========================================================
   MÓDULO COWORKING DIGITAL (HUMAN-IN-THE-LOOP & OMNICANAL)
   ========================================================= */
.coworking-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

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

.coworking-header h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

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

.coworking-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.coworking-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  min-height: 650px;
}

/* Columna Izquierda: Lista de Conversaciones */
.inbox-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.inbox-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card-light);
}

.inbox-filter-chips {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chip-btn.active, .chip-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.chat-card:hover {
  background: var(--card-hover);
  border-color: var(--line-active);
  box-shadow: var(--shadow-sm);
}

.chat-card.active {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.chat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-card-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-card-time {
  font-size: 11px;
  color: var(--text-dim);
}

.chat-card-snippet {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.chat-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Columna Derecha: Hilo Activo y Copiloto */
.chat-workspace {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.workspace-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--card-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workspace-contact-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.workspace-contact-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.conversation-scroll {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bubble-msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}

.bubble-cliente {
  align-self: flex-start;
  background: var(--card-light);
  border: 1px solid var(--line);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.bubble-copilot-box {
  align-self: flex-end;
  max-width: 90%;
  width: 90%;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-md);
  border-bottom-right-radius: 2px;
}

.copilot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.copilot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.copilot-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--input-text);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 12px;
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  transition: all 0.2s ease;
}

.copilot-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.calendar-pill-card {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid var(--teal);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.calendar-pill-text {
  font-size: 12.5px;
  color: var(--teal);
  font-weight: 700;
}

.calendar-pill-link {
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.calendar-pill-link:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 10px var(--teal-glow);
}

.approval-toolbar {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-approve {
  background: var(--teal);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-approve:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 15px var(--teal-glow);
}

.btn-edit-send {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-edit-send:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 15px var(--primary-glow);
}

.btn-reject {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reject:hover {
  background: var(--danger);
  color: #fff;
}

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

/* =========================================================
   MÓDULO DE AUTENTICACIÓN, ROLES Y GESTIÓN DE USUARIOS (RBAC)
   ========================================================= */
.user-badge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-light);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  color: var(--text);
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 25px var(--primary-glow);
}

.demo-users-box {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.demo-users-box p {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}

.demo-users-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-demo-user {
  background: var(--card-light);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.btn-demo-user:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}
