/* Philnance — Ano (#/ano?a=): estilos só desta vista (ecrãs 12 e 18 do design). Componentes partilhados no
   styles.css (.card, .seg, .lista/.linha, .cat-ico, .grelha + .span-N, .valor). */

/* cabeçalho: "Ano" + "‹ 2026 ›" no telemóvel; "Ano 2026" + texto + ‹ › e Dia a dia/Tudo no computador */
.cab-ano .cabecalho-aux, .cab-ano .cabecalho-sub {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.cab-ano .cabecalho-linha { align-items: center; }
.ano-nav { display: flex; align-items: center; gap: 2px; }
.ano-nav-b { border-color: transparent; color: var(--ink2); }
.ano-nav-b:disabled { color: var(--line2); border-color: transparent; }
.ano-nav-ano { min-width: 48px; text-align: center; font: 400 20px/1 var(--serif); font-variant-numeric: tabular-nums; }

/* Dia a dia / Tudo + a nota de quem distorcia as médias */
.ano-modo { display: flex; flex-direction: column; gap: 8px; }
.ano-nota { padding: 0 4px; font: 400 12.5px/1.4 var(--sans); color: var(--ink3); text-wrap: pretty; }

/* telemóvel: o quadro "Ficou · abr a set" */
.ano-quadro { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--r-hero); box-shadow: 0 1px 2px var(--shade); }
/* meses de onde se tirou o extraordinário (dia a dia) */
.ms.ano-sem { margin-left: 5px; font-size: 14px; color: var(--tan); vertical-align: -2px; }
.ano-legenda-sem { display: flex; align-items: flex-start; gap: 6px; }
.ano-legenda-sem .ms.ano-sem { margin: 1px 0 0; }

.ano-quadro-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ano-quadro-rot { font: 500 13px var(--sans); color: var(--ink2); }
.ano-badge {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 14px; flex: none;
  background: var(--green-tint); color: var(--green); font: 600 12.5px var(--sans); white-space: nowrap;
}
.ano-badge.tan { background: var(--tan-tint); color: var(--tan); }
.ano-quadro-v { font: 300 44px/.95 var(--serif); letter-spacing: -.04em; }
.ano-quadro-tres {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 12px; border-top: 1px solid var(--line);
  line-height: 1.35;
}
.ano-quadro-tres dt { font: 400 12px var(--sans); color: var(--ink2); }
.ano-quadro-tres dd { font: 500 14px var(--sans); overflow-wrap: anywhere; }

/* telemóvel: mês a mês (saldo · acumulado) */
.ano-lista { display: flex; flex-direction: column; gap: 10px; }
.ano-lista .sec-cab { margin-top: 4px; }
.ano-lista .sec-cab h2 { font-size: 24px; }
.ano-meses { padding: 0 16px; border-radius: 22px; }
.ano-mes {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(64px, auto) minmax(84px, auto) 18px; align-items: center; gap: 6px;
  min-height: 50px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.ano-mes:last-child { border-bottom: 0; }
.ano-mes:hover .ano-mes-n { color: var(--accent); }
.ano-mes-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ano-mes-sub { display: block; font-size: 12px; color: var(--ink3); white-space: normal; }
.ano-mes-s, .ano-mes-a { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ano-mes-s.pos { color: var(--green); }
.ano-mes-s.neg { color: var(--tan); }
.ano-mes-a { font: 500 15px var(--sans); font-variant-numeric: tabular-nums; }
.ano-mes-c { font-size: 18px; color: var(--ink3); }
.ano-mes.em-curso, .ano-mes.parcial { color: var(--ink3); }
.ano-mes.em-curso .ano-mes-n { white-space: normal; }
.ano-mes.em-curso .ano-mes-a, .ano-mes.parcial .ano-mes-a { font-weight: 400; }

/* blocos comuns (cartões com título em Geist 600 15px, como no ecrã 18) */
.ano-grelha > .card, .ano-grelha > div > .card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.ano-grelha .card-cab { flex-wrap: wrap; row-gap: 2px; }
.ano-vazio-p { font: 400 13px/1.45 var(--sans); color: var(--ink2); }

/* extraordinário do ano */
.ano-extra-l { min-height: 54px; gap: 12px; }
.ano-extra-l .linha-txt { font: 500 14px/1.3 var(--sans); }
.ano-extra-l .linha-sub { font-weight: 400; font-size: 12px; }
.ano-extra-l .valor, .ano-extra-tot .valor { font: 500 14px var(--sans); font-variant-numeric: tabular-nums; }
.ano-extra-tot { display: flex; align-items: center; gap: 12px; padding-top: 4px; font: 600 13.5px var(--sans); }
.ano-extra-tot .linha-sub { font-weight: 400; }
.ano-extra-tot .valor:not(.pos) { color: var(--ink); }

/* categorias do ano */
.ano-cat-lista { list-style: none; display: flex; flex-direction: column; }
.ano-cat {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line);
}
.ano-cat-meio { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ano-cat-l1 { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 8px; font: 400 13.5px var(--sans); }
.ano-cat-n { flex: none; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ano-cat-p { flex: none; font-size: 11.5px; color: var(--ink3); white-space: nowrap; }
.ano-cat-barra { display: block; height: 5px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.ano-cat-barra > i { display: block; height: 100%; border-radius: 3px; background: var(--c, var(--accent)); }
.ano-cat-v { min-width: 64px; text-align: right; font: 500 13.5px var(--sans); font-variant-numeric: tabular-nums; }
.ano-cats-mais { align-self: flex-start; }
.ano-fv { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.ano-fv-barra { display: block; height: 8px; border-radius: 4px; background: var(--tan); overflow: hidden; }
.ano-fv-barra > i { display: block; height: 100%; background: var(--accent); border-right: 2px solid var(--card); }
.ano-fv-txt { font: 400 12.5px/1.4 var(--sans); color: var(--ink2); }

/* onde mais se gastou */
.ano-top { list-style: none; }
.ano-top li {
  display: flex; align-items: center; gap: 8px; min-height: 40px; border-bottom: 1px solid var(--line);
  font: 400 14px var(--sans); break-inside: avoid;
}
.ano-top-i { width: 22px; flex: none; color: var(--ink3); font-variant-numeric: tabular-nums; }
.ano-top-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ano-top-v { flex: none; }

/* poupança */
.ano-poup-v { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ano-poup-saldo { font: 400 26px/1 var(--serif); letter-spacing: -.01em; }
.ano-poup-var { font: 500 12.5px var(--sans); color: var(--green); }
.ano-poup-var.neg { color: var(--tan); }
.ano-pp { display: flex; gap: 8px; height: 110px; }
.ano-pp-b { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; }
.ano-pp-t { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.ano-pp-t > i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: color-mix(in oklch, var(--green) 40%, var(--card)); }
.ano-pp-b.ultimo .ano-pp-t > i { background: var(--green); }
.ano-pp-b.partida .ano-pp-t > i { background: none; border: 1.5px dashed var(--line2); border-bottom: 0; }
.ano-pp-b small { font: 400 11px var(--sans); color: var(--ink3); }

/* ---------- computador (ecrã 18) ---------- */
@media (min-width: 1024px) {
  .cab-ano .cabecalho-aux, .cab-ano .cabecalho-sub { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .cab-ano .cabecalho-aux { font-size: inherit; color: inherit; letter-spacing: inherit; }
  .cab-ano .cabecalho-linha { align-items: flex-end; }
  .ano-nav { gap: 8px; }
  .ano-nav-b { border-color: var(--line2); color: var(--ink); }
  .ano-nav-b:disabled { border-color: var(--line2); }
  .ano-modo-cab .seg { height: 40px; min-width: 176px; }
  .ano-modo-cab .seg > button { padding: 0 14px; }

  .ano-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
  .ano-kpi {
    display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 14px 16px; border-radius: 20px;
    background: var(--card); border: 1px solid var(--line);
  }
  .ano-kpi-r { font: 500 12.5px var(--sans); opacity: .85; }
  .ano-kpi-v { font: 400 24px/1 var(--serif); letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ano-kpi.pos .ano-kpi-v { color: var(--green); }
  .ano-kpi.hero { background: var(--hero-bg); color: var(--hero-ink); border-color: transparent; }
  .ano-kpi.verde { background: var(--green-tint); border-color: transparent; }
  .ano-kpi.tan { background: var(--tan-tint); border-color: transparent; }

  /* gráfico mês a mês: entrou (verde) e saiu (destaque); o em curso às riscas */
  .ano-legenda i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 2px; vertical-align: -1px; }
  .ano-legenda i.ent { background: var(--green); }
  .ano-legenda i.sai { background: var(--accent); }
  .ano-graf { display: grid; gap: 6px; padding-top: 6px; }
  .ano-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; cursor: default; }
  .ano-col-rot { font: 600 11.5px var(--sans); color: var(--green); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .ano-col-rot.neg { color: var(--tan); }
  .ano-col-rot.em-curso { color: var(--ink3); }
  .ano-col-barras { display: flex; align-items: flex-end; justify-content: center; gap: 4px; width: 100%; height: 150px; }
  .ano-col-barras > i { display: block; width: 18px; max-width: 40%; min-height: 2px; border-radius: 4px 4px 0 0; }
  .ano-col-barras > .ent { background: var(--green); }
  .ano-col-barras > .sai { background: var(--accent); }
  .ano-col-barras > .sai.parcial { background: repeating-linear-gradient(45deg, var(--accent) 0 3px, var(--accent-tint) 3px 7px); }
  .ano-col-m { font: 500 12px var(--sans); color: var(--ink2); }

  /* tabela dos períodos */
  .ano-tab-wrap { overflow-x: auto; }
  .ano-tab { width: 100%; border-collapse: collapse; font: 400 13px var(--sans); font-variant-numeric: tabular-nums; }
  /* (o styles.css ainda tem regras antigas para th/td: aqui anulam-se) */
  .ano-tab th, .ano-tab td { position: static; background: none; vertical-align: middle; border-top: 0; letter-spacing: 0; text-transform: none; }
  .ano-tab tbody tr:hover { background: none; }
  .ano-tab thead th {
    padding: 0 0 6px 8px; border-bottom: 1px solid var(--line2); text-align: right;
    font: 500 11px var(--sans); color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  }
  .ano-tab thead th:first-child { text-align: left; padding-left: 0; }
  .ano-tab tbody th, .ano-tab td { height: 40px; padding: 0 0 0 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
  .ano-tab tbody th { padding-left: 0; text-align: left; font: 400 13px var(--sans); color: inherit; }
  .ano-tab tbody th a { color: inherit; text-decoration: none; }
  .ano-tab tbody tr { cursor: pointer; }
  .ano-tab tbody tr:hover th a { color: var(--accent); }
  .ano-tab td.pos { color: var(--green); }
  .ano-tab td.neg { color: var(--tan); }
  .ano-tab td.acum, .ano-tab td:last-child { font-weight: 600; }
  .ano-tab tr.em-curso, .ano-tab tr.parcial { color: var(--ink3); }

  .ano-top { columns: 2; column-gap: 24px; }
  .ano-top li { min-height: 36px; font-size: 13.5px; }
  .ano-cat { min-height: 46px; }
  .ano-cat-l1 { font-size: 13px; }
  .ano-cat-v { font-size: 13px; }
}

@media (max-width: 380px) {
  .ano-quadro-v { font-size: 38px; }
  .ano-mes { font-size: 14px; gap: 4px; grid-template-columns: minmax(0, 1fr) minmax(56px, auto) minmax(72px, auto) 16px; }
  .ano-mes-a { font-size: 14px; }
  .ano-nav-ano { min-width: 40px; font-size: 18px; }
  .ano-quadro-tres dd { font-size: 13px; }
}
