/* === Iskra — Paneles de Control === */
/* Tema oscuro, responsive mobile-first */

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161a22;
  --bg-card: #1c1c22;
  --bg-hover: #252530;
  --bg-specs: #161620;
  --border: #2e2e38;
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #6e7681;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --verde: #22c55e;
  --naranja: #f59e0b;
  --rojo: #ef4444;
  --verde-bg: rgba(34, 197, 94, 0.12);
  --naranja-bg: rgba(245, 158, 11, 0.12);
  --rojo-bg: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-sm: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* === Login === */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}

.login-titulo {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitulo {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

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

.login-input::placeholder {
  color: var(--text-muted);
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--rojo);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 20px;
}

/* === Header global === */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

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

.btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-logout {
  color: var(--rojo);
  border-color: var(--rojo);
  font-size: 0.8rem;
}

.btn-logout:hover {
  background: var(--rojo-bg);
}

.btn-accent {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-accent:hover {
  background: rgba(99, 102, 241, 0.1);
}

/* === Portal: Grid de tarjetas === */
.portal-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-card:hover {
  transform: translateY(-2px);
  background: var(--bg-hover);
}

.panel-card.activo {
  cursor: pointer;
}

.panel-card.proximamente {
  opacity: 0.5;
  cursor: default;
}

.panel-card.proximamente:hover {
  transform: none;
  background: var(--bg-card);
}

.panel-icon {
  font-size: 2rem;
}

.panel-nombre {
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.panel-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

.panel-badge.activo {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.panel-badge.proximamente {
  background: rgba(110, 118, 129, 0.15);
  color: var(--text-muted);
}

.panel-actualizacion {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* === Calendario === */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.periodo-label {
  font-size: 1rem;
  font-weight: 600;
  min-width: 200px;
  text-align: center;
}

.vista-group {
  display: flex;
}

.btn-nav {
  font-size: 1.1rem;
  padding: 4px 10px;
  font-weight: 700;
}

.btn-small {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-refresh {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-refresh:hover {
  background: rgba(99, 102, 241, 0.1);
}

.btn-vista {
  border-radius: 0;
  border-right-width: 0;
}

.btn-vista:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-vista:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-right-width: 1px;
}

.btn-vista.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.main-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 120px);
}

/* Vista semana */
.calendario {
  flex: 1;
  overflow-x: auto;
}

.semana-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 100%;
}

.dia-columna {
  border-right: 1px solid var(--border);
  min-width: 140px;
}

.dia-columna:last-child {
  border-right: none;
}

.dia-header {
  padding: 10px 8px;
  text-align: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.dia-header .dia-nombre {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dia-header .dia-numero {
  font-size: 1.3rem;
  font-weight: 700;
}

.dia-header.hoy .dia-numero {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dia-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 200px;
}

/* Tarjeta de tarea */
.tarea-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid var(--border);
  position: relative;
}

.tarea-card:hover {
  background: var(--bg-hover);
}

.tarea-card.verde { border-left-color: var(--verde); background: var(--verde-bg); }
.tarea-card.naranja { border-left-color: var(--naranja); background: var(--naranja-bg); }
.tarea-card.rojo { border-left-color: var(--rojo); background: var(--rojo-bg); }

.tarea-hora {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.tarea-nombre {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.tarea-agente {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.tarea-coste {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.tarea-semaforo {
  float: right;
  font-size: 0.9rem;
}

/* Badge de tipo de tarea */
.tipo-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

/* Vista mes */
.mes-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.mes-header-dia {
  padding: 8px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.mes-header-dia:last-child { border-right: none; }

.mes-celda {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  min-height: 90px;
  cursor: pointer;
  transition: background 0.15s;
}

.mes-celda:nth-child(7n) { border-right: none; }
.mes-celda:hover { background: var(--bg-hover); }
.mes-celda.otro-mes { opacity: 0.3; }
.mes-celda.hoy { background: rgba(99, 102, 241, 0.08); }

.mes-celda-num {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.mes-celda.hoy .mes-celda-num { color: var(--accent); }

.mes-celda-resumen {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.mes-celda-semaforo {
  font-size: 0.85rem;
  margin-left: 4px;
}

/* Vista dia */
.dia-lista {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

.dia-lista-titulo {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.dia-tarea-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border-left: 4px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.dia-tarea-item:hover {
  background: var(--bg-hover);
}

.dia-tarea-item.verde { border-left-color: var(--verde); }
.dia-tarea-item.naranja { border-left-color: var(--naranja); }
.dia-tarea-item.rojo { border-left-color: var(--rojo); }

.dia-tarea-hora-col {
  min-width: 55px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
  padding-top: 2px;
}

.dia-tarea-info { flex: 1; }

.dia-tarea-nombre {
  font-weight: 600;
  font-size: 0.95rem;
}

.dia-tarea-agente {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.dia-tarea-estado {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.dia-tarea-semaforo { font-size: 1.2rem; }

/* Panel lateral */
.panel-lateral {
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel-titulo {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.lista-pendientes { list-style: none; }

.pendiente-item {
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.pendiente-item:hover {
  background: var(--bg-hover);
}

.pendiente-nombre {
  font-weight: 600;
  color: var(--text-primary);
}

.pendiente-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
}

.pendiente-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.pendiente-prioridad {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.sin-tareas {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 20px 8px;
  font-style: italic;
}

.sin-pendientes {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 12px 0;
}

.meta-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === Panel de Detalle de Tarea === */
.detalle-panel {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 20px;
  overflow: hidden;
}

.detalle-panel .detalle-inner {
  background: var(--bg-card);
  border-top: 4px solid var(--verde);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.detalle-panel.detalle-visible .detalle-inner {
  opacity: 1;
  transform: translateY(0);
}

.detalle-cerrar {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.detalle-cerrar:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.detalle-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.detalle-titulo {
  font-size: 1.25rem;
  font-weight: 700;
}

.detalle-tipo-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
}

.detalle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

.detalle-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detalle-campo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detalle-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.detalle-valor {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.detalle-sin-asignar {
  color: var(--text-muted);
  font-style: italic;
}

.detalle-semaforo-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}

/* Descripción y especificaciones — ancho completo */
.detalle-fullwidth {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detalle-texto-block {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

.detalle-specs .detalle-texto-block {
  background: var(--bg-specs);
}

/* Sección de coste */
.detalle-coste {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detalle-coste-valores {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.detalle-coste-item {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.detalle-coste-item strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* === Responsive === */
@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }

  .panel-lateral {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 300px;
  }

  .semana-grid {
    grid-template-columns: repeat(7, minmax(120px, 1fr));
  }

  .detalle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .header {
    padding: 10px 12px;
  }

  .header-logo {
    font-size: 1.1rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-group {
    justify-content: center;
  }

  .vista-group {
    justify-content: center;
  }

  .periodo-label {
    font-size: 0.9rem;
    min-width: auto;
  }

  .semana-grid {
    grid-template-columns: repeat(7, minmax(100px, 1fr));
  }

  .dia-body {
    min-height: 120px;
  }

  .panel-lateral {
    max-height: 250px;
    padding: 10px;
  }

  .mes-celda {
    min-height: 60px;
    padding: 4px;
  }

  .portal-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 24px;
  }

  .detalle-grid {
    grid-template-columns: 1fr;
  }

  .detalle-inner {
    padding: 20px !important;
  }

  .detalle-coste-valores {
    flex-direction: column;
    gap: 8px;
  }
}

/* === Animaciones === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tarea-card, .dia-tarea-item, .pendiente-item, .panel-card {
  animation: fadeIn 0.2s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   ORGANIGRAMA v4 — Layout vertical + ficha técnica completa
   ============================================================ */

.org-page {
  background: #08080f;
}

/* --- Main Layout: 2 columnas --- */
.org-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
}

.org-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* Columna izquierda: árbol (60%) */
.org-col-arbol {
  flex: 0 0 60%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
}

/* Columna derecha: costes + ficha (40%) */
.org-col-derecha {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   NIVELES DEL ÁRBOL VERTICAL
   ============================================================ */
.org-nivel {
  display: flex;
  justify-content: center;
}

.org-nivel-diego,
.org-nivel-iskra {
  display: flex;
  justify-content: center;
}

/* Hijos: columna vertical a la izquierda */
.org-nivel-hijos {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  padding-left: 40px;
}

/* Cada fila de hijo: línea horizontal + nodo */
.org-hijo-fila {
  display: flex;
  align-items: center;
  gap: 0;
}

/* ============================================================
   LÍNEAS DE CONEXIÓN — CSS puro
   ============================================================ */
.org-linea-vertical {
  width: 2px;
  height: 40px;
  background: #3f3f46;
  margin: 0 auto;
}

.org-linea-horizontal {
  width: 32px;
  height: 2px;
  background: #3f3f46;
  flex-shrink: 0;
}

/* ============================================================
   NODOS — Floating Cards
   ============================================================ */
.org-nodo {
  position: relative;
  cursor: pointer;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(20, 20, 30, 0.9);
  border: 2px solid var(--nodo-color, #52525b);
  box-shadow: 0 0 20px rgba(82, 82, 91, 0.2);
  opacity: 0;
  transform: translateY(20px);
  animation: orgNodeAppear 0.5s ease forwards;
  animation-delay: var(--nodo-delay, 0s);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

@keyframes orgNodeAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.org-nodo:hover {
  transform: scale(1.03);
  box-shadow: 0 0 28px var(--nodo-glow, rgba(139, 92, 246, 0.25));
}

.org-nodo-sel {
  box-shadow: 0 0 28px var(--nodo-glow, #6366f1), 0 0 56px rgba(139, 92, 246, 0.12) !important;
  border-color: var(--nodo-glow, #6366f1) !important;
}

/* Click pulse */
.org-nodo-clicked {
  animation: orgPulseClick 0.3s ease !important;
  opacity: 1 !important;
  transform: translateY(0) !important;
}

@keyframes orgPulseClick {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

/* Status dot — absolute top-right */
.org-nodo-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.org-dot-pulse {
  animation: orgDotPulse 2s ease-in-out infinite;
}

.org-dot-working {
  animation: orgDotWorking 1s ease-in-out infinite;
}

@keyframes orgDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

@keyframes orgDotWorking {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 6px #f59e0b; }
  50% { opacity: 0.5; transform: scale(1.5); box-shadow: 0 0 14px #f59e0b; }
}

/* Emoji */
.org-nodo-emoji {
  font-size: 36px;
  display: block;
  margin-bottom: 6px;
  line-height: 1;
}

/* Name */
.org-nodo-nombre {
  font-size: 15px;
  font-weight: 700;
  color: #e4e4e7;
}

/* Model subtitle */
.org-nodo-modelo {
  font-size: 11px;
  color: #71717a;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Working text */
.org-nodo-trabajando {
  font-size: 10px;
  color: #f59e0b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  animation: orgDotWorking 1s ease-in-out infinite;
}

/* --- DIEGO node (gold border) --- */
.org-nodo-diego {
  width: 200px;
  border: 2px solid #d4a853;
  box-shadow: 0 0 20px rgba(212, 168, 83, 0.25);
}

.org-nodo-diego:hover {
  box-shadow: 0 0 36px rgba(212, 168, 83, 0.4);
}

/* --- ISKRA node (violet, pulsing glow, bigger) --- */
.org-nodo-iskra {
  width: 240px;
  border: 2px solid #8b5cf6;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  animation: orgNodeAppear 0.5s ease forwards, iskraPulseGlow 2s ease-in-out infinite;
  animation-delay: var(--nodo-delay, 0s), 0s;
}

.org-nodo-iskra .org-nodo-emoji {
  font-size: 48px;
}

.org-nodo-iskra .org-nodo-nombre {
  font-size: 20px;
}

@keyframes iskraPulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.55), 0 0 80px rgba(139, 92, 246, 0.15); }
}

/* --- Agent child nodes (compact) --- */
.org-nodo-agente {
  width: 170px;
  padding: 14px 16px;
}

.org-nodo-agente .org-nodo-emoji {
  font-size: 28px;
  margin-bottom: 4px;
}

.org-nodo-agente .org-nodo-nombre {
  font-size: 13px;
}

/* ============================================================
   COSTES PANEL — Glass sidebar (fixed right or below)
   ============================================================ */
.org-costes-panel {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
}

.org-costes-glass {
  background: rgba(20, 20, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 16px;
  padding: 24px;
}

.org-costes-titulo {
  font-size: 18px;
  font-weight: 700;
  color: #e4e4e7;
  margin-bottom: 20px;
}

/* Cost blocks */
.org-coste-bloque {
  padding: 8px 0;
}

.org-coste-label {
  font-size: 12px;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.org-coste-valor {
  font-size: 24px;
  font-weight: 700;
  color: #e4e4e7;
}

.org-coste-nota {
  font-size: 10px;
  color: #52525b;
  margin-top: 2px;
}

/* Separator */
.org-costes-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 12px 0;
}

/* Distribution sub-title */
.org-costes-dist-titulo {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #71717a;
  margin-bottom: 12px;
}

/* Distribution rows */
.org-dist-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.78rem;
}

.org-dist-name {
  flex: 1;
  min-width: 0;
  color: #a1a1aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.org-dist-pct {
  font-size: 12px;
  color: #71717a;
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

.org-dist-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  overflow: hidden;
}

.org-dist-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* ============================================================
   DETALLE PANEL — Slide-up bottom panel
   ============================================================ */
.org-detalle-panel {
  margin-top: 28px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.4s ease;
}

.org-detalle-panel.org-detalle-open {
  max-height: 600px;
  opacity: 1;
}

.org-detalle-inner {
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 3px solid var(--detalle-accent, #6366f1);
  border-radius: 16px 16px 16px 16px;
  padding: 32px;
  position: relative;
}

/* Close button */
.org-detalle-cerrar {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #71717a;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.org-detalle-cerrar:hover {
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.1);
}

/* Grid 2 columns */
.org-detalle-grid {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 32px;
}

/* Detail columns */
.org-detalle-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header inside detail */
.org-detalle-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.org-detalle-emoji {
  font-size: 40px;
  line-height: 1;
}

.org-detalle-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.org-detalle-titulo {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e4e4e7;
}

.org-detalle-estado {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.org-detalle-estado-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* Fields */
.org-detalle-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.org-detalle-field-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #52525b;
}

.org-detalle-field-value {
  font-size: 0.88rem;
  color: #a1a1aa;
  line-height: 1.6;
}

.org-detalle-field-normas {
  background: rgba(15, 15, 25, 0.6);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* Mini cost cards */
.org-detalle-costes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.org-mini-coste {
  background: rgba(15, 15, 25, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.org-mini-coste-label {
  font-size: 12px;
  color: #71717a;
  margin-bottom: 6px;
}

.org-mini-coste-val {
  font-size: 18px;
  font-weight: 700;
  color: #e4e4e7;
}

/* ============================================================
   RESPONSIVE — Organigrama Redesign
   ============================================================ */
@media (max-width: 1024px) {
  .org-layout {
    flex-direction: column;
  }

  .org-costes-panel {
    width: 100%;
    position: static;
  }

  .org-detalle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .org-main {
    padding: 16px 12px;
  }

  .org-tier-hijos {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }

  .org-tree {
    gap: 36px;
  }

  .org-nodo-diego {
    width: 180px;
  }

  .org-nodo-iskra {
    width: 200px;
  }

  .org-nodo-agente {
    width: 150px;
  }

  .org-svg-lines {
    display: none;
  }

  .org-detalle-inner {
    padding: 20px;
  }

  .org-detalle-costes {
    grid-template-columns: 1fr;
  }

  .org-detalle-panel.org-detalle-open {
    max-height: 900px;
  }
}
