/* Ferramentas gratuitas (/ferramentas). Complementa o styles.css da landing
   e usa as mesmas variáveis de cor. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Hub /ferramentas */
.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tool-card h2 {
  font-size: 1.3rem;
}

.tool-card h2 a {
  color: var(--ink);
  text-decoration: none;
}

/* O card inteiro é clicável pelo link do título. */
.tool-card {
  position: relative;
}

.tool-card h2 a::after {
  position: absolute;
  inset: 0;
  content: "";
}

.tool-card:hover,
.tool-card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

.tool-card h2 a:focus-visible {
  outline: none;
}

.tool-card:focus-within {
  outline: 3px solid rgba(31, 111, 104, 0.35);
  outline-offset: 2px;
}

.tool-card ul {
  margin: 0 0 1.2rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-card .tool-card-cta {
  margin-top: auto;
  margin-bottom: 0;
  color: var(--primary-dark);
  font-weight: 800;
}

/* "hidden" vence qualquer display definido abaixo. */
.calc [hidden] {
  display: none !important;
}

.tool-hero {
  padding-block: 2.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.tool-hero h1 {
  max-width: 900px;
  margin-bottom: 0.75rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.tool-hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: #334154;
  font-size: 1.1rem;
}

.tool-section {
  padding-block: 2rem 4rem;
}

.calc {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: start;
  gap: 1.5rem;
}

.calc-form,
.calc-result {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.calc-result {
  position: sticky;
  top: 88px;
}

.calc-form h2,
.calc-result h2 {
  margin-bottom: 1.2rem;
  font-size: 1.3rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1.15rem;
}

.field label,
.field legend {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 750;
}

.input-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid #b9c4be;
  border-radius: 8px;
  background: #ffffff;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  outline: 3px solid rgba(31, 111, 104, 0.3);
  outline-offset: 1px;
}

.input-wrap span {
  display: inline-flex;
  align-items: center;
  padding-inline: 0.8rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.input-wrap input {
  /* Encolhe abaixo da largura natural (20 caracteres) quando há um combo ao lado. */
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0.6rem 0.8rem;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.input-wrap span + input {
  padding-left: 0;
}

.input-wrap input:focus {
  outline: none;
}

.input-wrap:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-hint.aviso {
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  color: #5c3a14;
  background: #fbf3e8;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 700;
}

.link-button {
  justify-self: start;
  padding: 0.2rem 0;
  border: 0;
  color: var(--primary-dark);
  background: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:focus-visible,
.calc button:focus-visible {
  outline: 3px solid rgba(31, 111, 104, 0.35);
  outline-offset: 2px;
}

.result-main {
  margin-bottom: 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: 8px;
  background: var(--surface-soft);
}

.result-main strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--primary-dark);
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.result-main p {
  margin: 0;
  color: #334154;
  font-size: 0.98rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.1rem;
}

.result-grid div {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.result-grid dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.result-grid dd {
  margin: 0.15rem 0 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-empty {
  margin: 0;
}

.result-details {
  margin-bottom: 1rem;
}

.result-details summary {
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
}

.result-details .table-scroll {
  max-height: 420px;
  margin-top: 0.75rem;
  overflow-y: auto;
}

.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tool-table th,
.tool-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tool-table thead th {
  position: sticky;
  top: 0;
  color: var(--ink);
  background: var(--surface-soft);
}

.tool-table th[scope="row"],
.tool-table thead th:first-child {
  text-align: left;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
}

.share-row p {
  margin: 0;
  font-size: 0.88rem;
}

.share-row .button {
  min-height: 40px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.field-group {
  margin: 0 0 1.15rem;
  padding: 0;
  border: 0;
}

.field-group legend {
  margin-bottom: 0.5rem;
  padding: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 750;
}

.option-list {
  display: grid;
  gap: 0.45rem;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}

.option:has(input:checked) {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.option:has(input:disabled) {
  color: var(--muted);
  cursor: not-allowed;
}

.option input,
.check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0.15rem 0 0;
  accent-color: var(--primary);
}

.option input:focus-visible,
.check input:focus-visible {
  outline: 3px solid rgba(31, 111, 104, 0.35);
  outline-offset: 2px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.check-hint {
  margin: 0.2rem 0 0 1.85rem;
}

#aviso-cdi {
  margin: -0.4rem 0 1.15rem;
}

.subgroup {
  margin: 0.2rem 0 1.15rem;
  padding: 0.9rem;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  background: var(--bg);
}

.subgroup .field:last-child {
  margin-bottom: 0;
}

.result-main.secondary {
  background: #eef3fa;
}

.result-main.secondary strong {
  color: var(--navy);
}

.result-grid small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

/* Gráfico: cores validadas (CVD e contraste) contra fundo branco. */
.chart {
  position: relative;
  margin: 0 0 1rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-investido {
  fill: #2f6fb0;
}

.chart-juros {
  fill: #2a9d7f;
}

.chart-grid {
  stroke: #e6ebe8;
  stroke-width: 1;
}

.chart-base {
  stroke: #b9c4be;
  stroke-width: 1;
}

.chart-axis {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-hit {
  fill: transparent;
  cursor: default;
}

.chart-hit.ativo {
  fill: rgba(23, 32, 51, 0.06);
}

.chart-hit:focus {
  outline: none;
}

.chart-hit:focus-visible {
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 0.1rem;
  min-width: 170px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(23, 32, 51, 0.14);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin: 0 0 0.6rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  list-style: none;
}

.chart-legend li::before {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 0.4rem;
  border-radius: 3px;
  content: "";
  vertical-align: -1px;
}

.chart-linha {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-linha.serie-atual {
  stroke: #2f6fb0;
}

.chart-linha.serie-antecipando {
  stroke: #2a9d7f;
}

.chart-ponto {
  stroke: #ffffff;
  stroke-width: 2;
}

.chart-ponto.serie-atual,
.chart-legend .serie-atual::before {
  fill: #2f6fb0;
  background: #2f6fb0;
}

.chart-ponto.serie-antecipando,
.chart-legend .serie-antecipando::before {
  fill: #2a9d7f;
  background: #2a9d7f;
}

.input-wrap select {
  min-height: 46px;
  padding: 0 0.6rem;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
  color: var(--ink);
  background: var(--surface-soft);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
}

.input-wrap select:focus {
  outline: none;
}

.option-list.inline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compare-table {
  margin-bottom: 1rem;
}

.compare-table td:last-child {
  color: var(--primary-dark);
  font-weight: 800;
}

.download-actions {
  margin: 1.4rem 0 0.6rem;
}

.steps-list {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 2rem;
  padding-left: 1.3rem;
  color: var(--muted);
}

.steps-list strong {
  color: var(--ink);
}

.cta-inline-link {
  font-weight: 800;
}

.result-subtitle {
  margin: 0.4rem 0 0.6rem;
  font-size: 1rem;
}

.mini-table {
  margin-bottom: 1.2rem;
}

.mini-table td {
  font-weight: 700;
}

/* Linha que corresponde à simulação atual. */
.tool-table tr.linha-atual th,
.tool-table tr.linha-atual td {
  color: var(--primary-dark);
  background: var(--surface-soft);
  font-weight: 800;
}

.result-grid .span-2 {
  grid-column: 1 / -1;
}

.result-note {
  margin: -0.4rem 0 1rem;
  font-size: 0.86rem;
}

.chart-legend .investido::before {
  background: #2f6fb0;
}

.chart-legend .juros::before {
  background: #2a9d7f;
}

/* Alinhado com o título e a calculadora; só as linhas de texto são limitadas. */
.tool-content > * {
  max-width: 820px;
}

.tool-content h2 {
  font-size: 1.8rem;
}

.tool-content h2:not(:first-child) {
  margin-top: 2.5rem;
}

.tool-content h3 {
  margin-top: 1.6rem;
}

.formula {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  color: var(--ink);
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  overflow-x: auto;
}

.tool-example {
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tool-example ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.tool-disclaimer {
  margin-top: 2rem;
  padding: 0.9rem 1rem;
  border: 1px solid #ead9c3;
  border-radius: 8px;
  color: #5c3a14;
  background: #fbf3e8;
  font-size: 0.92rem;
}

.tool-section-alt {
  border-top: 1px solid var(--border);
  background: #ffffff;
}

@media (max-width: 1040px) {
  .calc {
    grid-template-columns: minmax(0, 1fr);
  }

  .calc-result {
    position: static;
  }
}

@media (max-width: 760px) {
  /* O styles.css usa 100vw no celular; com barra de rolagem fixa isso passa
     da tela. Nas ferramentas, a largura do conteúdo basta. */
  main .section-shell {
    width: 100%;
    max-width: 100%;
  }

  .tool-hero {
    padding-block: 1.75rem 1.25rem;
  }

  .tool-section {
    padding-block: 1.25rem 3rem;
  }

  .calc-form,
  .calc-result {
    padding: 1.1rem;
  }

  .result-grid,
  .option-list.inline {
    grid-template-columns: 1fr;
  }

  .tool-table th,
  .tool-table td {
    white-space: normal;
  }

}

/* Celular estreito: na comparação, o rótulo vai para uma linha própria e os
   dois valores ficam lado a lado embaixo, sem rolar de lado. */
@media (max-width: 480px) {
  .compare-table .tool-table,
  .compare-table .tool-table tbody {
    display: block;
  }

  .compare-table .tool-table thead tr,
  .compare-table .tool-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-table .tool-table thead th:first-child {
    display: none;
  }

  .compare-table .tool-table tbody th[scope="row"] {
    grid-column: 1 / -1;
    padding-bottom: 0;
    border-bottom: 0;
    color: var(--muted);
    font-size: 0.85rem;
  }

  .compare-table .tool-table th,
  .compare-table .tool-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
  }
}

/* Aviso de cookies (consentimento.js): ocupa a metade de baixo da tela para a
   pessoa escolher; um aviso pequeno ninguém clica. */
.cookie-consent {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2147483646;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  min-height: 50vh;
  padding: 2.2rem 1.75rem;
  border: 1px solid rgba(31, 111, 104, 0.25);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 -12px 48px rgba(23, 32, 51, 0.2);
  text-align: center;
}

.cookie-consent[hidden] {
  display: none;
}

.cookie-consent__texto {
  max-width: 680px;
  margin: 0;
  color: #334154;
}

.cookie-consent__texto strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ink);
  font-size: 1.25rem;
}

.cookie-consent__texto a {
  color: var(--primary-dark);
  font-weight: 800;
}

.cookie-consent__acoes {
  display: flex;
  gap: 0.75rem;
  width: min(100%, 460px);
}

.cookie-consent__botao {
  flex: 1;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: var(--primary-dark);
  background: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.cookie-consent__botao:hover {
  background: var(--surface-soft);
}

.cookie-consent__botao--principal {
  color: #ffffff;
  background: var(--primary);
}

.cookie-consent__botao--principal:hover {
  background: var(--primary-dark);
}

.cookie-consent__botao:focus-visible,
.cookie-preferences:focus-visible {
  outline: 3px solid #a86522;
  outline-offset: 2px;
}

.cookie-preferences {
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.cookie-preferences--flutuante {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 2147483645;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.8rem;
}

@media (max-width: 680px) {
  .cookie-consent {
    min-height: 55vh;
    padding: 1.75rem 1.25rem;
  }

  .cookie-consent__botao {
    min-height: 54px;
    padding-inline: 0.6rem;
    font-size: 0.9rem;
  }
}

.footer-links .cookie-preferences {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 750;
  text-decoration: none;
}

.footer-links .cookie-preferences:hover {
  color: var(--primary);
}
