:root {
  --bg-main: #f3f6fb;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-ad: #e5f1f7;

  --primary: #2d83b5;
  --primary-dark: #1a4d6e;
  --accent: #ffb347;

  --text-main: #222222;
  --text-muted: #555555;
  --border-soft: #dde3ee;
  --shadow-soft: 0 10px 30px rgba(15, 35, 52, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --max-width: 1200px;
  --sidebar-width: 260px;
}

/* Reset básico */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top left, #edf4ff 0, #f7f9fc 40%, #f3f6fb 100%);
}

/* HEADER */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(221, 227, 238, 0.8);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 40%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 6px 15px rgba(45, 131, 181, 0.35);
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
}

.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 14px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
}

.nav-link-active {
  color: var(--primary-dark);
  border-color: rgba(45, 131, 181, 0.25);
  background: rgba(45, 131, 181, 0.06);
}

.nav-link-disabled {
  opacity: 0.5;
  cursor: default;
}

/* ADS */

.ad-top {
  max-width: var(--max-width);
  margin: 14px auto 6px auto;
  padding: 0 20px;
}

.ad-placeholder,
.ad-placeholder-vertical {
  background: var(--bg-ad);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(26, 77, 110, 0.25);
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* LAYOUT PRINCIPAL */

.page {
  max-width: calc(var(--max-width) + var(--sidebar-width));
  margin: 0 auto 40px auto;
  padding: 10px 20px 40px 20px;
  display: grid;
  grid-template-columns: minmax(0, var(--sidebar-width)) minmax(0, 1fr);
  gap: 18px;
}

/* Sidebar con anuncio */

.sidebar {
  display: flex;
  align-items: flex-start;
}

.ad-vertical {
  position: sticky;
  top: 90px;
  width: 100%;
}

.ad-placeholder-vertical {
  height: 600px;
}

/* Main */

.main {
  background: transparent;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr);
  gap: 26px;
}

/* CONTENIDO */

.content-column {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  padding: 22px 24px 26px 24px;
  box-shadow: var(--shadow-soft);
}

h1 {
  font-size: 26px;
  margin: 0 0 8px 0;
}

h2 {
  font-size: 20px;
  margin: 22px 0 8px 0;
}

h3 {
  font-size: 16px;
  margin: 16px 0 6px 0;
}

.lead {
  margin-top: 0;
  margin-bottom: 18px;
  color: var(--text-muted);
}

p {
  line-height: 1.55;
  color: var(--text-main);
  margin: 8px 0;
}

ol,
ul {
  padding-left: 20px;
  margin: 8px 0;
}

/* Tabla de contenidos */

.toc {
  background: linear-gradient(135deg, #f0f6ff, #f6fbff);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px 14px;
  border: 1px solid rgba(221, 227, 238, 0.9);
  margin-bottom: 14px;
}

.toc h2 {
  margin-top: 0;
  font-size: 16px;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 6px 0 0 0;
}

.toc li {
  font-size: 14px;
  margin-bottom: 4px;
}

.toc a {
  text-decoration: none;
  color: var(--primary-dark);
}

/* CALCULADORA */

.calculator-column {
  align-self: stretch;
  display: flex;
}

.calculator-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px 22px;
  box-shadow: var(--shadow-soft);
  width: 100%;
  border: 1px solid rgba(221, 227, 238, 0.9);
}

.calculator-card h2 {
  margin-top: 0;
}

.calculator-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

/* Inputs y selects */

input[type="number"],
select {
  width: 100%;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  font-size: 14px;
  outline: none;
  background: #fdfdff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(45, 131, 181, 0.2);
  background: #ffffff;
}

/* Ajuste flechitas number */
input[type="number"]::-webkit-inner-spin-button {
  margin-left: 2px;
}

/* Contenedor input + periodo */

.input-with-period {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.input-with-period input[type="number"] {
  flex: 1;
}

/* Selector chip de periodo */

.period-select-chip {
  width: auto;
  min-width: 70px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #f4f7fc;
  cursor: pointer;
}

.period-select-chip:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(45, 131, 181, 0.2);
  background: #ffffff;
}

/* Tooltips */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 11px;
  border-radius: 50%;
  background: #ffe3a6;
  color: #7a4a00;
  margin-left: 4px;
  cursor: help;
  position: relative;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #111111;
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  white-space: normal;
  max-width: 240px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}

.info-icon::before {
  content: "";
  position: absolute;
  bottom: 128%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #111111 transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.info-icon:hover::after,
.info-icon:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Resultados */

.results {
  margin-top: 14px;
  padding: 12px 12px 10px 12px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, #edf5ff, #f7fbff);
  border: 1px solid rgba(221, 227, 238, 0.9);
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.result-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.result-label {
  font-size: 13px;
  color: var(--text-muted);
}

.result-label-amount {
  font-weight: 500;
}

.result-value {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary-dark);
}

.result-note {
  flex-direction: column;
  align-items: flex-start;
  margin-top: 4px;
}

.result-text {
  font-size: 12px;
  color: var(--text-muted);
}

code {
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
}

.disclaimer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* FOOTER */

.footer {
  border-top: 1px solid rgba(221, 227, 238, 0.9);
  background: #ffffff;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 20px 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-links {
  display: flex;
  gap: 10px;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

/* RESPONSIVE */


@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    width: 100%;
  }

  .content-column,
  .calculator-card {
    padding: 16px 16px 18px 16px;
  }

  .ad-top {
    padding: 0 12px;
  }

  .page {
    padding: 6px 12px 26px 12px;
  }
}

/* BANNER DE COOKIES */

.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.cookie-banner-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.cookie-banner-inner {
  max-width: var(--max-width);
  margin: 0 auto 14px auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: radial-gradient(circle at top left, #edf5ff, #f7fbff);
  border: 1px solid rgba(221, 227, 238, 0.9);
  box-shadow: 0 10px 30px rgba(15, 35, 52, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-main);
}

.cookie-banner-text a {
  color: var(--primary-dark);
  text-decoration: underline;
}

.cookie-banner-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.cookie-btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
}

.cookie-btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.cookie-btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.cookie-btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-soft);
}

.cookie-btn-secondary:hover {
  border-color: var(--primary);
}

@media (max-width: 640px) {
  .cookie-banner-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .cookie-banner-buttons {
    width: 100%;
    justify-content: flex-end;
  }
}
/* ---- PRIORIDAD EN MOVILES: CALCULADORA ARRIBA ---- */
@media (max-width: 900px) {
  .main-grid {
    display: flex;
    flex-direction: column;
  }

  /* Calculadora primero */
  .calculator-column {
    order: 1;
  }

  /* Contenido después */
  .content-column {
    order: 2;
  }
}
/* ===== ORDEN CORRECTO EN MÓVIL ===== */
@media (max-width: 900px) {

  /* Convertimos el grid en columna */
  .main-grid {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Calculadora primero, justo debajo del header */
  .calculator-column {
    order: 1 !important;
  }

  /* Texto largo después */
  .content-column {
    order: 2 !important;
  }

  /* Sidebar (anuncios) al final */
  .sidebar {
    order: 3 !important;
  }
}
/* ===== MOVIL: QUITAR COLUMNA LATERAL Y ANUNCIO ===== */
@media (max-width: 900px) {

  /* El layout pasa a una sola columna */
  .page {
    grid-template-columns: 1fr !important;
  }

  /* El sidebar NO existe en móvil */
  aside.sidebar,
  .sidebar {
    display: none !important;
  }

  /* Por seguridad, ocultamos cualquier resto */
  .ad-vertical,
  .ad-placeholder-vertical {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Calculadora arriba */
  .main-grid {
    display: flex !important;
    flex-direction: column !important;
  }

  .calculator-column {
    order: 1 !important;
  }

  .content-column {
    order: 2 !important;
  }
}




