/* Cores dos gráficos validadas (dataviz validate_palette: faixa de luminosidade, croma, daltonismo, contraste),
   no claro e no escuro. Situação: --g-prazo (a vencer, azul) · --g-ok (verde) · --g-atencao (âmbar) · --g-ruim (vermelho).
   --g-fin = verde do Financeiro para a série principal; --g-fin-2 (roxo) para a segunda série. */
:root { --g-prazo: #2F6FC4; --g-ok: #0E7A5A; --g-atencao: #D9A520; --g-ruim: #B4232F; --g-fin: #0B8A72; --g-fin-2: #4A5163;
  --g-reduz: #7A4A80; --g-laranja: #D2691E; --g-atencao-claro: #E9C46A; --g-atraso-pago: #9C6B00; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --g-prazo: #5089DB; --g-ok: #2AAE6E; --g-atencao: #C08A1E; --g-ruim: #D9404F; --g-fin: #2AA88E; --g-fin-2: #AEB4C2;
    --g-reduz: #9A7A9C; --g-laranja: #E07B3A; --g-atencao-claro: #E6C66E; --g-atraso-pago: #A87A1E; }
}
:root[data-theme="dark"] { --g-prazo: #5089DB; --g-ok: #2AAE6E; --g-atencao: #C08A1E; --g-ruim: #D9404F; --g-fin: #2AA88E; --g-fin-2: #AEB4C2;
  --g-reduz: #9A7A9C; --g-laranja: #E07B3A; --g-atencao-claro: #E6C66E; --g-atraso-pago: #A87A1E; }

/* Componentes de gráfico novos (graficos.js). Só usa as variáveis de cor do estilo.css. */

/* ---------- legenda ---------- */
.g-legenda { row-gap: 6px; }
.g-leg { width: 12px; height: 10px; border-radius: 3px; display: inline-block; background: var(--c, var(--text-muted)); flex: none; }
.g-leg.linha { height: 3px; border-radius: 2px; width: 16px; }
.g-leg.tracejado { height: 0; width: 16px; border-top: 2px dashed var(--c, var(--text-muted)); background: none; border-radius: 0; }
.g-leg.vazado { background: color-mix(in srgb, var(--text-muted) 14%, transparent); box-shadow: inset 0 0 0 1.4px var(--text-secondary); }
.g-leg.hachura { background: repeating-linear-gradient(45deg, var(--border-strong) 0 1.5px, transparent 1.5px 4px); box-shadow: inset 0 0 0 1px var(--border); }
.g-leg.marca { height: 3px; width: 16px; background: var(--c, var(--text-primary)); }
.g-leg.ponto { width: 10px; height: 10px; border-radius: 50%; }
.g-leg.oco { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-1); box-shadow: inset 0 0 0 2px var(--text-secondary); }
.g-leg.faixa { opacity: .3; height: 10px; }
.g-leg.claro { background: var(--text-muted); opacity: .45; }
.g-leg.vazio { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.g-leg.vertical { width: 2px; height: 12px; border-radius: 0; background: var(--border-strong); }
.g-leg.meta { width: 0; height: 12px; border-radius: 0; background: none; border-left: 3px dotted var(--text-primary); }
.g-leg.marca.esperado, .g-bullet-leg .g-leg.marca { width: 0; height: 12px; border-left: 2px dotted var(--text-secondary); background: none; border-radius: 0; }

/* ---------- marcas dentro dos gráficos ---------- */
.grafico .g-fundo { fill: color-mix(in srgb, var(--text-muted) 14%, transparent); stroke: var(--text-secondary); stroke-width: 1.4; }
.grafico .g-hach { stroke: var(--border-strong); stroke-width: 1.5; }
.grafico .g-semdado { opacity: .8; }
.grafico .g-zero { stroke: var(--text-muted); stroke-width: 1; }
.grafico .g-separador { stroke: var(--border-strong); stroke-width: 1; }
.grafico .g-guia { fill: var(--text-primary); fill-opacity: .05; pointer-events: none; }
.grafico .g-marca { stroke: var(--c, var(--text-primary)); stroke-width: 2.5; stroke-linecap: round; }
.grafico .g-ponto { stroke: var(--surface-1); stroke-width: 2; }
.grafico .g-ponto.oco { fill: var(--surface-1); stroke: var(--c, var(--text-secondary)); stroke-width: 2; }
.grafico .g-area { fill: var(--c, var(--text-muted)); fill-opacity: var(--o, .2); stroke: none; }
.grafico .g-txt-valor { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.grafico .g-txt-valor.forte { fill: var(--text-primary); }
.grafico .g-txt-semdado { fill: var(--text-muted); font-size: 10px; font-weight: 600; }
.grafico .g-txt-parcial { fill: var(--text-muted); font-size: 10px; }
.grafico .g-txt-destaque { fill: var(--text-secondary); font-size: 11px; font-weight: 700; }
.grafico .g-txt-destaque.ruim { fill: var(--bad); }
.grafico .g-fim { fill: var(--c, var(--text-secondary)); font-size: 11px; font-weight: 500; }
.grafico .g-fim.forte { font-weight: 700; }
.grafico .g-conector { stroke: var(--text-muted); stroke-width: 1; }
.grafico .g-marcax { stroke: var(--border-strong); stroke-width: 1; }
.grafico .g-haste { stroke: var(--border-strong); stroke-width: 3; stroke-linecap: round; }
.grafico .g-rot-linha { fill: var(--text-secondary); font-size: 12px; font-weight: 600; }
.dica .g-aviso { color: var(--text-muted); font-style: italic; display: block; max-width: 260px; white-space: normal; }

/* ---------- bullet ---------- */
.g-bullet { margin-top: 8px; }
.g-bullet .trilho { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); }
.g-bullet .valor { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--s-sol); }
.g-bullet .meta { position: absolute; top: -4px; bottom: -4px; width: 0; margin-left: -1.5px; border-left: 3px dotted var(--text-primary); }
.g-bullet .marca { position: absolute; top: -4px; bottom: -4px; width: 0; margin-left: -1.5px; border-left: 3px dotted var(--text-primary); opacity: .75; }
.g-bullet-leg { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.g-bullet-leg span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- sparkline no KPI ---------- */
.kpi.com-spark .g-kpi-spark { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.g-kpi-spark span { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.kpi.com-spark .g-kpi-spark { flex-wrap: wrap; }
.kpi.com-spark .g-kpi-spark { min-width: 0; }
.g-spark { max-width: 70%; height: auto; }
.g-spark { display: block; flex: none; overflow: visible; }

/* ---------- barras horizontais ---------- */
.g-barrash { display: grid; gap: 8px; padding: 4px 0; }
.g-barrash .linha { display: grid; grid-template-columns: clamp(84px, 24%, 140px) 1fr; gap: 10px; align-items: center; }
.g-barrash .rot { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.g-barrash .rot small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }
.g-barrash .trilho { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 18px; }
.g-barrash .trilho span { height: 18px; border-radius: 0; min-width: 0; }
.g-barrash .trilho span:last-of-type { border-radius: 0 3px 3px 0; }
.g-barrash .trilho b { font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; color: var(--text-primary); }

/* ---------- barras 100% ---------- */
.g-barras100 { display: grid; gap: 10px; padding: 4px 0; }
.g-barras100 .linha { display: grid; grid-template-columns: clamp(72px, 26%, 140px) 1fr; gap: 10px; align-items: center; }
.g-barras100 .rot { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.g-barras100 .trilho { display: flex; gap: 2px; height: 26px; }
.g-barras100 .trilho span { display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 0; }
.g-barras100 .trilho span:first-child { border-radius: 4px 0 0 4px; }
.g-barras100 .trilho span:last-child { border-radius: 0 4px 4px 0; }
.g-barras100 em { font-style: normal; font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; text-shadow: 0 1px 2px rgba(0,0,0,.35); }

/* ---------- rosca ---------- */
.g-rosca { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.g-rosca svg { flex: none; }
.g-rosca .g-rosca-valor { fill: var(--text-primary); font-size: 17px; font-weight: 600; }
.g-rosca .g-rosca-rot { fill: var(--text-muted); font-size: 10px; }
.g-rosca-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12px; min-width: 200px; flex: 1; }
.g-rosca-lista li { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; }
.g-rosca-lista i { width: 10px; height: 10px; border-radius: 3px; }
.g-rosca-lista b { font-weight: 600; }
.g-rosca-lista small { color: var(--text-muted); min-width: 64px; text-align: right; }

/* ---------- calendário de calor ---------- */
.grafico .g-cel { stroke: none; fill: var(--c, var(--surface-3)); }
.grafico .g-cel.vazia { fill: transparent; stroke: var(--border-strong); stroke-width: 1; }
.grafico .g-cel.vazia.sem-valor { stroke: var(--border-strong); } /* fill = hachura (estilo inline), dia com leitura e sem valor */
.grafico .g-cel:hover { stroke: var(--text-primary); stroke-width: 1.5; }

/* ---------- sankey ---------- */
.grafico .g-fluxo { fill: none; stroke: var(--c, var(--text-muted)); stroke-opacity: .32; }
.grafico .g-fluxo:hover { stroke-opacity: .55; }
.grafico .g-sk-rot { fill: var(--text-primary); font-size: 12px; font-weight: 600; }
.grafico .g-sk-fundo { fill: var(--surface-1); opacity: .88; pointer-events: none; }
.grafico .g-sk-rot, .grafico .g-sk-val { pointer-events: none; }
.grafico .g-sk-val { fill: var(--text-secondary); font-size: 11px; }

/* ---------- pequenos múltiplos ---------- */
.g-multiplos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 14px 22px; }
.g-mult-item { min-width: 0; }
.g-mult-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.g-mult-cab span { display: inline-flex; align-items: center; gap: 6px; }
.g-mult-cab i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.g-mult-cab b { color: var(--text-primary); }
.g-mult-cab small { font-weight: 400; color: var(--text-muted); }
.g-multiplos .grafico { overflow: visible; }

/* ---------- caminho do dinheiro: sankey no computador, caixas no celular ---------- */
.g-so-largo { display: block; }
.g-so-estreito { display: none; }
@media (max-width: 760px) {
  .g-so-largo { display: none; }
  .g-so-estreito { display: block; }
}

@media (prefers-reduced-motion: no-preference) {
  .g-bullet .valor { transition: width .5s ease; }
}
.grafico .g-guia-l { stroke: var(--text-muted); stroke-width: 1; opacity: .7; pointer-events: none; }

/* ---------- dispersão ---------- */
.grafico .g-pt { fill: var(--c); fill-opacity: .7; stroke: var(--surface-1); stroke-width: 1; }
.grafico .g-pt.alerta { fill-opacity: 1; stroke: var(--bad); stroke-width: 2.2; }
.grafico .g-pt:hover { fill-opacity: 1; stroke: var(--text-primary); }
.grafico .g-ref-disp { stroke: var(--c); stroke-width: 1.6; stroke-dasharray: 6 4; opacity: .9; }
.grafico .g-rot-eixo { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.g-leg.alerta { width: 10px; height: 10px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
/* ações do cabeçalho do painel (filtros do gráfico + "Ver tabela") quebram linha no celular */
.painel-cab .acoes { flex-wrap: wrap; justify-content: flex-end; }

/* marcas verticais da faixa (fechamento, pagamento…) */
.grafico .g-marca-v { stroke: var(--text-muted); stroke-width: 1; opacity: .8; }
.grafico .g-marca-v.pagamento { stroke: var(--s-a); stroke-width: 1.5; opacity: 1; }
.grafico .g-marca-v-txt { fill: var(--text-secondary); font-size: 10px; font-weight: 600; }
.grafico .g-marca-v-txt.pagamento { fill: var(--s-a); }

/* ---------- barra única dividida ---------- */
.g-barra-unica-total { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin: 2px 0 6px; }
.g-barra-unica-total b { color: var(--text-primary); font-size: 14px; }
.g-barra-unica { display: flex; gap: 2px; height: 34px; }
.g-barra-unica span { display: flex; align-items: center; justify-content: center; min-width: 3px; overflow: hidden; }
.g-barra-unica span:first-child { border-radius: 5px 0 0 5px; }
.g-barra-unica span:last-child { border-radius: 0 5px 5px 0; }
.g-barra-unica em { font-style: normal; font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.4); padding: 0 4px; }
.g-barra-unica-lista { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; font-size: 12px; }
.g-barra-unica-lista li { display: grid; grid-template-columns: 12px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; }
.g-barra-unica-lista li.zero { opacity: .55; }
.g-barra-unica-lista i { width: 10px; height: 10px; border-radius: 3px; grid-row: 1 / span 2; }
.g-barra-unica-lista span small { display: block; color: var(--text-muted); font-size: 11px; }
.g-barra-unica-lista b { font-weight: 600; text-align: right; }
.g-barra-unica-lista li > small { grid-column: 3; text-align: right; color: var(--text-muted); }
.grafico .g-marca-v.chuva { stroke: var(--s-chuva); opacity: .3; }
.grafico .g-marca-v-txt.chuva { fill: var(--s-chuva); }
.grafico .g-marca-v.limpeza { stroke: var(--s-a); stroke-dasharray: 3 3; opacity: .8; }
.grafico .g-marca-v-txt.limpeza { fill: var(--s-a); }
.g-leg.chuva { width: 2px; height: 12px; border-radius: 0; background: var(--s-chuva); }
.g-leg.limpeza { width: 0; height: 12px; border-radius: 0; background: none; border-left: 2px dashed var(--s-a); }
/* ---------- limpeza ---------- */
.g-recomenda { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.g-recomenda.chuva { color: var(--s-chuva); }
.g-info { display: inline-flex; vertical-align: middle; color: var(--text-muted); cursor: help; }

/* ---------- eventos no eixo e no calendário ---------- */
.grafico .g-evento { fill: var(--c); stroke: var(--surface-1); stroke-width: 1.5; cursor: pointer; }
.grafico .g-evento:hover { stroke: var(--text-primary); }
.grafico .g-evento-cel { fill: var(--text-primary); stroke: var(--surface-1); stroke-width: 1; cursor: pointer; }
.g-leg.evento { width: 9px; height: 9px; border-radius: 50%; }
.dica .g-evento-dica i { width: 8px; height: 8px; border-radius: 50%; }
.g-bullet-estado { font-weight: 600; }
/* selo "a vencer": azul (em aberto no prazo); vencido continua vermelho */
.selo.prazo { background: color-mix(in srgb, var(--g-prazo) 16%, var(--surface-1)); color: var(--g-prazo); }

/* período incompleto: desbotado (no claro fica mais claro; no escuro também clareia, em vez de sumir no fundo) */
.grafico .g-parcial { fill-opacity: .4; stroke-opacity: .4; }
/* no escuro também só reduz a opacidade (~40%): clarear dava a impressão contrária */
.g-leg.claro { background: var(--text-muted); opacity: .55; }
/* barra única: no celular a lista vira 1 coluna */
@media (max-width: 520px) { .g-barra-unica-lista { grid-template-columns: 1fr; } }

/* anos em sequência (mais antigo = mais apagado); o ano atual usa a cor do texto */
:root { --g-ano-1: #A7B4CF; --g-ano-2: #7186B4; --g-ano-3: #3D5794; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --g-ano-1: #5F7099; --g-ano-2: #8597C2; --g-ano-3: #AFBEE3; } }
:root[data-theme="dark"] { --g-ano-1: #5F7099; --g-ano-2: #8597C2; --g-ano-3: #AFBEE3; }
/* botões de alternância dentro do gráfico: cor da área (igual no claro e no escuro) */
.segmentos.g-seg button[aria-pressed="true"] { background: var(--ativo-fundo); color: var(--ativo-texto); }
/* cartões de limpeza: 1 coluna no celular */
@media (max-width: 520px) { .kpis.g-kpis-1col { grid-template-columns: 1fr; } }
.g-legenda .g-leg { align-self: center; flex: none; }
.grafico .referencia.emergencial { stroke: var(--g-ruim); }
/* ---------- limpeza: sujeira + chuva (telas/usinas/limpeza-grafico.js) ---------- */
/* chuva: "lavou" e "não lavou" com contraste ≥ 3:1 sobre o cartão nos dois temas (claro 6,5 e 3,3; escuro 7,7 e 3,7) */
:root { --g-chuva-lava: #1E58AB; --g-chuva-fraca: #6390D2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --g-chuva-lava: #8FB0E6; --g-chuva-fraca: #4A76BA; } }
:root[data-theme="dark"] { --g-chuva-lava: #8FB0E6; --g-chuva-fraca: #4A76BA; }
.g-suj-painel { scroll-margin-top: 84px; }
.grafico .g-suj-alem { fill: var(--text-muted); fill-opacity: .07; }
.grafico .g-suj-futuro { fill: var(--text-muted); fill-opacity: .035; }
.grafico .g-suj-txt-alem { fill: var(--text-muted); font-size: 10px; font-weight: 600; }
.grafico .referencia.g-suj-lim3 { stroke: var(--g-atencao); stroke-width: 1.2; }
.grafico .g-suj-hoje { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 2 3; }
.grafico .g-suj-txt-hoje { fill: var(--text-primary); font-size: 10.5px; font-weight: 700; }
.grafico .g-suj-claro { opacity: .45; }
.grafico .g-suj-base { stroke: var(--border-strong); stroke-width: 1; }
.grafico .g-suj-10mm { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.g-leg.g-leg-10mm { height: 0; width: 16px; border-top: 1px dashed var(--text-muted); background: none; border-radius: 0; }
.grafico .g-suj-txt-soma { fill: var(--text-secondary); font-size: 9.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round; }
@media (min-width: 761px) { .g-legenda span:has(> .g-leg-so-celular) { display: none; } }
.grafico .g-suj-txt-10mm { fill: var(--text-secondary); font-size: 9.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round; }
.grafico .g-suj-txt-banda { fill: var(--text-secondary); font-size: 10.5px; font-weight: 600; }
.grafico .g-suj-chuva { fill: var(--g-chuva-fraca); }
.grafico .g-suj-chuva.lava { fill: var(--g-chuva-lava); }
.grafico .g-suj-corte { stroke: var(--surface-1); stroke-width: 2; }
.grafico .g-suj-alvo { fill: var(--surface-1); stroke: var(--text-secondary); stroke-width: 2; }
.grafico .g-suj-alvo.limite { stroke: var(--g-atencao); }
.grafico .g-suj-alvo.chuva { stroke: var(--g-chuva-lava); }
.grafico .g-suj-nota { fill: var(--text-primary); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface-1); stroke-width: 4px; stroke-linejoin: round; }
.grafico .g-suj-txt-corte { fill: var(--c, var(--text-secondary)); font-size: 10.5px; font-weight: 700; }
.g-leg.pontilhado { height: 0; width: 16px; border-top: 2px dotted var(--c, var(--text-muted)); background: none; border-radius: 0; }
.g-leg.g-leg-lava { background: var(--g-chuva-lava); }
.g-leg.g-leg-fraca { background: var(--g-chuva-fraca); }
.g-suj-notas { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; font-size: 12px; font-weight: 600; color: var(--text-primary); }
.g-suj-notas span { display: inline-flex; align-items: center; gap: 6px; }
.g-suj-notas-m { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--text-secondary); flex: none; }
.g-suj-notas-m.limite { box-shadow: inset 0 0 0 2px var(--g-atencao); }
.g-suj-notas-m.chuva { box-shadow: inset 0 0 0 2px var(--g-chuva-lava); }
