---
title: "Data Dashboard · UI SDK — StyleX Blocks"
description: "Edge runtime A/B benchmark comparison dashboard (v3.2 Candidate vs. v3.1 Baseline) with environment and metric controls, dual-series KPI sparkline cards, synchronized overlay and workload bar charts, distribution breakdowns, and a regional statistical-significance table."
url: "https://stylexblocks.com/block/ui-sdk/data-dashboard/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Data Dashboard block

Edge runtime A/B benchmark comparison dashboard (v3.2 Candidate vs. v3.1 Baseline) with environment and metric controls, dual-series KPI sparkline cards, synchronized overlay and workload bar charts, distribution breakdowns, and a regional statistical-significance table.

- Behavior engine: UI SDK
- Category: [Dashboards](https://stylexblocks.com/blocks/dashboards.md)
- Built with: [Badge](https://stylexblocks.com/components/ui-sdk/badge.md), [Button](https://stylexblocks.com/components/ui-sdk/button.md), [Card](https://stylexblocks.com/components/ui-sdk/card.md), [Center](https://stylexblocks.com/components/ui-sdk/center.md), [Chart](https://stylexblocks.com/components/ui-sdk/chart.md), [Grid](https://stylexblocks.com/components/ui-sdk/grid.md), [Heading](https://stylexblocks.com/components/ui-sdk/heading.md), [Progress](https://stylexblocks.com/components/ui-sdk/progress.md), [Segment Group](https://stylexblocks.com/components/ui-sdk/segment-group.md), [Select](https://stylexblocks.com/components/ui-sdk/select.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Stat](https://stylexblocks.com/components/ui-sdk/stat.md), [Status](https://stylexblocks.com/components/ui-sdk/status.md), [Table](https://stylexblocks.com/components/ui-sdk/table.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/data-dashboard/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add data-dashboard
```

Equivalent: `npx shadcn add @stylexblocks/data-dashboard`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/data-dashboard.json

## Usage

```tsx
import { DataDashboard } from "#components/blocks/ui-sdk/data-dashboard.tsx";

export function Example() {
  return (
    <div style={{ height: "100dvh" }}>
      <DataDashboard />
    </div>
  );
}
```

## Source

`components/blocks/ui-sdk/data-dashboard.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { useMemo, useState } from "react";
import { Badge } from "#components/ui/ui-sdk/badge.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";
import { Card } from "#components/ui/ui-sdk/card.tsx";
import { Square } from "#components/ui/ui-sdk/center.tsx";
import {
  BarChart,
  CategoryBar,
  LineChart,
  Sparkline,
  type ChartColorName,
} from "#components/ui/ui-sdk/chart.tsx";
import { Grid } from "#components/ui/ui-sdk/grid.tsx";
import { Heading } from "#components/ui/ui-sdk/heading.tsx";
import { Progress } from "#components/ui/ui-sdk/progress.tsx";
import { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";
import { Select } from "#components/ui/ui-sdk/select.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Stat } from "#components/ui/ui-sdk/stat.tsx";
import { Status } from "#components/ui/ui-sdk/status.tsx";
import { Table } from "#components/ui/ui-sdk/table.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";
import {
  amberPalette,
  bluePalette,
  grayPalette,
  greenPalette,
  redPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

// ============= CONTAINER BREAKPOINTS =============

const NARROW = "@container data-dashboard (max-width: 1020px)";
const COMPACT = "@container data-dashboard (max-width: 660px)";

// ============= DOMAIN TYPES =============

type EnvironmentId = "prod-global" | "canary-50" | "staging-load";
type DateRange = "7d" | "30d" | "90d";
type MetricDimension = "latency" | "throughput" | "errors";
type RegionFilter = "all" | "significant" | "watch";

interface MetricDeltas {
  vsBaseline: number;
  dd: number;
  ww: number;
  mm: number;
}

interface SparkPoint extends Record<string, unknown> {
  i: number;
  "v3.1 Baseline": number;
  "v3.2 Candidate": number;
}

interface BenchmarkMetric {
  key: string;
  label: string;
  value: string;
  baselineValue: string;
  higherIsBetter: boolean;
  significance: "p < 0.001" | "p < 0.01" | "p = 0.04" | "p = 0.21";
  deltas: MetricDeltas;
  spark: SparkPoint[];
}

interface TrendPoint {
  slot: number;
  label: string;
  candidate: number;
  baseline: number;
}

interface WorkloadComparisonItem {
  workload: string;
  candidate: number;
  baseline: number;
}

interface BreakdownSegment {
  label: string;
  value: number;
  color: ChartColorName;
}

interface RegionalRow {
  id: string;
  pop: string;
  regionName: string;
  requestsM: number;
  baselineLatencyMs: number;
  candidateLatencyMs: number;
  baselineThroughputK: number;
  candidateThroughputK: number;
  baselineErrorPct: number;
  candidateErrorPct: number;
  pValue: number;
  status: "significant" | "neutral" | "watch";
}

// ============= CONSTANTS & OPTIONS =============

const ENVIRONMENT_OPTIONS: ReadonlyArray<{ value: EnvironmentId; label: string }> = [
  { value: "prod-global", label: "Production Global" },
  { value: "canary-50", label: "Canary 50/50" },
  { value: "staging-load", label: "Staging Replay" },
];

const DIMENSION_OPTIONS: ReadonlyArray<{ value: MetricDimension; label: string }> = [
  { value: "latency", label: "p95 Latency (ms)" },
  { value: "throughput", label: "Throughput (kRPS)" },
  { value: "errors", label: "5xx Error Rate (%)" },
];

const RANGE_META: Record<DateRange, { label: string; points: number; days: number }> = {
  "7d": { label: "Last 7 days", points: 14, days: 7 },
  "30d": { label: "Last 30 days", points: 30, days: 30 },
  "90d": { label: "Last 90 days", points: 45, days: 90 },
};

const ENV_PROFILES: Record<
  EnvironmentId,
  {
    latencyFactor: number;
    throughputFactor: number;
    errorFactor: number;
    sampleScale: number;
    candidateShare: number;
    baselineShare: number;
    holdoutShare: number;
  }
> = {
  "prod-global": {
    latencyFactor: 1.0,
    throughputFactor: 1.0,
    errorFactor: 1.0,
    sampleScale: 1.0,
    candidateShare: 25,
    baselineShare: 70,
    holdoutShare: 5,
  },
  "canary-50": {
    latencyFactor: 0.96,
    throughputFactor: 0.62,
    errorFactor: 0.92,
    sampleScale: 0.54,
    candidateShare: 48,
    baselineShare: 48,
    holdoutShare: 4,
  },
  "staging-load": {
    latencyFactor: 1.09,
    throughputFactor: 0.28,
    errorFactor: 1.18,
    sampleScale: 0.18,
    candidateShare: 50,
    baselineShare: 45,
    holdoutShare: 5,
  },
};

const DIMENSION_META: Record<
  MetricDimension,
  {
    shortTitle: string;
    overlayTitle: string;
    workloadTitle: string;
    unit: string;
    higherIsBetter: boolean;
    formatValue: (v: number) => string;
  }
> = {
  latency: {
    shortTitle: "p95 Latency",
    overlayTitle: "p95 Edge Latency · v3.2 Candidate vs. v3.1 Baseline",
    workloadTitle: "p95 Latency by Workload",
    unit: "ms",
    higherIsBetter: false,
    formatValue: (v) => `${v.toFixed(1)} ms`,
  },
  throughput: {
    shortTitle: "Throughput",
    overlayTitle: "Sustained Throughput · v3.2 Candidate vs. v3.1 Baseline",
    workloadTitle: "Throughput by Workload",
    unit: "kRPS",
    higherIsBetter: true,
    formatValue: (v) => `${v.toFixed(1)} kRPS`,
  },
  errors: {
    shortTitle: "5xx Error Rate",
    overlayTitle: "5xx Error Rate · v3.2 Candidate vs. v3.1 Baseline",
    workloadTitle: "Error Rate by Workload",
    unit: "%",
    higherIsBetter: false,
    formatValue: (v) => `${v.toFixed(3)}%`,
  },
};

// ============= DETERMINISTIC FIXTURES =============

function hashNoise(i: number, seed: number): number {
  const x = Math.sin(i * 127.1 + seed * 311.7) * 43758.5453;
  return x - Math.floor(x);
}

function buildComparisonSpark(
  seed: number,
  candidateEnd: number,
  baselineEnd: number,
  slope: number,
  count: number,
): SparkPoint[] {
  const rows: SparkPoint[] = [];
  let driftA = 0;
  let driftB = 0;
  for (let i = 0; i < count; i++) {
    const t = count > 1 ? i / (count - 1) : 1;
    const wave = Math.sin(t * Math.PI * 3.5 + seed) * 2.2;
    driftA = driftA * 0.68 + (hashNoise(i, seed) - 0.5) * 4.5;
    driftB = driftB * 0.68 + (hashNoise(i, seed + 29) - 0.5) * 4.2;
    const baseVal = baselineEnd - slope * (1 - t) * 4 + wave + driftB;
    const candVal = candidateEnd - slope * (1 - t) * 7 + wave * 0.85 + driftA;
    rows.push({
      i,
      "v3.1 Baseline": Number(baseVal.toFixed(2)),
      "v3.2 Candidate": Number(candVal.toFixed(2)),
    });
  }
  return rows;
}

function buildMetrics(env: EnvironmentId, range: DateRange): BenchmarkMetric[] {
  const p = ENV_PROFILES[env];
  const rangeShift = range === "7d" ? 0.98 : range === "30d" ? 1.0 : 1.03;
  const sparkCount = range === "7d" ? 14 : range === "30d" ? 24 : 32;

  const p50Cand = 11.4 * p.latencyFactor * rangeShift;
  const p50Base = 13.6 * p.latencyFactor * rangeShift;
  const p95Cand = 34.8 * p.latencyFactor * rangeShift;
  const p95Base = 42.8 * p.latencyFactor * rangeShift;
  const p99Cand = 78.2 * p.latencyFactor * rangeShift;
  const p99Base = 100.8 * p.latencyFactor * rangeShift;
  const rpsCand = 148.6 * p.throughputFactor * (2 - rangeShift);
  const rpsBase = 130.0 * p.throughputFactor * (2 - rangeShift);
  const coldCand = 4.2 * p.latencyFactor;
  const coldBase = 6.1 * p.latencyFactor;
  const cpuCand = 2.18 * p.latencyFactor;
  const cpuBase = 2.5 * p.latencyFactor;
  const hitCand = Math.min(
    99.2,
    96.4 + (env === "canary-50" ? 0.4 : env === "staging-load" ? -0.9 : 0),
  );
  const hitBase = hitCand - 1.8;
  const errCand = 0.044 * p.errorFactor;
  const errBase = 0.042 * p.errorFactor;

  return [
    {
      key: "p50-latency",
      label: "p50 Edge Latency",
      value: `${p50Cand.toFixed(1)} ms`,
      baselineValue: `${p50Base.toFixed(1)} ms`,
      higherIsBetter: false,
      significance: "p < 0.001",
      deltas: { vsBaseline: -16.2, dd: -0.4, ww: -2.1, mm: -5.8 },
      spark: buildComparisonSpark(11, 42, 54, -1.1, sparkCount),
    },
    {
      key: "p95-latency",
      label: "p95 Edge Latency",
      value: `${p95Cand.toFixed(1)} ms`,
      baselineValue: `${p95Base.toFixed(1)} ms`,
      higherIsBetter: false,
      significance: "p < 0.001",
      deltas: { vsBaseline: -18.7, dd: -0.8, ww: -3.4, mm: -7.9 },
      spark: buildComparisonSpark(17, 38, 56, -1.4, sparkCount),
    },
    {
      key: "p99-latency",
      label: "p99 Tail Latency",
      value: `${p99Cand.toFixed(1)} ms`,
      baselineValue: `${p99Base.toFixed(1)} ms`,
      higherIsBetter: false,
      significance: "p < 0.001",
      deltas: { vsBaseline: -22.4, dd: -1.1, ww: -4.2, mm: -9.6 },
      spark: buildComparisonSpark(23, 35, 58, -1.6, sparkCount),
    },
    {
      key: "peak-throughput",
      label: "Peak Throughput",
      value: `${rpsCand.toFixed(1)} kRPS`,
      baselineValue: `${rpsBase.toFixed(1)} kRPS`,
      higherIsBetter: true,
      significance: "p < 0.001",
      deltas: { vsBaseline: 14.3, dd: 0.9, ww: 3.1, mm: 8.4 },
      spark: buildComparisonSpark(31, 64, 50, 1.3, sparkCount),
    },
    {
      key: "cold-start",
      label: "Cold Start Duration",
      value: `${coldCand.toFixed(1)} ms`,
      baselineValue: `${coldBase.toFixed(1)} ms`,
      higherIsBetter: false,
      significance: "p < 0.001",
      deltas: { vsBaseline: -31.1, dd: -0.5, ww: -1.9, mm: -11.2 },
      spark: buildComparisonSpark(37, 32, 55, -1.5, sparkCount),
    },
    {
      key: "cpu-time",
      label: "Worker CPU Time",
      value: `${cpuCand.toFixed(2)} ms`,
      baselineValue: `${cpuBase.toFixed(2)} ms`,
      higherIsBetter: false,
      significance: "p < 0.01",
      deltas: { vsBaseline: -12.8, dd: -0.2, ww: -1.4, mm: -4.1 },
      spark: buildComparisonSpark(43, 44, 54, -0.8, sparkCount),
    },
    {
      key: "cache-hit",
      label: "Edge Cache Hit Ratio",
      value: `${hitCand.toFixed(1)}%`,
      baselineValue: `${hitBase.toFixed(1)}%`,
      higherIsBetter: true,
      significance: "p < 0.01",
      deltas: { vsBaseline: 1.9, dd: 0.1, ww: 0.5, mm: 1.3 },
      spark: buildComparisonSpark(53, 62, 54, 0.7, sparkCount),
    },
    {
      key: "error-rate",
      label: "5xx Error Rate",
      value: `${errCand.toFixed(3)}%`,
      baselineValue: `${errBase.toFixed(3)}%`,
      higherIsBetter: false,
      significance: "p = 0.04",
      deltas: { vsBaseline: 4.8, dd: 0.3, ww: 1.2, mm: 2.1 },
      spark: buildComparisonSpark(59, 54, 49, 0.6, sparkCount),
    },
  ];
}

function buildOverlaySeries(
  env: EnvironmentId,
  range: DateRange,
  dimension: MetricDimension,
): TrendPoint[] {
  const { points, days } = RANGE_META[range];
  const p = ENV_PROFILES[env];
  const out: TrendPoint[] = [];

  for (let i = 0; i < points; i++) {
    const progress = points > 1 ? i / (points - 1) : 1;
    const dayNumber = Math.max(1, Math.round(progress * (days - 1)) + 1);
    const label =
      range === "7d" ? `Day ${Math.ceil((i + 1) / 2)} ${i % 2 === 0 ? "AM" : "PM"}` : `Day ${dayNumber}`;
    const cycle = Math.sin(i * 0.65) * 0.5 + Math.cos(i * 0.28) * 0.5;
    const spike = hashNoise(i, 71) > 0.87 ? 1 : 0;

    if (dimension === "latency") {
      const base =
        (41.2 + cycle * 3.8 + (hashNoise(i, 13) - 0.5) * 4.4 + spike * 5.2) * p.latencyFactor;
      const cand =
        (35.8 - progress * 2.1 + cycle * 2.9 + (hashNoise(i, 29) - 0.5) * 3.2 + spike * 2.6) *
        p.latencyFactor;
      out.push({
        slot: i,
        label,
        baseline: Number(base.toFixed(1)),
        candidate: Number(cand.toFixed(1)),
      });
    } else if (dimension === "throughput") {
      const base =
        (122 + progress * 11 + cycle * 9.5 + (hashNoise(i, 19) - 0.5) * 8 + spike * 12) *
        p.throughputFactor;
      const cand =
        (138 + progress * 15 + cycle * 10.5 + (hashNoise(i, 41) - 0.5) * 8.5 + spike * 15) *
        p.throughputFactor;
      out.push({
        slot: i,
        label,
        baseline: Number(base.toFixed(1)),
        candidate: Number(cand.toFixed(1)),
      });
    } else {
      const base =
        (0.041 + cycle * 0.005 + (hashNoise(i, 61) - 0.5) * 0.007 + spike * 0.011) *
        p.errorFactor;
      const cand =
        (0.043 + cycle * 0.005 + (hashNoise(i, 83) - 0.5) * 0.008 + spike * 0.014) *
        p.errorFactor;
      out.push({
        slot: i,
        label,
        baseline: Number(Math.max(0.01, base).toFixed(3)),
        candidate: Number(Math.max(0.01, cand).toFixed(3)),
      });
    }
  }

  return out;
}

function buildWorkloadComparison(
  env: EnvironmentId,
  dimension: MetricDimension,
): WorkloadComparisonItem[] {
  const p = ENV_PROFILES[env];
  if (dimension === "latency") {
    return [
      {
        workload: "SSR Stream",
        baseline: Number((52.4 * p.latencyFactor).toFixed(1)),
        candidate: Number((40.8 * p.latencyFactor).toFixed(1)),
      },
      {
        workload: "API Proxy",
        baseline: Number((31.2 * p.latencyFactor).toFixed(1)),
        candidate: Number((25.9 * p.latencyFactor).toFixed(1)),
      },
      {
        workload: "Auth Edge",
        baseline: Number((22.6 * p.latencyFactor).toFixed(1)),
        candidate: Number((18.1 * p.latencyFactor).toFixed(1)),
      },
      {
        workload: "Image Opt",
        baseline: Number((68.5 * p.latencyFactor).toFixed(1)),
        candidate: Number((54.2 * p.latencyFactor).toFixed(1)),
      },
      {
        workload: "KV Read",
        baseline: Number((16.8 * p.latencyFactor).toFixed(1)),
        candidate: Number((13.4 * p.latencyFactor).toFixed(1)),
      },
    ];
  }
  if (dimension === "throughput") {
    return [
      {
        workload: "SSR Stream",
        baseline: Number((24.8 * p.throughputFactor).toFixed(1)),
        candidate: Number((29.4 * p.throughputFactor).toFixed(1)),
      },
      {
        workload: "API Proxy",
        baseline: Number((42.1 * p.throughputFactor).toFixed(1)),
        candidate: Number((48.6 * p.throughputFactor).toFixed(1)),
      },
      {
        workload: "Auth Edge",
        baseline: Number((28.4 * p.throughputFactor).toFixed(1)),
        candidate: Number((32.1 * p.throughputFactor).toFixed(1)),
      },
      {
        workload: "Image Opt",
        baseline: Number((14.2 * p.throughputFactor).toFixed(1)),
        candidate: Number((16.9 * p.throughputFactor).toFixed(1)),
      },
      {
        workload: "KV Read",
        baseline: Number((35.6 * p.throughputFactor).toFixed(1)),
        candidate: Number((41.2 * p.throughputFactor).toFixed(1)),
      },
    ];
  }
  return [
    {
      workload: "SSR Stream",
      baseline: Number((0.052 * p.errorFactor).toFixed(3)),
      candidate: Number((0.049 * p.errorFactor).toFixed(3)),
    },
    {
      workload: "API Proxy",
      baseline: Number((0.036 * p.errorFactor).toFixed(3)),
      candidate: Number((0.034 * p.errorFactor).toFixed(3)),
    },
    {
      workload: "Auth Edge",
      baseline: Number((0.024 * p.errorFactor).toFixed(3)),
      candidate: Number((0.022 * p.errorFactor).toFixed(3)),
    },
    {
      workload: "Image Opt",
      baseline: Number((0.064 * p.errorFactor).toFixed(3)),
      candidate: Number((0.079 * p.errorFactor).toFixed(3)),
    },
    {
      workload: "KV Read",
      baseline: Number((0.019 * p.errorFactor).toFixed(3)),
      candidate: Number((0.018 * p.errorFactor).toFixed(3)),
    },
  ];
}

const EXECUTION_PATH_DATA: BreakdownSegment[] = [
  { label: "Warm Isolate", value: 64, color: "blue" },
  { label: "Snapshot Restore", value: 23, color: "teal" },
  { label: "Cold Boot", value: 9, color: "orange" },
  { label: "Origin Fallback", value: 4, color: "slate" },
];

const TRAFFIC_CLASS_DATA: BreakdownSegment[] = [
  { label: "JSON API", value: 44, color: "blue" },
  { label: "HTML Stream", value: 24, color: "teal" },
  { label: "GraphQL", value: 15, color: "violet" },
  { label: "Static Asset", value: 11, color: "emerald" },
  { label: "WebSocket", value: 6, color: "orange" },
];

const BASE_REGIONAL_ROWS: RegionalRow[] = [
  {
    id: "iad-1",
    pop: "iad-1",
    regionName: "US East · Ashburn",
    requestsM: 21.4,
    baselineLatencyMs: 36.2,
    candidateLatencyMs: 28.9,
    baselineThroughputK: 34.8,
    candidateThroughputK: 40.2,
    baselineErrorPct: 0.034,
    candidateErrorPct: 0.031,
    pValue: 0.0002,
    status: "significant",
  },
  {
    id: "sjc-2",
    pop: "sjc-2",
    regionName: "US West · San Jose",
    requestsM: 16.8,
    baselineLatencyMs: 39.4,
    candidateLatencyMs: 32.1,
    baselineThroughputK: 27.6,
    candidateThroughputK: 31.8,
    baselineErrorPct: 0.038,
    candidateErrorPct: 0.036,
    pValue: 0.0006,
    status: "significant",
  },
  {
    id: "fra-1",
    pop: "fra-1",
    regionName: "EU Central · Frankfurt",
    requestsM: 15.2,
    baselineLatencyMs: 41.8,
    candidateLatencyMs: 33.4,
    baselineThroughputK: 24.1,
    candidateThroughputK: 27.9,
    baselineErrorPct: 0.041,
    candidateErrorPct: 0.039,
    pValue: 0.0004,
    status: "significant",
  },
  {
    id: "lhr-1",
    pop: "lhr-1",
    regionName: "EU West · London",
    requestsM: 11.6,
    baselineLatencyMs: 38.6,
    candidateLatencyMs: 31.5,
    baselineThroughputK: 18.4,
    candidateThroughputK: 21.1,
    baselineErrorPct: 0.037,
    candidateErrorPct: 0.035,
    pValue: 0.0021,
    status: "significant",
  },
  {
    id: "nrt-1",
    pop: "nrt-1",
    regionName: "Asia NE · Tokyo",
    requestsM: 9.4,
    baselineLatencyMs: 45.1,
    candidateLatencyMs: 37.8,
    baselineThroughputK: 14.2,
    candidateThroughputK: 16.4,
    baselineErrorPct: 0.044,
    candidateErrorPct: 0.042,
    pValue: 0.0048,
    status: "significant",
  },
  {
    id: "sin-1",
    pop: "sin-1",
    regionName: "Asia SE · Singapore",
    requestsM: 6.3,
    baselineLatencyMs: 48.2,
    candidateLatencyMs: 46.9,
    baselineThroughputK: 9.8,
    candidateThroughputK: 10.1,
    baselineErrorPct: 0.049,
    candidateErrorPct: 0.052,
    pValue: 0.19,
    status: "neutral",
  },
  {
    id: "gru-1",
    pop: "gru-1",
    regionName: "South America · Sao Paulo",
    requestsM: 3.9,
    baselineLatencyMs: 58.4,
    candidateLatencyMs: 61.9,
    baselineThroughputK: 6.1,
    candidateThroughputK: 5.8,
    baselineErrorPct: 0.062,
    candidateErrorPct: 0.074,
    pValue: 0.032,
    status: "watch",
  },
];

// ============= STYLES =============

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    containerName: "data-dashboard",
    containerType: "inline-size",
    display: "flex",
    flexDirection: "column",
    fontFamily: fonts.body,
    height: "100%",
    minHeight: 0,
    overflowY: "auto",
    width: "100%",
  },
  header: {
    backgroundColor: semanticColors.bgSurface,
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    paddingBlock: spacing._4,
    paddingInline: spacing._6,
    position: "sticky",
    top: 0,
    zIndex: 10,
  },
  headerInner: {
    marginInline: "auto",
    maxWidth: "90rem",
    width: "100%",
  },
  headingReset: {
    marginBlock: 0,
  },
  selectWrap: {
    minWidth: "10.5rem",
    width: "auto",
  },
  content: {
    marginInline: "auto",
    maxWidth: "90rem",
    paddingBlock: spacing._6,
    paddingInline: spacing._6,
    width: "100%",
  },
  sectionIconTile: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.borderSubtle,
    borderRadius: semanticRadii.control,
    borderStyle: "solid",
    borderWidth: "1px",
    color: semanticColors.fgMuted,
  },
  metricsGrid: {
    gridTemplateColumns: {
      default: "repeat(4, minmax(0, 1fr))",
      [NARROW]: "repeat(2, minmax(0, 1fr))",
      [COMPACT]: "minmax(0, 1fr)",
    },
  },
  metricCardBody: {
    paddingBlock: spacing._4,
    paddingInline: spacing._4,
  },
  metricValueRow: {
    marginTop: spacing._0_5,
  },
  trendArrow: {
    alignItems: "center",
    display: "inline-flex",
    flexShrink: 0,
  },
  comparisonGrid: {
    gridTemplateColumns: {
      default: "minmax(0, 1.45fr) minmax(0, 1fr)",
      [NARROW]: "minmax(0, 1fr)",
    },
  },
  cardInner: {
    paddingBlock: spacing._5,
    paddingInline: spacing._5,
  },
  threeColGrid: {
    gridTemplateColumns: {
      default: "repeat(3, minmax(0, 1fr))",
      [NARROW]: "repeat(2, minmax(0, 1fr))",
      [COMPACT]: "minmax(0, 1fr)",
    },
  },
  tableScroll: {
    overflowX: "auto",
    width: "100%",
  },
  progressCell: {
    minWidth: "8.5rem",
  },
  nowrapCell: {
    whiteSpace: "nowrap",
  },
});

// ============= INLINE ICONS =============

function ArrowUpIcon() {
  return (
    <svg
      width="14"
      height="14"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="2.2"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <line x1="12" y1="19" x2="12" y2="5" />
      <polyline points="5 12 12 5 19 12" />
    </svg>
  );
}

function ArrowDownIcon() {
  return (
    <svg
      width="14"
      height="14"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="2.2"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <line x1="12" y1="5" x2="12" y2="19" />
      <polyline points="19 12 12 19 5 12" />
    </svg>
  );
}

function DownloadIcon() {
  return (
    <svg
      width="14"
      height="14"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.9"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
      <polyline points="7 10 12 15 17 10" />
      <line x1="12" y1="15" x2="12" y2="3" />
    </svg>
  );
}

function RocketIcon() {
  return (
    <svg
      width="14"
      height="14"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.9"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z" />
      <path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z" />
      <path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0" />
      <path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" />
    </svg>
  );
}

function GaugeIcon() {
  return (
    <svg
      width="15"
      height="15"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d="m12 14 4-4" />
      <path d="M3.34 19a10 10 0 1 1 17.32 0" />
    </svg>
  );
}

function ActivityIcon() {
  return (
    <svg
      width="15"
      height="15"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />
    </svg>
  );
}

function LayersIcon() {
  return (
    <svg
      width="15"
      height="15"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <polygon points="12 2 2 7 12 12 22 7 12 2" />
      <polyline points="2 17 12 22 22 17" />
      <polyline points="2 12 12 17 22 12" />
    </svg>
  );
}

function GlobeIcon() {
  return (
    <svg
      width="15"
      height="15"
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <circle cx="12" cy="12" r="10" />
      <line x1="2" y1="12" x2="22" y2="12" />
      <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
    </svg>
  );
}

// ============= SHARED HELPERS =============

function formatSignedPct(value: number): string {
  if (value === 0) return "0.0%";
  return `${value > 0 ? "+" : ""}${value.toFixed(1)}%`;
}

function SectionHeading({
  title,
  hint,
  icon,
  trailing,
}: {
  title: string;
  hint?: string;
  icon: React.ReactNode;
  trailing?: React.ReactNode;
}) {
  return (
    <HStack justify="between" align="center" wrap="wrap" gap="3">
      <HStack align="center" gap="2.5">
        <Square render={<span />} size="sm" style={styles.sectionIconTile}>
          {icon}
        </Square>
        <VStack gap="0">
          <Heading render={<h2 />} size="md" style={styles.headingReset}>
            {title}
          </Heading>
          {hint ? (
            <Text size="xs" tone="muted">
              {hint}
            </Text>
          ) : null}
        </VStack>
      </HStack>
      {trailing ?? null}
    </HStack>
  );
}

// ============= METRIC SPARKLINE MINI-CARD =============

function DeltaCell({
  label,
  value,
  highlight,
  favorable,
}: {
  label: string;
  value: number;
  highlight?: boolean;
  favorable?: boolean;
}) {
  return (
    <HStack align="baseline" gap="1">
      <Text
        render={<span />}
        variant="mono"
        size="xs"
        weight="semibold"
        tabular="true"
        tone={highlight ? (favorable ? "success" : "error") : "default"}
      >
        {formatSignedPct(value)}
      </Text>
      <Text render={<span />} size="2xs" tone="muted">
        {label}
      </Text>
    </HStack>
  );
}

function MetricComparisonCard({ metric }: { metric: BenchmarkMetric }) {
  const isUp = metric.deltas.vsBaseline >= 0;
  const favorable = metric.higherIsBetter ? isUp : !isUp;

  return (
    <Card.Root variant="outline">
      <VStack gap="3" style={styles.metricCardBody}>
        <Stat.Root size="sm">
          <HStack justify="between" align="center" gap="2">
            <Stat.Label>{metric.label}</Stat.Label>
            <Badge
              variant="subtle"
              size="xs"
              palette={favorable ? greenPalette : amberPalette}
            >
              {metric.significance}
            </Badge>
          </HStack>
          <HStack align="center" wrap="wrap" gap="2" style={styles.metricValueRow}>
            <Stat.ValueText>{metric.value}</Stat.ValueText>
            <Text
              render={<span />}
              tone={favorable ? "success" : "error"}
              style={styles.trendArrow}
              aria-label={favorable ? "Favorable delta" : "Unfavorable delta"}
            >
              {isUp ? <ArrowUpIcon /> : <ArrowDownIcon />}
            </Text>
          </HStack>
          <Stat.HelpText>
            <Text render={<span />} variant="mono" size="2xs" tone="muted" tabular="true">
              v3.1: {metric.baselineValue}
            </Text>
          </Stat.HelpText>
        </Stat.Root>

        <div aria-hidden="true">
          <Sparkline
            data={metric.spark}
            categories={["v3.1 Baseline", "v3.2 Candidate"]}
            colors={[
              semanticColors.borderEmphasized,
              favorable ? semanticColors.greenSolid : semanticColors.orangeSolid,
            ]}
            height={44}
            curve="linear"
            ariaLabel={`${metric.label} candidate vs baseline trend`}
          />
        </div>

        <Grid columns="2" gap="2">
          <DeltaCell
            label="vs v3.1"
            value={metric.deltas.vsBaseline}
            highlight
            favorable={favorable}
          />
          <DeltaCell label="d/d" value={metric.deltas.dd} />
          <DeltaCell label="w/w" value={metric.deltas.ww} />
          <DeltaCell label="m/m" value={metric.deltas.mm} />
        </Grid>
      </VStack>
    </Card.Root>
  );
}

// ============= CANDIDATE VS. BASELINE OVERLAY CHART =============

function OverlayComparisonChart({
  data,
  dimension,
}: {
  data: TrendPoint[];
  dimension: MetricDimension;
}) {
  const meta = DIMENSION_META[dimension];

  const chartData = useMemo(
    () =>
      data.map((pt) => ({
        label: pt.label,
        "v3.2 Candidate": pt.candidate,
        "v3.1 Baseline": pt.baseline,
      })),
    [data],
  );

  return (
    <Card.Root variant="outline">
      <VStack gap="4" style={styles.cardInner}>
        <HStack justify="between" align="start" wrap="wrap" gap="2">
          <VStack gap="0.5">
            <Heading render={<h3 />} size="sm" style={styles.headingReset}>
              {meta.overlayTitle}
            </Heading>
            <Text size="xs" tone="muted">
              Synchronized cohort telemetry ({meta.unit}) — hover to inspect per-interval values
            </Text>
          </VStack>
          <Badge variant="subtle" size="xs" palette={bluePalette}>
            Live A/B Overlay
          </Badge>
        </HStack>

        <LineChart
          data={chartData}
          index="label"
          categories={["v3.2 Candidate", "v3.1 Baseline"]}
          colors={["blue", "slate"]}
          height={264}
          curve="linear"
          valueFormatter={meta.formatValue}
          ariaLabel={`${meta.overlayTitle} time-series comparison`}
        />
      </VStack>
    </Card.Root>
  );
}

// ============= SIDE-BY-SIDE WORKLOAD BAR COMPARISON =============

function WorkloadComparisonCard({
  items,
  dimension,
}: {
  items: WorkloadComparisonItem[];
  dimension: MetricDimension;
}) {
  const meta = DIMENSION_META[dimension];

  const chartData = useMemo(
    () =>
      items.map((item) => ({
        workload: item.workload,
        "v3.1 Baseline": item.baseline,
        "v3.2 Candidate": item.candidate,
      })),
    [items],
  );

  return (
    <Card.Root variant="outline">
      <VStack gap="4" style={styles.cardInner}>
        <HStack justify="between" align="start" wrap="wrap" gap="2">
          <VStack gap="0.5">
            <Heading render={<h3 />} size="sm" style={styles.headingReset}>
              {meta.workloadTitle}
            </Heading>
            <Text size="xs" tone="muted">
              Side-by-side runtime profile breakdown ({meta.unit})
            </Text>
          </VStack>
          <Badge variant="surface" size="xs" palette={grayPalette}>
            5 Profiles
          </Badge>
        </HStack>

        <BarChart
          data={chartData}
          index="workload"
          categories={["v3.1 Baseline", "v3.2 Candidate"]}
          colors={["slate", "blue"]}
          type="grouped"
          layout="vertical"
          height={264}
          valueFormatter={meta.formatValue}
          ariaLabel={`${meta.workloadTitle} grouped bar comparison`}
        />
      </VStack>
    </Card.Root>
  );
}

// ============= HORIZONTAL STACKED BREAKDOWN CARD =============

function BreakdownCard({
  title,
  data,
}: {
  title: string;
  data: BreakdownSegment[];
}) {
  return (
    <Card.Root variant="outline">
      <VStack gap="4" style={styles.cardInner}>
        <Heading render={<h3 />} size="sm" style={styles.headingReset}>
          {title}
        </Heading>
        <CategoryBar
          values={data.map((seg) => seg.value)}
          labels={data.map((seg) => seg.label)}
          colors={data.map((seg) => seg.color)}
          valueFormatter={(value) => `${value}%`}
          ariaLabel={`${title} percentage breakdown`}
        />
      </VStack>
    </Card.Root>
  );
}

// ============= MAIN COMPONENT =============

export interface DataDashboardProps extends StyleOverrideProps {}

/**
 * DataDashboard — dense metric-monitoring and A/B benchmark comparison screen
 * powered by UI SDK Chart primitives: filter bar with environment, range, and
 * metric dimension controls, 8 dual-series KPI sparkline cards with
 * multi-period deltas, side-by-side line overlay and grouped workload bar
 * charts, three-column category-bar distribution cards, and a regional
 * statistical-significance breakdown table.
 */
export function DataDashboard({ palette, style }: DataDashboardProps) {
  const queue = useMemo(() => Toast.createToaster(), []);
  const [environment, setEnvironment] = useState<EnvironmentId>("prod-global");
  const [range, setRange] = useState<DateRange>("30d");
  const [dimension, setDimension] = useState<MetricDimension>("latency");
  const [regionFilter, setRegionFilter] = useState<RegionFilter>("all");

  const envProfile = ENV_PROFILES[environment];
  const dimMeta = DIMENSION_META[dimension];

  const metrics = useMemo(() => buildMetrics(environment, range), [environment, range]);
  const overlayData = useMemo(
    () => buildOverlaySeries(environment, range, dimension),
    [environment, range, dimension],
  );
  const workloadItems = useMemo(
    () => buildWorkloadComparison(environment, dimension),
    [environment, dimension],
  );

  const cohortAllocationData = useMemo<BreakdownSegment[]>(
    () => [
      { label: "v3.2 Candidate", value: envProfile.candidateShare, color: "blue" },
      { label: "v3.1 Baseline", value: envProfile.baselineShare, color: "slate" },
      { label: "Holdout Control", value: envProfile.holdoutShare, color: "violet" },
    ],
    [envProfile],
  );

  const regionalRows = useMemo(() => {
    const scaled = BASE_REGIONAL_ROWS.map((row) => {
      const requestsM = Number((row.requestsM * envProfile.sampleScale).toFixed(1));
      const baseVal =
        dimension === "latency"
          ? Number((row.baselineLatencyMs * envProfile.latencyFactor).toFixed(1))
          : dimension === "throughput"
            ? Number((row.baselineThroughputK * envProfile.throughputFactor).toFixed(1))
            : Number((row.baselineErrorPct * envProfile.errorFactor).toFixed(3));
      const candVal =
        dimension === "latency"
          ? Number((row.candidateLatencyMs * envProfile.latencyFactor).toFixed(1))
          : dimension === "throughput"
            ? Number((row.candidateThroughputK * envProfile.throughputFactor).toFixed(1))
            : Number((row.candidateErrorPct * envProfile.errorFactor).toFixed(3));
      const deltaPct = baseVal !== 0 ? ((candVal - baseVal) / baseVal) * 100 : 0;
      const favorable = dimMeta.higherIsBetter ? deltaPct >= 0 : deltaPct <= 0;
      return {
        ...row,
        requestsM,
        baseVal,
        candVal,
        deltaPct,
        favorable,
      };
    });

    if (regionFilter === "all") return scaled;
    return scaled.filter((row) => row.status === regionFilter);
  }, [dimMeta.higherIsBetter, dimension, envProfile, regionFilter]);

  const maxRegionRequests = useMemo(
    () => Math.max(...BASE_REGIONAL_ROWS.map((r) => r.requestsM * envProfile.sampleScale), 1),
    [envProfile.sampleScale],
  );

  const envLabel =
    ENVIRONMENT_OPTIONS.find((opt) => opt.value === environment)?.label ?? environment;
  const summaryLine = `Edge Runtime A/B · v3.2 Candidate vs. v3.1 Baseline · ${envLabel} · ${RANGE_META[range].label}`;

  return (
    <div {...stylex.props(styles.root, palette, style)}>
      <header {...stylex.props(styles.header)}>
        <HStack justify="between" align="center" wrap="wrap" gap="4" style={styles.headerInner}>
          <VStack gap="1">
            <HStack align="center" wrap="wrap" gap="2.5">
              <Heading render={<h1 />} size="xl" style={styles.headingReset}>
                Data Dashboard
              </Heading>
              <Badge variant="subtle" size="sm" palette={greenPalette}>
                <Status.Root size="sm" palette={greenPalette}>
                  <Status.Indicator />
                  <span>99.4% Confidence</span>
                </Status.Root>
              </Badge>
            </HStack>
            <Text size="xs" tone="muted">
              {summaryLine}
            </Text>
          </VStack>

          <HStack align="center" wrap="wrap" gap="2">
            <SegmentGroup.Root
              size="sm"
              value={range}
              onValueChange={(next) => {
                if (next === "7d" || next === "30d" || next === "90d") {
                  setRange(next);
                }
              }}
              aria-label="Time window"
            >
              <SegmentGroup.Item value="7d">7d</SegmentGroup.Item>
              <SegmentGroup.Item value="30d">30d</SegmentGroup.Item>
              <SegmentGroup.Item value="90d">90d</SegmentGroup.Item>
            </SegmentGroup.Root>

            <Select.Root
              size="sm"
              variant="outline"
              value={environment}
              onValueChange={(next) => {
                if (next === "prod-global" || next === "canary-50" || next === "staging-load") {
                  setEnvironment(next);
                }
              }}
              style={styles.selectWrap}
            >
              <Select.Control>
                <Select.Trigger aria-label="Select environment">
                  <Select.Value>{envLabel}</Select.Value>
                </Select.Trigger>
                <Select.IndicatorGroup>
                  <Select.Icon />
                </Select.IndicatorGroup>
              </Select.Control>
              <Select.Content>
                {ENVIRONMENT_OPTIONS.map((opt) => (
                  <Select.Item key={opt.value} value={opt.value}>
                    <Select.ItemText>{opt.label}</Select.ItemText>
                    <Select.ItemIndicator />
                  </Select.Item>
                ))}
              </Select.Content>
            </Select.Root>

            <Select.Root
              size="sm"
              variant="outline"
              value={dimension}
              onValueChange={(next) => {
                if (next === "latency" || next === "throughput" || next === "errors") {
                  setDimension(next);
                }
              }}
              style={styles.selectWrap}
            >
              <Select.Control>
                <Select.Trigger aria-label="Select benchmark metric">
                  <Select.Value>
                    {DIMENSION_OPTIONS.find((opt) => opt.value === dimension)?.label}
                  </Select.Value>
                </Select.Trigger>
                <Select.IndicatorGroup>
                  <Select.Icon />
                </Select.IndicatorGroup>
              </Select.Control>
              <Select.Content>
                {DIMENSION_OPTIONS.map((opt) => (
                  <Select.Item key={opt.value} value={opt.value}>
                    <Select.ItemText>{opt.label}</Select.ItemText>
                    <Select.ItemIndicator />
                  </Select.Item>
                ))}
              </Select.Content>
            </Select.Root>

            <Button
              variant="surface"
              size="sm"
              onClick={() =>
                queue.info("Benchmark snapshot exported", {
                  description: `Prepared CSV report for ${envLabel} (${RANGE_META[range].label}).`,
                })
              }
            >
              <DownloadIcon />
              Export
            </Button>

            <Button
              variant="solid"
              size="sm"
              palette={bluePalette}
              onClick={() =>
                queue.success("Promotion queued for v3.2 Candidate", {
                  description: `Rolling ${envLabel} traffic from ${envProfile.candidateShare}% to 100% with automatic rollback guardrails.`,
                })
              }
            >
              <RocketIcon />
              Promote v3.2
            </Button>
          </HStack>
        </HStack>
      </header>

      <VStack render={<main />} gap="8" style={styles.content}>
        {/* Band 1: Dense comparison KPI sparkline cards */}
        <VStack render={<section aria-label="Benchmark metrics" />} gap="4">
          <SectionHeading
            title="Key benchmark metrics"
            hint="v3.2 Candidate vs. v3.1 Baseline · deltas across baseline, d/d, w/w, and m/m"
            icon={<GaugeIcon />}
          />
          <Grid gap="3" style={styles.metricsGrid}>
            {metrics.map((metric) => (
              <MetricComparisonCard key={metric.key} metric={metric} />
            ))}
          </Grid>
        </VStack>

        {/* Band 2: Multi-series overlay + side-by-side workload bar comparison */}
        <VStack render={<section aria-label="Candidate versus baseline charts" />} gap="4">
          <SectionHeading
            title="Candidate vs. baseline telemetry"
            hint={`Comparing ${dimMeta.shortTitle} across time and edge workload profiles`}
            icon={<ActivityIcon />}
          />
          <Grid gap="4" style={styles.comparisonGrid}>
            <OverlayComparisonChart data={overlayData} dimension={dimension} />
            <WorkloadComparisonCard items={workloadItems} dimension={dimension} />
          </Grid>
        </VStack>

        <Separator />

        {/* Band 3: Three-column stacked distribution cards */}
        <VStack render={<section aria-label="Runtime distributions" />} gap="4">
          <SectionHeading
            title="Traffic & runtime distribution"
            hint="Share of benchmarked requests by cohort, isolate execution path, and payload class"
            icon={<LayersIcon />}
          />
          <Grid gap="4" style={styles.threeColGrid}>
            <BreakdownCard title="Cohort Allocation" data={cohortAllocationData} />
            <BreakdownCard title="Execution Path" data={EXECUTION_PATH_DATA} />
            <BreakdownCard title="Payload Class" data={TRAFFIC_CLASS_DATA} />
          </Grid>
        </VStack>

        {/* Band 4: Regional breakdown table with statistical significance badges */}
        <VStack render={<section aria-label="Regional breakdown" />} gap="4">
          <SectionHeading
            title="Regional POP breakdown"
            hint={`Per-POP ${dimMeta.shortTitle} comparison with two-tailed Welch's t-test significance`}
            icon={<GlobeIcon />}
            trailing={
              <SegmentGroup.Root
                size="xs"
                value={regionFilter}
                onValueChange={(next) => {
                  if (next === "all" || next === "significant" || next === "watch") {
                    setRegionFilter(next);
                  }
                }}
                aria-label="Filter regional rows"
              >
                <SegmentGroup.Item value="all">All POPs</SegmentGroup.Item>
                <SegmentGroup.Item value="significant">Significant</SegmentGroup.Item>
                <SegmentGroup.Item value="watch">Watch</SegmentGroup.Item>
              </SegmentGroup.Root>
            }
          />

          <Card.Root variant="outline">
            <VStack gap="4" style={styles.cardInner}>
              <div {...stylex.props(styles.tableScroll)}>
                <Table.Root size="sm">
                  <Table.Header>
                    <Table.Row>
                      <Table.ColumnHeader>POP Region</Table.ColumnHeader>
                      <Table.ColumnHeader>Sample Volume</Table.ColumnHeader>
                      <Table.ColumnHeader>v3.1 Baseline</Table.ColumnHeader>
                      <Table.ColumnHeader>v3.2 Candidate</Table.ColumnHeader>
                      <Table.ColumnHeader>Delta</Table.ColumnHeader>
                      <Table.ColumnHeader>Significance</Table.ColumnHeader>
                    </Table.Row>
                  </Table.Header>
                  <Table.Body>
                    {regionalRows.map((row) => {
                      const sigPalette =
                        row.status === "significant"
                          ? greenPalette
                          : row.status === "watch"
                            ? redPalette
                            : grayPalette;
                      const sigText =
                        row.status === "significant"
                          ? `p < ${row.pValue < 0.001 ? "0.001" : "0.01"} · Sig.`
                          : row.status === "watch"
                            ? `p = ${row.pValue.toFixed(3)} · Watch`
                            : `p = ${row.pValue.toFixed(2)} · Neutral`;

                      return (
                        <Table.Row key={row.id}>
                          <Table.Cell>
                            <VStack gap="0.5">
                              <Text render={<span />} variant="mono" size="xs" weight="semibold">
                                {row.pop}
                              </Text>
                              <Text render={<span />} size="xs" tone="muted">
                                {row.regionName}
                              </Text>
                            </VStack>
                          </Table.Cell>
                          <Table.Cell>
                            <VStack gap="1" style={styles.progressCell}>
                              <Progress.Root
                                value={row.requestsM}
                                max={maxRegionRequests}
                                size="xs"
                                palette={bluePalette}
                                aria-label={`${row.pop} sample volume`}
                              >
                                <Progress.Track>
                                  <Progress.Range />
                                </Progress.Track>
                              </Progress.Root>
                              <Text
                                render={<span />}
                                variant="mono"
                                size="2xs"
                                tone="muted"
                                tabular="true"
                              >
                                {row.requestsM.toFixed(1)}M requests
                              </Text>
                            </VStack>
                          </Table.Cell>
                          <Table.Cell style={styles.nowrapCell}>
                            <Text render={<span />} variant="mono" size="xs" tabular="true">
                              {dimMeta.formatValue(row.baseVal)}
                            </Text>
                          </Table.Cell>
                          <Table.Cell style={styles.nowrapCell}>
                            <Text render={<span />} variant="mono" size="xs" tabular="true">
                              {dimMeta.formatValue(row.candVal)}
                            </Text>
                          </Table.Cell>
                          <Table.Cell>
                            <Badge
                              variant="subtle"
                              size="xs"
                              palette={
                                Math.abs(row.deltaPct) < 2
                                  ? grayPalette
                                  : row.favorable
                                    ? greenPalette
                                    : redPalette
                              }
                            >
                              {formatSignedPct(row.deltaPct)}
                            </Badge>
                          </Table.Cell>
                          <Table.Cell>
                            <Badge variant="outline" size="xs" palette={sigPalette}>
                              {sigText}
                            </Badge>
                          </Table.Cell>
                        </Table.Row>
                      );
                    })}
                  </Table.Body>
                </Table.Root>
              </div>
            </VStack>
          </Card.Root>
        </VStack>
      </VStack>

      <Toaster toaster={queue} />
    </div>
  );
}
```

Credit: Inspired by [Data Dashboard](https://astryx.atmeta.com/playground?template=dashboard-comparison) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
