/*
  Tessel: product analytics dashboard
  1. Tokens (light and dark), base, browser surfaces
  2. Shell: rail, top bar, popovers, command palette
  3. Components: tooltip, select (listbox), notice, confirmation dialog, dialog motion, scrollbars
  4. Page: headline, anchor chart, key figures slab, cohort table, funnel, pages table, dated log
*/

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  /* colour */
  --paper: #fbfaf8;
  --paper-2: #f3f1ec;
  --paper-3: #ebe8e1;
  --surface: #ffffff;
  --rule: #e4e1d9;
  --rule-2: #cfcbc1;
  --ink: #16181d;
  --ink-2: #454952;
  --ink-3: #686c75;
  --cobalt: #2747d6;
  --cobalt-deep: #1d38b4;
  --cobalt-tint: #e6ebfb;
  --on-cobalt: #ffffff;
  --sand: #ab8448;
  --sand-tint: #f0e7d6;
  --good: #1a7a48;
  --bad: #bf3327;
  --rail: #16181d;
  --rail-ink: #a9acb4;
  --rail-ink-on: #ffffff;
  --rail-hover: #262a33;
  --rail-accent: #6f8bff;
  --heat: #2747d6;
  --heat-on: #ffffff;
  --shadow: 0 1px 2px rgba(22, 24, 29, .06), 0 14px 34px -10px rgba(22, 24, 29, .22);
  --backdrop: rgba(22, 24, 29, .44);
  --backdrop-rule: rgba(251, 250, 248, .07);
  --danger: #b42b20;
  --danger-deep: #96221a;
  --on-danger: #ffffff;
  --tip: #16181d;
  --on-tip: #fbfaf8;
  --notice-accent: #8ea3ff;
  /* the key figures slab: one flat ink block beside the paper chart */
  --slab: #16181d;
  --slab-2: #22252d;
  --slab-3: #2c303a;
  --slab-ink: #f4f3ef;
  --slab-ink-2: #b3b6bd;
  --slab-rule: #30343e;
  --slab-cur: #8ea3ff;
  --slab-prev: #cfae7a;
  --slab-good: #52c488;
  --slab-bad: #ff8172;

  /* space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* shape */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 12px;
  --rail-w: 60px;
  --bar-h: 56px;

  /* type */
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111317;
  --paper-2: #181b21;
  --paper-3: #20242c;
  --surface: #1b1e25;
  --rule: #282c35;
  --rule-2: #3a3f4a;
  --ink: #ecebe7;
  --ink-2: #b9bbc1;
  --ink-3: #8f929b;
  --cobalt: #7b94ff;
  --cobalt-deep: #9db0ff;
  --cobalt-tint: #1f2a52;
  --on-cobalt: #0d1020;
  --sand: #cfae7a;
  --sand-tint: #3a3122;
  --good: #52c488;
  --bad: #ff8172;
  --rail: #0a0b0e;
  --rail-ink: #8f929b;
  --rail-hover: #1b1e25;
  --rail-accent: #7b94ff;
  --heat: #7b94ff;
  --heat-on: #0d1020;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 38px -10px rgba(0, 0, 0, .7);
  --backdrop: rgba(4, 5, 8, .66);
  --backdrop-rule: rgba(236, 235, 231, .05);
  --danger: #ff8172;
  --danger-deep: #ff9d91;
  --on-danger: #2a0906;
  --tip: #ecebe7;
  --on-tip: #111317;
  --notice-accent: #2747d6;
  --slab: #1a2452;
  --slab-2: #232f68;
  --slab-3: #2d3a7c;
  --slab-ink: #f1f1ee;
  --slab-ink-2: #bcc4e8;
  --slab-rule: #303c7a;
  --slab-cur: #aab9ff;
  --slab-prev: #dcbd8c;
  --slab-good: #6fd69c;
  --slab-bad: #ffa094;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--rule-2) transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  accent-color: var(--cobalt);
  caret-color: var(--cobalt);
}

::selection { background: var(--cobalt); color: var(--on-cobalt); }

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

h1, h2, p, ul, ol, dl, dd, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input { font: inherit; color: inherit; }
input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink); caret-color: var(--cobalt);
  box-shadow: 0 0 0 100px var(--paper) inset;
}
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s-1) 0; }
table { border-collapse: collapse; }
kbd {
  font: 500 11px/1 var(--mono);
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  padding: 4px 6px;
  white-space: nowrap;
}

.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.sprite { position: absolute; width: 0; height: 0; }
.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico--sm { width: 14px; height: 14px; }

.skip {
  position: fixed; left: var(--s-4); top: -60px; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-2);
  transition: top .2s var(--ease);
}
.skip:focus { top: var(--s-3); }

/* ---------- 2. Shell ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--rail-w);
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s-3) 0;
}
.rail__brand {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-bottom: var(--s-3);
  color: var(--rail-ink-on, #fff); border-radius: var(--r-2);
}
.rail__list { display: flex; flex-direction: column; gap: var(--s-1); }
.rail__link {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-2);
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.rail__link .ico { width: 20px; height: 20px; }
.rail__link:hover { background: var(--rail-hover); color: #fff; }
.rail__link[aria-current="true"] { background: var(--cobalt); color: var(--on-cobalt); }
.rail :focus-visible { outline-color: #fff; }
/* the label doubles as a tooltip on the desktop rail */
.rail__link span {
  position: absolute; left: calc(100% + 10px); top: 50%;
  translate: -4px -50%;
  background: var(--tip); color: var(--on-tip);
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 7px 9px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s, translate .2s var(--ease);
}
.rail__link:hover span, .rail__link:focus-visible span { opacity: 1; translate: 0 -50%; }

.app { margin-left: var(--rail-w); min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar-h);
  display: grid; grid-template-columns: 1fr minmax(240px, 420px) 1fr;
  align-items: center; gap: var(--s-5);
  padding: 0 var(--s-6);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topbar__id { display: flex; align-items: center; gap: var(--s-4); min-width: 0; }
.topbar__mark { display: none; color: var(--ink); }
.topbar__ws { display: flex; align-items: center; gap: var(--s-2); font-size: 14px; white-space: nowrap; }
.topbar__ws strong { font-weight: 600; }
.topbar__env {
  font-size: 12px; color: var(--ink-2);
  border: 1px solid var(--rule-2); border-radius: 999px; padding: 1px 8px;
}
.topbar__fresh {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }
/* while a day is being read, the freshness line names it */
.topbar__fresh.is-live {
  font: 500 12px/1 var(--mono); color: var(--on-tip); background: var(--tip);
  padding: 6px 8px; border-radius: var(--r-1);
}
.topbar__fresh.is-live .dot { display: none; }

.search {
  display: flex; align-items: center; gap: var(--s-2);
  height: 36px; width: 100%;
  padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--paper-2); color: var(--ink-3);
  border: 1px solid var(--rule); border-radius: var(--r-2);
  text-align: left;
  transition: border-color .15s, background-color .15s;
}
.search:hover { border-color: var(--rule-2); color: var(--ink-2); }
.search__label { flex: 1; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search__kbd { background: var(--paper); }

.topbar__tools { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-1); }
.iconbtn {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-2);
  color: var(--ink-2);
  transition: background-color .15s, color .15s;
}
.iconbtn:hover, .iconbtn[aria-expanded="true"] { background: var(--paper-2); color: var(--ink); }
.iconbtn__badge {
  position: absolute; top: 4px; right: 3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  font: 600 10px/1 var(--mono);
  background: var(--cobalt); color: var(--on-cobalt);
  border-radius: 999px; box-shadow: 0 0 0 2px var(--paper);
}
.iconbtn__badge[hidden] { display: none; }
.ico--moon { display: none; }
:root[data-theme="dark"] .ico--moon { display: block; }
:root[data-theme="dark"] .ico--sun { display: none; }

.avatar {
  width: 32px; height: 32px; margin-left: var(--s-2);
  display: grid; place-items: center;
  font: 600 11.5px/1 var(--sans); letter-spacing: .02em;
  background: var(--ink); color: var(--paper);
  border-radius: 50%;
}
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--paper-3); }

/* popovers and menus */
.pop { position: relative; }
.panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow);
  transform-origin: top right;
  animation: pop .18s var(--ease);
}
.panel[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.panel--menu { min-width: 232px; padding: 6px; }
.menuitem {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 36px; padding: 0 10px;
  border-radius: 6px;
  font-size: 13.5px; text-align: left; text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.menuitem .ico { color: var(--ink-3); }
.menuitem:hover, .menuitem:focus-visible { background: var(--paper-2); outline: none; }
.menuitem:focus-visible { box-shadow: inset 0 0 0 2px var(--cobalt); }
.menuitem__meta, .menuitem__kbd { margin-left: auto; padding-left: var(--s-4); }
.menuitem__meta { font: 400 12px/1 var(--mono); color: var(--ink-3); }
.menuitem .ico--tick { color: var(--cobalt); visibility: hidden; }
.menuitem[aria-checked="true"] .ico--tick { visibility: visible; }
.menuitem[aria-checked="true"] { font-weight: 500; }
.panel__who { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.panel__who strong { font-weight: 600; }
.panel__who span { font-size: 12.5px; color: var(--ink-3); }

.panel--notif { width: 372px; padding: 0; overflow: hidden; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--rule);
}
.panel__head h2 { font-size: 14px; font-weight: 600; }
.textbtn { font-size: 12.5px; color: var(--cobalt); font-weight: 500; padding: 6px 4px; border-radius: var(--r-1); }
.textbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.textbtn:disabled { color: var(--ink-3); cursor: default; text-decoration: none; }
.notif li + li { border-top: 1px solid var(--rule); }
.notif__item {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 10px;
  align-items: start; width: 100%;
  padding: 12px 14px; text-align: left;
}
.notif__item:hover { background: var(--paper-2); }
.notif__item:focus-visible { outline-offset: -2px; }
.notif__dot { width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: transparent; }
.is-unread .notif__dot { background: var(--cobalt); }
.notif__body { display: grid; gap: 2px; }
.notif__body strong { font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.is-unread .notif__body strong { font-weight: 600; }
.notif__body span { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.notif__item time { font: 400 11.5px/1.8 var(--mono); color: var(--ink-3); }

/* command palette */
.palette {
  width: min(620px, calc(100vw - 24px));
  max-height: min(520px, calc(100dvh - 24vh));
  margin: 14vh auto auto; padding: 0;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; animation: dlg-in .22s var(--ease); }
.palette[open].is-closing { animation: dlg-out .14s ease-in forwards; }
.palette__field {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4); height: 54px; flex: none;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-3);
}
.palette__field input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; outline: none;
  font-size: 16px; color: var(--ink);
}
.palette__field input::placeholder { color: var(--ink-3); }
.palette__list { overflow-y: auto; padding: 6px; flex: 1; scrollbar-width: thin; }
.palette__group {
  padding: 10px 10px 4px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
}
.palette__opt {
  display: flex; align-items: center; gap: 12px;
  min-height: 40px; padding: 0 10px;
  border-radius: var(--r-2);
  font-size: 14px; cursor: pointer;
}
.palette__opt .ico { color: var(--ink-3); }
.palette__opt mark { background: none; color: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: var(--cobalt); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.palette__opt small { margin-left: auto; font: 400 12px/1 var(--mono); color: var(--ink-3); }
.palette__opt[aria-selected="true"] { background: var(--cobalt); color: var(--on-cobalt); }
.palette__opt[aria-selected="true"] .ico,
.palette__opt[aria-selected="true"] small { color: inherit; }
.palette__opt[aria-selected="true"] mark { text-decoration-color: currentColor; }
.palette__none { padding: 28px 16px 32px; text-align: center; color: var(--ink-2); }
.palette__none strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.palette__foot {
  display: flex; align-items: center; gap: var(--s-4); flex: none;
  padding: 8px 14px; border-top: 1px solid var(--rule);
  font-size: 12px; color: var(--ink-3); background: var(--paper);
}
.palette__foot span { display: inline-flex; align-items: center; gap: 5px; }
.palette__foot kbd { padding: 2px 4px; display: inline-grid; }
.palette__foot span:last-child { margin-left: auto; font-family: var(--mono); }

/* ---------- 3. Components ----------
   The kit: every control a visitor can open is drawn here from the tokens above.
   Nothing on the page falls back to a browser or operating-system surface. */

/* Tooltip: add data-tip="Label" to an icon button. Shows on hover and on keyboard focus.
   The button keeps its own accessible name; the tooltip is a visual label only. */
[data-tip] { position: relative; }
[data-tip]::before {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); left: 50%; z-index: 50;
  translate: -50% -4px;
  background: var(--tip); color: var(--on-tip);
  font: 500 12px/1 var(--sans); letter-spacing: 0;
  padding: 7px 9px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s, translate .2s var(--ease);
}
[data-tip][data-tip-end]::before { left: auto; right: 0; translate: 0 -4px; }
[data-tip]:focus-visible::before { opacity: 1; translate: -50% 0; }
[data-tip][data-tip-end]:focus-visible::before { translate: 0 0; }
@media (hover: hover) {
  [data-tip]:hover::before { opacity: 1; translate: -50% 0; transition-delay: .35s; }
  [data-tip][data-tip-end]:hover::before { translate: 0 0; }
}
[data-tip][aria-expanded="true"]::before { opacity: 0; transition-delay: 0s; }

/* Select: a button that opens a listbox (markup in index.html, behaviour in setupSelect).
   Each option carries a figure and a hairline bar of its share, like a row in a table of record. */
.select { position: relative; }
.select__chev { transition: rotate .2s var(--ease); }
.select__btn[aria-expanded="true"] .select__chev { rotate: 180deg; }
.select__list {
  left: 0; right: auto; transform-origin: top left;
  min-width: 256px; max-height: min(336px, 60dvh); overflow-y: auto;
  padding: 6px;
}
.select__list.is-end { left: auto; right: 0; transform-origin: top right; }
.select__opt {
  position: relative;
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 42px; padding: 0 10px 5px;
  border-radius: 6px; font-size: 13.5px; cursor: pointer;
}
.select__opt .ico--tick { color: var(--cobalt); visibility: hidden; }
.select__opt[aria-selected="true"] { font-weight: 600; }
.select__opt[aria-selected="true"] .ico--tick { visibility: visible; }
.select__meta { font: 400 12px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.select__opt::after {
  content: ""; position: absolute; left: 38px; right: 10px; bottom: 6px; height: 2px;
  background:
    linear-gradient(var(--cobalt), var(--cobalt)) no-repeat left / calc(100% * var(--share, 0)) 100%,
    var(--rule);
}
.select__opt.is-active { background: var(--cobalt); color: var(--on-cobalt); }
.select__opt.is-active .ico--tick, .select__opt.is-active .select__meta { color: inherit; }
.select__opt.is-active::after {
  background:
    linear-gradient(currentColor, currentColor) no-repeat left / calc(100% * var(--share, 0)) 100%,
    color-mix(in srgb, currentColor 28%, transparent);
}
.select__note {
  margin-top: 6px; padding: 9px 10px 5px;
  border-top: 1px solid var(--rule);
  font-size: 12px; color: var(--ink-3);
}

/* Notice: the line that confirms an action. Optional single action (Undo) and a dismiss button.
   Add .is-on to show it; toast() in script.js does the timing. */
.notice {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: min(580px, calc(100vw - 32px));
  padding: 6px 6px 6px 14px;
  background: var(--tip); color: var(--on-tip);
  border-radius: var(--r-2); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 500;
  translate: -50% 12px; opacity: 0; visibility: hidden;
  transition: opacity .2s, translate .3s var(--ease), visibility 0s .3s;
}
.notice.is-on { opacity: 1; translate: -50% 0; visibility: visible; transition-delay: 0s; }
.notice__ico { color: var(--notice-accent); }
.notice__text { flex: 1; min-width: 0; padding: 6px 0; line-height: 1.4; }
.notice__act {
  height: 32px; padding: 0 11px; flex: none;
  border: 1px solid color-mix(in srgb, var(--on-tip) 38%, transparent); border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--on-tip);
  transition: background-color .15s;
}
.notice__act[hidden] { display: none; }
.notice__x {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 6px; color: color-mix(in srgb, var(--on-tip) 72%, transparent);
  transition: background-color .15s, color .15s;
}
.notice__act:hover, .notice__x:hover { background: color-mix(in srgb, var(--on-tip) 14%, transparent); color: var(--on-tip); }
.notice :focus-visible { outline-color: var(--on-tip); outline-offset: 1px; }

/* Dialogs: one backdrop and one open and close motion for the palette and the confirmation.
   The backdrop is the desk dimmed, with the chart's gridlines still faintly ruled across it. */
dialog::backdrop {
  background:
    repeating-linear-gradient(to bottom, transparent 0 55px, var(--backdrop-rule) 55px 56px),
    var(--backdrop);
  animation: fade .2s ease-out;
}
dialog.is-closing { animation: dlg-out .14s ease-in forwards; }
dialog.is-closing::backdrop { animation: fade-out .14s ease-in forwards; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(-8px) scale(.985); } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(-6px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* Confirmation dialog: a question, what it costs, and a ledger of what will change
   (old value struck through in sand, new value beside it). The safe button takes focus. */
.confirm {
  width: min(452px, calc(100vw - 32px));
  margin: auto; padding: var(--s-5);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--r-3);
  box-shadow: var(--shadow);
}
.confirm[open] { animation: dlg-in .22s var(--ease); }
.confirm h2 { font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
.confirm p { margin-top: var(--s-2); color: var(--ink-2); text-wrap: pretty; }
.confirm__rows { margin-top: var(--s-4); border-top: 1px solid var(--ink); }
.confirm__rows[hidden] { display: none; }
.confirm__rows div {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4);
  padding: 9px 0; border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.confirm__rows dt { color: var(--ink-2); white-space: nowrap; }
.confirm__rows dd {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px;
  font: 400 12.5px/1.5 var(--mono); font-variant-numeric: tabular-nums; text-align: right;
}
.confirm__rows s { color: var(--ink-3); text-decoration-color: var(--sand); text-decoration-thickness: 1.5px; }
.confirm__rows b { font-weight: 500; }
.confirm__actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-5); }
.btn.btn--danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.btn--danger:hover { background: var(--danger-deep); border-color: var(--danger-deep); }

/* Scroll areas inside the page (tables, palette list, select list) */
.scroller, .palette__list, .select__list { scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 999px; border: 2px solid var(--paper); }
  ::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
}

/* ---------- 4. Page ---------- */
.main {
  max-width: 1640px; margin: 0 auto;
  padding: var(--s-5) var(--s-6) 96px;
}

/* the headline states the finding; the controls and the dateline sit opposite it */
.pagehead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-5) var(--s-7); align-items: end;
  padding-top: var(--s-2); margin-bottom: var(--s-5);
}
.pagehead h1 {
  font-size: clamp(30px, 3.4vw, 50px); line-height: 1.03; font-weight: 600; letter-spacing: -.036em;
  text-wrap: balance; max-width: 20ch;
  font-variant-numeric: tabular-nums;
}
.pagehead h1:focus-visible { outline-offset: 6px; }
.pagehead__stand {
  margin-top: var(--s-4); max-width: 60ch;
  font-size: 16px; line-height: 1.5; color: var(--ink-2);
  text-wrap: pretty; font-variant-numeric: tabular-nums;
}
.pagehead__stand b { font-weight: 600; color: var(--ink); }
.pagehead__side { display: grid; gap: var(--s-3); justify-items: end; }
.controls { display: flex; align-items: center; gap: var(--s-2); }
.dateline {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0 var(--s-3);
  font: 400 12px/1.5 var(--mono); color: var(--ink-3); text-align: right;
  min-height: 30px;
}
.dateline__reset { display: inline-flex; align-items: center; gap: 5px; font-family: var(--sans); }
.dateline__reset[hidden] { display: none; }

.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-3);
  border: 1px solid var(--rule-2); border-radius: var(--r-2);
  background: var(--paper); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover, .btn[aria-expanded="true"] { background: var(--paper-2); border-color: var(--ink-3); }
.btn .ico { color: var(--ink-2); }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary .ico { color: inherit; }
.btn--primary:hover, .btn--primary[aria-expanded="true"] { background: var(--ink-2); border-color: var(--ink-2); }

.range {
  display: inline-flex; padding: 2px; gap: 2px;
  border: 1px solid var(--rule-2); border-radius: var(--r-2);
  background: var(--paper);
}
.range label { position: relative; cursor: pointer; }
.range input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.range span {
  display: flex; align-items: center;
  height: 30px; padding: 0 var(--s-3);
  border-radius: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: background-color .2s var(--ease), color .2s;
}
.range i { font-style: normal; }
.range .u-s { display: none; }
.range label:hover span { color: var(--ink); background: var(--paper-2); }
.range input:checked + span { background: var(--ink); color: var(--paper); }
.range input:focus-visible + span { outline: 2px solid var(--cobalt); outline-offset: 2px; }

/* figures: a ruled heading, a standfirst, the graphic, a source line */
.fig { border-top: 2px solid var(--ink); padding-top: var(--s-3); min-width: 0; scroll-margin-top: calc(var(--bar-h) + var(--s-4)); }
.fig__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4) var(--s-5); flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.fig__head--row { align-items: center; }
.fig h2 { font-size: 21px; line-height: 1.22; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; max-width: 40ch; }
.fig--anchor h2, .fig--kpi h2 { font-size: 15px; line-height: 1.4; letter-spacing: -.005em; }
.fig__stand { color: var(--ink-2); margin-top: 3px; max-width: 68ch; text-wrap: pretty; font-variant-numeric: tabular-nums; }
.fig__stand b { font-weight: 500; color: var(--ink); }
.fig__src { margin-top: var(--s-3); font-size: 12px; color: var(--ink-3); max-width: 75ch; }
.fig__narrow { display: none; }
.fig__stand--hint { font-size: 13px; }
.is-compact .fig__stand--hint { display: none; }   /* the docked readout carries the hint instead */

.key { display: flex; gap: var(--s-4); font-size: 12.5px; color: var(--ink-2); padding-top: 4px; white-space: nowrap; }
.key li { display: flex; align-items: center; gap: 7px; }
.key__line { width: 18px; height: 0; border-top: 2px solid var(--cobalt); }
.key__line--prev { border-top: 2px solid var(--sand); }
.key__tick { display: inline-block; width: 2px; height: 11px; background: var(--sand); margin-right: 7px; vertical-align: -1px; }

.lead {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--s-6); align-items: stretch;
}
.pair {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--s-7); align-items: start; margin-top: var(--s-7);
}
.pair--wide { grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s-6); }

/* anchor chart */
.chart { position: relative; display: flex; flex-direction: column; border-radius: var(--r-1); touch-action: pan-y; }
.chart__svg { min-height: 430px; }
.chart svg { display: block; width: 100%; overflow: visible; font-family: var(--mono); cursor: crosshair; }
.g-grid { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.g-base { stroke: var(--ink); stroke-width: 1; shape-rendering: crispEdges; }
.g-y, .g-x { fill: var(--ink-3); font-size: 11px; }
.g-sub { fill: var(--ink-2); font: 500 12px var(--sans); }
.s-cur { fill: none; stroke: var(--cobalt); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.s-prev { fill: none; stroke: var(--sand); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.p-cur { fill: var(--paper); stroke: var(--cobalt); stroke-width: 2; }
.p-prev { fill: var(--paper); stroke: var(--sand); stroke-width: 1.5; }
.b-gain { fill: var(--cobalt); }
.b-loss { fill: var(--sand); }
.a-lead { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.a-ring { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.a-disc { fill: var(--ink); }
.a-letter { fill: var(--paper); font: 600 10px var(--sans); text-anchor: middle; }
.a-label { fill: var(--ink); font: 500 12px var(--sans); }
.x-line { stroke: var(--ink); stroke-width: 1; shape-rendering: crispEdges; }
.x-dot { fill: var(--cobalt); stroke: var(--paper); stroke-width: 2; }
.x-dot--prev { fill: var(--sand); }
.x-date { fill: var(--paper); font: 500 11px var(--mono); text-anchor: middle; }
.x-tag { fill: var(--ink); }
.x-hide { visibility: hidden; }

.tip {
  position: absolute; top: 0; left: 0; z-index: 5;
  min-width: 216px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--r-2); box-shadow: var(--shadow);
  font-size: 12.5px; pointer-events: none;
  transition: transform .12s var(--ease);
}
.tip[hidden] { display: none; }
.tip__date { font-weight: 600; margin-bottom: 6px; }
.tip dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s-4); }
.tip dt { color: var(--ink-2); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip dd { margin: 0; font-family: var(--mono); text-align: right; white-space: nowrap; }
.tip__sw { width: 10px; height: 2px; background: var(--cobalt); }
.tip__sw--prev { background: var(--sand); }
.tip__note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rule); color: var(--ink); font-weight: 500; max-width: 220px; }
/* docked readout: narrow charts keep the plot clear and read the day out above it */
.tip--dock {
  position: static; order: -1; min-width: 0;
  display: grid; align-content: center; gap: 3px;
  min-height: 58px; margin-bottom: var(--s-2); padding: 8px 12px;
  background: var(--paper-2); border: 0; box-shadow: none;
  transition: none;
}
.tip__row { display: flex; align-items: baseline; gap: var(--s-3); min-width: 0; font-family: var(--mono); white-space: nowrap; }
.tip__row > span { display: inline-flex; align-items: center; gap: 6px; }
.tip__row .tip__date { margin: 0; font-family: var(--sans); font-size: 13.5px; }
.tip__ev { display: block !important; font-family: var(--sans); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tip__num { margin-left: auto; }
.tip__hint { color: var(--ink-2); }
.is-good { color: var(--good); }
.is-bad { color: var(--bad); }

.notes { display: none; margin-top: var(--s-3); gap: 6px var(--s-4); flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.notes li { display: flex; align-items: baseline; gap: 6px; }
.notes b {
  display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none;
  border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: 10px; font-weight: 600; translate: 0 -1px;
}
.notes time { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.is-compact .notes { display: flex; }

/* Key figures: one flat slab beside the chart. The tokens are re-pointed inside it, so the
   rows, mini charts, skeleton and focus ring all draw from the slab palette without extra rules. */
.fig--kpi {
  --paper: var(--slab); --paper-2: var(--slab-2); --paper-3: var(--slab-3);
  --ink: var(--slab-ink); --ink-2: var(--slab-ink-2); --ink-3: var(--slab-ink-2);
  --rule: var(--slab-rule); --cobalt: var(--slab-cur); --sand: var(--slab-prev);
  --good: var(--slab-good); --bad: var(--slab-bad);
  display: flex; flex-direction: column;
  border-top: 0; border-radius: var(--r-1);
  padding: var(--s-4) var(--s-5) var(--s-2);
  background: var(--slab); color: var(--slab-ink);
}
.fig--kpi .fig__head { margin-bottom: var(--s-3); min-height: 26px; }
.kpi__when { font: 400 12px/1 var(--mono); color: var(--ink-2); white-space: nowrap; }
.kpi__when.is-live { color: var(--slab); background: var(--slab-cur); font-weight: 500; padding: 6px 8px; border-radius: var(--r-1); margin: -6px 0; }
.kpis { flex: 1; display: grid; grid-auto-rows: 1fr; }
.kpi {
  display: grid; grid-template-columns: minmax(0, 1fr) 136px;
  gap: 0 var(--s-4); align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}
.kpi__label { display: block; font-size: 13px; color: var(--ink-2); }
.kpi__val {
  display: block; margin-top: 2px;
  font: 500 25px/1.2 var(--mono); letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.kpi__side { display: grid; gap: 6px; justify-items: end; }
.kpi__delta {
  display: inline-flex; align-items: center; gap: 3px;
  font: 500 12px/1 var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.kpi__delta .ico { width: 12px; height: 12px; stroke-width: 2; }
.kpi__delta.is-flat { color: var(--ink-3); }
.kpi__mini { display: block; width: 136px; height: 34px; overflow: visible; cursor: crosshair; touch-action: pan-y; }
.kpi__mini .s-cur { stroke-width: 1.75; }
.kpi__mini .s-prev { stroke-width: 1; }
.kpi__mini .x-line { stroke: var(--ink-2); }

/* cohort heat table */
.scroller { position: relative; overflow-x: auto; scrollbar-width: thin; }   /* relative: keeps visually hidden header text inside */
.scroller:focus-visible { outline-offset: 4px; }
.cohort { width: 100%; border-collapse: separate; border-spacing: 2px; margin: -2px; font-variant-numeric: tabular-nums; }
.cohort th, .cohort td { height: 30px; padding: 0 4px; white-space: nowrap; }
.cohort thead th { font: 400 11px/1 var(--mono); color: var(--ink-3); text-align: center; height: 24px; }
.cohort thead th:first-child, .cohort thead th:nth-child(2) { text-align: left; font-family: var(--sans); font-size: 12px; }
.cohort tbody th, .cohort tfoot th {
  position: sticky; left: 0; z-index: 1;
  background: var(--paper);
  text-align: left; font-weight: 500; font-size: 13px; padding-left: 0; padding-right: var(--s-3);
}
.cohort .c-size { font: 400 12px/1 var(--mono); color: var(--ink-2); text-align: right; padding-right: var(--s-3); }
.cohort thead .c-size { text-align: right; }
.cohort td.h { font: 400 12px/1 var(--mono); text-align: center; min-width: 42px; border-radius: 2px; transition: box-shadow .15s; }
.cohort td.is-blank { background: none; }
.cohort tfoot th, .cohort tfoot td { border-top: 0; }
.cohort tfoot tr > * { height: 34px; }
.cohort tfoot td.h { font-weight: 500; }
.cohort tfoot th { color: var(--ink-2); font-weight: 400; }
.cohort tr.is-cur th { color: var(--cobalt); }
.cohort tr.is-cur th::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--cobalt); vertical-align: 1px; }
.cohort tr.is-cur td.h:not(.is-blank) { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.cohort tr.is-note th span { border-bottom: 1px dashed var(--ink-3); }

.h { background: color-mix(in srgb, var(--heat) var(--m, 0%), var(--paper)); color: var(--ink); }
.h1 { --m: 8%; }  .h2 { --m: 18%; } .h3 { --m: 30%; } .h4 { --m: 42%; }
.h5 { --m: 54%; } .h6 { --m: 66%; } .h7 { --m: 86%; } .h8 { --m: 100%; }
.h7, .h8 { color: var(--heat-on); }
:root[data-theme="dark"] .h1 { --m: 10%; } :root[data-theme="dark"] .h2 { --m: 20%; }
:root[data-theme="dark"] .h3 { --m: 30%; } :root[data-theme="dark"] .h4 { --m: 40%; }
:root[data-theme="dark"] .h5 { --m: 49%; } :root[data-theme="dark"] .h6 { --m: 58%; }

.scale { display: flex; align-items: center; gap: 2px; font: 400 11px/1 var(--mono); color: var(--ink-3); padding-top: 6px; }
.scale .h { width: 18px; height: 10px; border-radius: 1px; }
.scale span:first-child { margin-right: 5px; }
.scale span:last-child { margin-left: 5px; }

/* funnel */
.funnel { display: grid; }
.fstep { display: grid; gap: 6px; padding: 11px 0 12px; border-top: 1px solid var(--rule); }
.fstep:first-child { border-top: 0; padding-top: 2px; }
.fstep__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); }
.fstep__name { font-weight: 500; }
.fstep__n { font: 500 14px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.fstep__bar { position: relative; height: 22px; background: var(--paper-2); border-radius: 2px; }
.fstep__bar i { position: absolute; inset: 0 auto 0 0; min-width: 3px; background: var(--cobalt); border-radius: 2px; transition: width .5s var(--ease); }
.fstep__bar b { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--sand); }
.fstep__meta { display: flex; justify-content: space-between; gap: var(--s-4); font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fstep__meta span:last-child { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.fstep.is-worst .fstep__meta span:last-child { color: var(--bad); font-weight: 500; }

/* pages table */
.filter {
  display: flex; align-items: center; gap: var(--s-2);
  height: 36px; width: 260px; padding: 0 var(--s-3);
  border: 1px solid var(--rule-2); border-radius: var(--r-2);
  background: var(--paper); color: var(--ink-3);
  transition: border-color .15s, box-shadow .15s;
}
.filter:focus-within { border-color: var(--cobalt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 22%, transparent); }
.filter input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 13.5px; color: var(--ink); -webkit-appearance: none; appearance: none; }
.filter input::-webkit-search-decoration { -webkit-appearance: none; }
.filter input::placeholder { color: var(--ink-3); }
.filter input::-webkit-search-cancel-button {
  -webkit-appearance: none; width: 14px; height: 14px; cursor: pointer;
  background: var(--ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pages { width: 100%; font-variant-numeric: tabular-nums; }
.pages th { padding: 0; text-align: left; border-bottom: 1px solid var(--rule-2); }
.pages th button {
  display: inline-flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 var(--s-3);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  border-radius: var(--r-1);
}
.pages th.c-num button { flex-direction: row-reverse; }
.pages th.c-num { text-align: right; }
.pages th:first-child button { padding-left: 0; }
.pages th:last-child button { padding-right: 0; }
.pages th button:hover { color: var(--ink); }
.pages th .ico { opacity: .45; }
.pages th[aria-sort="ascending"] button, .pages th[aria-sort="descending"] button { color: var(--ink); }
.pages th[aria-sort="ascending"] .ico, .pages th[aria-sort="descending"] .ico { opacity: 1; color: var(--cobalt); }
.pages td { padding: 9px var(--s-3); border-bottom: 1px solid var(--rule); vertical-align: middle; }
.pages td:first-child { padding-left: 0; }
.pages td:last-child { padding-right: 0; }
.pages tbody tr { transition: background-color .12s; }
.pages tbody tr:hover { background: var(--paper-2); }
.pages .c-num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.pages th.c-num { font-family: var(--sans); }
.pages .pg__path { display: block; font: 500 13px/1.35 var(--mono); overflow-wrap: break-word; }
.pages .pg__title { display: block; font-size: 12.5px; color: var(--ink-3); line-height: 1.35; }
.pages .pg__path mark, .pages .pg__title mark { background: var(--cobalt-tint); color: inherit; border-radius: 2px; padding: 0 1px; }
.pages td.c-bar {
  min-width: 168px;
  background: linear-gradient(var(--cobalt-tint), var(--cobalt-tint)) no-repeat left var(--s-2) center / calc((100% - var(--s-4)) * var(--w, 0)) 24px;
}
.pages tfoot td { border-bottom: 0; border-top: 1px solid var(--ink); font-weight: 500; padding-top: 11px; }
.pages tfoot td:first-child { font-family: var(--sans); font-size: 13px; }
.chg { display: inline-flex; align-items: center; gap: 2px; }
.chg .ico { width: 12px; height: 12px; stroke-width: 2; }

.empty {
  display: grid; justify-items: center; gap: var(--s-3);
  padding: var(--s-7) var(--s-4); text-align: center;
  border-bottom: 1px solid var(--rule);
}
.empty[hidden] { display: none; }
.empty > .ico { width: 28px; height: 28px; color: var(--ink-3); }
.empty p { display: grid; gap: 4px; max-width: 46ch; color: var(--ink-2); }
.empty strong { color: var(--ink); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

/* dated log */
.log { border-top: 1px solid var(--rule); }
.log li { border-bottom: 1px solid var(--rule); }
.log__item {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px var(--s-3);
  width: 100%; padding: 12px 0; text-align: left;
  transition: background-color .12s;
}
.log__item:hover { background: var(--paper-2); }
.log__mark {
  grid-row: span 3; margin-top: 1px;
  display: grid; place-items: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: 10.5px; font-weight: 600;
}
.log__item.is-out .log__mark { background: none; border: 1px dashed var(--ink-3); color: transparent; }
.log__when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); }
.log__date { font: 400 12px/1.5 var(--mono); color: var(--ink-3); }
.log__hint { font-size: 12px; color: var(--ink-3); }
.log__title { font-weight: 500; line-height: 1.35; }
.log__fx { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.log__fx b { font: 500 12px var(--mono); }
.log__item.is-out .log__title { color: var(--ink-2); }
.log__item.is-cur .log__mark { background: var(--cobalt); color: var(--on-cobalt); box-shadow: 0 0 0 3px var(--cobalt-tint); }
.log__item.is-cur .log__date { color: var(--cobalt); }

.noscript { margin-top: var(--s-6); color: var(--ink-2); }

/* skeleton: shown briefly while a new range or segment is drawn */
.is-loading .sk { position: relative; color: transparent !important; pointer-events: none; }
.is-loading .sk > * { visibility: hidden; }
.is-loading .sk::after {
  content: ""; position: absolute; inset: 2px 0;
  border-radius: var(--r-1);
  background: linear-gradient(100deg, var(--paper-2) 30%, var(--paper-3) 50%, var(--paper-2) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.1s linear infinite;
}
.is-loading h1.sk::after { right: 8%; }
.is-loading h2.sk::after { right: 30%; }
.is-loading .pagehead__stand.sk::after { right: 12%; }
.is-loading .fig__stand.sk::after { right: 12%; }
.is-loading .kpi__val.sk::after { right: 20%; }
.is-loading .chart.sk::after,
.is-loading .scroller.sk::after,
.is-loading .funnel.sk::after,
.is-loading .log.sk::after {
  background:
    repeating-linear-gradient(to bottom, transparent 0 34px, var(--paper) 34px 44px),
    linear-gradient(100deg, var(--paper-2) 30%, var(--paper-3) 50%, var(--paper-2) 70%) 0 0 / 300% 100%;
}
@keyframes shimmer { to { background-position: 0 0, -300% 0; } }
.is-loading h1.sk::after, .is-loading h2.sk::after, .is-loading .fig__stand.sk::after, .is-loading .pagehead__stand.sk::after, .is-loading .kpi__val.sk::after, .is-loading .kpi__side.sk::after { animation-name: shimmer-one; }
@keyframes shimmer-one { to { background-position: -300% 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .lead, .pair, .pair--wide { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
  .pair { margin-top: var(--s-6); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-7); }
  .topbar__fresh:not(.is-live) { display: none; }
  .pagehead { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .pagehead__side { justify-items: start; }
  .dateline { justify-content: flex-start; text-align: left; }
}

@media (max-width: 920px) {
  .pages .c-hide { display: none; }   /* visitors and average time give way first */
  .topbar { grid-template-columns: auto minmax(220px, 420px) 1fr; }
  .cohort td.h { min-width: 34px; }
}

@media (max-width: 760px) {
  :root { --bar-h: 52px; }
  body { display: flex; flex-direction: column; }
  .app { display: contents; }
  .topbar {
    order: 1; position: static;
    grid-template-columns: 1fr auto auto; gap: var(--s-1);
    padding: 0 var(--s-2) 0 var(--s-4);
  }
  .topbar__mark { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 -10px; }
  .topbar__id { gap: 10px; }
  .topbar__env { display: none; }
  .search { width: 44px; height: 44px; padding: 0; justify-content: center; background: none; border-color: transparent; color: var(--ink-2); }
  .search__label, .search__kbd { display: none; }
  .iconbtn { width: 44px; height: 44px; }
  .avatar { margin: 0 6px; }
  .avatar::after { content: ""; position: absolute; width: 44px; height: 44px; }
  .avatar { position: relative; }

  .rail {
    order: 2; position: sticky; top: 0; inset: auto;
    width: auto; height: 48px; padding: 0;
    flex-direction: row; align-items: stretch;
  }
  .rail__brand { display: none; }
  .rail__list {
    flex-direction: row; gap: 0; width: 100%;
    overflow-x: auto; scrollbar-width: none; padding: 0 var(--s-2);
  }
  .rail__list::-webkit-scrollbar { display: none; }
  .rail__link { width: auto; height: 48px; padding: 0 12px; border-radius: 0; color: var(--rail-ink); }
  .rail__link .ico { display: none; }
  .rail__link span {
    position: static; translate: none; opacity: 1; background: none !important; padding: 0;
    color: inherit !important; font-size: 14px; pointer-events: auto;
  }
  .rail__link:hover { background: none; }
  .rail__link[aria-current="true"] { background: none; color: #fff; box-shadow: inset 0 -3px 0 var(--rail-accent); }
  .rail :focus-visible { outline-offset: -3px; }

  .main { order: 3; width: 100%; padding: var(--s-5) var(--s-4) 96px; }
  .topbar__fresh { display: none !important; }   /* the docked readout above the chart does this job */
  .pagehead { gap: var(--s-4); padding-top: 0; margin-bottom: var(--s-5); }
  .pagehead h1 { font-size: clamp(31px, 9.4vw, 40px); max-width: none; }
  .pagehead__stand { font-size: 15px; margin-top: var(--s-3); }
  .pagehead__side { justify-items: stretch; gap: var(--s-2); }
  .controls { justify-content: space-between; gap: 6px; }
  .controls .select { flex: 1; min-width: 0; }
  .select__list { min-width: min(256px, calc(100vw - 32px)); }
  .select__opt { min-height: 48px; }
  .dateline { min-height: 0; }
  .dateline #page-sub { display: none; }   /* the standfirst already gives both periods */
  .dateline__reset { min-height: 32px; }
  .btn { height: 44px; }
  #seg-btn { width: 100%; }
  #seg-btn { min-width: 0; padding: 0 10px; }
  #seg-btn > .ico:first-child { display: none; }   /* the label needs the room */
  #seg-btn span { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; }
  #export-btn { width: 44px; padding: 0; justify-content: center; }
  .btn__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .range span { height: 38px; min-width: 44px; padding: 0 clamp(8px, 2.6vw, 12px); display: flex; align-items: center; justify-content: center; }
  .range input { inset: -3px 0; }
  .range .u-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .range .u-s { display: inline; }
  .menuitem { min-height: 44px; }
  .panel--notif { position: fixed; top: 58px; left: 12px; right: 12px; width: auto; }
  .palette { margin-top: 12px; max-height: calc(100dvh - 24px); }
  .palette__opt { min-height: 44px; }
  .palette__foot span:not(:last-child) { display: none; }
  .palette__foot span:last-child { margin-left: 0; }

  .fig { scroll-margin-top: 60px; }
  .fig h2 { font-size: 19px; }
  .fig--anchor h2, .fig--kpi h2 { font-size: 15px; }
  .fig--kpi { margin: 0 calc(var(--s-4) * -1); border-radius: 0; padding: var(--s-4) var(--s-4) var(--s-2); }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi { grid-template-columns: minmax(0, 1fr) 124px; }
  .kpi__mini { width: 124px; }
  .chart__svg { min-height: 380px; }
  .filter { width: 100%; height: 44px; }
  .filter input { font-size: 16px; }
  .fig__head--row:has(.filter) { align-items: stretch; flex-direction: column; }
  .pages .c-hide, .pages .c-hide2 { display: none; }
  .pages th button { height: 44px; min-width: 44px; padding: 0 6px; }
  .pages th.c-num button { justify-content: flex-start; }
  .pages td { padding-left: 6px; padding-right: 6px; }
  .pages td.c-bar { min-width: 0; background: none; }
  .pages .c-num { width: 1%; }
  .pages th[aria-sort="none"] .ico { display: none; }   /* the arrow shows on the sorted column only */
  .cohort tr.is-cur td.h:not(.is-blank) { box-shadow: inset 0 0 0 1.5px var(--ink); }
  .pages .pg__path { font-size: 12.5px; }
  .log__item { padding: 14px 0; }
  /* cohort table: fits the screen instead of scrolling (see renderCohort for the kept columns) */
  .cohort .c-wide, .cohort .c-long { display: none; }
  .fig__narrow { display: inline; }
  .cohort { table-layout: auto; }
  .cohort th, .cohort td { height: 32px; padding: 0 1px; }
  .cohort td.h { min-width: 0; font-size: 11.5px; }
  .cohort tbody th, .cohort tfoot th { position: static; font-size: 12.5px; padding-right: var(--s-2); }
  .cohort .c-size { font-size: 11.5px; padding-right: var(--s-2); }
  .cohort tr.is-cur th::after { content: none; }
  .scale { width: 100%; }
  .notice { bottom: 20px; width: calc(100vw - 24px); max-width: none; }
  .notice__act, .notice__x { height: 40px; }
  .notice__x { width: 40px; }
  .confirm { padding: var(--s-4); }
  .confirm__actions { flex-direction: column-reverse; }
  .confirm__actions .btn { justify-content: center; width: 100%; }
  .confirm__actions .btn--primary { width: 100%; }
  .confirm__rows div { flex-direction: column; gap: 2px; }
  .confirm__rows dd { justify-content: flex-start; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .rail, .topbar, .controls, .notice, .dateline__reset { display: none; }
  .app { margin: 0; }
}
