/* =============================================
   SIMULADOR DE PRÉSTAMOS — Estilos
   Método Francés y Americano
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.ocultar-inicial::first-letter {
  font-size: 0;
}

:root {
  --blue-dark:   #0D2B5E;
  --blue-mid:    #1A4FA0;
  --blue-light:  #3B82F6;
  --blue-pale:   #EFF6FF;
  --green:       #0F6E56;
  --green-light: #E6F4F1;
  --red:         #993C1D;
  --red-light:   #FDF1EC;
  --amber:       #92600B;
  --amber-light: #FEF8EC;
  --gray-100:    #F8F9FB;
  --gray-200:    #EEF0F4;
  --gray-300:    #D1D5DB;
  --gray-500:    #6B7280;
  --gray-700:    #374151;
  --gray-900:    #111827;
  --white:       #FFFFFF;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(13,43,94,.10);
  --font-main:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background:#0b1829;
  color: var(--white);
  padding: 2.5rem 2rem 2rem;
  text-align: center;
}
header .badge {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
header h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .5rem;
}
header p {
  font-size: 14px;
  opacity: .75;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Controls card ── */
.controls-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
}
.controls-card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls-card h2 .icon { font-size: 18px; }

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.ctrl-group { display: flex; flex-direction: column; gap: 8px; }

.ctrl-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ctrl-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}
.ctrl-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue-dark);
  font-family: var(--font-mono);
}
.ctrl-unit {
  font-size: 13px;
  color: var(--gray-500);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 4px;
  background: var(--gray-200);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue-mid);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 1px var(--blue-mid);
  transition: transform .15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue-mid);
  border: 3px solid var(--white);
  cursor: pointer;
}

.ctrl-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-300);
}

/* ── Tabs ── */
.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--gray-200);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 1.75rem;
  width: fit-content;
}
.tab-btn {
  padding: 9px 22px;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font-main);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--gray-900); }
.tab-btn.active {
  background: var(--white);
  color: var(--blue-dark);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.tab-btn.active.frances { color: var(--blue-mid); }
.tab-btn.active.americano { color: var(--red); }
.tab-btn.active.comparar { color: var(--green); }

/* ── Metric cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 2rem;
}
.metric-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-card .m-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}
.metric-card .m-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gray-900);
}
.metric-card .m-sub {
  font-size: 11px;
  color: var(--gray-500);
}
.metric-card.blue  { border-top: 3px solid var(--blue-light); }
.metric-card.blue  .m-value { color: var(--blue-mid); }
.metric-card.green { border-top: 3px solid var(--green); }
.metric-card.green .m-value { color: var(--green); }
.metric-card.red   { border-top: 3px solid var(--red); }
.metric-card.red   .m-value { color: var(--red); }
.metric-card.amber { border-top: 3px solid var(--amber); }
.metric-card.amber .m-value { color: var(--amber); }

/* ── Amortization table ── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.table-wrapper {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 2rem;
  border: 1px solid var(--gray-200);
}
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: var(--blue-dark);
  color: var(--white);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--blue-pale); }
tbody tr:nth-child(even) { background: var(--gray-100); }
tbody tr:nth-child(even):hover { background: var(--blue-pale); }
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-family: var(--font-mono);
  font-size: 13px;
}
tbody td:first-child {
  font-family: var(--font-main);
  font-weight: 600;
  color: var(--gray-500);
}
tbody tr:last-child td { border-bottom: none; }
.tfoot-row td {
  background: var(--blue-dark) !important;
  color: var(--white) !important;
  font-weight: 700;
  border-top: 2px solid var(--blue-mid);
}
.col-cuota   { color: var(--blue-mid); font-weight: 600; }
.col-capital { color: var(--green); }
.col-interes { color: var(--red); }
.col-saldo   { color: var(--gray-700); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.chart-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.chart-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--gray-500);
  margin-bottom: 10px;
}
.chart-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.leg-sq {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.chart-canvas-wrap { position: relative; height: 230px; }

/* ── Compare ── */
.compare-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.compare-col {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.compare-col.is-frances { border-top: 4px solid var(--blue-mid); }
.compare-col.is-americano { border-top: 4px solid var(--red); }
.compare-col h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}
.compare-col.is-frances h3 { color: var(--blue-mid); }
.compare-col.is-americano h3 { color: var(--red); }
.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--gray-200);
}
.compare-row:last-child { border-bottom: none; }
.compare-row .cr-label { color: var(--gray-500); }
.compare-row .cr-value { font-weight: 700; font-family: var(--font-mono); font-size: 13px; }
.badge-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pill-green { background: var(--green-light); color: var(--green); }
.pill-amber { background: var(--amber-light); color: var(--amber); }
.pill-red   { background: var(--red-light); color: var(--red); }

.compare-charts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Info box ── */
.info-box {
  background: var(--blue-pale);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 13px;
  color: var(--blue-dark);
  margin-bottom: 1.5rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.5;
}
.info-box .info-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--gray-500);
  font-size: 12px;
  border-top: 1px solid var(--gray-200);
  margin-top: 2rem;
}

/* ── Download button ── */
.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-mid);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, transform .1s;
  font-family: var(--font-main);
}
.dl-btn:hover { background: var(--blue-dark); }
.dl-btn:active { transform: scale(.97); }

.pane { display: none; }
.pane.active { display: block; }

/* ── Responsive ── */
@media (max-width: 640px) {
  header { padding: 1.75rem 1rem 1.5rem; }
  .container { padding: 1.25rem 1rem; }
  .controls-card { padding: 1.25rem; }
  .compare-header { grid-template-columns: 1fr; }
  .tab-nav { width: 100%; justify-content: stretch; }
  .tab-btn { flex: 1; padding: 9px 8px; font-size: 12px; }
}

@media print {
  header { background: var(--blue-dark) !important; -webkit-print-color-adjust: exact; }
  .controls-card, .tab-nav, footer { display: none; }
  .pane { display: block !important; }
}