/* CalculaFiniquito — estética institucional chilena (limpia, seria, confiable). */

:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --ink: #16202b;
  --ink-soft: #51616e;
  --primary: #0b4f8a;      /* azul institucional */
  --primary-dark: #073a68;
  --primary-tint: #e7f0f8;
  --accent-red: #d52b1e;   /* rojo bandera, uso mínimo */
  --line: #d5dfe8;
  --ok: #1c7a44;
  --ok-tint: #e6f4ec;
  --warn: #a15c00;
  --warn-tint: #fbf1df;
  --focus: #2f80ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 43, .06), 0 4px 16px rgba(16, 32, 43, .05);
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1620; --surface: #17222e; --surface-2: #1d2a37;
    --ink: #e7eef4; --ink-soft: #9fb1bf; --primary: #4fa3e3; --primary-dark: #3a8bcb;
    --primary-tint: #172c3d; --line: #26333f; --ok: #4cc178; --ok-tint: #14301f;
    --warn: #d99a3a; --warn-tint: #30260f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1620; --surface: #17222e; --surface-2: #1d2a37;
  --ink: #e7eef4; --ink-soft: #9fb1bf; --primary: #4fa3e3; --primary-dark: #3a8bcb;
  --primary-tint: #172c3d; --line: #26333f; --ok: #4cc178; --ok-tint: #14301f;
  --warn: #d99a3a; --warn-tint: #30260f;
}
:root[data-theme="light"] {
  --bg: #eef2f6; --surface: #ffffff; --surface-2: #f6f9fc; --ink: #16202b; --ink-soft: #51616e;
  --primary: #0b4f8a; --primary-dark: #073a68; --primary-tint: #e7f0f8; --line: #d5dfe8;
  --ok: #1c7a44; --ok-tint: #e6f4ec; --warn: #a15c00; --warn-tint: #fbf1df;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
}
a { color: var(--primary); }

.container { width: 100%; max-width: 940px; margin: 0 auto; padding: 0 20px; }

/* franja tricolor superior (guiño institucional) */
.topstripe { height: 4px; background: linear-gradient(to right, var(--accent-red) 0 33%, #fff 33% 66%, var(--primary) 66% 100%); }

/* header */
.site-header { background: var(--primary); color: #fff; }
.site-header .container { display: flex; align-items: center; gap: 14px; padding-top: 16px; padding-bottom: 16px; }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 8px; background: #fff;
  color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; margin: 0; }
.brand-tag { margin: 2px 0 0; font-size: .8rem; opacity: .9; }

/* nav del hub de calculadoras */
.site-nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-nav .container { display: flex; gap: 4px; padding-top: 0; padding-bottom: 0; overflow-x: auto; }
.site-nav a {
  padding: 13px 14px; font-size: .9rem; font-weight: 600; color: var(--ink-soft);
  text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.site-nav a:hover { color: var(--primary); }
.site-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* hero */
.hero { padding: 30px 0 8px; }
.hero h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 8px; text-wrap: balance; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--ink-soft); max-width: 60ch; }
.trust { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.trust span {
  font-size: .78rem; font-weight: 600; color: var(--primary-dark);
  background: var(--primary-tint); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px;
}
:root[data-theme="dark"] .trust span, @media (prefers-color-scheme: dark) { }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card + .card { margin-top: 18px; }
main { padding-bottom: 40px; }
section { margin-top: 22px; }

.card h2 { font-size: 1.15rem; margin: 0 0 4px; letter-spacing: -.01em; }
.card .subtitle { color: var(--ink-soft); font-size: .9rem; margin: 0 0 18px; }

/* form */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .field-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .78rem; color: var(--ink-soft); }
.field input, .field select {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
.field input:focus, .field select:focus, .btn:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--focus);
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }

/* condicionales (aviso previo) ocultos según causal */
.cond { display: none; }
.cond.show { display: flex; }

.actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 700; border: 1px solid transparent; border-radius: 8px;
  padding: 12px 22px; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); }

/* resultado */
.result { display: none; }
.result.show { display: block; }
.result .total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  background: var(--ok-tint); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px; margin-bottom: 16px;
}
.result .total .lbl { font-weight: 600; color: var(--ink); }
.result .total .amt { font-size: 1.9rem; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result .total .sub { display: block; font-size: .72rem; font-weight: 500; color: var(--ink-soft); text-align: right; }

.table-wrap { overflow-x: auto; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.breakdown th, table.breakdown td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.breakdown td.amt, table.breakdown th.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.breakdown .glosa { display: block; font-size: .78rem; color: var(--ink-soft); }
table.breakdown tr:last-child td { border-bottom: 0; }

.notes { margin-top: 14px; padding: 12px 14px; background: var(--warn-tint); border: 1px solid var(--line); border-radius: 8px; font-size: .86rem; }
.notes ul { margin: 6px 0 0; padding-left: 18px; }

.disclaimer { margin-top: 16px; font-size: .82rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 14px; }

.error { color: var(--accent-red); font-size: .88rem; margin-top: 10px; font-weight: 600; }

/* espacio publicitario (placeholder) */
.ad-slot {
  margin: 22px 0; min-height: 100px; border: 1px dashed var(--line); border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-soft); font-size: .78rem;
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,.015) 10px, rgba(0,0,0,.015) 20px);
}

/* contenido (guía / faq / legal) */
.prose h2 { font-size: 1.25rem; margin: 0 0 10px; }
.prose h3 { font-size: 1rem; margin: 18px 0 6px; }
.prose p, .prose li { color: var(--ink); }
.prose p { max-width: 68ch; }
.prose ul { padding-left: 20px; }
details.faq-item { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: var(--surface); }
details.faq-item summary { cursor: pointer; font-weight: 600; padding: 14px 16px; list-style: none; }
details.faq-item summary::-webkit-details-marker { display: none; }
details.faq-item summary::after { content: "+"; float: right; color: var(--primary); font-weight: 800; }
details.faq-item[open] summary::after { content: "–"; }
details.faq-item .faq-body { padding: 0 16px 14px; color: var(--ink-soft); font-size: .93rem; }

.legal-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; font-size: .9rem; }
.legal-box code { background: var(--primary-tint); padding: 1px 6px; border-radius: 4px; font-size: .85em; }

/* footer */
.site-footer { background: var(--primary-dark); color: #dbe7f1; font-size: .85rem; }
.site-footer .container { padding-top: 26px; padding-bottom: 26px; }
.site-footer strong { color: #fff; }
.site-footer a { color: #cfe2f2; }
.site-footer .fine { margin-top: 12px; opacity: .8; font-size: .78rem; }

.theme-toggle {
  margin-left: auto; background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: .82rem; cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.24); }

@media (prefers-reduced-motion: no-preference) {
  .result.show { animation: fade .25s ease; }
  @keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ─────────────────────────────────────────────
   HUB — estilos propios de la home de TuCálculo
   ───────────────────────────────────────────── */

/* rejilla de calculadoras */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 4px; }

.calc-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; text-decoration: none; color: inherit;
  border-top: 3px solid var(--primary);
}
.calc-card:hover { border-color: var(--primary); box-shadow: 0 2px 4px rgba(16,32,43,.08), 0 8px 24px rgba(16,32,43,.10); }
.calc-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.calc-card .ico { font-size: 1.5rem; line-height: 1; }
.calc-card h3 { margin: 0; font-size: 1.02rem; color: var(--primary); letter-spacing: -.01em; }
.calc-card p { margin: 0; font-size: .88rem; color: var(--ink-soft); }
.calc-card .go { margin-top: auto; padding-top: 8px; font-size: .82rem; font-weight: 700; color: var(--primary); }

/* tarjeta "próximamente" (no enlazada) */
.calc-card.soon { border-top-color: var(--line); opacity: .72; }
.calc-card.soon h3 { color: var(--ink-soft); }
.calc-card.soon .go { color: var(--ink-soft); }

/* bloque de confianza en la home */
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.why-grid h3 { margin: 0 0 4px; font-size: .98rem; }
.why-grid p { margin: 0; font-size: .88rem; color: var(--ink-soft); }

/* páginas legales: índice y textos largos */
.legal-toc { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; font-size: .9rem; }
.legal-toc ol { margin: 6px 0 0; padding-left: 20px; }
.legal-toc a { text-decoration: none; }
.legal-toc a:hover { text-decoration: underline; }
.updated { font-size: .82rem; color: var(--ink-soft); margin: 0 0 18px; }
.prose h2[id] { scroll-margin-top: 16px; }
