/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e2e1dc;
  --ink: #1c1c1a;
  --ink-soft: #55534c;
  --accent: #1f6f4f;
  --accent-ink: #ffffff;
  --accent-soft: #e7f3ec;
  --warn: #a15a00;
  --warn-bg: #fdf1df;
  --danger: #b23b3b;
  --danger-bg: #fbe9e9;
  --favor: #1f6f4f;
  --favor-bg: #e7f3ec;
  --radius: 12px;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1d1e17;
    --border: #33342a;
    --ink: #f1f1ea;
    --ink-soft: #b9b9ac;
    --accent: #4fbd8b;
    --accent-ink: #0b1a13;
    --accent-soft: #1c2e24;
    --warn: #e0a94b;
    --warn-bg: #322a15;
    --danger: #e08080;
    --danger-bg: #331b1b;
    --favor: #4fbd8b;
    --favor-bg: #1c2e24;
  }
}

/* =============================================================
   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);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-family: var(--mono); background: var(--accent-soft); padding: .1em .4em; border-radius: 4px; font-size: .9em; }

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

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

.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  padding: .8rem 1.4rem; border-radius: 10px; font-weight: 700;
  transition: transform .15s var(--ease-out), opacity .15s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-ghost {
  border: 1px solid var(--border); padding: .65rem 1.1rem; border-radius: 10px;
  font-weight: 600; color: var(--ink); background: var(--surface);
  transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--accent); }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-row { display: flex; align-items: center; justify-content: space-between; padding-block: .9rem; }
.brand { font-weight: 800; font-size: 1.05rem; }
.brand span strong { color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding-block: 1.5rem; }
.site-footer p { color: var(--ink-soft); font-size: .85rem; }

/* =============================================================
   5. Intro & disclaimer
   ============================================================= */
.intro { padding-top: 2.2rem; }
.intro h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
.subtitle { color: var(--ink-soft); margin-top: .5rem; max-width: 60ch; }

.disclaimer {
  margin-top: 1.25rem; background: var(--warn-bg); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  padding: .9rem 1.1rem; border-radius: var(--radius); font-size: .92rem; line-height: 1.5;
}
.disclaimer code { color: var(--ink); }

/* =============================================================
   6. Wizard / tool card
   ============================================================= */
.tool-card {
  margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.wizard-progress {
  height: 4px; background: var(--border); border-radius: 4px; margin-bottom: 1.5rem; overflow: hidden;
}
.wizard-progress::after {
  content: ""; display: block; height: 100%; width: var(--pct, 20%);
  background: var(--accent); transition: width .3s var(--ease-out);
}

.step { display: none; }
.step.is-active { display: block; animation: fadeIn .25s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step h2 { font-size: 1.25rem; }
.step-help { color: var(--ink-soft); font-size: .92rem; margin-top: .35rem; margin-bottom: 1.1rem; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; }
.option-card {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 1rem .8rem;
  text-align: center; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s;
}
.option-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.option-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.option-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1rem; }
.field-grid.single { grid-template-columns: 1fr; }
.field {
  display: flex; flex-direction: column; gap: .4rem; font-size: .88rem;
  font-weight: 600; color: var(--ink-soft);
}
.field input[type="number"] {
  font: inherit; font-family: var(--mono); font-size: 1rem; color: var(--ink);
  padding: .7rem .8rem; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); width: 100%;
}
.field input[type="number"]:focus { border-color: var(--accent); outline: none; }
.checkbox-field {
  flex-direction: row; align-items: center; gap: .6rem; margin-bottom: 1rem;
  font-weight: 500; color: var(--ink);
}
.checkbox-field input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.pdf-upload { margin-bottom: .5rem; }
.pdf-dropzone {
  display: flex; align-items: center; gap: .9rem; border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 1rem 1.1rem; cursor: pointer; background: var(--bg);
  transition: border-color .15s, background .15s;
}
.pdf-dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.pdf-icon { font-size: 1.6rem; }
.pdf-text { display: flex; flex-direction: column; gap: .2rem; }
.pdf-text strong { font-size: .95rem; }
.pdf-text small { color: var(--ink-soft); font-size: .82rem; }
.pdf-note { margin-top: .5rem; margin-bottom: 1rem; }

.pdf-status {
  margin-top: .8rem; padding: .8rem 1rem; border-radius: 10px; font-size: .88rem;
}
.pdf-status[data-kind="cargando"] { background: var(--accent-soft); color: var(--accent); }
.pdf-status[data-kind="ok"] { background: var(--favor-bg); color: var(--favor); }
.pdf-status[data-kind="error"] { background: var(--danger-bg); color: var(--danger); }
.pdf-status ul { margin-top: .5rem; padding-left: 1.1rem; }
.pdf-status li { margin-top: .15rem; }

.field-total {
  margin-top: 1rem; font-weight: 700; font-family: var(--mono);
  background: var(--accent-soft); color: var(--accent); padding: .7rem 1rem; border-radius: 8px;
}

.wizard-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.step-indicator { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }

/* =============================================================
   7. Resultados
   ============================================================= */
.resultados { margin-top: 2rem; padding-bottom: 2rem; }
.result-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.result-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; margin-bottom: 1rem;
}
.result-card h3 { font-size: 1.05rem; margin-bottom: .8rem; }

.status-banner {
  display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem; border-radius: 10px; font-weight: 700;
}
.status-banner.si { background: var(--warn-bg); color: var(--warn); }
.status-banner.no { background: var(--favor-bg); color: var(--favor); }
.status-detail { margin-top: .8rem; font-size: .85rem; color: var(--ink-soft); }
.status-detail ul { padding-left: 1.2rem; margin-top: .4rem; }
.status-detail li.superado { color: var(--warn); font-weight: 600; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.summary-item { background: var(--bg); border-radius: 8px; padding: .8rem .9rem; }
.summary-item .label { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.summary-item .value { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; margin-top: .2rem; }

.steps-explained { padding-left: 1.1rem; display: flex; flex-direction: column; gap: .9rem; }
.steps-explained li { padding-left: .3rem; }
.steps-explained .line-label { font-weight: 600; }
.steps-explained .line-value { font-family: var(--mono); font-weight: 700; }
.steps-explained .line-note { display: block; color: var(--ink-soft); font-size: .85rem; margin-top: .15rem; }

.deductions-list { list-style: none; display: flex; flex-direction: column; gap: .7rem; }
.deductions-list li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--border); padding-bottom: .6rem; }
.deductions-list .d-name { font-weight: 600; }
.deductions-list .d-note { display: block; color: var(--ink-soft); font-size: .82rem; margin-top: .15rem; }
.deductions-list .d-value { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.deductions-list .empty { color: var(--ink-soft); font-style: italic; }

.saldo-banner { text-align: center; padding: 1.5rem 1rem; border-radius: 10px; }
.saldo-banner.pagar { background: var(--danger-bg); color: var(--danger); }
.saldo-banner.favor { background: var(--favor-bg); color: var(--favor); }
.saldo-banner .saldo-amount { font-size: 1.8rem; font-weight: 800; font-family: var(--mono); margin-top: .3rem; }

/* =============================================================
   8. Escenarios
   ============================================================= */
.escenarios-panel { margin-top: 1.5rem; }
.escenarios-lista { display: flex; flex-direction: column; gap: .8rem; margin: 1rem 0; }
.escenario-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .9rem 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.escenario-info strong { display: block; }
.escenario-info span { color: var(--ink-soft); font-size: .82rem; }
.escenario-actions { display: flex; gap: .5rem; }
.escenario-actions button { font-size: .82rem; padding: .45rem .8rem; }

/* =============================================================
   9. SEO / info
   ============================================================= */
.info-seo { margin-top: 2.5rem; }
.info-seo h2 { font-size: 1.2rem; margin-top: 1.8rem; margin-bottom: .8rem; }
.how-it-works { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .5rem; color: var(--ink-soft); }
.info-seo p { color: var(--ink-soft); margin-top: .6rem; }
details {
  border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; margin-top: .6rem; background: var(--surface);
}
summary { font-weight: 600; cursor: pointer; }
details p { margin-top: .5rem; color: var(--ink-soft); font-size: .92rem; }

/* =============================================================
   10. Responsive
   ============================================================= */
@media (max-width: 540px) {
  .field-grid { grid-template-columns: 1fr; }
  .result-actions { width: 100%; }
  .result-actions button { flex: 1; }
}

/* =============================================================
   11. Print
   ============================================================= */
@media print {
  .site-header, .site-footer, .wizard-nav, .result-actions, #wizard, #panelEscenarios, .btn-ghost, .btn-primary { display: none !important; }
  body { background: #fff; color: #000; }
  .result-card { break-inside: avoid; border-color: #ccc; }
  .container { max-width: 100%; }
}

/* =============================================================
   12. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .step.is-active { animation: none; }
  html { scroll-behavior: auto; }
}
