/* Lei24: desenho do site. Claro e escuro automáticos. Sem estilos dentro das páginas (política de segurança). */
:root {
  color-scheme: light dark;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #14202e;
  --muted: #5a6878;
  --line: #dbe3ee;
  --brand: #0f2a4a;
  --brand-2: #1d4f91;
  --footer-bg: #1c4a7d;
  --accent: #0d9488;
  --accent-soft: #d9f3ef;
  --btn: #1d4f91;
  --btn-text: #ffffff;
  --warn-bg: #fff6df; --warn-line: #e3b341;
  --err-bg: #fdecec; --err-line: #d14343;
  --ok-bg: #e7f6ee; --ok-line: #3d9a5f;
  --shadow: 0 1px 2px rgba(15, 42, 74, .06), 0 8px 24px rgba(15, 42, 74, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b; --surface: #16202b; --surface-2: #1c2836; --text: #e8eef5; --muted: #9fb0c3; --line: #2a394a;
    --brand: #0b1a2c; --footer-bg: #12304f; --brand-2: #7fb0f0; --accent: #2dd4bf; --accent-soft: #123b39;
    --btn: #7fb0f0; --btn-text: #0b1a2c;
    --warn-bg: #3a3017; --warn-line: #b8912d; --err-bg: #3b1d1d; --err-line: #cf6a6a; --ok-bg: #173126; --ok-line: #4fae72;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 1.1rem; }
.narrow { max-width: 46rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--btn); color: var(--btn-text); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--brand-2); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.5rem); line-height: 1.2; margin: .3rem 0 .75rem; letter-spacing: -.015em; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 2rem 0 .6rem; }
h3 { font-size: 1.1rem; margin: 0 0 .3rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 44rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.icon { vertical-align: -.2em; flex-shrink: 0; }

.announcement { background: var(--accent-soft); color: var(--text); text-align: center; padding: .5rem 1rem; font-size: .95rem; border-bottom: 1px solid var(--line); }

/* Cabeçalho */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; flex-wrap: wrap; padding-top: .7rem; padding-bottom: .7rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--brand); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
@media (prefers-color-scheme: dark) { .brand { color: var(--text); } }
.brand-mark { color: var(--brand-2); }
.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .4rem; }
.main-nav a { color: var(--text); text-decoration: none; padding: .4rem .75rem; border-radius: 999px; font-size: .97rem; font-weight: 500; }
.main-nav a:hover { background: var(--surface-2); }
/* Barra a pedir para guardar o site nos favoritos, logo abaixo do menu (sem botão de fechar, para não irritar) */
.bookmark-bar { background: var(--btn); color: var(--btn-text); }
.bookmark-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .4rem 1rem; padding-top: .45rem; padding-bottom: .45rem; }
.bookmark-row > p { margin: 0; font-size: .95rem; line-height: 1.4; text-align: center; }
.bookmark-cta { text-decoration: underline; text-underline-offset: 3px; }
.bookmark-cta strong { font-weight: 800; }
.bookmark-details { position: relative; }
.bookmark-btn { list-style: none; cursor: pointer; display: inline-block; padding: .3rem .9rem; border-radius: 999px; background: var(--btn-text); color: var(--btn); font-weight: 700; font-size: .92rem; white-space: nowrap; }
.bookmark-btn::-webkit-details-marker { display: none; }
.bookmark-pop { position: absolute; right: 0; top: calc(100% + .45rem); z-index: 30; width: min(20rem, 86vw); margin: 0; padding: .7rem .9rem; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; line-height: 1.45; text-align: left; }
.bookmark-short { display: none; }
@media (max-width: 700px) {
  .bookmark-pop { right: auto; left: 50%; transform: translateX(-50%); }
  .bookmark-long { display: none; }
  .bookmark-short { display: inline; }
  .bookmark-row { padding: .3rem .5rem; gap: .25rem .8rem; }
  .bookmark-row > p { font-size: .92rem; line-height: 1.35; }
  .bookmark-btn { padding: .12rem .8rem; font-size: .88rem; line-height: 1.4; }
}
/* Menu: em ecrãs pequenos fica fechado atrás de um botão (funciona sem JavaScript) */
.nav-check { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.nav-toggle { display: none; }
.ico-close { display: none; }
@media (min-width: 961px) { .nav-extra { display: none; } }
@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; }
  .nav-check:checked + .nav-toggle .ico-open { display: none; }
  .nav-check:checked + .nav-toggle .ico-close { display: inline; }
  .nav-check:focus-visible + .nav-toggle { outline: 3px solid var(--brand-2); outline-offset: 2px; }
  .main-nav { display: none; flex-wrap: nowrap; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid var(--line); padding-top: .4rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; }
  .nav-check:checked ~ .main-nav { display: flex; }
  .main-nav a { padding: .85rem .6rem; border-radius: 8px; font-size: 1.05rem; }
}

/* Menu «Calculadoras»: abre ao passar o rato (ou com o teclado) e mostra as categorias; ao passar numa categoria, as calculadoras aparecem à direita. Só CSS, só em ecrãs largos. */
.drop-panel { display: none; }
@media (min-width: 961px) {
  .nav-drop { position: relative; }
  .nav-drop-link::after { content: ""; display: inline-block; margin-left: .4rem; vertical-align: .12em; border: .3rem solid transparent; border-top-color: currentColor; border-bottom-width: 0; }
  .drop-panel { position: absolute; top: 100%; left: 0; z-index: 40; padding-top: .35rem; }
  .nav-drop:hover .drop-panel, .nav-drop:focus-within .drop-panel { display: block; }
  .drop-cats { list-style: none; margin: 0; padding: .4rem 0; width: 16.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); position: relative; }
  .drop-cat { position: static; }
  .main-nav .drop-cat-link { display: flex; justify-content: space-between; align-items: center; border-radius: 8px; margin: 0 .4rem; padding: .55rem .75rem; white-space: nowrap; }
  .drop-cat-link::after { content: ""; border: .3rem solid transparent; border-left-color: currentColor; border-right-width: 0; opacity: .6; }
  .drop-cat:hover > .drop-cat-link, .drop-cat:focus-within > .drop-cat-link, .drop-cats:not(:hover):not(:focus-within) > .drop-cat:first-child > .drop-cat-link { background: var(--surface-2); }
  .drop-calcs { visibility: hidden; opacity: 0; z-index: 1; transition: visibility 0s linear .3s, opacity .1s linear .3s; list-style: none; margin: 0; padding: .4rem; position: absolute; top: -1px; left: calc(100% - 1px); width: 19rem; min-height: 100%; box-sizing: border-box; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
  .drop-cat:hover > .drop-calcs, .drop-cat:focus-within > .drop-calcs, .drop-cats:not(:hover):not(:focus-within) > .drop-cat:first-child > .drop-calcs { visibility: visible; opacity: 1; z-index: 2; transition-delay: .1s; }
  /* A caixa da direita aparece 0,1 s depois e a anterior fica 0,3 s: ao passar na diagonal por outras categorias, não muda. */
  .drop-calcs a { display: block; border-radius: 8px; padding: .5rem .75rem; white-space: nowrap; }
}

/* Guias (artigos) */
.guide-article .guide-meta { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.guide-body h2 { margin-top: 2.2rem; }
.guide-body h3 { margin: 1.6rem 0 .4rem; }
.guide-body p, .guide-body li { line-height: 1.7; }
.toc-card { margin: 1rem 0 1.6rem; }
.toc-card .toc-title { margin: 0 0 .4rem; font-weight: 700; }
.toc-card .toc { margin: 0; padding-left: 1.2rem; }
.toc-card .toc li { margin: .25rem 0; }
.guide-calcs { margin-top: 2rem; }

/* Guias longos por baixo das calculadoras */
.guide h3 { margin: 1.8rem 0 .5rem; }
.guide .guide-meta { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.guide .toc { margin: 1rem 0 1.4rem; padding: 1rem 1.2rem 1rem 2.2rem; background: var(--surface-2); border-radius: var(--radius); }
.guide .toc li { margin: .25rem 0; }
.guide .toc a { text-decoration: none; }
.guide .toc a:hover { text-decoration: underline; }

/* Imposto do selo: separadores dos casos */
.tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.tab { display: inline-block; padding: .45rem .95rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--brand-2); font-weight: 600; text-decoration: none; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

/* Página inicial */
.hero { background: var(--brand); color: #fff; padding: 3.2rem 0 3.6rem; }
.hero-inner { max-width: 52rem; }
.hero h1 { color: #fff; font-size: clamp(2rem, 6vw, 3.1rem); }
.hero-lead { font-size: 1.2rem; color: #dbe7f5; margin: 0 0 1.4rem; }
.eyebrow { display: inline-flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.14); padding: .3rem .8rem; border-radius: 999px; font-size: .9rem; margin: 0 0 .8rem; }
.hero-search { display: flex; align-items: center; gap: .6rem; background: #fff; color: #14202e; border-radius: 999px; padding: .3rem 1.1rem; max-width: 34rem; box-shadow: var(--shadow); }
.hero-search input { flex: 1; border: 0; background: transparent; font: inherit; padding: .7rem 0; color: #14202e; min-width: 0; }
.hero-search input:focus { outline: none; }
.hero-search input[type="search"] { background: transparent; border: 0; border-radius: 0; padding: .7rem 0; max-width: none; color: #14202e; }
.hero-search:focus-within { outline: 3px solid var(--accent); }

.section { padding-top: 2.2rem; padding-bottom: 1rem; }
.section-title { display: flex; align-items: center; gap: .5rem; margin-top: 1.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.tile { display: flex; align-items: flex-start; gap: .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.tile[hidden] { display: none; }
.tile-icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 12px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.tile-body { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.tile-cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.tile-title { font-weight: 700; font-size: 1.1rem; line-height: 1.3; }
.tile-text { color: var(--muted); font-size: .95rem; line-height: 1.5; }
.tile-go { color: var(--brand-2); align-self: center; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.feature-icon { display: inline-grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: .6rem; }
.feature p { margin: 0; color: var(--muted); font-size: .98rem; }

/* Calculadora */
.crumbs { font-size: .9rem; color: var(--muted); padding: 1rem 0 .2rem; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 .25rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .85rem; padding: .2rem .7rem; border-radius: 999px; margin: .5rem 0 0; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; padding-bottom: 2rem; }
@media (min-width: 62rem) { .calc-layout { grid-template-columns: minmax(0, 1fr) 20rem; } .calc-side { position: sticky; top: 5rem; align-self: start; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin: 1.2rem 0; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.form-card { padding: 1.4rem 1.4rem 1.6rem; }
.field { margin: 0 0 1.1rem; }
label, .label { display: block; font-weight: 600; margin-bottom: .3rem; }
.hint { color: var(--muted); font-size: .9rem; margin: .3rem 0 0; line-height: 1.5; }
input[type="date"], input[type="number"], input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; max-width: 24rem; padding: .7rem .8rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.date-error { margin: 0 0 .3rem; color: var(--err-line); font-size: .92rem; font-weight: 600; }
input.invalid { border-color: var(--err-line); box-shadow: 0 0 0 1px var(--err-line); }
textarea { max-width: 100%; min-height: 8rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem 1rem; }
.row > div { flex: 1 1 8rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; }
.check input { margin-top: .4rem; flex-shrink: 0; width: 1.1rem; height: 1.1rem; }
.btn, button.btn { display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-weight: 700; padding: .8rem 1.6rem; color: var(--btn-text); background: var(--btn); border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; padding: .5rem 1rem; color: var(--brand-2); background: transparent; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.btn-ghost:hover { background: var(--surface-2); }
.advanced { margin: .5rem 0 1.2rem; }
summary { cursor: pointer; font-weight: 600; }

.result { border: 2px solid var(--accent); background: var(--surface); border-radius: var(--radius); padding: 1.3rem 1.4rem; margin: 1.6rem 0 1rem; box-shadow: var(--shadow); }
.result-label { margin: 0; color: var(--muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.result-big { margin: .1rem 0 .4rem; font-size: clamp(1.7rem, 5vw, 2.4rem); font-weight: 800; line-height: 1.2; color: var(--brand-2); letter-spacing: -.01em; }
.result-sub { margin: 0 0 .6rem; color: var(--text); }
.result-actions { margin: .6rem 0 0; }
.steps { padding-left: 1.3rem; }
.steps li { margin: .4rem 0; }
.ticks { list-style: none; padding: 0; margin: .5rem 0; }
.ticks li { position: relative; padding-left: 1.7rem; margin: .5rem 0; }
.ticks li::before { content: ""; position: absolute; left: .15rem; top: .55em; width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: .6rem 0 1rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .88rem; text-transform: uppercase; letter-spacing: .04em; }
.row-yours td { font-weight: 700; background: var(--ok-bg); }
.box { border: 1px solid; border-radius: 12px; padding: .8rem 1.1rem; margin: 1rem 0; }
.box ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.warning { background: var(--warn-bg); border-color: var(--warn-line); }
.error { background: var(--err-bg); border-color: var(--err-line); }
.okbox { background: var(--ok-bg); border-color: var(--ok-line); }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin: .5rem 0; }
.faq summary { font-weight: 600; }
.faq details p { margin: .6rem 0 0; color: var(--muted); }
.sources ol { padding-left: 1.3rem; }
.calc-side .card { margin-top: 0; }
.side-card h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
.side-list { list-style: none; padding: 0; margin: 0; }
.side-list li { margin: .5rem 0; }
.prose h2 { margin-top: 1.8rem; }

/* Publicidade: espaço reservado para a página não saltar */
.ad { margin: 1.4rem auto; max-width: 100%; text-align: center; }
.ad-label { margin: 0 0 .25rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ad-box { display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--surface-2); border-radius: 8px; }
.ad-box ins { width: 100%; }
.ad-banner img { max-width: 100%; height: auto; display: block; }
.ad-mh-50 { min-height: 50px; } .ad-mh-90 { min-height: 90px; } .ad-mh-100 { min-height: 100px; } .ad-mh-250 { min-height: 250px; } .ad-mh-280 { min-height: 280px; } .ad-mh-600 { min-height: 600px; }
@media (min-width: 768px) {
  .ad-dh-50 { min-height: 50px; } .ad-dh-90 { min-height: 90px; } .ad-dh-100 { min-height: 100px; } .ad-dh-250 { min-height: 250px; } .ad-dh-280 { min-height: 280px; } .ad-dh-600 { min-height: 600px; }
}
@media (max-width: 767px) { .ad-nomobile { display: none; } }
@media (min-width: 768px) { .ad-nodesktop { display: none; } }
.calc-side .ad { margin-top: 0; }

/* Rodapé */
.site-footer { background: var(--footer-bg); color: #e3ecf6; margin-top: 3rem; padding: 2.4rem 0 1rem; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.6rem; }
.footer-brand { font-weight: 800; font-size: 1.25rem; color: #fff; margin: 0; }
.footer-title { font-weight: 700; color: #fff; margin: 0 0 .4rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .35rem 0; }
.site-footer .muted { color: #bccde1; }
.site-footer .notice { font-size: .88rem; margin-top: .8rem; color: #e3ecf6; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.22); margin-top: 1.6rem; padding-top: 1rem; }

/* Impressão: só o resultado */
@media print {
  .site-header, .site-footer, .ad, .calc-side, .form-card, .faq, .btn-ghost, .announcement, .hero-search, .bookmark-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .result { box-shadow: none; }
  /* A grelha da página não se parte entre folhas: o conteúdo todo ia para a 2.ª folha e a 1.ª ficava em branco. */
  .calc-layout { display: block; }
  .result, .steps li, .notice, .card { break-inside: avoid; }
  h1, h2 { break-after: avoid; }
}

[data-situations][hidden] { display: none; }

.site-footer button.link { background: none; border: 0; padding: 0; color: #fff; font: inherit; text-decoration: underline; cursor: pointer; }

.glossary-list { margin: 0 0 1rem; }
.glossary-list dt { font-weight: 600; margin-top: .75rem; }
.glossary-list dd { margin: .15rem 0 0; color: var(--muted, #555); }
