/* ==========================================================
   GeroTheme charts — chart chrome for assets/js/charts.js.
   The palette tokens (--series-*, --seq-*, --div-*, --status-*) live in
   style.css, because the map page uses them too.
   ========================================================== */

/* ---------- chart container ---------- */
.viz { position: relative; min-width: 0; }
.viz-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin-bottom: 8px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 2px 4px; min-width: 0; }
.viz-legend > * {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s, opacity .15s;
}
.viz-legend button:hover { background: var(--surface-2); color: var(--text); }
.viz-legend .off { opacity: .4; }
.viz-key { flex-shrink: 0; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.viz-key.line { width: 14px; height: 2px; border-radius: 2px; }
.viz-key.dot { width: 8px; height: 8px; border-radius: 50%; }
.viz-toggle {
  flex-shrink: 0; margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  transition: background .15s, color .15s;
}
.viz-toggle:hover, .viz-toggle[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.viz-toggle .lucide { width: 14px; height: 14px; }

.viz-plot { position: relative; border-radius: 6px; }
.viz-plot:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.viz-plot > svg { display: block; width: 100%; overflow: visible; }
.viz.refetching .viz-plot { opacity: .45; transition: opacity .15s; }
.viz-table { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.viz-table .table th, .viz-table .table td { height: 34px; }
.viz-table .table th:not(:first-child), .viz-table .table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.viz-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- SVG marks ---------- */
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; transition: opacity .1s; }
.viz-tick { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.viz-label { font-size: 12px; fill: var(--text-2); }
.viz-value { font-size: 11.5px; font-weight: 600; fill: var(--text); font-variant-numeric: tabular-nums; }
.viz-title { font-size: 11px; fill: var(--text-3); }
.viz-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viz-mark { transition: opacity .15s; }
.viz-dim { opacity: .3; }
.viz-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s var(--ease) forwards; }
.viz-fade { animation: fadeIn .5s var(--ease) both; }
.viz-grow-y { animation: vizGrowY .6s var(--ease-out) both; }
.viz-grow-x { animation: vizGrowX .6s var(--ease-out) both; }
@keyframes vizGrowY { from { transform: scaleY(0); } }
@keyframes vizGrowX { from { transform: scaleX(0); } }

/* ---------- tooltip: values lead, names follow ---------- */
.viz-tip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none;
  min-width: 130px; max-width: 240px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
  font-size: 12px; opacity: 0; transition: opacity .12s;
}
.viz-tip.show { opacity: 1; }
.viz-tip-title { margin-bottom: 6px; color: var(--text-3); font-size: 11.5px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.viz-tip-row + .viz-tip-row { margin-top: 4px; }
.viz-tip-row i { flex-shrink: 0; width: 12px; height: 2px; border-radius: 2px; background: var(--c); }
.viz-tip-row i.dot { width: 8px; height: 8px; border-radius: 50%; }
.viz-tip-row strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-tip-row span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }

/* ---------- scale legend (heatmaps) ---------- */
.viz-scale { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-3); }
.viz-scale i { width: 14px; height: 10px; border-radius: 2px; background: var(--c); }
.viz-scale span { margin: 0 5px; }

/* ---------- donut ---------- */
.viz-plot.donut { display: flex; align-items: center; gap: 24px; }
.viz-plot.donut > svg { flex-shrink: 0; }
.viz-plot.donut.stacked { flex-direction: column; align-items: stretch; }
.viz-side { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.viz-side li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; cursor: default; transition: background .15s; }
.viz-side li:hover, .viz-side li.hover { background: var(--surface-2); }
.viz-side li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.viz-side li strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-side li small { width: 40px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- calendar heatmap (scrolls on narrow screens) ---------- */
.viz-plot.scroll-x { overflow-x: auto; }

/* ---------- stat tiles & meters ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-tile .card-body { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12.5px; color: var(--text-2); }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.stat-delta .lucide { width: 13px; height: 13px; }
.stat-delta.good { color: var(--delta-good); }
.stat-delta.bad { color: var(--delta-bad); }
.stat-delta + small { font-size: 12px; color: var(--text-3); }
.stat-foot { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.stat-spark { width: 104px; height: 34px; overflow: visible; }

.meters { display: flex; flex-direction: column; gap: 16px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.meter-head span { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.meter-head strong { font-variant-numeric: tabular-nums; }
.meter-head .lucide { width: 14px; height: 14px; }
.meter { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--fill); transition: width .8s var(--ease-out); }
.meter.ok       { --fill: var(--series-1); --track: var(--seq-100); }
.meter.warning  { --fill: var(--status-warning); --track: var(--warning-track); }
.meter.critical { --fill: var(--status-critical); --track: var(--critical-track); }

/* ---------- page layout ---------- */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-row .segmented { width: auto; }
.filter-row .segmented button { padding: 0 12px; }
.viz-section { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: calc(120px + var(--hnav-h)); }
.viz-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 8px; }
.viz-section-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.viz-section-head p { margin-top: 2px; font-size: 12.5px; color: var(--text-2); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.chart-grid.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-grid > .span-2 { grid-column: 1 / -1; }
.chart-grid.thirds > .span-2 { grid-column: span 2; }
.chart-sub { margin: -2px 0 10px; font-size: 12px; color: var(--text-3); }
.multiples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; }
.multiple h4 { margin: 0 0 2px; font-size: 12.5px; font-weight: 600; }
.multiple .viz-top { display: none; }

@media (max-width: 1200px) {
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid.thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .chart-grid, .chart-grid.thirds { grid-template-columns: minmax(0, 1fr); }
  .multiples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .stat-tiles, .multiples { grid-template-columns: minmax(0, 1fr); }
}
