:root {
  --bg-canvas: #08090a;
  --bg-card: #0f1115;
  --bg-elevated: #151821;
  --bg-input: #0b0d12;
  --bg-header: #08090a;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.22);
  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-primary-text: #ffffff;
  --accent-secondary: #2563eb;
  --badge-bg: rgba(16, 185, 129, 0.12);
  --badge-text: #34d399;
  --badge-border: rgba(16, 185, 129, 0.30);
  --shadow-subtle: 0 2px 10px rgba(0, 0, 0, 0.45);
}

html.light-mode {
  --bg-canvas: #f6f9fc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-input: #ffffff;
  --bg-header: #ffffff;
  --text-primary: #0a2540;
  --text-secondary: #334155;
  --text-muted: #475569;
  --border-subtle: #e2e8f0;
  --border-focus: #94a3b8;
  --accent-primary: #047857;
  --accent-primary-hover: #065f46;
  --accent-primary-text: #ffffff;
  --accent-secondary: #1d4ed8;
  --badge-bg: #ecfdf5;
  --badge-text: #065f46;
  --badge-border: #a7f3d0;
  --shadow-subtle: 0 2px 8px rgba(10, 37, 64, 0.06);
}

/* Desactivar toda iluminación ornamental, retículas y desenfoques gaussianos */
#mallen-wasm-spotlight,
.quantum-ambient-stage,
.quantum-orb,
.quantum-grid-overlay,
body::before,
body::after,
.quantum-card::before,
.laser-border::before,
.laser-border::after {
  display: none !important;
  content: none !important;
  animation: none !important;
}

*, *::before, *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html, body {
  background-color: var(--bg-canvas) !important;
  color: var(--text-primary) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.011em;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

p, li, dd, .prose-narrative {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-secondary);
}

h1, h2, h3, h4, .heading-exec {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  color: var(--text-primary) !important;
  letter-spacing: -0.022em;
}

/* JetBrains Mono reservado exclusivamente para RFC, USt-IdNr., KVK, SCIAN, SHA-256 y montos */
.font-mono-data,
#folioInput,
#cal_emp,
#eu-tax-input,
#eu-emp-input,
#sbx-total-fine,
#sbx-risk-score,
code,
pre {
  font-family: 'JetBrains Mono', monospace !important;
  font-variant-numeric: tabular-nums;
}

/* Reemplazar abuso de font-mono-code en textos descriptivos por Inter legible */
.font-mono-code {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  letter-spacing: 0.01em;
}

header, nav.top-bar-surface {
  background-color: var(--bg-header) !important;
  border-color: var(--border-subtle) !important;
}

/* Tarjetas sobrias con micro-interacción de 140ms y bordes finos */
.quantum-card,
.quantum-laser-console,
.mallen-surface-card,
.bg-slate-900,
.bg-slate-900\/90,
.bg-slate-900\/80,
.bg-slate-950,
.bg-slate-950\/90,
.bg-slate-950\/80 {
  background: var(--bg-card) !important;
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-subtle) !important;
  transition: border-color 140ms ease, transform 140ms ease !important;
}

.quantum-card:hover,
.mallen-surface-card:hover {
  border-color: var(--border-focus) !important;
  transform: translateY(-1px);
}

/* Controles de formulario semánticos en ambos modos */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background-color: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-focus) !important;
  border-radius: 8px !important;
  font-size: 16px !important;
  min-height: 44px;
  transition: border-color 140ms ease, box-shadow 140ms ease !important;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.18) !important;
  outline: none !important;
}

/* Botones de acción primaria con ratio de contraste AA/AAA (>4.70:1) */
.mallen-btn-primary,
.w16-action-btn,
button[type="submit"] {
  background: var(--accent-primary) !important;
  color: var(--accent-primary-text) !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
  min-height: 44px;
  transition: background-color 140ms ease !important;
}

.mallen-btn-primary:hover,
.w16-action-btn:hover,
button[type="submit"]:hover {
  background: var(--accent-primary-hover) !important;
}

.mallen-btn-secondary {
  background-color: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-focus) !important;
  border-radius: 8px !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
  min-height: 40px;
  transition: border-color 140ms ease, background-color 140ms ease !important;
}

.mallen-btn-secondary:hover {
  border-color: var(--accent-primary) !important;
}

/* Consistencia total en Modo Claro para textos heredados de Tailwind */
html.light-mode .text-white,
html.light-mode .text-slate-100,
html.light-mode .text-slate-200 {
  color: var(--text-primary) !important;
}

html.light-mode .text-slate-300,
html.light-mode .text-slate-400 {
  color: var(--text-secondary) !important;
}

html.light-mode .text-emerald-400,
html.light-mode .text-emerald-300 {
  color: #047857 !important;
}

html.light-mode .text-sky-400,
html.light-mode .text-blue-400 {
  color: #1d4ed8 !important;
}

/* Autocompletado Predictivo Unificado */
.mallen-predictive-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border-focus);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 60;
  max-height: 280px;
  overflow-y: auto;
}

.mallen-predictive-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--text-primary);
}

.mallen-predictive-item:hover,
.mallen-predictive-item.active {
  background: var(--bg-elevated);
}

.mallen-baymard-microcopy {
  display: block;
  font-family: 'Inter', sans-serif !important;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.45;
}

/* Ocultar secciones extraídas a rutas dedicadas (/normativa y /radar-dof) en la portada '/' */
body.mallen-home-4blocks .mallen-extracted-to-dedicated-route {
  display: none !important;
}

/* ==========================================================================
   8. ESCALADO TIPOGRÁFICO EJECUTIVO (CERO LETRAS PEQUEÑAS EN WEB Y MÓVIL)
   Eleva automáticamente todas las clases pequeñas de Tailwind a tamaños
   de lectura ejecutiva (mínimo 13.5px en etiquetas y 15.5px-17px en cuerpo)
   ========================================================================== */
html {
  font-size: 17px !important;
}

body, p, li, dd, td, blockquote {
  font-size: 1rem !important; /* 17px reales */
  line-height: 1.65 !important;
}

.text-\[8px\],
.text-\[9px\],
.text-\[10px\],
.text-\[11px\] {
  font-size: 0.82rem !important; /* ~14px mínimo absoluto, nunca 9px/10px */
  line-height: 1.45 !important;
}

.text-xs {
  font-size: 0.88rem !important; /* ~15px */
  line-height: 1.55 !important;
}

.text-sm {
  font-size: 0.96rem !important; /* ~16.3px */
  line-height: 1.6 !important;
}

.text-base {
  font-size: 1.05rem !important; /* ~17.8px */
  line-height: 1.65 !important;
}

h1 {
  font-size: clamp(1.85rem, 3.2vw, 2.65rem) !important;
  line-height: 1.2 !important;
}

h2 {
  font-size: clamp(1.45rem, 2.4vw, 1.95rem) !important;
  line-height: 1.28 !important;
}

h3 {
  font-size: clamp(1.15rem, 1.8vw, 1.35rem) !important;
  line-height: 1.35 !important;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
button {
  font-size: 0.96rem !important; /* ~16.3px en todos los botones e inputs */
}


/* ==========================================================================
   9. OVERRIDE DE ALTA ESPECIFICIDAD SOBRE TAILWIND CDN (LETRAS GRANDES Y CLARAS)
   ========================================================================== */
html {
  font-size: 18px !important;
}
html body {
  font-size: 18px !important;
  line-height: 1.7 !important;
}
html body p,
html body li,
html body dd,
html body td,
html body th,
html body label,
html body summary {
  font-size: 1.02rem !important; /* ~18.3px */
  line-height: 1.68 !important;
}
html body .text-xs,
html body .text-\[8px\],
html body .text-\[9px\],
html body .text-\[10px\],
html body .text-\[11px\],
html body .text-\[12px\],
html body small,
html body .mallen-baymard-microcopy {
  font-size: 0.88rem !important; /* ~15.8px mínimo absoluto */
  line-height: 1.55 !important;
}
html body .text-sm {
  font-size: 1.0rem !important; /* 18px */
  line-height: 1.62 !important;
}
html body .text-base,
html body .text-lg {
  font-size: 1.14rem !important; /* ~20.5px */
  line-height: 1.6 !important;
}
html body h1 {
  font-size: clamp(2.1rem, 3.6vw, 3.0rem) !important;
  line-height: 1.18 !important;
}
html body h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem) !important;
  line-height: 1.25 !important;
}
html body h3 {
  font-size: clamp(1.25rem, 2.0vw, 1.5rem) !important;
  line-height: 1.32 !important;
}
html body input:not([type="checkbox"]):not([type="radio"]),
html body select,
html body textarea,
html body button,
html body a.mallen-btn-primary,
html body a.mallen-btn-secondary {
  font-size: 1.0rem !important; /* 18px en botones y campos */
  min-height: 48px !important;
}
