/* ==========================================================================
   Chart cards
   ========================================================================== */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-2);
  flex-wrap: wrap;
}
.chart-head-main { flex: 1 1 220px; min-width: 0; }
.chart-title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chart-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.chart-sub .sep { color: var(--border-strong); }
.chart-toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

.chart-canvas {
  width: 100%;
  min-height: 260px;
  flex: 1 1 auto;
  padding: 0 var(--s-2) var(--s-2);
}
.chart-canvas.h-sm { min-height: 190px; }
.chart-canvas.h-lg { min-height: 340px; }
.chart-canvas.h-xl { min-height: 420px; }

.chart-foot {
  padding: var(--s-2) var(--s-4) var(--s-3);
  font-size: var(--fs-xxs);
  color: var(--text-3);
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: center;
}

/* Custom legend (we render our own so it stays stable and translatable) */
.legend { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  min-height: 24px;
}
.legend-item.is-off { opacity: 0.4; }
.legend-swatch { width: 11px; height: 3px; border-radius: 2px; flex: 0 0 11px; }
.legend-swatch.is-dashed {
  height: 0;
  border-top: 2px dashed currentColor;
  background: none !important;
  width: 13px;
}
.legend-swatch.is-square { width: 10px; height: 10px; border-radius: 2px; }

/* Fullscreen chart */
.chart-card.is-fullscreen {
  position: fixed;
  inset: var(--s-4);
  z-index: var(--z-modal);
  box-shadow: var(--shadow-lg);
}
.chart-card.is-fullscreen .chart-canvas { min-height: 0; }

/* Sparkline inside KPI cards */
.spark { width: 100%; height: 30px; }

/* Waterfall / decomposition legend colours */
.wf-pos { color: var(--pos-600); }
.wf-neg { color: var(--neg-600); }

/* Chart-level inline state (unavailable source, no results) */
.chart-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: var(--s-6) var(--s-4);
}

@media (max-width: 768px) {
  .chart-head { padding: var(--s-3) var(--s-3) var(--s-2); }
  .chart-canvas { min-height: 230px; padding: 0 0 var(--s-2); }
  .chart-canvas.h-lg, .chart-canvas.h-xl { min-height: 280px; }
  .chart-foot { padding: var(--s-2) var(--s-3) var(--s-3); }
  .chart-card.is-fullscreen { inset: 0; border-radius: 0; }
}
