/* financeiro.css :: Financeiro e Aditivos (js/financeiro.js), inclusive o fluxo de caixa (classes fc-),
   e caixa "Enviar ao cliente pelo portal" (js/proposta.js) */

.fn-wrap { display: flex; flex-direction: column; gap: 14px; max-width: 1200px; min-width: 0; }
.fn-wrap .sc { margin-bottom: 0; }
.fn-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fn-topo .rd-dica { margin: 2px 0 0; }
.fn-tabs { margin-bottom: 0; }
.fn-badge { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px; border-radius: 10px; background: var(--navy-800);
  color: #fff; font-size: 10px; letter-spacing: 0; text-align: center; vertical-align: 1px; }
.fn-badge-alerta { background: #B42318; }
.fn-mt { margin-top: 12px; }
.fn-sem-mb { margin-bottom: 0; }
.fn-primeiro { order: -1; }
.fn-fora { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 0; }

/* botões do módulo: sem largura mínima; no celular quebram linha em vez de estourar */
.fn-wrap .btn, .fn-portal .btn { min-width: 0; }
@media (max-width: 480px) {
  .fn-wrap .btn, .fn-portal .btn { white-space: normal; line-height: 1.25; text-align: left; }
}

/* campo de data (o estilo global não cobre type=date) */
.fn-wrap input[type=date] { font-family: var(--font-ui); font-size: 13px; font-weight: 500; color: var(--ink); background: var(--bg-surface);
  border: 1px solid #D1D5E8; border-radius: var(--r-sm); padding: 7px 10px; width: 100%; min-height: 37px; outline: none; line-height: 1.4; }
.fn-wrap input[type=date]:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(22,34,71,0.09); }
.fn-wrap textarea { min-height: 64px; }

/* números do topo */
.fn-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.fn-stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-card);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fn-stat-rot { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); }
.fn-stat-val { font-family: var(--font-ui); font-size: 21px; font-weight: 700; color: var(--navy-800); font-variant-numeric: tabular-nums;
  line-height: 1.2; overflow-wrap: anywhere; }
.fn-stat-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }
.fn-stat-alerta { border-left: 4px solid #B42318; }
.fn-stat-alerta .fn-stat-val { color: #B42318; }
@media (max-width: 480px) {
  .fn-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fn-stat { padding: 12px; }
  .fn-stat-val { font-size: 17px; }
}

/* filtro de projeto */
.fn-filtro { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fn-filtro label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); }
.fn-filtro select { flex: 1 1 220px; max-width: 420px; min-width: 0; }

/* listas (parcelas, aditivos, retornos) */
.fn-lista { display: flex; flex-direction: column; }
.fn-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "info valor acoes" "form form form";
  gap: 8px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.fn-item:first-child { padding-top: 0; }
.fn-item:last-child { border-bottom: 0; padding-bottom: 0; }
.fn-item-info { grid-area: info; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.fn-item-info strong { color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.fn-item-sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.fn-item-motivo { color: var(--body); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.fn-item-valor { grid-area: valor; font-weight: 700; color: var(--navy-800); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fn-item-acoes { grid-area: acoes; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.fn-item-atraso .fn-item-valor { color: #B42318; }
.fn-item-edit { display: block; }
@media (max-width: 760px) {
  .fn-item { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info valor" "acoes acoes" "form form"; }
  .fn-item-acoes { justify-content: flex-start; }
}
/* item sem botões: o valor encosta na direita */
.fn-item:not(:has(.fn-item-acoes)) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "info valor" "form form"; }

.fn-tag { display: inline-block; font-size: 11px; font-weight: 700; line-height: 1.35; padding: 2px 8px; border-radius: 20px;
  background: var(--navy-100); color: var(--navy-700); overflow-wrap: anywhere; }
.fn-ok { background: #E7F6EC; color: #067647; }
.fn-atraso { background: #FEE4E2; color: #B42318; }
.fn-hoje { background: var(--orange-light); color: #9A4A12; }

/* formulário curto dentro de um item (pagamento, parcela do aditivo) */
.fn-pagar { grid-area: form; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end;
  background: var(--bg-zebra); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; min-width: 0; }
.fn-pagar-acoes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }

/* divisão por serviço */
.fn-serv { margin-bottom: 14px; }
.fn-serv-top { display: flex; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; font-size: 13px; color: var(--body); margin-bottom: 6px; }
.fn-serv-top strong { color: var(--ink); }
.fn-barra { height: 12px; }
.fn-barra-tot { display: block; height: 100%; background: var(--navy-100); border-radius: 6px; overflow: hidden; }
.fn-barra-rec { display: block; height: 100%; background: var(--orange); }

/* revisões */
.fn-rev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 12px; align-items: start; }
.fn-rev { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-card);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fn-rev-top { display: flex; flex-direction: column; gap: 2px; }
.fn-rev-top strong { color: var(--ink); overflow-wrap: anywhere; }
.fn-rev-linha { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.fn-rev-cont { display: flex; flex-direction: column; align-items: flex-end; }
.fn-rev-num { font-size: 30px; font-weight: 700; color: var(--navy-800); line-height: 1; font-variant-numeric: tabular-nums; }
.fn-rev-msg { font-size: 13px; color: var(--body); line-height: 1.45; }
.fn-alerta { background: #FEF3F2; border: 1px solid #FECDCA; color: #912018; border-radius: var(--r-md); padding: 10px 12px; font-weight: 600; }
.fn-limite { background: var(--orange-light); border: 1px solid var(--orange-border); color: #7A3A0C; border-radius: var(--r-md); padding: 10px 12px; }
.fn-dentro { color: #067647; }
.fn-rev-btn { align-self: flex-start; }
.fn-rev-btn[hidden] { display: none; }
.fn-rev-det summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy-700); }
.fn-rev-det ul { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.fn-rev-det li { font-size: 13px; color: var(--body); line-height: 1.4; overflow-wrap: anywhere; }
.fn-rev-det small { display: block; color: var(--muted); font-size: 11.5px; }

/* funil comercial */
.fn-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 900px) { .fn-board { grid-template-columns: minmax(0, 1fr); } }
.fn-col { background: var(--bg-zebra); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fn-col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; font-weight: 700; color: var(--ink);
  font-size: 14px; padding: 2px 4px 8px; border-bottom: 3px solid var(--navy-700); }
.fn-col-head span { font-size: 12px; font-weight: 600; color: var(--muted); }
.fn-col-negociacao .fn-col-head { border-color: var(--orange); }
.fn-col-fechado .fn-col-head { border-color: #12B76A; }
.fn-col-perdido .fn-col-head { border-color: #B42318; }
.fn-col > .rd-dica { padding: 0 4px; }
.fn-fcard { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-card);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fn-fcard > strong { color: var(--ink); overflow-wrap: anywhere; }
.fn-fcard-acoes { display: flex; flex-wrap: wrap; gap: 6px; }

/* proposta: caixa "Enviar ao cliente pelo portal" (js/proposta.js) */
.fn-portal { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-zebra); }
.fn-portal[hidden] { display: none; }
.fn-portal-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); }
.fn-portal-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.fn-portal-ok { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: #067647; font-weight: 600; }
.fn-portal-ok .av-ic { width: 20px; height: 20px; flex-shrink: 0; }
.fn-portal-erro { font-size: 13px; color: #B42318; }

/* ===== fluxo de caixa (aba "Fluxo de caixa", Visão geral e cobrança) ===== */
/* valores dos cartões de número: quebram entre "R$" e o número, nunca no meio do número */
.fn-stat-val { overflow-wrap: break-word; }
@media (min-width: 761px) {
  .fc-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fc-stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.fc-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.fc-subs .pj-chip, .fc-atalhos .pj-chip, .fc-linha-ctrl .pj-chip { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--navy-700); }
.fc-subs .pj-chip.on, .fc-atalhos .pj-chip.on, .fc-linha-ctrl .pj-chip.on { color: #fff; }
.fc-per { display: flex; align-items: flex-end; gap: 10px 12px; flex-wrap: wrap; }
.fc-per .field { flex: 0 1 130px; min-width: 110px; }
.fc-atalhos { flex: 1 1 260px; }
.fc-linha-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.fc-mesnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fc-mesnav strong { font-size: 15px; color: var(--ink); min-width: 150px; text-align: center; }
.fc-mesnav .btn { padding: 6px 12px; font-size: 13px; }
.fc-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--body); line-height: 1.4; margin: 6px 0; cursor: pointer; }
.fc-check input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; accent-color: var(--orange); }
.fc-neg { color: #B42318 !important; }
.fc-zero { color: var(--muted); font-weight: 400; }
.fc-forte { font-weight: 700; }
.fc-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--navy-700); text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.fc-link:hover { color: var(--orange); }
.fc-proj-msg { font-size: 13.5px; color: var(--body); line-height: 1.45; margin: 10px 0 4px; }
.fc-proj-msg strong { color: var(--navy-800); }
.fc-nw { white-space: nowrap; }
.fn-wrap .sc-body > .rd-dica + .fn-lista { margin-top: 12px; }

/* gráficos (SVG). Entradas #3B5BA5 e saídas #E27526: par validado para daltonismo (ΔE 26 protan) */
.fc-graf { display: block; width: 100%; height: auto; max-width: 100%; overflow: visible; font-family: var(--font-ui); }
.fc-g-grade { stroke: var(--border); stroke-width: 1; }
.fc-g-zero { stroke: #B8BFD0; stroke-width: 1; }
.fc-g-eixo { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.fc-g-atual { fill: var(--ink); font-weight: 700; }
.fc-g-ent { fill: #3B5BA5; }
.fc-g-sai { fill: #E27526; }
.fc-g-prev { opacity: .38; }
.fc-g-alvo { fill: transparent; cursor: default; }
.fc-g-alvo:hover { fill: rgba(22,34,71,.06); }
.fc-g-linha { fill: none; stroke: #3B5BA5; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fc-g-linha-prev { stroke-dasharray: 5 4; }
.fc-g-ponto { fill: #3B5BA5; stroke: var(--bg-surface); stroke-width: 2; }
.fc-g-ponto-neg { fill: #B42318; }
.fc-g-rot { fill: var(--ink); font-size: 11.5px; font-weight: 700; }
.fc-leg { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--body); margin-bottom: 8px; }
.fc-leg span { display: inline-flex; align-items: center; gap: 6px; }
.fc-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.fc-sw-ent { background: #3B5BA5; }
.fc-sw-sai { background: #E27526; }
.fc-sw-prev { background: linear-gradient(90deg, rgba(59,91,165,.38) 50%, rgba(226,117,38,.38) 50%); }

/* tabelas: no celular cada linha vira um cartão (sem rolagem lateral) */
.fc-tab { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.fc-tab th, .fc-tab td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.fc-tab thead th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--bg-zebra); }
.fc-tab th[scope=row], .fc-tab thead th:first-child { text-align: left; color: var(--ink); font-weight: 600; white-space: normal; }
.fc-tab thead th:first-child { color: var(--muted); font-weight: 700; }
.fc-num { font-variant-numeric: tabular-nums; color: var(--body); }
.fc-tab tfoot th, .fc-tab tfoot td { font-weight: 700; border-top: 2px solid var(--navy-border); border-bottom: 0; background: var(--bg-zebra); }
.fc-tr-atual th, .fc-tr-atual td { background: var(--orange-light); }
.fc-tr-prev th, .fc-tr-prev td { color: var(--muted); }
.fc-tr-prev .fc-forte { color: var(--navy-700); }
.fc-tab .fn-tag { margin-left: 4px; font-size: 10px; vertical-align: 1px; }
@media (max-width: 760px) {
  .fc-tab, .fc-tab tbody, .fc-tab tfoot, .fc-tab tr, .fc-tab th, .fc-tab td { display: block; width: 100%; }
  .fc-tab thead { display: none; }
  .fc-tab tr { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; padding: 6px 10px; background: var(--bg-surface);
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 10px; }
  .fc-tab th[scope=row] { grid-column: 1 / -1; border-bottom: 1px solid var(--border); padding: 4px 0 6px; font-size: 14px; }
  .fc-tab td { border: 0; padding: 4px 0; text-align: left; white-space: normal; display: flex; flex-direction: column; gap: 1px; }
  .fc-tab td::before { content: attr(data-l); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .fc-tab td.fc-vazio, .fc-tab td.fc-zero:not(.fc-forte) { display: none; } /* no celular, valor zerado sai do cartão */
  .fc-tab td { font-size: 12.5px; }
  .fc-tab tfoot tr { border-top: 2px solid var(--navy-border); }
  .fc-tab tfoot th, .fc-tab tfoot td { border-top: 0; background: none; }
  .fc-tr-atual, .fc-tr-atual th, .fc-tr-atual td { background: var(--orange-light); }
}

/* DRE */
.fc-dre { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.fc-dre-l { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.fc-dre-l:last-child { border-bottom: 0; }
.fc-dre-l > span:first-child { overflow-wrap: anywhere; min-width: 0; }
.fc-dre-tot { font-weight: 700; color: var(--ink); background: var(--bg-zebra); }
.fc-dre-sub { padding-left: 26px; color: var(--body); }
.fc-dre-sub small { color: var(--muted); font-size: 11.5px; margin-right: 8px; }
.fc-dre-res { font-weight: 700; font-size: 15px; color: var(--navy-800); background: var(--navy-100); }
.fc-dre-res.fc-neg .fc-num { color: #B42318; }
.fc-meta { margin: 12px 0 0; font-size: 13.5px; line-height: 1.45; }
.fc-meta.fn-dentro { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; background: #ECFDF3; border: 1px solid #ABEFC6; border-radius: var(--r-md); padding: 10px 12px; }
.fc-meta .av-ic { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* importar da Hora Técnica */
.fc-imp-resumo { font-size: 13.5px; color: var(--body); margin: 12px 0 6px; }
.fc-imp-lista { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-md); max-height: 280px; overflow-y: auto; }
.fc-imp-lista li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--ink); }
.fc-imp-lista li:last-child { border-bottom: 0; }
.fc-imp-lista li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.fc-imp-lista li > span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.fc-imp-lista small { display: block; color: var(--muted); font-size: 11.5px; }
.fc-imp-existe { color: var(--muted) !important; background: var(--bg-zebra); }
.fc-imp-existe > span:last-child { font-weight: 400; }

/* cobrança pelo WhatsApp */
.fc-cobrar .fc-cob-largo { grid-column: 1 / -1; }
.fc-cobrar textarea { width: 100%; min-height: 150px; line-height: 1.45; }
.fc-cobrar .rd-dica { margin: 0; }
.fc-cobrar a.btn { text-decoration: none; }

/* ===== Pagamentos do cliente (aba pagamentos) ===== */
.fn-pg-cli { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; margin: 0; font-size: 13.5px; color: var(--body); line-height: 1.4; }
.fn-pg-cli strong { color: var(--ink); overflow-wrap: anywhere; }
.fn-pg-cli .av-ic { width: 18px; height: 18px; flex-shrink: 0; }
.fn-pg-sub { font-family: var(--font-ui); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--navy-700); margin: 0 0 10px; }
.fn-pg-grupo + .fn-pg-grupo { margin-top: 18px; }
.fn-pg-vencidas { background: #FEF3F2; border: 1px solid #FECDCA; border-left: 4px solid #B42318; border-radius: var(--r-md); padding: 12px; }
.fn-pg-vencidas .fn-pg-sub { color: #B42318; }
.fn-pg-vencidas .fn-item { border-bottom-color: #FECDCA; }
.fn-pg-nota { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--orange-light); border: 1px solid var(--orange-border);
  color: #7A3A0C; font-size: 13px; line-height: 1.45; }
.fn-pg-mini { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0 0 12px; font-size: 13px; color: var(--body); }
.fn-pg-mini strong { color: var(--navy-800); font-variant-numeric: tabular-nums; }
.fn-pg-neg .fc-num { color: #B42318; font-weight: 700; }
.fn-wrap .sc-body > .fn-serv + .fc-dre { margin-top: 4px; }
