/* ==========================================================================
   Food Toxicology Studio • Estilos canónicos fijate.com
   Paleta Midnight Slate (#0b0f17) con semáforos de riesgo toxicológico EFSA
   ========================================================================== */

:root {
  /* Paleta base en tema oscuro por defecto */
  --bg-primary: #0b0f17;
  --bg-surface: #121824;
  --bg-surface-elevated: #1a2232;
  --bg-surface-hover: #222d42;
  --border-subtle: #232f44;
  --border-focus: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f17;

  /* Semáforos de riesgo toxicológico */
  --risk-safe: #10b981;
  --risk-safe-bg: rgba(16, 185, 129, 0.12);
  --risk-safe-border: rgba(16, 185, 129, 0.35);

  --risk-caution: #f59e0b;
  --risk-caution-bg: rgba(245, 158, 11, 0.12);
  --risk-caution-border: rgba(245, 158, 11, 0.35);

  --risk-warning: #f97316;
  --risk-warning-bg: rgba(249, 115, 22, 0.14);
  --risk-warning-border: rgba(249, 115, 22, 0.4);

  --risk-danger: #ef4444;
  --risk-danger-bg: rgba(239, 68, 68, 0.15);
  --risk-danger-border: rgba(239, 68, 68, 0.45);

  /* Acentos de marca */
  --brand-cyan: #06b6d4;
  --brand-cyan-glow: rgba(6, 182, 212, 0.2);
  --brand-blue: #3b82f6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --risk-safe: #059669;
  --risk-safe-bg: #ecfdf5;
  --risk-safe-border: #a7f3d0;

  --risk-caution: #d97706;
  --risk-caution-bg: #fffbeb;
  --risk-caution-border: #fde68a;

  --risk-warning: #ea580c;
  --risk-warning-bg: #fff7ed;
  --risk-warning-border: #fed7aa;

  --risk-danger: #dc2626;
  --risk-danger-bg: #fef2f2;
  --risk-danger-border: #fecaca;

  --brand-cyan: #0891b2;
  --brand-cyan-glow: rgba(8, 145, 178, 0.15);
  --brand-blue: #2563eb;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.08);
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
}

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

/* Layout canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3.5rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr 300px;
  }
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Panel de bienvenida / Hero */
.hero-card {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-elevated) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, var(--brand-cyan-glow) 0%, transparent 70%);
  pointer-events: none;
}

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

.hero-title-group h2 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--brand-cyan-glow);
  color: var(--brand-cyan);
  border: 1px solid rgba(6, 182, 212, 0.35);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 850px;
}

/* Métricas del catálogo en cabecera */
.catalog-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

@media (min-width: 640px) {
  .catalog-stats-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform var(--transition-fast);
}

.stat-pill:hover {
  transform: translateY(-2px);
}

.stat-pill .stat-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 700;
}

.stat-pill.safe .stat-num { color: var(--risk-safe); }
.stat-pill.caution .stat-num { color: var(--risk-caution); }
.stat-pill.warning .stat-num { color: var(--risk-warning); }
.stat-pill.danger .stat-num { color: var(--risk-danger); }

.stat-pill .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: none;
}

/* Barra de pestañas principales */
.nav-tabs-wrapper {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-subtle);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: all var(--transition-fast);
  position: relative;
}

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

.tab-btn.active {
  color: var(--brand-cyan);
  background: var(--bg-surface);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-cyan);
  border-radius: 3px 3px 0 0;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
  display: flex;
}

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

/* -------------------------------------------------------------
   TAB 1: Buscador y catálogo de aditivos
   ------------------------------------------------------------- */
.search-filter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 2.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px var(--brand-cyan-glow);
}

.btn-clear-search {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  display: none;
  border-radius: var(--radius-sm);
}

.btn-clear-search:hover {
  color: var(--text-primary);
}

/* Filtros en cuadrícula */
.filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .filters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .filters-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 2.5rem 0 0.75rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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%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;
  background-size: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.custom-select:focus {
  outline: none;
  border-color: var(--brand-cyan);
}

.custom-select option, .custom-select optgroup {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

/* Barra de resultados y vista */
.results-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0.5rem;
}

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

.results-count strong {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.view-mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.2rem;
}

.btn-view-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.btn-view-mode.active {
  background: var(--bg-surface-elevated);
  color: var(--brand-cyan);
}

/* Cuadrícula de tarjetas de aditivos */
.additives-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .additives-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .additives-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.additive-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.additive-card:hover {
  transform: translateY(-3px);
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.additive-code-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.card-risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-pill);
}

/* Modificadores según riesgo */
.risk-safe .additive-code-pill,
.badge-safe {
  background: var(--risk-safe-bg);
  color: var(--risk-safe);
  border-color: var(--risk-safe-border);
}

.risk-caution .additive-code-pill,
.badge-caution {
  background: var(--risk-caution-bg);
  color: var(--risk-caution);
  border-color: var(--risk-caution-border);
}

.risk-warning .additive-code-pill,
.badge-warning {
  background: var(--risk-warning-bg);
  color: var(--risk-warning);
  border-color: var(--risk-warning-border);
}

.risk-prohibited .additive-code-pill,
.badge-danger {
  background: var(--risk-danger-bg);
  color: var(--risk-danger);
  border-color: var(--risk-danger-border);
}

.additive-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.4rem;
  color: var(--text-primary);
}

.additive-category-tag {
  font-size: 0.8rem;
  color: var(--brand-cyan);
  font-weight: 500;
}

.additive-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.additive-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.mini-pill {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.mini-pill.alert-pill {
  background: var(--risk-warning-bg);
  color: var(--risk-warning);
  border-color: var(--risk-warning-border);
}

.card-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.btn-view-details {
  background: transparent;
  border: none;
  color: var(--brand-cyan);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

.btn-view-details:hover {
  text-decoration: underline;
}

.btn-add-compare {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-compare:hover {
  background: var(--brand-cyan-glow);
  color: var(--brand-cyan);
  border-color: var(--brand-cyan);
}

.btn-add-compare.added {
  background: var(--brand-cyan);
  color: var(--text-inverse);
  border-color: var(--brand-cyan);
}

/* -------------------------------------------------------------
   TAB 2: Analizador de etiquetas (OCR / Texto de ingredientes)
   ------------------------------------------------------------- */
.scanner-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.scanner-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.scanner-header h3 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.scanner-textarea-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

.scanner-textarea {
  width: 100%;
  min-height: 140px;
  padding: 1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color var(--transition-fast);
}

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

.scanner-presets-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

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

.preset-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-chip:hover {
  background: var(--brand-cyan-glow);
  color: var(--brand-cyan);
  border-color: rgba(6, 182, 212, 0.4);
}

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-primary-action {
  flex: 1 1 200px;
  min-height: 46px;
  background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
  transition: all var(--transition-fast);
}

.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-secondary-action {
  min-height: 46px;
  padding: 0 1.25rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background var(--transition-fast);
}

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

/* Resultados del analizador de etiquetas */
.analysis-results-box {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.analysis-results-box.active {
  display: flex;
}

.analysis-summary-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

@media (min-width: 768px) {
  .analysis-summary-header {
    grid-template-columns: auto 1fr;
  }
}

.overall-traffic-light {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  margin: 0 auto;
  border: 4px solid;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.overall-traffic-light .traffic-score {
  font-size: 2.2rem;
  line-height: 1;
}

.overall-traffic-light .traffic-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.traffic-safe {
  background: var(--risk-safe-bg);
  border-color: var(--risk-safe);
  color: var(--risk-safe);
}

.traffic-caution {
  background: var(--risk-caution-bg);
  border-color: var(--risk-caution);
  color: var(--risk-caution);
}

.traffic-warning {
  background: var(--risk-warning-bg);
  border-color: var(--risk-warning);
  color: var(--risk-warning);
}

.traffic-danger {
  background: var(--risk-danger-bg);
  border-color: var(--risk-danger);
  color: var(--risk-danger);
}

.analysis-summary-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
}

.analysis-summary-meta h4 {
  font-size: 1.2rem;
}

.detected-counts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Alertas críticas del analizador */
.critical-alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-banner-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
}

.alert-banner-item.alert-danger {
  background: var(--risk-danger-bg);
  border: 1px solid var(--risk-danger-border);
  color: var(--risk-danger);
}

.alert-banner-item.alert-warning {
  background: var(--risk-warning-bg);
  border: 1px solid var(--risk-warning-border);
  color: var(--risk-warning);
}

.alert-banner-item.alert-info {
  background: var(--brand-cyan-glow);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: var(--brand-cyan);
}

.alert-banner-item strong {
  display: block;
  font-weight: 700;
}

/* Desglose de aditivos detectados */
.detected-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.detected-list-table th {
  text-align: left;
  padding: 0.6rem;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.detected-list-table td {
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.detected-list-table tr:hover td {
  background: var(--bg-surface);
}

/* -------------------------------------------------------------
   TAB 3: Comparador cara a cara
   ------------------------------------------------------------- */
.comparator-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.comparator-selectors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .comparator-selectors-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.compare-col-selector {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.compare-matrix-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.compare-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.compare-matrix-table th,
.compare-matrix-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: top;
}

.compare-matrix-table th:first-child,
.compare-matrix-table td:first-child {
  background: var(--bg-surface-elevated);
  font-weight: 600;
  color: var(--text-secondary);
  width: 180px;
  min-width: 140px;
}

.compare-matrix-table th {
  background: var(--bg-surface-elevated);
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
}

/* -------------------------------------------------------------
   TAB 4: Calculadora de dosis segura (IDA)
   ------------------------------------------------------------- */
.calculator-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.calc-inputs-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .calc-inputs-row {
    grid-template-columns: 1.2fr 1fr;
  }
}

.calc-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calc-field-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.weight-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 1rem;
  height: 46px;
}

.weight-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
}

.weight-input:focus {
  outline: none;
}

.weight-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.weight-slider {
  width: 100%;
  margin-top: 0.5rem;
  accent-color: var(--brand-cyan);
}

.calc-quick-weights {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.quick-weight-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.quick-weight-chip:hover {
  background: var(--brand-cyan-glow);
  color: var(--brand-cyan);
}

/* Tarjeta de resultado de la calculadora */
.calc-result-display {
  background: linear-gradient(135deg, var(--bg-surface-elevated) 0%, var(--bg-surface-hover) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.calc-max-dose-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--brand-cyan);
  line-height: 1;
}

.calc-max-dose-unit {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.calc-equivalences-box {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.45;
}

/* -------------------------------------------------------------
   MODAL DE FICHA TÉCNICA TOXICOLÓGICA (CERO ALERTS)
   ------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-close-modal:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-cyan);
}

/* Caja de contras y efectos adversos en modal */
.cons-box {
  background: var(--risk-warning-bg);
  border: 1px solid var(--risk-warning-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.cons-box strong {
  color: var(--risk-warning);
}

.modal-props-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

@media (min-width: 640px) {
  .modal-props-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.modal-prop-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

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

.modal-prop-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

/* Toast de notificación rápida */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--brand-cyan);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

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

/* Ajustes mobile strict */
@media (max-width: 639px) {
  .tool-layout {
    padding: 0 0.75rem;
  }
  
  .hero-card {
    padding: 1.15rem;
  }
  
  .hero-title-group h2 {
    font-size: 1.25rem;
  }
  
  .modal-sheet {
    max-height: 95vh;
  }
}
