/* ============================================================================
   Plataforma de Agentes Colcamer — Identidad alineada con colcamer.com
   Tema claro: vidrio blanco translúcido ("liquid glass") sobre lienzo
   gris-azulado, azul corporativo #003388 + azul medio #5384C4 (logo MOTOS) y
   el degradado del velocímetro del logo (amarillo→naranja→rojo) como acento.
   ========================================================================== */

:root {
  /* --- Marca Colcamer (extraída de colcamer.com y su logo) --- */
  --azul: #003388;            /* azul corporativo (color principal del sitio) */
  --azul-hi: #1A4FA8;         /* hover / gradientes */
  --azul-lo: #002566;         /* activo */
  --azul-medio: #5384C4;      /* azul del "MOTOS" del logo */
  --azul-soft: rgba(0, 51, 136, 0.10);

  /* Velocímetro del logo (acento de energía). */
  --gauge-amarillo: #F5B90F;
  --gauge-naranja: #F28C1E;
  --gauge-rojo: #E23A24;
  --gauge-gradiente: linear-gradient(150deg, #F5B90F 0%, #F28C1E 55%, #E23A24 100%);

  /* --- Lienzo claro --- */
  --lienzo: #F2F5FA;
  --tinta: #16233A;           /* texto principal (azul tinta) */
  --tinta-2: #33415C;
  --muted: #5E6B80;
  --linea: rgba(22, 35, 58, 0.10);

  /* --- Vidrio (liquid glass, variante clara) --- */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-fuerte: rgba(255, 255, 255, 0.78);
  --glass-claro: rgba(0, 51, 136, 0.05);   /* hover sutil azulado */
  --glass-borde: rgba(255, 255, 255, 0.75);
  --glass-sheen: rgba(255, 255, 255, 0.85);
  --blur: 26px;

  /* --- Estados semánticos (AA sobre claro) --- */
  --ok: #1E7E3E;      --ok-soft: rgba(30, 126, 62, 0.13);
  --warn: #9A6200;    --warn-soft: rgba(178, 106, 0, 0.14);
  --err: #C62828;     --err-soft: rgba(198, 40, 40, 0.12);
  --info: #0F5CC0;    --info-soft: rgba(15, 92, 192, 0.12);
  --idle: #64748B;    --idle-soft: rgba(100, 116, 139, 0.13);

  /* --- Sombras (frías, suaves) --- */
  --sombra-sm: 0 1px 2px rgba(22, 35, 58, 0.08);
  --sombra-md: 0 8px 28px rgba(22, 35, 58, 0.12);
  --sombra-lg: 0 20px 60px rgba(22, 35, 58, 0.20);

  /* --- Radios --- */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 30px;
  --r-pill: 999px;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--tinta);
  background: var(--lienzo);
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* la app gestiona su propio scroll interno */
}

/* ============================================================================
   Fondo liquid glass (claro con blobs azules + naranja del velocímetro)
   ========================================================================== */
.fondo {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(130% 130% at 85% 0%, #FAFCFF 0%, #F2F5FA 45%, #E8EDF5 100%);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  will-change: transform;
}
.blob-1 {
  width: 48vw; height: 48vw;
  top: -14vw; left: -10vw;
  background: radial-gradient(circle at 30% 30%, #7FA8DC, #5384C4 70%);
  animation: flotar1 24s ease-in-out infinite;
}
.blob-2 {
  width: 42vw; height: 42vw;
  bottom: -16vw; right: -8vw;
  background: radial-gradient(circle at 40% 40%, #2B5CAD, #003388 72%);
  opacity: 0.34;
  animation: flotar2 28s ease-in-out infinite;
}
.blob-3 {
  width: 34vw; height: 34vw;
  top: 20vh; right: 14vw;
  background: radial-gradient(circle at 50% 50%, #F8C468, #F28C1E 72%);
  opacity: 0.30;
  animation: flotar3 32s ease-in-out infinite;
}
.blob-4 {
  width: 30vw; height: 30vw;
  bottom: 6vh; left: 16vw;
  background: radial-gradient(circle at 50% 50%, #9DBCE4, #6699CC 72%);
  opacity: 0.38;
  animation: flotar1 30s ease-in-out infinite reverse;
}
/* Grano sutil: textura de papel. */
.grano {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}
@keyframes flotar1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vw, 5vh) scale(1.08); }
}
@keyframes flotar2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-5vw, -4vh) scale(1.1); }
}
@keyframes flotar3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-3vw, 4vh) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
}

/* ============================================================================
   Material de vidrio reutilizable
   ========================================================================== */
.glass {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-borde);
  box-shadow: var(--sombra-md),
              inset 0 1px 0 var(--glass-sheen),
              inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
/* Brillo especular en el borde superior (reflejo de "liquid glass"). */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.65) 0%,
    rgba(255, 255, 255, 0.12) 22%,
    rgba(255, 255, 255, 0) 60%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(255, 255, 255, 0.96); }
}

.texto-muted { color: var(--muted); }
.oculto { display: none !important; }

/* ============================================================================
   Estructura de la app (dos paneles)
   ========================================================================== */
.app {
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
}

/* --- Barra lateral --- */
.sidebar {
  border-radius: var(--r-lg);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.marca {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--tinta);
  padding: 6px 8px 18px;
}
.marca-chip {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  color: #fff;
  background: var(--gauge-gradiente);
  box-shadow: var(--sombra-sm), inset 0 1px 0 rgba(255,255,255,0.45);
  flex-shrink: 0;
}
.marca-chip-grande { width: 60px; height: 60px; border-radius: 18px; }
.marca-chip-grande .lucide { width: 30px; height: 30px; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.2; }
.marca-texto strong { font-size: 15px; font-weight: 600; color: var(--azul); }
.marca-texto small { color: var(--muted); font-size: 12px; }

.sidebar-seccion { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sidebar-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 8px 10px;
}
.agentes-lista {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
}

.agente-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  font: inherit;
  color: var(--tinta);
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.agente-item:hover { background: var(--glass-claro); }
.agente-item.activo {
  background: var(--glass-bg-fuerte);
  border-color: var(--glass-borde);
  box-shadow: var(--sombra-sm);
}
.agente-avatar {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--azul-soft);
  color: var(--azul);
  flex-shrink: 0;
}
.agente-avatar .lucide { width: 18px; height: 18px; }
.agente-item-cuerpo { flex: 1; min-width: 0; }
.agente-item-nombre {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.agente-item-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.punto-estado {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8);
}
.punto-activo { background: var(--ok); }
.punto-en_ejecucion { background: var(--info); animation: latido 1.2s ease-in-out infinite; }
.punto-error { background: var(--err); }
.punto-inactivo { background: var(--idle); }
@keyframes latido {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.agente-skeleton {
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(0,51,136,0.06), rgba(0,51,136,0.02), rgba(0,51,136,0.06));
  background-size: 200% 100%;
  animation: brillar 1.4s ease infinite;
}
@keyframes brillar { to { background-position: -200% 0; } }

/* Botón "Nuevo agente" bajo la lista. */
.boton-nuevo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px dashed rgba(0, 51, 136, 0.30);
  background: transparent;
  color: var(--tinta-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.boton-nuevo:hover { background: var(--azul-soft); color: var(--azul); border-color: var(--azul); }
.boton-nuevo .lucide { width: 16px; height: 16px; }

/* Pestaña "Rendimiento" bajo el agente seleccionado. */
.agente-subtab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 26px);
  margin: 2px 0 4px 26px;
  padding: 7px 10px;
  border: none;
  border-left: 2px solid rgba(0, 51, 136, 0.18);
  border-radius: 0 10px 10px 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.agente-subtab:hover { background: var(--azul-soft); color: var(--azul); }
.agente-subtab.activo {
  background: var(--azul-soft);
  color: var(--azul);
  border-left-color: var(--azul);
}
.agente-subtab .lucide { width: 14px; height: 14px; }

.sidebar-pie {
  border-top: 1px solid var(--linea);
  padding-top: 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-linea { font-size: 12px; color: var(--muted); padding: 0 8px 8px; }
.pie-enlace {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--tinta-2);
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}
.pie-enlace:hover { background: var(--azul-soft); color: var(--azul); }
.pie-enlace .lucide { width: 15px; height: 15px; }

/* ============================================================================
   Panel principal (chat / bienvenida / ajustes)
   ========================================================================== */
.chat-panel {
  border-radius: var(--r-lg);
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* --- Bienvenida (sin agente) --- */
.bienvenida {
  margin: auto;
  max-width: 640px;
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.bienvenida-chip {
  display: grid;
  place-items: center;
  width: 62px; height: 62px;
  border-radius: 20px;
  color: #fff;
  background: var(--gauge-gradiente);
  box-shadow: var(--sombra-md), inset 0 1px 0 rgba(255,255,255,0.45);
  margin-bottom: 6px;
}
.bienvenida-chip .lucide { width: 30px; height: 30px; }
.bienvenida-titulo {
  font-family: var(--serif);
  font-size: 38px;
  line-height: 1.12;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--azul);
}
.bienvenida-sub { color: var(--muted); font-size: 15.5px; max-width: 470px; }
.bienvenida-agentes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  width: 100%;
  margin-top: 12px;
}
.tarjeta-agente {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--glass-bg-fuerte);
  border: 1px solid var(--glass-borde);
  box-shadow: var(--sombra-sm);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--tinta);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.tarjeta-agente:hover {
  transform: translateY(-2px);
  box-shadow: var(--sombra-md);
  border-color: rgba(0, 51, 136, 0.35);
}
.tarjeta-agente .agente-item-nombre { font-size: 14.5px; }

/* --- Cabecera del chat / ajustes --- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ajustes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--linea);
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0));
}
.chat-header-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-header-id h2 {
  font-size: 17px;
  font-weight: 600;
  text-transform: capitalize;
  line-height: 1.2;
}
.chat-header-id .texto-muted { font-size: 12.5px; }
.chat-header-id .agente-avatar { width: 40px; height: 40px; border-radius: 13px; }
.chat-header-acciones { display: flex; align-items: center; gap: 12px; }

.boton-icono {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 1px solid var(--linea);
  background: rgba(255, 255, 255, 0.6);
  color: var(--tinta-2);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.boton-icono:hover { background: var(--azul-soft); color: var(--azul); }
.boton-icono .lucide { width: 18px; height: 18px; }

/* --- Zona de mensajes --- */
.mensajes {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.turno {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
}
.turno-user { flex-direction: row-reverse; }
.turno-avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
  margin-top: 2px;
}
.turno-user .turno-avatar { background: rgba(0, 51, 136, 0.12); color: var(--azul); }
.turno-agente .turno-avatar { background: var(--azul-soft); color: var(--azul); }
.turno-avatar .lucide { width: 16px; height: 16px; }

.burbuja {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 78%;
  word-wrap: break-word;
}
.turno-user .burbuja {
  background: linear-gradient(160deg, var(--azul-hi), var(--azul));
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: var(--sombra-sm);
}
.turno-agente .burbuja {
  background: var(--glass-bg-fuerte);
  border: 1px solid var(--glass-borde);
  border-bottom-left-radius: 6px;
  box-shadow: var(--sombra-sm);
}
.burbuja-estado {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
.burbuja-estado.est-ok { color: var(--ok); }
.burbuja-estado.est-error { color: var(--err); }
.burbuja-estado .lucide { width: 14px; height: 14px; }

.burbuja-detalle { margin-top: 10px; }
.burbuja-detalle summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--azul);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.burbuja-detalle summary::-webkit-details-marker { display: none; }
.chips-resumen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-resumen {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--azul-soft);
  color: var(--azul);
}

/* Indicador "escribiendo…" */
.escribiendo { display: inline-flex; gap: 5px; align-items: center; padding: 4px 2px; }
.escribiendo span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: puntear 1.2s ease-in-out infinite;
}
.escribiendo span:nth-child(2) { animation-delay: 0.2s; }
.escribiendo span:nth-child(3) { animation-delay: 0.4s; }
@keyframes puntear {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* --- Badges de estado --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-activo { color: var(--ok); background: var(--ok-soft); }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-en_ejecucion { color: var(--info); background: var(--info-soft); }
.badge-error { color: var(--err); background: var(--err-soft); }
.badge-inactivo { color: var(--idle); background: var(--idle-soft); }

/* --- Composer --- */
.composer-zona { padding: 8px 22px 18px; }
.sugerencias {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto 10px;
}
.chip-sugerencia {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(0, 51, 136, 0.18);
  background: rgba(255, 255, 255, 0.6);
  color: var(--tinta-2);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, color 150ms ease;
}
.chip-sugerencia:hover { background: var(--azul-soft); color: var(--azul); transform: translateY(-1px); }

.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 18px;
  border-radius: var(--r-xl);
  background: var(--glass-bg-fuerte);
}
.boton-adjuntar {
  border: none;
  background: transparent;
  flex-shrink: 0;
}
.boton-adjuntar:hover { background: var(--azul-soft); }
.composer-entrada {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--tinta);
  max-height: 160px;
  padding: 8px 0;
}
.composer-entrada:focus { outline: none; }
.composer-entrada::placeholder { color: var(--muted); }
.boton-enviar {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(160deg, var(--azul-hi), var(--azul));
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  box-shadow: var(--sombra-sm), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: filter 150ms ease, transform 150ms ease, opacity 150ms ease;
}
.boton-enviar:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.boton-enviar:disabled { opacity: 0.4; cursor: not-allowed; }
.boton-enviar .lucide { width: 20px; height: 20px; }
.composer-nota {
  max-width: 760px;
  margin: 9px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ============================================================================
   Ajustes
   ========================================================================== */
.ajustes-cuerpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.bloque-ajustes {
  background: var(--glass-bg-fuerte);
  border: 1px solid var(--glass-borde);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--sombra-sm);
}
.bloque-ajustes h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--azul);
}
.bloque-ajustes h3 .lucide { width: 17px; height: 17px; color: var(--gauge-naranja); }
.fila-dato {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--linea);
  font-size: 14px;
}
.fila-dato:last-child { border-bottom: none; }
.fila-dato dt { color: var(--muted); font-weight: 500; }
.fila-dato dd { font-weight: 600; text-align: right; }
.chip-si { color: var(--ok); background: var(--ok-soft); padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.chip-no { color: var(--err); background: var(--err-soft); padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }

/* Fila de agente en ajustes: toggle + cron. */
.ajuste-agente {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--linea);
  flex-wrap: wrap;
}
.ajuste-agente:last-child { border-bottom: none; }
.ajuste-agente .agente-item-cuerpo { flex: 1; min-width: 160px; }
.ajuste-cron {
  width: 150px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid rgba(0, 51, 136, 0.20);
  background: #FFFFFF;
  color: var(--tinta);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.ajuste-cron:focus { outline: 2px solid var(--azul-medio); outline-offset: 1px; }
.boton-mini {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0, 51, 136, 0.20);
  background: rgba(255, 255, 255, 0.7);
  color: var(--tinta-2);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.boton-mini:hover { background: var(--azul-soft); color: var(--azul); }

/* --- Rendimiento: tarjeta por agente con cifras y mini gráfica --- */
.tarjeta-rend { transition: border-color 150ms ease, box-shadow 150ms ease; }
.rend-destacada {
  border-color: rgba(0, 51, 136, 0.45);
  box-shadow: 0 0 0 3px var(--azul-soft), var(--sombra-sm);
}
.rend-cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.rend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.rend-celda {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--linea);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}
.rend-valor {
  font-size: 22px;
  font-weight: 700;
  color: var(--azul);
  line-height: 1.2;
}
.rend-valor-ok { color: var(--ok); }
.rend-valor-error { color: var(--err); }
/* Fechas: más compactas para que nunca se salgan de la tarjeta. */
.rend-valor-fecha { font-size: 15px; line-height: 1.35; padding-top: 4px; }
.rend-etiqueta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.mini-grafica {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 66px;
  padding: 4px 2px 0;
}
.mini-dia {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.mini-barras {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 44px;
}
.mini-barra {
  width: 12px;
  border-radius: 4px 4px 2px 2px;
  display: inline-block;
}
.mini-ok { background: linear-gradient(180deg, #2FA45C, var(--ok)); }
.mini-err { background: linear-gradient(180deg, #E05C4B, var(--err)); }
.mini-vacia { background: rgba(22, 35, 58, 0.12); width: 12px; }
.mini-etiqueta { font-size: 10px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* --- Dashboard de rendimiento: KPIs, gráfica grande, anillo y orígenes --- */
.rend-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi-rend {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg-fuerte);
  border: 1px solid var(--glass-borde);
  border-radius: var(--r-md);
  box-shadow: var(--sombra-sm);
  padding: 14px 16px;
}
.kpi-rend-icono {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--azul-soft);
  color: var(--azul);
  flex-shrink: 0;
}
.kpi-rend-icono .lucide { width: 20px; height: 20px; }
.kpi-rend-err { background: var(--err-soft); color: var(--err); }
.kpi-rend-valor {
  font-size: 24px;
  font-weight: 700;
  color: var(--azul);
  line-height: 1.15;
}

.rend-fila2 {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr);
  gap: 12px;
  align-items: stretch;
}
.rend-lateral { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 980px) {
  .rend-fila2 { grid-template-columns: 1fr; }
}

.grafica-bloque { display: flex; flex-direction: column; }
.grafica-zona { display: flex; gap: 10px; flex: 1; }
.grafica-eje {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 132px;
  padding-bottom: 18px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  min-width: 20px;
}
.grafica-barras {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-left: 1px solid var(--linea);
  border-bottom: 1px solid var(--linea);
  padding: 0 4px;
}
.grafica-dia {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
}
.grafica-pila {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 1px;
  width: 100%;
  max-width: 26px;
}
.grafica-barra {
  width: 100%;
  border-radius: 4px 4px 2px 2px;
  display: inline-block;
  transition: filter 150ms ease;
}
.grafica-pila:hover .grafica-barra { filter: brightness(1.12); }
.grafica-leyenda {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.grafica-leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda-punto {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.anillo-bloque { text-align: center; }
.anillo-cont { position: relative; width: 140px; margin: 0 auto; }
.anillo-svg { width: 140px; height: 140px; display: block; }
.anillo-centro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.anillo-num { font-size: 26px; font-weight: 700; color: var(--azul); }

.origen-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.origen-nombre { font-size: 12.5px; font-weight: 500; color: var(--tinta-2); min-width: 92px; }
.origen-pista {
  flex: 1;
  height: 10px;
  border-radius: var(--r-pill);
  background: rgba(22, 35, 58, 0.08);
  overflow: hidden;
}
.origen-barra {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--azul-medio), var(--azul));
  transition: width 300ms ease;
}
.origen-num { font-size: 13px; font-weight: 700; color: var(--azul); min-width: 24px; text-align: right; }

.rend-seccion-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}
.rend-seccion-titulo .lucide { width: 15px; height: 15px; }

/* Toggle habilitar/deshabilitar (44x24). */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-pista {
  position: absolute;
  inset: 0;
  border-radius: var(--r-pill);
  background: rgba(22, 35, 58, 0.18);
  transition: background 150ms ease;
}
.toggle-pista::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sombra-sm);
  transition: transform 150ms ease;
}
.toggle input:checked + .toggle-pista { background: var(--azul); }
.toggle input:checked + .toggle-pista::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-pista { outline: 2px solid var(--azul-medio); outline-offset: 2px; }

/* ============================================================================
   Login
   ========================================================================== */
.login-escena {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-tarjeta {
  width: min(400px, 100%);
  border-radius: var(--r-lg);
  padding: 40px 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.login-titulo {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  margin-top: 12px;
  color: var(--azul);
}
.login-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.campo-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.campo-input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 51, 136, 0.20);
  background: #FFFFFF;
  color: var(--tinta);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 150ms ease;
}
.campo-input:focus { outline: none; border-color: var(--azul); }
.campo-input::placeholder { color: var(--muted); }
.boton-login {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 14.5px;
  margin-top: 4px;
}
.login-error {
  color: var(--err);
  background: var(--err-soft);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}
.login-nota { color: var(--muted); font-size: 11.5px; margin-top: 18px; }
.login-nota code {
  font-family: ui-monospace, Menlo, monospace;
  background: rgba(0, 51, 136, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ============================================================================
   Modal (nuevo agente)
   ========================================================================== */
.modal-fondo {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 25, 55, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: aparecerSuave 180ms ease;
}
@keyframes aparecerSuave { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border-radius: var(--r-lg);
  background: var(--glass-bg-fuerte);
  animation: entrarPanel 220ms ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--linea);
}
.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--azul);
}
.modal-header h3 .lucide { width: 18px; height: 18px; color: var(--gauge-naranja); }
.modal-cuerpo {
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pasos-titulo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  color: var(--ok);
}
.pasos-titulo .lucide { width: 18px; height: 18px; }
.pasos-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 22px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--tinta-2);
}
.pasos-lista li::marker { color: var(--gauge-naranja); font-weight: 700; }
.pasos-lista code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: rgba(0, 51, 136, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ============================================================================
   Panel lateral de logs
   ========================================================================== */
.panel-logs {
  position: fixed;
  top: 18px; right: 18px; bottom: 18px;
  width: min(460px, calc(100vw - 36px));
  border-radius: var(--r-lg);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg-fuerte);
  animation: entrarPanel 220ms ease;
}
@keyframes entrarPanel {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.panel-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--linea);
}
.panel-logs-header h3 { font-size: 15px; font-weight: 600; }
.panel-logs-cuerpo { flex: 1; overflow-y: auto; padding: 18px 20px; }

/* El visor de logs se mantiene oscuro (contraste tipo consola) en azul marino. */
.visor-logs {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: #0C1B33;
  color: #D8E0EC;
  border-radius: var(--r-md);
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.visor-logs .log-info { color: #D8E0EC; }
.visor-logs .log-warn { color: #F5B90F; }
.visor-logs .log-error { color: #FF8A70; }
.log-run-titulo {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 16px 0 8px;
}
.log-run-titulo:first-child { margin-top: 0; }

/* ============================================================================
   Toasts
   ========================================================================== */
.toasts {
  position: fixed;
  right: 22px; bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}
.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 260px;
  max-width: 380px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--glass-bg-fuerte);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-borde);
  box-shadow: var(--sombra-lg);
  font-size: 13.5px;
  font-weight: 500;
  animation: entrarToast 220ms ease;
}
@keyframes entrarToast {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast .lucide { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--ok); }
.toast-success .lucide { color: var(--ok); }
.toast-error { border-left: 3px solid var(--err); }
.toast-error .lucide { color: var(--err); }
.toast-info { border-left: 3px solid var(--info); }
.toast-info .lucide { color: var(--info); }

/* ============================================================================
   Foco accesible, scrollbars y responsive
   ========================================================================== */
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--azul-medio);
  outline-offset: 2px;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(22, 35, 58, 0.22);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(22, 35, 58, 0.36); background-clip: padding-box; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .sidebar { max-height: none; }
  .chat-panel { min-height: 76vh; }
  .bienvenida-titulo { font-size: 30px; }
  .burbuja { max-width: 88%; }
}
