/* Ring Insights design layer on top of Polaris 2.
   Polaris draws the controls and tables (selects, buttons, badges, s-table, modal, banners).
   Everything else here is ours: shell, sidebar, page header, cards, metric tiles and charts.
   Polaris's own CSS variables carry a per-build hash, so we never read them. */

/* Geist, self-hosted from the geist@1.5.1 npm package (SIL Open Font License, see /fonts/OFL.txt). */
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ri-canvas: #f3f3f5;
  --ri-surface: #ffffff;
  --ri-inset: #f7f7f9;
  --ri-line: #e7e7eb;
  --ri-line-soft: #efeff2;
  --ri-ink: #18181b;
  --ri-ink-2: #52525b;
  --ri-ink-3: #6e6e78;        /* 4.5:1 or better on surface, inset and canvas */
  --ri-accent: #3654e6;      /* sapphire: our tracking */
  --ri-accent-soft: #eef1fe;
  --ri-gold: #b07f22;        /* Meta spend */
  --ri-bar-opacity: 1;       /* daily spend bars: full gold is 3.5:1 on the card (0.6 was 2:1) */
  --ri-meta: #c4c4cc;        /* Meta's own reported figure */
  --ri-meta-line: #71717a;   /* Meta's own figure as a line (3:1 or better on surface and inset) */
  --ri-meta-click: #3f3f46;  /* Meta reports: click-through purchases (3:1 against the view shade and the page) */
  --ri-meta-view: #9393a0;   /* Meta reports: view-through purchases */
  --ri-good: #0d8a5e;        /* emerald */
  --ri-good-soft: #e6f5ee;
  --ri-bad: #cc3347;         /* ruby */
  --ri-bad-soft: #fcebed;
  --ri-shadow: 0 1px 2px rgb(24 24 27 / 0.04), 0 1px 1px rgb(24 24 27 / 0.02);
  --ri-radius: 14px;
  --ri-radius-inner: 10px;
  --ri-focus: #005bd3;          /* focus ring on controls we draw ourselves (the model pills) */
  --ri-hover: rgb(24 24 27 / 0.045);
  --ri-on-accent: #ffffff;      /* text on an accent fill (the selected pill) */
}
:root.p-partial-theme-admin-next-dark {
  color-scheme: dark;
  --ri-canvas: #0d0d10;
  --ri-surface: #151519;
  --ri-inset: #1b1b20;
  --ri-line: #27272d;
  --ri-line-soft: #202026;
  --ri-ink: #ededf0;
  --ri-ink-2: #a3a3ad;
  --ri-ink-3: #8a8a94;        /* 4.5:1 or better on surface and inset */
  --ri-accent: #7089ff;
  --ri-accent-soft: rgb(112 137 255 / 0.14);
  --ri-gold: #d8a84c;
  --ri-bar-opacity: 0.6;     /* 3.7:1 on the dark card */
  --ri-meta: #4a4a53;
  --ri-meta-line: #a1a1aa;
  --ri-meta-click: #d4d4dc;
  --ri-meta-view: #6e6e7a;
  --ri-good: #3ccb94;
  --ri-good-soft: rgb(60 203 148 / 0.13);
  --ri-bad: #f26b78;
  --ri-bad-soft: rgb(242 107 120 / 0.13);
  --ri-shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset;
  --ri-focus: #7089ff;
  --ri-hover: rgb(255 255 255 / 0.06);
  --ri-on-accent: #0b0d1a;      /* dark text: white on the light dark-mode accent is under 4.5:1 */
}

/* Polaris hosts set their own display, which beats the browser's [hidden] rule. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ri-canvas);
  color: var(--ri-ink);
  font: 13.5px/1.5 "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- shell: sidebar on the canvas, the page in a raised panel beside it ---------- */
.shell { display: flex; min-height: 100vh; align-items: flex-start; }
#sidebar { width: 236px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 18px 12px 14px; }
#main { flex: 1; min-width: 0; margin: 8px 8px 8px 0; min-height: calc(100vh - 16px); padding: 26px 32px 48px; background: var(--ri-surface); border: 1px solid var(--ri-line); border-radius: 16px; box-shadow: var(--ri-shadow); }

.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.side-brand .mark, .mobilebar .mark, .embed-state-brand .mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: radial-gradient(120% 120% at 30% 20%, #5c76ff 0%, #2f47d6 55%, #1c2a8f 100%); box-shadow: 0 1px 2px rgb(28 42 143 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.25); }
.side-brand .mark svg, .mobilebar .mark svg, .embed-state-brand .mark svg { width: 17px; height: 17px; }

.tabs[hidden] { display: none; }
.tabs { display: flex; flex-direction: column; gap: 1px; }
.tabs a { display: flex; align-items: center; gap: 10px; padding: 7px 9px; color: var(--ri-ink-2); text-decoration: none; border-radius: 8px; font-weight: 500; transition: background-color 120ms ease, color 120ms ease; }
.tabs a .ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }
.tabs a:hover { color: var(--ri-ink); background: rgb(24 24 27 / 0.045); }
:root.p-partial-theme-admin-next-dark .tabs a:hover { background: rgb(255 255 255 / 0.05); }
.tabs a:focus-visible { outline: 2px solid var(--ri-accent); outline-offset: -2px; }
.tabs a[aria-current="page"] { color: var(--ri-ink); background: var(--ri-surface); font-weight: 600; box-shadow: 0 0 0 1px var(--ri-line), var(--ri-shadow); }
.tabs a[aria-current="page"] .ico { opacity: 1; color: var(--ri-accent); }

.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 6px 0; border-top: 1px solid var(--ri-line); }
.side-foot .avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ri-ink-2); background: var(--ri-surface); box-shadow: 0 0 0 1px var(--ri-line); }
.side-foot s-text { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.mobilebar { display: none; }

/* ---------- page header: title, period, filters ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
#page-title { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 640; letter-spacing: -0.022em; }
.page-sub { margin: 4px 0 0; color: var(--ri-ink-3); font-size: 13px; }
.page-sub:empty { display: none; }
/* flex-end: the date fields keep visible From and To labels, so controls line up along their bottom edge. */
.toolbar-row { display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
/* Polaris form hosts are display: contents; give them a box so the toolbar can size them. */
.toolbar-row s-select, .toolbar-row s-date-field, .toolbar-row s-checkbox { display: block; }
.toolbar-row s-select { width: 168px; }
.toolbar-row s-select.range-select { width: 204px; }
.toolbar-row s-date-field { width: 224px; }

/* ---------- attribution model pills (app.js modelBar): a radio row under the page header ---------- */
.pills-bar { display: grid; gap: 8px; margin: -4px 0 20px; min-width: 0; }
.pills-caption { font-size: 12px; font-weight: 500; color: var(--ri-ink-3); }
/* One row that scrolls sideways when it doesn't fit. The 4px padding (taken back by the margin) keeps focus rings
   from being clipped by the scroll box. */
.pills { position: relative; display: flex; gap: 8px; margin: -4px; padding: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.pill { flex: none; display: grid; align-content: center; gap: 1px; min-height: 36px; margin: 0; padding: 7px 14px; border: 1px solid var(--ri-line); border-radius: 999px; background: var(--ri-surface); color: var(--ri-ink); font: inherit; text-align: left; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease; }
.pills-bar.has-values .pill { min-width: 116px; padding: 8px 14px 9px; border-radius: 14px; }
.pill:hover { background: var(--ri-hover); }
.pill:focus-visible { outline: 2px solid var(--ri-focus); outline-offset: 2px; }
.pill-head { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ri-ink-2); }
.pill-tag { padding: 0 6px; border-radius: 99px; font-size: 10.5px; line-height: 16px; font-weight: 600; color: var(--ri-accent); background: var(--ri-accent-soft); }
/* The value line is always there on Overview and Ads, so numbers arriving never move anything. */
.pill-value { display: block; min-height: 22px; font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ri-ink); }
.pill-value.is-loading::before { content: ""; display: block; width: 44px; height: 10px; margin-top: 6px; border-radius: 4px; background: var(--ri-line); }
.pill[aria-checked="true"] { background: var(--ri-accent); border-color: var(--ri-accent); }
.pill[aria-checked="true"] .pill-label { color: var(--ri-on-accent); font-weight: 600; }
.pill[aria-checked="true"] .pill-value { color: var(--ri-on-accent); }
.pill[aria-checked="true"] .pill-tag { color: var(--ri-on-accent); background: color-mix(in srgb, var(--ri-on-accent) 18%, transparent); }
.pill[aria-checked="true"] .pill-value.is-loading::before { background: color-mix(in srgb, var(--ri-on-accent) 35%, transparent); }
.pills-desc { margin: 0; max-width: 110ch; font-size: 12.5px; color: var(--ri-ink-2); text-wrap: pretty; }
:root[data-embedded="true"] .pills-bar { margin: 12px 0 2px; }
@media (prefers-reduced-motion: reduce) {
  .pill { transition: none; }
}
/* Forced colors drop the accent fill: outline every pill and mark the selected one with the system highlight. */
@media (forced-colors: active) {
  .pill { border: 1px solid ButtonText; }
  .pill[aria-checked="true"] { forced-color-adjust: none; background: Highlight; border: 2px solid Highlight; }
  .pill[aria-checked="true"] .pill-label, .pill[aria-checked="true"] .pill-value, .pill[aria-checked="true"] .pill-tag { color: HighlightText; }
  .pill[aria-checked="true"] .pill-tag { background: transparent; box-shadow: inset 0 0 0 1px HighlightText; }
  .pill:focus-visible { outline: 2px solid CanvasText; }
}

@media (max-width: 899.98px) {
  .shell { flex-direction: column; align-items: stretch; }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; padding: 8px 12px 8px 16px; background: var(--ri-canvas); border-bottom: 1px solid var(--ri-line); }
  .mobilebar strong { display: flex; align-items: center; gap: 8px; font-weight: 620; }
  #sidebar { display: none; position: fixed; top: 53px; left: 0; bottom: 0; height: auto; z-index: 19; width: min(300px, 86vw); background: var(--ri-canvas); border-right: 1px solid var(--ri-line); box-shadow: 0 12px 32px rgb(0 0 0 / 0.18); }
  .menu-open #sidebar { display: flex; }
  #main { margin: 0; border-radius: 0; border: 0; padding: 18px 16px 40px; min-height: auto; box-shadow: none; }
  /* No wrap: a wrapping column sizes the toolbar at its narrowest (selects stacked), then stretches it, leaving a gap. */
  .page-head { align-items: stretch; flex-direction: column; flex-wrap: nowrap; }
  .toolbar-row { justify-content: stretch; }
  .toolbar-row s-select, .toolbar-row s-select.range-select, .toolbar-row s-date-field { flex: 1 1 140px; width: auto; }
  /* Phones: one row of 44px pills scrolling edge to edge (no wrap); app.js scrolls the selected one into view. */
  .pills { margin: -4px -16px; padding: 4px 16px; scroll-padding-inline: 16px; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { min-height: 44px; }
}

/* Embedded in the Shopify admin: no sidebar, no raised panel. Section links and filters sit across the top. */
:root[data-embedded="true"] .shell { display: block; }
:root[data-embedded="true"] .mobilebar, :root[data-embedded="true"] .side-brand, :root[data-embedded="true"] #viewer { display: none; }
:root[data-embedded="true"] #sidebar { display: flex; position: static; width: auto; height: auto; overflow: visible; background: transparent; border: 0; border-bottom: 1px solid var(--ri-line); padding: 8px 16px; box-shadow: none; }
:root[data-embedded="true"] .tabs { flex-direction: row; flex-wrap: wrap; }
:root[data-embedded="true"] .side-foot { display: none; }
:root[data-embedded="true"] #main { margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 16px; background: transparent; }

/* The embedded host (app.js startEmbedded): nothing but the view until /api/meta answers (a spinner), and after a stop
   (no access, not set up, Shopify unreachable) only its message. Links, filters and the header appear once it's ready. */
:root[data-embed-host="true"]:not([data-boot="ready"]) #sidebar,
:root[data-embed-host="true"]:not([data-boot="ready"]) .page-head { display: none; }
/* The opening store's name above the page title. */
.page-store { margin: 0 0 3px; font-size: 12.5px; line-height: 1.4; font-weight: 560; color: var(--ri-ink-2); }
.embed-state { display: grid; place-items: center; min-height: min(70vh, 480px); padding: 24px 0; }
.embed-state-card { display: grid; justify-items: start; gap: 14px; width: min(100%, 440px); padding: 24px; background: var(--ri-surface); border: 1px solid var(--ri-line); border-radius: var(--ri-radius); box-shadow: var(--ri-shadow); }
.embed-state-brand { display: flex; align-items: center; gap: 10px; }
.embed-state-brand h1 { margin: 0; font-size: 14.5px; line-height: 1.3; font-weight: 620; letter-spacing: -0.01em; }
.embed-state-msg { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ri-ink); text-wrap: pretty; }
@media (forced-colors: active) { .embed-state-card { border-color: CanvasText; } }

/* ---------- cards ---------- */
.ri-card { background: var(--ri-surface); border: 1px solid var(--ri-line); border-radius: var(--ri-radius); box-shadow: var(--ri-shadow); min-width: 0; }
.ri-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.ri-card-title { margin: 0; font-size: 14px; font-weight: 620; letter-spacing: -0.01em; }
.ri-card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ri-ink-3); }
/* --ri-chart-bg: what a chart sits on, so dot fills and label halos match it (surface unless inset). */
.ri-inset { --ri-chart-bg: var(--ri-inset); background: var(--ri-inset); border: 1px solid var(--ri-line-soft); border-radius: var(--ri-radius-inner); }

/* Lead card: the ROAS comparison on the left, the daily chart in an inset panel on the right,
   supporting Meta numbers in a ruled strip underneath. */
.ri-lead-body { display: grid; grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.4fr); gap: 18px; padding: 16px 18px 18px; }
.ri-compare { display: flex; flex-direction: column; gap: 18px; padding: 6px 4px 4px; }
.ri-compare-row { display: grid; gap: 6px; }
.ri-compare-label { font-size: 12.5px; color: var(--ri-ink-2); display: flex; align-items: center; gap: 7px; }
.ri-compare-label .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.ri-compare-figure { display: flex; align-items: baseline; gap: 10px; }
.ri-compare-value { font-size: 40px; line-height: 1; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.ri-compare-value .unit { font-size: 0.5em; letter-spacing: 0; color: var(--ri-ink-3); margin-left: 1px; font-weight: 500; }
.ri-meter { height: 8px; border-radius: 99px; background: var(--ri-line-soft); overflow: hidden; }
.ri-meter span { display: block; height: 100%; border-radius: inherit; min-width: 4px; transform-origin: left center; }
.ri-gap-note { margin: 0; font-size: 13px; color: var(--ri-ink-2); max-width: 44ch; text-wrap: pretty; }
.ri-gap-note strong { color: var(--ri-ink); font-weight: 600; }
.ri-chart-panel { padding: 12px 14px 8px; min-width: 0; }
.ri-chart-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

.ri-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--ri-line); overflow: hidden; }
.ri-strip > .ri-kpi { padding: 14px 18px 16px; }

/* Store panel: one card ruled into cells, not six separate cards. */
.ri-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; border-top: 1px solid var(--ri-line); overflow: hidden; }
.ri-cells > .ri-kpi, .ri-cells > .ri-cell { padding: 16px 18px 14px; }
/* A ruled cell that isn't a metric (Status connections): a label over a badge or a short list. */
.ri-cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* Hairlines on each cell's left and top edge; the container clips the ones on its outer edge,
   so the rules stay right at any column count. */
.ri-strip > .ri-kpi, .ri-cells > .ri-kpi, .ri-cells > .ri-cell { box-shadow: -1px 0 0 var(--ri-line), 0 -1px 0 var(--ri-line); }

/* ---------- metric tile ---------- */
.ri-kpi { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ri-kpi-label { font-size: 12.5px; color: var(--ri-ink-2); }
.ri-kpi-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ri-kpi-value { font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.ri-kpi-sub { font-size: 12px; color: var(--ri-ink-3); text-wrap: pretty; }
.ri-spark { display: block; width: 100%; height: 34px; margin-top: 6px; overflow: visible; }

.ri-delta { display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 6px 0 4px; border-radius: 6px; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ri-ink-2); background: var(--ri-line-soft); }
.ri-delta svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ri-delta.good { color: var(--ri-good); background: var(--ri-good-soft); }
.ri-delta.bad { color: var(--ri-bad); background: var(--ri-bad-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ri-notes { margin-top: 18px; padding: 14px 18px; border-radius: var(--ri-radius-inner); background: var(--ri-inset); color: var(--ri-ink-2); font-size: 12.5px; }
.ri-notes p { margin: 0; max-width: 92ch; }
.ri-notes p + p { margin-top: 6px; }
.ri-notes strong { color: var(--ri-ink); font-weight: 600; }

.ri-stack { display: flex; flex-direction: column; gap: 16px; }
/* Journeys: the list's pager under its table; a journey's visits ruled apart inside one card. */
.ri-pager { margin-top: 12px; }
.ri-visit { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--ri-line); min-width: 0; }
.ri-visit:first-child { padding-top: 2px; border-top: 0; }
.ri-visit:last-child { padding-bottom: 0; }
.ri-visit-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.ri-visit-title { margin: 0; font-size: 13.5px; font-weight: 620; }
.ri-visit-time { color: var(--ri-ink-2); font-variant-numeric: tabular-nums; }
.ri-visit-about { margin: 0; font-size: 12.5px; color: var(--ri-ink-3); overflow-wrap: anywhere; }
/* Status: Meta token rows in their connection cell; job results wrap inside the card (Polaris cells never wrap). */
.ri-token-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ri-token-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.ri-wrap { display: block; min-inline-size: 240px; max-inline-size: 560px; white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 1180px) {
  .ri-lead-body { grid-template-columns: 1fr; }
  .ri-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ri-compare-value { font-size: 34px; }
  .ri-strip, .ri-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ri-strip > .ri-kpi, .ri-cells > .ri-kpi, .ri-cells > .ri-cell { padding: 12px 14px; }
  .ri-kpi-value { font-size: 19px; }
}

/* ---------- charts ---------- */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ri-ink-2); flex-wrap: wrap; }
.legend .key { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; margin-right: 6px; border-radius: 3px; }

.chart { width: 100%; height: 260px; display: block; touch-action: pan-y; overflow: visible; }
.chart text { fill: var(--ri-ink-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: inherit; }
.chart .grid { stroke: var(--ri-line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .axis { stroke: var(--ri-line); }
.chart .crosshair { stroke: var(--ri-ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
/* A halo in the chart's background keeps an end label readable where a marker line runs through it. */
.chart .end-label { font-size: 11px; fill: var(--ri-ink-2); font-weight: 500; paint-order: stroke; stroke: var(--ri-chart-bg, var(--ri-surface)); stroke-width: 4px; stroke-linejoin: round; }
.chart .hit:focus-visible { outline: 2px solid var(--ri-accent); }
.chart .pt { fill: var(--ri-chart-bg, var(--ri-surface)); }
.chart .focus-dot { stroke: var(--ri-chart-bg, var(--ri-surface)); }
.chart .marker { stroke-width: 1.25; }
.chart .marker.launch { stroke: var(--ri-accent); }
.chart .marker.access { stroke: var(--ri-ink-3); stroke-dasharray: 3 3; }
.chart .marker-dot.launch { fill: var(--ri-accent); }
.chart .marker-dot.access { fill: var(--ri-surface); stroke: var(--ri-ink-3); stroke-width: 1.25; }
.chart text.marker-label { font-size: 10.5px; font-weight: 600; paint-order: stroke; stroke: var(--ri-chart-bg, var(--ri-surface)); stroke-width: 5px; stroke-linejoin: round; }
.chart text.marker-label.launch { fill: var(--ri-accent); }
.chart text.marker-label.access { fill: var(--ri-ink-2); }
.chart .draw { animation: ri-draw 1100ms cubic-bezier(0.3, 0.7, 0.2, 1) both; }
.chart .fade { animation: ri-fade 900ms 250ms ease-out both; }
@keyframes ri-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes ri-fade { from { opacity: 0; } to { opacity: 1; } }
.ri-meter span.grow { animation: ri-grow 900ms cubic-bezier(0.3, 0.7, 0.2, 1) both; }
@keyframes ri-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .chart .draw, .chart .fade, .ri-meter span.grow { animation: none; }
  .tabs a { transition: none; }
}

.tooltip { position: fixed; z-index: 1000; pointer-events: none; background: color-mix(in srgb, var(--ri-surface) 92%, transparent); backdrop-filter: blur(8px); color: var(--ri-ink); border: 1px solid var(--ri-line); border-radius: 10px; padding: 9px 11px; font-size: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.10), 0 1px 3px rgb(0 0 0 / 0.06); min-width: 170px; }
.tooltip .t-head { color: var(--ri-ink-3); margin-bottom: 6px; font-size: 11.5px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tooltip .t-row strong { font-variant-numeric: tabular-nums; margin-left: auto; font-weight: 600; }
.tooltip .key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.tooltip .t-marker { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--ri-line); color: var(--ri-ink-2); }
.tooltip .t-marker .key { width: 2px; height: 12px; border-radius: 1px; }
.tooltip .t-marker.launch .key { background: var(--ri-accent); }
.tooltip .t-marker.access .key { background: var(--ri-ink-3); }

/* One click selects the whole snippet for copying. */
code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--ri-inset); border: 1px solid var(--ri-line); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; user-select: all; }

/* Ads view: campaign > ad set > ad, each level indented under a disclosure button. */
/* Polaris's table is a fit-content grid whose cells never wrap (white-space: nowrap in its shadow DOM), so each column is
   as wide as its widest content. Our own content wraps instead: the name is capped, headers break between words, the
   schedule only after its arrow. Then the grid narrows its columns to the card and the default columns fit at 1440px. */
.ad-cell { display: flex; align-items: center; gap: 8px; min-inline-size: 240px; max-inline-size: 300px; white-space: normal; }
.ad-cell.ri-tree-1 { padding-left: 22px; }
.ad-cell.ri-tree-2 { padding-left: 44px; }
.ad-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; background: var(--ri-inset); }
.ad-name { min-width: 0; overflow-wrap: break-word; }
.ri-th { display: block; white-space: normal; text-wrap: balance; }
.ri-plan { white-space: normal; line-height: 1.35; }
.ri-plan-sub { color: var(--ri-ink-2); }
.ri-nowrap { white-space: nowrap; }
.ri-disclose, .ri-disclose-spacer { flex: none; width: 24px; height: 24px; }
.ri-disclose { display: grid; place-items: center; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ri-ink-2); cursor: pointer; }
.ri-disclose:hover { background: var(--ri-hover); color: var(--ri-ink); }
.ri-disclose:focus-visible { outline: 2px solid var(--ri-focus); outline-offset: 1px; }
.ri-disclose svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 120ms ease; }
.ri-disclose[aria-expanded="true"] svg { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .ri-disclose svg { transition: none; } }
@media (forced-colors: active) { .ri-disclose:focus-visible { outline-color: CanvasText; } }
.chart .bar { fill-opacity: var(--ri-bar-opacity); }

/* Ads and Overview: two cards per row on desktop (the chart gets the wider one), one on phones. Tables sit outside
   and stay full width. */
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
.two-col > * { min-width: 0; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }

/* ---------- Overview additions: click vs view-through, app visits, device and traffic ---------- */
.ri-card-body { padding: 14px 18px 18px; }
.ri-card-foot { margin: 10px 0 0; font-size: 12px; color: var(--ri-ink-3); max-width: 92ch; text-wrap: pretty; }
.ri-callout { margin: 14px 18px 0; padding: 10px 14px; border-radius: var(--ri-radius-inner); background: var(--ri-inset); border: 1px solid var(--ri-line-soft); color: var(--ri-ink); font-size: 13px; font-weight: 500; text-wrap: pretty; }
.ri-extras-note { margin: 0; padding: 12px 16px; border: 1px dashed var(--ri-line); border-radius: var(--ri-radius-inner); color: var(--ri-ink-2); font-size: 13px; }
.ri-window-value { font-size: 30px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ri-window-unit { font-size: 13px; color: var(--ri-ink-3); }
.ri-meter-split { display: flex; }
.ri-meter-split span { border-radius: 0; min-width: 0; }
.ri-cells.ri-cells-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ri-cells.ri-cells-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.chart .gap-mark { stroke: var(--ri-ink-3); stroke-width: 1.5; stroke-dasharray: 2 2; }
.chart .band-hl { fill: var(--ri-hover); }
.ri-rank-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 28px; padding: 14px 18px 4px; }
.ri-rank { min-width: 0; }
.ri-rank-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--ri-ink-2); }
.ri-rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ri-rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 12.5px; }
.ri-rank-label { color: var(--ri-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-rank-value { color: var(--ri-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ri-rank-track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--ri-line-soft); overflow: hidden; }
.ri-rank-bar { display: block; height: 100%; border-radius: inherit; background: var(--ri-accent); min-width: 2px; }
.ri-rank-note { margin: 10px 0 0; font-size: 12px; color: var(--ri-ink-3); text-wrap: pretty; }
/* Channels: one ranking in two columns on wide screens, read down the first column, then the second. */
.ri-rank-list.ri-rank-cols { display: block; columns: 2; column-gap: 40px; }
.ri-rank-cols > .ri-rank-row { break-inside: avoid; margin-bottom: 12px; }
@media (max-width: 1180px) {
  .ri-cells.ri-cells-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ri-cells.ri-cells-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 899.98px) {
  .ri-rank-grid { grid-template-columns: 1fr; }
  .ri-rank-list.ri-rank-cols { columns: 1; }
}
@media (max-width: 640px) {
  .ri-cells.ri-cells-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ri-cells.ri-cells-5 > :last-child { grid-column: 1 / -1; } /* the odd fifth cell takes the whole row */
  .ri-window-value { font-size: 26px; }
  .ri-card-body { padding: 12px 14px 14px; }
  .ri-rank-grid { padding: 12px 14px 4px; }
  .ri-callout { margin: 12px 14px 0; }
}

/* ---------- History: before vs since cells, partial periods (app.js history) ---------- */
/* A cell reads before → since: the before figure small and quiet, the since figure as the metric value. */
.ri-bs-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.ri-bs-before { font-size: 14px; font-weight: 500; color: var(--ri-ink-2); font-variant-numeric: tabular-nums; }
.ri-bs-arrow { color: var(--ri-ink-3); font-size: 13px; }
.ri-bs-row .ri-kpi-value.ri-bs-none { font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--ri-ink-2); }
.ri-bs > .ri-delta { align-self: flex-start; margin-top: 2px; }
.ri-bs-note p { margin: 0; font-size: 12px; color: var(--ri-ink-3); max-width: 40ch; text-wrap: pretty; }
.ri-bs-foot { margin: 0; max-width: none; padding: 12px 18px 16px; border-top: 1px solid var(--ri-line); }
.ri-bs-foot p { margin: 0; max-width: 92ch; }
.ri-bs-foot p + p { margin-top: 4px; }
/* Partial periods: a light band behind the period, its bar hatched (the pattern is drawn in the bar's own color). */
.chart .partial-band { fill: var(--ri-line-soft); }
.legend .key-partial { background: repeating-linear-gradient(45deg, var(--ri-ink-3) 0 1.5px, transparent 1.5px 4px); box-shadow: inset 0 0 0 1px var(--ri-ink-3); }
@media (max-width: 640px) {
  .ri-bs-foot { padding: 10px 14px 14px; }
  .ri-bs-before { font-size: 13px; }
}
@media (forced-colors: active) {
  .legend .key-partial { forced-color-adjust: none; background: repeating-linear-gradient(45deg, CanvasText 0 1.5px, Canvas 1.5px 4px); }
}
