/* Tabelas Dinâmicas — estilos do módulo TB */
:root {
  --verde: #1f6e43;
  --verde-escuro: #14502f;
  --verde-claro: #e8f3ec;
  --verde-linha: #cfe5d8;
  --tinta: #1d2522;
  --tinta-suave: #56625c;
  --fundo: #f6f8f7;
  --papel: #ffffff;
  --borda: #dde4e0;
  --ambar: #b7791f;
  --ambar-claro: #fdf6e7;
  --azul-claro: #eef4fb;
  --azul: #2b5c93;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 16px rgba(20, 40, 30, .05);
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--tinta);
  background: var(--fundo);
}
img { max-width: 100%; height: auto; }
a { color: var(--verde); }
a:hover { color: var(--verde-escuro); }
code, kbd { font-family: var(--mono); font-size: .9em; }
kbd {
  background: var(--papel); border: 1px solid var(--borda); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 .35em; white-space: nowrap;
}

/* ---------- topo ---------- */
.topo { background: var(--verde); color: #fff; }
.topo-int {
  max-width: 1180px; margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.marca { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.marca:hover { color: #fff; }
.marca-icone {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px;
  background: #fff; color: var(--verde); font-weight: 800; font-size: .95rem;
}
.topo nav a { color: #fff; text-decoration: none; opacity: .9; margin-left: 1rem; font-size: .95rem; }
.topo nav a:hover { opacity: 1; text-decoration: underline; }

.migalhas { max-width: 1180px; margin: 0 auto; padding: .8rem 1rem 0; font-size: .88rem; color: var(--tinta-suave); }
.migalhas a { color: var(--tinta-suave); }

/* ---------- layout ---------- */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 1rem 1rem 3rem;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2rem; align-items: start;
}
.lateral {
  position: sticky; top: 1rem; background: var(--papel); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1rem .6rem; box-shadow: var(--sombra);
}
.lateral h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tinta-suave); margin: 0 .5rem .5rem; }
.lateral ol { list-style: none; margin: 0; padding: 0; counter-reset: cap; }
.lateral li a {
  display: flex; gap: .55rem; padding: .42rem .5rem; border-radius: 6px;
  text-decoration: none; color: var(--tinta); font-size: .92rem; line-height: 1.3;
}
.lateral li a::before {
  counter-increment: cap; content: counter(cap);
  flex: 0 0 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--verde-claro); color: var(--verde); font-size: .75rem; font-weight: 700;
}
.lateral li a:hover { background: var(--verde-claro); }
.lateral li a.ativo { background: var(--verde); color: #fff; }
.lateral li a.ativo::before { background: #fff; }
.lateral .extra { border-top: 1px solid var(--borda); margin-top: .7rem; padding-top: .7rem; }
.lateral .extra a { display: block; padding: .35rem .5rem; font-size: .9rem; text-decoration: none; }

main { min-width: 0; }
.cartao {
  background: var(--papel); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 1.6rem 2rem; box-shadow: var(--sombra);
}
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .4rem; color: var(--verde-escuro); }
h2 { font-size: 1.4rem; margin: 2.4rem 0 .7rem; color: var(--verde-escuro); scroll-margin-top: 1rem; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.subtitulo { font-size: 1.1rem; color: var(--tinta-suave); margin: 0 0 1.2rem; }
.capitulo-num { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--verde); }

/* ---------- caixas ---------- */
.perguntas {
  background: var(--ambar-claro); border: 1px solid #f1dfb8; border-left: 5px solid var(--ambar);
  border-radius: var(--raio); padding: 1rem 1.3rem; margin: 1.2rem 0;
}
.perguntas h2 { margin: 0 0 .3rem; font-size: 1.1rem; color: #7a4f0f; }
.perguntas p { margin: 0 0 .5rem; color: #6b5324; font-size: .95rem; }
.perguntas ol { margin: 0; padding-left: 1.3rem; }
.perguntas li { margin: .3rem 0; }
.perguntas li a { color: var(--tinta); text-decoration: none; border-bottom: 1px dashed #c9a35a; }

.pergunta {
  display: flex; gap: .8rem; align-items: flex-start; background: var(--azul-claro);
  border-radius: var(--raio); padding: .8rem 1rem; margin: 2.4rem 0 1rem; scroll-margin-top: 1rem;
}
.pergunta .etiqueta {
  flex: 0 0 auto; background: var(--azul); color: #fff; font-weight: 700; font-size: .8rem;
  padding: .15rem .55rem; border-radius: 99px; margin-top: .2rem;
}
.pergunta h2 { margin: 0; font-size: 1.2rem; color: var(--azul); }

.resposta {
  background: var(--verde-claro); border-left: 5px solid var(--verde); border-radius: var(--raio);
  padding: .8rem 1.1rem; margin: 1rem 0 1.5rem;
}
.resposta strong:first-child { color: var(--verde-escuro); }
.nota {
  background: #f3f5f4; border-radius: var(--raio); padding: .7rem 1rem; margin: 1rem 0;
  font-size: .95rem; color: var(--tinta-suave);
}
.nota strong { color: var(--tinta); }

.download {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  border: 1px dashed var(--verde); border-radius: var(--raio); padding: .8rem 1rem; margin: 1rem 0 1.4rem;
  background: #fbfdfc;
}
.download .ico {
  width: 2.6rem; height: 2.6rem; border-radius: 8px; background: var(--verde); color: #fff;
  display: grid; place-items: center; font-weight: 800; flex: 0 0 auto;
}
.download div { flex: 1 1 14rem; }
.download small { color: var(--tinta-suave); display: block; }
.botao {
  display: inline-block; background: var(--verde); color: #fff; text-decoration: none; font-weight: 600;
  padding: .5rem 1rem; border-radius: 8px; white-space: nowrap;
}
.botao:hover { background: var(--verde-escuro); color: #fff; }
.botao.sec { background: transparent; color: var(--verde); border: 1px solid var(--verde); }

/* ---------- passos ---------- */
ol.passos { counter-reset: passo; list-style: none; padding: 0; margin: .6rem 0 1rem; }
ol.passos > li { counter-increment: passo; position: relative; padding-left: 2.4rem; margin: .7rem 0; }
ol.passos > li::before {
  content: counter(passo); position: absolute; left: 0; top: .05rem;
  width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--verde); color: #fff;
  display: grid; place-items: center; font-size: .85rem; font-weight: 700;
}
.menu { font-weight: 600; background: #eef1ef; border-radius: 4px; padding: 0 .3em; white-space: nowrap; }

/* ---------- áreas da lista de campos ---------- */
.areas {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem;
  max-width: 460px; margin: 1rem 0 1.3rem; padding: .7rem; border: 1px solid var(--borda);
  border-radius: var(--raio); background: #fafbfa;
}
.areas .titulo-areas { grid-column: 1 / -1; font-size: .8rem; color: var(--tinta-suave); font-weight: 600; }
.area { background: var(--papel); border: 1px solid var(--borda); border-radius: 6px; padding: .35rem .5rem; min-height: 4.2rem; }
.area b { display: block; font-size: .75rem; color: var(--tinta-suave); font-weight: 600; margin-bottom: .25rem; }
.area b::before { margin-right: .3rem; }
.area.filtros b::before { content: "⏷"; }
.area.colunas b::before { content: "▥"; }
.area.linhas b::before { content: "☰"; }
.area.valores b::before { content: "Σ"; }
.chip {
  display: block; background: var(--verde-claro); border: 1px solid var(--verde-linha); color: var(--verde-escuro);
  border-radius: 4px; padding: .05rem .4rem; margin: .2rem 0; font-size: .85rem; font-weight: 600;
}

/* ---------- tabelas dinâmicas ---------- */
.tabela-wrap { overflow-x: auto; margin: .8rem 0 1.2rem; }
table.td {
  border-collapse: collapse; font-size: .9rem; background: var(--papel); min-width: 16rem;
  font-variant-numeric: tabular-nums;
}
table.td caption { caption-side: top; text-align: left; font-size: .8rem; color: var(--tinta-suave); padding-bottom: .3rem; }
table.td th, table.td td { padding: .28rem .7rem; border-bottom: 1px solid #edf0ee; white-space: nowrap; }
table.td thead th { background: var(--verde); color: #fff; text-align: left; font-weight: 600; }
table.td thead th.num { text-align: right; }
table.td td.num { text-align: right; }
table.td tr.filtro td { background: #f3f5f4; border-bottom: 0; }
table.td tr.filtro td:first-child { font-weight: 600; }
table.td tr.grupo td { font-weight: 700; background: #f4f9f6; }
table.td tr.filho td:first-child { padding-left: 1.6rem; }
table.td tr.total td { font-weight: 700; border-top: 2px solid var(--verde); border-bottom: 0; }
table.td tr.destaque td { background: #fff6dc; }
table.td tr.reticencias td { color: var(--tinta-suave); text-align: center; font-style: italic; }
table.td td.vazio { color: #b5bdb8; }

table.simples { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.simples th, table.simples td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
table.simples th { background: var(--verde-claro); color: var(--verde-escuro); }

figure { margin: 1rem 0 1.5rem; }
figure img { border: 1px solid var(--borda); border-radius: 6px; background: #fff; }
figcaption { font-size: .85rem; color: var(--tinta-suave); margin-top: .3rem; }

.formula {
  font-family: var(--mono); background: #1f2a25; color: #e6f2eb; border-radius: 8px;
  padding: .6rem .9rem; overflow-x: auto; white-space: pre; font-size: .9rem; margin: .6rem 0 1rem;
}
.formula .fn { color: #8fe0b0; }

.desafio {
  border: 2px solid var(--verde); border-radius: var(--raio); padding: 1rem 1.3rem; margin: 2.5rem 0 1rem;
}
.desafio h2 { margin-top: 0; }
.desafio details { margin: .4rem 0; }
.desafio summary { cursor: pointer; color: var(--verde); font-weight: 600; }

.nav-cap { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; flex-wrap: wrap; }
.nav-cap a {
  flex: 1 1 14rem; border: 1px solid var(--borda); border-radius: var(--raio); padding: .7rem 1rem;
  text-decoration: none; background: var(--papel);
}
.nav-cap a:hover { border-color: var(--verde); }
.nav-cap small { display: block; color: var(--tinta-suave); }
.nav-cap .seg { text-align: right; }

/* ---------- índice ---------- */
.hero {
  background: linear-gradient(135deg, var(--verde) 0%, #2f8a57 100%); color: #fff;
  border-radius: var(--raio); padding: 2rem; margin-bottom: 1.5rem;
}
.hero h1 { color: #fff; font-size: 2.2rem; }
.hero p { font-size: 1.1rem; max-width: 46rem; margin: .4rem 0 1rem; opacity: .95; }
.hero .botao { background: #fff; color: var(--verde); }
.hero .botao.sec { background: transparent; color: #fff; border-color: #fff; }
.numeros { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1.2rem 0 0; }
.numeros div { background: rgba(255, 255, 255, .14); border-radius: 8px; padding: .5rem .9rem; }
.numeros b { display: block; font-size: 1.4rem; line-height: 1.2; }
.numeros span { font-size: .85rem; opacity: .9; }

.grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.cap-cartao {
  display: flex; flex-direction: column; background: var(--papel); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1rem 1.1rem; text-decoration: none; color: var(--tinta);
  box-shadow: var(--sombra); transition: border-color .15s, transform .15s;
}
.cap-cartao:hover { border-color: var(--verde); transform: translateY(-2px); color: var(--tinta); }
.cap-cartao .num { font-size: .78rem; font-weight: 700; color: var(--verde); letter-spacing: .06em; }
.cap-cartao h3 { margin: .2rem 0 .4rem; color: var(--verde-escuro); }
.cap-cartao p { margin: 0 0 .7rem; font-size: .92rem; color: var(--tinta-suave); }
.cap-cartao q {
  margin-top: auto; font-size: .9rem; background: var(--ambar-claro); border-radius: 6px; padding: .45rem .6rem;
  quotes: "«" "»"; color: #6b5324;
}

.rodape { text-align: center; font-size: .85rem; color: var(--tinta-suave); padding: 1.5rem 1rem 2rem; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .lateral { position: static; }
  .lateral ol { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 560px) {
  .cartao { padding: 1.1rem 1rem; }
  h1 { font-size: 1.6rem; }
  .hero { padding: 1.3rem; }
  .hero h1 { font-size: 1.7rem; }
  .areas { grid-template-columns: 1fr 1fr; }
  .topo nav a { margin-left: .6rem; }
}
@media print {
  .topo, .lateral, .nav-cap, .migalhas { display: none; }
  .layout { display: block; }
  .cartao { box-shadow: none; border: 0; }
}
