/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #18201d;
  --muted: #5b6662;
  --line: #e2e6e1;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f3f1;
  --warn: #b42318;
  --gold: #fbbf24;
  --radius: 16px;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --ink: #e8eeeb;
    --muted: #9aa7a2;
    --line: #2a3430;
    --accent: #2dd4bf;
    --accent-ink: #052e2a;
    --accent-soft: #12302b;
    --warn: #f97066;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(100% - 32px, 760px); margin-inline: auto; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 99;
  padding: .6rem 1rem; background: var(--surface); border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   5. Components
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; color: var(--accent); }
.logo span { color: var(--ink); }
.header-link { font-size: .9rem; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--ink); }

.hero { padding-top: 16px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; }
.subtitle { color: var(--muted); margin-top: 6px; }

.tool-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .04);
}

.mode { border: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--bg); border-radius: 12px; padding: 4px; }
.mode-opt { position: relative; }
.mode-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode-opt span {
  display: block; text-align: center; padding: 9px 8px; border-radius: 9px;
  font-size: .88rem; color: var(--muted); transition: background .2s var(--ease-out), color .2s;
}
.mode-opt input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.mode-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { margin-top: 12px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.amount-wrap { position: relative; }
#amount {
  width: 100%; font-size: 1.6rem; font-weight: 700; padding: 10px 44px 10px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
  transition: border-color .2s;
}
#amount:focus { outline: none; border-color: var(--accent); }
.currency { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); }
select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: .92rem;
}
.grid-2 { display: grid; gap: 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.check small { color: var(--muted); }

.error-msg { display: none; color: var(--warn); font-size: .85rem; margin-top: 6px; }
.tool-card[data-state="error"] .error-msg { display: block; }
.tool-card[data-state="error"] #amount { border-color: var(--warn); }

.result { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.result-empty { color: var(--muted); font-size: .92rem; }
.breakdown, .tip, .actions { display: none; }
.tool-card[data-state="done"] .result-empty { display: none; }
.tool-card[data-state="done"] .breakdown { display: block; }
.tool-card[data-state="done"] .tip { display: flex; }
.tool-card[data-state="done"] .actions { display: flex; }
.tool-card[data-state="error"] .result-empty { visibility: hidden; }

.breakdown > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.breakdown dt { color: var(--muted); }
.breakdown dd { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown .neg { color: var(--warn); }
.row-recargo, .row-irpf { display: none !important; }
.has-recargo .row-recargo, .has-irpf .row-irpf { display: flex !important; }
.breakdown .total {
  margin-top: 6px; padding: 12px 14px; border-radius: 12px;
  background: var(--accent-soft); align-items: baseline;
}
.breakdown .total dt { color: var(--ink); font-weight: 700; }
.breakdown .total dd { font-size: 1.7rem; color: var(--accent); }

.tip { gap: 10px; margin-top: 12px; font-size: .88rem; color: var(--muted); }
.tip svg { flex: none; color: var(--gold); margin-top: 2px; }
.tip b { color: var(--ink); }

.actions { gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn { padding: 11px 18px; border-radius: 10px; font-weight: 700; font-size: .95rem; transition: transform .15s var(--ease-out), background .2s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); flex: 1 1 180px; }
.btn-ghost { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.noscript { color: var(--warn); margin-top: 12px; }

.privacy { font-size: .82rem; color: var(--muted); margin-top: 12px; }

.ad-slot {
  display: grid; place-items: center; margin: 28px 0;
  border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
}
.ad-leaderboard { min-height: 100px; }
.ad-incontent { min-height: 250px; }

/* =============================================================
   6. Sections
   ============================================================= */
.content h2 { font-size: 1.45rem; margin: 36px 0 14px; }
.content h3 { font-size: 1.1rem; margin: 22px 0 8px; }
.steps { list-style: none; padding: 0; display: grid; gap: 12px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.steps svg { color: var(--accent); margin-bottom: 8px; }
.steps h3 { margin: 0 0 4px; font-size: 1rem; }
.steps p { color: var(--muted); font-size: .92rem; }
.seo-text p { margin-bottom: 12px; }

.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin-top: 8px; color: var(--muted); }

.more-grid { display: grid; gap: 12px; }
.more-card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; text-decoration: none; transition: border-color .2s;
}
.more-card:hover { border-color: var(--accent); }
.more-card b { display: block; }
.more-card span { color: var(--muted); font-size: .9rem; }
.more-card.is-soon { opacity: .6; }

.site-footer { margin-top: 48px; border-top: 1px solid var(--line); padding: 22px 0; font-size: .88rem; color: var(--muted); }
.footer-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.footer-row nav { display: flex; gap: 16px; }

/* Modelo 303 */
.group { border: 0; padding: 0; margin-top: 4px; }
.group + .group { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.group legend { float: left; width: 100%; font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: 6px; }
.group legend + * { clear: both; }
.group legend small { font-weight: 500; color: var(--muted); }
.vat-row { display: grid; grid-template-columns: 1fr 120px 92px; gap: 10px; align-items: center; padding: 4px 0; }
.vat-row label { font-size: .88rem; color: var(--muted); line-height: 1.3; }
.amount-wrap.sm input {
  width: 100%; font-weight: 700; padding: 8px 28px 8px 10px; text-align: right;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.amount-wrap.sm input:focus { outline: none; border-color: var(--accent); }
.amount-wrap.sm input.is-invalid { border-color: var(--warn); }
.amount-wrap.sm .currency { right: 10px; font-size: .95rem; }
.quota { text-align: right; font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.more-rates summary { cursor: pointer; font-size: .85rem; color: var(--accent); font-weight: 600; padding: 4px 0; }
.result-303 { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.calc-303 .breakdown { display: block; }
.calc-303 .row-comp { display: none; }
.calc-303.has-comp .row-comp { display: flex; }
.calc-303.is-negative .breakdown .total dd { color: var(--gold); }
.verdict { font-size: .92rem; margin-top: 8px; }
.quarter-field { margin-top: 10px; }
.deadline { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.deadline svg { flex: none; margin-top: 2px; color: var(--accent); }
.crosslink { font-size: .9rem; margin-top: 6px; }
.crosslink a { color: var(--accent); font-weight: 600; }
.dates { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .92rem; }
.dates th, .dates td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.dates th { color: var(--muted); font-weight: 600; }

.legal { padding: 32px 0; }
.legal h1 { font-size: 2rem; margin-bottom: 16px; }
.legal h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.legal p { margin-bottom: 10px; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .tool-card { padding: 24px; }
  .mode-opt span { font-size: .95rem; }
}
@media (min-width: 720px) {
  .hero { padding-top: 40px; }
  .steps, .more-grid { grid-template-columns: repeat(3, 1fr); }
}
