/* ══════════════════════════════════════════════════════════════════
   CALC-VAN-TIR.CSS — Calculadora de evaluación de proyectos
══════════════════════════════════════════════════════════════════ */

/* ── Hero ─────────────────────────────────────────────────────── */

.calc-hero {
  background:
    linear-gradient(135deg, rgba(16,32,39,0.97) 0%, rgba(31,111,104,0.78) 100%),
    url("../img/hero-bg.jpg") center / cover;
  color: var(--white);
  padding: 76px clamp(18px, 6vw, 76px) 56px;
}

.calc-hero-inner {
  width: min(960px, 100%);
}

.calc-hero h1 {
  margin: 14px 0 16px;
  color: var(--white);
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  line-height: 1.05;
}

.calc-hero > .calc-hero-inner > p:not(.eyebrow) {
  max-width: 680px;
  margin: 0;
  color: rgba(255,255,255,0.78);
  font-size: 1.02rem;
  line-height: 1.55;
}

/* ── Layout principal ─────────────────────────────────────────── */

.calc-section {
  padding: 40px clamp(18px, 4vw, 60px) 80px;
  background: var(--paper);
}

.calc-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 28px;
  width: min(1240px, 100%);
  margin: 0 auto;
  align-items: start;
}

/* ── Cards genéricas ──────────────────────────────────────────── */

.calc-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
  padding: 22px;
  margin-bottom: 18px;
}

.calc-card:last-child {
  margin-bottom: 0;
}

.calc-card h2,
.calc-card h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  color: var(--ink);
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.calc-card h2 i,
.calc-card h3 i {
  color: var(--teal);
  font-size: 1.1rem;
  font-family: "bootstrap-icons";
}

.calc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.calc-card-header h2,
.calc-card-header h3 {
  margin: 0;
}

.calc-card-actions {
  display: flex;
  gap: 8px;
}

.calc-card-actions .button {
  flex: 1;
}

/* ── Sidebar (inputs) ────────────────────────────────────────── */

.calc-inputs {
  position: sticky;
  top: calc(var(--header) + 14px);
}

/* ── Campos de formulario ────────────────────────────────────── */

.calc-field {
  margin-bottom: 16px;
}

.calc-field:last-child {
  margin-bottom: 0;
}

.calc-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.calc-field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.calc-input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.calc-input-group:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(31, 111, 104, 0.10);
}

.calc-input-group input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  min-width: 0;
  text-align: right;
}

.calc-prefix,
.calc-suffix {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  height: 100%;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0 12px;
  align-self: stretch;
}

.calc-prefix {
  border-right: 1px solid var(--line);
}

.calc-suffix {
  border-left: 1px solid var(--line);
}

.calc-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  padding: 10px 12px;
  cursor: pointer;
  outline: none;
}

.calc-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(31, 111, 104, 0.10);
}

/* ── Lista de flujos de caja ─────────────────────────────────── */

.calc-cashflows {
  margin-top: 14px;
}

.calc-cashflows-header {
  display: grid;
  grid-template-columns: 60px 1fr 34px;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cashflow-row {
  display: grid;
  grid-template-columns: 60px 1fr 34px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  animation: fadeIn 200ms ease;
}

.cashflow-period {
  display: grid;
  place-items: center;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
}

.cashflow-input-group input {
  padding: 8px 10px;
}

.cashflow-remove {
  display: grid;
  place-items: center;
  width: 34px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 160ms ease;
}

.cashflow-remove:hover {
  border-color: var(--clay);
  background: rgba(191, 91, 69, 0.06);
  color: var(--clay);
}

.calc-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--teal-dark);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 160ms ease;
}

.calc-add-btn:hover {
  border-style: solid;
  border-color: var(--teal);
  background: rgba(31, 111, 104, 0.06);
}

.calc-btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 160ms ease;
}

.calc-btn-mini:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Resultados ───────────────────────────────────────────────── */

.calc-results {
  min-width: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metric-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  overflow: hidden;
}

.metric-card.metric-primary {
  grid-column: span 2;
  background:
    linear-gradient(135deg, var(--white) 0%, rgba(16,32,39,0.02) 100%);
  border-color: rgba(16,32,39,0.16);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 4px solid transparent;
  pointer-events: none;
  border-radius: 10px;
  transition: border-color 220ms ease;
}

.metric-card.is-positive::before {
  border-left-color: var(--teal);
}

.metric-card.is-negative::before {
  border-left-color: var(--clay);
}

.metric-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  margin: 0 0 6px;
  color: var(--ink);
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-value.metric-small {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
}

.metric-card.is-positive .metric-value {
  color: var(--teal-dark);
}

.metric-card.is-negative .metric-value {
  color: var(--clay);
}

.metric-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

/* ── Panel de decisión ──────────────────────────────────────── */

.decision-panel {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px;
  border-radius: 10px;
  background: rgba(16,32,39,0.05);
  border-left: 4px solid var(--muted);
  margin-bottom: 22px;
}

.decision-panel > i {
  color: var(--muted);
  font-size: 1.2rem;
  margin-top: 2px;
}

.decision-panel strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 4px;
}

.decision-panel p {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.55;
}

.decision-positive {
  background: rgba(31,111,104,0.08);
  border-left-color: var(--teal);
}

.decision-positive > i { color: var(--teal); }

.decision-negative {
  background: rgba(191,91,69,0.08);
  border-left-color: var(--clay);
}

.decision-negative > i { color: var(--clay); }

.decision-neutral {
  background: rgba(196,134,60,0.08);
  border-left-color: var(--gold);
}

.decision-neutral > i { color: var(--gold); }

/* ── Gráfico ──────────────────────────────────────────────────── */

.calc-chart-card {
  padding: 22px;
}

.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart-container svg {
  width: 100%;
  min-width: 500px;
  height: auto;
  display: block;
}

.chart-bar-positive {
  fill: rgba(31, 111, 104, 0.85);
  transition: fill 160ms ease;
}

.chart-bar-positive:hover {
  fill: var(--teal-dark);
}

.chart-bar-negative {
  fill: rgba(191, 91, 69, 0.85);
}

.chart-bar-negative:hover {
  fill: var(--clay);
}

.chart-cumulative-line {
  stroke: var(--gold);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.chart-cumulative-dot {
  fill: var(--gold);
  stroke: white;
  stroke-width: 1.5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-positive   { background: rgba(31, 111, 104, 0.85); }
.legend-negative   { background: rgba(191, 91, 69, 0.85); }
.legend-cumulative { background: var(--gold); }

/* ── Tabla de cálculo ─────────────────────────────────────────── */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 0 -22px;
  padding: 0 22px;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.calc-table th {
  padding: 10px 12px;
  text-align: left;
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.calc-table th.num {
  text-align: right;
}

.calc-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}

.calc-table td.num {
  text-align: right;
  font-weight: 600;
}

.calc-table td.positive {
  color: var(--teal-dark);
}

.calc-table td.negative {
  color: var(--clay);
}

.calc-table tr:last-child td {
  border-bottom: 0;
}

.calc-table tr.row-base {
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

.calc-table tr.row-base td {
  color: var(--ink);
  font-weight: 700;
}

.badge-base {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--gold);
  color: var(--ink);
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}

.formula {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.formula code {
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.86em;
  color: var(--ink);
}

/* ── Sensibilidad ─────────────────────────────────────────────── */

.sensitivity-content {
  margin-top: 14px;
}

.sens-curve {
  stroke: var(--teal-dark);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.sens-base-dot {
  fill: var(--gold);
  stroke: white;
  stroke-width: 2;
}

.sensitivity-table-wrapper {
  margin-top: 14px;
  width: 100%;
  overflow-x: auto;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

/* ── Explicaciones ────────────────────────────────────────────── */

.calc-explainer dl {
  margin: 0 0 18px;
  display: grid;
  gap: 12px;
}

.calc-explainer dt {
  font-weight: 800;
  color: var(--teal-dark);
  font-size: 0.94rem;
}

.calc-explainer dd {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 0.94rem;
  line-height: 1.55;
}

.calc-explainer a {
  color: var(--teal-dark);
  border-bottom: 1px solid rgba(31,111,104,0.4);
}

.calc-explainer a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Animaciones ──────────────────────────────────────────────── */

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

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }

  .calc-inputs {
    position: static;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card.metric-primary {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-card.metric-primary {
    grid-column: span 1;
  }

  .calc-card-actions {
    flex-direction: column;
  }
}


/* ══════════════════════════════════════════════════════════════
   Comparación dramática (Tarjeta de crédito)
   Dos cards lado a lado: pago mínimo vs estrategia agresiva
══════════════════════════════════════════════════════════════ */
.cc-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.cc-compare-card {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.cc-compare-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.cc-compare-card header i {
  font-size: 1.3rem;
}

.cc-compare-card h4 {
  margin: 0;
  font-family: "Inter", sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.cc-compare-card dl {
  margin: 0;
}

.cc-compare-card dl > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
}

.cc-compare-card dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.cc-compare-card dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  text-align: right;
}

.cc-compare-bad header i { color: var(--clay); }
.cc-compare-bad { background: color-mix(in srgb, var(--clay) 6%, var(--paper)); }
.cc-compare-bad dd { color: var(--clay); }

.cc-compare-good header i { color: var(--teal); }
.cc-compare-good { background: color-mix(in srgb, var(--teal) 6%, var(--paper)); }
.cc-compare-good dd { color: var(--teal); }

.cc-savings {
  margin: 18px 4px 0;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .cc-compare {
    grid-template-columns: 1fr;
  }
}


/* ══════════════════════════════════════════════════════════════
   Vehículos dinámicos del Comparador de Inversiones
══════════════════════════════════════════════════════════════ */
.ci-vehicle-row {
  display: grid;
  grid-template-columns: 14px 1fr auto 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.ci-vehicle-row:last-of-type {
  border-bottom: none;
}

.ci-vehicle-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ci-v-name {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 6px 8px;
  border-radius: 6px;
  outline: none;
  transition: background 160ms ease, border-color 160ms ease;
}
.ci-v-name:hover {
  background: var(--paper-2);
}
.ci-v-name:focus {
  border-color: var(--teal);
  background: var(--white);
}

.ci-vehicle-ret {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--paper-2);
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}
.ci-v-ret {
  width: 64px;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: right;
  font: inherit;
  color: inherit;
  outline: none;
  font-variant-numeric: tabular-nums;
  /* Quitar spinners feos en Chrome/Safari para que el número quepa */
  -moz-appearance: textfield;
  appearance: textfield;
}
.ci-v-ret::-webkit-outer-spin-button,
.ci-v-ret::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ci-v-remove {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 160ms ease;
}
.ci-v-remove:hover {
  background: color-mix(in srgb, var(--clay) 14%, transparent);
  color: var(--clay);
}

.ci-table-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}


/* ══════════════════════════════════════════════════════════════
   Snowball/Avalanche: lista dinámica de deudas
══════════════════════════════════════════════════════════════ */
.sa-debt-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.sa-debt-row:last-of-type { border-bottom: none; }

.sa-debt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sa-d-name {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.94rem;
  padding: 6px 8px;
  border-radius: 6px;
  outline: none;
  transition: background 160ms ease, border-color 160ms ease;
}
.sa-d-name:hover  { background: var(--paper-2); }
.sa-d-name:focus  { border-color: var(--teal); background: var(--white); }

.sa-debt-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.sa-debt-field {
  min-width: 0;
}
.sa-debt-field label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.sa-debt-field .calc-input-group {
  padding: 4px 8px;
}
.sa-debt-field .calc-input-group input {
  padding: 4px 0;
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .sa-debt-fields { grid-template-columns: 1fr; }
}

/* Orden de pago lado a lado */
.sa-orders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.sa-order-col h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.sa-order-col h4 .bi-mountain { color: var(--teal); }
.sa-order-col h4 .bi-snow     { color: var(--clay); }

.sa-order-col ol {
  margin: 0;
  padding-left: 20px;
}
.sa-order-col li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.sa-order-col li:last-child { border-bottom: none; }
.sa-order-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 600px) {
  .sa-orders { grid-template-columns: 1fr; }
}


/* ══════════════════════════════════════════════════════════════
   Costo de un Préstamo: barra de composición horizontal
══════════════════════════════════════════════════════════════ */
.cp-breakdown {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cp-breakdown-bar {
  display: flex;
  width: 100%;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.cp-bar-segment {
  height: 100%;
  transition: width 240ms ease;
  position: relative;
}

.cp-bar-capital     { background: var(--teal); }
.cp-bar-interest    { background: var(--gold); }
.cp-bar-origination { background: var(--clay); }
.cp-bar-insurance   { background: var(--olive); }
.cp-bar-fees        { background: var(--ink-2); }

.cp-breakdown-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
}

.cp-breakdown-legend > div {
  display: grid;
  grid-template-columns: 14px auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.cp-breakdown-legend dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.cp-breakdown-legend dd {
  margin: 0;
  text-align: right;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.cp-breakdown-legend .legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.cp-pct {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}


/* ══════════════════════════════════════════════════════════════
   Calculadora de Tamaño de Muestra — Pasos del cálculo
══════════════════════════════════════════════════════════════ */
.ms-steps {
  list-style: none;
  counter-reset: ms-step;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ms-steps li {
  counter-increment: ms-step;
  position: relative;
  padding: 14px 16px 14px 56px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.55;
}

.ms-steps li::before {
  content: counter(ms-step);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: var(--white);
  border-radius: 50%;
  font-size: 0.86rem;
  font-weight: 800;
}

.ms-steps li.ms-result {
  background: color-mix(in srgb, var(--teal) 8%, var(--paper));
  border-left: 3px solid var(--teal);
  font-weight: 600;
}

.ms-steps li.ms-result::before {
  content: "✓";
  background: var(--gold);
}

/* ══════════════════════════════════════════════════════════════
   Tablas Estadísticas — Tabs + tabla densa
══════════════════════════════════════════════════════════════ */
.te-container {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 0 clamp(18px, 6vw, 76px);
}

.te-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.te-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  transition: all 160ms ease;
  font: inherit;
}

.te-tab:hover {
  background: var(--paper-2);
}

.te-tab.is-active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

[data-theme="dark"] .te-tab.is-active {
  color: #ffffff;
}

.te-tab-symbol {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.te-tab-name {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Panel de búsqueda rápida (controles + resultado) */
.te-quick-panel {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: center;
}

.te-quick-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.te-quick-controls .calc-field {
  margin-bottom: 0;
}

.te-result-card {
  padding: 22px;
  background: color-mix(in srgb, var(--teal) 8%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--teal) 20%, transparent);
  border-radius: var(--radius);
  text-align: center;
}

.te-result-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.te-result-value {
  margin: 0 0 10px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

[data-theme="dark"] .te-result-value {
  color: var(--teal);
}

.te-result-help {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.86rem;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .te-quick-panel {
    grid-template-columns: 1fr;
  }
  .te-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tabla densa para datos tabulados */
.te-table {
  width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.te-table th,
.te-table td {
  padding: 6px 8px;
  border: 1px solid var(--line);
  text-align: center;
}

.te-table thead th {
  background: var(--paper-2);
  font-weight: 700;
  color: var(--ink);
  position: sticky;
  top: 0;
  z-index: 1;
}

.te-table tbody th {
  background: var(--paper-2);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.84rem;
}

.te-table tbody tr:hover td {
  background: color-mix(in srgb, var(--teal) 6%, transparent);
}


/* ══════════════════════════════════════════════════════════════
   Regresión Lineal Simple — Textarea + bloque de predicción
══════════════════════════════════════════════════════════════ */

.calc-field textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.calc-field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 14%, transparent);
  background: var(--white);
}

.calc-field textarea::placeholder {
  color: var(--muted);
  font-size: 0.84rem;
}

/* Bloque de predicción puntual */
.rl-predict {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
  padding: 18px;
  background: color-mix(in srgb, var(--teal) 6%, var(--paper));
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--teal) 18%, transparent);
}

.rl-predict > div:first-child label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.rl-predict > div:first-child input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.rl-predict > div:first-child input:focus {
  border-color: var(--teal);
}

.rl-predict-result {
  text-align: right;
}

.rl-predict-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.rl-predict-result strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .rl-predict-result strong {
  color: var(--teal);
}

@media (max-width: 540px) {
  .rl-predict {
    grid-template-columns: 1fr;
  }
  .rl-predict-result {
    text-align: left;
  }
}


/* ══════════════════════════════════════════════════════════════
   Test de Hipótesis — Hipótesis, dos columnas, decisión grande
══════════════════════════════════════════════════════════════ */

.th-hypothesis {
  background: color-mix(in srgb, var(--teal) 6%, var(--paper));
  border-left: 3px solid var(--teal);
}

.th-hyp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 8px;
}

.th-hyp-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.th-hyp-formula {
  margin: 0;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  word-spacing: 0.05em;
}

@media (max-width: 540px) {
  .th-hyp-grid { grid-template-columns: 1fr; }
}

/* Dos columnas (muestra 1 / muestra 2) en sidebar */
.th-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.th-two-cols h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.th-two-cols .calc-field {
  margin-bottom: 12px;
}

.th-two-cols .calc-field:last-child {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .th-two-cols { grid-template-columns: 1fr; }
}

/* Caja de decisión - reemplaza al decision-panel para algo más visual */
.th-decision {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px;
  margin: 18px 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.th-decision > i {
  font-size: 1.7rem;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--muted);
}

.th-decision strong {
  display: block;
  margin-bottom: 6px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.th-decision p {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.55;
}

.th-decision.is-reject {
  background: color-mix(in srgb, var(--clay) 8%, var(--white));
  border-color: color-mix(in srgb, var(--clay) 30%, transparent);
  border-left: 4px solid var(--clay);
}

.th-decision.is-reject > i {
  color: var(--clay);
}

.th-decision.is-not-reject {
  background: color-mix(in srgb, var(--teal) 8%, var(--white));
  border-color: color-mix(in srgb, var(--teal) 30%, transparent);
  border-left: 4px solid var(--teal);
}

.th-decision.is-not-reject > i {
  color: var(--teal);
}


/* ══════════════════════════════════════════════════════════════
   WACC — Detalle plegable (CAPM auxiliar)
══════════════════════════════════════════════════════════════ */
.wc-detail {
  margin-top: 14px;
  padding: 14px;
  background: var(--paper-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.wc-detail > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--teal-dark);
  font-size: 0.92rem;
  list-style: none;
  padding: 2px 0;
  user-select: none;
}

[data-theme="dark"] .wc-detail > summary {
  color: var(--teal);
}

.wc-detail > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 200ms ease;
}

.wc-detail[open] > summary::before {
  transform: rotate(90deg);
}

.wc-detail[open] > summary {
  margin-bottom: 10px;
}

.wc-detail .calc-field {
  margin-bottom: 10px;
}

/* ── Intervalos de Confianza ── */
.ic-result-banner {
  background: linear-gradient(135deg, rgba(40, 184, 156, 0.10), rgba(40, 184, 156, 0.04));
  border: 1.5px solid rgba(40, 184, 156, 0.30);
  border-radius: 14px;
  padding: 22px 26px;
  margin-bottom: 22px;
  text-align: center;
}

[data-theme="dark"] .ic-result-banner {
  background: linear-gradient(135deg, rgba(40, 184, 156, 0.18), rgba(40, 184, 156, 0.06));
  border-color: rgba(40, 184, 156, 0.45);
}

.ic-result-eyebrow {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal, #28b89c);
  margin: 0 0 10px;
}

.ic-result-formula {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink, #102027);
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}

[data-theme="dark"] .ic-result-formula {
  color: #f5f6f8;
}

.ic-result-help {
  font-size: 0.97rem;
  color: var(--muted, #475569);
  margin: 0;
  line-height: 1.55;
}

[data-theme="dark"] .ic-result-help {
  color: #c7cdd6;
}

.ic-result-help strong {
  color: var(--teal, #28b89c);
}

@media (max-width: 640px) {
  .ic-result-formula { font-size: 1.25rem; }
  .ic-result-banner { padding: 18px 16px; }
}

/* ── CVU producto rows ── */
.cv-prod-row {
  border: 1px solid var(--line, #d8dbe0);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg-soft, #f9fafb);
}

[data-theme="dark"] .cv-prod-row {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.10);
}

.cv-prod-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.cv-prod-name {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--line, #d8dbe0);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--white, #fff);
  color: var(--ink, #102027);
}

[data-theme="dark"] .cv-prod-name {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
  color: #f5f6f8;
}

.cv-prod-del {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--clay, #e07a5f);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}

.cv-prod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.cv-prod-grid label {
  display: flex; flex-direction: column;
  font-size: 0.8rem; font-weight: 600;
  color: var(--muted, #6b7280);
  gap: 3px;
}

.cv-prod-grid input {
  padding: 5px 8px;
  border: 1px solid var(--line, #d8dbe0);
  border-radius: 5px;
  font-size: 0.9rem;
  background: var(--white, #fff);
  color: var(--ink, #102027);
}

[data-theme="dark"] .cv-prod-grid input {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
  color: #f5f6f8;
}

/* ── CTA contextual reutilizable (embebido en calculadoras) ── */
.srv-contextual-cta {
  background: linear-gradient(135deg, #102027 0%, #1a2f38 100%);
  color: #ffffff;
  border-radius: 14px;
  padding: 28px 32px;
  margin: 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  position: relative;
  overflow: hidden;
}

.srv-contextual-cta::before {
  content: "";
  position: absolute;
  top: -30%; right: -10%;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(40,184,156,0.20) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.srv-contextual-cta-body {
  flex: 1;
  position: relative;
  z-index: 1;
}

.srv-contextual-cta-eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #28b89c;
  margin: 0 0 8px;
}

.srv-contextual-cta h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: #ffffff !important;
  line-height: 1.3;
}

.srv-contextual-cta p {
  font-size: 0.96rem;
  line-height: 1.5;
  margin: 0;
  color: rgba(255,255,255,0.85);
}

.srv-contextual-cta-action {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.srv-contextual-cta-btn {
  background: #d4a017;
  color: #102027 !important;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.96rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.2s;
}

.srv-contextual-cta-btn:hover {
  background: #b88a13;
  color: #102027 !important;
}

@media (max-width: 700px) {
  .srv-contextual-cta {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
  }
  .srv-contextual-cta-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Markowitz correlation matrix ── */
.mk-corr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.mk-corr-table th, .mk-corr-table td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid var(--line, #d8dbe0);
}
[data-theme="dark"] .mk-corr-table th,
[data-theme="dark"] .mk-corr-table td {
  border-color: rgba(255,255,255,0.10);
}
.mk-corr-table th {
  background: var(--bg-soft, #f6f8fa);
  font-weight: 700;
  color: var(--ink, #102027);
  font-size: 0.75rem;
}
[data-theme="dark"] .mk-corr-table th {
  background: rgba(255,255,255,0.04);
  color: #f5f6f8;
}
.mk-corr-diag {
  background: var(--teal, #28b89c);
  color: #ffffff;
  font-weight: 700;
}
.mk-corr-mirror {
  color: var(--muted, #6b7280);
  background: var(--bg-soft, #f9fafb);
}
[data-theme="dark"] .mk-corr-mirror {
  background: rgba(255,255,255,0.02);
}
.mk-corr-input {
  width: 56px;
  padding: 3px 5px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink, #102027);
  -moz-appearance: textfield;
  appearance: textfield;
}
.mk-corr-input::-webkit-outer-spin-button,
.mk-corr-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
[data-theme="dark"] .mk-corr-input { color: #f5f6f8; }
.mk-corr-input:focus {
  outline: 2px solid var(--teal, #28b89c);
  outline-offset: -1px;
}

/* ── Simplex (PL) ── */
.sp-coefs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 6px;
}
.sp-coef-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
  color: var(--ink, #102027);
}
[data-theme="dark"] .sp-coef-item { color: #f5f6f8; }
.sp-obj-input, .sp-cons-coef, .sp-cons-rhs {
  width: 60px;
  padding: 5px 8px;
  border: 1px solid var(--line, #d8dbe0);
  border-radius: 6px;
  font-size: 0.9rem;
  text-align: center;
  background: var(--white, #fff);
  color: var(--ink, #102027);
  -moz-appearance: textfield;
}
[data-theme="dark"] .sp-obj-input,
[data-theme="dark"] .sp-cons-coef,
[data-theme="dark"] .sp-cons-rhs {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
  color: #f5f6f8;
}
.sp-obj-input::-webkit-outer-spin-button,
.sp-obj-input::-webkit-inner-spin-button,
.sp-cons-coef::-webkit-outer-spin-button,
.sp-cons-coef::-webkit-inner-spin-button,
.sp-cons-rhs::-webkit-outer-spin-button,
.sp-cons-rhs::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.sp-plus {
  color: var(--muted, #6b7280);
  margin: 0 2px;
}
.sp-cons-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-soft, #f9fafb);
  border-radius: 8px;
  border: 1px solid var(--line, #d8dbe0);
}
[data-theme="dark"] .sp-cons-row {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.10);
}
.sp-cons-lhs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 200px;
  font-size: 0.9rem;
}
.sp-cons-op {
  padding: 6px 10px;
  border: 1px solid var(--line, #d8dbe0);
  border-radius: 6px;
  font-weight: 700;
  background: var(--white, #fff);
  color: var(--ink, #102027);
}
[data-theme="dark"] .sp-cons-op {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
  color: #f5f6f8;
}
.sp-tableau {
  font-size: 0.82rem;
}
.sp-tableau th, .sp-tableau td {
  text-align: center;
  padding: 5px 8px;
}
