
/* Layout: two-column tool — inputs on the left, results + chart on the right; stacks on phones. */
:root {
  --bg: #eef2ef;
  --surface: #ffffff;
  --ink: #15211c;
  --muted: #5b6b64;
  --line: #d5ded9;
  --accent: #0b5a45;      /* capital inicial */
  --accent-2: #3e9c7c;    /* reforços */
  --accent-soft: #cfe6dc;
  --gain: #d4891c;        /* juros */
  --gain-soft: #f6e2c2;
  --focus: #1b5fd1;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1714; --surface: #17221e; --ink: #e8efeb; --muted: #9aaba3; --line: #2a3832;
    --accent: #2f9a78; --accent-2: #6fd1ad; --accent-soft: #1d3d32; --gain: #f0a73d; --gain-soft: #463316; --focus: #7aa8ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1714; --surface: #17221e; --ink: #e8efeb; --muted: #9aaba3; --line: #2a3832;
  --accent: #2f9a78; --accent-2: #6fd1ad; --accent-soft: #1d3d32; --gain: #f0a73d; --gain-soft: #463316; --focus: #7aa8ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  padding: 32px 20px 48px;
}
.wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 24px; }
header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; }
header h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1; margin: 0 0 6px; text-wrap: balance; letter-spacing: -0.01em;
}
header p { margin: 0; color: var(--muted); max-width: 62ch; }
.prefs { display: flex; gap: 10px; flex-wrap: wrap; }
.pref { display: grid; gap: 4px; }
.pref label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
select {
  font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
select:hover { border-color: var(--accent); }
select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

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

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; min-width: 0; }
.card h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin: 0 0 14px; }

/* Inputs */
form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field label, .label { font-weight: 600; font-size: .95rem; }
.hint { color: var(--muted); font-size: .82rem; text-align: end; }
.num {
  display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); overflow: hidden; transition: border-color .15s;
}
.num:focus-within { border-color: var(--accent); }
.num input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font-family: var(--font-num); font-size: 1.1rem; padding: 10px 12px; outline: none;
  font-variant-numeric: tabular-nums;
}
.num .unit { padding: 0 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.num select {
  border: 0; border-inline-start: 1.5px solid var(--line); border-radius: 0; background: var(--surface);
  align-self: stretch; padding: 0 10px; font-weight: 500; font-size: .9rem;
}
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; height: 22px; cursor: pointer; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  text-align: center; padding: 9px 4px; font-weight: 500; font-size: .86rem; cursor: pointer;
  border-inline-start: 1px solid var(--line); color: var(--muted); user-select: none;
}
.seg label:first-of-type { border-inline-start: 0; }
.seg input:checked + label { background: var(--accent); color: #fff; }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -3px; }

details { border-top: 1px solid var(--line); padding-top: 14px; }
summary { cursor: pointer; font-weight: 600; font-size: .95rem; color: var(--accent); }
details .field { margin-top: 14px; }

button:focus-visible, summary:focus-visible, input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Results */
.results { display: grid; gap: 24px; min-width: 0; }
.hero { display: grid; gap: 6px; }
.hero .label { color: var(--muted); font-weight: 500; }
.big {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.3rem, 6vw, 3.6rem);
  line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.sentence { margin: 6px 0 0; max-width: 60ch; }
.sentence b { font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } }
.tile { border-radius: 10px; padding: 12px 14px; background: var(--bg); border-left: 4px solid var(--line); }
.tile .t { font-size: .82rem; color: var(--muted); }
.tile .v { font-family: var(--font-num); font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile.inv { border-left-color: var(--accent); }
.tile.gain { border-left-color: var(--gain); }
.tile.real { border-left-color: var(--muted); }

.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.bar span { display: block; height: 100%; transition: width .3s; }
.bar .a { background: var(--accent); } .bar .g { background: var(--gain); }
.bar-legend { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin-top: 6px; gap: 8px; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; flex: none; }
.dash { display: inline-block; width: 16px; height: 0; border-top: 2px dashed var(--ink); margin-right: 6px; vertical-align: 3px; }

/* Tabs */
.tabs-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.tabs button {
  font: inherit; font-weight: 500; font-size: .9rem; padding: 6px 16px; border-radius: 7px; cursor: pointer;
  border: 0; background: transparent; color: var(--muted);
}
.tabs button[aria-pressed="true"],
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Chart */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; color: var(--muted); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; }
.chart-wrap { position: relative; touch-action: pan-y; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--font-body); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gl line { stroke: var(--line); stroke-width: 1; }
.chart .end { fill: var(--ink); font-weight: 600; font-size: 12.5px; }
.chart .end-sub { font-size: 11px; }
.chart .mark { fill: var(--gain); font-weight: 600; font-size: 11px; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.14);
  border-radius: 10px; padding: 10px 12px; font-size: .82rem; line-height: 1.5;
  min-width: 210px; opacity: 0; transition: opacity .1s; font-variant-numeric: tabular-nums; z-index: 2;
}
.tip.on { opacity: 1; }
.tip .h { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 12px; }
.tip .r { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.tip .r span:first-child { display: inline-flex; align-items: center; color: var(--muted); }
.tip .tot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; font-weight: 600; }
.chart-note { font-size: .84rem; color: var(--muted); margin: 10px 0 0; }

/* Table */
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: end; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: start; padding-inline-start: 14px; }
th:last-child, td:last-child { padding-inline-end: 14px; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); font-weight: 600; color: var(--muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; vertical-align: bottom; line-height: 1.3;
}
tfoot td { position: sticky; bottom: 0; background: var(--surface); font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; }
tbody tr:hover td { background: var(--bg); }
td.yr { font-weight: 600; }
td.g { color: var(--gain); }
td.m { color: var(--muted); }
td.bal { font-weight: 600; }
.mini { display: flex; width: 64px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); margin-inline-start: auto; }
.mini i { display: block; height: 100%; }
.chip {
  display: inline-block; margin-inline-start: 8px; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: var(--gain-soft); color: var(--ink); vertical-align: 1px;
}
tr.turn td { background: color-mix(in srgb, var(--gain-soft) 45%, transparent); }
.tbl-tools { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--muted); }
#every-wrap { display: inline-flex; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
tr.grp td { background: var(--bg); font-weight: 600; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: start; padding: 6px 14px; }
td.empty { text-align: center !important; color: var(--muted); padding: 28px 14px; white-space: normal; }
.tbl-tools select { padding: 4px 8px; border-radius: 8px; background: var(--bg); }
@media (max-width: 640px) { .opt { display: none; } th, td { padding: 8px 8px; } }

.insights { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.insights li { font-size: .92rem; color: var(--muted); padding-inline-start: 18px; position: relative; }
.insights li::before { content: ""; position: absolute; inset-inline-start: 0; top: .55em; width: 8px; height: 8px; border-radius: 2px; background: var(--gain); }
.insights b { color: var(--ink); font-weight: 600; }
footer { color: var(--muted); font-size: .8rem; line-height: 1.6; width: 100%; margin: 8px 0 0; text-align: justify; text-align-last: center; hyphens: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn {
  font: inherit; font-size: .9rem; font-weight: 500; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.1); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.status { font-size: .85rem; color: var(--muted); }
.share-panel { margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); display: grid; gap: 10px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.note { margin: 0; font-size: .85rem; color: var(--muted); }
#share-link {
  flex: 1; min-width: 0; font-family: var(--font-num); font-size: .82rem; padding: 8px 10px; direction: ltr;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Telemóvel ---------- */
@media (max-width: 640px) {
  body { padding: 20px 12px 36px; }
  .card { padding: 16px; }
  select, .num select, .tbl-tools select { font-size: 16px; }
  .tabs button { padding: 9px 14px; }
  form summary { padding: 8px 0; }
  .btn { padding: 10px 14px; }
  .chart .end { font-size: 11px; }
  .chart .end-sub { font-size: 10px; }
  .chart .mark { font-size: 10px; }
  .site-links a { display: inline-block; padding: 6px 4px; }
  .tip { min-width: 0; max-width: 240px; }
}
@media (max-width: 480px) {
  .opt2 { display: none; }
  .table-wrap table { font-size: .8rem; }
  td.yr { white-space: normal; }
  td.yr .chip { display: table; margin: 3px 0 0; font-size: .66rem; white-space: nowrap; }
}

/* ---------- Guia (conteúdo para o Google) ---------- */
.content {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(18px, 3vw, 28px); display: grid; gap: 18px;
}
.content p { margin: 0; line-height: 1.7; }
.content .muted, .muted { color: var(--muted); font-size: .92rem; }

/* Três temas em cartões */
.topics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .topics { grid-template-columns: 1fr; } }
.topic {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 4px; align-content: start;
  padding: 16px; border-radius: 12px; cursor: pointer; position: relative;
  background: var(--bg); border: 1.5px solid transparent; transition: border-color .15s, background .15s;
}
.topic:hover { border-color: var(--line); }
.topic[aria-selected="true"] { background: var(--surface); border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.topic:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.topic-ico {
  grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.topic[aria-selected="true"] .topic-ico { background: var(--accent); color: #fff; }
.topic h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; line-height: 1.3; margin: 0; text-wrap: balance; }
.topic p { font-size: .86rem; line-height: 1.5; color: var(--muted); }
.topic p b { color: var(--ink); font-weight: 600; }
.topic-formula { font-family: var(--font-num); color: var(--ink) !important; }

/* Painel do tema escolhido */
.panel {
  display: grid; gap: 14px; padding: clamp(16px, 3vw, 26px); border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line);
}
.panel[hidden] { display: none; }
.panel > p { max-width: 75ch; }
.formula {
  font-family: var(--font-num); font-size: clamp(.95rem, 2.4vw, 1.15rem); text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gain);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto; white-space: nowrap;
}
.vars { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.vars > div { display: flex; gap: 10px; align-items: baseline; background: var(--surface); border-radius: 8px; padding: 8px 12px; border: 1px solid var(--line); }
.vars dt { font-family: var(--font-num); font-weight: 500; color: var(--accent); min-width: 2.2em; }
.vars dd { margin: 0; font-size: .9rem; }
.ex-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; max-width: 520px; background: var(--surface); }
.ex-table table { font-size: .92rem; }
.ex-table thead th { position: static; }

/* Perguntas frequentes */
.faq-block { display: grid; gap: 14px; padding-top: 8px; }
.faq-block > h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.25rem, 2.4vw, 1.5rem); margin: 0; }
.faq-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
@media (max-width: 760px) { .faq-grid { grid-template-columns: 1fr; } }
.faq { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, background .15s; }
.faq:hover { border-color: var(--accent); }
.faq[open] { background: var(--bg); border-color: var(--accent); }
.faq > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 12px; }
.faq h3 { color: var(--ink); font-family: var(--font-body); font-weight: 600; font-size: .95rem; line-height: 1.4; margin: 0; }
.faq .pm { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); position: relative; }
.faq .pm::before, .faq .pm::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 2px; background: var(--accent); transform: translate(-50%, -50%); transition: transform .15s; }
.faq .pm::after { transform: translate(-50%, -50%) rotate(90deg); }
.faq[open] .pm::after { transform: translate(-50%, -50%) rotate(0deg); }
.faq > p { padding: 0 16px 16px; font-size: .92rem; color: var(--ink); }

/* ---------- Anúncios ---------- */
.ad { display: grid; gap: 6px; justify-items: center; }
.ad .ad-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: none; }
.ad:has(ins[data-ad-status="filled"]) .ad-label { display: block; }
.ad ins { width: 100%; }
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.content .ad.in-article { padding: 4px 0; }

/* Anúncio lateral: só no computador, por baixo dos dados */
.side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.ad.side-ad { justify-items: stretch; }
.ad.side-ad ins { min-height: 250px; }
@media (max-width: 900px) { .ad.side-ad { display: none; } }

/* ---------- Ligações no fim ---------- */
.site-links { display: grid; gap: 8px; text-align: center; font-size: .82rem; color: var(--muted); }
.site-links p { margin: 0; line-height: 1.9; }
.site-links a { color: var(--muted); text-underline-offset: 3px; }
.site-links a:hover { color: var(--accent); }
.lang-links span { font-weight: 600; }

/* ---------- Página de escolha de idioma ---------- */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lang-grid a {
  display: grid; gap: 4px; padding: 16px 18px; border-radius: 12px; text-decoration: none;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink);
}
.lang-grid a:hover { border-color: var(--accent); }
.lang-grid b { font-family: var(--font-display); font-weight: 600; }
.lang-grid span { color: var(--muted); font-size: .88rem; }

/* ---------- Política de privacidade ---------- */
.legal { max-width: 80ch; }
.legal a { color: var(--accent); }
.back { margin: 0 0 8px; font-size: .9rem; }
.back a { color: var(--accent); text-decoration: none; }
.faq:hover h3, .faq[open] h3 { color: var(--accent); }
.topic::after {
  content: ""; position: absolute; top: 18px; inset-inline-end: 16px; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s;
}
.topic[aria-selected="true"]::after { transform: rotate(-135deg); top: 22px; border-color: var(--accent); }
.topic h2 { padding-inline-end: 18px; }

/* Marca */
.brand { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 12px; text-decoration: none; color: var(--accent);
  font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; letter-spacing: -.015em; }
.brand svg { flex: none; border-radius: 9px; }
.brand:hover span { color: var(--accent-2); }
