/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --border: #dde1e6;
  --text: #1c2430;
  --text-muted: #5b6572;
  --accent: #0f6e5c;
  --accent-dark: #0b5245;
  --accent-soft: #e3f2ee;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 30, 0.06), 0 4px 14px rgba(20, 24, 30, 0.05);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1c2229;
    --border: #2c343d;
    --text: #eef1f4;
    --text-muted: #a2adb8;
    --accent: #37b799;
    --accent-dark: #2c8f78;
    --accent-soft: #1b2f2b;
    --danger: #e2887f;
    --danger-soft: #34201e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
  scroll-behavior: smooth;
  overflow-x: clip;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent-dark); }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }
::selection { background: var(--accent-soft); color: var(--accent-dark); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 760px; margin-inline: auto; padding-inline: 1.1rem; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 600; text-decoration: none;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / Footer
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.site-header__row {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: .85rem;
}
.logo { font-weight: 700; font-size: 1.05rem; }
.logo-accent { color: var(--accent); }
.header-link { font-size: .92rem; font-weight: 500; text-decoration: none; color: var(--text-muted); }
.header-link:hover { color: var(--accent-dark); }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-block: 1.4rem;
  color: var(--text-muted);
  font-size: .88rem;
}
.site-footer__row { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between; }
.site-footer nav { display: flex; gap: 1rem; }
.site-footer a { text-decoration: none; color: var(--text-muted); }
.site-footer a:hover { color: var(--accent-dark); }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding-block: 1.6rem .9rem; text-align: center; }
.hero h1 { font-size: clamp(1.5rem, 4.6vw, 2.1rem); max-width: 22ch; margin-inline: auto; }
.hero-sub { color: var(--text-muted); margin-top: .6rem; max-width: 46ch; margin-inline: auto; font-size: .98rem; }

/* =============================================================
   6. Tool card
   ============================================================= */
.tool-card {
  max-width: 760px;
  margin: 0 auto 1.4rem;
  padding: 1.1rem 1.1rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
@media (min-width: 540px) { .tool-card { padding: 1.5rem 1.6rem 1.7rem; } }

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .9rem;
  margin-bottom: .9rem;
}
@media (min-width: 620px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
  .field--full { grid-column: 1 / -1; }
}

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .86rem; font-weight: 600; color: var(--text); }
.field .opt { font-weight: 400; color: var(--text-muted); }

.field--otra { animation: fieldIn .18s var(--ease-out); }
@keyframes fieldIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

select, input[type="number"], input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: .62rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
select { appearance: auto; }

.input-prefix, .input-suffix {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.input-prefix:focus-within, .input-suffix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-prefix span, .input-suffix span {
  padding-inline: .65rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .92rem;
}
.input-prefix input, .input-suffix input {
  border: none; box-shadow: none; flex: 1; min-width: 0;
}
.input-prefix input:focus, .input-suffix input:focus { box-shadow: none; }

.unit-input { display: flex; gap: .5rem; }
.unit-input .input-prefix { flex: 1; min-width: 0; }
.unit-input select { width: auto; flex-shrink: 0; min-width: 5rem; }

.field-tip {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

.advanced {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: .1rem .9rem .9rem;
  margin-bottom: 1rem;
}
.advanced summary {
  cursor: pointer;
  padding-block: .7rem;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-muted);
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸ "; color: var(--accent); }
.advanced[open] summary::before { content: "▾ "; }
.advanced .field-grid:first-of-type { margin-top: .2rem; }

.form-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }

.btn {
  border: none; border-radius: var(--radius);
  padding: .75rem 1.4rem;
  font-weight: 600; font-size: .98rem;
  transition: transform .12s var(--ease-out), background .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent-dark); text-decoration: underline; padding-inline: .3rem; }

/* =============================================================
   7. Result
   ============================================================= */
.resultado {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.resultado-titulo { font-size: 1.05rem; margin-bottom: .8rem; }

.desglose {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.desglose li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .6rem .85rem;
  font-size: .92rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.desglose li:last-child { border-bottom: none; }
.desglose li.is-subtotal { background: var(--accent-soft); font-weight: 600; }
.desglose li.is-note { font-size: .82rem; color: var(--text-muted); font-style: italic; }
.desglose .linea-label { color: var(--text-muted); }
.desglose li.is-subtotal .linea-label { color: var(--text); }
.desglose .linea-valor { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

.resultado-final {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--accent-dark);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1.02rem;
  font-weight: 600;
}
.resultado-final strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.resultado-nota { margin-top: .7rem; font-size: .82rem; color: var(--text-muted); }

.error-state {
  margin-top: 1.2rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .9rem;
  font-weight: 500;
}

.privacy-badge {
  margin-top: 1.1rem;
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}

/* =============================================================
   8. Ad slots
   ============================================================= */
.ad-slot {
  max-width: 760px;
  margin: 0 auto 1.6rem;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ad-slot--footer { margin-top: 1.6rem; margin-bottom: 0; }

/* =============================================================
   9. Content sections
   ============================================================= */
.content-section { padding-block: 1.4rem; }
.content-section h2 { font-size: 1.15rem; margin-bottom: .7rem; }
.content-section h2 + h2 { margin-top: 1.3rem; }
.content-section p { color: var(--text-muted); margin-bottom: .5rem; }
.content-section p + h2 { margin-top: 1.3rem; }

.steps { list-style: none; display: flex; flex-direction: column; gap: .9rem; margin: 1rem 0 1.6rem; }
.steps li { display: flex; gap: .8rem; align-items: flex-start; }
.step-num {
  flex-shrink: 0;
  width: 1.9rem; height: 1.9rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-dark);
  border-radius: 50%; font-weight: 700; font-size: .88rem;
}
.steps div { color: var(--text-muted); font-size: .95rem; }
.steps strong { color: var(--text); }

.faq-list { display: flex; flex-direction: column; gap: .55rem; }
.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .2rem .95rem;
  background: var(--surface);
}
.faq-list summary {
  cursor: pointer;
  padding-block: .75rem;
  font-weight: 600;
  font-size: .95rem;
  list-style: none;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::before { content: "+ "; color: var(--accent); }
.faq-list details[open] summary::before { content: "– "; }
.faq-list p { padding-bottom: .85rem; color: var(--text-muted); font-size: .92rem; margin: 0; }

.disclaimer {
  font-size: .82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  padding-bottom: 1.6rem;
}

/* =============================================================
   10. Standalone legal pages
   ============================================================= */
.legal-page { padding-block: 2rem 3rem; }
.legal-page h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.legal-page .updated { color: var(--text-muted); font-size: .85rem; margin-bottom: 1.4rem; }
.legal-page h2 { font-size: 1.05rem; margin-top: 1.4rem; margin-bottom: .5rem; }
.legal-page p, .legal-page li { color: var(--text-muted); font-size: .95rem; }
.legal-page ul { padding-left: 1.2rem; margin-top: .4rem; }
.legal-page a.back { display: inline-block; margin-top: 1.6rem; font-size: .9rem; }
