/* Gráficos v2 (DESIGN-V2.md §5 e §7.4). Um SVG por gráfico, à largura real: rótulos sempre a 12 px. */

.chart-figure { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; cursor: crosshair; user-select: none; -webkit-user-select: none; overflow: visible; }
.chart:focus-visible { outline-offset: 6px; }

.chart .bar { fill: var(--bar); transform-box: fill-box; transform-origin: bottom; }
.chart .bar.p-vazio { fill: var(--tou-vazio); }
.chart .bar.p-cheias { fill: var(--tou-cheias); }
.chart .bar.p-fora_vazio { fill: var(--tou-fora-vazio); }
.chart .bar.p-simples { fill: var(--tou-simples); }
.chart .bar.p-ponta { fill: var(--tou-ponta); }
.chart .bar.is-partial { fill-opacity: 0.45; }
.chart .bar.is-incomplete { fill-opacity: 0.55; stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .bar.is-imported { fill: none; stroke: var(--bar); stroke-width: 1; }
.chart .bar.is-carried { fill: none; stroke: var(--bar); stroke-width: 1.5; }
.chart .bar.is-carried.p-vazio { stroke: var(--tou-vazio); }
.chart .bar.is-carried.p-ponta { stroke: var(--tou-ponta); }
.chart .bar.is-selected { fill: var(--bar-selected); fill-opacity: 1; }
.chart .bar.is-imported.is-selected, .chart .bar.is-carried.is-selected { fill: none; stroke: var(--bar-selected); stroke-width: 2; }
.chart .bar-missing { fill: none; stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .band-vazio { fill: var(--band-vazio); }
.chart .band-ponta { fill: var(--band-ponta); }
.chart .band-cheias, .chart .band-fora_vazio, .chart .band-simples { fill: none; }
.chart .strip-vazio { fill: var(--tou-vazio); }
.chart .strip-cheias, .chart .strip-fora_vazio, .chart .strip-simples { fill: var(--tou-cheias); }
.chart .strip-ponta { fill: var(--tou-ponta); }
.chart .band-label { fill: var(--text-muted); font-size: var(--fs-axis); font-family: var(--font-sans); letter-spacing: 0.04em; }
.chart .grid { stroke: var(--hairline); stroke-dasharray: 2 4; }
.chart .baseline { stroke: var(--hairline); }
.chart .axis-label { fill: var(--text-muted); font-size: var(--fs-axis); font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .chart-empty { fill: var(--text-muted); font-size: 14px; font-family: var(--font-sans); }
.chart .ghost { fill: none; stroke: var(--ghost); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
.chart .forecast { fill: none; stroke: var(--forecast); stroke-width: 1; stroke-dasharray: 3 2; }
.chart .now-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 1 3; }
.chart .cursor { stroke: var(--cursor); stroke-width: 1; pointer-events: none; }
.chart .float { fill: var(--bg); font-size: 13px; font-weight: 600; font-family: var(--font-sans); font-variant-numeric: tabular-nums; pointer-events: none; }
/* v3: o valor flutuante é uma pílula grafite com texto claro. */
.chart .float-bg { fill: var(--text); rx: 11px; pointer-events: none; }
.chart .line { fill: none; stroke: var(--bar); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-dot { fill: var(--bar); }
.chart .line-dot-end { fill: var(--bg); stroke: var(--bar-selected); stroke-width: 2; }
.chart .line-dot.is-selected { fill: var(--bar-selected); }
.chart .gap-mark { stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .h0 { fill: var(--heat-0); }
.chart .h1 { fill: var(--heat-1); }
.chart .h2 { fill: var(--heat-2); }
.chart .h3 { fill: var(--heat-3); }
.chart .h4 { fill: var(--heat-4); }
.chart .h-null { fill: none; stroke: var(--control-border); stroke-dasharray: 2 2; }
.chart .cell.is-selected { stroke: var(--cursor); stroke-width: 2; }
.chart .tick-step { stroke: var(--control-border); }
.chart .tick-current { stroke: var(--text); stroke-width: 1.5; }
.chart .tick-reco { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .peak { fill: var(--bar); }
.chart .peak-max { fill: var(--bar-selected); }
.chart .peak.is-selected { stroke: var(--cursor); stroke-width: 2; }
.chart .rail { stroke: var(--control-border); stroke-width: 1; }
.chart .label-strong { fill: var(--text); font-size: 13px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }

.chart-caption { min-height: var(--lh-small); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); font-size: var(--fs-label); line-height: 18px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; background: var(--bar); }
.sw-vazio { background: var(--tou-vazio); }
.sw-cheias { background: var(--tou-cheias); }
.sw-fora_vazio { background: var(--tou-fora-vazio); }
.sw-simples { background: var(--tou-simples); }
.sw-ponta { background: var(--tou-ponta); }
.sw-ghost { height: 0; border-top: 2px dashed var(--ghost); width: 18px; border-radius: 0; background: none; }
.sw-forecast { background: transparent; border: 1px dashed var(--forecast); }
.sw-imported { background: transparent; border: 1px solid var(--bar); }
.sw-missing { background: transparent; border: 1px dashed var(--warning); }
.heat-legend { display: inline-flex; gap: 2px; }
.heat-legend span { width: 14px; height: 10px; border-radius: 2px; }
.hl-0 { background: var(--heat-0); } .hl-1 { background: var(--heat-1); } .hl-2 { background: var(--heat-2); } .hl-3 { background: var(--heat-3); } .hl-4 { background: var(--heat-4); }


/* ---------- v3 (DESIGN-V3.md §5) ---------- */
/* Barras empilhadas por período (kWh): vazio em baixo, ponta em cima. */
.chart .seg.p-vazio { fill: var(--tou-vazio); }
.chart .seg.p-cheias { fill: var(--tou-cheias); }
.chart .seg.p-fora_vazio { fill: var(--tou-fora-vazio); }
.chart .seg.p-simples { fill: var(--tou-simples); }
.chart .seg.p-ponta { fill: var(--tou-ponta); }
.chart .stack.is-partial .seg { fill-opacity: 0.45; }
.chart .stack.is-incomplete .seg { fill-opacity: 0.55; }
.chart .stack.is-imported .seg { fill: none; stroke: var(--bar); stroke-width: 1; }
.chart .stack.is-selected .seg { fill: var(--bar-selected); fill-opacity: 1; }
/* Espelho por baixo do eixo (DESIGN-PRODUCAO-INJECAO §4.2): a injeção é medida (cheia), o autoconsumo estimado
   (esbatido). Cresce do eixo para baixo. A escolhida ganha contorno, não grafite: perdia a cor da fonte. */
.chart .seg.p-inj, .chart .seg.p-auto { transform-box: fill-box; transform-origin: top; }
.chart .seg.p-inj { fill: var(--flow-solar); }
.chart .seg.p-auto { fill: var(--flow-solar); fill-opacity: 0.45; }
.chart .mirror.is-partial .seg { fill-opacity: 0.45; }
/* Produção trazida de uma falta do inversor: a mesma marca tracejada da falta; não manda na escala. */
.chart .mirror-carried { fill: none; stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.chart .mirror.is-selected .seg { stroke: var(--cursor); stroke-width: 1; }
.chart .mirror-missing { fill: none; stroke: var(--warning); stroke-width: 1; stroke-dasharray: 2 2; }
.swatch.sw-solar-soft { background: var(--flow-solar); opacity: 0.45; }
/* Acumulado do mês */
.chart .line-load { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.chart .line-forecast { fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-dasharray: 3 5; stroke-linecap: round; }
.chart .dot-now { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
/* Anel */
.chart.donut { width: 140px; height: 140px; flex-shrink: 0; cursor: default; }
.donut-track { fill: none; stroke: var(--surface-2); }
.d-vazio { fill: none; stroke: var(--tou-vazio); }
.d-cheias { fill: none; stroke: var(--tou-cheias); }
.d-fora_vazio { fill: none; stroke: var(--tou-fora-vazio); }
.d-simples { fill: none; stroke: var(--tou-simples); }
.d-ponta { fill: none; stroke: var(--tou-ponta); }
.d-solar { fill: none; stroke: var(--flow-solar); }
.d-grid { fill: none; stroke: var(--flow-grid); }
.d-battery { fill: none; stroke: var(--flow-battery); }
.donut-num { fill: var(--text); font-size: 24px; font-weight: 300; text-anchor: middle; font-variant-numeric: tabular-nums; }
.donut-sub { fill: var(--text-muted); font-size: 13px; text-anchor: middle; }
.chart .cell { rx: 3px; }
