/* ==========================================================================
   BOT ADELANTO DE CITAS — ESTILOS GLOBALES & SISTEMA DE DISEÑO (100vh NO-SCROLL)
   ========================================================================== */

:root {
  /* Color Palette - Dark Sleek Modern Theme */
  --bg-primary: #07090e;
  --bg-secondary: #0d111a;
  --bg-tertiary: #141a27;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --border-accent: rgba(59, 130, 246, 0.3);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-green-hover: #059669;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-amber: #f59e0b;
  --accent-amber-hover: #d97706;

  /* Console Specific Colors */
  --console-bg: #05070b;
  --console-text: #cbd5e1;
  --console-success: #10b981;
  --console-error: #f87171;
  --console-warning: #fbbf24;
  --console-info: #38bdf8;
  --console-dim: #475569;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, "Courier New", monospace;

  /* Layout dimensions */
  --header-height: 58px;
  --tabs-height: 48px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden; /* Prohibido scroll de página */
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */

.login-wrapper {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #151d30 0%, #07090e 70%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: fadeIn 0.4s ease-out;
}

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

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.15));
  border: 1px solid var(--border-accent);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 2rem;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   APP HEADER & SHELL (100vh Container)
   ========================================================================== */

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  height: var(--header-height);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid var(--border-accent);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.2;
}

.brand-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

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

.header-main-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  margin: 0;
  text-align: center;
}

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

/* ==========================================================================
   TABS BAR (Slots Fijos = MAX_RUNS, siempre visibles)
   ========================================================================== */

.tabs-bar {
  height: var(--tabs-height);
  flex-shrink: 0;
  background: rgba(13, 17, 26, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 0.5rem;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

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

.tab-item.active {
  background: var(--bg-tertiary);
  border-color: rgba(59, 130, 246, 0.3);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.tab-label {
  font-weight: 600;
}

.tab-mode-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.tab-item.active .tab-mode-tag {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

/* Status dots */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-idle { background-color: var(--text-faint); }
.status-dot-corriendo {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
  animation: pulseGreen 1.5s infinite;
}
.status-dot-awaiting_choice {
  background-color: var(--accent-amber);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
  animation: pulseAmber 1.2s infinite;
}
.status-dot-detenido { background-color: var(--text-faint); }
.status-dot-agendado {
  background-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.9);
}
.status-dot-bloqueado { background-color: var(--accent-red); }
.status-dot-sin_citas { background-color: var(--accent-amber); }
.status-dot-error { background-color: var(--accent-red); }

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulseAmber {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 7px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* ==========================================================================
   WORKSPACE & PANELS (Left: Config / Right: Console)
   ========================================================================== */

.workspace-container {
  flex: 1;
  overflow: hidden; /* Contenedor principal sin scroll */
  position: relative;
}

.slot-view {
  display: none;
  height: 100%;
  width: 100%;
}

.slot-view.active {
  display: grid;
  grid-template-columns: 460px 1fr;
  height: 100%;
  overflow: hidden;
}

/* COLUMNA IZQUIERDA: CONFIGURACIÓN */
.config-panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Solo el panel hace scroll interno si la pantalla es baja */
  padding: 1.25rem 1.5rem;
}

/* Custom scrollbar para panel config */
.config-panel::-webkit-scrollbar {
  width: 6px;
}
.config-panel::-webkit-scrollbar-track {
  background: transparent;
}
.config-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.config-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

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

/* Mode selector block below bot title */
.mode-selector-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.4rem 0 0.35rem 0;
}

.mode-selector-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mode-selector {
  display: inline-flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.mode-option {
  position: relative;
  cursor: pointer;
  margin: 0;
  user-select: none;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 34px;
}

.mode-option input:checked + .mode-pill {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

/* Drag & Drop Zone */
.dropzone-area {
  background: rgba(59, 130, 246, 0.03);
  border: 1.5px dashed rgba(59, 130, 246, 0.3);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone-area:hover, .dropzone-area.drag-over {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

.dropzone-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.dropzone-icon {
  color: var(--accent-blue);
  flex-shrink: 0;
}

.dropzone-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dropzone-text strong {
  color: #93c5fd;
}

/* Grid de Formulario */
.config-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.85rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.req {
  color: var(--accent-red);
}

.field-hint {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-faint);
}

.field-optional {
  font-size: 0.7rem;
  font-weight: 400;
  color: #38bdf8;
}

/* Input Fields */
.form-input, .form-select {
  width: 100%;
  height: 36px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 0.75rem;
  font-size: 0.82rem;
  color: var(--text-main);
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Password Toggle Wrapper */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper .form-input {
  padding-right: 36px;
}

.btn-toggle-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-toggle-password:hover {
  color: var(--text-main);
}

/* ==========================================================================
   DATEPICKER CUSTOM — Guarda dd.mm.aaaa SIN sombra de números
   (Overlay de date nativo superpuesto transparente, solo icono visible)
   ========================================================================== */

.date-picker-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.date-picker-wrapper .date-text-input {
  padding-right: 36px;
  letter-spacing: 0.03em;
}

.date-native-overlay {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  opacity: 0.001; /* Completamente invisible para evitar sombras nativas */
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

/* Icono de calendario visible en el input */
.date-picker-wrapper::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0.7;
}

.date-picker-wrapper:hover::after {
  opacity: 1;
}

/* ==========================================================================
   TOGGLE SWITCH (NECESITA_CAS)
   ========================================================================== */

.toggle-wrapper {
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-top: 0.2rem;
}

.switch-container {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: 0.25s;
  border-radius: 22px;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

.switch-container input:checked + .switch-slider {
  background-color: var(--accent-green);
}

.switch-container input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.switch-label-group {
  display: flex;
  flex-direction: column;
}

.switch-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.switch-description {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Form Actions */
.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   COLUMNA DERECHA: CONSOLA EN VIVO & SSE
   ========================================================================== */

.console-panel {
  background: var(--bg-primary);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Solo terminal-screen hace scroll */
}

.console-header {
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.console-status-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.console-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
}

.console-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tool-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

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

.autoscroll-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* ==========================================================================
   AWAITING CHOICE BANNER (Elección interactiva en la pestaña)
   ========================================================================== */

.choice-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  border-bottom: 1.5px solid rgba(245, 158, 11, 0.4);
  padding: 1rem 1.25rem;
  flex-shrink: 0;
  animation: slideDown 0.3s ease-out;
}

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

.choice-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.choice-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.choice-info {
  flex: 1;
}

.choice-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fef08a;
}

.choice-description {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  margin-bottom: 0.65rem;
}

.choice-action-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 600px;
}

.choice-select {
  flex: 1;
  background: #0d111a;
  border-color: rgba(245, 158, 11, 0.4);
  color: #fff;
  font-weight: 500;
}

/* ==========================================================================
   TERMINAL SCREEN & LOG COLORING
   ========================================================================== */

.terminal-screen {
  flex: 1;
  background: var(--console-bg);
  overflow-y: auto; /* SCROLL INTERNO ÚNICO */
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--console-text);
  scroll-behavior: smooth;
}

.terminal-screen::-webkit-scrollbar {
  width: 8px;
}
.terminal-screen::-webkit-scrollbar-track {
  background: #05070b;
}
.terminal-screen::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.terminal-screen::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.terminal-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-line {
  word-break: break-all;
  white-space: pre-wrap;
}

/* Sintaxis y Colores de Consola */
.log-line.log-success {
  color: var(--console-success) !important;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.08);
  padding: 2px 4px;
  border-radius: 3px;
}

.log-line.log-error {
  color: var(--console-error) !important;
  background: rgba(239, 68, 68, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
}

.log-line.log-warning {
  color: var(--console-warning) !important;
}

.log-line.log-info {
  color: var(--console-info) !important;
}

.log-line.log-dim {
  color: var(--console-dim) !important;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-idle {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-corriendo {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-awaiting_choice {
  background: rgba(245, 158, 11, 0.2);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.5);
  animation: pulseAmber 1.2s infinite;
}

.badge-agendado {
  background: rgba(16, 185, 129, 0.25);
  color: #4ade80;
  border: 1px solid #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.badge-bloqueado {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid var(--accent-red);
}

.badge-sin_citas {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-detenido {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-faint);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.badge-error {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid var(--accent-red);
}

/* ==========================================================================
   BUTTONS & ALERTS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-block { width: 100%; }

.btn-lg {
  height: 42px;
  font-size: 0.88rem;
}

.btn-sm {
  height: 30px;
  padding: 0 0.65rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-blue-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
}
.btn-success:hover {
  background: var(--accent-green-hover);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}
.btn-danger:hover {
  background: var(--accent-red-hover);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-warning {
  background: var(--accent-amber);
  color: #000;
  font-weight: 700;
}
.btn-warning:hover {
  background: var(--accent-amber-hover);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
}

.alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MÓVIL <= 768px)
   ========================================================================== */

@media (max-width: 768px) {
  html, body {
    height: auto;
    min-height: 100%;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-container {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* Header móvil compacto */
  .app-header {
    height: auto;
    min-height: 52px;
    padding: 0.6rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .brand-status {
    display: none;
  }

  .header-center {
    order: 3;
    width: 100%;
    margin-top: 0.25rem;
    display: flex;
    justify-content: center;
  }

  .header-main-title {
    font-size: 0.95rem;
  }

  /* Barra de pestañas con scroll horizontal táctil */
  .tabs-bar {
    height: auto;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 0.5rem;
    scrollbar-width: thin;
  }

  .tabs-bar::-webkit-scrollbar {
    height: 3px;
  }

  .tabs-bar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
  }

  .tab-item {
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
  }

  /* Workspace & Slots apilados verticalmente */
  .workspace-container {
    height: auto;
    overflow: visible;
  }

  .slot-view.active {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Columna superior: Formulario */
  .config-panel {
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 0.85rem 1.25rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .mode-selector-block {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    margin: 0.5rem 0;
  }

  .mode-selector {
    width: 100%;
    display: flex;
  }

  .mode-option {
    flex: 1;
  }

  .mode-pill {
    width: 100%;
    text-align: center;
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    min-height: 44px;
  }

  .dropzone-area {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .dropzone-text {
    font-size: 0.75rem;
  }

  /* Formulario a 1 sola columna en pantallas móviles (360-390px) */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

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

  .input-control {
    min-height: 42px;
    font-size: 0.9rem;
  }

  .btn-eye {
    min-width: 42px;
    min-height: 42px;
  }

  /* Botones Iniciar/Detener con tamaño táctil adecuado (mínimo 44px de alto) */
  .form-actions {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
  }

  .form-actions .btn,
  .btn-lg {
    min-height: 44px;
    height: 44px;
    font-size: 0.92rem;
  }

  /* Columna inferior: Consola */
  .console-panel {
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .console-header {
    height: 44px;
    padding: 0 0.85rem;
  }

  .terminal-screen {
    height: 40vh;
    min-height: 220px;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .choice-card {
    padding: 1rem 0.85rem;
  }
}

/* ==============================================================================
   VENTANA DE ESTADÍSTICAS (CENTRAL)
   ============================================================================== */
.stats-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}

.stats-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.9) 100%);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-select {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 170px;
  outline: none;
  transition: all 0.2s ease;
}

.filter-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-sublabel {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.date-input-wrap input[type="date"] {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-icon {
  font-size: 1.15rem;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.kpi-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.kpi-card.highlight-success {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.12) 0%, #0f172a 100%);
}

.kpi-value.highlight-value {
  color: #10b981;
  text-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

/* Sections */
.stats-card-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 0.75rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.section-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Histograma */
.histogram-wrapper {
  background: #0a0f1d;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 1.25rem 1rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.histogram-bars-container {
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 4px;
}

.hist-bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  position: relative;
  cursor: pointer;
}

.hist-bar {
  width: 100%;
  background: rgba(100, 116, 139, 0.2);
  border-radius: 2px 2px 0 0;
  transition: all 0.25s ease;
}

.hist-bar.active-bar {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.hist-bar-col:hover .hist-bar {
  filter: brightness(1.3);
  transform: scaleY(1.03);
}

.histogram-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  padding: 0 4px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.data-table th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.tag-date {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.tag-date-highlight {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.tag-date-prev {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.text-cyan {
  color: #38bdf8;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

.font-bold {
  font-weight: 700;
}

.badge-outline-info {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #22d3ee;
}

.badge-outline-secondary {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

/* Tablas Crudas y Paginación */
.raw-tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.raw-tab-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.raw-tab-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #f1f5f9;
}

.raw-tab-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.raw-tab-count {
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

.raw-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0.25rem 0.25rem 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.raw-pagination-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.raw-pagination-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pagination-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: #334155;
  color: #ffffff;
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-btn.active-page {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
  font-weight: 700;
}

/* Ventana de estadísticas: scroll vertical normal (excepción a la regla 100vh sin scroll de la vista principal) */
html:has(body.page-stats),
body.page-stats {
  height: auto;
  max-height: none;
  overflow-y: auto;
}

body.page-stats .app-container,
body.page-stats .stats-container {
  height: auto;
  max-height: none;
  overflow: visible;
}

/* ==========================================================================
   BOTS ROTATIVOS (MULTICUENTA)
   ========================================================================== */

.rotativo-bar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.rotativo-count-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rotativo-count-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.rotativo-count-pills {
  display: flex;
  gap: 0.35rem;
  background: rgba(30, 41, 59, 0.7);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-count-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-count-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-count-pill.active {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.4);
}

.rotativo-subtabs {
  display: flex;
  gap: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.25rem;
  overflow-x: auto;
}

.subtab-btn {
  position: relative;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.subtab-btn:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.03);
}

.subtab-btn.active {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
  background: rgba(59, 130, 246, 0.08);
  font-weight: 700;
}

.subtab-btn.hidden-subtab {
  display: none !important;
}

.subtab-choice-badge {
  background: #f59e0b;
  color: #1e293b;
  font-size: 0.65rem;
  font-weight: 800;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: pulse-badge 1.2s infinite;
}

.subtab-btn.has-choice {
  color: #f59e0b;
  border-bottom-color: #f59e0b;
}

@keyframes pulse-badge {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.subpane-pane {
  display: none;
}

.subpane-pane.active {
  display: block;
}




