
/* Layout: three tabs (cuota, sueldo, gastos). Each tab has a sticky input rail on the left and live results on the right; stacks to one column on phones. */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --muted: #55657c;
  --line: #d6dce5;
  --principal: #0b5fa5;
  --interest: #c9731a;
  --accent: #0b5fa5;
  --accent-ink: #ffffff;
  --soft: #e3ebf5;
  --warn-bg: #fbf0df;
  --warn-ink: #7a4509;
  --f-display: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1522; --surface: #132033; --ink: #e7edf6; --muted: #9aabc2; --line: #26364d;
    --principal: #5aa9ee; --interest: #f0a24f; --accent: #5aa9ee; --accent-ink: #08121f; --soft: #1a2c45;
    --warn-bg: #3a2a12; --warn-ink: #f3d6a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1522; --surface: #132033; --ink: #e7edf6; --muted: #9aabc2; --line: #26364d;
  --principal: #5aa9ee; --interest: #f0a24f; --accent: #5aa9ee; --accent-ink: #08121f; --soft: #1a2c45;
  --warn-bg: #3a2a12; --warn-ink: #f3d6a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.55;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 1100px; margin: 0 auto; }
header.top { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.brand { font-family: var(--f-mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(30px, 5vw, 46px); line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.lead { color: var(--muted); max-width: 62ch; margin: 4px 0 0; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs button {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .app { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.inputs { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; }
@media (max-width: 860px) { .inputs { position: static; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .lab { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.field .val { font-family: var(--f-mono); font-weight: 500; color: var(--accent); }
.num { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 0 12px; }
.num:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.num input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-family: var(--f-mono); font-size: 17px; padding: 10px 0; outline: none; }
.num span { color: var(--muted); font-family: var(--f-mono); }
select {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.results { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.hero { display: flex; flex-direction: column; gap: 4px; }
.hero .k { font-size: 13px; font-weight: 600; color: var(--muted); }
.hero .big { font-family: var(--f-display); font-weight: 800; font-size: clamp(40px, 9vw, 68px); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero .big small { font-size: .4em; font-weight: 600; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--bg); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-family: var(--f-mono); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.dot.p { background: var(--principal); } .dot.i { background: var(--interest); }

.saving { background: var(--soft); border-radius: 8px; padding: 12px 14px; font-size: 15px; margin-top: 16px; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 12px 14px; font-size: 14px; margin-top: 16px; }
.saving[hidden], .warn[hidden] { display: none; }
.btn {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; margin-top: 16px; align-self: flex-start;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent); background: transparent; color: var(--accent);
}
.btn:hover { background: var(--soft); }

h2 { font-family: var(--f-display); font-weight: 800; font-size: 22px; margin: 0 0 4px; text-wrap: balance; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.chartbox { overflow-x: auto; }
svg.chart { width: 100%; min-width: 520px; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-family: var(--f-mono); font-size: 11px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .bp { fill: var(--principal); }
svg.chart .bi { fill: var(--interest); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-top: 8px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 380px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-family: var(--f-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 8px 12px; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--soft); font-family: var(--f-body); font-size: 12.5px; font-weight: 600; }
tbody tr + tr td { border-top: 1px solid var(--line); }
tbody tr.me td { background: var(--soft); font-weight: 600; }

.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--bg); margin: 16px 0 6px; }
.bar i { display: block; height: 100%; min-width: 2px; }
.rows { display: flex; flex-direction: column; margin-top: 8px; }
.rows .r { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rows .r:first-child { border-top: 0; }
.rows .r .n { flex: 1; min-width: 0; }
.rows .r .a { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.rows .r.total { font-weight: 600; border-top: 2px solid var(--ink); margin-top: 4px; }

.info { max-width: 72ch; margin: 40px auto 0; display: flex; flex-direction: column; gap: 14px; }
.info h2 { margin-top: 16px; }
.info p { margin: 0; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
summary { cursor: pointer; font-weight: 600; }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
details p { margin-top: 8px; color: var(--muted); }
footer { max-width: 72ch; margin: 28px auto 0; font-size: 13px; color: var(--muted); }
[role="tabpanel"][hidden] { display: none; }

a { color: var(--accent); }
.site-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.site-head .logo { font-family: var(--f-display); font-weight: 800; font-size: 24px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.site-head nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.prose { max-width: 72ch; display: flex; flex-direction: column; gap: 14px; }
.prose h1 { margin-bottom: 4px; }
.prose h2 { margin-top: 18px; }
.prose p, .prose ul { margin: 0; }
.prose ul { padding-left: 20px; }
.callout { background: var(--soft); border-radius: 8px; padding: 14px 16px; }
.cta { display: inline-block; padding: 12px 18px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; align-self: flex-start; }
.cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.linkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; list-style: none; padding: 0; margin: 0; }
.linkgrid a { font-size: 14px; }
.tplbox { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 14px 16px; font-size: 14px; }
.prose .tablewrap { max-height: none; }
