:root {
  --nora-brand: #00274E;
  --nora-accent: #CBA052;
  --nora-bg-soft: #F7F8FB;
  --nora-border-soft: #E1E4EC;
  --nora-text-main: #2B3440;
  --nora-text-muted: #6B7280;

  /* AÑADE ESTA LÍNEA */
  --nora-font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

/* Contenedor general del cuestionario dentro de .container-xxl */
.quiz-layout {
  display: flex;
  gap: 1.75rem;
  max-width: 1280px;
  margin: 0 auto;
  align-items: flex-start;
}

/* Menú lateral (stepper) */
#quiz-sidenav {
  flex: 0 0 230px;
}

/* Área principal */
#quiz-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* Layout interno de cada paso (form + guía) */
.step-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 1.5rem;
  align-items: flex-start;
}

/* Por defecto: guía oculta, se abre con la clase en el layout */
.step-guide {
  display: none;
}

.step-layout.has-guide-open .step-guide {
  display: block;
}

/* Card principal del paso */
.step-card {
  border-radius: 14px;
  border: 1px solid var(--nora-border-soft);
  background-color: #ffffff;
  padding: 1.75rem 1.75rem 1.5rem;
}

/* Cabecera del paso */
.step-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.step-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--nora-brand);
  margin: 0 0 0.35rem;
}

.step-subtitle {
  font-size: 0.95rem;
  color: var(--nora-text-muted);
  margin: 0;
}

/* Grupo de campos */
.step-field-group {
  margin-top: 0.75rem;
}

.step-label {
  display: block;
  font-weight: 500;
  color: var(--nora-text-main);
  margin-bottom: 0.35rem;
}

.step-help {
  font-size: 0.88rem;
  color: var(--nora-text-muted);
  margin-bottom: 0.5rem;
}

/* Select principal de la sección (mejorado) */
.step-select.form-select {
  border-radius: 10px;
  border: 1px solid var(--nora-border-soft);
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  color: var(--nora-text-main);
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.step-select.form-select:focus {
  border-color: var(--nora-accent);
  box-shadow: 0 0 0 2px rgba(203, 160, 82, 0.18);
  outline: none;
}

/* Nota de guardado */
#note.step-note {
  font-size: 0.8rem;
}

/* Guía NORA */
.step-guide .nora-guide-card {
  position: sticky;
  top: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--nora-border-soft);
  background: var(--nora-bg-soft);
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--nora-text-main);
}

.nora-guide-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--nora-brand);
  margin: 0 0 0.5rem;
}

.nora-guide-body {
  margin: 0 0 0.75rem;
  color: var(--nora-text-muted);
}

.nora-guide-list {
  padding-left: 1.1rem;
  margin: 0 0 0.75rem;
}

.nora-guide-list li {
  margin-bottom: 0.3rem;
}

.nora-guide-tip {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: var(--nora-text-main);
}

.nora-guide-warning {
  margin: 0;
  font-size: 0.86rem;
  color: #B45309;
}

/* Botón para abrir/cerrar la guía */
.step-guide-toggle {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--nora-border-soft);
  background-color: #fff;
  padding: 0.35rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.step-guide-toggle:hover {
  border-color: var(--nora-accent);
  background-color: #FDF8EE;
}

.step-guide-toggle:focus-visible {
  outline: 2px solid var(--nora-accent);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 991.98px) {
  .quiz-layout {
    flex-direction: column;
    padding-inline: 12px;
    gap: 1.25rem;
  }

  #quiz-sidenav {
    order: -1;
    width: 100%;
    flex: none;
  }

  #quiz-sidenav .card {
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .step-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .step-card {
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }

  .step-title {
    font-size: 1.2rem;
  }
}


/* Contenedor general del cuestionario dentro de .container-xxl */
.quiz-layout {
  display: flex;
  gap: 1.75rem;
  max-width: 1360px;
  /* ← más ancho que antes */
  margin: 0 auto;
  align-items: flex-start;
}

/* Menú lateral (stepper) */
#quiz-sidenav {
  flex: 0 0 230px;
}

/* Área principal */
#quiz-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* Layout interno de cada paso: TODO EN COLUMNA (form arriba, guía abajo) */
.step-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
}

/* Guía oculta por defecto, visible sólo cuando el layout tiene la clase */
.step-guide {
  display: none;
  width: 100%;
}

.step-layout.has-guide-open .step-guide {
  display: block;
}

/* Card principal del paso (la mantienes igual que antes) */
.step-card {
  border-radius: 14px;
  border: 1px solid var(--nora-border-soft);
  background-color: #ffffff;
  padding: 1.75rem 1.75rem 1.5rem;
}

/* Guía NORA debajo, ya no sticky lateral */
.step-guide .nora-guide-card {
  border-radius: 14px;
  border: 1px solid var(--nora-border-soft);
  background: var(--nora-bg-soft);
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--nora-text-main);
}

/* Financiación: labels y ayuda más limpias */
.fin-grid .form-label.step-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Botón de ayuda mini, sin gritar */
.btn-help {
  padding: 0;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-help .help-icon {
  font-size: 11px;
  font-weight: 600;
}

/* Tarjetas de ayuda: más discretas y acotadas */
.help-card {
  max-width: 380px;
}

/* Para que las filas verticalmente queden más compactas */
.fin-grid .row.g-3>[class*="col-"] {
  margin-bottom: 0.5rem;
}

/* ===== Financiación: alineado labels + ayuda ===== */

/* Todas las labels de financiación: texto + ? alineados arriba */
#fin-card .form-label.step-label {
  display: flex;
  align-items: flex-start;
  /* ← clave */
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

/* Botón de ayuda: mini, no molesta visualmente */
#fin-card .btn-help {
  padding: 0;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.05rem;
  /* micro-ajuste vertical */
}

#fin-card .btn-help .help-icon {
  font-size: 11px;
  font-weight: 600;
}

/* Tarjetas de ayuda: menos agresivas y compactas */
#fin-card .help-card {
  max-width: 360px;
  margin-top: 0.25rem;
  background: #f8fbff;
  border-color: #cfe2ff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

#fin-card .help-card .card-body {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

/* Un poco menos de “aire” vertical por columna para que cuadren mejor las filas */
#fin-card .fin-grid .row.g-3>[class*="col-"] {
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   RESUMEN – Layout general
   ========================================================================== */
/* Resumen – ancho más generoso */
#resumen-pdf.print-a4 {
  width: 100%;
  max-width: 1320px;
  /* antes 960px */
  margin: 0 auto;
  padding: 1.5rem 2.25rem 2.25rem;
  /* un poco más de aire lateral */
}


/* Evitar cortes feos al imprimir */
.print-avoid-break {
  page-break-inside: avoid;
}

.print-page-break {
  page-break-before: always;
}

/* Card principal */
#resumen-pdf .card {
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
}

#resumen-pdf .card-body {
  padding: 1.5rem 1.75rem;
}

/* Subtextos finos */
#resumen-pdf .section-subtext {
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ==========================================================================
   RESUMEN – Chips de beneficios
   ========================================================================== */

.resumen-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  font-size: 0.78rem;
  font-weight: 500;
  color: #1e40af;
}

.resumen-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #2563eb;
  flex-shrink: 0;
}

/* ==========================================================================
   RESUMEN – Tarjetas de métricas (precio, impuestos, fondos, etc.)
   ========================================================================== */

.resumen-stat-card {
  border-radius: 0.9rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 0.7rem 0.9rem;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.resumen-stat-card.highlight {
  background: #0f172a;
  border-color: #0f172a;
  color: #f9fafb;
}

.resumen-stat-card .resumen-stat-label {
  font-size: 0.8rem;
  color: #64748b;
}

.resumen-stat-card.highlight .resumen-stat-label {
  color: #cbd5f5;
}

.resumen-stat-card .resumen-stat-value {
  font-size: 1rem;
  font-weight: 600;
}

/* ==========================================================================
   RESUMEN – Bloques de Impuestos / Gastos
   ========================================================================== */

@media (max-width: 768px) {
  #resumen-pdf.print-a4 {
    padding: 1rem 12px;
  }

  #resumen-pdf .card-body {
    padding: 1.25rem 1rem;
  }

  .resumen-stat-card {
    min-height: 64px;
    padding: 0.6rem 0.8rem;
  }

  .resumen-stat-value {
    font-size: 0.95rem !important;
  }

  /* Ajustar filas de métricas */
  .resumen-box {
    padding: 1rem;
  }
}


/* ==========================================================================
   RESUMEN – Bloque documentación + NIE
   ========================================================================== */

.resumen-nie-callout {
  padding: 0.75rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  font-size: 0.8rem;
}

.resumen-nie-callout .fw-bold {
  font-size: 0.82rem;
}

#resumen-pdf .list-group.list-group-flush.small li.list-group-item {
  padding: 0.4rem 0;
}

/* ==========================================================================
   NORA AI – Bloque explicación cliente
   ========================================================================== */

#noraAiCard {
  border-radius: 1rem;
  overflow: hidden;
}

#noraAiCard .card-body {
  border-radius: 1rem;
  background: radial-gradient(circle at top left, #1e293b 0, #020617 60%);
  color: #e5e7eb;
}

/* Título + botón */
#noraAiCard h3 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Estado de IA */
#aiExplainStatus {
  font-size: 0.78rem;
  color: #9ca3af;
}

/* Output IA: estilo “terminal” limpio */
#aiExplainOutput {
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

/* Botón copiar */
#btnAiCopy {
  font-size: 0.8rem;
}

/* Botones dentro del bloque IA – más compactos */
#noraAiCard .btn.btn-primary.btn-sm {
  font-size: 0.8rem;
  padding-inline: 0.9rem;
}

/* ==========================================================================
   NORA AI – Velo / Paywall (planes free)
   ========================================================================== */

.nora-ai-veil {
  position: absolute;
  inset: 0;
  padding: 1.2rem 1.4rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  background: linear-gradient(115deg,
      rgba(15, 23, 42, 0.9),
      rgba(17, 24, 39, 0.96));
  color: #e5e7eb;
  text-align: left;
  backdrop-filter: blur(2px);
}

.nora-ai-veil .nora-ai-veil-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.nora-ai-veil .nora-ai-veil-text {
  font-size: 0.8rem;
  color: #cbd5f5;
}

.nora-ai-veil #btnUpgradeNow {
  margin-top: 0.4rem;
  align-self: flex-start;
}

/* ==========================================================================
   PRINT – Ajustes específicos al imprimir el resumen
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
  }

  #resumen-pdf.print-a4 {
    max-width: none;
    padding: 0;
  }

  /* Evitar que botones/IA salgan en el PDF impreso */
  #btnAiExplain,
  #btnAiCopy,
  .nora-ai-veil,
  #btnPreview {
    display: none !important;
  }
}

/* Wrapper del select con flecha custom */
.step-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

/* Base del select */
.step-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--nora-border-muted, #d4d7e1);
  background-color: #ffffff;
  padding: 0.7rem 2.6rem 0.7rem 0.95rem;

  font-size: 0.95rem;
  line-height: 1.3;
  color: #1f2430;

  box-shadow: 0 0 0 1px transparent;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    transform 0.05s ease;
}

/* Hover: ligero énfasis */
.step-select:hover {
  border-color: #99b0ff;
  background-color: #f9fbff;
}

/* Focus: anillo tipo app moderna */
.step-select:focus {
  outline: none;
  border-color: #4b6bff;
  box-shadow: 0 0 0 1px rgba(75, 107, 255, 0.18);
}

/* Estado error: ya usas .border-danger en la card, lo reforzamos en el select */
#scope-card.border.border-danger .step-select {
  border-color: #dc3545;
  box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.18);
}

/* Flecha custom (chevron) */
.step-select-wrapper::after {
  content: "";
  position: absolute;
  pointer-events: none;

  right: 1rem;
  top: 50%;
  transform: translateY(-55%) rotate(45deg);

  width: 0.45rem;
  height: 0.45rem;

  border-right: 2px solid #7a7f92;
  border-bottom: 2px solid #7a7f92;
  opacity: 0.85;
}

/* Deshabilitado (por si lo usas en otros pasos) */
.step-select:disabled {
  cursor: not-allowed;
  background-color: #f3f4f7;
  color: #9a9fb2;
}

.step-select:disabled+.step-select-wrapper::after {
  border-color: #c0c3cf;
}

/* Mobile: algo más grande para dedo */
@media (max-width: 768px) {
  .step-select {
    font-size: 1rem;
    padding: 0.8rem 2.6rem 0.8rem 1rem;
    border-radius: 0.8rem;
  }
}

.resumen-savings-card {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: 10px;
  background: #f0faf3;
  border: 1px solid #cde7d5;
  font-size: 13px;
}

.resumen-savings-card .rs-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.resumen-savings-card .rs-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  color: #297f4b;
}

.resumen-savings-card .rs-total {
  text-align: right;
}

.resumen-savings-card .rs-total-label {
  display: inline-block;
  margin-right: 4px;
  font-size: 11px;
  color: #355844;
}

.resumen-savings-card .rs-total-amount {
  font-weight: 700;
  font-size: 15px;
}

.resumen-savings-card .rs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.25rem;
  margin-bottom: 0.35rem;
}

.resumen-savings-card .rs-table td {
  padding: 2px 0;
  font-size: 12px;
}

.resumen-savings-card .rs-table td:first-child {
  font-weight: 500;
}

.resumen-savings-card .rs-table td.rs-amount {
  text-align: right;
  font-weight: 600;
}

.resumen-savings-card .rs-table td.rs-rate {
  text-align: right;
  font-size: 11px;
  color: #4c6a57;
  white-space: nowrap;
}

.resumen-savings-card .rs-note {
  font-size: 10px;
  color: #557163;
}

/* =========================================================
   RESUMEN — Modo auditoría (origen de números)
   ========================================================= */

#resumen-pdf.show-sources .resumen-src {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* KPIs nuevos */
.resumen-kpi {
  border-radius: 0.9rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 0.8rem 0.95rem;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.resumen-kpi.kpi-dark {
  background: #0f172a;
  border-color: #0f172a;
  color: #f9fafb;
}

.resumen-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.resumen-kpi-label {
  font-size: 0.8rem;
  color: #64748b;
}

.resumen-kpi.kpi-dark .resumen-kpi-label {
  color: #cbd5f5;
}

.resumen-kpi-value {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Solo visible cuando se activa el toggle */
#resumen-pdf.show-sources .resumen-src {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  /* ajusta a tu layout */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.resumen-kpi-label {
  min-width: 0;
}

/* deja que el texto encoja */
.resumen-src {
  flex: 0 0 auto;
}

/* el badge no se aplasta */

#consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
}

.consent-banner__inner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .12);
}

.consent-banner__text {
  font-size: 13px;
  color: #333;
}

.consent-banner__actions {
  display: flex;
  gap: 8px;
}