/* Cores do Manual de Normas Gráficas da Herdade do Vidigal:
   Azul Vidigal #2A588D (primária) · Dourado das Colinas #C9A15D ·
   Terracota da Vinha #93503F · Verde-Oliveira #707C4C · Branco-Cal #F7F3EA */
:root {
  --bg: #F7F3EA;
  --surface: #FFFFFF;
  --surface-2: #F0EBDF;
  --border: #E4DDCD;
  --ink: #1C2B3C;
  --ink-muted: #5A6472;
  --ink-faint: #7B8391;
  --accent: #2A588D;
  --accent-ink: #FFFFFF;
  --accent-soft: #D4DEE8;
  --gold: #C9A15D;
  --gold-soft: #F4E9D3;
  --ok: #56613A;
  --warn: #7A5418;
  --danger: #93503F;
  --lateral: #2A588D;
  --lateral-item: #1F4670;
  --shadow: 0 1px 2px rgba(28,43,60,0.05), 0 6px 18px rgba(28,43,60,0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lato', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; margin: 0; }
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.6rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .marca { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.topbar .marca img { height: 44px; width: 44px; display: block; }
.marca-nome { font-family: 'Playfair Display', Georgia, serif; font-size: 1.45rem; font-weight: 600; color: #2A588D; white-space: nowrap; letter-spacing: -0.01em; }
.marca-sub { font-family: 'Lato', system-ui, sans-serif; font-size: 0.95rem; font-weight: 500; color: var(--ink-muted); letter-spacing: 0; }
.topbar nav { display: flex; gap: 1.2rem; align-items: center; font-size: 0.92rem; }
.topbar nav > a { text-decoration: none; color: var(--ink); font-weight: 500; }
.topbar nav > a.ativo, .menu-topo > summary.ativo { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.menu-topo { position: relative; }
.menu-topo > summary {
  list-style: none; cursor: pointer; font-weight: 500; color: var(--ink); padding: 0.3rem 0; user-select: none;
}
.menu-topo > summary::-webkit-details-marker { display: none; }
.menu-topo > summary::after { content: ""; display: inline-block; margin-left: 0.35rem; border: 4px solid transparent; border-top-color: currentColor; vertical-align: -1px; }
.menu-topo[open] > summary::after { border-top-color: transparent; border-bottom-color: currentColor; vertical-align: 3px; }
.menu-topo .submenu {
  position: absolute; top: calc(100% + 0.5rem); left: -0.8rem; z-index: 40; min-width: 210px;
  display: flex; flex-direction: column; padding: 0.4rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.menu-topo .submenu a { padding: 0.5rem 0.7rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.menu-topo .submenu a:hover { background: var(--surface-2); color: var(--accent); }
.titulo-folha { margin: 0.6rem 0 0.1rem; padding: 0 0.9rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.topbar .user { color: var(--ink-muted); font-size: 0.88rem; }

main.conteudo { max-width: 1180px; margin: 0 auto; padding: 2rem 1.6rem 4rem; }

.cabecalho-pagina { margin-bottom: 1.4rem; }
.cabecalho-pagina p { color: var(--ink-muted); margin: 0.2rem 0 0; max-width: 60ch; }
.cabecalho-com-acao { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap; }

.painel-filtros {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.2rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.4rem;
}
.filtros-grelha {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem;
  align-items: end;
}
.campo-filtro label {
  display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-faint); margin-bottom: 0.3rem;
}
.campo-filtro select, .campo-filtro input {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 0.9rem;
}
.acoes-filtro { display: flex; gap: 0.6rem; }
.botao {
  border: none; border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.88rem; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
}
.botao.secundario { background: var(--surface-2); color: var(--ink); }

.resumo-totais { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cartao-total {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.8rem 1.1rem; min-width: 170px;
}
.cartao-total .rotulo { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.cartao-total .valor { font-family: 'Playfair Display', Georgia, serif; font-size: 1.25rem; margin-top: 0.15rem; }
.cartao-total.alerta .valor { color: var(--warn); }

.tabela-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
table.documentos { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 760px; }
table.documentos th, table.documentos td { text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); }
table.documentos th { background: var(--surface-2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); font-weight: 500; }
table.documentos td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.documentos tr:last-child td { border-bottom: none; }
table.documentos tr:hover td { background: var(--surface-2); }
table.documentos th a { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; }
table.documentos th a:hover { color: var(--ink); text-decoration: underline; }

.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.76rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-weight: 500; }
.pill.pago, .pill.ativo, .pill.cruzado { background: var(--accent-soft); color: var(--ok); }
.pill.nao_pago, .pill.nao_cruzado, .pill.em_falta_na_bd { background: var(--gold-soft); color: var(--warn); }
.pill.parcial, .pill.inativo, .pill.ignorado, .pill.em_falta_no_efatura { background: #EEEAE0; color: var(--ink-muted); }
.pill.ocr { background: #FBEFE0; color: var(--warn); border: 1px dashed var(--warn); margin-left: 0.35rem; }
.pill.outra-entidade { background: #F7E4E0; color: var(--danger); border: 1px solid var(--danger); margin-left: 0.35rem; }

.valor-credito { color: var(--ok); }
.valor-debito { color: var(--ink); }

.vazio { padding: 2.4rem; text-align: center; color: var(--ink-faint); }

/* Categorias */
.swatch {
  display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%;
  margin-right: 0.5rem; border: 1px solid rgba(0,0,0,0.08); vertical-align: middle;
}
table.categorias td.linha-subcategoria { padding-left: 2.2rem; color: var(--ink-muted); }
td.acoes-col { text-align: right; white-space: nowrap; }
.acoes-linha { display: inline-flex; align-items: center; gap: 0.8rem; }
.acoes-linha form { margin: 0; }
.botao-link {
  background: none; border: none; padding: 0; margin: 0; color: var(--accent);
  font-size: inherit; font-family: inherit; cursor: pointer; text-decoration: underline;
}
.campo-caixa { display: flex; align-items: center; }
.campo-caixa input[type="checkbox"] { width: auto; margin-right: 0.4rem; }

/* Associação manual de pagamento (comprovativo ↔ fatura, movimento ↔ fatura) */
.lista-selecao { list-style: none; margin: 0; padding: 0.4rem 0; max-height: 420px; overflow-y: auto; }
.lista-selecao li { border-bottom: 1px solid var(--border); }
.lista-selecao li:last-child { border-bottom: none; }
.lista-selecao label { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.2rem; margin: 0; cursor: pointer; font-size: 0.9rem; }
.lista-selecao input[type="checkbox"] { width: auto; }
.sugestao-fornecedor { background: var(--accent-soft); color: var(--ok); border-radius: 8px; padding: 0.6rem 0.9rem; font-size: 0.88rem; margin-bottom: 1rem; }

/* Estatísticas */
.grelha-tabelas {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.4rem;
}
.barra-evolucao { display: flex; flex-direction: column; gap: 0.55rem; }
.linha-barra {
  display: grid; grid-template-columns: 42px 1fr 90px; align-items: center; gap: 0.8rem;
}
.linha-barra .rotulo-barra { font-size: 0.8rem; color: var(--ink-muted); }
.linha-barra .trilho { background: var(--surface-2); border-radius: 6px; height: 10px; overflow: hidden; }
.linha-barra .preenchimento { background: var(--accent); height: 100%; border-radius: 6px; }
.linha-barra .valor-barra { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.84rem; color: var(--ink-muted); }

.form-login {
  max-width: 340px; margin: 4rem auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem; box-shadow: var(--shadow);
}
.form-login .logo-login { display: block; height: 44px; width: auto; margin: 0 auto 1.6rem; }
.form-login h1 { font-size: 1.4rem; margin-bottom: 1.2rem; text-align: center; }
.form-login label { display: block; font-size: 0.8rem; color: var(--ink-muted); margin: 0.8rem 0 0.3rem; }
.form-login input { width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; }
.form-login button { margin-top: 1.2rem; width: 100%; }

/* Importar por foto — botão grande que abre logo a câmara traseira */
.botao-camara {
  display: flex; align-items: center; justify-content: center; width: 100%;
  padding: 0.9rem 1rem; font-size: 1rem; margin-bottom: 0.4rem; text-align: center;
}
.entrada-camara { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.estado-camara { font-size: 0.88rem; color: var(--ink-muted); margin: 0 0 1rem; min-height: 1.2em; }

/* Telemóvel (e webapp instalada no ecrã principal) */
@media (max-width: 720px) {
  .topbar {
    flex-direction: column; align-items: stretch; gap: 0.6rem;
    padding: calc(0.7rem + env(safe-area-inset-top)) 16px 0.6rem;
  }
  .topbar .marca img { height: 34px; width: 34px; }
  .marca-nome { font-size: 1.2rem; }
  .marca-sub { font-size: 0.82rem; }
  .topbar nav {
    gap: 1rem; overflow-x: auto; white-space: nowrap; padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  main.conteudo { padding: 1.2rem 16px calc(3rem + env(safe-area-inset-bottom)); }
  .painel-filtros { padding: 1rem; }
  /* 16px evita que o iPhone faça zoom ao tocar num campo */
  .campo-filtro select, .campo-filtro input, .form-login input { font-size: 16px; }
  .botao { padding: 0.65rem 1rem; font-size: 0.95rem; }
  .form-login { margin: 2rem auto; padding: 1.4rem; }
  .grelha-tabelas { grid-template-columns: 1fr; }
}

/* Documento: ver e corrigir */
.voltar { margin: 0 0 0.4rem; font-size: 0.9rem; }
.etiquetas { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.etiquetas .pill { margin-left: 0; }
.documento-grelha { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.4rem; align-items: start; }
.pre-visualizacao img { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--surface-2); }
.pre-visualizacao iframe { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: var(--surface-2); }
.ligacoes-ficheiro { font-size: 0.88rem; margin: 0.7rem 0 0; color: var(--ink-muted); }
.grelha-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.9rem; }
.erro-campo, .erro-formulario { color: var(--danger); font-size: 0.85rem; margin: 0.3rem 0 0; }
.erro-formulario { margin: 0 0 0.8rem; }
.aviso-formulario { background: var(--gold-soft); color: var(--warn); border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.88rem; margin: 0 0 0.9rem; }
.titulo-seccao { font-size: 1rem; margin-bottom: 0.5rem; }
.lista-simples { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; }
.zona-apagar { margin: 0.4rem 0 2rem; }
.botao.perigo { background: #F7E4E0; color: var(--danger); }
.faixa-importado {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap;
  background: var(--accent-soft); color: var(--ok); border-radius: 12px; padding: 0.8rem 1rem; margin-bottom: 1.2rem;
}
.faixa-importado p { margin: 0; }
.pill.efatura { background: var(--accent-soft); color: var(--ok); }
a.botao { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 900px) {
  .documento-grelha { grid-template-columns: 1fr; }
  .pre-visualizacao img { max-height: 42vh; object-fit: contain; }
  .pre-visualizacao iframe { height: 60vh; }
}

/* Lista de documentos: linhas clicáveis, coluna e-Fatura, cartões no telemóvel */
table.documentos tr.linha-clicavel { cursor: pointer; }
table.documentos td a { text-decoration: none; }
table.documentos th.centro, table.documentos td.centro { text-align: center; }
.check-efatura {
  display: inline-flex; align-items: center; justify-content: center; width: 1.45rem; height: 1.45rem;
  border-radius: 50%; background: var(--ok); color: #fff; font-weight: 700; font-size: 0.85rem; line-height: 1;
}
.so-telemovel { display: none; }
.cartoes-documentos { list-style: none; margin: 0; padding: 0; flex-direction: column; gap: 0.6rem; }
.cartao-documento {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 0.85rem 1rem; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.cartao-documento:active { background: var(--surface-2); }
.cartao-linha { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; }
.cartao-fornecedor { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cartao-valor { font-family: 'Playfair Display', Georgia, serif; font-size: 1.1rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cartao-secundaria { color: var(--ink-muted); font-size: 0.86rem; margin-top: 0.15rem; }
.cartao-documento .etiquetas { margin-top: 0.45rem; }
@media (max-width: 720px) {
  .so-computador { display: none; }
  .so-telemovel { display: flex; }
}

/* Ecrã de espera ("A ler a fatura…") enquanto a foto é enviada */
.espera {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(245, 247, 241, 0.94);
}
.espera[hidden] { display: none; }
.espera-caixa { text-align: center; padding: 1.5rem; }
.roda {
  width: 46px; height: 46px; margin: 0 auto 0.9rem; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: rodar 0.9s linear infinite;
}
@keyframes rodar { to { transform: rotate(360deg); } }
.espera-texto { margin: 0; font-size: 1.02rem; }

/* Telemóvel como uma app: barra de separadores em baixo, câmara ao centro */
.barra-inferior, .form-camara-global, .alternar-filtros { display: none; }
@media (max-width: 720px) {
  .topbar {
    flex-direction: row; justify-content: center; position: sticky; top: 0; z-index: 20;
    padding: calc(0.55rem + env(safe-area-inset-top)) 16px 0.55rem;
  }
  .topbar nav { display: none; }
  .barra-inferior {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(32, 43, 32, 0.06);
  }
  .barra-inferior > a, .barra-inferior summary {
    display: flex; flex-direction: column; align-items: center; gap: 0.12rem; padding: 0.3rem 0;
    font-size: 0.68rem; color: var(--ink-muted); text-decoration: none; list-style: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent; user-select: none;
  }
  .barra-inferior summary::-webkit-details-marker { display: none; }
  .barra-inferior svg {
    width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .barra-inferior .ativo { color: var(--accent); font-weight: 600; }
  .botao-camara-central {
    justify-self: center; align-self: center; width: 60px; height: 60px; margin-top: -26px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer;
    background: var(--accent); box-shadow: 0 6px 16px rgba(62, 107, 79, 0.35); -webkit-tap-highlight-color: transparent;
  }
  .botao-camara-central svg { width: 28px; height: 28px; stroke: #fff; }
  .botao-camara-central:active { transform: scale(0.94); }
  .menu-mais { position: relative; display: flex; justify-content: center; }
  .folha-mais {
    position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 40;
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
    padding: 0.4rem 0.8rem 0.8rem; display: flex; flex-direction: column; gap: 0.2rem;
    background: var(--surface); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 32px rgba(32, 43, 32, 0.18);
  }
  .pega-folha { width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 0.2rem auto 0.4rem; flex: none; }
  .grupo-folha { border-bottom: 1px solid var(--border); }
  .grupo-folha:last-child { border-bottom: 0; }
  .barra-inferior .grupo-folha > summary {
    list-style: none; display: flex; flex-direction: row; justify-content: space-between; align-items: center; cursor: pointer; gap: 0.5rem;
    padding: 0.85rem 0.3rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted);
  }
  .grupo-folha > summary::-webkit-details-marker { display: none; }
  .grupo-folha > summary::after { content: ""; border: 5px solid transparent; border-top-color: currentColor; margin-top: 5px; }
  .grupo-folha[open] > summary::after { border-top-color: transparent; border-bottom-color: currentColor; margin-top: -5px; }
  .links-folha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.3rem; padding: 0 0 0.7rem; }
  .folha-mais a, .folha-mais button {
    display: flex; align-items: center; min-height: 48px; width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface-2); font: inherit; font-size: 0.92rem; color: var(--ink); text-align: left; text-decoration: none;
  }
  .folha-mais a:active, .folha-mais button:active { background: var(--accent-soft); }
  .folha-mais form { grid-column: 1 / -1; margin: 0; }
  main.conteudo { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
  .cabecalho-pagina h1 { font-size: 1.5rem; }
  .cabecalho-pagina p { font-size: 0.92rem; }
  .alternar-filtros { display: flex; width: 100%; margin-bottom: 0.8rem; }
  /* recolhido: só os botões de pagamento ficam à vista */
  .painel-filtros.recolhivel:not(.aberto) { padding: 0; border: 0; background: none; box-shadow: none; }
  .painel-filtros.recolhivel:not(.aberto) > :not(.botoes-estado) { display: none; }
  .resumo-totais { gap: 0.5rem; }
  .cartao-total { min-width: 0; flex: 1 1 30%; padding: 0.6rem 0.7rem; }
  .cartao-total .rotulo { font-size: 0.62rem; }
  .cartao-total .valor { font-size: 1.02rem; }
}

/* Intracomunitárias e observações */
.na-efatura { font-size: 0.72rem; color: var(--ink-faint); border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.45rem; }
.pill.intracom { background: #E6ECF5; color: #3A5A8C; }
.icone-obs { font-size: 0.8rem; margin-left: 0.2rem; cursor: help; }
.cartao-obs { font-size: 0.82rem; color: var(--ink-muted); margin-top: 0.35rem; }
.obs-documento { background: var(--surface-2); border-radius: 8px; padding: 0.55rem 0.8rem; font-size: 0.9rem; margin: 0.7rem 0 0; max-width: 70ch; }
.grelha-campos .campo-largo { grid-column: 1 / -1; }
.grelha-campos textarea { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 0.9rem; }
.grelha-campos .campo-caixa label { display: flex; align-items: center; gap: 0.5rem; text-transform: none; letter-spacing: 0; font-size: 0.88rem; color: var(--ink); }

/* Por lançar */
.lista-por-lancar { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.lista-por-lancar li { display: flex; gap: 1rem; align-items: center; margin: 0; }
.miniatura { flex: 0 0 90px; height: 110px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; text-decoration: none; }
.miniatura img { width: 100%; height: 100%; object-fit: cover; }
.miniatura-pdf { font-weight: 700; color: var(--ink-muted); }
.por-lancar-info { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.por-lancar-info strong { overflow-wrap: anywhere; }
.por-lancar-info form { margin: 0; }

/* Definições */
.grelha-definicoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.cartao-definicao {
  display: flex; flex-direction: column; gap: 0.35rem; padding: 1.1rem 1.2rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--ink); text-decoration: none;
}
.cartao-definicao:hover { border-color: var(--accent); }
.cartao-definicao span { color: var(--ink-muted); font-size: 0.9rem; }
.ajuda-campo { font-size: 0.8rem; color: var(--ink-faint); margin: 0.3rem 0 0; }
.historico { margin-top: 0; }

/* ---------- Categorias agrupadas ---------- */
.titulo-grupo { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; }
.titulo-grupo:first-of-type { margin-top: 0; }

/* ---------- Fluxo de caixa ---------- */
.acoes-cabecalho { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.valor-negativo { color: var(--danger); }
.cartao-total.alerta { border-color: var(--danger); }
.cartao-grafico {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 1rem 1rem 0.4rem; margin-bottom: 1.4rem;
}
.legenda-grafico { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-muted); margin-bottom: 0.4rem; }
.legenda-grafico .chave { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }
.chave.receita { background: #98A46C; }
.chave.despesa { background: #C98E7C; }
.chave.saldo { background: var(--ink); height: 3px; vertical-align: 3px; }
.grafico-fluxo { width: 100%; height: auto; display: block; }
.grafico-fluxo .grelha { stroke: var(--border); stroke-width: 1; }
.grafico-fluxo .grelha.zero { stroke: var(--ink-faint); }
.grafico-fluxo .eixo { font-size: 11px; fill: var(--ink-faint); font-family: 'Lato', system-ui, sans-serif; }
.grafico-fluxo .barra.receita { fill: #98A46C; }
.grafico-fluxo .barra.despesa { fill: #C98E7C; }
.grafico-fluxo .alvo { fill: transparent; }
.grafico-fluxo .mes:hover .alvo { fill: var(--surface-2); }
.grafico-fluxo .linha-saldo { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; pointer-events: none; }
.grafico-fluxo .ponto-saldo { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; pointer-events: none; }
.grafico-fluxo .ponto-saldo.negativo { stroke: var(--danger); fill: var(--danger); }

.tabela-fluxo-wrap { max-height: 75vh; }
table.tabela-fluxo { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; white-space: nowrap; }
.tabela-fluxo th, .tabela-fluxo td { padding: 0.32rem 0.55rem; border-bottom: 1px solid var(--surface-2); }
.tabela-fluxo thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; font-size: 0.74rem;
  text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted);
}
.tabela-fluxo .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela-fluxo .col-categoria {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 500;
  min-width: 190px; max-width: 240px; overflow: hidden; text-overflow: ellipsis;
}
.tabela-fluxo thead .col-categoria { z-index: 3; background: var(--surface-2); }
.tabela-fluxo .col-categoria a { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--ink-faint); }
.tabela-fluxo .col-categoria a:hover { color: var(--accent); }
.tabela-fluxo .col-comparacao { text-align: left; }
.tabela-fluxo .col-total { font-weight: 600; background: var(--surface-2); }
.tabela-fluxo .linha-sub .col-categoria { padding-left: 1.5rem; font-weight: 400; }
.tabela-fluxo .linha-grupo th, .tabela-fluxo .linha-grupo td { font-weight: 600; background: #FAF7F0; }
.tabela-fluxo .linha-grupo .col-categoria { background: #FAF7F0; }
.tabela-fluxo .linha-seccao th, .tabela-fluxo .linha-seccao td {
  background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.74rem; font-weight: 700;
}
.tabela-fluxo .linha-total th, .tabela-fluxo .linha-total td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); }
.tabela-fluxo .linha-saldo-mes th, .tabela-fluxo .linha-saldo-mes td { font-weight: 600; }
.tabela-fluxo .linha-caixa th, .tabela-fluxo .linha-caixa td { font-weight: 700; background: var(--gold-soft); border-top: 2px solid var(--gold); }
.tabela-fluxo td.origem-manual, .origem-exemplo.origem-manual { color: #3A5A8C; font-weight: 600; }
.tabela-fluxo td.origem-orcamento, .origem-exemplo.origem-orcamento { color: var(--ink); }
.tabela-fluxo td.origem-sugestao, .origem-exemplo.origem-sugestao { color: var(--ink-muted); font-style: italic; }
.tabela-fluxo .vazio-linha { color: var(--ink-faint); font-weight: 400; }
.pill.comparacao-ok { background: var(--accent-soft); color: var(--ok); }
.pill.comparacao-acima, .pill.comparacao-abaixo { background: var(--gold-soft); color: var(--warn); }
.pill.comparacao-novo { background: #E6ECF5; color: #3A5A8C; }
.pill.comparacao-sem_dados { background: transparent; color: var(--ink-faint); }
.pill.comparacao-distribuicao { background: #EDE6F2; color: #6A4C82; margin-left: 0.2rem; }
.nota-rodape { font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.6rem; }
.origem-exemplo { padding: 0 0.2rem; }
.grelha-meses { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; }
.dica-automatico { display: block; font-size: 0.74rem; color: var(--ink-faint); margin-top: 0.2rem; }
@media (max-width: 720px) {
  .tabela-fluxo .col-categoria { min-width: 130px; max-width: 150px; }
  .grelha-meses { grid-template-columns: repeat(2, 1fr); }
}
.tabela-orcamento { width: 100%; }
.tabela-orcamento .entrada-valor { width: 8.5rem; text-align: right; padding: 0.3rem 0.45rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.tabela-orcamento .variacao { color: var(--ink-muted); font-size: 0.78rem; }
.form-criar-orcamento { display: flex; gap: 0.5rem; }
.form-criar-orcamento input { width: 6rem; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
@media (max-width: 720px) {
  .cartao-grafico { overflow-x: auto; }
  .grafico-fluxo { min-width: 680px; }
}

/* ---------- Trabalhadores ---------- */
.grelha-trabalhadores { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.9rem; }
.cartao-trabalhador {
  display: flex; gap: 0.9rem; align-items: center; padding: 0.9rem 1rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.cartao-trabalhador:hover { border-color: var(--accent); }
.cartao-trabalhador.inativo { opacity: 0.6; }
.dados-trabalhador { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.86rem; color: var(--ink-muted); min-width: 0; }
.dados-trabalhador strong { color: var(--ink); font-size: 1rem; }
.dados-trabalhador .custo { font-size: 0.8rem; }
.foto-trabalhador { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; }
.foto-trabalhador.grande { width: 110px; height: 110px; }
.foto-trabalhador.sem-foto {
  display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent);
  font-family: 'Playfair Display', Georgia, serif; font-size: 1.4rem; font-weight: 600;
}
.foto-trabalhador.grande.sem-foto { font-size: 2.4rem; }
.bloco-foto { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.ficha-trabalhador fieldset { border: 1px solid var(--border); }
.ficha-trabalhador legend { padding: 0 0.4rem; }
.campo-largo { grid-column: 1 / -1; }
.erro-campo { color: var(--danger); font-size: 0.82rem; margin: 0.2rem 0 0; }

/* ---------- Sócios ---------- */
.saldo-socio { font-family: 'Playfair Display', Georgia, serif; font-size: 1.1rem; color: var(--ink); }
.saldo-socio.credor { color: var(--ok); }
.saldo-socio.devedor { color: var(--danger); }
.tabela-conta .linha-anulada td { color: var(--ink-faint); }
.tabela-conta .registo { font-size: 0.78rem; color: var(--ink-faint); white-space: nowrap; }
.opcoes-sentido { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; }
.opcoes-sentido label { text-transform: none; letter-spacing: 0; font-size: 0.9rem; color: var(--ink); }
.form-em-linha { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-em-linha select { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 12rem; }

/* ---------- Fornecedores ---------- */
.grelha-ficha { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.2rem; align-items: start; }
.grelha-ficha > .painel-filtros { margin-bottom: 0; }
.iban { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.lista-ibans li { margin-bottom: 0.35rem; }
.entrada-pesquisa { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 12rem; }
@media (max-width: 860px) { .grelha-ficha { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Cobertura do e-Fatura ---------- */
.mapa-cobertura { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 0.35rem; margin-bottom: 1rem; }
.mes-cobertura { text-align: center; padding: 0.35rem 0.2rem; border-radius: 6px; font-size: 0.78rem; font-weight: 500; }
.mes-cobertura.coberto { background: var(--accent-soft); color: var(--ok); }
.mes-cobertura.em-falta { background: var(--gold-soft); color: var(--warn); border: 1px dashed var(--warn); }
.mes-cobertura.antes { background: var(--surface-2); color: var(--ink-faint); }
.marca-bloco { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.4rem; }
.marca-bloco.centrada { justify-content: center; flex-wrap: wrap; text-align: center; }
.marca-bloco .marca-nome { font-size: 1.6rem; }

/* ---------- Frota ---------- */
.painel-alertas { background: #FBF3EC; border: 1px solid #E8C9B8; border-radius: 12px; padding: 0.9rem 1.2rem; margin-bottom: 1.2rem; }
.painel-alertas ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.painel-alertas li { margin-bottom: 0.3rem; }
.painel-alertas li.alerta-vencida { color: var(--danger); }
.painel-alertas li.alerta-breve { color: var(--warn); }
.matricula { display: inline-block; font-family: ui-monospace, Menlo, monospace; font-size: 0.78em; padding: 0.05rem 0.4rem; border: 1px solid var(--ink-faint); border-radius: 4px; background: var(--surface); color: var(--ink); vertical-align: 2px; }
.linha-inativa td { color: var(--ink-faint); }
.form-viatura select, .form-viatura input { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }

/* ---------- Calendário agrícola ---------- */
.grelha-calendario-pagina { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.2rem; align-items: start; }
.navegacao-mes { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.navegacao-mes h2 { font-size: 1.3rem; min-width: 11rem; text-align: center; }
.calendario-mes {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--border); gap: 1px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.cabecalho-dia { background: var(--surface-2); padding: 0.35rem; text-align: center; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.dia { background: var(--surface); min-height: 96px; padding: 0.3rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dia.fora { background: #FBF9F4; }
.dia.fora .numero-dia { color: var(--ink-faint); }
.dia.hoje .numero-dia { background: var(--accent); color: #fff; }
.numero-dia { align-self: flex-start; font-size: 0.8rem; font-weight: 600; color: var(--ink); text-decoration: none; padding: 0 0.35rem; border-radius: 999px; line-height: 1.5; }
.numero-dia:hover { background: var(--surface-2); }
.evento { display: block; font-size: 0.72rem; line-height: 1.3; padding: 0.1rem 0.3rem; border-radius: 4px; text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--ink-faint); background: var(--surface-2); }
.evento.concluida { text-decoration: line-through; opacity: 0.6; }
.tipo-sementeira { --cor: #5E8C3A; } .tipo-colheita { --cor: #C9962B; } .tipo-tratamento { --cor: #3A7C8C; }
.tipo-gado { --cor: #8C5A3A; } .tipo-cortica { --cor: #A0522D; } .tipo-montanheira { --cor: #6B4E8C; }
.tipo-lenha { --cor: #7A6A3A; } .tipo-manutencao { --cor: #5B6B57; } .tipo-administrativo { --cor: #2A588D; }
.tipo-frota { --cor: #B24A3C; } .tipo-pagamento { --cor: #93503F; } .tipo-ferias { --cor: #707C4C; } .tipo-outro { --cor: #8A9686; }
.evento[class*="tipo-"] { border-left-color: var(--cor); background: color-mix(in srgb, var(--cor) 12%, white); }
.lista-proximas { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.88rem; }
.lista-proximas li { display: flex; gap: 0.5rem; align-items: flex-start; }
.lista-proximas small { color: var(--ink-muted); }
.ponto { width: 10px; height: 10px; border-radius: 50%; background: var(--cor, var(--ink-faint)); flex: none; margin-top: 0.35rem; }
@media (max-width: 860px) {
  .grelha-calendario-pagina { grid-template-columns: 1fr; }
  .dia { min-height: 64px; }
  .evento { font-size: 0.64rem; padding: 0.05rem 0.2rem; }
}
.tabela-permissoes { min-width: 0; margin-top: 0.4rem; }
.tabela-permissoes select { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 14rem; }

/* ---------- Sementeiras ---------- */
.grelha-campos-sem { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; align-items: start; }
.grelha-campos-sem ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.grelha-campos-sem ul label { text-transform: none; letter-spacing: 0; font-size: 0.9rem; color: var(--ink); display: flex; gap: 0.35rem; align-items: center; }
.chip-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.86rem; font-weight: 500; }
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.chip-link.ativo { background: var(--accent); border-color: var(--accent); color: #fff; }
.abas-sem { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin: 0.4rem 0 1.2rem; }
.abas-sem a { padding: 0.6rem 1rem; text-decoration: none; color: var(--ink-muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.abas-sem a.ativa { color: var(--ink); border-bottom-color: var(--accent); }
.grelha-sementeiras { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.cartao-sementeira { display: flex; flex-direction: column; gap: 0.8rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.cartao-sementeira:hover { border-color: var(--accent); }
.cartao-sementeira strong { font-family: 'Playfair Display', Georgia, serif; font-size: 1.2rem; }
.topo-cartao { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.dados-cartao { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 1rem; font-size: 0.86rem; }
.dados-cartao span { display: block; color: var(--ink-muted); font-size: 0.76rem; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; }
.pill.estado-planeada { background: #EEEAE0; color: #48554B; }
.pill.estado-preparacao { background: var(--gold-soft); color: #7E520F; }
.pill.estado-semeada { background: var(--accent-soft); color: var(--ok); }
.pill.estado-concluida { background: #E1EAF4; color: #24507F; }
.pill.estado-cancelada { background: #F6DFD9; color: #8E3020; }
.acoes-rapidas-op { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.acoes-rapidas-op .chip-link { min-height: 32px; font-size: 0.8rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 0.9rem; padding-bottom: 1.1rem; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.ponto-tl { width: 16px; height: 16px; border-radius: 50%; margin-top: 3px; flex: none; background: var(--cor-op, #8A9686); box-shadow: 0 0 0 3px var(--surface); position: relative; }
.timeline li.prevista .ponto-tl { background: var(--surface); border: 2px dashed var(--cor-op, #8A9686); }
.op-gradagem, .op-preparacao, .op-corte, .op-enfardamento, .op-transporte { --cor-op: #8A6A3A; }
.op-adubacao { --cor-op: #8A5CA8; } .op-sementeira { --cor-op: #2E9270; } .op-tratamento { --cor-op: #2F6FA8; } .op-outra { --cor-op: #8A9686; }
.corpo-tl { flex: 1; min-width: 0; }
.linha-tl { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.linha-tl .valor-tl { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.small-tl { font-size: 0.84rem; margin-top: 0.15rem; }
.barra-custo { display: grid; grid-template-columns: 150px minmax(0, 1fr) 100px; gap: 0.7rem; align-items: center; font-size: 0.86rem; margin-bottom: 0.55rem; }
.barra-custo b { text-align: right; font-variant-numeric: tabular-nums; }
.bar-sem { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-sem > div { height: 100%; border-radius: 99px; background: var(--accent); }
.cartao-resultado { background: var(--accent); color: #fff; border-radius: 14px; padding: 1.2rem 1.4rem; align-self: start; }
.eyebrow-claro { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: #C9D6E4; font-weight: 600; margin-bottom: 0.4rem; }
.cartao-resultado dl { margin: 0; }
.cartao-resultado dl > div { display: flex; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid #3B6698; }
.cartao-resultado dt { color: #D6E1EE; }
.cartao-resultado dd { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cartao-resultado .grande dd { font-size: 1.5rem; }
.grelha-mapa { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.2rem; align-items: start; }
.mapa-herdade { position: relative; width: 100%; border-radius: 12px; overflow: hidden; background: #7C8757; user-select: none; }
.mapa-herdade.sem-foto { aspect-ratio: 16 / 10; }
.mapa-herdade img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.mapa-herdade svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mapa-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; }
.parcela-mapa { fill: rgba(46, 146, 112, 0.28); stroke: #fff; stroke-width: 2px; vector-effect: non-scaling-stroke; cursor: pointer; }
.parcela-mapa:hover { fill: rgba(46, 146, 112, 0.45); }
.parcela-mapa.inativa { fill: rgba(255, 255, 255, 0.08); stroke-dasharray: 6 5; }
.parcela-mapa.selecionada, .parcela-mapa.destaque { stroke: #F2C14E; stroke-width: 4px; }
.desenho { fill: rgba(242, 193, 78, 0.25); stroke: #F2C14E; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.rotulo-mapa { position: absolute; transform: translate(-50%, -50%); background: rgba(27, 51, 37, 0.85); color: #fff; font-size: 0.78rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 6px; pointer-events: none; }
.linha-inativa td { color: var(--ink-faint); }
@media (max-width: 860px) {
  .grelha-mapa { grid-template-columns: 1fr; }
  .barra-custo { grid-template-columns: 110px minmax(0, 1fr) 84px; }
}
.caixa-so-fiscal { background: #ECE4F3; border-radius: 10px; padding: 0.6rem 0.8rem; }
.caixa-so-fiscal label { text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: #4A2F66; font-weight: 600; }
.pill.so-fiscal { background: #ECE4F3; color: #5E3E7E; }
.pill.por-fora { background: #F7EAD2; color: #7E520F; border: 1px dashed #C38A2E; }
.caixa-por-fora { background: var(--gold-soft); border-radius: 10px; padding: 0.6rem 0.8rem; }
.caixa-por-fora label { text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: #6E470C; font-weight: 600; }
.passos-revolut { list-style: none; padding: 0; margin: 0 0 1rem; max-width: 860px; }
.certificado { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 0.75rem; border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; }
.copiavel { background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 5px; user-select: all; word-break: break-all; }
.barra-pagar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 0.8rem; align-items: center; justify-content: flex-end; padding: 0.7rem 1rem; margin-top: 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.col-escolher { width: 34px; text-align: center; }
.col-escolher input { width: 18px; height: 18px; cursor: pointer; }
.bolinha-ok, .bolinha-pendente { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; margin-right: 0.3rem; }
.bolinha-ok { background: #2F9E5B; box-shadow: 0 0 0 2px #D8EFE0; }
.bolinha-pendente { background: transparent; border: 2px solid #C38A2E; width: 10px; height: 10px; }
.tabela-salarios input:not([type=checkbox]) { width: 100%; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 0.86rem; }
.tabela-salarios input.valor { width: 7.5rem; text-align: right; }
.tabela-salarios input.iban { min-width: 15rem; font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; }
.tabela-salarios .linha-trabalhador td { background: var(--surface-2); }
.info-custo { display: block; font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.15rem; }


/* =====================================================================
   Layout do protótipo: menu lateral + barra de topo (computador)
   ===================================================================== */
body { -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.85rem; letter-spacing: -0.01em; }
.menu-lateral { display: none; }
@media (min-width: 721px) {
  body.com-menu { padding-left: 248px; }
  .menu-lateral {
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; width: 248px; z-index: 30;
    background: var(--lateral); color: #E4ECF5; padding: 18px 14px 14px; overflow-y: auto;
  }
  .marca-lateral { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; text-decoration: none; }
  .marca-lateral .nome { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 1.35rem; font-weight: 600; color: #fff; line-height: 1.1; }
  .marca-lateral .sub { display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #C9D6E4; }
  .menu-lateral nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .menu-lateral .item {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: 8px;
    color: #D6E1EE; text-decoration: none; font-size: 0.9rem; font-weight: 500;
  }
  .menu-lateral .item:hover { background: #243F2F; color: #fff; }
  .menu-lateral .item.ativo { background: var(--lateral-item); color: #fff; }
  .menu-lateral .item svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .menu-lateral .subitens { display: flex; flex-direction: column; margin: 2px 0 8px; }
  .menu-lateral .subitens a { padding: 6px 12px 6px 43px; border-radius: 6px; color: #B9CADD; text-decoration: none; font-size: 0.84rem; }
  .menu-lateral .subitens a:hover { color: #fff; }
  .menu-lateral .subitens a.ativo { color: #fff; background: rgba(255,255,255,0.07); }
  .utilizador-lateral { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; margin-top: 12px; border-top: 1px solid #3B6698; }
  .utilizador-lateral .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: var(--lateral); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex: none; }
  .utilizador-lateral .n { display: block; color: #fff; font-size: 0.85rem; font-weight: 600; }
  .utilizador-lateral button { background: none; border: 0; padding: 0; color: #C9D6E4; font: inherit; font-size: 0.78rem; cursor: pointer; text-decoration: underline; }

  .topbar {
    position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 28px; gap: 12px;
    display: flex; align-items: center; justify-content: flex-start; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .marca { display: none; }
  main.conteudo { max-width: 1320px; padding: 1.8rem 2rem 4rem; }
}
.pesquisa-topo {
  flex: 1; max-width: 460px; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border: 1px solid #DDD5C4; border-radius: 10px; background: #FBF9F4; color: var(--ink-muted);
}
.pesquisa-topo svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.pesquisa-topo input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 0.9rem; color: var(--ink); outline: none; min-width: 0; }
.acoes-topo { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.botao.pequeno { padding: 0.4rem 0.8rem; font-size: 0.84rem; border-radius: 8px; text-decoration: none; }
.sino { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #DDD5C4; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); background: var(--surface); }
.sino svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 720px) {
  .pesquisa-topo, .acoes-topo { display: none; }
}
/* Cartões, tabelas e botões com o acabamento do protótipo */
.painel-filtros, .tabela-wrap, .cartao-total { border-radius: 14px; }
.cartao-total { box-shadow: none; }
.cartao-total .valor { font-size: 1.45rem; font-weight: 600; }
.botao { border-radius: 9px; }
table.documentos th { background: #FBF9F4; }

/* ---------- Dashboard ---------- */
.data-extenso { margin: 0 0 0.2rem; color: var(--ink-muted); font-size: 0.88rem; }
.kpis-painel { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-painel { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--ink); }
.kpi-painel:hover { border-color: var(--accent); }
.kpi-painel .r { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-muted); }
.kpi-painel .v { font-family: 'Playfair Display', Georgia, serif; font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em; }
.kpi-painel .s { font-size: 0.8rem; color: var(--ink-muted); }
.neg { color: var(--danger); }
.grelha-painel { display: grid; gap: 20px; margin-bottom: 20px; }
.grelha-painel.tres { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grelha-painel.dois-um { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.cartao-painel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; min-width: 0; }
.cartao-painel > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.cartao-painel h2 { font-family: 'Lato', system-ui, sans-serif; font-size: 0.98rem; font-weight: 650; margin: 0; }
.cartao-painel > header a { font-size: 0.84rem; font-weight: 600; }
.linha-painel { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ECEFE8; text-decoration: none; color: var(--ink); min-width: 0; }
.linha-painel:last-of-type { border-bottom: 0; }
.linha-painel .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.linha-painel .t1 { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { font-size: 0.8rem; color: var(--ink-muted); }
.data-mini { width: 44px; flex: none; text-align: center; border: 1px solid var(--border); border-radius: 9px; padding: 2px 0; font-size: 0.66rem; text-transform: uppercase; color: var(--ink-muted); font-weight: 700; display: flex; flex-direction: column; }
.data-mini b { font-family: 'Playfair Display', Georgia, serif; font-size: 1.1rem; color: var(--ink); line-height: 1.1; }
.valor-painel { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.valor-painel.pos { color: var(--ok); }
.alerta-painel { display: block; padding: 10px 12px; border-radius: 10px; font-size: 0.86rem; margin-bottom: 8px; text-decoration: none; }
.alerta-painel.bad { background: #F9E6E1; color: #7E2A1C; }
.alerta-painel.warn { background: #FBF1DE; color: #6E470C; }
.alerta-painel.info { background: #E7EEF6; color: #1F466F; }
.barra-orc { margin-bottom: 10px; }
.barra-orc .topo { display: flex; justify-content: space-between; font-size: 0.86rem; margin-bottom: 4px; }
.cartao-grafico-painel .grafico-fluxo { max-height: 300px; }
.opcao-cartao { display: flex; gap: 8px; align-items: center; padding: 8px 0; text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--ink); }
.cartao-grafico-painel { overflow-x: auto; }
@media (max-width: 900px) { .grelha-painel.dois-um { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .kpis-painel { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-painel { padding: 12px 14px; }
  .kpi-painel .v { font-size: 1.25rem; }
  .grelha-painel.tres { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Marca (Manual de Normas Gráficas) ---------- */
.logo-completo { margin-bottom: 0.4rem; }
.logo-completo img { width: 200px; height: auto; }
.marca-portal { text-align: center; margin: 0 0 1rem; font-family: 'EB Garamond', Georgia, serif; font-style: italic; font-size: 1.25rem; color: var(--accent); }
.data-extenso { font-family: 'EB Garamond', Georgia, serif; font-style: italic; font-size: 1.05rem; }
.linha-copiar { display: flex; gap: 0.5rem; }
.linha-copiar input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.lista-numerada { list-style: decimal; padding-left: 1.3rem; }
.destaque-ano { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.linha-selecionada td { background: var(--accent-soft); }
.pill.debito-direto { background: #E1EAF4; color: #24507F; border: 1px dashed #2A588D; }

/* Prazos de pagamento: uma data limite (no telemóvel o formulário passa para baixo) */
.vencimento { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid #ECEFE8; }
.vencimento:last-child { border-bottom: 0; }
.vencimento-topo { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; min-width: 0; }
.vencimento-topo .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vencimento-topo .t1 { display: block; font-size: 0.92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vencimento-topo .pill { flex: none; white-space: nowrap; }
.vencimento-acao { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; }
.vencimento-acao input { width: 8rem; }
@media (max-width: 720px) {
  .vencimento-acao { flex: 1 1 100%; padding-left: 56px; }
  .vencimento-acao input { flex: 1; min-width: 0; width: auto; }
}
/* Telemóvel: as tabelas ocupam só o que precisam (a largura mínima de 760 px
   obrigava a deslizar para o lado mesmo em tabelas de 2–4 colunas). */
@media (max-width: 720px) {
  table.documentos { min-width: 0; font-size: 0.84rem; }
  table.documentos th, table.documentos td { padding-left: 0.45rem; padding-right: 0.45rem; }
  table.documentos th { font-size: 0.66rem; letter-spacing: 0.02em; }
}
.registo-erro { border-bottom: 1px solid var(--border); padding: 0.7rem 0; }
.registo-erro summary { cursor: pointer; }
.registo-erro .t2 { margin-top: 0.3rem; overflow-wrap: anywhere; }
.detalhe-erro { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.75rem; background: var(--surface-2); padding: 0.8rem; border-radius: 8px; max-height: 60vh; overflow: auto; }

/* Botão de voltar na barra de cima (só telemóvel) */
.voltar-topo { display: none; }
@media (max-width: 720px) {
  .com-voltar .voltar-topo {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; left: 8px; bottom: 0.35rem; width: 44px; height: 44px;
    border-radius: 12px; color: var(--accent); text-decoration: none;
  }
  .voltar-topo:active { background: var(--surface-2); }
  .voltar-topo svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
}

/* Documentos: resumo do ano e dos trimestres (clicáveis) */
.resumo-ano { display: grid; grid-template-columns: minmax(200px, 1fr) 3fr; gap: 0.7rem; margin-bottom: 0.6rem; }
.resumo-ano a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.resumo-ano a.ativo { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.resumo-ano .rotulo { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.resumo-ano .valor { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 1.35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resumo-ano .detalhe { font-size: 0.8rem; color: var(--ink-muted); }
.resumo-trimestres { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem; }
.resumo-trimestre .valor { font-size: 1.05rem; }
.linha-filtro { font-size: 0.85rem; color: var(--ink-muted); margin: 0 0 0.8rem; }
.aviso-invulgares { margin: 0 0 0.6rem; }
@media (max-width: 720px) {
  .resumo-ano { grid-template-columns: 1fr; gap: 0.5rem; }
  .resumo-ano-total { flex-direction: row !important; align-items: baseline; flex-wrap: wrap; column-gap: 0.6rem !important; }
  .resumo-ano-total .rotulo { width: 100%; }
  .resumo-trimestres { gap: 0.4rem; }
  .resumo-trimestre { padding: 0.5rem 0.45rem !important; }
  .resumo-trimestre .valor { font-size: 0.86rem; font-family: 'Lato', system-ui, sans-serif; }
  .resumo-trimestre .rotulo { font-size: 0.6rem; letter-spacing: 0.02em; }
  .resumo-trimestre .detalhe { font-size: 0.7rem; }
}
.barra-pagar[hidden] { display: none; }

/* Recibos de vencimento por confirmar */
.cabecalho-seccao { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.recibo-pendente { border-top: 1px solid var(--border); padding: 0.9rem 0 0.4rem; }
.recibo-pendente-topo { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.mes-recibos { border-top: 1px solid var(--border); padding: 0.6rem 0; }
.mes-recibos summary { cursor: pointer; }

/* Ocorrências no terreno */
.mapa-terreno { height: 420px; border-radius: 14px; border: 1px solid var(--border); margin: 0 0 1rem; z-index: 0; }
.mapa-terreno.pequeno { height: 280px; margin-top: 0.6rem; }
.filtros-em-linha { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros-em-linha select { padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font: inherit; font-size: 16px; }
.cartao-ocorrencia { display: flex !important; gap: 0.8rem; align-items: flex-start; }
.cartao-ocorrencia img, .cartao-ocorrencia .sem-foto { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.cartao-ocorrencia .dados { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.lista-ocorrencias { display: flex !important; }
.foto-ocorrencia img { max-width: 100%; max-height: 360px; border-radius: 14px; }
@media (max-width: 720px) { .mapa-terreno { height: 320px; } }

/* Visualizador de ficheiros (static/js/visualizador.js) */
.visor { position: fixed; inset: 0; z-index: 100; background: #1d2530; display: flex; flex-direction: column; }
body.visor-aberto { overflow: hidden; }
.visor-barra { display: flex; align-items: center; gap: 0.8rem; padding: calc(0.5rem + env(safe-area-inset-top)) 12px 0.5rem; background: #111821; color: #fff; }
.visor-fechar { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255,255,255,0.12); color: #fff; font-size: 1.3rem; cursor: pointer; flex: none; }
.visor-titulo { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.visor-descarregar { color: #fff; font-size: 0.85rem; flex: none; }
.visor-corpo { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.visor-corpo img { max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
.visor-estado { color: #E8EEF4; margin-top: 2rem; }

/* Documento acabado de guardar, ao voltar à lista */
.acabado-de-editar { animation: realce-editado 3s ease-out; }
tr.acabado-de-editar td { animation: realce-linha 3s ease-out; }
@keyframes realce-editado { from { box-shadow: 0 0 0 3px var(--gold, #C9A15D); } to { box-shadow: 0 0 0 3px transparent; } }
@keyframes realce-linha { from { background-color: #F3E7CF; } to { background-color: #F3E7CF00; } }

/* Instalar a app */
.instalar-app { max-width: 720px; }
.instalar-topo { display: flex; gap: 0.9rem; align-items: center; margin-bottom: 1rem; }
.instalar-topo img { border-radius: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.instalar-topo strong { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 1.2rem; }
.instalar-topo span { color: var(--ink-muted); font-size: 0.9rem; }
.botao.grande { font-size: 1.05rem; padding: 0.8rem 1.4rem; }
.passos-instalar ol { padding-left: 1.3rem; line-height: 1.7; }
.icone-ios { display: inline-flex; vertical-align: middle; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); align-items: center; justify-content: center; }
.icone-ios svg { width: 18px; height: 18px; fill: none; stroke: #2A7BF6; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.aviso-sucesso { background: var(--accent-soft); color: var(--ok); padding: 0.7rem 0.9rem; border-radius: 10px; margin: 0; }
.cartao-definicao.destaque { border-color: var(--accent); }
.utilizador-lateral form a { color: #C9D6E4; font-size: 0.78rem; }
/* Já a correr como app instalada: não mostrar "Instalar a app" nos menus */
@media (display-mode: standalone) { [data-esconder-na-app] { display: none; } }

/* Lista de documentos (computador): colunas com largura fixa, o fornecedor
   fica com o que sobra e nada sai da tabela. Em ecrãs mais estreitos sai a
   coluna Tipo (quase sempre "Fatura") e, abaixo de 820 px, a tabela desliza
   em vez de esmagar o fornecedor. */
table.lista-documentos { table-layout: fixed; min-width: 820px; }
table.lista-documentos th, table.lista-documentos td { padding-left: 0.55rem; padding-right: 0.55rem; }
table.lista-documentos .c-escolher { width: 40px; }
table.lista-documentos .c-data { width: 98px; }
table.lista-documentos .c-numero { width: 17%; }
table.lista-documentos .c-tipo { width: 80px; }
table.lista-documentos .c-categoria { width: 13%; }
table.lista-documentos .c-valor { width: 132px; }
table.lista-documentos .c-estado { width: 142px; }
table.lista-documentos .c-efatura { width: 66px; }
table.lista-documentos td.cortar { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.lista-documentos td.estado .pill { margin: 1px 2px 1px 0; }
table.lista-documentos th a { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
@media (max-width: 1280px) {
  table.lista-documentos col.c-tipo, table.lista-documentos th:nth-child(4), table.lista-documentos td:nth-child(4) { display: none; }
  table.lista-documentos .c-numero { width: 16%; }
  table.lista-documentos .c-categoria { width: 12%; }
}

/* Apagar fornecedor: opções */
.opcao-apagar { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0; border-top: 1px solid var(--border); cursor: pointer; }
.opcao-apagar input[type=radio] { margin-top: 0.3rem; }
.opcao-apagar select { display: block; margin-top: 0.5rem; width: 100%; max-width: 480px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; background: var(--surface); }

.aviso-nomes-nif { display: flex; gap: 0.8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }

/* Por lançar: escolher vários */
.barra-massa { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin: 0 0 0.8rem; padding: 0.6rem 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; position: sticky; top: 64px; z-index: 5; }
.barra-massa label { display: flex; gap: 0.4rem; align-items: center; cursor: pointer; }
.escolher-por-lancar { width: 22px; height: 22px; flex: none; cursor: pointer; }
@media (max-width: 720px) { .barra-massa { top: calc(56px + env(safe-area-inset-top)); } }
.estado-leitura { display: block; color: var(--ink-muted); font-size: 0.8rem; margin: 0.15rem 0 0.4rem; }

/* Pré-visualização de PDFs (1.ª página em imagem) */
.miniatura { position: relative; }
.selo-pdf { position: absolute; right: 4px; bottom: 4px; font-size: 0.62rem; font-weight: 700; color: #fff; background: var(--danger); border-radius: 4px; padding: 1px 4px; }
.pagina-pdf { display: block; }
.pagina-pdf img { border: 1px solid var(--border); background: #fff; }
.miniatura img { background: #fff; }
.miniatura img { object-position: top; }

/* Documento: o nome do fornecedor abre a ficha dele */
.ligacao-fornecedor { color: inherit; text-decoration: none; }
.ligacao-fornecedor span { color: var(--accent); font-size: 0.8em; }
.ligacao-fornecedor:hover { text-decoration: underline; }
.pill.recibo { background: #E3ECF6; color: #2A588D; margin-left: 0.3rem; }

/* Filtro de pagamento em botões */
.botoes-estado { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.botao-estado { position: relative; padding: 0.45rem 0.9rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 0.88rem; cursor: pointer; user-select: none; }
.botao-estado input { position: absolute; opacity: 0; pointer-events: none; }
.botao-estado.ativo, .botao-estado:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }

/* "← Voltar" do topo das páginas: um botão a sério */
.botao-voltar {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.95rem; margin-bottom: 0.4rem;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--accent);
  font-size: 0.9rem; font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.botao-voltar:hover { background: var(--surface-2); text-decoration: none; }
.cabecalho-pagina p:has(> .botao-voltar) { margin-bottom: 0.4rem; }
td.estado .sem-pagamento { display: inline-block; min-width: 1.5rem; color: var(--ink-faint); text-align: center; }

/* Estatísticas */
.filtros-estatisticas .botoes-periodo .botao-estado { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; padding: 0.45rem 1rem; border-radius: 12px; min-width: 6.2rem; }
.botoes-periodo .rotulo-periodo { font-weight: 700; }
.botoes-periodo .total-periodo { font-size: 0.76rem; opacity: 0.8; font-variant-numeric: tabular-nums; }
.filtros-ativos { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.7rem; }
.chip-filtro { padding: 0.25rem 0.7rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.82rem; text-decoration: none; }
.kpis-estatisticas .cartao-total { flex: 1 1 200px; }
.cartao-total .comparacao { font-size: 0.78rem; color: var(--ink-faint); margin-top: 0.2rem; }
.comparacao.subiu, td.subiu { color: var(--danger); }
.comparacao.desceu, td.desceu { color: var(--ok); }
.grelha-graficos { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1rem; }
.grelha-graficos .cartao-grafico, .tabela-estatisticas { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem; }
.grelha-graficos h2, .tabela-estatisticas h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.tabela-estatisticas { margin-bottom: 1rem; overflow-x: auto; }
.tabela-estatisticas table { width: 100%; }
.tabela-estatisticas th, .tabela-estatisticas td { white-space: nowrap; }
.tabela-estatisticas td.cortar { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tabela-estatisticas .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela-estatisticas .forte { font-weight: 700; }
.tabela-estatisticas .suave { color: var(--ink-faint); }
.tabela-estatisticas tfoot th { border-top: 2px solid var(--border); padding: 0.6rem 0.9rem; font-size: 0.9rem; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; background: var(--surface-2); }
.tabela-estatisticas .celula-calor { background: rgba(42, 88, 141, calc(var(--calor) * 0.22)); }
.col-peso { min-width: 105px; font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--ink-muted); }
.col-barra { width: 32%; min-width: 120px; }
.mini-barra { display: inline-block; width: 64px; height: 7px; margin-right: 0.45rem; border-radius: 4px; background: var(--surface-2); overflow: hidden; vertical-align: 1px; }
.mini-barra.larga { width: 100%; height: 10px; }
.mini-barra > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.nota-tabela { font-size: 0.8rem; color: var(--ink-faint); margin: 0.6rem 0 0; }
.chave.atual { background: var(--accent); }
.chave.anterior { background: #C9D3DF; }
.grafico-colunas { width: 100%; height: auto; display: block; }
.grafico-colunas .grelha { stroke: var(--border); stroke-width: 1; }
.grafico-colunas .eixo { font-size: 13px; fill: var(--ink-faint); font-family: 'Lato', system-ui, sans-serif; }
.grafico-colunas .barra.atual { fill: var(--accent); }
.grafico-colunas .barra.anterior { fill: #C9D3DF; }
.grafico-colunas .alvo { fill: transparent; }
.grafico-colunas .mes:hover .alvo { fill: var(--surface-2); }
.donut-com-legenda { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.donut { width: 190px; height: 190px; flex: 0 0 auto; }
.donut-valor { font-size: 4px; font-weight: 700; fill: var(--ink); font-family: 'Lato', system-ui, sans-serif; }
.donut-rotulo { font-size: 2.8px; fill: var(--ink-faint); font-family: 'Lato', system-ui, sans-serif; }
.legenda-donut { list-style: none; margin: 0; padding: 0; flex: 1 1 160px; font-size: 0.84rem; }
.legenda-donut li { display: flex; align-items: center; gap: 0.45rem; padding: 0.18rem 0; }
.legenda-donut i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legenda-donut .nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legenda-donut .pct { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .grelha-graficos { grid-template-columns: 1fr; }
  .filtros-estatisticas .botoes-periodo .botao-estado { min-width: 0; flex: 1 1 28%; padding: 0.4rem 0.5rem; }
  .donut { width: 150px; height: 150px; }
  .kpis-estatisticas .cartao-total { flex: 1 1 45%; }
  .grafico-colunas .eixo { font-size: 22px; }
  .tabela-estatisticas .col-barra, .tabela-estatisticas .mini-barra { display: none; }
}
.separador-botoes { width: 1px; align-self: stretch; margin: 0 0.3rem; background: var(--border); }
.barra-escolhidos { flex-wrap: wrap; }
.barra-escolhidos [data-contagem-escolhidos] { margin-right: auto; font-weight: 600; }
.barra-escolhidos .grupo-categoria { display: inline-flex; gap: 0.4rem; align-items: center; }
.barra-escolhidos select { max-width: 240px; padding: 0.45rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font: inherit; }
.tabela-conta-corrente td.cortar { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabela-conta-corrente .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabela-conta-corrente .forte { font-weight: 700; }
.por-conta-form { margin-top: 1.2rem; }
.por-conta-form select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 240px; }
.tabela-conta-corrente th.num { text-align: right; }

/* Interruptores da lista de documentos */
.interruptores { align-items: center; gap: 1rem; }
.interruptor-3 { position: relative; display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.interruptor-3 label { position: relative; padding: 0.38rem 0.95rem; border-radius: 999px; font-size: 0.88rem; cursor: pointer; user-select: none; color: var(--ink-muted); transition: background .15s, color .15s; }
.interruptor-3 input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor-3 label:has(input:checked) { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(28,43,60,0.25); }
.interruptor { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; user-select: none; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor .trilho { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #C8C2B4; transition: background .15s; flex: 0 0 auto; }
.interruptor .trilho::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform .15s; }
.interruptor input:checked + .trilho { background: var(--accent); }
.interruptor input:checked + .trilho::after { transform: translateX(18px); }
.interruptor input:focus-visible + .trilho { outline: 2px solid var(--accent); outline-offset: 2px; }
.interruptor small { color: var(--ink-faint); }
.filtros-efatura .botoes-estado { margin-bottom: 0.6rem; }
.filtros-efatura a.botao-estado { text-decoration: none; color: inherit; }
.pct-falta { font-size: 0.9rem; color: var(--ink-faint); font-family: 'Lato', system-ui, sans-serif; }
.filtros-efatura a.botao-estado.ativo { color: #fff; }
.efatura-topo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.efatura-topo .painel-filtros, .efatura-topo .resumo-totais { margin: 0; }
.resumo-efatura { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.resumo-efatura .cartao-total { min-width: 0; }
.efatura-topo > .linha-filtro { grid-column: 1 / -1; margin: 0; }
@media (max-width: 900px) { .efatura-topo { grid-template-columns: 1fr; } }
.pill.enviado { background: #E3EBD3; color: var(--ok); }
.barra-envio { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.popup-progresso { border: 0; border-radius: 16px; padding: 1.4rem 1.6rem; width: min(440px, 92vw); box-shadow: 0 18px 50px rgba(28,43,60,0.3); background: var(--surface); color: var(--ink); }
.popup-progresso::backdrop { background: rgba(28,43,60,0.45); }
.popup-progresso h2 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.barra-progresso { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 0.9rem 0 0.4rem; }
.barra-progresso > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }
.contagem-progresso { font-size: 0.85rem; color: var(--ink-muted); margin: 0 0 0.8rem; }
.recomendacao-adubo { margin-top: 1rem; padding: 0.9rem 1rem; border-radius: 12px; background: var(--gold-soft); }
.recomendacao-adubo h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.linha-recomendacao { display: flex; gap: 1rem; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-top: 1px solid rgba(0,0,0,0.06); }
tr.oferta-melhor { background: #F1F4E8; }
.recomendacao-adubo h4 { font-size: 0.92rem; margin: 0.9rem 0 0.2rem; }
.bloco-adubacao { margin: 1.1rem 0 0; padding: 0.9rem 1rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.bloco-adubacao legend { padding: 0 0.5rem; font-weight: 700; font-size: 0.95rem; }
.bloco-adubacao legend small { font-weight: 400; color: var(--ink-muted); margin-left: 0.4rem; }
.bloco-adubacao .campo-filtro input { background: var(--surface); }
.digitalizar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; max-width: 720px; }
.digitalizar .botao-camara { flex: 1 1 100%; text-align: center; font-size: 1.1rem; padding: 0.9rem; }
.estado-fila { flex: 1 1 100%; margin: 0.3rem 0 0; font-weight: 600; }
.fila-digitalizar { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; flex: 1 1 100%; }
.fila-digitalizar li { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; }
.fila-digitalizar img { width: 100%; height: 100%; object-fit: cover; }
.fila-digitalizar .estado-item { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.2rem 0.3rem; font-size: 0.7rem; background: rgba(28,43,60,0.75); color: #fff; text-align: center; }
.fila-digitalizar li.ok .estado-item { background: rgba(86,97,58,0.9); }
.fila-digitalizar li.erro { cursor: pointer; border-color: var(--danger); }
.fila-digitalizar li.erro .estado-item { background: rgba(147,80,63,0.95); }
.acoes-digitalizar { max-width: 720px; margin-top: 1rem; }
