/* xr-web design system -- ported from the "XR Web Report Screen" Design
   canvas mockup (Clicks + Delivery redesign, approved 2026-09-18): dark
   violet-accented sidebar with a gradient logo mark, Figtree (UI) + IBM
   Plex Mono (tabular data) via Google Fonts, rounded 12px cards, a single
   confident violet accent for interactive/active state kept separate from
   the semantic green/red used for deltas and status badges. Replaces the
   earlier plunk-web-derived monochrome token set. */

:root {
  /* -- spacing scale -------------------------------------------------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* -- radius / border -------------------------------------------------- */
  --radius-sm: 8px;
  --radius-md: 12px;

  /* -- type scale -------------------------------------------------- */
  --font-sans: 'Figtree', ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: 'IBM Plex Mono', ui-monospace, "SFMono-Regular", Menlo, monospace;
  --fs-label: 11px;
  --fs-body: 13px;
  --fs-heading: 22px;
  --lh-body: 1.4;

  /* -- neutral palette (from the mockup's #12151C / #F5F6F8 ground) ---- */
  --n-0: #ffffff;
  --n-50: #f5f6f8;
  --n-100: #eef0f3;
  --n-150: #e7e9ed;
  --n-200: #dee1e7;
  --n-300: #c9cdd6;
  --n-400: #9ba2b0;
  --n-500: #8890a0;
  --n-600: #626a7a;
  --n-700: #4a5060;
  --n-800: #22262f;
  --n-900: #12151c;
  --n-950: #0a0c11;

  /* -- accent: the one confident color the mockup uses, violet, reserved
     for interactive/active state -- kept out of the semantic
     positive/negative palette below. */
  --accent-500: #6c63ff;
  --accent-600: #4338ca;
  --accent-100: #ece9ff;

  /* -- semantic tokens -------------------------------------------------- */
  --bg-page: var(--n-50);
  --bg-surface: var(--n-0);
  --bg-surface-sunken: #fafbfc;
  --bg-hover: var(--n-50);
  --bg-sidebar: var(--bg-surface);
  --bg-sidebar-active: rgba(108, 99, 255, 0.12);
  --sidebar-strong: var(--n-900);
  --sidebar-line: var(--border-default);
  --sidebar-hover: rgba(18, 21, 28, 0.05);
  --sidebar-hover-strong: rgba(18, 21, 28, 0.08);
  --sidebar-label: var(--n-600);

  --text-primary: var(--n-900);
  --text-secondary: var(--n-600); /* n-500 was 3.0:1 on white (sweep) */
  --text-inverse: var(--n-0);
  --text-on-sidebar: var(--n-600);
  --text-on-sidebar-active: var(--accent-600);

  --border-subtle: var(--n-150);
  --border-default: var(--n-150);
  --border-strong: var(--n-300);
  --border-heading: var(--n-300);

  --accent: var(--accent-500);
  --accent-hover: var(--accent-600);
  --accent-soft-bg: var(--accent-100);
  --accent-soft-fg: var(--accent-600);
  --ring: var(--accent-500);

  --accent-contrast: var(--n-0);
  --bg-raised: var(--n-0);
  --bg-selected: var(--accent-100);
  --bg-backdrop: rgba(10, 12, 17, 0.45);

  --danger: #c22929;

  /* -- delta/diff + status-badge semantics (mockup's Trusted/Filtered
     badge colors) -------- */
  --positive: #12794a;
  --positive-soft-bg: #e7f8ef;
  --negative: #c22929;
  --negative-soft-bg: #fdecec;
  --warning: #9a5b00;
  --warning-fg: #8a5200;
  --warning-soft-bg: #fff5df;
  --info: #1f63b8;
  --info-soft-bg: #e8f1fc;

  /* -- heat map tints: space-separated RGB for `rgb(var(--x) / a)`. Warm,
     light hues used TRANSLUCENTLY (12-48%), so the value text keeps the
     theme's own colour and contrast in both themes. -------- */
  --heat-pos: 104 178 96;
  --heat-neg: 238 124 92;
  --heat-neutral: 214 190 140;
  --heat-pos-text: #245a1e;
  --heat-neg-text: #8f3219;
  --heat-neutral-text: #5c4d2c;

  --shadow-sm: 0 1px 2px 0 rgba(18, 21, 28, 0.06);
  --shadow-md: 0 8px 24px -4px rgba(18, 21, 28, 0.12), 0 2px 6px -2px rgba(18, 21, 28, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Dark palette v2 (2026-11-07, long-session pass): no pure black or
       pure white, four distinguishable ground levels (sidebar < page <
       sunken < surface < hover/raised), softer accent and status hues.
       Text >= 4.5:1 and control borders/accents >= 3:1 against
       --bg-surface; the ratios are tabulated in docs/ui/DARK_PALETTE_V2.md. */
    --bg-page: #14171d;
    --bg-surface: #1f242c;
    --bg-surface-sunken: #191d24;
    --bg-raised: #262b34;
    --bg-hover: #2b313c;
    --bg-selected: #2a2a48;
    --bg-sidebar: #101318;
    --bg-sidebar-active: rgba(149, 140, 245, 0.2);
    --bg-backdrop: rgba(6, 8, 12, 0.6);
    --sidebar-strong: #e6e9ef;
    --sidebar-line: rgba(230, 233, 239, 0.08);
    --sidebar-hover: rgba(230, 233, 239, 0.05);
    --sidebar-hover-strong: rgba(230, 233, 239, 0.09);
    --sidebar-label: #8a93a3;

    --text-primary: #e6e9ef;
    --text-secondary: #a7afbd;
    --text-inverse: #13161c;
    --text-on-sidebar: #aab2c0;
    --text-on-sidebar-active: #e4e1fd;

    --border-subtle: #323844;
    --border-default: #626e82;
    --border-strong: #7a859a;
    --border-heading: #4a5262;

    --accent: #958cf5;
    --accent-hover: #aea7f8;
    --accent-contrast: #13161c;
    --accent-soft-bg: #2a2a48;
    --accent-soft-fg: #c6c1fb;
    --ring: #a59df7;

    --danger: #ec8073;

    --positive: #5bbf82;
    --positive-soft-bg: #1a3226;
    --negative: #ec8073;
    --negative-soft-bg: #3c2422;
    --warning: #dcab5c;
    --warning-fg: #dcab5c;
    --warning-soft-bg: #352a17;
    --info: #6eaee8;
    --info-soft-bg: #1b2c40;

    --heat-pos: 80 200 125;
    --heat-neg: 236 110 95;
    --heat-neutral: 215 190 145;
    --heat-pos-text: #c4efb8;
    --heat-neg-text: #ffd0c2;
    --heat-neutral-text: #e6dac0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  /* Dark palette v2 (2026-11-07, long-session pass): no pure black or
     pure white, four distinguishable ground levels (sidebar < page <
     sunken < surface < hover/raised), softer accent and status hues.
     Text >= 4.5:1 and control borders/accents >= 3:1 against
     --bg-surface; the ratios are tabulated in docs/ui/DARK_PALETTE_V2.md. */
  --bg-page: #14171d;
  --bg-surface: #1f242c;
  --bg-surface-sunken: #191d24;
  --bg-raised: #262b34;
  --bg-hover: #2b313c;
  --bg-selected: #2a2a48;
  --bg-sidebar: #101318;
  --bg-sidebar-active: rgba(149, 140, 245, 0.2);
  --bg-backdrop: rgba(6, 8, 12, 0.6);
  --sidebar-strong: #e6e9ef;
  --sidebar-line: rgba(230, 233, 239, 0.08);
  --sidebar-hover: rgba(230, 233, 239, 0.05);
  --sidebar-hover-strong: rgba(230, 233, 239, 0.09);
  --sidebar-label: #8a93a3;

  --text-primary: #e6e9ef;
  --text-secondary: #a7afbd;
  --text-inverse: #13161c;
  --text-on-sidebar: #aab2c0;
  --text-on-sidebar-active: #e4e1fd;

  --border-subtle: #323844;
  --border-default: #626e82;
  --border-strong: #7a859a;
  --border-heading: #4a5262;

  --accent: #958cf5;
  --accent-hover: #aea7f8;
  --accent-contrast: #13161c;
  --accent-soft-bg: #2a2a48;
  --accent-soft-fg: #c6c1fb;
  --ring: #a59df7;

  --danger: #ec8073;

  --positive: #5bbf82;
  --positive-soft-bg: #1a3226;
  --negative: #ec8073;
  --negative-soft-bg: #3c2422;
  --warning: #dcab5c;
  --warning-fg: #dcab5c;
  --warning-soft-bg: #352a17;
  --info: #6eaee8;
  --info-soft-bg: #1b2c40;

  --heat-pos: 80 200 125;
  --heat-neg: 236 110 95;
  --heat-neutral: 215 190 145;
  --heat-pos-text: #c4efb8;
  --heat-neg-text: #ffd0c2;
  --heat-neutral-text: #e6dac0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg-page);
}

a {
  color: inherit;
}

h1 {
  font-size: var(--fs-heading);
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* thin, unobtrusive scrollbars everywhere -- this is a dense data tool with
   lots of scrolling surfaces (table body, sticky columns, chip popover); the
   default OS scrollbar is disproportionately heavy next to a 13px type
   scale. Firefox + WebKit/Blink variants both covered. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg-surface);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
  background-clip: padding-box;
}

/* keyboard-focus ring -- plunk's exact recipe (packages/ui Button/Input:
   "ring-2 ring-offset-2 ring-offset-white"), a light inset ring against
   --bg-surface plus a --ring-colored outer ring, so it reads as a halo
   rather than an accent-colored outline (plunk has no accent color). */
a:focus-visible,
button:focus-visible,
th:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
  border-radius: var(--radius-sm);
}

.xr-sidebar a:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--ring);
}

/* ===================== page header ===================== */
/* One row: "Reports / Title" + the Report Variants pill on the left, the
   compact header-scoped filters (DBA/Site) on the right. */

.xr-report {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.xr-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
  min-height: 44px;
}

.xr-page-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.xr-page-title {
  /* a narrow screen: the Variant pill drops under the title instead of pushing the page wider than the viewport */
  flex-wrap: wrap;
  row-gap: var(--sp-2);
  max-width: 100%;
}

.xr-page-title h1 {
  margin: 0;
  font-size: var(--fs-heading);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.xr-page-eyebrow {
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text-secondary);
}

.xr-page-crumb-sep {
  font-size: var(--fs-body);
  color: var(--text-secondary);
}

.xr-page-header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.xr-page-header-controls .xr-cfield select {
  min-width: 150px;
}

@media (max-width: 480px) {
  .xr-page-header-controls { margin-left: 0; max-width: 100%; }
  .xr-page-header-controls .xr-cfield select { min-width: 0; max-width: 100%; }
}

/* ===================== loading spinner ===================== */

.xr-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: var(--sp-2);
  vertical-align: -2px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: xr-spin 0.7s linear infinite;
}

@keyframes xr-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .xr-spinner {
    animation-duration: 1.8s;
  }
}

/* A refetch over rows already on screen (any filter change) dims the
   existing table and floats a spinner over it instead of replacing it, so
   nothing resizes/jumps and the previous data stays legible as "stale, a
   new answer is coming" rather than vanishing with no feedback. */
.xr-results-body {
  position: relative;
}
.xr-results-body.xr-refetching > :not(.xr-refetch-overlay) {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s ease 0.2s;
}
.xr-refetch-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Same delay as the dim above: a refetch that resolves in well under
     200ms (cache hit, tiny result) never flashes anything. */
  animation: xr-refetch-overlay-in 0.15s ease 0.2s both;
}
.xr-refetch-overlay .xr-spinner {
  width: 22px;
  height: 22px;
  margin-right: 0;
  border-width: 3px;
}
@keyframes xr-refetch-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .xr-results-body.xr-refetching > :not(.xr-refetch-overlay) { transition: none; }
  .xr-refetch-overlay { animation: none; }
}

/* ===================== shell / sidebar ===================== */

.xr-shell {
  display: flex;
  min-height: 100vh;
}

.xr-sidebar {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  color: var(--text-on-sidebar);
  padding: var(--sp-4) var(--sp-3) var(--sp-4);
  box-sizing: border-box;
}

.xr-sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--sidebar-line);
}

.xr-sidebar-logo {
  width: 30px;
  height: 30px;
  color: var(--sidebar-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex: none;
}

.xr-sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-strong);
  letter-spacing: -0.01em;
}

.xr-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xr-sidebar a {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-on-sidebar);
  position: relative;
}

/* Icons come from the `nav::NavItem::icon` registry; fixed box so labels
   line up whether or not an item declares one. */
.xr-sidebar a svg {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

.xr-sidebar a.active svg {
  opacity: 1;
}

.xr-sidebar a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-strong);
}

.xr-sidebar a.active {
  background: var(--bg-sidebar-active);
  color: var(--text-on-sidebar-active);
  font-weight: 600;
}

.xr-sidebar a.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

/* Section header: a disclosure <button> (aria-expanded/aria-controls).
   Scoped under .xr-sidebar so it beats the global button rules. */
.xr-sidebar .xr-sidebar-section-label {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-label);
  background: transparent;
  border-color: transparent;
  padding: 4px 10px;
  margin: 0 0 4px;
  text-align: left;
}

.xr-sidebar .xr-sidebar-section-label:not(:disabled):hover {
  background: var(--sidebar-hover);
  border-color: transparent;
  color: var(--sidebar-strong);
}

.xr-sidebar .xr-sidebar-section-label:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--ring);
}

.xr-nav-chevron {
  flex: none;
  transition: transform 0.15s ease;
}

.xr-sidebar-section-label[aria-expanded="false"] .xr-nav-chevron {
  transform: rotate(-90deg);
}

/* The panel is a flex column, which would beat the UA [hidden] rule. */
.xr-sidebar-nav[hidden] {
  display: none;
}

/* Vertical rhythm lives on the group wrapper (it used to depend on the
   label and the link list being adjacent siblings). */
.xr-sidebar-group + .xr-sidebar-group {
  margin-top: var(--sp-3);
}

.xr-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xr-nav-group + .xr-nav-group {
  margin-top: var(--sp-2);
}

.xr-nav-subgroup-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--sidebar-label);
  padding: 2px 10px;
}

.xr-main {
  flex: 1;
  padding: var(--sp-6);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===================== viewport-fit data screens ===================== */
/* A data screen (`.xr-fit` root: ReportPage, EntityList, DataCard pages) is
   exactly one viewport tall: the page column is a flex column of the screen's
   height, the results card takes whatever the header / filter bar leave, and
   the table scrolls INSIDE the card (both axes, header row pinned above the
   scroller, totals row pinned at its bottom, pager below it). A screen whose
   wrapper chain is not `.xr-fit` all the way keeps the natural height and the
   page scrolls, as before. Below ~320px of card height the page scrolls
   instead of squeezing the table to nothing. */
.xr-main:has(> .xr-fit) {
  height: 100vh;
  height: 100dvh;
}

.xr-fit {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  gap: var(--sp-4);
}

/* A screen root inside an .xr-fit parent must shrink with it: the base
   .xr-report rules (and some screen styles) opt out of shrinking, and one
   tall card would push the whole page past the viewport instead of scrolling
   inside the card. */
.xr-fit.xr-report,
.xr-fit.xr-crud-list {
  flex-shrink: 1;
}

.xr-fit > .xr-results {
  flex: 1 1 auto;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.xr-fit > .xr-results > .xr-results-toolbar {
  flex: none;
}

.xr-fit > .xr-results > .xr-results-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.xr-fit .xr-results-body > .xr-table-wrap,
.xr-fit .xr-results-body > .xr-body-slot {
  flex: 1 1 auto;
  min-height: 0;
  /* Without it the wrap is content-sized: a wide table inflates its own
     measuring container and the width distribution chases its own tail. */
  min-width: 0;
  max-width: 100%;
}

/* A screen-owned body (BodyMode::Custom) sits in this slot; a table it renders
   as a direct child takes the card exactly like the standard table does. */
.xr-fit .xr-body-slot {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.xr-fit .xr-body-slot > .xr-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.xr-fit .xr-results-body > .xr-table-footer,
.xr-fit .xr-results-body > .xr-state-row,
.xr-fit .xr-body-slot > .xr-state-row {
  flex: none;
}

/* The card's footer (row count | page controls | page size) is a sibling under
   the body: it never scrolls away. */
.xr-fit > .xr-results > .xr-table-footer {
  flex: none;
}

/* One scroll container for the body; the header strip above it never scrolls
   vertically, and both reserve the same scrollbar gutter so their columns
   stay aligned. */
.xr-fit .xr-table-wrap > .xr-table-header-scroll {
  flex: none;
  overflow: hidden;
  scrollbar-gutter: stable;
  background: var(--bg-surface-sunken);
}

.xr-fit .xr-table-wrap > .xr-table-body-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

/* The totals row stays visible at the bottom of the scroller. */
.xr-fit tfoot td:not(.xr-sticky-col) {
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.xr-fit tfoot td.xr-sticky-col {
  bottom: 0;
}

/* ===================== stacked field (popover panels) ===================== */





.xr-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
}

.xr-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.xr-field-label {
  font-size: var(--fs-label);
  color: var(--text-secondary);
  font-weight: 600;
}

.xr-divider {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: 0;
}


/* ===================== form controls ===================== */

select,
input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"] {
  appearance: none;
  -webkit-appearance: none;
  font-family: 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: 6px var(--sp-2);
  height: 32px;
  line-height: 1.2;
}

select:not([multiple]) {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px 7px;
  min-width: 140px;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

input::placeholder {
  color: var(--text-secondary);
}

label {
  font-size: var(--fs-body);
  color: var(--text-primary);
}

/* ===================== buttons ===================== */

button {
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 6px var(--sp-3);
  height: 32px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* default / secondary button */
button {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

button:not(:disabled):hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.xr-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

.xr-btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.xr-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 6px var(--sp-2);
}

.xr-btn-ghost:not(:disabled):hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Anchors styled as buttons ("Open in Ampier", "Validate", list "+ New"...): the
   box model of the bare `button` rule does not reach an <a>. Not for .xr-btn-sm
   (row links keep their 26px height). */
a.xr-btn-primary:not(.xr-btn-sm),
a.xr-btn-ghost:not(.xr-btn-sm) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  text-decoration: none;
  cursor: pointer;
}

a.xr-btn-primary:not(.xr-btn-sm) {
  padding: 6px var(--sp-3);
  font-weight: 600;
}

a.xr-btn-ghost:not(.xr-btn-sm) {
  padding: 6px var(--sp-2);
}

.xr-btn-sm {
  height: 26px;
  padding: 2px var(--sp-2);
  font-size: var(--fs-label);
}

.xr-btn-dashed {
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 600;
}

.xr-btn-dashed:not(:disabled):hover {
  background: var(--accent-soft-bg);
  border-color: var(--accent);
}

.xr-btn-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
}

/* ===== tabs (framework/tabs.rs) ===== */

.xr-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--sp-2); }
.xr-tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: var(--sp-2) var(--sp-3); }
.xr-tab.xr-tab-on { border-bottom-color: var(--accent); color: var(--accent-soft-fg); font-weight: 600; }

/* ===================== chip multi-select (ISP picker) ===================== */

.xr-chip-field {
  position: relative;
  min-width: 220px;
}

.xr-chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  padding: 3px 28px 3px 6px;
  cursor: text;
  /* Same inline-SVG chevron as every native `select:not([multiple])`
     above -- the ISP field is a custom chip+checkbox-popover control, not
     a real <select>, so it doesn't pick up that rule automatically; this
     is purely visual, so the field reads as "opens a dropdown" the same
     way DBA/Site/Campaign/etc. do right next to it. No markup/behavior
     change. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px 7px;
}

.xr-chip-box:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

.xr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
  border-radius: 999px;
  padding: 2px 4px 2px 8px;
  font-size: var(--fs-label);
  font-weight: 600;
  white-space: nowrap;
}

.xr-chip-remove {
  border: none;
  background: transparent;
  color: inherit;
  height: 16px;
  width: 16px;
  min-width: 16px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.xr-chip-remove:hover {
  background: rgba(0, 0, 0, 0.1);
}

.xr-chip-placeholder {
  color: var(--text-secondary);
  font-size: var(--fs-body);
  /* 13px at the inherited 1.4 line-height = 18.2px: with the 2px vertical
     padding the span is 22.19px, and inside the chip box's own 3px padding
     the content stack comes to 28.19px — 0.19px taller than the toolbar
     chip's 28px content area (.xr-results-toolbar: 30px field - 2 × 1px
     border). The opaque box then pokes into the parent's border on both
     sides; invisible at 100%, but at fractional display scales the browser's
     per-element device-pixel snapping turns it into a visible bite out of
     the top border right above the placeholder text. A round 18px line box
     makes the stack exactly 28px. (Selected-value chips fit already: 11px
     × 1.4 + padding ≈ 19.4 + 6 = 25.4px.) */
  line-height: 18px;
  padding: 2px 4px;
}

.xr-chip-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-2);
}

.xr-chip-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-body);
  cursor: pointer;
}

.xr-chip-option:hover {
  background: var(--bg-hover);
}

.xr-chip-option input[type="checkbox"] {
  margin: 0;
}

/* ===================== group-by / split-by pill rows ===================== */

.xr-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.xr-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-sunken);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 3px 3px 3px 10px;
}

.xr-pill select {
  border: none;
  background: transparent;
  height: 24px;
  padding: 0 20px 0 0;
  min-width: unset;
}

.xr-pill select:focus {
  box-shadow: none;
}

/* ===================== report variants: dropdown + menu + dialog ===================== */
/* Ported from legacy's `ReportVariants/index.js`: a small `ArrowDropDown`
   icon-button next to the report title opens a `Menu` (Default + every
   saved variant, current one highlighted, plus a "Manage Variants..."
   entry); that opens a `Dialog` for save/overwrite/delete. Reuses this
   crate's own `.xr-chip-popover` positioning convention for the menu, and
   a simple centered-overlay pattern for the dialog -- same dark-violet/
   rounded-12px language as the rest of the redesign, no new colors. */



.xr-variant-anchor {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.xr-variant-pill {
  max-width: 100%;
}

.xr-variant-pill-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-variant-pill {
  height: 30px;
  gap: 6px;
  padding: 0 10px 0 12px;
  border-radius: 999px;
  font-weight: 600;
}

.xr-variant-pill-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.xr-variants-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-2);
}

.xr-variants-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px var(--sp-2);
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  height: auto;
}

.xr-variants-menu-item:hover {
  background: var(--bg-hover);
}

.xr-variants-menu-item.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft-bg);
}

.xr-variants-menu-manage {
  color: var(--text-secondary);
  font-weight: 600;
}

.xr-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.xr-dialog {
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.xr-dialog-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.xr-dialog-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xr-dialog-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
}

.xr-dialog-list-row:hover {
  background: var(--bg-hover);
}

.xr-dialog-list-row-name {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-primary);
}

.xr-dialog-list-row-sub {
  font-size: var(--fs-label);
  color: var(--text-secondary);
}

.xr-dialog-list-row-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.xr-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

/* ===================== collapsible panel (custom filters / columns) ========= */

.xr-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-sunken);
  padding: var(--sp-3);
  margin-top: var(--sp-2);
  max-width: 680px;
}

.xr-panel-hint {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-label);
  color: var(--text-secondary);
}

.xr-filter-cond-row {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  align-items: center;
}

.xr-columns-grid {
  columns: 4;
  column-gap: var(--sp-4);
  padding: var(--sp-2) 0 0;
}

.xr-columns-grid label {
  display: block;
  white-space: nowrap;
  font-size: var(--fs-body);
  padding: 2px 0;
}

/* -- Advanced Settings: delta display (classic subtext / heatmap tint) -- */
.xr-cell-value {
  display: inline-block;
  border-radius: var(--radius-sm);
  padding: 1px 4px;
}

.xr-delta {
  display: block;
  font-size: var(--fs-label);
  color: var(--text-secondary);
}

.xr-delta-up {
  color: var(--positive);
}

.xr-delta-down {
  color: var(--negative);
}

/* ===================== results card / table ===================== */

.xr-results {
  /* NOTE: deliberately no `overflow: hidden` here (it used to clip the
     card's rounded corners) -- `overflow` other than `visible` on ANY
     ancestor of the table header makes that ancestor a "scroll container"
     for `position: sticky` purposes, even when (like here) it never
     actually scrolls -- and a sticky child of a non-scrolling container
     just renders pinned at that container's own top edge instead of
     visibly sticking to the viewport as the PAGE scrolls. That's exactly
     the bug this rule used to cause once `.xr-table-scroll`'s inner
     scrollbox was removed: removing max-height alone wasn't enough while
     this card still clipped. Corner rounding is recovered below via
     `.xr-table-header-scroll`'s own radius instead. */
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ===================== full-height, page-scrolling table ===================== */
/* Ported from `DataTable.js`'s "Sticky header + horizontally-scrollable
   wide table" comment: two separate <table>s (see
   `framework::table::SortableTable`'s doc comment for the full mechanism),
   so the table grows to its natural height in normal page flow -- letting
   the page itself scroll, and its own scroll is what the header sticks
   against -- while still allowing independent horizontal scroll of a wide
   table body without recapturing the sticky header inside a capped inner
   scrollbox (the old `.xr-table-scroll { overflow:auto; max-height:65vh }`
   this replaces). */
.xr-table-wrap {
  display: flex;
  flex-direction: column;
}

.xr-table-header-scroll {
  overflow-x: hidden;
  position: sticky;
  top: 0;
  z-index: 6;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.xr-table-body-scroll {
  overflow-x: auto;
}

table.xr-table-fixed {
  table-layout: fixed;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

td {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

thead th {
  /* No `position: sticky; top: 0` here anymore -- the whole header
     `<table>` now lives inside `.xr-table-header-scroll`, which is itself
     `position: sticky; top: 0` against the page, so individual header
     cells no longer need their own top-stickiness (see
     `framework::table::SortableTable`'s doc comment). `.xr-sticky-col`
     below still applies `position: sticky; left: ...` per cell, for the
     frozen leading columns' horizontal stickiness within the header's own
     micro-scroll (driven by JS mirroring the body's scrollLeft). */
  z-index: 5;
  background: var(--bg-surface-sunken);
  font-weight: 600;
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-heading);
}

thead th:hover {
  color: var(--text-primary);
}

th.sorted {
  color: var(--accent);
}

.xr-sort-icon {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.9;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

tbody tr:nth-child(even) td {
  background: var(--bg-surface-sunken);
}

tbody tr:nth-child(even):hover td {
  background: var(--bg-hover);
}

tfoot td {
  /* No `position: sticky; bottom: 0` -- legacy's totals row isn't sticky
     either (`DataTable.js`'s <TableFooter> is a plain row in the body
     table); that only made sense here while `.xr-table-scroll` was a
     capped inner scrollbox, which this task removes. */
  /* 1px in the subtle token: the old 2px strong line under a scrolling body
     read as a horizontal scrollbar. */
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
  background: var(--bg-surface-sunken);
  font-weight: 700;
}

/* Frozen/sticky leading group-by column(s) -- flat and pivot table modes.
   `left` itself is set inline per-cell (running sum of this fixed width,
   see `sticky_col_style` in delivery.rs); this rule supplies the fixed
   width, the sticky positioning, and an OPAQUE background so scrolling
   metric-column content doesn't show through underneath. z-index is
   layered above ordinary cells so frozen cells paint over the columns
   scrolling past/underneath them; thead's sticky-left cells additionally
   need to outrank thead's own sticky-top cells (equal z-index sticky
   siblings stack by DOM order, and non-frozen header cells come later in
   the row), so the header variant gets a higher z-index than body/footer. */
.xr-sticky-col {
  /* Width comes from the table's <colgroup> (content-based auto width or
     the user's dragged width), not a fixed 160px. */
  position: sticky;
  z-index: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-surface);
}

thead th.xr-sticky-col {
  z-index: 7;
  background: var(--bg-surface-sunken);
}

tfoot td.xr-sticky-col {
  z-index: 4;
  background: var(--bg-surface-sunken);
}

tbody tr:nth-child(even) td.xr-sticky-col {
  background: var(--bg-surface-sunken);
}

tbody tr:hover td.xr-sticky-col {
  background: var(--bg-hover);
}

/* ===================== toolbar (search) ===================== */

.xr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
}

.xr-toolbar input[type="search"] {
  min-width: 240px;
}

/* ===================== pagination ===================== */

/* THE table footer: three zones on one line -- row count on the left, page
   controls centered, page size on the right. The side zones share the free
   space equally (1fr) so the controls stay truly centered. Below 900px the
   count and the size stay on the first line and the controls wrap under them. */
.xr-table-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "count pages size";
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 16px;
  min-height: 44px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-sunken);
}

.xr-footer-count {
  grid-area: count;
  min-width: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.xr-footer-pages {
  grid-area: pages;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
}

.xr-footer-size {
  grid-area: size;
  display: flex;
  justify-content: flex-end;
}

.xr-footer-pages:not(:has(*)),
.xr-footer-size:not(:has(*)) {
  display: none;
}

.xr-table-footer button {
  padding: 4px 10px;
  height: 28px;
}

.xr-table-footer select {
  height: 28px;
}

@media (max-width: 900px) {
  .xr-table-footer {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "count size"
      "pages pages";
  }
  .xr-table-footer.xr-footer-bare {
    grid-template-areas: "count size";
  }
}

.xr-page-indicator {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Bottom corners of a results card. `.xr-results` cannot clip (`overflow`
   would break the sticky header, see its NOTE), so whatever paints last
   inside it must round its own bottom corners -- otherwise its square
   background covers the card's rounded border. The inner radius is one
   border width smaller than the card's. */
.xr-results .xr-table-footer,
.xr-results > .xr-table-wrap:last-child > .xr-table-body-scroll,
.xr-results-body > .xr-table-wrap:last-child > .xr-table-body-scroll {
  border-radius: 0 0 calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px);
}

/* A footer sits right under the body: the scroller above it keeps square
   bottom corners. */
.xr-results-body:has(+ .xr-table-footer) > .xr-table-wrap:last-child > .xr-table-body-scroll {
  border-radius: 0;
}

/* ===================== state rows ===================== */

.xr-state-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  color: var(--text-secondary);
  font-size: var(--fs-body);
}

.xr-state-row.xr-error {
  color: var(--danger);
}

.xr-state-row.xr-empty {
  color: var(--text-secondary);
  font-style: italic;
}

/* ===================== shared table: row features ===================== */
/* `framework::table` (SortableTable / SimpleTable): status row, clickable,
   selected and expanded rows, detail rows, selection column, Compact
   variant. Tokens only, so both themes follow automatically. */

/* One full-width status row (loading / error / empty) under the header. */
tbody.xr-status-body td.xr-status-cell,
tbody.xr-status-body tr:hover td.xr-status-cell {
  padding: 0;
  background: var(--bg-surface);
  white-space: normal;
}

tr.xr-row-clickable {
  cursor: pointer;
}

tr.xr-row-clickable:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -2px;
}

tbody tr.xr-row-selected td,
tbody tr.xr-row-selected td.xr-sticky-col,
tbody tr.xr-row-selected:nth-child(even) td {
  background: var(--accent-soft-bg);
}

tbody tr.xr-row-expanded td {
  border-bottom-color: transparent;
}

/* Expanded detail row: one cell across every column. */
tbody tr.xr-detail-row td.xr-detail-cell,
tbody tr.xr-detail-row:hover td.xr-detail-cell {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface-sunken);
  white-space: normal;
  cursor: default;
}

.xr-detail-inner {
  /* Stays in view while a wide Page table body is scrolled sideways. */
  position: sticky;
  left: var(--sp-4);
  max-width: calc(100vw - 2 * var(--sp-6));
}

/* Projects: the count chip on a project row of the tree. */
.xr-projects-count {
  flex: none; padding: 1px 8px; border-radius: 999px;
  background: var(--bg-surface-sunken); border: 1px solid var(--border-default);
  color: var(--text-secondary); font-size: var(--fs-label); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Projects: the current-project label in the card toolbar (kept on screen
   by the toolbar itself; a scroll listener on the page updates the name). */
.xr-projects-current { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.xr-projects-current b { font-weight: 600; color: var(--text-primary); }

/* Leading selection-checkbox column. */
th.xr-sel-col,
td.xr-sel-col {
  width: 36px;
  min-width: 36px;
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
  text-align: center;
  cursor: default;
}

th.xr-sel-col input,
td.xr-sel-col input {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

/* Column / cell utility classes (`SimpleColumn::class`, `col_classes`,
   `cell_class`). Element-qualified so they beat the global `th, td` rules. */
th.xr-td-center,
td.xr-td-center {
  text-align: center;
}

th.xr-td-right,
td.xr-td-right {
  text-align: right;
}

td.xr-td-mono {
  font-family: var(--font-mono);
}

td.xr-td-bold {
  font-weight: 600;
}

td.xr-td-nowrap {
  white-space: nowrap;
}

/* `row_span`: a full-width message row. */
tbody td.xr-row-span-cell {
  white-space: normal;
  color: var(--text-secondary);
}

/* Compact variant: one plain table sized to its content, own horizontal
   scroll, no pinned header. For cards, modals, forms and detail rows. */
.xr-table-compact-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table.xr-table-compact {
  width: auto;
  min-width: 0;
}

table.xr-table-compact th,
table.xr-table-compact td {
  padding: 6px var(--sp-3);
}

table.xr-table-compact thead th {
  position: static;
}

/* "N selected" next to an EntityList's bulk actions. */
.xr-bulk-count {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===================== summary blocks (Clicks-style reports) ===================== */

.xr-summary {
  margin: 0;
  /* One spacing between the summary's own widgets (stat strip, note, chart),
     the same step as between the page's other blocks. */
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* A fixed-height data screen squeezes only its results card; everything
   else (filter bar, summary, headers) keeps its natural height, so nothing
   ever collapses onto the card below it. */
.xr-fit > :not(.xr-results):not(.xr-fit) {
  flex-shrink: 0;
}

/* ...except a large summary block: it yields and scrolls inside its own area
   instead of pushing the results card (and the whole page) past the
   viewport. */
.xr-fit > .xr-summary.xr-summary {
  flex-shrink: 1;
  min-height: 0;
  overflow-y: auto;
}

.xr-summary-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}

.xr-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.xr-stat-label {
  font-size: var(--fs-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.xr-stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.xr-stat-positive,
.xr-stat-negative {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.xr-stat-positive::before,
.xr-stat-negative::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  align-self: center;
}

.xr-stat-positive::before {
  background: var(--positive);
}

.xr-stat-negative::before {
  background: var(--negative);
}

/* ===================== compact field (label inside the control) ===================== */
/* `FilterField compact`: "Send date · Last 7 days ▾". One bordered box of
   control height; the native control inside is borderless so the box is
   the only frame. */

.xr-cfield {
  display: inline-flex;
  align-items: center;
  height: 32px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  min-width: 0;
}

.xr-cfield:hover {
  border-color: var(--border-strong);
}

.xr-cfield:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

.xr-cfield-label {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 8px 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-default);
  white-space: nowrap;
}

.xr-cfield select,
.xr-cfield input[type="text"],
.xr-cfield input[type="date"] {
  height: 30px;
  border: none;
  background-color: transparent;
  font-weight: 600;
  box-shadow: none;
}

.xr-cfield select:focus,
.xr-cfield input:focus {
  box-shadow: none;
}

/* A compact select sizes to its CURRENT value (field-sizing), not to its
   longest option, and is capped + ellipsized so one long campaign name can't
   widen the bar. The open dropdown still lists full option text and the
   select carries the current label in `title` for hover. */
.xr-cfield select:not([multiple]) {
  field-sizing: content;
  min-width: 64px;
  max-width: 200px;
  padding-left: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-cfield input[type="text"] {
  width: 150px;
  padding-left: 10px;
}

.xr-cfield input[type="checkbox"] {
  margin: 0 10px;
}

/* Date range: preset select + (Custom only) the two date inputs, one row. */
.xr-cfield .xr-filter-row {
  flex-wrap: nowrap;
  gap: 0;
  align-items: center;
}

.xr-cfield .xr-filter-row > span {
  display: inline-flex;
  border-left: 1px solid var(--border-default);
}

/* Composite controls (chip picker, pill list, custom editors) keep their own
   frame; the compact box just hosts them. */
.xr-cfield .xr-chip-box {
  border: none;
  min-height: 30px;
  flex-wrap: nowrap;
  overflow: hidden;
}

/* Compact chip picker: as narrow as its current value ("All ISPs") allows,
   capped so many selected chips clip instead of widening the bar. The
   popover keeps its own 220px min-width. */
.xr-cfield .xr-chip-field {
  min-width: 0;
  max-width: 280px;
}

.xr-cfield .xr-chip,
.xr-cfield .xr-chip-placeholder {
  white-space: nowrap;
}

.xr-cfield .xr-pill-row {
  padding: 0 4px;
  flex-wrap: nowrap;
}

.xr-cfield-disabled {
  background: var(--bg-surface-sunken);
}

.xr-cfield-disabled:hover {
  border-color: var(--border-default);
}

.xr-flex-spacer {
  flex-grow: 1;
}

/* ===================== toolbar buttons + popovers ===================== */

.xr-tool-btn {
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

a.xr-tool-btn {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

a.xr-tool-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.xr-tool-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.xr-tool-btn-sm {
  height: 30px;
  padding: 0 10px;
  gap: 6px;
}

.xr-tool-btn-value {
  color: var(--text-secondary);
  font-weight: 500;
}

.xr-tool-icon {
  width: 30px;
  padding: 0;
  justify-content: center;
  color: var(--text-secondary);
}

.xr-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 700;
}

.xr-popover-anchor {
  position: relative;
}

/* Transparent full-screen click-catcher behind an open popover/menu: a
   click anywhere outside closes it. */
.xr-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
}

.xr-popover-panel {
  min-width: 280px;
  max-width: min(560px, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.xr-popover-right {
  left: auto;
  right: 0;
}

/* ===================== results card toolbar ===================== */

.xr-results-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--sp-2);
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border-default);
}

.xr-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  width: 220px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-sunken);
  color: var(--text-secondary);
  position: relative;
}

.xr-search:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

.xr-search input[type="search"] {
  border: none;
  background: transparent;
  height: 28px;
  padding: 0 22px 0 0;
  width: 100%;
  box-shadow: none;
}

.xr-search input[type="search"]:focus {
  box-shadow: none;
}

/* The clear "×" replaces the browser's own search-cancel button, so it looks
   and sits the same everywhere; the input reserves its width either way so
   the text does not shift when the button appears. */
.xr-search input[type="search"]::-webkit-search-cancel-button,
.xr-search input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.xr-search-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.xr-search-clear:hover { background: var(--bg-hover); color: var(--text-primary); }

.xr-results-toolbar .xr-cfield {
  height: 30px;
}

.xr-results-toolbar .xr-cfield select,
.xr-results-toolbar .xr-cfield input {
  height: 28px;
}

/* The table's sticky header strip sits under the toolbar now, so its own
   top corners are square. */
.xr-results-toolbar ~ .xr-table-wrap .xr-table-header-scroll,
.xr-results-toolbar ~ .xr-results-body .xr-table-header-scroll {
  border-radius: 0;
}

/* The panel: record actions on the LEFT ("+ New" first), then a spacer, then
   view options, search and export on the right
   (framework::page_shell::DataPanel draws the slots in that order). An empty
   slot takes no room. */
.xr-results-toolbar {
  min-height: 52px;
}
.xr-panel-slot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.xr-panel-slot:not(:has(*)) {
  display: none;
}
/* A panel whose slots are all empty draws no strip at all. */
.xr-results-toolbar:not(:has(.xr-panel-slot > *)) {
  display: none;
}
/* The one shared "New" button: the same size everywhere. */
.xr-panel-actions > .xr-btn-new {
  min-width: 56px;
  justify-content: center;
}

/* A toolbar narrower than ~700px (`overflow::is_narrow`, set by the report
   framework) wraps: line 1 New + view options + More filters, line 2 the
   search and the export; every filter is inside More filters. */
.xr-results-toolbar.xr-toolbar-narrow {
  flex-wrap: wrap;
  row-gap: var(--sp-2);
}
.xr-toolbar-narrow > .xr-panel-actions { order: 0; }
.xr-toolbar-narrow > .xr-panel-filters { order: 1; }
.xr-toolbar-narrow > .xr-panel-tools { order: 2; }
.xr-toolbar-narrow > .xr-flex-spacer { order: 3; }
.xr-toolbar-narrow > .xr-panel-more { order: 4; }
.xr-toolbar-narrow > .xr-panel-search { order: 5; flex: 1 1 calc(100% - 48px); }
.xr-toolbar-narrow > .xr-panel-export { order: 6; }
.xr-toolbar-narrow .xr-panel-search .xr-search { width: 100%; }

.xr-panel-actions > .xr-btn-primary,
.xr-panel-actions > .xr-btn-ghost,
.xr-panel-actions > button,
.xr-panel-actions > a {
  height: 30px;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}


/* =====================================================================
   Floating layer (framework::popover) -- portaled to <body>, fixed.
   ONE stacking order for the whole app: page < modal (1000) < popover
   (1100). Nothing inside the page can cover a popover any more.
   ===================================================================== */

.xr-pop {
  position: fixed;
  z-index: 1100;
  top: 0;
  left: 0;
  max-width: min(560px, calc(100vw - 16px));
  overflow: auto;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.xr-pop.xr-popover-panel {
  display: flex;
}

.xr-pop.xr-select-pop {
  display: flex;
  flex-direction: column;
  padding: 6px;
  min-width: 200px;
  max-width: min(420px, calc(100vw - 16px));
  overflow: hidden;
}

.xr-variants-menu.xr-pop {
  position: fixed;
  top: 0;
  z-index: 1100;
}

.xr-search-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.xr-pop-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-sunken);
  color: var(--text-secondary);
  flex: none;
}

.xr-pop-search:focus-within {
  border-color: var(--ring);
}

.xr-pop-search {
  position: relative;
}

.xr-pop-search input[type="search"] {
  border: none;
  background: transparent;
  height: 28px;
  padding: 0 22px 0 0;
  width: 100%;
  box-shadow: none;
}

.xr-pop-search input[type="search"]:focus {
  box-shadow: none;
}

/* The clear "×" (same as .xr-search-clear): the browser's own search-cancel
   is suppressed for a consistent look. */
.xr-pop-search input[type="search"]::-webkit-search-cancel-button,
.xr-pop-search input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.xr-pop-options {
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.xr-pop-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: var(--fs-body);
  cursor: pointer;
  user-select: none;
}

.xr-pop-option.active {
  background: var(--bg-hover);
}

.xr-pop-option.selected {
  color: var(--accent);
  font-weight: 600;
}

/* A grouped option run (e.g. sites matching the previous screen's header
   filter, drawn under the "In your current filter" section label) -- see
   `framework::select::SearchList` and `framework::spec::Opt::group`. */
.xr-pop-option.xr-pop-option-grouped .xr-pop-option-label {
  font-weight: 600;
}

.xr-pop-option input[type="checkbox"] {
  margin: 0;
  pointer-events: none;
}

.xr-pop-option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-pop-option mark,
.xr-search-list mark {
  background: rgb(var(--heat-neutral) / 0.55);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 700;
}

.xr-pop-empty {
  padding: 8px;
  font-size: var(--fs-label);
  color: var(--text-secondary);
}

.xr-pop-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 0;
  margin-top: 4px;
  border-top: 1px solid var(--border-default);
  font-size: var(--fs-label);
  color: var(--text-secondary);
  flex: none;
}

.xr-pop-footer > span {
  margin-right: auto;
}

.xr-pop-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 8px 4px 4px;
}

/* -- single-value select trigger (framework::select::SelectBox) -- */

.xr-select {
  position: relative;
  min-width: 0;
}

.xr-select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 120px;
  height: 32px;
  padding: 0 28px 0 10px;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px 7px;
  border: 1px solid var(--border-default);
  text-align: left;
}

.xr-select-trigger:not(:disabled):hover {
  background-color: var(--bg-surface);
}

.xr-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-cfield .xr-select-trigger {
  border: none;
  background-color: transparent;
  height: 30px;
  min-width: 64px;
  max-width: 220px;
  font-weight: 600;
  box-shadow: none;
}

.xr-cfield .xr-select-trigger:not(:disabled):hover {
  background-color: transparent;
}

.xr-cfield .xr-select-trigger:focus-visible {
  box-shadow: none;
}

.xr-results-toolbar .xr-cfield .xr-select-trigger {
  height: 28px;
}

.xr-cfield .xr-filter-row .xr-select-trigger {
  min-width: 100px;
}

/* -- compact chips (multi-select trigger) -- never grows past its box -- */

.xr-chip-field {
  min-width: 160px;
  max-width: 100%;
}

.xr-chip-box {
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 3px;
  min-height: 32px;
  cursor: pointer;
}

.xr-chip-box:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

.xr-chip-box-disabled {
  cursor: default;
  opacity: 0.6;
}

.xr-chip {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 120px;
  height: 20px;
  gap: 2px;
  padding: 0 2px 0 7px;
  font-size: 11px;
  line-height: 20px;
}

.xr-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xr-chip-remove {
  height: 14px;
  width: 14px;
  min-width: 14px;
  font-size: 9px;
}

.xr-chip-more {
  flex: none;
  height: 20px;
  line-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-surface-sunken);
  border: 1px solid var(--border-default);
}

.xr-chip-placeholder {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.xr-cfield .xr-chip-field {
  min-width: 96px;
  max-width: 260px;
}

.xr-cfield .xr-chip-box {
  min-height: 30px;
  padding-left: 6px;
}

.xr-cfield .xr-chip-placeholder {
  font-weight: 600;
  color: var(--text-primary);
}

.xr-results-toolbar .xr-chip-box {
  min-height: 28px;
}

/* =====================================================================
   Grouped multi-select (framework::select::MultiSelectBox's `groups`) --
   the Project picker (framework::scope_filters::ProjectPicker) is its
   first user. Each group's parent row carries its OWN checkbox
   (indeterminate while only some children are picked); the children are
   the shared option rows, indented one step. A group with an EMPTY value
   has nothing of its own to select and draws as a plain heading
   (`.xr-pop-section-label`) instead of a row.
   ===================================================================== */

.xr-pop-group-row {
  font-weight: 600;
}

.xr-pop-option-child {
  padding-left: 26px;
}

/* The parent row's "how many children" counter. */
.xr-pop-option-count {
  flex: none;
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* The tri-state tree's INHERITED site row (framework::scope_filters::
   site_pick_state): in scope through its checked DBA row, not picked here --
   drawn checked, but muted grey, unlike an explicitly picked row's accent
   (`.xr-pop-option.selected`). Label and checkbox are both mixed towards the
   surface token (color-mix), so the grey tracks light and dark themes. */
.xr-pop-option.xr-pop-option-inherited .xr-pop-option-label {
  color: color-mix(in srgb, var(--text-primary) 62%, var(--bg-surface));
}

.xr-pop-option.xr-pop-option-inherited input[type="checkbox"] {
  accent-color: color-mix(in srgb, var(--accent) 55%, var(--bg-surface));
  opacity: 0.7;
}

/* -- ordered chips: drag to reorder -- */

.xr-chip-drag {
  cursor: grab;
  touch-action: none;
  position: relative;
}

.xr-chip-drag:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.xr-chip-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.xr-drop-before {
  box-shadow: -3px 0 0 0 var(--accent);
}

.xr-drop-after {
  box-shadow: 3px 0 0 0 var(--accent);
}

.xr-olist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 4px;
}

.xr-olist-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: var(--fs-body);
}

.xr-olist-row:hover {
  background: var(--bg-hover);
}

.xr-olist-row:focus-visible {
  outline: 2px solid var(--ring);
}

.xr-olist-row.xr-drop-before {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

.xr-olist-row.xr-drop-after {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

.xr-olist-grip {
  cursor: grab;
  touch-action: none;
  color: var(--text-secondary);
  letter-spacing: -3px;
  padding: 0 6px 0 2px;
  user-select: none;
}

.xr-olist-idx {
  min-width: 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.xr-olist-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =====================================================================
   Modal (framework::popover::Modal)
   ===================================================================== */

.xr-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.xr-modal {
  width: 100%;
  max-width: 480px;
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  outline: none;
}

.xr-modal-wide {
  max-width: 880px;
}

.xr-modal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-default);
  flex: none;
}

.xr-modal-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
}

.xr-modal-body {
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  overflow-y: auto;
  min-height: 0;
}

.xr-modal-scroll {
  min-height: 120px;
}

/* -- custom filter rules inside the modal -- */

.xr-filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.xr-filter-group-nested {
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--accent-soft-bg);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface-sunken);
}

.xr-filter-group-head,
.xr-filter-group-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.xr-filter-add {
  width: 200px;
}

.xr-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.xr-filter-cond-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 140px minmax(200px, 2fr) 26px;
  gap: var(--sp-2);
  align-items: center;
  margin: 0;
}

.xr-filter-cond-row > * {
  min-width: 0;
}

.xr-filter-cond-row .xr-chip-field {
  min-width: 0;
}

.xr-filter-text {
  width: 100%;
}

/* =====================================================================
   Heat map: every cell is a tinted tile filling its table cell, with the
   SAME gap between tiles horizontally and vertically (2px td padding on
   each side = 4px, and no row hairline under tiles).
   ===================================================================== */

td:has(> .xr-heat) {
  padding: 2px;
  border-bottom: 0;
  /* No `height: 1px` + `height: 100%` trick: Firefox resolves the percentage
     against that 1px and collapses the tile to its padding, so the value and
     delta spill out of it. The tile is instead sized by its own content, with
     a floor so tiles without a delta line (empty cells) match their row. */
}

/* Cells without a tile in the same row keep the row rhythm but lose their
   hairline, so the line does not stop and start along the row. */
tr:has(.xr-heat) > td:not(:has(> .xr-heat)) {
  border-bottom-color: transparent;
}

.xr-heat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  min-height: 50px;
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 4px;
}

/* No value: a plain light-grey tile, not the warm "no change" tint. */
.xr-heat-empty {
  background-color: var(--heat-empty-bg);
  color: var(--text-secondary);
}

.xr-cell-value {
  padding: 0;
}

/* =====================================================================
   Table: resizable columns, merged two-row headers
   ===================================================================== */

thead th {
  position: relative;
}

thead th.xr-th-merged {
  vertical-align: bottom;
}

thead th[rowspan] {
  vertical-align: bottom;
}

.xr-col-resize {
  position: absolute;
  top: 0;
  /* Fully INSIDE the header cell: the header scrollbox clips overflow, so a
     handle straddling the right edge (-4px) kept only a ~1px grab sliver --
     pointer events landed on the next column's header instead, and resizing
     was dead (owner report, flow-subscriptions). The 8px strip at the inner
     edge is the handle. */
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.xr-col-resize::after {
  content: "";
  position: absolute;
  top: 25%;
  bottom: 25%;
  left: 3px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.12s;
}

thead th:hover .xr-col-resize::after,
.xr-col-resize:active::after {
  background: var(--border-strong);
}

/* Column reordering (framework/table.rs): drag a metric header. */
th.xr-th-movable {
  touch-action: pan-y;
}
th.xr-th-movable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.xr-table-col-dragging,
.xr-table-col-dragging * {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing !important;
}
th.xr-th-drag-src {
  opacity: 0.35;
}
.xr-col-drop-line {
  position: fixed;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft-bg);
  pointer-events: none;
  z-index: 1000;
}
.xr-col-drag-ghost {
  position: fixed;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-surface);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  z-index: 1001;
}

/* =====================================================================
   Collapsible sidebar
   ===================================================================== */

.xr-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.22s cubic-bezier(0.2, 0, 0, 1), padding 0.22s cubic-bezier(0.2, 0, 0, 1);
  will-change: width;
}

.xr-sidebar-text {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s ease;
}

.xr-sidebar-header {
  position: relative;
}

.xr-sidebar-toggle {
  margin-left: auto;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  color: var(--text-on-sidebar);
}

.xr-sidebar-toggle:not(:disabled):hover {
  background: var(--sidebar-hover-strong);
  border-color: transparent;
  color: var(--sidebar-strong);
}

.xr-sidebar-toggle svg {
  transition: transform 0.22s ease;
}

.xr-sidebar-initial {
  flex: none;
  width: 16px;
  text-align: center;
  font-weight: 700;
}

.xr-shell-collapsed .xr-sidebar {
  width: 64px;
  padding-left: 10px;
  padding-right: 10px;
}

.xr-shell-collapsed .xr-sidebar-text {
  opacity: 0;
  width: 0;
}

.xr-shell-collapsed .xr-sidebar-header {
  flex-direction: column;
  gap: 6px;
  padding-left: 0;
  padding-right: 0;
}

.xr-shell-collapsed .xr-sidebar-toggle {
  margin-left: 0;
}

.xr-shell-collapsed .xr-sidebar-toggle svg {
  transform: rotate(180deg);
}

.xr-shell-collapsed .xr-sidebar a {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

.xr-shell-collapsed .xr-sidebar .xr-sidebar-section-label {
  height: 1px;
  margin: 10px 6px;
  padding: 0;
  background: var(--sidebar-line);
}

.xr-shell-collapsed .xr-nav-chevron {
  display: none;
}

/* Icon rail: sub-labels become thin dividers between groups. */
.xr-shell-collapsed .xr-nav-subgroup-label {
  height: 1px;
  margin: 6px 12px;
  padding: 0;
  background: var(--sidebar-line);
}

.xr-shell-collapsed .xr-sidebar-group + .xr-sidebar-group {
  margin-top: 0;
}

.xr-shell-collapsed .xr-sidebar a.active::before {
  left: -10px;
}

@media (prefers-reduced-motion: reduce) {
  .xr-sidebar,
  .xr-sidebar-text,
  .xr-sidebar-toggle svg,
  .xr-col-resize::after {
    transition: none;
  }
}

/* =====================================================================
   Outline mode ("groupings in one column")
   ===================================================================== */

.xr-tree-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.xr-tree-toggle {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
}

.xr-tree-toggle svg {
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.xr-tree-toggle[aria-expanded="false"] svg {
  transform: rotate(0deg);
}

.xr-tree-spacer {
  flex: none;
  width: 18px;
}

.xr-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr.xr-tree-parent td {
  font-weight: 600;
}

tbody tr.xr-tree-parent.xr-tree-l0 td,
.xr-pinned-rows tr.xr-tree-l0 td {
  background: var(--bg-surface-sunken);
}

.xr-pinned-rows td {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--fs-body);
  color: var(--text-primary);
  cursor: default;
}

.xr-pinned-rows tr:last-child td {
  box-shadow: 0 2px 4px -2px rgba(18, 21, 28, 0.18);
}

.xr-pinned-rows td.xr-sticky-col {
  z-index: 7;
}

@media (prefers-reduced-motion: reduce) {
  .xr-tree-toggle svg {
    transition: none;
  }
}

/* ===================== compact field: ONE focus ring ===================== */
/* The outer `.xr-cfield:focus-within` ring is the only focus indication of
   a compact field. Every inner control (chip box, select trigger, date/text/
   search inputs, chip remove buttons, ...) would otherwise draw its own
   ring/border inside it -- a double outline. `!important` because the inner
   rules are scattered and some are more specific (`.xr-chip-box:focus-visible`). */
.xr-cfield *:focus,
.xr-cfield *:focus-visible,
.xr-cfield *:focus-within {
  outline: none !important;
  box-shadow: none !important;
}

.xr-cfield .xr-chip-box:focus-within,
.xr-cfield .xr-chip-box:focus-visible,
.xr-cfield input:focus,
.xr-cfield select:focus,
.xr-cfield .xr-select-trigger:focus-visible {
  border-color: transparent !important;
}

.xr-cfield:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--ring);
}

/* ===================== unified toolbar: inline filters ===================== */
/* The primary filters sit inline in the card's ONE toolbar row (left group,
   after New). A filter that does not fit (`overflow::inline_filters`) stays
   laid out (so its natural width stays measurable -- no hidden clone, no
   flicker) but is taken out of flow, invisible and inert; its twin inside the
   More filters popover is shown instead. */
.xr-panel-filters {
  position: relative;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: clip;
  overflow-clip-margin: 6px;
}

.xr-qb-item {
  flex: 0 0 auto;
  display: flex;
}

.xr-qb-item:empty {
  display: none;
}

.xr-qb-item.xr-qb-overflow {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  visibility: hidden;
  pointer-events: none;
}

/* The More filters button is the toolbar's right edge; unused, it stays laid
   out (measurable) but out of flow and invisible. */
.xr-panel-more:has(> .xr-qb-more-off) {
  position: absolute;
  right: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

.xr-tool-btn-on {
  border-color: var(--accent);
}

.xr-pop-hidden {
  display: none !important;
}

/* ===================== popover forms (More filters / Display) ===================== */
/* Sections with small uppercase labels; every field is a row on one grid:
   checkbox rows (16px box on the label's first line, hint below), and
   label/control rows in two columns for selects/text. Wide composite
   controls (chips, date range, custom editors) stack label above control. */
.xr-pop-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 280px;
}

.xr-pop-form-section {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(160px, 1fr);
  column-gap: var(--sp-3);
  row-gap: 10px;
  align-items: center;
}

.xr-pop-form-section + .xr-pop-form-section {
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

.xr-pop-form-label {
  grid-column: 1 / -1;
  margin: 0 0 -2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.xr-prow-check {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 16px 1fr;
  column-gap: 10px;
  align-items: start;
  cursor: pointer;
  user-select: none;
}

.xr-prow-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0; /* centres the box on the 20px first text line */
  accent-color: var(--accent);
  cursor: pointer;
}

.xr-prow-check.xr-prow-disabled {
  cursor: default;
  opacity: 0.6;
}

.xr-prow-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.xr-prow-label {
  font-size: var(--fs-body);
  line-height: 20px;
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.xr-prow-hint {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary);
}

/* two-column label/control row: its children join the section grid */
.xr-prow-grid {
  display: contents;
}

.xr-prow-grid > .xr-prow-label {
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.xr-prow-grid > .xr-prow-control {
  min-width: 0;
  display: flex;
}

.xr-prow-grid > .xr-prow-control > * {
  flex: 1 1 auto;
  min-width: 0;
}

.xr-prow-grid > .xr-prow-hint {
  grid-column: 2;
  margin-top: -6px;
}

.xr-prow-stack {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.xr-prow-stack > .xr-prow-label {
  color: var(--text-secondary);
  font-weight: 600;
}

.xr-pop-slot {
  display: contents;
}

/* A chip without its ✕ (e.g. the last required Group by) must not end in the
   2px gutter meant for the ✕ button: mirror the left padding instead. */
.xr-chip:not(:has(.xr-chip-remove)) {
  padding-right: 7px;
}

/* Sortable headers of the Split-by (pivot) table. */
th.xr-sortable {
  cursor: pointer;
  user-select: none;
}

th.xr-sortable:hover {
  color: var(--text-primary);
}

.xr-variant-custom { font-style: italic; }

/* ===================== column-header quick filters =====================
   framework::column_filter — funnel icon in <th> + hover bubble. */
.xr-colf-anchor {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
}
.xr-colf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}
th:hover .xr-colf-btn,
th:focus-within .xr-colf-btn,
.xr-colf-btn:focus-visible,
.xr-colf-btn[aria-expanded="true"],
.xr-colf-btn.is-active {
  opacity: 1;
}
.xr-colf-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.xr-colf-btn.is-active {
  color: var(--accent);
}
.xr-colf-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ring);
}
@media (hover: none) {
  .xr-colf-btn { opacity: 1; }
}
.xr-colf-pop {
  /* As wide as its content: a metric bubble is exactly the width of the
     signal toggle; value pickers get their own minimum below. */
  width: max-content;
  min-width: 0;
  max-width: min(320px, 92vw);
  overflow-y: auto;
}
.xr-colf {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3);
  text-transform: none;
  font-weight: normal;
  white-space: normal;
}
.xr-colf-title {
  font-weight: 600;
  color: var(--text-primary);
}
.xr-colf-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.xr-colf-section + .xr-colf-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--sp-3);
}
.xr-colf-label {
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.xr-colf-hint {
  margin: 0;
}
.xr-colf-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}
.xr-colf-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
}
.xr-colf-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 0 0 var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--positive-soft-bg);
  color: var(--positive);
  font-size: var(--fs-body);
}
.xr-colf-chip.is-neg {
  background: var(--negative-soft-bg);
  color: var(--negative);
}

/* Column-filter funnel: pinned to the header's right edge (left of the
   resize grip) so a long label is ellipsized instead of pushing it out of
   view. Its colour tells the column's signal filter at a glance. */
thead th:has(> .xr-colf-anchor) {
  padding-right: 28px;
}
.xr-colf-anchor {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  z-index: 1;
}
.xr-colf-btn.is-positive {
  color: var(--positive);
  opacity: 1;
}
.xr-colf-btn.is-negative {
  color: var(--negative);
  opacity: 1;
}

/* Theme switch at the bottom of the sidebar. */
.xr-sidebar {
  display: flex;
  flex-direction: column;
}
.xr-sidebar-footer {
  margin-top: auto;
  padding: var(--sp-2);
  border-top: 1px solid var(--sidebar-line);
}
.xr-theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-on-sidebar);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.xr-theme-toggle:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-strong);
}
.xr-theme-toggle svg {
  flex: none;
}

/* Column bubble sizing: the hint must wrap inside the toggle's width, never
   widen the bubble; value pickers need room for their options. */
.xr-colf-hint {
  width: 0;
  min-width: 100%;
}
.xr-colf-section:has(.xr-select, .xr-chip-field, input[type="text"], input[type="search"]) {
  min-width: 220px;
}
.xr-colf .xr-seg .xr-btn-sm {
  padding: 2px 10px;
}

.xr-empty-filtered {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
}

:root {
  --heat-empty-bg: #edf0f4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --heat-empty-bg: var(--bg-raised);
  }
}
:root[data-theme="dark"] {
  --heat-empty-bg: var(--bg-raised);
}

/* The light sidebar is a white panel: separate it from the page with a line. */
.xr-sidebar {
  border-right: 1px solid var(--sidebar-line);
  box-sizing: border-box;
}

/* Autocomplete filter (framework::autocomplete) */
.xr-ac {
  position: relative;
}

.xr-ac .xr-select-trigger {
  padding-right: 46px;
}

.xr-ac-empty .xr-select-value {
  color: var(--text-secondary);
}

.xr-ac-clear {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.xr-ac-clear:hover {
  background: var(--bg-surface-sunken);
  color: var(--text-primary);
}

.xr-cfield .xr-ac .xr-select-trigger {
  max-width: 260px;
}
/* Frozen (sticky) headers clip overflow, so their resize handle sits INSIDE the right edge. */
thead th.xr-sticky-col .xr-col-resize {
  right: 0;
}

/* -- Date picker (framework/date_picker.rs) ------------------------------
   Themed calendar for every date field; tokens only, so light/dark follow. */
.xr-datepicker {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 150px;
}
.xr-datepicker .xr-datepicker-input {
  width: 100%;
  padding-right: 30px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.xr-datepicker-toggle {
  position: absolute;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.xr-datepicker-toggle:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--accent);
}
.xr-pop.xr-datepicker-pop {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 264px;
  padding: var(--sp-3);
}
.xr-datepicker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1);
}
.xr-datepicker-nav,
.xr-datepicker-title,
.xr-datepicker-day,
.xr-datepicker-month,
.xr-datepicker-link {
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.xr-datepicker-nav {
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
}
.xr-datepicker-title {
  flex: 1;
  height: 28px;
  font-weight: 600;
}
.xr-datepicker-nav:hover,
.xr-datepicker-title:hover,
.xr-datepicker-month:hover,
.xr-datepicker-day:hover:not(:disabled):not(.is-selected) {
  background: var(--bg-hover);
}
.xr-datepicker-weekdays,
.xr-datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.xr-datepicker-weekdays span {
  text-align: center;
  font-size: var(--fs-label);
  color: var(--text-secondary);
}
.xr-datepicker-grid:focus-visible {
  outline: none;
}
.xr-datepicker-day {
  height: 32px;
  font-variant-numeric: tabular-nums;
}
.xr-datepicker-day.is-outside {
  color: var(--text-secondary);
  opacity: 0.6;
}
.xr-datepicker-day.is-today {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.xr-datepicker-grid:focus-visible .xr-datepicker-day.is-cursor {
  box-shadow: 0 0 0 2px var(--ring);
}
.xr-datepicker-day.is-selected {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
}
.xr-datepicker-day:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.xr-datepicker-months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-1);
}
.xr-datepicker-month {
  height: 40px;
}
.xr-datepicker-month.is-selected {
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
  font-weight: 600;
}
.xr-datepicker-time {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-secondary);
}
.xr-datepicker-time input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  color-scheme: light dark;
}
.xr-datepicker-foot {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-default);
  padding-top: var(--sp-2);
}
.xr-datepicker-link {
  padding: 4px 8px;
  color: var(--accent);
  font-weight: 600;
}
.xr-datepicker-link:hover:not(:disabled) {
  background: var(--accent-soft-bg);
}
.xr-datepicker-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===================== login page (auth.rs) ===================== */
/* 1:1 port of the inline styles the page carried before. The input rules are
   qualified with `.xr-auth-card` so they outrank the global
   `input[type="text"]` control style on specificity (0-2-0 vs 0-1-1), not by
   source order. */

.xr-auth-card {
  max-width: 320px;
  margin: 80px auto;
  padding: 24px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.xr-auth-title {
  margin-top: 0;
  font-size: 20px;
}

.xr-auth-field {
  margin-bottom: 12px;
}

.xr-auth-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.xr-auth-card .xr-auth-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-primary);
  box-sizing: border-box;
}

.xr-auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

/* Only the full width lives here; the rest (accent fill, hover, disabled
   dimming, focus ring, radius/height) comes from the global button +
   `.xr-btn-primary` rules -- the ~2px deltas (radius 4->8px, height ~34->32px)
   buy parity with every other primary button in the app. */
.xr-auth-submit {
  width: 100%;
}

/* Session gate: nothing but this is drawn until the session is confirmed. */
.xr-session-check { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3, 12px); color: var(--text-secondary, inherit); }
.xr-session-check p { margin: 0; }
.xr-sign-out { margin-top: var(--sp-1, 4px); }

/* ===================== ISP Catalog (/isps/catalog) ===================== */
/* A normal scrolling report page (`.xr-report`, NOT `.xr-fit`): cards of controls plus the ISP grid. */
.xr-isp-version { margin-left: var(--sp-3); font-size: var(--fs-label); color: var(--text-secondary); font-weight: 600; }
.xr-isp-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: var(--sp-4);
}
.xr-isp-card > .xr-isp-h { flex: 1 0 100%; margin: 0 0 var(--sp-1); font-size: var(--fs-body); font-weight: 700; }
.xr-isp-card > input[type="text"] { flex: 1 1 220px; min-width: 0; }
.xr-isp-card > select { flex: 0 1 180px; min-width: 0; }
.xr-isp-card > .xr-isp-preview, .xr-isp-card > .xr-isp-conflicts, .xr-isp-card > p, .xr-isp-card > ul,
.xr-isp-card > .xr-isp-text { flex: 1 0 100%; min-width: 0; margin: 0; }
.xr-isp-preview, .xr-isp-card > p { color: var(--text-secondary); overflow-wrap: anywhere; white-space: pre-wrap; }
.xr-isp-conflicts, .xr-isp-card > ul { padding-left: var(--sp-4); overflow-wrap: anywhere; }
.xr-isp-text {
  box-sizing: border-box; width: 100%; resize: vertical; min-height: 120px; font-family: var(--font-mono);
  font-size: var(--fs-label); color: var(--text-primary); background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: var(--sp-2);
}
.xr-isp-grid {
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-md);
  overflow-x: auto;
}
.xr-isp-row {
  display: grid; min-width: 880px; align-items: start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  grid-template-columns: minmax(120px, 1fr) minmax(220px, 2fr) 110px 150px 90px minmax(240px, 3fr);
  border-top: 1px solid var(--border-subtle);
}
.xr-isp-row:first-child { border-top: 0; }
.xr-isp-row > div { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); overflow-wrap: anywhere; }
.xr-isp-row > div > div { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.xr-isp-row input[type="text"] { width: 100%; max-width: 100%; box-sizing: border-box; }
.xr-isp-row > div:nth-child(3) input[type="text"], .xr-isp-row > div:nth-child(4) input[type="text"] { width: 72px; }
.xr-isp-row ul { margin: 0; padding: 0; list-style: none; width: 100%; }
.xr-isp-row li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 2px 0; font-family: var(--font-mono); font-size: var(--fs-label); }
.xr-isp-head {
  position: sticky; top: 0; background: var(--bg-surface-sunken); font-size: var(--fs-label); font-weight: 700;
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; border-top: 0;
}
@media (max-width: 720px) { .xr-isp-card > input[type="text"], .xr-isp-card > select { flex-basis: 100%; } }

/* ISPs hub (/isps): tab strip + the active tab's screen in a scrolling body. */
.xr-isp-hub-body { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.xr-isp-hub-body > * { flex-shrink: 0; }
.xr-isp-hub-body > .xr-fit { flex: 1 1 auto; flex-shrink: 1; }
