/*
 * Tema claro: fundo cinza muito claro, cartões brancos, texto cor de asfalto
 * e o azul das placas de sinalização como cor de destaque.
 * Letra: Barlow Condensed (inspirada na sinalética de estrada) para nome,
 * meses, dias e números; Barlow para o texto.
 */
:root {
    --papel: #f5f7f9;
    --branco: #ffffff;
    --asfalto: #22262c;
    --cinza: #5d6672;
    --linha: #e1e5ea;
    --linha-forte: #c9d0d8;
    --sinal: #1c4fa0;
    --sinal-escuro: #163f80;
    --sinal-suave: #e8eef8;
    --trail: #2f6b3f;
    --trail-suave: #e6f1e8;
    --corta-mato: #8a5a14;
    --corta-mato-suave: #f6eedf;
    --pista: #a3361f;          /* tartan das pistas */
    --pista-suave: #f9e9e4;
    --premios: #1f7a4d;        /* verde das notas */
    --premios-escuro: #17603c;
    --erro: #b3261e;
    --erro-soft: #fbe9e7;

    --letra: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --letra-estreita: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
    --largura: 920px;
    /* Alturas da barra de filtros e do título do mês: o título do mês fica
       fixo por baixo da barra, e o dorsal do dia por baixo do título. */
    --altura-filtros: 60px;
    --altura-mes: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--letra);
    font-size: 1rem;
    line-height: 1.45;
    background: var(--papel);
    color: var(--asfalto);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--sinal); outline-offset: 2px; border-radius: 4px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Topo: da cor da página, só o nome e a conta */
header.topo { padding: 16px 16px 6px; }
.topo-linha {
    max-width: var(--largura);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.marca {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--asfalto);
}
.marca-simbolo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #2f6fd0 0%, var(--sinal) 55%, var(--sinal-escuro) 100%);
    color: #fff;
    box-shadow: 0 4px 12px -4px rgba(28, 79, 160, 0.55);
}
.marca-nome {
    font-family: var(--letra-estreita);
    font-weight: 800;
    font-size: 1.75rem;
    line-height: 1;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}
nav.conta { display: flex; align-items: center; gap: 16px; font-size: 0.92rem; }
nav.conta a { text-decoration: none; color: var(--cinza); display: inline-flex; align-items: center; gap: 6px; }
nav.conta a:hover { color: var(--sinal); }
nav.conta a.conta-destaque { color: var(--sinal); font-weight: 600; }
nav.conta form { margin: 0; }
nav.conta button.link {
    background: none; border: none; padding: 0; margin: 0;
    color: var(--cinza); font: inherit; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
nav.conta svg { flex: none; }
nav.conta button.link:hover { color: var(--sinal); }

/* Filtros: barra fixa no topo ao descer */
.barra-filtros {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(245, 247, 249, 0.94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    padding: 10px 16px;
}
form.filtros {
    max-width: var(--largura);
    margin: 0 auto;
    position: relative;
}
/* Linha principal: Filtros, pesquisa, tipo e mês; o resto dos filtros fica no painel. */
.linha-principal {
    display: grid;
    grid-template-columns: auto minmax(200px, 1fr) minmax(130px, 160px) minmax(130px, 160px) auto;
    gap: 8px;
    align-items: center;
}
form.filtros.com-js .filtrar { position: absolute; left: -9999px; }
form.filtros label { display: block; min-width: 0; }
form.filtros select,
form.filtros input[type="search"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--linha);
    border-radius: 10px;
    background: var(--branco);
    color: var(--asfalto);
    font-family: var(--letra);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1;
}
form.filtros select { text-overflow: ellipsis; }
form.filtros select:hover,
form.filtros input[type="search"]:hover { border-color: var(--linha-forte); }
form.filtros select:focus-visible,
form.filtros input[type="search"]:focus-visible { outline: 2px solid var(--sinal); outline-offset: 1px; border-color: var(--sinal); }
.campos-painel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
}
.procura { position: relative; }
.procura svg {
    position: absolute; left: 11px; top: 11px;
    fill: none; stroke: var(--cinza); stroke-width: 2; stroke-linecap: round;
    pointer-events: none;
}
form.filtros .procura input { padding-left: 36px; }
form.filtros .filtrar {
    height: 40px;
    padding: 0 18px;
    border: none;
    border-radius: 10px;
    background: var(--sinal);
    color: var(--branco);
    font-family: var(--letra);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

main {
    max-width: var(--largura);
    margin: 0 auto;
    padding: 10px 16px 40px;
}
.resumo {
    margin: 0 0 6px;
    color: var(--cinza);
    font-size: 0.92rem;
}
.resumo .numero-total { font-size: 1.35em; font-weight: 700; color: var(--asfalto); }
.resumo a { margin-left: 10px; color: var(--sinal); font-weight: 600; text-decoration: none; }
.resumo a:hover { text-decoration: underline; }

/* Meses: o título fica fixo ao descer (até o mês seguinte o empurrar) */
section.mes { margin-top: 14px; }
section.mes > h2 {
    position: sticky;
    top: var(--altura-filtros);
    z-index: 5;
    height: var(--altura-mes);
    margin: 0 0 4px;
    padding: 12px 0 8px;
    font-family: var(--letra-estreita);
    font-weight: 600;
    font-size: 1.9rem;
    line-height: 36px;
    background: rgba(245, 247, 249, 0.94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* Dias: o dorsal com o dia à esquerda (fica à vista ao descer), as provas à direita */
.dia {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 18px;
}
.dia-marca {
    position: sticky;
    top: calc(var(--altura-filtros) + var(--altura-mes) + 8px);
    align-self: start;
}
.dia-titulo { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* O dorsal: faixa azul com o dia da semana, número grande e quatro alfinetes */
.dorsal {
    display: flex;
    flex-direction: column;
    width: 76px;
    height: 80px;
    background:
        radial-gradient(circle at 8px calc(100% - 8px), var(--linha-forte) 2.5px, transparent 3px),
        radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--linha-forte) 2.5px, transparent 3px),
        var(--branco);
    border: 1px solid var(--linha-forte);
    border-radius: 6px;
    overflow: hidden;
}
.dorsal-topo {
    position: relative;
    height: 22px;
    background: var(--sinal);
    color: var(--branco);
    font-family: var(--letra-estreita);
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 22px;
    text-align: center;
    text-transform: lowercase;
}
.dorsal-topo::before,
.dorsal-topo::after {
    content: "";
    position: absolute;
    top: 8px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
}
.dorsal-topo::before { left: 6px; }
.dorsal-topo::after { right: 6px; }
.dorsal-dia {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--letra-estreita);
    font-weight: 700;
    font-size: 2.5rem;
    line-height: 1;
    letter-spacing: -0.02em;
}

/* Cartões das provas */
ul.provas {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}
li.prova {
    position: relative;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
    padding: 14px;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: 12px;
    transition: border-color .15s, box-shadow .15s;
}
/* O cartão inteiro abre a página da prova: o ::after do link cobre-o todo */
li.prova { cursor: pointer; }
li.prova:hover { border-color: var(--linha-forte); box-shadow: 0 3px 12px rgba(34, 38, 44, 0.07); }
li.prova:hover h4 { color: var(--sinal); }
.prova-link { text-decoration: none; }
.prova-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.prova-link:focus-visible { outline: none; }
.prova-link:focus-visible::after { outline: 2px solid var(--sinal); outline-offset: 2px; }
/* O que tem ação própria fica por cima do link do cartão */
.prova-fontes a,
.prova-corpo .premios,
form.favorito,
li.prova > a.favorito-btn { position: relative; z-index: 1; }

/* Miniatura: o cartaz da prova; sem cartaz, o desenho de uma estrada */
.miniatura {
    position: relative;
    display: block;
    width: 88px;
    height: 88px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--papel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c3cbd5' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M5 21 10 3M19 21 14 3'/%3E%3Cpath d='M12 20v-2.5M12 14v-2M12 8.5V7' stroke-width='1.2'/%3E%3C/svg%3E") center / 40px no-repeat;
}
.miniatura img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prova-corpo { min-width: 0; }
.prova-corpo h4 {
    margin: 2px 0 4px;
    font-size: 1.06rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
    transition: color .15s;
}
/* Prémios monetários: moeda "€" ao lado do nome (verde: há; riscada: não há) */
.premios {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    border-radius: 50%;
    vertical-align: 2px;
    font-family: var(--letra-estreita);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: help;
}
a.premios { cursor: pointer; }
.premios-sim { background: var(--premios); color: var(--branco); }
.premios-sim:hover { background: var(--premios-escuro); }

.prova-local {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 0 8px;
    color: var(--cinza);
    font-size: 0.92rem;
}
.prova-local svg { flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
.prova-inscricao {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 0 0 8px;
    color: var(--cinza);
    font-size: 0.92rem;
}
.prova-inscricao svg { flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
.prova-inscricao strong { color: var(--asfalto); }
.prova-inscricao a { margin-left: 4px; color: var(--sinal); font-size: 0.9rem; font-weight: 600; text-decoration: none; }
.prova-inscricao a:hover { text-decoration: underline; }
.prova-inscricao .nota-inline { font-size: 0.85rem; }

/* Distâncias: lembram os marcos quilométricos */
ul.etiquetas {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
ul.etiquetas li {
    font-family: var(--letra-estreita);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
    padding: 4px 7px 3px;
    border: 1px solid var(--linha);
    border-radius: 4px;
    background: var(--papel);
}
ul.etiquetas li.etiqueta-trail { border-color: transparent; background: var(--trail-suave); color: var(--trail); }
ul.etiquetas li.etiqueta-corta-mato { border-color: transparent; background: var(--corta-mato-suave); color: var(--corta-mato); }
ul.etiquetas li.etiqueta-pista { border-color: transparent; background: var(--pista-suave); color: var(--pista); }
.prova-fontes { margin: 0; font-size: 0.8rem; color: var(--cinza); }
.prova-fontes a { color: var(--cinza); }
.prova-fontes a:hover { color: var(--sinal); }

/* Entrada dos cartões: aparecem suavemente ao chegar ao ecrã (assets/app.js).
   Só com JavaScript ativo (classe "js" no <html>), para nunca ficarem escondidos. */
html.js li.prova {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease, transform .5s ease, border-color .15s, box-shadow .15s;
}
html.js li.prova.visivel { opacity: 1; transform: none; }

/* Guardar no "meu calendário" */
form.favorito { margin: 0; }
.favorito-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px 0 9px;
    border: 1px solid var(--linha);
    border-radius: 999px;
    background: var(--branco);
    color: var(--cinza);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.favorito-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.favorito-btn:hover { border-color: var(--sinal); color: var(--sinal); }
.favorito-btn.ativo { background: var(--sinal); border-color: var(--sinal); color: var(--branco); }
.favorito-btn.ativo svg { fill: currentColor; }
.favorito-btn.ativo:hover { background: var(--sinal-escuro); color: var(--branco); }
.favorito-btn:disabled { opacity: 0.6; cursor: progress; }

/* Carregar mais provas */
a.mais {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 22px auto 0;
    padding: 10px 20px;
    border: 1px solid var(--linha);
    border-radius: 999px;
    background: var(--branco);
    color: var(--sinal);
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}
a.mais:hover { border-color: var(--sinal); }
a.mais.a-carregar { color: var(--cinza); pointer-events: none; }

.vazio { text-align: center; color: var(--cinza); padding: 48px 0; }
.vazio a { display: block; margin-top: 8px; color: var(--sinal); font-weight: 600; }

.voltar-topo {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--linha);
    border-radius: 50%;
    background: var(--branco);
    color: var(--asfalto);
    box-shadow: 0 4px 14px rgba(34, 38, 44, 0.14);
    cursor: pointer;
}
.voltar-topo[hidden] { display: none; }
.voltar-topo svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.voltar-topo:hover { color: var(--sinal); border-color: var(--sinal); }

footer {
    max-width: var(--largura);
    margin: 0 auto;
    padding: 8px 16px 32px;
    text-align: center;
    color: var(--cinza);
    font-size: 0.8rem;
}

/* Título de página interior (ex. "O meu calendário") */
.pagina-titulo {
    font-family: var(--letra-estreita);
    font-weight: 700;
    font-size: 2.2rem;
    line-height: 1.1;
    margin: 6px 0 0;
}
.cabeca-pagina {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}
/* Sem barra de filtros fixa, o mês fica no topo da janela e o dia logo abaixo */
.cabeca-pagina ~ section.mes > h2 { top: 0; }
.cabeca-pagina ~ section .dia-marca { top: calc(var(--altura-mes) + 8px); }

/* Exportar "o meu calendário" (.ics): barra de ícones, sem texto visível */
nav.exportar {
    position: relative;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.icone-botao {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--linha);
    border-radius: 12px;
    background: var(--branco);
    color: var(--asfalto);
    cursor: pointer;
}
.icone-botao:hover { border-color: var(--sinal); color: var(--sinal); }
.icone-botao svg { width: 20px; height: 20px; }
.icone-botao svg.traco {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icone-perigo:hover { border-color: var(--erro); color: var(--erro); }

details.exportar-link > summary { list-style: none; }
details.exportar-link > summary::-webkit-details-marker { display: none; }
details.exportar-link[open] > summary { border-color: var(--sinal); color: var(--sinal); background: var(--sinal-suave); }
.exportar-painel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 5;
    width: min(460px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(34, 38, 44, 0.12);
}
.exportar-painel input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 10px;
    border: 1px solid var(--linha);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--cinza);
    background: var(--papel);
}
.exportar-painel form { margin: 0; }
#copiar-link-ics .icone-copiado { display: none; }
#copiar-link-ics.copiado { border-color: var(--sinal); color: var(--sinal); }
#copiar-link-ics.copiado .icone-copiar { display: none; }
#copiar-link-ics.copiado .icone-copiado { display: block; }
.link-renovado { color: var(--sinal); font-weight: 700; padding: 0 4px; }

/* Páginas de autenticação */
.auth-wrap {
    max-width: 380px;
    margin: 40px auto;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: 12px;
    padding: 28px;
}
.auth-wrap h1 {
    margin: 0 0 20px;
    font-family: var(--letra-estreita);
    font-weight: 700;
    font-size: 1.9rem;
    text-align: center;
}
.campo { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: 0.85rem; color: var(--cinza); }
.campo input {
    height: 42px;
    padding: 0 10px;
    border: 1px solid var(--linha);
    border-radius: 8px;
    font: inherit;
}
.botao-principal {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--sinal);
    color: var(--branco);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}
.botao-principal:hover { background: var(--sinal-escuro); }
.botao-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--linha);
    border-radius: 8px;
    background: var(--branco);
    color: var(--asfalto);
    font-size: 0.92rem;
    text-align: center;
    text-decoration: none;
    margin-top: 10px;
}
.botao-google:hover { border-color: var(--sinal); }
.separador { text-align: center; color: var(--cinza); font-size: 0.8rem; margin: 16px 0; }
.aviso-erro {
    background: var(--erro-soft);
    color: var(--erro);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    margin-bottom: 14px;
}
/* Gestão de utilizadores (administradores) */
.gestao-explicacao { margin: 0 0 16px; color: var(--cinza); font-size: 0.95rem; max-width: 640px; }
.gestao-explicacao .premios { margin: 0 2px; cursor: default; }
.gestao-procura { display: flex; gap: 8px; margin-bottom: 14px; max-width: 520px; }
.gestao-procura .procura { flex: 1; min-width: 0; }
.gestao-procura input[type="search"] {
    width: 100%;
    height: 40px;
    padding: 0 10px 0 36px;
    border: 1px solid var(--linha);
    border-radius: 8px;
    background: var(--branco);
    color: var(--asfalto);
    font: inherit;
}
.gestao-procura .botao-principal { width: auto; height: 40px; margin: 0; padding: 0 18px; }
.gestao-aviso {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--trail-suave);
    color: var(--trail);
    font-size: 0.9rem;
}
ul.utilizadores { list-style: none; margin: 10px 0 40px; padding: 0; display: grid; gap: 10px; }
li.utilizador {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--linha);
    border-radius: 12px;
    background: var(--branco);
}
.utilizador-dados { min-width: 0; }
.utilizador-dados p { margin: 0; }
.utilizador-nome { font-weight: 600; }
.utilizador-email { color: var(--asfalto); font-size: 0.92rem; overflow-wrap: anywhere; }
.utilizador-info { color: var(--cinza); font-size: 0.8rem; margin-top: 2px !important; }
.etiqueta-admin {
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--sinal-suave);
    color: var(--sinal);
    font-family: var(--letra-estreita);
    font-size: 0.82rem;
    font-weight: 600;
}
.acesso-form { display: flex; align-items: center; gap: 10px; margin: 0; flex: none; }
.acesso-botao {
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.acesso-botao.retirar { border: 1px solid var(--linha-forte); background: var(--branco); color: var(--cinza); }
.acesso-botao.retirar:hover { border-color: var(--erro); color: var(--erro); }
.acesso-botao.secundario { border: 1px solid var(--sinal); background: var(--branco); color: var(--sinal); }
.acesso-botao.secundario:hover { background: var(--sinal-suave); }
.utilizador-acoes { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; flex: none; max-width: 60%; }
.etiqueta-desativado {
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--letra-estreita);
    font-size: 0.82rem;
    font-weight: 600;
}
.etiqueta-desativado { background: var(--erro-soft); color: var(--erro); }
.etiqueta-eu { margin-left: 4px; color: var(--cinza); font-size: 0.85rem; font-weight: 400; }
li.utilizador.desativado { background: var(--papel); border-left: 4px solid var(--erro); }
li.utilizador.desativado .utilizador-dados { opacity: 0.7; }
/* Página individual da prova (prova.php) */
.voltar-calendario {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0 14px;
    color: var(--cinza);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}
.voltar-calendario svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.voltar-calendario:hover { color: var(--sinal); }

.prova-detalhe {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    padding: 20px;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: 14px;
}
/* Cartaz da prova; sem cartaz, um dorsal grande com o dia */
.prova-cartaz { border-radius: 10px; overflow: hidden; background: var(--papel); }
.prova-cartaz img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: contain; }
.prova-cartaz .dorsal { display: none; }
.prova-cartaz.sem-imagem { display: grid; place-items: center; aspect-ratio: 1; }
.prova-cartaz.sem-imagem .dorsal { display: flex; }
.prova-cartaz .dorsal-grande { width: 130px; height: 136px; border-radius: 8px; }
.prova-cartaz .dorsal-grande .dorsal-topo { height: 34px; line-height: 34px; font-size: 1.2rem; }
.prova-cartaz .dorsal-grande .dorsal-topo::before,
.prova-cartaz .dorsal-grande .dorsal-topo::after { top: 13px; width: 7px; height: 7px; }
.prova-cartaz .dorsal-grande .dorsal-topo::before { left: 10px; }
.prova-cartaz .dorsal-grande .dorsal-topo::after { right: 10px; }
.prova-cartaz .dorsal-grande .dorsal-dia { font-size: 4.4rem; }

.prova-cabeca h1 {
    margin: 6px 0 6px;
    font-family: var(--letra-estreita);
    font-weight: 700;
    font-size: 2.3rem;
    line-height: 1.08;
    overflow-wrap: anywhere;
}
.prova-quando { margin: 0 0 6px; font-size: 1.08rem; font-weight: 600; }
.ja-passou {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--papel);
    color: var(--cinza);
    font-size: 0.8rem;
    font-weight: 600;
    vertical-align: 2px;
}
.prova-cabeca .prova-local { flex-wrap: wrap; font-size: 1rem; }
.prova-cabeca .prova-local a { color: var(--sinal); font-size: 0.9rem; font-weight: 600; text-decoration: none; margin-left: 4px; }
.prova-cabeca .prova-local a:hover { text-decoration: underline; }

.prova-hora { margin-left: 6px; color: var(--sinal); }
/* Organização: o que mais interessa, em destaque */
.prova-organizacao {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--linha);
}
.prova-organizador { margin: 0 0 10px; font-size: 1.05rem; font-weight: 600; }
.prova-organizador span {
    display: block;
    color: var(--cinza);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.prova-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.botao-secundario {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px;
    border: 1px solid var(--sinal);
    border-radius: 999px;
    color: var(--sinal);
    font-weight: 600;
    text-decoration: none;
}
.botao-secundario svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.botao-secundario:hover { background: var(--sinal-suave); }
.botao-organizador {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    background: var(--sinal);
    color: var(--branco);
    font-weight: 600;
    text-decoration: none;
}
.botao-organizador svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.botao-organizador:hover { background: var(--sinal-escuro); }
.prova-acoes .favorito-btn { height: 42px; padding: 0 16px 0 12px; font-size: 0.92rem; }

.prova-zona { color: var(--cinza); font-size: 0.88rem; }
.prova-zona::before { content: "·"; margin: 0 6px 0 2px; }
.prova-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 12px 0 0; font-size: 0.9rem; }
.prova-links span { color: var(--cinza); }
.prova-credito { margin: 24px 0 0; font-size: 0.85rem; color: var(--cinza); }
.prova-credito a { color: inherit; text-decoration: underline; }
.prova-links a { color: var(--sinal); font-weight: 600; text-decoration: none; }
.prova-links a:hover { text-decoration: underline; }
.premios-excerto { margin: 8px 0; padding-left: 10px; border-left: 3px solid var(--linha); color: var(--cinza); font-size: 0.9rem; }
.nota { display: block; margin: 4px 0 0; color: var(--cinza); font-size: 0.86rem; }
.nota a { color: var(--sinal); }
.nota-inline { color: var(--cinza); }

/* Programa e prémios */
.prova-seccao {
    margin-top: 14px;
    padding: 16px 20px 18px;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: 14px;
}
.prova-seccao h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-family: var(--letra-estreita);
    font-weight: 700;
    font-size: 1.45rem;
    line-height: 1.1;
}
.prova-seccao h2 .premios { margin: 0; cursor: default; }
.prova-seccao p { margin: 0; }
.tabela-rolar { overflow-x: auto; }
.tabela-prova { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tabela-prova th {
    padding: 6px 10px;
    border-bottom: 2px solid var(--linha);
    color: var(--cinza);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}
.tabela-prova td { padding: 7px 10px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.tabela-prova tbody tr:last-child td { border-bottom: none; }
.tabela-hora { font-family: var(--letra-estreita); font-weight: 600; font-size: 1rem; white-space: nowrap; }
.tabela-premios { width: auto; min-width: 240px; }
.tabela-premios th:not(:first-child) { text-align: right; }
.tabela-premios tfoot th,
.tabela-premios tfoot td { padding: 8px 10px; border-top: 2px solid var(--linha); border-bottom: none; }
.tabela-premios tfoot th { color: var(--asfalto); font-size: 0.85rem; }
.tabela-premios .nota-inline { font-family: var(--letra); font-weight: 400; font-size: 0.8rem; white-space: nowrap; }
.premios-total { margin: 10px 0 6px !important; font-size: 1.05rem; }
.premios-total strong { font-family: var(--letra-estreita); font-size: 1.35rem; color: var(--premios); }
.tabela-valor { font-family: var(--letra-estreita); font-weight: 700; font-size: 1.02rem; color: var(--premios); text-align: right; }

@media (max-width: 640px) {
    li.utilizador { flex-direction: column; align-items: stretch; gap: 10px; }
    .acesso-form { justify-content: space-between; }
    .utilizador-acoes { justify-content: flex-start; max-width: none; }
}

.rodape-auth { text-align: center; margin-top: 16px; font-size: 0.88rem; color: var(--cinza); }
.rodape-auth a { color: var(--sinal); font-weight: 600; }

/* Telemóvel */
@media (max-width: 700px) {
    .marca-nome { font-size: 1.5rem; }
    .marca-simbolo { width: 28px; height: 28px; border-radius: 8px; }
    nav.conta { gap: 4px; font-size: 0.88rem; }
    /* Só os ícones (o nome fica em title/aria-label); "Entrar" e "Criar conta" mantêm o texto */
    nav.conta .conta-rotulo { display: none; }
    nav.conta a:has(> svg),
    nav.conta button.link:has(> svg) { padding: 8px; border-radius: 8px; }

    .barra-filtros { padding: 8px 16px; }
    /* Telemóvel: pesquisa na 1.ª linha; Filtros, Tipo e Mês na 2.ª. */
    .linha-principal { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
    .linha-principal .procura { grid-column: 1 / -1; order: -1; }
    form.filtros:not(.com-js) .filtrar { grid-column: 1 / -1; }
    form.filtros select { font-size: 0.88rem; padding: 0 8px; }
    .campos-painel { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    :root { --altura-filtros: 104px; --altura-mes: 48px; }
    /* No telemóvel fixa-se o dia (que já diz o mês, "Domingo, 11 de outubro")
       em vez do título do mês: fixar os dois ocupava demasiado ecrã. */
    section.mes > h2 {
        position: static; height: auto; background: none;
        -webkit-backdrop-filter: none; backdrop-filter: none;
        font-size: 1.6rem; line-height: 30px; padding: 10px 0 4px;
    }

    /* O dia passa para cima das provas: dorsal pequeno + data por extenso */
    .dia { grid-template-columns: 1fr; gap: 8px; }
    .dia-marca {
        position: sticky;
        top: var(--altura-filtros);
        z-index: 4;
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 -16px;
        padding: 6px 16px;
        background: rgba(245, 247, 249, 0.94);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }
    .cabeca-pagina ~ section .dia-marca { top: 0; }
    .dia-titulo {
        position: static; width: auto; height: auto; overflow: visible; clip: auto;
        font-family: var(--letra-estreita); font-weight: 600; font-size: 1.15rem;
    }
    .dorsal { width: 44px; height: 46px; border-radius: 5px; }
    .dorsal-topo { height: 15px; line-height: 15px; font-size: 0.7rem; }
    .dorsal-topo::before, .dorsal-topo::after { top: 5px; width: 3.5px; height: 3.5px; }
    .dorsal-topo::before { left: 4px; }
    .dorsal-topo::after { right: 4px; }
    .dorsal-dia { font-size: 1.45rem; }
    .dorsal { background-size: 0 0, 0 0, auto; }

    li.prova {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 12px;
        padding: 12px;
    }
    .miniatura { width: 64px; height: 64px; background-size: 30px; }
    /* O botão de guardar passa para baixo do texto, alinhado com ele */
    form.favorito,
    li.prova > a.favorito-btn { grid-column: 2; justify-self: start; }
    .favorito-btn { height: 34px; }
}

@media (max-width: 700px) {
    .prova-detalhe { grid-template-columns: 1fr; gap: 16px; padding: 14px; }
    .prova-cartaz { max-width: 320px; }
    .prova-cartaz.sem-imagem { aspect-ratio: auto; place-items: start; background: none; }
    .prova-cabeca h1 { font-size: 1.9rem; }
    .prova-seccao { padding: 14px; }
    .tabela-premios { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
    html.js li.prova { opacity: 1; transform: none; transition: none; }
}

/* Ranking dos prémios (administradores) */
.tabela-ranking { background: var(--branco); border: 1px solid var(--linha); border-radius: 14px; border-collapse: separate; border-spacing: 0; }
.tabela-ranking th:nth-child(n+4) { text-align: right; }
.tabela-ranking td { vertical-align: middle; }
.tabela-ranking a,
.ranking-sem-valores a { color: var(--asfalto); font-weight: 600; text-decoration: none; }
.tabela-ranking a:hover,
.ranking-sem-valores a:hover { color: var(--sinal); text-decoration: underline; }
.ranking-posicao { font-family: var(--letra-estreita); font-weight: 700; font-size: 1.1rem; color: var(--cinza); }
.ranking-info { display: block; color: var(--cinza); font-size: 0.8rem; }
.ranking-data { white-space: nowrap; }
.ranking-total { font-size: 1.15rem; white-space: nowrap; }
.ranking-data-movel { display: none; }
/* Telemóvel: a data passa para baixo do nome e os valores encolhem, para a tabela caber. */
@media (max-width: 640px) {
    .tabela-ranking th.ranking-data, .tabela-ranking td.ranking-data { display: none; }
    .ranking-data-movel { display: inline; }
    .tabela-ranking th, .tabela-ranking td { padding-left: 6px; padding-right: 6px; }
    .tabela-ranking .tabela-valor { white-space: nowrap; font-size: 0.95rem; }
    .tabela-ranking .ranking-total { font-size: 1rem; }
    .tabela-ranking td:first-child, .tabela-ranking th:first-child { padding-right: 2px; }
    .tabela-ranking td:nth-child(2) { overflow-wrap: anywhere; }
}
.ranking-sem-valores { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 8px; }
.ranking-sem-valores .ranking-info { display: inline; margin-left: 6px; }
.ranking-sem-valores a.ranking-regulamento { margin-left: 8px; color: var(--sinal); font-size: 0.85rem; }

/* Radar dos organizadores (administradores) */
.radar-ver { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.radar-ver a {
    padding: 5px 12px;
    border: 1px solid var(--linha);
    border-radius: 999px;
    color: var(--asfalto);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}
.radar-ver a:hover { border-color: var(--sinal); color: var(--sinal); }
.radar-ver a[aria-current="page"] { background: var(--sinal); border-color: var(--sinal); color: var(--branco); }
.tabela-radar th:nth-child(2), .tabela-radar th:nth-child(3) { text-align: right; }
.tabela-radar th:nth-child(4) { text-align: left; }
.tabela-radar td:first-child { overflow-wrap: anywhere; }
.tabela-radar .etiqueta-admin, .tabela-radar .etiqueta-premios { white-space: nowrap; }
.tabela-radar a.radar-exemplo { color: var(--cinza); font-weight: 400; }
.tabela-radar tr.radar-candidato td { background: var(--trail-suave); }
.radar-fontes { max-width: 260px; }
.radar-fontes-movel { display: none; }
@media (max-width: 640px) {
    .tabela-radar .radar-fontes { display: none; }
    .tabela-radar .radar-fontes-movel { display: block; }
    .tabela-radar th, .tabela-radar td { padding-left: 6px; padding-right: 6px; }
}

/* Painel "Filtros": abre-se e fecha-se como um elevador, por cima da lista (não a empurra),
   e a barra fixa fica só com o botão. Sem JavaScript o painel fica sempre aberto. */
.botao-filtros {
    display: none;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--linha-forte);
    border-radius: 10px;
    background: var(--branco);
    color: var(--asfalto);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.js .botao-filtros { display: inline-flex; }
.botao-filtros:hover { border-color: var(--sinal); }
.botao-filtros:focus-visible { outline: 2px solid var(--sinal); outline-offset: 2px; }
.botao-filtros .seta { transition: transform 0.25s ease; }
.botao-filtros[aria-expanded="true"] .seta { transform: rotate(180deg); }
.contagem-filtros {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--sinal);
    color: var(--branco);
    font-size: 0.8rem;
}
.painel-interior { min-height: 0; overflow: hidden; padding: 10px 16px 14px; }
.js .painel-filtros {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 9;
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    background: var(--papel);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    transition: grid-template-rows 0.3s ease, visibility 0.3s;
}
.js .painel-filtros.aberto { grid-template-rows: 1fr; visibility: visible; }
