/* Cores com contraste verificado: texto normal ≥ 4,5:1, componentes ≥ 3:1 (WCAG 2.2 AA). */
:root {
  --fundo: #f6f5f2;
  --superficie: #ffffff;
  --superficie-2: #eeece6;
  --texto: #1b1a17;
  --suave: #5a564e;
  --borda: #cfcbc0;
  --borda-forte: #8a8578;
  --marca: #14213d;
  --sobre-marca: #f6f5f2;
  --acento: #a8470f;
  --sobre-acento: #ffffff;
  --verde: #0b6b6a;
  --perigo: #b3261e;
  --aviso: #8a5a00;
  --foco: #0b57d0;
  --fundo-info: #e8f0f7;
  --fundo-erro: #fbe9e7;
  --fundo-ok: #e4f2ee;
  --fundo-aviso: #fbf0d9;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.08);
  --raio: 10px;
  color-scheme: light;
}
:root[data-tema="dark"] {
  --fundo: #14130f;
  --superficie: #1d1b17;
  --superficie-2: #26241f;
  --texto: #f1ede2;
  --suave: #b9b3a4;
  --borda: #3a372f;
  --borda-forte: #8f897a;
  --marca: #0e0d0a;
  --sobre-marca: #f1ede2;
  --acento: #f0a63c;
  --sobre-acento: #14130f;
  --verde: #5cc9c7;
  --perigo: #ff8a80;
  --aviso: #f2c04e;
  --foco: #8ab4ff;
  --fundo-info: #1b2733;
  --fundo-erro: #3a1f1c;
  --fundo-ok: #17302c;
  --fundo-aviso: #3a2f14;
  --sombra: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
img, svg { max-width: 100%; }
a { color: var(--acento); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; border-radius: 3px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.4em 0 0.6em; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.2em 0 0.5em; }
p { margin: 0.5em 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--superficie-2); padding: 0.75em; border-radius: 6px; margin: 0.5em 0; }
.suave { color: var(--suave); }
.so-leitor { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.saltar { position: absolute; left: 8px; top: -60px; background: var(--acento); color: var(--sobre-acento); padding: 0.6em 1em; border-radius: 6px; z-index: 100; font-weight: 600; }
.saltar:focus { top: 8px; }
.grande-texto { font-size: 1.25rem; }

/* topo */
.topo { background: var(--marca); color: var(--sobre-marca); }
.topo a { color: var(--sobre-marca); }
.topo-linha { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; padding: 0.6rem 16px; max-width: 1400px; margin: 0 auto; }
.marca { display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; margin-right: auto; }
.marca-nome { font-weight: 700; font-size: 1.05rem; }
.marca-cliente { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.menu ul, .linguas { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.menu a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.8rem; border-radius: 8px; text-decoration: none; }
.menu a:hover { background: rgb(255 255 255 / 0.12); }
.menu a[aria-current="page"] { background: rgb(255 255 255 / 0.2); font-weight: 700; box-shadow: inset 0 -3px 0 var(--acento); }
.ferramentas { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; order: 3; }
/* Em ecrã largo, a língua, o tema e a conta ficam sempre em cima, à direita, e o menu numa linha própria por
   baixo. Antes o menu ocupava a linha de cima e empurrava estes botões para uma segunda linha, à esquerda, onde
   não se davam por eles com a janela maximizada. */
@media (min-width: 900px) {
  .topo .menu { order: 4; flex-basis: 100%; }
}
.linguas a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border-radius: 8px; text-decoration: none; font-size: 0.85rem; }
.linguas a[aria-current="true"] { background: rgb(255 255 255 / 0.2); font-weight: 700; }
.pessoa { font-size: 0.9rem; display: inline-flex; flex-direction: column; line-height: 1.2; }
.pessoa-papel { font-size: 0.75rem; opacity: 0.85; }
.botao-menu, .botao-tema, .botao-sair {
  min-height: 44px; padding: 0 0.9rem; border: 1px solid rgb(255 255 255 / 0.5); border-radius: 8px;
  background: transparent; color: var(--sobre-marca); font: inherit; cursor: pointer;
}
.botao-menu:hover, .botao-tema:hover, .botao-sair:hover { background: rgb(255 255 255 / 0.15); }
.form-sair { margin: 0; }
.botao-menu { display: none; }
.faixa-demo { background: var(--fundo-aviso); color: var(--texto); padding: 0.5rem 16px; text-align: center; border-bottom: 2px solid var(--aviso); }

/* conteúdo */
main { margin: 0 auto; padding: 1rem 16px 5rem; }
main.estreito { max-width: 920px; }
main.largo { max-width: 1400px; }
main:focus { outline: none; }
.rodape { max-width: 1400px; margin: 0 auto; padding: 1rem 16px 2rem; color: var(--suave); font-size: 0.85rem; }
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem 1.25rem; margin: 1rem 0; box-shadow: var(--sombra); }
.cartao h2:first-child { margin-top: 0.2em; }
.cartao.destaque { border-left: 6px solid var(--acento); }
.cartao.centrado { text-align: center; max-width: 640px; margin-inline: auto; }
.estreito-form { max-width: 460px; margin-inline: auto; }
.aviso { padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 0; border: 1px solid var(--borda-forte); }
.aviso p { margin: 0.25em 0; }
.aviso-ok { background: var(--fundo-ok); }
.aviso-erro { background: var(--fundo-erro); border-color: var(--perigo); }
.aviso-info { background: var(--fundo-info); }
.migalhas ol { list-style: none; display: flex; gap: 0.5rem; padding: 0; margin: 0.25rem 0; font-size: 0.9rem; }
.migalhas li + li::before { content: "›"; margin-right: 0.5rem; color: var(--suave); }

/* botões e campos */
.botao {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.4rem 1.1rem;
  border-radius: 8px; border: 2px solid var(--borda-forte); background: var(--superficie); color: var(--texto);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.botao:hover { background: var(--superficie-2); }
.botao.primario { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); }
.botao.primario:hover { filter: brightness(1.08); background: var(--acento); }
.botao.grande { min-height: 52px; font-size: 1.1rem; padding-inline: 1.6rem; }
.botao[disabled], button[disabled] { opacity: 0.55; cursor: not-allowed; }
.botoes { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.botoes form { margin: 0; }
.botao.pequeno { min-height: 44px; padding: 0.3rem 0.8rem; font-size: 0.95rem; }
.campo { margin: 0.9rem 0; }
.campo label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: 0.5rem 0.7rem; font: inherit; color: var(--texto); background: var(--superficie);
  border: 2px solid var(--borda-forte); border-radius: 8px;
}
textarea { resize: vertical; }
input[type="file"] { width: 100%; padding: 0.5rem 0; font: inherit; }
fieldset { border: 1px solid var(--borda); border-radius: 8px; padding: 0.5rem 1rem 0.75rem; margin: 0.75rem 0; min-width: 0; }
legend { font-weight: 700; padding: 0 0.4rem; }
fieldset.envolvente { border: 0; padding: 0; margin: 0; }
.titulo-form { font-size: 1.25rem; margin: 0 0 0.4rem; }

/* lista de números */
.numeros { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.numero { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 0.8rem 1rem; }
.numero a { text-decoration: none; display: flex; flex-direction: column; color: var(--texto); }
.numero a:hover .numero-rotulo { text-decoration: underline; }
.numero-valor { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.numero-rotulo { font-weight: 600; color: var(--acento); }
.numero-ajuda { display: block; font-size: 0.85rem; margin-top: 0.25rem; }
.lista-simples { padding-left: 1.2rem; }
.lista-simples li { margin: 0.25rem 0; }

/* tabelas */
/* position: relative é o que impede o texto escondido (.so-leitor, absoluto) de escapar ao recorte e esticar a página */
.tabela-envolvente { position: relative; overflow-x: auto; border: 1px solid var(--borda); border-radius: var(--raio); background: var(--superficie); }
.tabela { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tabela th, .tabela td { padding: 0.55rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--borda); }
.tabela thead th { background: var(--superficie-2); position: sticky; top: 0; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.tabela tbody th[scope="row"] { font-weight: 600; background: var(--superficie); position: sticky; left: 0; }
.tabela .num { text-align: right; white-space: nowrap; }
.celula-assunto { min-width: 14rem; max-width: 28rem; overflow-wrap: anywhere; }
.ligacao-acao { font-weight: 600; white-space: nowrap; }
.codigos { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.78rem; background: var(--superficie-2); border: 1px solid var(--borda); border-radius: 4px; padding: 0 0.3rem; white-space: nowrap; }
.estado { display: inline-block; font-weight: 600; font-size: 0.9rem; }
.estado-pendente { color: var(--aviso); }
.estado-feita { color: var(--verde); }
.estado-duvidas { color: var(--aviso); }
.estado-repetida, .estado-neutro { color: var(--suave); }
.estado-erro { color: var(--perigo); display: block; }
.estado-erro p { color: var(--texto); }
.estado-erro p:first-child { color: var(--perigo); }
.barra { display: inline-block; vertical-align: middle; width: 90px; height: 8px; background: var(--superficie-2); border: 1px solid var(--borda-forte); border-radius: 4px; margin-left: 0.4rem; overflow: hidden; }
.barra-cheia { display: block; height: 100%; background: var(--verde); }
.filtros { display: grid; gap: 0.5rem 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 0.75rem 1rem; }
.filtros .campo { margin: 0; }
.contagem { font-weight: 600; margin: 0.9rem 0 0.4rem; }
.paginacao { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.selo { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0 0.4rem; border-radius: 4px; background: var(--fundo-aviso); border: 1px solid var(--aviso); color: var(--texto); vertical-align: middle; }
.nota { display: block; font-size: 0.85rem; color: var(--texto); border-left: 3px solid var(--acento); padding-left: 0.5rem; margin-top: 0.15rem; }
.lista-assuntos { list-style: none; padding: 0; margin: 0; }
.lista-assuntos li { padding: 0.6rem 0; border-top: 1px solid var(--borda); }
.cartoes-caixa { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cartoes-caixa .cartao { margin: 0; }
.cartoes-caixa h2 { font-size: 1.05rem; word-break: break-all; }
.tecnico summary { cursor: pointer; color: var(--suave); font-size: 0.85rem; min-height: 32px; }
.lista-erros { padding-left: 1.2rem; }
.palavra-passe { font-size: 1.5rem; background: var(--superficie-2); padding: 0.3rem 0.6rem; border-radius: 6px; user-select: all; }

/* ecrã de classificação */
.duas-colunas { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
.mensagem { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem 1.25rem; }
.olho { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--suave); margin: 0; overflow-wrap: anywhere; }
.meta { margin: 0.5rem 0; display: grid; gap: 0.15rem; }
.meta div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.5rem; }
.meta dt { color: var(--suave); font-weight: 600; }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.posicao { background: var(--fundo-info); border-radius: 6px; padding: 0.4rem 0.7rem; font-size: 0.9rem; }
.corpo { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--fundo); border: 1px solid var(--borda); border-radius: 8px; padding: 0.8rem 1rem; max-height: 55vh; overflow: auto; font-size: 0.98rem; }
.anexos ul { list-style: none; padding: 0; margin: 0; }
.anexos li { padding: 0.4rem 0; border-top: 1px solid var(--borda); display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; }
.anexo-nome { font-weight: 600; overflow-wrap: anywhere; }
.dica { background: var(--fundo-info); border-radius: 8px; padding: 0.4rem 0.9rem; margin-top: 1rem; font-size: 0.92rem; }
.coluna-form { min-width: 0; }
.classificacao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem 1.25rem 0; }
.ajuda { margin-top: 0; }
.resumo-escolha { background: var(--fundo-ok); border: 1px solid var(--verde); border-radius: 8px; padding: 0.5rem 0.8rem; margin: 0.75rem 0; font-size: 0.93rem; overflow-wrap: anywhere; }
.resumo-escolha.vazio { background: var(--superficie-2); border-color: var(--borda-forte); }
.categoria { border: 1px solid var(--borda); border-radius: 8px; margin: 0.6rem 0; background: var(--superficie); }
.categoria > summary, .duvidas > summary, .mais > summary { cursor: pointer; font-weight: 700; padding: 0.6rem 0.8rem; min-height: 44px; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.categoria[open] > summary { border-bottom: 1px solid var(--borda); background: var(--superficie-2); border-radius: 8px 8px 0 0; }
.categoria-codigo { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--acento); }
.categoria-contagem { margin-left: auto; font-size: 0.82rem; font-weight: 600; color: var(--verde); }
.categoria-pergunta { margin: 0.4rem 0.8rem; font-size: 0.9rem; }
.opcoes { padding: 0 0.4rem 0.4rem; }
.opcao { display: flex; gap: 0.7rem; align-items: flex-start; min-height: 44px; padding: 0.55rem 0.5rem; border-radius: 8px; cursor: pointer; }
.opcao:hover { background: var(--superficie-2); }
.opcao input { flex: none; width: 24px; height: 24px; margin: 0.1rem 0 0; accent-color: var(--acento); }
.opcao:has(input:checked) { background: var(--fundo-ok); outline: 2px solid var(--verde); outline-offset: -2px; }
.opcao-texto { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.opcao-titulo { display: block; }
.duvidas, .mais { border: 1px dashed var(--borda-forte); border-radius: 8px; margin: 0.8rem 0; padding: 0 0.4rem 0.4rem; }
.duvidas > p, .mais > .campo { margin-inline: 0.6rem; }
.certeza { margin: 0.8rem 0; }
.barra-acoes { position: sticky; bottom: 0; background: var(--superficie); border-top: 2px solid var(--borda); margin: 0.75rem -1.25rem 0; padding: 0.6rem 1.25rem calc(0.6rem + env(safe-area-inset-bottom)); border-radius: 0 0 var(--raio) var(--raio); z-index: 5; }
/* Espaço reservado para duas linhas: uma mensagem nova nunca empurra os botões debaixo do dedo. */
.estado-guardar { min-height: 3.1em; margin: 0 0 0.4rem; font-size: 0.9rem; color: var(--suave); }
.estado-guardar.erro { color: var(--perigo); font-weight: 600; }
.estado-guardar.ok { color: var(--verde); font-weight: 600; }
.historico { margin: 1rem 0; }
.historico summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.historico ol { padding-left: 1.2rem; }
.historico li { margin: 0.5rem 0; }
.recuperar { margin: 0.75rem 0; }

.titulo-com-acao { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.importar-caixa summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.form-importar { margin-top: 0.4rem; }
.tabela tbody th.celula-assunto a { font-weight: 600; }

@media (min-width: 1000px) {
  .duas-colunas { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .mensagem { position: sticky; top: 0.75rem; max-height: calc(100vh - 1.5rem); overflow: auto; }
}
/* Em ecrãs estreitos a mensagem e o formulário ficam um por baixo do outro: a barra de ações fixa-se ao fundo,
   para a ação principal nunca ficar fora do ecrã, e a página reserva espaço para ela não tapar o fim do conteúdo. */
@media (max-width: 999px) {
  html { scroll-padding-bottom: 10rem; }
  .barra-acoes { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; box-shadow: 0 -4px 14px rgb(0 0 0 / 0.18); }
  .barra-acoes .botoes { flex-wrap: wrap; }
  .classificacao { padding-bottom: 9rem; }
  /* Enquanto se escreve num campo de texto, o teclado do telemóvel ocupa o fundo do ecrã: a barra deixa de
     estar presa ao fundo, para nunca tapar o campo nem ficar escondida atrás do teclado. */
  .a-escrever .barra-acoes { position: static; box-shadow: none; margin: 0.75rem -1.25rem 0; }
}
@media (max-width: 899px) {
  .js .botao-menu { display: inline-flex; align-items: center; }
  .js .menu { display: none; width: 100%; order: 10; }
  .js .menu.aberto { display: block; }
  .menu ul { flex-direction: column; }
  .menu a { width: 100%; }
  .meta div { grid-template-columns: 1fr; gap: 0; }
  .corpo { max-height: 40vh; }
}
@media (max-width: 520px) {
  main { padding-inline: 12px; }
  .botoes .botao, .barra-acoes .botao { flex: 1 1 100%; }
  h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* separadores da lista e menu da ordem */
.barra-lista { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; justify-content: space-between; margin: 0.75rem 0; }
.separadores { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem; padding: 0; margin: 0; border-bottom: 2px solid var(--borda); }
.separadores a {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.35rem 0.9rem;
  color: var(--texto); text-decoration: none; font-weight: 600; border-radius: 8px 8px 0 0; margin-bottom: -2px;
  border-bottom: 3px solid transparent;
}
.separadores a:hover { background: var(--superficie-2); }
.separadores a[aria-current="page"] { border-bottom-color: var(--acento); color: var(--acento); }
.separador-n { font-weight: 400; font-size: 0.9rem; color: var(--suave); }
.separadores a[aria-current="page"] .separador-n { color: inherit; }
.form-ordem { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.form-ordem label { font-weight: 600; }
.form-ordem select { width: auto; }

/* sugestão automática */
.aviso.sugestao { border-left: 6px solid var(--foco); }
.selo-sugestao { border-color: var(--foco); color: var(--texto); background: var(--fundo-info); }
