/* Chart library (framework/charts.rs). Categorical palette --chart-1..32,
   validated >= 3:1 against the surface colour by a unit test in charts.rs.
   Slots 1-8 (the ones stacks and legends use first), both themes: blue, cyan, green,
   orange, red-pink, grey-violet, teal, grey (= "Other"). The light set has similar
   lightness on purpose so no slot dominates a stack (the old brown/ochre 3-4 did). */
:root {
  --chart-1: #4b7be8; --chart-2: #1a9fc4; --chart-3: #2a9d68; --chart-4: #e4712a;
  --chart-5: #e24f66; --chart-6: #8089c4; --chart-7: #0f8f8a; --chart-8: #6b7280;
  --chart-9: #d6703d; --chart-10: #349d76; --chart-11: #dd47eb; --chart-12: #7f9720;
  --chart-13: #5b91c8; --chart-14: #eb4769; --chart-15: #22a02d; --chart-16: #8c66cc;
  --chart-17: #b88114; --chart-18: #219c97; --chart-19: #cc66b2; --chart-20: #519c11;
  --chart-21: #576ddb; --chart-22: #cc7366; --chart-23: #12a14e; --chart-24: #b557db;
  --chart-25: #919130; --chart-26: #1695ca; --chart-27: #db578e; --chart-28: #419d34;
  --chart-29: #6347eb; --chart-30: #ce772c; --chart-31: #349d83; --chart-32: #ea3ee2;
  /* heat map (framework/chart_heat.rs): fill per level 0..8 and the label colour that reads on it (contrast-tested) */
  --heat-0: #eef0f4; --heat-1: #d5e2fa; --heat-2: #bcd1f8; --heat-3: #a0bdf3; --heat-4: #82a5ec;
  --heat-5: #6590e3; --heat-6: #3b6fd0; --heat-7: #2f5dbb; --heat-8: #1f4597;
  --heat-fg-0: #1b1f26; --heat-fg-1: #1b1f26; --heat-fg-2: #1b1f26; --heat-fg-3: #1b1f26; --heat-fg-4: #1b1f26;
  --heat-fg-5: #1b1f26; --heat-fg-6: #ffffff; --heat-fg-7: #ffffff; --heat-fg-8: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chart-1: #7ba3f5; --chart-2: #4cc9e8; --chart-3: #5ccf8a; --chart-4: #f59e4b;
    --chart-5: #f2708f; --chart-6: #a89fd6; --chart-7: #3cc8b4; --chart-8: #9ca3af;
  --chart-9: #bd5a28; --chart-10: #39ac81; --chart-11: #bf17cf; --chart-12: #9ebd28;
  --chart-13: #3973ac; --chart-14: #dc1841; --chart-15: #28bd35; --chart-16: #845bc8;
  --chart-17: #cf9217; --chart-18: #28bdb7; --chart-19: #bb3e9c; --chart-20: #6bcf17;
  --chart-21: #4e65da; --chart-22: #bb4e3e; --chart-23: #17cf64; --chart-24: #a839d5;
  --chart-25: #acac39; --chart-26: #1799cf; --chart-27: #ce2c6f; --chart-28: #47ac39;
  --chart-29: #735aed; --chart-30: #bd6d28; --chart-31: #39ac90; --chart-32: #cf17c6;
  /* heat map (framework/chart_heat.rs): fill per level 0..8 and the label colour that reads on it (contrast-tested) */
  --heat-0: #262b34; --heat-1: #1f3560; --heat-2: #274a86; --heat-3: #2f5da8; --heat-4: #3e72c6;
  --heat-5: #5a8ee0; --heat-6: #82aaf0; --heat-7: #aec6f7; --heat-8: #d6e2fc;
  --heat-fg-0: #ffffff; --heat-fg-1: #ffffff; --heat-fg-2: #ffffff; --heat-fg-3: #ffffff; --heat-fg-4: #ffffff;
  --heat-fg-5: #0b1020; --heat-fg-6: #0b1020; --heat-fg-7: #0b1020; --heat-fg-8: #0b1020;
  }
}
:root[data-theme="dark"] {
  --chart-1: #7ba3f5; --chart-2: #4cc9e8; --chart-3: #5ccf8a; --chart-4: #f59e4b;
  --chart-5: #f2708f; --chart-6: #a89fd6; --chart-7: #3cc8b4; --chart-8: #9ca3af;
  --chart-9: #bd5a28; --chart-10: #39ac81; --chart-11: #bf17cf; --chart-12: #9ebd28;
  --chart-13: #3973ac; --chart-14: #dc1841; --chart-15: #28bd35; --chart-16: #845bc8;
  --chart-17: #cf9217; --chart-18: #28bdb7; --chart-19: #bb3e9c; --chart-20: #6bcf17;
  --chart-21: #4e65da; --chart-22: #bb4e3e; --chart-23: #17cf64; --chart-24: #a839d5;
  --chart-25: #acac39; --chart-26: #1799cf; --chart-27: #ce2c6f; --chart-28: #47ac39;
  --chart-29: #735aed; --chart-30: #bd6d28; --chart-31: #39ac90; --chart-32: #cf17c6;
  /* heat map (framework/chart_heat.rs): fill per level 0..8 and the label colour that reads on it (contrast-tested) */
  --heat-0: #262b34; --heat-1: #1f3560; --heat-2: #274a86; --heat-3: #2f5da8; --heat-4: #3e72c6;
  --heat-5: #5a8ee0; --heat-6: #82aaf0; --heat-7: #aec6f7; --heat-8: #d6e2fc;
  --heat-fg-0: #ffffff; --heat-fg-1: #ffffff; --heat-fg-2: #ffffff; --heat-fg-3: #ffffff; --heat-fg-4: #ffffff;
  --heat-fg-5: #0b1020; --heat-fg-6: #0b1020; --heat-fg-7: #0b1020; --heat-fg-8: #0b1020;
}
.xr-chart { position: relative; width: 100%; flex-shrink: 0; }
.xr-chart-canvas { width: 100%; flex-shrink: 0; }
.xr-chart-state {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: var(--fs-body);
}
.xr-chart-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg-surface); opacity: .7; color: var(--text-secondary); }
.xr-spark { display: inline-block; vertical-align: middle; }
.xr-chart-line { fill: none; stroke-width: 1.5; }
.xr-chart-c1 { stroke: var(--chart-1); } .xr-chart-c2 { stroke: var(--chart-2); }
.xr-chart-c3 { stroke: var(--chart-3); } .xr-chart-c4 { stroke: var(--chart-4); }
.xr-chart-c5 { stroke: var(--chart-5); } .xr-chart-c6 { stroke: var(--chart-6); }
.xr-chart-c7 { stroke: var(--chart-7); } .xr-chart-c8 { stroke: var(--chart-8); }

/* ---------------------------------------------------------------------
   Report chart mode (framework/chart_view.rs, framework/kpi.rs).
   Tokens only: surface/border/text from styles.css, series colours from
   --chart-N above, good/bad from --positive/--negative. Direction is also
   an arrow in the markup, so colour is never the only cue.
   --------------------------------------------------------------------- */
.xr-cv-ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-width: 0; }
/* same look as the command panel's other tool buttons (.xr-tool-btn-sm): 30px, 1px border, small radius */
.xr-cv-seg { display: inline-flex; gap: 0; padding: 0; height: 30px; box-sizing: border-box; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface); overflow: hidden; }
/* a narrow screen: a long grouping name ("By Day, Site ID and Site Name") wraps inside its button instead of being cut */
@media (max-width: 480px) {
  .xr-cv-seg { max-width: 100%; }
  .xr-cv-seg .xr-cv-segbtn { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.2; padding: 6px 10px; text-align: center; overflow-wrap: anywhere; }
}
.xr-cv-segbtn {
  border: 0; background: transparent; color: var(--text-secondary); cursor: pointer;
  font: inherit; font-size: var(--fs-body); font-weight: 600; line-height: 1; height: 100%; padding: 0 10px; border-radius: 0;
}
.xr-cv-segbtn + .xr-cv-segbtn { border-left: 1px solid var(--border-default); }
.xr-cv-segbtn:hover { background: var(--bg-hover); color: var(--text-primary); }
.xr-cv-segbtn.on { background: var(--bg-hover); color: var(--text-primary); }
.xr-cv-segbtn.on:hover { background: var(--bg-hover); }
.xr-cv-segbtn:focus-visible, .xr-kpi:focus-visible, .xr-cv-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.xr-cv { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; padding: var(--sp-2) 0; }
.xr-cv-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.xr-cv-spacer { flex: 1 1 auto; }
.xr-cv-select {
  font: inherit; font-size: var(--fs-body); color: var(--text-primary); background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: 5px 8px;
}
/* "Chart settings" popover: the report Display popover's section grid (.xr-pop-form-section) with a few additions */
.xr-cv-settings { min-width: min(340px, 86vw); }
.xr-cv-settings .xr-cv-set-head { grid-column: 1 / -1; }
.xr-cv-settings .xr-cv-set-name { color: var(--text-secondary); font-size: var(--fs-label); align-self: start; padding-top: 6px; }
.xr-cv-settings select.xr-cv-select { min-width: 0; width: 100%; height: 30px; }
.xr-cv-settings input[type="checkbox"] { justify-self: start; }
.xr-cv-set-measures { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.xr-cv-set-measure { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-width: 0; }
.xr-cv-set-measure label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.xr-cv-set-move { display: inline-flex; gap: 2px; flex: 0 0 auto; }
.xr-cv-set-move .xr-btn-icon { width: 24px; height: 24px; padding: 0; }
.xr-cv-set-move .xr-btn-icon:disabled { opacity: .35; cursor: default; }
.xr-cv-set-foot { display: flex; justify-content: flex-end; padding-top: var(--sp-2); border-top: 1px solid var(--border-default); }
.xr-cv-groupcap { color: var(--text-secondary); font-size: var(--fs-label); min-width: 0; overflow-wrap: anywhere; }
.xr-cv-pin-status { color: var(--text-secondary); font-size: var(--fs-label); }
.xr-cv-pin-status:empty { display: none; }
.xr-cv-note { margin: 0; color: var(--text-secondary); font-size: var(--fs-label); }
.xr-cv-chart { min-height: 240px; }
.xr-cv-error { flex-direction: column; gap: var(--sp-2); text-align: center; padding: var(--sp-3); }
.xr-cv-data summary { cursor: pointer; color: var(--text-secondary); font-size: var(--fs-label); }
.xr-cv-table-wrap { max-height: 280px; overflow: auto; margin-top: var(--sp-2); border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.xr-cv-table { border-collapse: collapse; width: 100%; font-size: var(--fs-label); }
.xr-cv-table th, .xr-cv-table td { padding: 4px 8px; text-align: right; border-bottom: 1px solid var(--border-default); white-space: nowrap; }
.xr-cv-table th:first-child, .xr-cv-table td:first-child { text-align: left; }
.xr-cv-table thead th { position: sticky; top: 0; background: var(--bg-surface-sunken); color: var(--text-secondary); font-weight: 600; }

/* KPI strip */
.xr-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-2); }
.xr-kpis:empty { display: none; }
.xr-kpi {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left;
  /* the global `button { height: 32px }` would clip the tile (value and delta overflow it) */
  height: auto; min-width: 0; padding: var(--sp-3); font: inherit; font-weight: 400; color: var(--text-primary); cursor: pointer;
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md);
}
/* value and change on one baseline: "24.8k +12%" */
.xr-kpi-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.xr-kpi-head { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--fs-label); }
.xr-kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.xr-kpi-icon { flex: 0 0 auto; }
.xr-kpi-value { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.xr-kpi-delta { font-size: var(--fs-label); font-weight: 500; font-variant-numeric: tabular-nums; min-height: 1em; white-space: nowrap; }
.xr-kpi-delta.xr-tone-good { color: var(--positive); }
.xr-kpi-delta.xr-tone-bad { color: var(--negative); }
.xr-kpi-delta.xr-tone-neutral { color: var(--text-secondary); }
.xr-kpi-caption { margin: 0; color: var(--text-secondary); font-size: var(--fs-label); text-align: right; }

@media (max-width: 640px) {
  /* one scrollable row: six tiles in a 2-column grid took the whole phone screen and pushed the chart out of view */
  .xr-kpis { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; }
  .xr-kpi { flex: 0 0 138px; scroll-snap-align: start; padding: var(--sp-2) var(--sp-3); }
  .xr-kpi-value { font-size: 19px; }
  .xr-kpi-head { white-space: nowrap; }
}

/* Optional badge for demo data next to a card title (orange tint from palette slot 4). */
.xr-badge-sample {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-label); font-weight: 500;
  white-space: nowrap; flex: 0 0 auto;
  color: var(--chart-4); background: color-mix(in srgb, var(--chart-4) 14%, var(--bg-surface));
}

/* ---------------------------------------------------------------------
   Charts v2 (2026-11-01): chart grouping bar, heat map legend, Traffic's
   summary hidden while its report chart is open.
   --------------------------------------------------------------------- */
.xr-cv-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.xr-cv-group-label { color: var(--text-secondary); font-size: var(--fs-label); }

/* heat map legend: nine steps from "0" to the largest figure, same tokens as the cells */
.xr-heat-legend { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--fs-label); }
.xr-heat-steps { display: inline-flex; gap: 2px; }
.xr-heat-step { width: 22px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 12%, transparent); }
@media (max-width: 480px) { .xr-heat-step { width: 14px; } .xr-heat-legend { flex-wrap: wrap; } }
.xr-heat-step-0 { background: var(--heat-0); } .xr-heat-step-1 { background: var(--heat-1); }
.xr-heat-step-2 { background: var(--heat-2); } .xr-heat-step-3 { background: var(--heat-3); }
.xr-heat-step-4 { background: var(--heat-4); } .xr-heat-step-5 { background: var(--heat-5); }
.xr-heat-step-6 { background: var(--heat-6); } .xr-heat-step-7 { background: var(--heat-7); }
.xr-heat-step-8 { background: var(--heat-8); }

/* A report whose chart view replaces its summary card (Traffic: the card has its own line chart, two charts
   on one screen). The summary precedes the results card as a sibling, so :has() on it finds the marker. */
.xr-summary.xr-summary:has(~ .xr-results .xr-cv-solo) { display: none !important; }
