/* ===== Tokens ===== */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1c1d1a;
  --muted: #5f625b;
  --line: #e2e0d8;
  --accent: #0f6b4f;
  --accent-soft: #e3f1ea;
  --gravado: #d9a441;
  --isr: #c4553b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --surface: #1b1e1b;
    --text: #ecebe6;
    --muted: #a3a69e;
    --line: #2d312d;
    --accent: #4cc493;
    --accent-soft: #1d3329;
    --gravado: #e0b55c;
    --isr: #e07a60;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, p, dl, dd, ol { margin: 0; }
a { color: var(--accent); }
input, select, button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* ===== Header ===== */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 18px; }
.logo span { color: var(--text); }
.logo b { color: var(--accent); }

/* ===== Menú de calculadoras ===== */
.menu { display: flex; gap: 4px; }
.menu a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.menu a:hover { color: var(--text); background: var(--bg); }
.menu a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 380px) { .logo span { font-size: 16px; } .menu a { padding: 6px 8px; } }

/* ===== Hero ===== */
.hero { padding-top: 24px; padding-bottom: 8px; }
h1 { font-size: clamp(26px, 6vw, 38px); line-height: 1.15; letter-spacing: -0.02em; }
.sub { color: var(--muted); margin-top: 6px; }

.sello {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
}

/* ===== Tool card ===== */
.tool-card {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
@media (min-width: 720px) {
  .tool-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 24px; gap: 28px; }
}

.campos { display: grid; gap: 16px; align-content: start; min-width: 0; }
.campo { display: grid; gap: 6px; }
.campo > label, .sub-campo > label { font-weight: 600; font-size: 15px; }
.campo small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.sub-campo { display: grid; gap: 6px; margin-top: 8px; }

input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sueldo { display: grid; grid-template-columns: auto 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.sueldo:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.sueldo .pesos { padding-left: 12px; color: var(--muted); font-weight: 600; }
.sueldo input, .sueldo select { border: 0; background: transparent; outline: none; }
.sueldo input { font-size: 20px; font-weight: 600; padding-left: 6px; min-width: 0; }
.sueldo select { width: auto; color: var(--muted); padding-right: 8px; border-left: 1px solid var(--line); border-radius: 0; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ===== Campos del finiquito ===== */
.fila-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.fila-2 input { min-width: 0; }
.fila-2 .campo > label { font-size: 14px; }
fieldset.motivo { border: 0; margin: 0; padding: 0; min-width: 0; }
.motivo legend { font-weight: 600; font-size: 15px; margin-bottom: 6px; padding: 0; }
.opciones { display: grid; gap: 6px; }
.opciones label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  font-size: 15px;
  transition: border-color .15s ease, background .15s ease;
}
.opciones input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.opciones label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.opciones label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mas { border-top: 1px solid var(--line); padding-top: 10px; }
.mas summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 15px; }
.mas-in { display: grid; gap: 14px; margin-top: 12px; }
.mas-in small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.desglose.conceptos { gap: 8px; }
.desglose.conceptos div { align-items: flex-start; }
.desglose.conceptos dt { flex-direction: column; align-items: flex-start; gap: 0; color: var(--text); }
.desglose.conceptos dt small { color: var(--muted); font-size: 12px; }
.desglose.extra { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,.08); }
@media (prefers-color-scheme: dark) { .desglose.extra { border-top-color: rgba(255,255,255,.08); } }

/* ===== Result ===== */
.resultado {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 18px;
  display: grid;
  align-content: center;
}
.aviso { color: var(--muted); text-align: center; }
.hecho { display: none; }
.tool-card[data-state="done"] .hecho { display: block; animation: aparecer .35s ease both; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tool-card[data-state="done"] .aviso { display: none; }

.etiqueta { color: var(--muted); font-size: 14px; }
.neto { font-size: clamp(34px, 9vw, 46px); font-weight: 700; color: var(--accent); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.nota-neto { color: var(--muted); font-size: 13px; }

.barra { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 14px 0; background: var(--line); gap: 2px; }
.barra span { display: block; height: 100%; transition: width .25s ease; }
.b-exento, .d-exento { background: var(--accent); }
.b-gravado, .d-gravado { background: var(--gravado); }
.b-isr, .d-isr { background: var(--isr); }

.desglose { display: grid; gap: 6px; font-size: 14px; }
.desglose div { display: flex; justify-content: space-between; gap: 12px; }
.desglose dt { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.desglose dd { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.formula { margin-top: 10px; font-size: 12px; color: var(--muted); }

.btn {
  margin-top: 14px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-size: 16px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .btn { color: #0c1a14; } }
.btn:hover { filter: brightness(1.08); }

.badge { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: center; }

/* ===== Botones de acción ===== */
.acciones { display: grid; gap: 8px; margin-top: 14px; }
.acciones .btn { margin-top: 0; }

/* ===== Botón flotante de WhatsApp (siempre visible) ===== */
.wa-flotante {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px 12px 14px;
  border-radius: 999px;
  background: #157a43;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.wa-flotante:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,.26); }
.wa-flotante svg { width: 22px; height: 22px; flex: none; }
@media (prefers-color-scheme: dark) { .wa-flotante { background: #25d366; color: #0b2414; } }
@media (prefers-reduced-motion: reduce) { .wa-flotante { transition: none; } .wa-flotante:hover { transform: none; } }
/* Espacio al final para que el botón no tape el pie de página. */
body:has(.wa-flotante) .pie { padding-bottom: 84px; }

/* ===== Embed (calculadora dentro de otras páginas) ===== */
body.embed { background: var(--surface); }
.embed .embed-in { padding: 12px; }
.embed h1 { font-size: 20px; margin-bottom: 4px; }
.embed .tool-card { margin-top: 10px; box-shadow: none; padding: 14px; }
.embed .credito { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.embed .credito a { font-weight: 600; }

/* ===== Página para insertar ===== */
.codigo { width: 100%; min-height: 150px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.vista-previa { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 12px; }
.vista-previa iframe { display: block; width: 100%; height: 920px; border: 0; }

/* ===== Ad slots (vacíos hasta activar AdSense) ===== */
.ad-slot {
  margin: 28px 0;
  min-height: 100px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ad-contenido { min-height: 250px; }

/* ===== Content ===== */
.contenido h2, .faq h2 { font-size: 22px; margin: 28px 0 10px; letter-spacing: -0.01em; }
.contenido p { margin-bottom: 12px; }
.pasos { padding-left: 20px; display: grid; gap: 8px; margin-bottom: 14px; }

.faq { padding-bottom: 32px; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin-top: 8px; color: var(--muted); }

/* ===== Más calculadoras ===== */
.otras { padding-bottom: 32px; }
.otras h2 { font-size: 22px; margin: 8px 0 12px; letter-spacing: -0.01em; }
.tarjetas { display: grid; gap: 12px; }
@media (min-width: 620px) { .tarjetas { grid-template-columns: 1fr 1fr; } }
.tarjeta {
  display: grid; gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tarjeta strong { color: var(--accent); }
.tarjeta strong::after { content: " →"; }
.tarjeta span { color: var(--muted); font-size: 14px; }
.tarjeta:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.contenido ul.pasos { list-style: disc; }

/* ===== Legal pages ===== */
.legal { padding-top: 24px; padding-bottom: 40px; }
.legal h1 { font-size: 30px; margin-bottom: 14px; }
.legal h2 { font-size: 19px; margin: 22px 0 8px; }
.legal p, .legal li { margin-bottom: 10px; }
.todo { background: #fff3c4; color: #5a4300; padding: 0 4px; border-radius: 4px; }

/* ===== Footer ===== */
.pie { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0; font-size: 13px; color: var(--muted); }
.pie p { margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) {
  .barra span, .tarjeta, .opciones label { transition: none; }
  .tool-card[data-state="done"] .hecho { animation: none; }
  .tarjeta:hover { transform: none; }
}
