/* Report chart mode: layout of the report page around the chart engine's own
   blocks (KPI strip, toolbar, hint). Owned by the report page
   (framework/report_page.rs); the engine's files (charts.css, chart_view.rs, kpi.rs)
   are not touched. Everything is keyed on `.xr-chart-mode`, which report_page puts on
   the page root while the Chart view is selected.

   The Table / Chart switch lives in the report command panel (.xr-cv-ctl), not here. */

/* Failed request: the message and its Retry button on one line. */
.xr-state-row.xr-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); }
.xr-state-row.xr-error .xr-retry { flex: 0 0 auto; }

/* Phone: a compact top part so the chart itself is visible without scrolling the card.
   Before: the two segmented controls, six KPI tiles with a caption, a three-row toolbar
   and a two-line hint took the whole card and the chart started below the fold.
   Measured at 375 px (mock, Delivery): the card scrolled 130 px; now the chart is fully visible. */
@media (max-width: 767px) {
  /* command-panel controls: Table/Chart + type + pin on one row; the pin is an icon */
  .xr-cv-ctl { flex: 1 1 100%; max-width: 100%; flex-wrap: wrap; gap: 6px; }
  .xr-cv-ctl .xr-cv-select { flex: 1 1 90px; min-width: 0; max-width: 140px; height: 30px; }
  .xr-cv-ctl .xr-cv-pin { flex: 0 0 auto; padding: 0 8px; }
  .xr-cv-ctl .xr-cv-pin-text, .xr-cv-ctl .xr-cv-pin-status { display: none; }
  /* Chart settings: an icon on a phone (the popover has the words) */
  .xr-cv-ctl .xr-cv-set-btn { flex: 0 0 auto; padding: 0 8px; }
  .xr-cv-ctl .xr-cv-set-text { display: none; }
  /* the page's own tool row (Columns / Display / export / More filters): two short rows instead of four */
  .xr-chart-mode .xr-results-toolbar { gap: 4px 6px; }
  .xr-chart-mode .xr-panel-tools { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .xr-chart-mode .xr-panel-tools > .xr-cfield { flex: 0 1 auto; min-width: 0; }
  .xr-chart-mode .xr-panel-tools .xr-tool-btn-value { display: none; }

  .xr-chart-mode .xr-kpis { flex: 0 0 auto; }
  .xr-cv-ctl .xr-cv-seg { flex: 0 0 auto; }
  .xr-cv-ctl .xr-cv-segbtn { padding: 0 10px; white-space: nowrap; }

  /* KPI: one short row, value and change side by side, the "vs previous" caption folded away */
  .xr-chart-mode .xr-kpis { gap: 6px; padding-bottom: 2px; }
  .xr-chart-mode .xr-kpi { flex: 0 0 auto; min-width: 112px; gap: 0; padding: 4px 10px; }
  .xr-chart-mode .xr-kpi-row { flex-wrap: nowrap; gap: 6px; }
  .xr-chart-mode .xr-kpi-value { font-size: 16px; line-height: 1.25; }
  .xr-chart-mode .xr-kpi-icon { display: none; }
  .xr-chart-mode .xr-kpi-caption { display: none; }

  /* chart toolbar: grouping caption and Export / Save on one wrapping row */
  .xr-chart-mode .xr-cv-toolbar { gap: 4px 6px; }
  .xr-chart-mode .xr-cv-toolbar > .xr-btn-sm { flex: 0 0 auto; height: 28px; padding: 0 8px; }
  .xr-chart-mode .xr-cv-groupcap { flex: 1 1 100%; }
  .xr-chart-mode .xr-cv-spacer { display: none; }

}

/* ---- Report card polish (2026-11-01) -------------------------------------------------------
   The chart card has NO scroll of its own: the report page's fit-to-viewport rules (.xr-fit)
   gave the results card a fixed share of the screen and scrolled its body, so the chart sat
   below the KPI tiles, three lines of notes and a button row, and was squeezed to ~160 px.
   In chart mode the card grows with its content and the page scrolls instead. */
.xr-chart-mode.xr-fit > .xr-results { flex: 0 0 auto; min-height: 0; }
.xr-chart-mode.xr-fit > .xr-results > .xr-results-body { flex: 0 0 auto; min-height: auto; overflow: visible; }
.xr-chart-mode .xr-results-body > .xr-body-slot { flex: 0 0 auto; }
.xr-chart-mode .xr-cv { padding: var(--sp-2) var(--sp-3) var(--sp-3); }

/* the chart is never squeezed: 320 px, 280 px on a narrow screen (the engine re-measures on resize) */
.xr-chart-mode .xr-cv-chart .xr-chart-canvas { min-height: 320px; }
.xr-chart-mode .xr-cv-chart .xr-chart-state { min-height: 320px; }
@media (max-width: 480px) {
  .xr-chart-mode .xr-cv-chart .xr-chart-canvas, .xr-chart-mode .xr-cv-chart .xr-chart-state { min-height: 280px; }
}

/* KPI tiles: one compact row that scrolls sideways, at every width */
.xr-chart-mode .xr-kpis { display: flex; overflow-x: auto; scroll-snap-type: x proximity; gap: 6px; padding-bottom: 4px; }
.xr-chart-mode .xr-kpi { flex: 0 0 auto; min-width: 112px; gap: 0; padding: 4px 10px; scroll-snap-align: start; }
.xr-chart-mode .xr-kpi-row { flex-wrap: nowrap; gap: 6px; }
.xr-chart-mode .xr-kpi-value { font-size: 16px; line-height: 1.25; }
.xr-chart-mode .xr-kpi-icon, .xr-chart-mode .xr-kpi-caption { display: none; }
.xr-chart-mode .xr-kpi-head { white-space: nowrap; }

/* download menu in the command panel */
.xr-cv-menu { display: flex; flex-direction: column; min-width: 170px; padding: 4px; }
.xr-cv-menuitem {
  height: auto; justify-content: flex-start; text-align: left; border: 0; background: transparent; color: var(--text-primary);
  font: inherit; font-size: var(--fs-body); padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
}
.xr-cv-menuitem:hover:not(:disabled) { background: var(--bg-hover); }
.xr-cv-menuitem:disabled { color: var(--text-secondary); opacity: .55; cursor: default; }
.xr-cv-menuitem:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* "Chart notes": one line until opened */
.xr-cv-notes { min-width: 0; color: var(--text-secondary); font-size: var(--fs-label); }
.xr-cv-notes > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; padding: 2px 4px; border-radius: var(--radius-sm); }
.xr-cv-notes > summary::-webkit-details-marker { display: none; }
.xr-cv-notes > summary:hover { color: var(--text-primary); background: var(--bg-hover); }
.xr-cv-notes > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.xr-cv-notes-count { min-width: 16px; padding: 0 5px; border-radius: 999px; text-align: center; font-size: 11px; background: var(--bg-surface-sunken); }
.xr-cv-notes-body { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; padding: 6px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-surface-sunken); }
