/* finanças&poupanças — estilos base */
:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #1b2420;
  --muted: #5d6b64;
  --border: #dde3dc;
  --brand: #12805c;
  --brand-strong: #0b5e43;
  --brand-soft: #e1f3ea;
  --accent: #e7a325;
  --danger: #c2412d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(16,40,30,.06);
  --max: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #161e1b; --surface-2: #1d2824; --text: #e6ece8;
    --muted: #9aaba3; --border: #2a3632; --brand: #3ccf98; --brand-strong: #6ee0b5;
    --brand-soft: #173a2d; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --surface-2: #1d2824; --text: #e6ece8;
  --muted: #9aaba3; --border: #2a3632; --brand: #3ccf98; --brand-strong: #6ee0b5;
  --brand-soft: #173a2d; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6; font-size: 16px;
}
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: .2em 0 .4em; }
h2 { font-size: clamp(1.35rem, 2.5vw, 1.7rem); margin: 1.6em 0 .6em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 .4em; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Cabeçalho */
.site-header {
  position: sticky; top: 0; z-index: 50; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.logo { font-weight: 800; font-size: 1.25rem; text-decoration: none; color: var(--text); white-space: nowrap; }
.logo .amp { color: var(--brand); }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav > .nav-item { position: relative; }
.nav a, .nav button.nav-link {
  display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none;
  color: var(--text); font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer;
}
.nav a:hover, .nav button.nav-link:hover, .nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
.dropdown {
  display: none; position: absolute; top: 100%; left: 0; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.nav-item:hover .dropdown, .nav-item:focus-within .dropdown, .nav-item.open .dropdown { display: block; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px;
  width: 38px; height: 38px; cursor: pointer; font-size: 1rem;
}
.menu-toggle { display: none; }

@media (max-width: 1100px) {
  .menu-toggle { display: block; margin-left: auto; }
  .nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column;
    align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px;
  }
  .nav.open { display: flex; }
  .dropdown { position: static; display: block; border: 0; box-shadow: none; padding: 0 0 0 12px; }
  .nav .theme-wrap { padding-top: 8px; }
}

/* Hero */
.hero { padding: 56px 0 40px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; }
.btn {
  display: inline-block; padding: 12px 20px; border-radius: 10px; background: var(--brand);
  color: #fff; text-decoration: none; font-weight: 600; border: 0; cursor: pointer; font: inherit;
}
.btn:hover { background: var(--brand-strong); color: #fff; }
.btn.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); color: var(--brand-strong); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* Cartões e grelhas */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
a.card { display: block; text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--brand); color: var(--text); }
.card h3 { margin-top: 0; }
.card .emoji { font-size: 1.6rem; }
.tag {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong);
}

section { padding: 8px 0 24px; }
.page-head { padding: 40px 0 8px; }
.breadcrumb { font-size: .875rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

.notice {
  background: var(--surface-2); border-left: 4px solid var(--accent); padding: 12px 16px;
  border-radius: 8px; margin: 16px 0; font-size: .925rem;
}

/* Tabelas comparativas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); font-weight: 600; cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }

/* Formulários / calculadoras */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.tabs button {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font: inherit; font-weight: 500;
}
.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.calc { display: none; }
.calc.active { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 760px) { .calc.active { grid-template-columns: 1fr; } }
label { display: block; font-weight: 500; margin: 10px 0 4px; font-size: .95rem; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.result { background: var(--brand-soft); border-radius: var(--radius); padding: 20px; }
.result .big { font-size: 2rem; font-weight: 800; color: var(--brand-strong); font-variant-numeric: tabular-nums; }
.result dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 12px 0 0; }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin-top: 16px; }
.bars div { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; position: relative; min-width: 2px; }
.bars div span { position: absolute; inset: auto 0 0 0; background: var(--accent); border-radius: 3px 3px 0 0; }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Notícias */
.news-list { display: grid; gap: 14px; }
.news-item { display: grid; gap: 4px; }
.news-item h3 { margin: 0; }
.news-item h3 a { color: var(--text); text-decoration: none; }
.news-item h3 a:hover { color: var(--brand); }

/* Conteúdo de artigo */
.prose { max-width: 760px; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin: 4px 0; }
.two-col { display: grid; gap: 24px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* Newsletter / Instagram */
.cta-band { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 28px; margin: 32px 0; }
.cta-band h2 { margin-top: 0; color: #fff; }
.cta-band .btn { background: #fff; color: var(--brand-strong); }

/* Rodapé */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 32px 0; background: var(--surface); font-size: .9rem; }
.footer-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 4px 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--brand); }

/* Termos do glossário */
a.termo { color: inherit; text-decoration: underline dotted var(--brand); text-underline-offset: 3px; cursor: help; }
a.termo:hover { color: var(--brand-strong); }
.glossario dt { font-weight: 700; font-size: 1.05rem; margin-top: 18px; scroll-margin-top: 80px; }
.glossario dt:target { color: var(--brand-strong); }
.glossario dd { margin: 4px 0 0; color: var(--muted); }
.letras { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.letras a { padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }

/* Indicadores de mercado */
.indicadores { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 8px 0 24px; }
.indicadores .card { padding: 14px 16px; }
.indicadores .valor { font-size: 1.5rem; font-weight: 800; color: var(--brand-strong); font-variant-numeric: tabular-nums; }

/* Separadores agrupados (calculadoras) */
.grupos-tabs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 16px 0 12px; }
.grupo { min-width: 0; }
.grupo { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grupo-nome { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 110px; }
.grupo .tabs { margin: 4px 0; }
@media (max-width: 760px) {
  .grupo { display: block; }
  .grupo .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .grupo .tabs button { white-space: nowrap; flex: none; padding: 7px 12px; font-size: .9rem; }
}

/* Menu: página atual dentro de um submenu e botão da newsletter */
.nav button.nav-link.ativo { color: var(--brand-strong); }
.nav a.btn.nav-newsletter { background: var(--brand); color: #fff; padding: 8px 14px; margin-left: 6px; white-space: nowrap; }
.nav a.btn.nav-newsletter:hover { background: var(--brand-strong); color: #fff; }
.nav .nav-link { white-space: nowrap; }
@media (max-width: 1100px) { .nav a.btn.nav-newsletter { margin: 8px 0 0; text-align: center; } }

/* Cabeçalho em duas linhas no computador: logótipo em cima, menu completo por baixo */
@media (min-width: 1101px) {
  .site-header .container { flex-wrap: wrap; row-gap: 0; padding-top: 6px; }
  .site-header .nav { width: 100%; margin-left: 0; padding-bottom: 6px; gap: 0; }
  .site-header .nav .theme-wrap { margin-left: 6px; }
  .site-header .nav a.btn.nav-newsletter { margin-left: auto; }
  .nav a, .nav button.nav-link { padding: 8px 9px; }
}

/* Artigos */
.artigo .lead { font-size: 1.15rem; max-width: 760px; }
.artigo .prose h2 { scroll-margin-top: 110px; }
.cta-calc { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--brand-soft); border-radius: var(--radius); padding: 14px 18px; margin: 18px 0; }
.cta-calc span { font-size: 1.6rem; }
