:root {
  color-scheme: light;
  --plane:          #f7f5f1;
  --surface-1:      #fffefb;
  --text-primary:   #16130e;
  --text-secondary: #57524a;
  --text-muted:     #8a857b;
  --grid:           #e7e3d9;
  --baseline:       #cec9bb;
  --border:         rgba(22,19,14,0.10);
  --bad:            #a11b1b;
  --s1:             #2a78d6;  /* mes mais antigo da janela */
  --s2:             #eb6834;  /* mes passado               */
  --s3:             #1baf7a;  /* mes atual + barras do ano */
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:          #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #8f8b81;
    --grid:           #2c2c2a;
    --baseline:       #3c3a35;
    --border:         rgba(255,255,255,0.10);
    --bad:            #e06060;
    --s1:             #3987e5;
    --s2:             #d95926;
    --s3:             #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:          #0d0d0d;
  --surface-1:      #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #8f8b81;
  --grid:           #2c2c2a;
  --baseline:       #3c3a35;
  --border:         rgba(255,255,255,0.10);
  --bad:            #e06060;
  --s1:             #3987e5;
  --s2:             #d95926;
  --s3:             #199e70;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  min-height: 100vh;
  padding: clamp(12px, 1.5vw, 22px);
  line-height: 1.5;
}

/* 40 / 60, colunas esticadas para terminarem na mesma altura */
.wrap {
  display: grid; grid-template-columns: 40fr 60fr;
  gap: clamp(12px, 1.6vw, 20px); align-items: stretch;
}
/* espacamento vertical entre blocos = metade do horizontal */
.col { display: flex; flex-direction: column; gap: clamp(6px, 0.8vw, 10px); min-width: 0; }
@media (max-width: 820px) { .wrap { grid-template-columns: 1fr; } }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px clamp(12px, 3vw, 20px) 14px;
}
/* o ultimo card da esquerda estica ate alinhar com o fim da coluna da direita */
.card.cresce { flex: 1; display: flex; flex-direction: column; }
.holder-mensal { position: relative; flex: 1; min-height: 170px; }
#svgMensal { position: absolute; inset: 0; width: 100%; height: 100%; }

.card-top { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.card-top h2 { margin: 0; font-size: 15px; font-weight: 650; }

.total-bloco { display: flex; flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.3; }
.total-ano { font-size: 15px; font-weight: 650; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-ano small { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
.vs-ano { font-size: 11px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.legend .dash { width: 16px; height: 3px; border-radius: 2px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr; } }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 15px 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.kpi .lbl { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.kpi .lbl-l { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kpi .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.kpi .tot { font-size: 15px; font-weight: 650; color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .tot small { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.03em; }
.kpi .val { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .val .unidade { font-size: 14px; font-weight: 600; color: var(--text-muted); }

.split { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; column-gap: 12px; margin: 2px 0 1px; }
.split .rule { background: var(--baseline); width: 1px; height: 44px; justify-self: center; }
.split .half { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; min-width: 0; }
.split .tag { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); }
.split .num { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }

.chart-holder { position: relative; width: 100%; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--baseline); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.end-dot { stroke: var(--surface-1); stroke-width: 1.5; }
.end-label { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.end-name { font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; }
.bar-val { fill: var(--text-secondary); font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }

.hover-line { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.hover-dot { stroke: var(--surface-1); stroke-width: 2; opacity: 0; }
.tooltip {
  position: absolute; pointer-events: none; opacity: 0; transform: translate(-50%, -8px);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.14); min-width: 148px; z-index: 5;
  transition: opacity .1s;
}
.tooltip .tt-day { font-weight: 650; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tooltip .tt-row .nm { color: var(--text-secondary); }
.tooltip .tt-row .vv { margin-left: auto; font-weight: 650; color: var(--text-primary); }

/* carimbo de atualizacao - so existe no app (o artefato era estatico) */
.rodape { display: flex; justify-content: flex-end; margin-top: 8px; }
.carimbo { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.aviso {
  background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--bad);
  border-radius: 10px; padding: 12px 15px; font-size: 13px; color: var(--text-secondary);
  margin-bottom: 14px; display: none;
}
