/**
 * Fijate Tools - Entrenador Canino Interactivo
 * Estilos canónicos: Tipografías corporativas, paleta Midnight Slate,
 * pulsador háptico 3D de latencia cero y contención móvil estricta.
 */

/* =========================================================================
   VARIABLES CANÓNICAS Y SISTEMA DE TEMAS (Lección 322)
   ========================================================================= */
:root,
[data-theme="dark"],
body.dark-mode {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta Midnight Slate Canónica */
  --bg-page: #0b0f17;
  --bg-card: #111827;
  --bg-surface: #1e293b;
  --bg-input: #151d2e;
  --border-color: #334155;
  --border-subtle: #1e293b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  /* Acentos de interacción */
  --accent-primary: #10b981;    /* Verde esmeralda entrenamiento positivo */
  --accent-primary-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.25);

  --accent-secondary: #0ea5e9;  /* Azul cian */
  --accent-secondary-hover: #0284c7;

  --accent-warning: #f59e0b;    /* Ámbar */
  --accent-danger: #ef4444;     /* Rojo carmín parada de emergencia */
  --accent-danger-hover: #dc2626;

  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --clicker-plate-grad: linear-gradient(145deg, #374151, #1f2937);
  --clicker-plate-active: linear-gradient(145deg, #1f2937, #111827);
  --clicker-dot-color: #10b981;
}

[data-theme="light"],
body.light-mode,
body.light-theme {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-glow: rgba(5, 150, 105, 0.2);

  --accent-secondary: #0284c7;
  --accent-secondary-hover: #0369a1;

  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-danger-hover: #b91c1c;

  --card-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
  --clicker-plate-grad: linear-gradient(145deg, #e2e8f0, #cbd5e1);
  --clicker-plate-active: linear-gradient(145deg, #cbd5e1, #94a3b8);
  --clicker-dot-color: #059669;
}

/* =========================================================================
   CONTENCIÓN Y LAYOUT PRINCIPAL
   ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 1rem;
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

.main-wrapper.tool-layout {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* Cero colisión con ads.css: display: flex solo en pantallas ultra-anchas */
@media (min-width: 1536px) {
  .tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
  }
  .tool-main-content {
    flex: 1 1 0%;
    min-width: 0;
  }
}

.tool-main-content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* =========================================================================
   BARRA DE NAVEGACIÓN MODULAR TÁCTIL (.nav-tabs)
   ========================================================================= */
.nav-tabs-wrapper {
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 auto;
  touch-action: manipulation;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface);
}

.tab-btn.active {
  color: #ffffff;
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.tab-pane {
  display: none;
  animation: fadeInPane 0.25s ease-out;
}

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

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

/* =========================================================================
   TARJETAS Y ENCABEZADOS PRINCIPALES
   ========================================================================= */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.card-header-clean {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.header-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}

.section-heading {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
}

.section-lead {
  font-size: 0.98rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

.card-subtitle {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.35rem 0;
}

.text-muted-readable {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
}

/* =========================================================================
   MÓDULO 1: PULSADOR HÁPTICO 3D Y CRONÓMETRO DE LATENCIA
   ========================================================================= */
.clicker-interactive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 1.75rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 768px) {
  .clicker-interactive-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.clicker-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  text-align: center;
}

/* Botón pulsador 3D del clicker */
.clicker-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease;
}

.clicker-body {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a3447, #131b2e 70%);
  border: 4px solid var(--border-color);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6), inset 0 3px 6px rgba(255, 255, 255, 0.15), 0 0 0 8px rgba(16, 185, 129, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.clicker-plate {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--clicker-plate-grad);
  border: 3px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 3px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.4rem;
  transition: all 0.08s ease;
}

.clicker-inner-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--clicker-dot-color);
  box-shadow: 0 0 12px var(--accent-primary);
  transition: transform 0.08s ease;
}

.clicker-label {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.clicker-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.2rem;
}

/* Efecto de pulsación activa */
.clicker-trigger:active .clicker-body,
.clicker-trigger.is-pressed .clicker-body {
  transform: translateY(6px) scale(0.97);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 0 10px rgba(16, 185, 129, 0.3);
}

.clicker-trigger:active .clicker-plate,
.clicker-trigger.is-pressed .clicker-plate {
  background: var(--clicker-plate-active);
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.7);
}

.clicker-trigger:active .clicker-inner-dot,
.clicker-trigger.is-pressed .clicker-inner-dot {
  transform: scale(0.85);
  box-shadow: 0 0 18px #34d399;
}

.clicker-shortcuts-hint {
  margin-top: 1.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.kbd-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Caja de latencia */
.latency-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

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

.latency-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.latency-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.latency-badge.status-idle {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.latency-badge.status-running {
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  animation: pulseLatency 1.2s infinite;
}

.latency-badge.status-optimal {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.latency-badge.status-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.latency-badge.status-slow {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

@keyframes pulseLatency {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.latency-timer-display {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.timer-digits {
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1;
}

.timer-unit {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Barra semafórica de la regla biológica */
.latency-gauge-bar {
  position: relative;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  background: #1e293b;
  margin-bottom: 0.4rem;
}

.gauge-section {
  height: 100%;
}

.gauge-section.gauge-green {
  width: 42.8%; /* 0 a 1.5s sobre escala de 3.5s */
  background: #10b981;
}

.gauge-section.gauge-yellow {
  width: 14.3%; /* 1.5 a 2.0s */
  background: #f59e0b;
}

.gauge-section.gauge-red {
  width: 42.9%; /* > 2.0s */
  background: #ef4444;
}

.gauge-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #ffffff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transition: left 0.15s ease-out;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.btn-action-primary {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.btn-action-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
  transform: translateY(-1px);
}

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

.latency-feedback-box {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Estadísticas de la sesión */
.latency-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 640px) {
  .latency-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat-mini-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Historial de repeticiones */
.session-history-container {
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 2rem;
}

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

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.btn-text-action:hover {
  text-decoration: underline;
}

.latency-history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 38px;
  align-items: center;
}

.empty-history-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
}

.chip-latency {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.chip-latency.chip-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.chip-latency.chip-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.chip-latency.chip-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Silbato de alta frecuencia */
.whistle-section-box {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

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

.whistle-freq-badge {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: 10px;
  white-space: nowrap;
}

.whistle-controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 1.5rem;
  align-items: center;
}

@media (max-width: 768px) {
  .whistle-controls-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.whistle-actions-row {
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .whistle-actions-row {
    flex-direction: column;
  }
}

.btn-action-secondary {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

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

.btn-action-secondary.is-active {
  background: var(--accent-secondary);
  color: #ffffff;
  border-color: var(--accent-secondary);
}

.btn-freq-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-freq-preset:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.btn-freq-preset.active {
  background: var(--accent-secondary);
  color: #ffffff;
  border-color: var(--accent-secondary);
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

/* =========================================================================
   MÓDULO 2: PLANES GUIADOS POR FASES (CRITERIO DEL 80 %)
   ========================================================================= */
.plans-selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .plans-selection-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

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

.form-control-select,
.form-control-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0.6rem 0.9rem;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-select {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  appearance: none;
  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%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

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

/* Ficha de conducta activa */
.behavior-card-info {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: 12px;
  margin-bottom: 1.75rem;
}

.behavior-info-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.behavior-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.behavior-card-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.badge-accent {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.behavior-level-indicator {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.behavior-card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.behavior-technique-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.technique-pill {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
}

/* Matriz 3D */
.matrix-3d-box {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 1.75rem;
}

.matrix-header {
  margin-bottom: 1.25rem;
}

.matrix-tip {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--accent-warning);
  font-weight: 600;
  margin-top: 0.2rem;
}

.matrix-3d-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .matrix-3d-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.d-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.1rem;
}

.d-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.d-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--accent-primary);
  color: #ffffff;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.d-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.d-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 0.75rem;
  min-height: 22px;
}

.d-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Sliders personalizados */
.custom-range-slider {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 4px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.custom-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* Contador de series del 80% */
.series-counter-box {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

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

.series-score-badge {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: 10px;
  white-space: nowrap;
}

.series-slots-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .series-slots-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.slot-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.slot-item.slot-success {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

.slot-item.slot-fail {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #f87171;
}

.slot-item.slot-current {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
  color: var(--text-main);
}

.series-actions-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .series-actions-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.btn-rep-success {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.btn-rep-success:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-rep-fail {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--accent-danger);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.btn-rep-fail:hover {
  background: var(--accent-danger-hover);
  transform: translateY(-1px);
}

/* Veredicto del 80% */
.series-verdict-banner {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.series-verdict-banner.is-pass {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
}

.series-verdict-banner.is-maintain {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
}

.series-verdict-banner.is-drop {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
}

.verdict-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.35rem 0;
  color: var(--text-main);
}

.verdict-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* =========================================================================
   MÓDULO 3: LABORATORIO DE DESENSIBILIZACIÓN SONORA
   ========================================================================= */
.stress-meter-box {
  margin-bottom: 1.75rem;
}

.stress-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stress-meter-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stress-zones-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .stress-zones-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stress-zone {
  padding: 1rem;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.stress-zone p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

.zone-badge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.zone-green .zone-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.zone-yellow .zone-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.zone-red .zone-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Biblioteca de sonidos */
.sound-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 768px) {
  .sound-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .sound-library-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.sound-card-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

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

.sound-card-btn.active {
  background: var(--bg-card);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sound-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.sound-card-btn.active .sound-icon-box {
  background: var(--accent-primary);
  color: #ffffff;
}

.sound-title {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.sound-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Panel de control de desensibilización */
.desens-controls-panel {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

.desens-slider-row {
  margin-bottom: 1.5rem;
}

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

.volume-percent-badge {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent-primary);
}

.volume-hint-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.desens-actions-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .desens-actions-bar {
    grid-template-columns: minmax(0, 1fr);
  }
}

.btn-action-emergency {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  background: var(--accent-danger);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
  touch-action: manipulation;
}

.btn-action-emergency:hover:not(:disabled) {
  background: var(--accent-danger-hover);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-action-emergency:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.session-timer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.session-timer-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.session-timer-info .timer-digits {
  font-size: 1.4rem;
  color: var(--text-main);
}

.session-timer-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* =========================================================================
   MÓDULO 4: CALCULADORA NUTRICIONAL WSAVA / FEDIAF
   ========================================================================= */
.nutrition-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 992px) {
  .nutrition-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .nutrition-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.treats-calculator-box {
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 1.75rem;
}

.treats-inputs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .treats-inputs-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.treat-counter-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.treat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.number-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.number-stepper .form-control-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.stepper-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* KPIs de nutrición */
.nutrition-results-card {
  padding: 1.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.nutrition-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .nutrition-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.kpi-card.highlight-card {
  border-color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.08);
}

.kpi-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.kpi-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.highlight-card .kpi-value {
  color: var(--accent-primary);
}

.kpi-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Barra de presupuesto */
.treat-budget-track {
  margin-bottom: 1.5rem;
}

.treat-budget-label-flex {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.treat-budget-label-flex strong {
  color: var(--text-main);
}

.budget-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  overflow: hidden;
}

.budget-fill-safe {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.budget-fill-danger {
  background: var(--accent-danger) !important;
}

/* Banner de ración final */
.final-ration-banner {
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.ration-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.ration-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1.2;
}

.ration-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.warning-alert-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-danger);
  border-radius: 10px;
  color: #f87171;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* =========================================================================
   GUÍA DIDÁCTICA Y ACORDEÓN SEO
   ========================================================================= */
.seo-guide-section {
  margin-top: 2.5rem;
}

.seo-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface);
  overflow: hidden;
}

.accordion-header {
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  user-select: none;
  list-style: none;
}

.accordion-header::-webkit-details-marker {
  display: none;
}

.accordion-header svg {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.accordion-item[open] .accordion-header svg {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.accordion-body p {
  margin: 0;
}

/* =========================================================================
   MODAL CANÓNICO DE CONFIRMACIÓN (Cero alerts)
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  animation: fadeInModal 0.2s ease-out;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  max-width: 440px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: scaleModal 0.2s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleModal {
  from { transform: scale(0.95); }
  to { transform: scale(1); }
}

.modal-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.5rem 0;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.75rem 0;
  line-height: 1.5;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

/* =========================================================================
   UTILIDADES
   ========================================================================= */
.is-hidden {
  display: none !important;
}
