/* ==========================================================================
   CalcuFinanzas — hoja de estilos global
   Objetivos: carga rápida (sin dependencias externas), cero layout shift,
   y espacios publicitarios con altura reservada.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-card: #ffffff;
  --text: #14181f;
  --text-soft: #5a6472;
  --border: #e3e7ec;
  --accent: #1857c4;
  --accent-soft: #e8f0fe;
  --accent-text: #ffffff;
  --ok: #0f7b46;
  --warn: #9a5b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .05);
  --maxw: 1140px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --bg-soft: #161b23;
    --bg-card: #161b23;
    --text: #e8ecf1;
    --text-soft: #9aa5b4;
    --border: #262d38;
    --accent: #5b93f5;
    --accent-soft: #1a2537;
    --accent-text: #0f1319;
    --ok: #4ec98a;
    --warn: #e0a95c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Cabecera ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.2px;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 800;
}

.nav { display: flex; gap: 4px; flex-wrap: wrap; }

.nav a {
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 15px;
  color: var(--text-soft);
  text-decoration: none;
}

.nav a:hover { background: var(--bg-soft); color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 18px;
  padding: 6px 11px;
  cursor: pointer;
}

@media (max-width: 780px) {
  .nav-toggle { display: block; }
  .nav {
    display: none;
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 8px 20px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 8px; }
}

/* ---------- Estructura de página ---------- */

main { padding: 32px 0 56px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: start;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .sidebar { order: 2; }
}

.sidebar-sticky { position: sticky; top: 82px; }

/* ---------- Tipografía ---------- */

h1 {
  font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.18;
  letter-spacing: -.8px;
  margin: 0 0 12px;
}

h2 {
  font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.3;
  letter-spacing: -.4px;
  margin: 40px 0 12px;
}

h3 { font-size: 19px; margin: 28px 0 8px; letter-spacing: -.2px; }

p { margin: 0 0 16px; }

.lead { font-size: 19px; color: var(--text-soft); margin-bottom: 24px; }

a { color: var(--accent); }

article ul, article ol { margin: 0 0 16px; padding-left: 22px; }
article li { margin-bottom: 7px; }

.breadcrumb {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 14px;
}
.breadcrumb a { color: var(--text-soft); }

.meta {
  font-size: 14px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 36px;
}

/* ---------- Calculadora ---------- */

.calc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 24px 0 32px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label { font-size: 14px; font-weight: 600; color: var(--text-soft); }

.field .hint { font-size: 12.5px; color: var(--text-soft); font-weight: 400; }

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

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  appearance: none;
}

.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.input-wrap .suffix {
  position: absolute;
  right: 12px;
  font-size: 14px;
  color: var(--text-soft);
  pointer-events: none;
}

.input-wrap:has(.suffix) input { padding-right: 42px; }

/* ---------- Resultados ---------- */

.result {
  margin-top: 22px;
  padding: 20px;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.result-main { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.result-label { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.result-value {
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.result-item { display: flex; flex-direction: column; gap: 1px; }
.result-item .k { font-size: 13px; color: var(--text-soft); }
.result-item .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Tablas ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 24px;
}

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th, td {
  padding: 10px 14px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

th {
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .4px;
  position: sticky;
  top: 0;
}

th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }

.btn {
  display: inline-block;
  padding: 10px 18px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg-soft); }

/* ---------- Tarjetas del índice ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin: 28px 0 8px;
}

.card {
  display: block;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .15s;
}

.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .icon { font-size: 26px; line-height: 1; }
.card h3 { margin: 12px 0 6px; font-size: 18px; }
.card p { margin: 0; font-size: 15px; color: var(--text-soft); line-height: 1.55; }

.callout {
  padding: 16px 18px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  margin: 0 0 24px;
  font-size: 15.5px;
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--text); }

/* ==========================================================================
   BLOQUES PUBLICITARIOS
   La altura mínima está reservada para que la inserción del anuncio no
   desplace el contenido (Cumulative Layout Shift = 0, mejor CPM).
   ========================================================================== */

.ad-slot {
  display: block;
  margin: 30px 0;
  text-align: center;
  overflow: hidden;
}

.ad-slot::before {
  content: "Publicidad";
  display: block;
  font-size: 10.5px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-soft);
  opacity: .65;
  margin-bottom: 6px;
}

.ad-slot .adsbygoogle { display: block; }

/* Alturas reservadas por tipo de bloque */
.ad-leaderboard { min-height: 116px; }   /* 728x90 + etiqueta */
.ad-inarticle   { min-height: 276px; }   /* fluido en artículo */
.ad-sidebar     { min-height: 626px; }   /* 300x600 rascacielos */
.ad-footer      { min-height: 276px; }

@media (max-width: 780px) {
  .ad-leaderboard { min-height: 276px; }  /* en móvil sirve 300x250 */
  .ad-sidebar     { min-height: 276px; }
}

/* ---------- Pie ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 36px 0 28px;
  font-size: 14.5px;
  color: var(--text-soft);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 28px;
  margin-bottom: 26px;
}

.footer-grid h4 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text);
}

.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 7px; }
.footer-grid a { color: var(--text-soft); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.disclaimer {
  font-size: 13px;
  line-height: 1.55;
  max-width: 620px;
}

/* ---------- Banner de cookies ---------- */

#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .1);
  font-size: 14.5px;
}

#cookie-banner.show { display: flex; }
#cookie-banner .cookie-actions { display: flex; gap: 10px; flex-shrink: 0; }

#cookie-banner .btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
