/* =============================================================
   1. Tokens — identidad "Finiquito Claro" (papel / libro contable)
   ============================================================= */
:root {
  --paper: #F1EDE3;
  --paper-dark: #E7E0CC;
  --card: #FBF9F3;
  --ink: #1E2B27;
  --ink-soft: #4B5850;
  --ink-faint: #7C877E;
  --brand: #2F5D50;
  --brand-dark: #203F36;
  --brand-tint: #DEE9E4;
  --stamp: #B9812B;
  --stamp-dark: #8F621E;
  --line: #CFC6AC;
  --line-soft: #DFD9C6;
  --alert: #9C4632;
  --alert-tint: #F1DFD7;

  --bg: var(--paper);
  --bg-alt: var(--paper-dark);
  --texto: var(--ink);
  --texto-suave: var(--ink-soft);
  --texto-tenue: var(--ink-faint);
  --borde: var(--line);
  --accent: var(--brand);
  --accent-dark: var(--brand-dark);
  --accent-tint: var(--brand-tint);

  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --display: "Lora", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --radius: 2px;
  --radius-sm: 2px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(30, 43, 39, 0.08);
  --shadow-md: 0 10px 26px rgba(30, 43, 39, 0.14);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --container: 1120px;
}

/* Identidad fija de marca: no cambia con el modo oscuro del sistema —
   "Finiquito Claro" es deliberadamente una estética de papel. */

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3, h4 {
  text-wrap: balance; line-height: 1.2; font-family: var(--display);
  font-weight: 600; color: var(--texto);
}
ul, ol { padding-left: 1.2em; }
::selection { background: var(--accent-tint); color: var(--brand-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.num, .valor, .monto { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--brand); color: #fff;
  z-index: 9999; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: var(--container); margin-inline: auto; padding-inline: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.section { padding-block: clamp(2rem, 5vw, 3.5rem); }
.section-alt { background: var(--bg-alt); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.text-suave { color: var(--texto-suave); }
.badge {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .78rem; font-weight: 600; color: var(--texto-soft);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); letter-spacing: -0.005em; max-width: 18ch; }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); margin-bottom: .8rem; }
h3 { font-size: 1.1rem; margin-bottom: .4rem; }
.subtitulo { color: var(--texto-suave); font-size: 1.05rem; max-width: 58ch; }
.contenido-seo { max-width: 72ch; }
.contenido-seo p { margin-bottom: 1rem; }
.contenido-seo h2, .contenido-seo h3 { margin-top: 1.9rem; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.6rem; border-radius: var(--radius-sm); font-weight: 600; font-family: var(--sans);
  transition: background .15s var(--ease-out), border-color .15s var(--ease-out), color .15s var(--ease-out);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--texto-suave); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand-dark); text-decoration: none; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 68px; }
.logo { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.logo-mark {
  width: 34px; height: 34px; border: 2px solid var(--brand); border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; color: var(--brand); font-size: .85rem;
}
.logo-name { font-family: var(--display); font-weight: 700; font-size: clamp(0.95rem, 3.2vw, 1.2rem); color: var(--texto); }
.logo-name span { color: var(--brand); }
.nav-derecha { display: flex; align-items: center; gap: .9rem; }
.nav-derecha > a { white-space: nowrap; color: var(--texto-suave); font-size: .92rem; font-weight: 500; }
.nav-derecha > a:hover { color: var(--brand-dark); }
@media (max-width: 539px) { .nav-derecha > a { display: none; } }

.selector-pais { position: relative; }
.selector-pais summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .45rem;
  padding: .5rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-pill);
  font-size: .88rem; font-weight: 600; background: var(--paper); color: var(--texto);
}
.selector-pais summary::-webkit-details-marker { display: none; }
.selector-pais summary::after { content: "▾"; font-size: .68rem; color: var(--texto-tenue); }
.selector-pais[open] summary::after { content: "▴"; }
.selector-pais .menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: .4rem; z-index: 60;
}
.selector-pais .menu a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border-radius: var(--radius-sm); font-size: .9rem; color: var(--texto);
}
.selector-pais .menu a:hover { background: var(--bg-alt); text-decoration: none; }
.selector-pais .menu a[aria-current="true"] { background: var(--brand); color: #fff; font-weight: 700; }

/* Hero */
.hero { padding-block: clamp(2rem, 4.5vw, 3.25rem) 1rem; }
.hero .kicker {
  display: flex; flex-wrap: wrap; gap: 1.1rem; color: var(--texto-suave); font-size: .8rem;
  font-weight: 500; margin-bottom: .9rem; align-items: center;
}
.hero .kicker span { display: inline-flex; align-items: center; gap: .45rem; }
.hero .kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }
.hero h1 { color: var(--texto); margin-bottom: .6rem; }

/* Tool card — estilo "libro de asientos" (ledger) */
.tool-card { padding: 0; margin-top: 1.5rem; overflow: hidden; }
.ledger-tab {
  background: var(--brand-dark); color: #EFEAD8; padding: .95rem 1.5rem;
  font-family: var(--display); font-size: .98rem; font-weight: 600;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem;
}
.ledger-tab small { font-family: var(--sans); font-weight: 400; color: #C9D6CF; font-size: .74rem; }
.ledger-body { padding: clamp(1.25rem, 3vw, 2rem); }

.calc-form .form-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
@media (min-width: 720px) { .calc-form .form-grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .84rem; font-weight: 600; color: var(--texto-suave); }
.field .ayuda { font-size: .76rem; color: var(--texto-tenue); }
.field input[type="number"], .field input[type="date"], .field select {
  padding: .68rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: var(--sans); background: #fff; color: var(--texto);
  width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field-checkbox { flex-direction: row; align-items: center; gap: .6rem; }
.field-checkbox input { width: 17px; height: 17px; accent-color: var(--brand); }
.parametros-legales {
  margin-top: 1.1rem; padding: 1rem; background: var(--paper); border: 1px dotted var(--line);
  display: grid; gap: .9rem; grid-template-columns: 1fr;
}
@media (min-width: 720px) { .parametros-legales { grid-template-columns: 1fr 1fr; } }
.parametros-legales .titulo-parametros { grid-column: 1 / -1; font-size: .74rem; font-weight: 700; color: var(--texto-tenue); text-transform: uppercase; letter-spacing: .05em; font-family: var(--mono); }

.calc-form .btn-calc { margin-top: 1.5rem; }

.mensaje-error {
  display: none; margin-top: 1rem; padding: .85rem 1rem; background: var(--alert-tint);
  color: var(--alert); border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600;
}
.mensaje-error.visible { display: block; }

/* Result — "ficha estimada" con sello */
.resultado { display: none; border-top: 1px solid var(--line); padding: clamp(1.25rem, 3vw, 2rem); position: relative; }
.resultado.visible { display: block; }
.sello-estimado {
  position: absolute; top: 20px; right: clamp(1rem, 3vw, 2rem);
  border: 2px solid var(--stamp); color: var(--stamp-dark);
  padding: .35rem .85rem; font-family: var(--mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; transform: rotate(-6deg); border-radius: 4px; opacity: .88; pointer-events: none;
}
.resultado-total {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem; padding-right: 6rem;
}
.resultado-total .etiqueta { font-size: .85rem; color: var(--texto-suave); width: 100%; }
.resultado-total .monto { font-family: var(--mono); font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 700; color: var(--texto); }
.desglose { margin-top: 1.1rem; }
.desglose-item {
  display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0;
  border-bottom: 1px dotted var(--line-soft);
}
.desglose-item .nombre { font-weight: 600; font-size: .95rem; }
.desglose-item .detalle { font-size: .78rem; color: var(--texto-tenue); margin-top: .15rem; }
.desglose-item .valor { font-weight: 600; white-space: nowrap; font-family: var(--mono); }
.acciones-resultado { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.4rem; }

.disclaimer-legal {
  margin-top: 1.5rem; padding: 1.1rem 1.25rem; background: var(--bg-alt); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); font-size: .89rem; color: var(--texto-suave); line-height: 1.6;
}
.badge-privacidad { display: flex; align-items: center; gap: .5rem; margin-top: 1.1rem; font-size: .85rem; color: var(--texto-suave); }
.badge-actualizacion { margin-top: .4rem; font-size: .78rem; color: var(--texto-tenue); font-family: var(--mono); }

/* Ad slots — textura de trama diagonal, estilo "espacio reservado" */
.ad-slot {
  display: flex; align-items: center; justify-content: center; margin-inline: auto;
  border: 1px dashed #B8AF95;
  background: repeating-linear-gradient(135deg, var(--paper-dark), var(--paper-dark) 10px, #E6DFC9 10px, #E6DFC9 20px);
  color: #8A8168; font-size: .74rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  font-family: var(--mono); border-radius: var(--radius-sm);
}
.ad-slot span { opacity: .85; }
.ad-slot--leaderboard { width: 100%; max-width: 728px; height: 90px; }
.ad-slot--mobile-banner { width: 100%; max-width: 320px; height: 100px; }
.ad-slot--rectangle { width: 300px; max-width: 100%; height: 250px; }
.ad-slot--in-card { margin-top: 1.4rem; }
.ad-slot-wrap { display: flex; justify-content: center; padding-block: 1.5rem; }
@media (min-width: 720px) { .ad-slot-wrap .solo-mobile { display: none; } }
@media (max-width: 719px) { .ad-slot-wrap .solo-desktop { display: none; } }

/* Pasos */
.pasos-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.4rem; }
@media (min-width: 720px) { .pasos-grid { grid-template-columns: repeat(4, 1fr); } }
.paso { border-left: 2px solid var(--brand); padding-left: 1rem; }
.paso .paso-n { font-family: var(--mono); color: var(--brand); font-size: .72rem; letter-spacing: .08em; display: block; margin-bottom: .3rem; }
.paso p { color: var(--texto-suave); font-size: .9rem; }

/* Tabla resumen */
.tabla-conceptos { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .92rem; }
.tabla-conceptos th, .tabla-conceptos td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tabla-conceptos th { font-family: var(--display); font-weight: 600; color: var(--texto); border-bottom: 2px solid var(--ink); }
.tabla-conceptos td { color: var(--texto-suave); }
.tabla-conceptos tr td:first-child { color: var(--texto); font-weight: 600; }
.tabla-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tabla-wrap .tabla-conceptos { margin-top: 0; }
.tabla-wrap .tabla-conceptos tr:last-child td { border-bottom: none; }

/* FAQ */
.faq-item { border-bottom: 1px solid var(--line-soft); padding: .2rem 0; }
.faq-item summary {
  cursor: pointer; padding: .95rem 0; font-weight: 600; font-family: var(--display); font-size: 1.02rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem; color: var(--texto);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--brand); font-family: var(--mono); font-size: 1.3rem; line-height: 1; flex: none; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding-bottom: 1rem; color: var(--texto-suave); max-width: 66ch; }

/* Más herramientas / países */
.paises-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; margin-top: 1.25rem; }
@media (min-width: 720px) { .paises-grid { grid-template-columns: repeat(5, 1fr); } }
.pais-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .4rem;
  padding: 1.25rem .75rem; transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), border-color .15s var(--ease-out);
}
.pais-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand); text-decoration: none; }
.pais-card .bandera { font-size: 2.1rem; }
.pais-card .nombre-pais { font-weight: 700; font-family: var(--display); }
.pais-card .termino-pais { font-size: .76rem; color: var(--texto-tenue); }

/* Layout con sidebar */
.layout-con-sidebar { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 960px) { .layout-con-sidebar { grid-template-columns: minmax(0, 1fr) 300px; } }
.sidebar { display: none; }
@media (min-width: 960px) { .sidebar { display: block; } .sidebar .ad-slot { position: sticky; top: 88px; } }

/* Footer */
.site-footer { background: var(--brand-dark); color: #D9E1DB; padding-block: 2.75rem; margin-top: 2.5rem; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 1.75rem; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-grid h4 { color: #fff; font-family: var(--display); font-size: .95rem; margin-bottom: .6rem; }
.footer-grid p { color: #B9C6BE; font-size: .88rem; }
.footer-grid ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .45rem; font-size: .88rem; }
.footer-grid a { color: #B9C6BE; }
.footer-grid a:hover { color: #fff; }
.footer-bottom { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid rgba(255,255,255,.15); font-size: .8rem; color: #A9B7B0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; }
.footer-bottom a { color: #A9B7B0; }
.footer-bottom a:hover { color: #fff; }

/* =============================================================
   9. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pais-card { transition: none; }
}

/* Print */
@media print {
  .site-header, .site-footer, .ad-slot-wrap, .ad-slot, .calc-form, .acciones-resultado, .sidebar, .sello-estimado { display: none !important; }
}
