/* The Stats dashboard's design system: calm and light, one accent (indigo), hairline borders, a soft shadow, a 4/8 px
   spacing scale, tabular numbers. Colour means one thing each: green good or up, red broken or needs action now, amber
   waiting for you, indigo links and primary actions, grey neutral. Money is never red for being money.
   Type: five sizes (12, 13, 14, 20, 36) and three weights (400, 500, 600); every card title is 14/600 in ink.
   Widths: a sidebar down to 901 px, then a top bar and a menu; tables become cards at 640 px and below. */
:root {
  /* Surfaces and lines */
  --bg: #f7f6f3; --surface: #ffffff; --surface-2: #faf9f7; --well: #f4f3ef;
  --line: #e7e5e0; --line-soft: #efede9; --line-strong: #d6d3cc;
  /* Ink (muted is AA on white and on the background) */
  --ink: #1c1917; --ink-2: #3f3b37; --muted: #625d56; --faint: #8b857c;
  /* The accent: links, primary actions, charts */
  --accent: #4b32c3; --accent-hover: #3a2699; --accent-soft: #efecfc; --accent-line: #d3cbf6;
  --chart: #6552d6; --chart-soft: #9486e3; --chart-wash: rgba(101, 82, 214, .1);
  /* Meaning */
  --good: #15803d; --good-ink: #166534; --good-soft: #e7f4ec;
  --bad: #b42318; --bad-ink: #9f1c13; --bad-soft: #fdeceb; --bad-line: #f4c7c3;
  --wait: #b45309; --wait-ink: #8a4507; --wait-soft: #fdf3e2; --wait-line: #efd6a6;
  --grey-soft: #efede8; --grey-ink: #46413c;
  /* Shape */
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 1px 1px rgba(28, 25, 23, .02);
  --shadow-pop: 0 10px 28px rgba(28, 25, 23, .14), 0 2px 6px rgba(28, 25, 23, .06);
  --focus: 0 0 0 3px rgba(75, 50, 195, .28);
  /* Spacing: 4 / 8 scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  /* Type */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--font);
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button { font: inherit; }
b, strong { font-weight: 600; }
.num, .table, .kpi .value, .stat .value, .segmented, .delta { font-variant-numeric: tabular-nums; }
.grow { flex-grow: 1; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip:focus { top: 8px; box-shadow: var(--shadow-pop); }
.skip:not(:focus) { box-shadow: none; }

/* ---- App shell: a sidebar on a computer, a top bar and a menu below 900 px ---- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.side { grid-column: 1; grid-row: 1; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--s5) var(--s3); display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 20px; font-weight: 600; font-size: 14px; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--ink); }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; min-height: 36px; }
.nav-link svg, .menu-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-link svg { color: var(--faint); }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav-link[aria-current="page"] svg { color: var(--accent); }
.count { font-size: 12px; font-weight: 600; background: var(--wait); color: #fff; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.more { margin-top: var(--s4); border-top: 1px solid var(--line-soft); padding-top: var(--s2); }
.more summary { list-style: none; cursor: pointer; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); margin: 0 4px 0 2px; transition: transform .15s; }
.more[open] summary::before { transform: rotate(45deg); }
.more summary:hover { background: var(--surface-2); color: var(--ink); }
.more-note { margin: 2px 10px 4px; font-size: 12px; color: var(--muted); }
.small-link { font-size: 13px; padding: 6px 10px 6px 26px; min-height: 32px; }
.sign-out { margin-top: auto; padding: var(--s2) 0 0; border-top: 1px solid var(--line-soft); }
/* The older pages (their write controls, until every page is taken over): one quiet link above Sign out. */
.older-link { margin-top: auto; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.older-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.older-link + .sign-out { margin-top: var(--s1); }
.sign-out button { background: none; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--muted); cursor: pointer; width: 100%; text-align: left; font-size: 13px; min-height: 36px; }
.sign-out button:hover { background: var(--surface-2); color: var(--ink); }
.scrim { display: none; }
.main { grid-column: 2; grid-row: 1; width: 100%; max-width: 1320px; min-width: 0; padding: 28px 40px 56px; display: flex; flex-direction: column; gap: var(--s5); }
.main:focus { outline: none; }
.slot { display: contents; }
.slot:empty { display: none; }

/* ---- Page header ---- */
.topline { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; min-height: 40px; }
.topline h1 { font-size: 20px; font-weight: 600; line-height: 1.3; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: -12px; }
.crumbs a { color: var(--muted); }
.page-meta { display: flex; flex-direction: column; gap: var(--s2); margin-top: -14px; }
.range-line { margin: 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.range-line > * + *::before { content: "·"; margin: 0 8px; color: var(--faint); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }
.refresh { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.refresh svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lead { margin: -8px 0 0; color: var(--muted); }
.section-title { margin: 8px 0 -8px; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }
.rule { font-size: 12px; color: var(--muted); margin: var(--s2) 0 0; }

/* ---- Date control: presets in one row, custom days below ---- */
.dates { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); position: relative; max-width: 100%; min-width: 0; }
.segmented { display: inline-flex; background: var(--grey-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; }
.segmented button { border: 0; background: transparent; color: var(--ink-2); border-radius: 7px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; min-height: 32px; }
.segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, .6); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(28, 25, 23, .1), 0 0 0 1px rgba(28, 25, 23, .04); }
.range-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2); font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s3); box-shadow: var(--shadow-pop); position: absolute; top: calc(100% + 6px); right: 0; z-index: 25; }
.range-form label { display: flex; flex-direction: column; gap: 4px; }
.range-form input, .filters input, .filters select { font: inherit; font-size: 13px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 8px; background: var(--surface); min-height: 34px; }
.range-form input:focus, .filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.range-hint { color: var(--bad); font-size: 12px; flex-basis: 100%; }
.range-hint:empty { display: none; }

/* ---- Buttons, pills, links ---- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; border-radius: 8px; padding: 8px 14px; min-height: 36px; white-space: nowrap;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); box-shadow: 0 1px 1px rgba(28, 25, 23, .04); cursor: pointer; }
.button:hover { text-decoration: none; background: var(--surface-2); border-color: var(--faint); color: var(--ink); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.button.small { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 13px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; white-space: nowrap; }
.pill:hover { border-color: var(--line-strong); color: var(--ink); }
.pill[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }

/* ---- Badges: only for what is not normal ---- */
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 18px; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.badge.live { color: var(--good-ink); background: var(--good-soft); }
.badge.live::before, .badge.partial::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.badge.partial { color: var(--grey-ink); background: var(--grey-soft); }
.badge.partial::before { background: linear-gradient(90deg, var(--good) 50%, var(--faint) 50%); }
.badge.wait { color: var(--wait-ink); background: var(--wait-soft); }
.badge.bad, .badge.money { color: var(--bad-ink); background: var(--bad-soft); }
.badge.grey, .badge.test { color: var(--grey-ink); background: var(--grey-soft); }

/* ---- Terms: their meaning above them on hover or focus, never off the screen, never over the number ---- */
.term { position: relative; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; cursor: help; }
.term.quiet { text-decoration: none; }
.term:focus-visible { outline-offset: 1px; }
.term:hover::after, .term:focus-visible::after { content: attr(data-help); position: absolute; left: -8px; bottom: calc(100% + 8px); z-index: 30; width: min(260px, calc(100vw - 32px));
  background: #1f1b18; color: #fff; font-size: 12px; font-weight: 400; line-height: 1.45; letter-spacing: 0; text-transform: none; white-space: normal; text-align: left;
  padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-pop); pointer-events: none; }
.term.end:hover::after, .term.end:focus-visible::after { left: auto; right: -8px; }
.term-short { display: none; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card-head { margin: 0; padding: 14px var(--s5); font-size: 14px; font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 52px; }
.card-head h2 { font-size: 14px; font-weight: 600; color: var(--ink); }
.card-body { padding: var(--s4) var(--s5); }
.loading { color: var(--muted); }
.empty { color: var(--muted); }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--muted); margin: 0; }
.notice.attention { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }
.banner { display: flex; align-items: center; gap: 12px; background: var(--wait-soft); border: 1px solid var(--wait-line); border-radius: var(--radius); padding: 12px 16px; color: var(--wait-ink); }
.banner:hover { text-decoration: none; color: var(--wait-ink); border-color: var(--wait); }
.banner .go { font-weight: 600; white-space: nowrap; }
.banner.attention { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }

/* ---- States: loading, empty, failed ---- */
.skeleton { display: inline-block; vertical-align: middle; border-radius: 6px; background: linear-gradient(90deg, #eeece7 25%, #f7f6f2 50%, #eeece7 75%); background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.sk-title { width: 180px; height: 26px; }
.sk-value { width: 6em; max-width: 90%; height: .9em; }
.sk-line { width: 14em; max-width: 100%; height: 12px; }
.sk-num { width: 3.5em; height: 12px; }
.sk-spark { width: 104px; height: 22px; }
.sk-chip { width: 52px; height: 18px; }
.sk-dot { width: 22px; height: 22px; border-radius: 50%; }
.sk-chart { width: 100%; height: 200px; border-radius: var(--radius); margin-top: var(--s2); }
.sk-card { height: 112px; border-radius: var(--radius-lg); }
.sk-block { width: 100%; height: 280px; border-radius: var(--radius-lg); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: var(--s8) var(--s5); color: var(--muted); min-height: 150px; }
.empty-state strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.empty-state .button { margin-top: var(--s2); }
.error-state { display: flex; align-items: center; gap: var(--s3); background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad-ink); border-radius: var(--radius); padding: 10px 12px 10px 14px; }
.error-state strong { font-weight: 600; }
.error-state > .grow { flex: 1 1 220px; min-width: 0; }
.error-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--bad); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.error-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); }
.kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--s4) 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .label, .stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 20px; font-weight: 600; line-height: 1.3; color: var(--ink); white-space: nowrap; overflow-wrap: normal; min-height: 26px; display: flex; align-items: center; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.value-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.delta { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 18px; padding: 1px 6px; border-radius: 6px; white-space: nowrap; cursor: default; }
.delta.good { color: var(--good-ink); background: var(--good-soft); }
.delta.bad { color: var(--bad-ink); background: var(--bad-soft); }
.delta.neutral { color: var(--grey-ink); background: var(--grey-soft); }
.value-row .vs { font-size: 13px; color: var(--muted); }
.value-row .link.vs { color: var(--accent); }

/* The home headline: revenue and its chart; beside it (below 1180 px: under it, in one row) money in and traffic. */
.overview { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); gap: var(--s3); align-items: stretch; }
.kpi.hero { padding: var(--s5) var(--s5) var(--s4); gap: 6px; }
.kpi.hero .value { font-size: 36px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; min-height: 44px; }
.kpi.hero .chart-figure, .kpi.hero .sk-chart, .kpi.hero .empty-state, .kpi.hero .error-state { margin-top: var(--s3); }
.hero-note { margin: 0; font-size: 12px; color: var(--muted); }
.overview-error { grid-column: 1 / -1; }
.stats { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.stat-group { flex: 1 1 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 14px 18px 6px; min-width: 0; }
.stat-group h2 { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); min-height: 48px; }
.stat-group h2 + .stat { border-top: 0; }
.stat-value { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat .value { font-size: 20px; font-weight: 600; white-space: nowrap; }
.stat:has(> p.stat-sub) { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; }
.stat > p.stat-sub { grid-column: 1 / -1; margin: 0; font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---- Charts ---- */
.chart-figure { margin: 0; min-width: 0; }
.chart { position: relative; min-height: 150px; border-radius: 8px; }
.chart:focus-visible { outline-offset: 4px; }
.chart-svg { display: block; overflow: visible; }
.chart .grid line { stroke: var(--line-soft); stroke-width: 1; }
.chart .grid g:first-child line { stroke: var(--line-strong); }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .future { fill: var(--well); }
.chart .now line { stroke: var(--faint); stroke-width: 1; }
.chart .now text { fill: var(--muted); }
.chart .bar { fill: var(--chart); transition: fill .12s; }
.chart .bar.partial { fill: var(--chart-soft); }
.chart .bars:hover .bar:not(.active), .chart:focus-within .bars .bar:not(.active) { opacity: .55; }
.chart .bar.active { fill: var(--accent-hover); opacity: 1; }
.chart .bar.partial.active { fill: var(--chart); }
.chart-tip { position: absolute; transform: translate(-50%, calc(-100% - 10px)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-pop);
  padding: 7px 10px; font-size: 12px; line-height: 1.4; pointer-events: none; display: flex; flex-direction: column; white-space: nowrap; z-index: 5; }
.chart-tip strong { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-tip span { color: var(--muted); }
.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke: var(--chart); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark-tail { fill: none; stroke: var(--chart); stroke-width: 1.75; stroke-linecap: round; stroke-dasharray: 2 3; opacity: .4; }
.spark-area { fill: var(--chart-wash); }
.spark-dot { fill: var(--chart); stroke: var(--surface); stroke-width: 1.5; }
.spark.flat .spark-line, .spark.flat .spark-tail { stroke: var(--line-strong); opacity: 1; }

/* ---- Needs you: three rows, then "Show N more"; each a title and one line ---- */
.needs .card-head { border-bottom: 0; padding-bottom: 6px; min-height: 0; }
.head-note { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }
.needs-list { list-style: none; margin: 0; padding: 0 0 4px; }
.need { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px var(--s5); border-top: 1px solid var(--line-soft); min-height: 60px; }
.need-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; align-self: start; margin-top: 1px; }
.need-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.need.bad .need-icon { background: var(--bad); color: #fff; }
.need.bad .need-title { color: var(--bad-ink); }
.need.wait .need-icon { background: var(--wait-soft); color: var(--wait); box-shadow: inset 0 0 0 1.5px var(--wait); }
.need.wait .need-icon svg { stroke-width: 2.2; }
.need.unknown .need-icon { background: var(--grey-soft); color: var(--grey-ink); }
.need.check .need-title { color: var(--muted); font-weight: 500; }
.need-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.need-title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need-detail { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.needs-more { padding: 6px var(--s5) 10px 54px; border-top: 1px solid var(--line-soft); }
.need-action svg { display: none; }

/* ---- Tables: they fit their card or scroll inside it, never past the page ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: bottom; line-height: 1.35; overflow-wrap: normal; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td, .table tr:last-child th[scope="row"] { border-bottom: 0; }
.table .right { text-align: right; }
.table td.empty { color: var(--muted); padding: var(--s6) var(--s5); text-align: center; }
.big { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.small { font-size: 12px; color: var(--muted); }

/* The funnels list: it fits from 761 px up (its headings' meanings open above it, so no scroll box there); below, it
   scrolls inside its card if it must, until it becomes cards at 640 px. */
@media (min-width: 761px) { .funnels-card .table-scroll { overflow: visible; } }
.table.funnels th:first-child, .table.funnels td:first-child { padding-left: var(--s5); }
.table.funnels th:last-child, .table.funnels td:last-child { padding-right: var(--s5); }
.table.funnels th { white-space: nowrap; }
.table.funnels td { vertical-align: middle; padding-top: 14px; padding-bottom: 14px; }
.table.funnels td.num { white-space: nowrap; color: var(--ink-2); }
.table.funnels td.strong { font-weight: 600; color: var(--ink); }
.table.funnels .trend-col { width: 128px; }
.funnel-row { cursor: pointer; }
.funnel-row:hover td { background: #fcfbf9; }
.name-cell { min-width: 200px; }
.name-cell > * + * { margin-top: 6px; }
.row-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.row-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.row-name:hover { color: var(--accent); }
.row-url { font-size: 12px; color: var(--muted); overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: inline-block; vertical-align: bottom; }
.row-url:hover { color: var(--accent); }
.row-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-notes { font-size: 12px; color: var(--muted); }
.span-note { color: var(--muted); font-size: 13px; }
.span-note a { font-weight: 500; }
.note-row td { color: var(--muted); font-size: 13px; padding: 12px var(--s5); background: var(--surface-2); }
.funnel-row.outside td { background: var(--surface-2); }
.funnel-row.outside .row-name { font-weight: 500; color: var(--ink-2); }
.drafts { margin: 0; padding: 12px var(--s5); border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }

/* Data tables (a funnel's pages): numbers on one line; a wide one scrolls inside its card */
.table.data td { white-space: nowrap; }
.table.data th[scope="row"] { font-weight: 400; background: none; white-space: normal; color: var(--ink); font-size: 14px; min-width: 160px; padding: 12px 14px; vertical-align: top; }
.table.data.wide { min-width: 1000px; }
.named { display: flex; flex-direction: column; gap: 2px; }
.named strong { font-weight: 600; }
.named small { font-size: 12px; color: var(--muted); }

/* An address in monospace (the older controls' page cards). */
.addr { font-size: 13px; font-family: var(--mono); overflow-wrap: anywhere; }

/* ---- Lists (waiting, history) ---- */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 14px var(--s5); border-bottom: 1px solid var(--line-soft); }
.item:last-child { border-bottom: 0; }
.item .when { font-size: 13px; color: var(--muted); }
.item .what { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item .what .title { font-weight: 600; }
.item .what .addrs { font-size: 12px; font-family: var(--mono); color: var(--ink-2); word-break: break-all; }
.item .note { font-size: 13px; color: var(--muted); }

/* ---- A funnel's sections and filters ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: var(--s5); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-sm:empty { display: none; }
.filter-bar { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 12px; font-weight: 600; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-hover); border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.filters fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.filters legend { font-weight: 600; padding: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 3px; }
.filter-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.filter-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filter-actions { display: flex; gap: 8px; }
.versions { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.version-steps { margin-top: 14px; }
.main > .segmented { align-self: flex-start; }
details > summary { cursor: pointer; }

/* ---- Below 1180 px: the headline over one card with the five numbers in a row ---- */
@media (max-width: 1180px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
  .stats { flex-direction: row; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 14px 0 12px; }
  .stat-group { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0 var(--s5); display: grid; column-gap: var(--s4); align-content: start; }
  .stat-group.two { flex: 2 1 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-group.three { flex: 3 1 0; grid-template-columns: repeat(3, minmax(0, 1fr)); border-left: 1px solid var(--line-soft); }
  .stat-group h2 { grid-column: 1 / -1; margin-bottom: 6px; }
  .stat { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; border-top: 0; padding: 0; min-height: 0; }
  .stat-value { flex-direction: column; align-items: flex-start; gap: 4px; }
  .stat .term-full { display: none; }
  .stat .term-short { display: inline; }
  .kpis.five { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (min-width: 641px) and (max-width: 1180px) {
  .stat:has(> p.stat-sub) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1080px) {
  .table.funnels .trend-col { display: none; }
}

/* ---- Below 900 px: a top bar and a menu ---- */
@media (max-width: 900px) {
  .name-cell { min-width: 150px; }
  .table.funnels th, .table.funnels td { padding-left: 10px; padding-right: 10px; }
  .table.funnels th:first-child, .table.funnels td:first-child { padding-left: var(--s4); }
  .table.funnels th:last-child, .table.funnels td:last-child { padding-right: var(--s4); }
  .app { display: block; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; gap: 12px; height: 56px; padding: 0 8px 0 16px;
    background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
  .topbar .brand { padding: 0; }
  .menu-button { position: relative; width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
  .menu-button:hover { background: var(--surface-2); }
  .menu-button svg { width: 22px; height: 22px; }
  .menu-button .icon-close, .menu-button[aria-expanded="true"] .icon-open, .menu-button[aria-expanded="true"] .menu-dot { display: none; }
  .menu-button[aria-expanded="true"] .icon-close { display: block; }
  .menu-dot { position: absolute; top: 9px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--wait); border: 2px solid var(--surface); }
  .side { display: none; position: fixed; left: 0; right: 0; top: 56px; height: auto; max-height: calc(100vh - 56px); z-index: 29; border-right: 0; border-bottom: 1px solid var(--line);
    padding: var(--s2) var(--s3) var(--s4); box-shadow: var(--shadow-pop); }
  .side > .brand { display: none; }
  .app.menu-open .side { display: flex; }
  .scrim { display: block; position: fixed; inset: 56px 0 0; background: rgba(28, 25, 23, .28); z-index: 28; }
  .nav-link { min-height: 44px; }
  .small-link { min-height: 40px; }
  .sign-out { margin-top: var(--s3); }
  .older-link { margin-top: var(--s3); min-height: 40px; display: flex; align-items: center; }
  .sign-out button { min-height: 44px; }
  .main { padding: 18px 24px 40px; gap: var(--s4); max-width: none; }
  .topline { gap: var(--s2); }
  .topline > .grow { display: none; }
  .dates { width: 100%; flex: 1 1 100%; align-items: stretch; order: 5; }
  .dates .segmented { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); padding-right: 32px; }
  .dates .segmented::-webkit-scrollbar { display: none; }
  .dates .segmented button { flex: 1 0 auto; }
  .range-form { position: static; box-shadow: none; }
  .page-meta { margin-top: -8px; }
  .refresh { min-height: 32px; }
  .crumbs { margin-bottom: -8px; }
}

/* ---- 640 px and below (a phone): numbers in two columns, tables as cards, rows as links ---- */
@media (max-width: 640px) {
  .main { padding: 18px 16px 40px; }
  .range-line { font-size: 12px; }
  .range-line .tz { display: none; }
  /* Refresh sits at the right end with no dot before it, so it never starts a line with a stray "·". */
  .range-line .refresh { margin-left: auto; }
  .range-line .refresh::before { content: none; }
  .kpis, .kpis.five, .kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis.five > .kpi:first-child, .kpis.three > .kpi:first-child { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .kpi.hero { padding: var(--s4); }
  /* The five numbers: one card, two titled lists. */
  .stats { flex-direction: column; padding: 12px 0 4px; }
  .stat-group { display: block; padding: 0 var(--s4); }
  .stat-group.three { border-left: 0; border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 4px; }
  .stat { flex-direction: row; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); padding: 8px 0; min-height: 44px; }
  .stat-value { flex-direction: row; align-items: center; }
  .stat .term-full { display: inline; }
  .stat .term-short { display: none; }
  .stat-group h2 + .stat { border-top: 0; }
  .card > h2, .card-head { padding: 12px var(--s4); min-height: 48px; }
  .card-body { padding: 14px var(--s4); }
  /* Needs you: the whole line is the link. */
  .need { grid-template-columns: 22px minmax(0, 1fr) 16px; padding: 10px var(--s4); position: relative; min-height: 0; }
  .need:active { background: var(--surface-2); }
  .need-title { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .need .need-action { border: 0; background: none; box-shadow: none; padding: 0; min-height: 0; color: var(--faint); width: 16px; }
  .need .need-action::after { content: ""; position: absolute; inset: 0; }
  .need .need-action:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
  .need .need-action:focus-visible { outline: none; }
  .need-action-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .need-action svg { display: block; width: 16px; height: 16px; }
  .need.unknown { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .needs-more { padding-left: 50px; }
  .needs-more .link { min-height: 44px; }
  .head-note { flex-basis: 100%; margin-left: 0; }
  .table .optional { display: none; }
  .item { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 14px var(--s4); }
  .item > .button { justify-self: start; }
  .error-state { flex-wrap: wrap; }
  /* Data tables as labelled cards. */
  .table.data.wide { min-width: 0; }
  .table.data thead { display: none; }
  .table.data, .table.data tbody, .table.data tr { display: block; }
  .table.data tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 12px var(--s4); border-bottom: 1px solid var(--line-soft); }
  .table.data tr:last-child { border-bottom: 0; }
  .table.data th[scope="row"], .table.data td { padding: 0; border: 0; text-align: left; white-space: normal; }
  .table.data th[scope="row"] { grid-column: 1 / -1; min-width: 0; }
  .table.data td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  .table.data td.empty { grid-column: 1 / -1; }
  /* Funnels as cards: name and state beside the trend, then the numbers in three columns. */
  .table.funnels thead { display: none; }
  .table.funnels, .table.funnels tbody { display: block; }
  .table.funnels tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; padding: 14px var(--s4); border-bottom: 1px solid var(--line-soft); }
  .table.funnels tr:last-child { border-bottom: 0; }
  .table.funnels td { padding: 0 !important; border: 0; }
  .table.funnels td.name-cell { grid-column: 1 / 3; min-width: 0; }
  .table.funnels .trend-col { display: flex; grid-column: 3; justify-content: flex-end; align-items: flex-start; width: auto; }
  .table.funnels .trend-col .spark { width: 72px; height: 28px; }
  .table.funnels .trend-col .sk-spark { width: 64px; }
  .table.funnels td.span-note, .note-row td { grid-column: 1 / -1; }
  .table.funnels td[data-label] { text-align: left; display: flex; flex-direction: column; justify-content: flex-end; }
  .table.funnels td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-weight: 400; white-space: normal; line-height: 1.3; margin-bottom: 2px; }
  .table.funnels td.empty { grid-column: 1 / -1; }
  .note-row { display: block !important; }
  .funnel-row.outside { background: var(--surface-2); }
  .funnel-row.outside td { background: none; }
  .table.funnels td.not-counted { display: none; }
  .drafts { padding: 12px var(--s4); }
}
