/* Vista do mês e detalhe do dia. Telemóvel: versão B; computador (≥ 900 px): versão A. */

/* ---------- Disposição ---------- */

.mes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "topo" "resumo" "grelha" "notas";
}
.mes > .topo { grid-area: topo; }
.mes .calendario { grid-area: grelha; }
.mes-lado { display: contents; }
.mes .resumo { grid-area: resumo; margin-bottom: 14px; }
.mes .notas-mes-bloco { grid-area: notas; }
.mes .resumo-ano { display: none; }

/* ---------- Grelha ---------- */

.semana, .grelha { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
/* Ecrãs muito estreitos (< 360 px): sete quadrados de 44 px não cabem; os dias ficam mais altos que largos. */
@media (max-width: 359px) {
  .semana, .grelha { gap: 3px; }
  .grelha .dia { aspect-ratio: auto; }
}
.semana { margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); text-align: center; }

.dia {
  /* --borda: contorno do tipo (por dentro); hoje troca-o por 2 px em --accent; o foco junta-lhe um halo. */
  --borda: inset 0 0 0 1px var(--line);
  position: relative;
  aspect-ratio: 1;
  min-height: 44px;
  display: grid; place-items: center;
  border-radius: var(--r-dia-compacto);
  background: var(--card);
  box-shadow: var(--borda);
  color: var(--ink);
  font-size: 15px; font-weight: 600;
  transition: transform var(--t-toque) var(--ease-out);
}
.dia:active { transform: scale(.96); }
.dia .rotulo { display: none; }
/* Telemóvel: a letra do tipo por baixo do número (F, L, TL, Fer, Fa), na cor do tipo. */
.dia .marca {
  position: absolute; left: 0; right: 0; bottom: 4px;
  font-size: 11px; font-weight: 600; line-height: 1; text-align: center; letter-spacing: -.01em;
}
.dia:has(.marca) .n { margin-bottom: 9px; }
.dia .ponto {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

.dia.fer { background: var(--fer-bg); color: var(--fer-ink); --borda: 0 0 #0000; }
.dia.lic { background: var(--lic-bg); color: var(--lic-ink); --borda: 0 0 #0000; }
.dia.hol { background: var(--hol-bg); color: var(--hol-ink); --borda: 0 0 #0000; }
.dia.we { background: var(--we-bg); color: var(--we-ink); --borda: 0 0 #0000; }
.dia.fa, .legenda .fa, .tipo.fa {
  background: repeating-linear-gradient(135deg, var(--fa-risca) 0 4px, transparent 4px 8px), var(--fa-bg);
  color: var(--fa-ink);
}
.dia.fa { --borda: 0 0 #0000; }
.dia.tl, .legenda .tl {
  background: repeating-linear-gradient(135deg, var(--tl-risca) 0 4px, var(--card) 4px 8px);
  color: var(--ink);
}
.dia.fora { background: transparent; color: var(--ink-2); font-weight: 500; }
/* Só os dias úteis simples esbatem no futuro (os outros cairiam abaixo de 3:1). */
.dia.trabalho.futuro { opacity: .62; }
.dia.hoje { --borda: inset 0 0 0 2px var(--accent); opacity: 1; }
.dia.hoje .n { color: var(--accent); }
/* Foco: anel por fora com halo, para não se confundir com o contorno de hoje (por dentro). */
.dia:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
  box-shadow: var(--borda), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
}

.legenda {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px;
  font-size: 13px; color: var(--ink-2);
}
.legenda i {
  display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 6px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.legenda .trabalho { background: var(--card); }
.legenda .fer { background: var(--fer-bg); color: var(--fer-ink); }
.legenda .lic { background: var(--lic-bg); color: var(--lic-ink); }
.legenda .hol { background: var(--hol-bg); color: var(--hol-ink); }
.legenda .we { background: var(--we-bg); }
/* Telemóvel: a legenda do mês repete a letra que aparece nos dias. */
.mes .legenda li { display: inline-flex; align-items: center; }
.mes .legenda i {
  width: auto; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 5px; vertical-align: 0; flex: none;
  font: normal 600 11px/18px var(--letra); text-align: center;
}

/* ---------- Resumo ---------- */

.resumo, .resumo-ano { border-radius: var(--r-painel); padding: 16px; }
.numeros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.numero b { display: block; font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.numero span { display: block; font-size: 13px; color: var(--ink-2); line-height: 1.35; margin-top: 2px; }
.subsidio {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.subsidio span { font-size: 13px; color: var(--ink-2); }
.subsidio b { font-size: 22px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.diferenca, .na-licenca {
  margin-top: 10px; font-size: 14px; color: var(--ink-2);
  background: var(--card-2); border-radius: 10px; padding: 8px 10px;
}
.diferenca strong { color: var(--ink); }
.na-licenca { margin-top: 6px; }
.resumo-ano h2 { font-size: 17px; font-weight: 650; margin-bottom: 8px; }

.botao-sec {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; margin-top: 12px; border-radius: 999px;
  background: var(--card); color: var(--accent); font-weight: 600; font-size: 15px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--t-toque) var(--ease-out);
}
.botao-sec:active { transform: scale(.98); }

/* ---------- Notas ---------- */

.notas-mes-bloco h2 { font-size: 17px; font-weight: 650; margin: 22px 2px 10px; }
.notas-mes, .dia-notas .lista { display: grid; gap: 8px; }
.nota {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px;
  width: 100%; text-align: left;
  background: var(--card); border-radius: var(--r-cartao); padding: 12px 14px;
  transition: transform var(--t-toque) var(--ease-out);
}
.nota:active { transform: scale(.98); }
.nota-quando { font-size: 13px; color: var(--ink-2); text-align: center; line-height: 1.2; }
.nota-quando b { display: block; font-size: 20px; color: var(--ink); }
.nota-corpo { display: grid; gap: 2px; min-width: 0; }
.nota-tipo { font-size: 13px; font-weight: 600; color: var(--accent); }
.nota-texto {
  font-size: 15px; overflow-wrap: anywhere; white-space: pre-line;
  /* Nos cartões, até 3 linhas; o texto completo está no editor. */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.nota-meta { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.vazio-texto { font-size: 15px; color: var(--ink-2); }
.notas-mes .ver-todas { width: 100%; margin-top: 0; }

/* ---------- Detalhe do dia ---------- */

.dia-estado { color: var(--ink-2); font-size: 15px; margin-bottom: 12px; }
.tipos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tipo {
  min-height: 48px; border-radius: 12px; padding: 0 8px;
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 15px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--t-toque) var(--ease-out);
}
.tipo:active { transform: scale(.96); }
.tipo.fer { background: var(--fer-bg); color: var(--fer-ink); box-shadow: none; }
.tipo.lic { background: var(--lic-bg); color: var(--lic-ink); box-shadow: none; }
.tipo.hol { background: var(--hol-bg); color: var(--hol-ink); box-shadow: none; }
.tipo.fa { box-shadow: none; }
.tipo[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
/* Marca de escolhido no canto (forma, além da cor); o texto alternativo vazio deixa o nome do botão igual. */
.tipo { position: relative; white-space: nowrap; }
.tipo[aria-pressed="true"]::before { content: "✓" / ""; position: absolute; top: 2px; left: 6px; font-size: 11px; color: var(--accent); }

.repor-linha { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.repor-ajuda { font-size: 13px; color: var(--ink-2); }

.aplicar, .dia-notas { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.aplicar h3, .dia-notas h3 { font-size: 16px; font-weight: 650; margin-bottom: 4px; }
.dia-notas h3 { margin-bottom: 10px; }
.aplicar .ajuda { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.aplicar-linha { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.aplicar-linha .botao-sec { margin-top: 0; }
.aplicar-campo { display: grid; gap: 4px; flex: 1 1 160px; font-size: 13px; font-weight: 600; }
.aplicar-campo input {
  font-size: 16px; min-height: 44px; padding: 0 12px; width: 100%;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card);
}
.aplicar-estado { font-size: 14px; margin-top: 8px; color: var(--ink); }
.aplicar-estado:empty { display: none; }
.aplicar-estado.erro { color: var(--erro); }
.dia-notas .nova-nota { width: 100%; }

.recibo-form .campo input[type="file"] { min-height: 44px; padding: 10px 0; border: 0; background: none; font-size: 15px; }
.anexos-lista { margin: 4px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }

/* ---------- Computador: versão A ---------- */

@media (min-width: 900px) {
  .mes {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "topo lado" "grelha lado";
    grid-template-rows: auto 1fr;
    column-gap: 24px;
    align-items: start;
  }
  .mes-lado { display: flex; flex-direction: column; gap: 14px; grid-area: lado; }
  .mes .resumo { margin-bottom: 0; }
  .mes .resumo-ano { display: block; }
  .notas-mes-bloco h2 { margin: 8px 2px 10px; }
  .semana, .grelha { gap: 6px; }
  .dia {
    aspect-ratio: auto; min-height: 84px;
    display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
    padding: 10px 12px; border-radius: var(--r-dia);
    font-size: 18px; text-align: left;
  }
  .dia .rotulo { display: block; font-size: 12px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
  /* No computador cada dia diz o nome do tipo: sem letra, e a legenda volta aos quadradinhos. */
  .dia .marca { display: none; }
  .dia:has(.marca) .n { margin-bottom: 0; }
  .mes .legenda i { width: 12px; min-width: 0; height: 12px; padding: 0; border-radius: 4px; vertical-align: -1px; font-size: 0; }
  .dia .ponto { top: 7px; right: 7px; }
}

@media (hover: hover) and (pointer: fine) {
  .dia.trabalho:hover, .dia.fora:hover { background: var(--card); }
  .dia.trabalho:not(.hoje):hover, .dia.fora:not(.hoje):hover { --borda: inset 0 0 0 1px var(--accent); }
  .dia:not(.trabalho):not(.fora):hover { filter: brightness(.97); }
  .nota:hover, .botao-sec:hover { box-shadow: inset 0 0 0 1px var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  .dia:active, .nota:active, .tipo:active, .botao-sec:active { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .resumo, .resumo-ano { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* No resumo, "Registar recibo" é uma ligação discreta (não compete com os números). */
.resumo .botao-sec { margin-top: 4px; margin-bottom: -10px; padding: 0 2px; background: none; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .resumo .botao-sec:hover { box-shadow: none; text-decoration: underline; }
}

.dia-aviso { color: var(--erro); background: var(--card-2); border-radius: 12px; padding: 8px 12px; font-size: 14px; margin-bottom: 12px; }
