/* wtanalytics: white cards with a soft shadow on a light grey page, violet
   accent, 10 px radii, uppercase small stat labels, tabular numbers.
   Dynamic values (bar widths, gauge fills) arrive as custom properties set
   with setStyle(); there are no style attributes anywhere (CSP). */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #1b2330;
  --muted: #5b6676;
  --faint: #9aa5b6;
  --border: #d5dae2;
  --grid: #e3e7ed;
  --row-line: #f0f2f5;
  --accent: #5b4fd6;
  --accent-text: #ffffff;
  --accent-soft: #ecebfb;
  --accent-strong: #4a3fc0;
  --selected: #f1f0fd;
  --neutral-soft: #eef1f4;
  --series: #5b4fd6;
  --series-err: #d4432f;
  --series-city: #d9650b;
  --series-compare: #9aa5b6;
  --ok: #1a7f37;
  --warn: #9a6700;
  --warn-dot: #d29a00;
  --bad: #c62828;
  --bar: #ecebfb;
  --bar-err: #fbe9e7;
  --bar-slow: #fdf3dc;
  --notice-bg: #fdf3dc;
  --notice-text: #7a5300;
  --danger-border: #f0c4c0;
  --focus: #4a3fc0;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 4px 14px rgba(16, 24, 40, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #181d26;
    --surface-2: #141920;
    --text: #e6eaf0;
    --muted: #9aa5b6;
    --faint: #6b7686;
    --border: #2f3a4a;
    --grid: #2a3442;
    --row-line: #222a36;
    --accent: #9d93ff;
    --accent-text: #120d33;
    --accent-soft: rgba(157, 147, 255, 0.16);
    --accent-strong: #b9b2ff;
    --selected: rgba(157, 147, 255, 0.12);
    --neutral-soft: #242c38;
    --series: #9d93ff;
    --series-err: #ff6b57;
  --series-city: #ffa24a;
    --series-compare: #6b7686;
    --ok: #4ac26b;
    --warn: #e3b341;
    --warn-dot: #e3b341;
    --bad: #ff7b72;
    --bar: rgba(157, 147, 255, 0.16);
    --bar-err: rgba(255, 123, 114, 0.16);
    --bar-slow: rgba(227, 179, 65, 0.16);
    --notice-bg: rgba(227, 179, 65, 0.14);
    --notice-text: #f0c96a;
    --danger-border: rgba(255, 123, 114, 0.45);
    --focus: #b9b2ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-pop: 0 6px 18px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { font-family: var(--font); font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; min-width: 320px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 30; }
.skip:focus { left: 0; }
.spacer { flex: 1 1 auto; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* tabindex="-1" elements (pane headings, the secret box) only take focus from script, to move screen readers; no ring */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ------------------------------------------------------------ page layout */
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; padding: 1.5rem 1rem; font-size: 0.85rem; color: var(--muted); }
.page-title { font-size: 1.15rem; margin: 0.25rem 0 1rem; }
main.narrow { max-width: 46rem; }

/* header (shell.js) */
.app-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; max-width: 1200px; margin: 0 auto; padding: 0.9rem 1rem 0.6rem; }
.logo { display: inline-flex; line-height: 0; border-radius: 0.5rem; }
.logo img { width: 2rem; height: 2rem; }
.crumb { color: var(--muted); }
.crumb a { color: inherit; }
.crumb a:hover { color: var(--text); }
.back-link { color: var(--muted); text-decoration: none; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.back-link:hover { color: var(--text); border-color: var(--accent); }
.control { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.6rem; max-width: 16rem; }
.site-picker, .range-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.range-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.range-custom label { font-size: 0.85rem; color: var(--muted); }
.range-custom .form-error { flex-basis: 100%; }
.live-rate { color: var(--muted); text-decoration: none; font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-rate:hover { color: var(--text); }
.live-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--ok); margin-right: 0.4rem; vertical-align: 1px; }
.live-value { color: var(--text); font-weight: 600; }

/* avatar menu */
.menu-wrap { position: relative; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; padding: 0; border: 0; background: var(--accent); color: var(--accent-text); font-size: 0.8rem; font-weight: 600; display: grid; place-items: center; letter-spacing: 0.02em; }
.avatar { position: relative; }
.avatar-ro { position: absolute; right: -0.25rem; bottom: -0.25rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 0.6rem; line-height: 1; display: grid; place-items: center; }
.avatar:hover:not(:disabled) { border: 0; filter: brightness(1.08); }
.menu { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-pop); border: 1px solid var(--grid); padding: 0.35rem; width: max-content; min-width: 12rem; max-width: min(18rem, calc(100vw - 2rem)); }
.menu-id { display: flex; flex-direction: column; padding: 0.4rem 0.6rem; overflow-wrap: anywhere; }
.menu-id .muted { font-size: 0.85rem; }
.menu-sep { border: 0; border-top: 1px solid var(--grid); margin: 0.3rem 0; }
.menu-item { display: block; width: 100%; text-align: left; padding: 0.4rem 0.6rem; border-radius: 5px; color: var(--text); text-decoration: none; background: none; border: 0; font-size: 0.95rem; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--neutral-soft); border: 0; }
.menu-item.danger { color: var(--bad); }

/* dashboard tabs */
.page-tabs { display: flex; gap: 0.25rem; max-width: 1200px; margin: 0 auto; padding: 0 1rem; overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--border); }
/* Chevron on the edge where tabs run off (fade-start / fade-end set by shell.js): sticky flex items over a fade of the page background. */
.page-tabs::before, .page-tabs::after { display: none; position: sticky; z-index: 1; flex: none; align-self: stretch; width: 2.75rem; align-items: center; color: var(--muted); font-size: 1.4rem; pointer-events: none; }
.page-tabs::before { content: '\2039'; left: 0; margin-right: calc(-2.75rem - 0.25rem); justify-content: flex-start; padding-left: 0.2rem; background: linear-gradient(to right, var(--bg) 45%, transparent); }
.page-tabs::after { content: '\203a'; right: 0; margin-left: calc(-2.75rem - 0.25rem); justify-content: flex-end; padding-right: 0.2rem; background: linear-gradient(to left, var(--bg) 45%, transparent); }
.page-tabs.fade-start::before, .page-tabs.fade-end::after { display: flex; }
.page-tab { padding: 0.55rem 0.8rem; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.page-tab:hover { color: var(--text); }
.page-tab[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

/* --------------------------------------------------------------- surfaces */
.card, .panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card-head, .panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.card-head h2, .card > h2 { font-size: 0.95rem; }
.card > h2 { margin-bottom: 0.75rem; }
.card-head .hint, .card-head .muted { font-size: 0.8rem; }
.card.danger { border: 1px solid var(--danger-border); }
.card.danger h2 { color: var(--bad); }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card-grid > .card { margin-bottom: 0; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin: 0.25rem 0 1rem; overflow-wrap: anywhere; }
.link-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.link-list li { margin: 0.2rem 0; }
.more { display: inline-block; margin-top: 0.5rem; font-size: 0.85rem; text-decoration: none; }
.more:hover { text-decoration: underline; }

/* notices and banners */
.banner { padding: 0.6rem 0.85rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); margin: 0.5rem 0 1rem; }
.banner.error { border-color: var(--bad); color: var(--bad); }
.notice, .banner.warn { background: var(--notice-bg); color: var(--notice-text); border: 0; border-radius: 8px; padding: 0.6rem 0.85rem; margin: 0 0 1rem; }

/* ---------------------------------------------------------------- controls */
button, input, select { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.8rem; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { border-color: var(--danger-border); color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.small { padding: 0.15rem 0.5rem; font-size: 0.85rem; }
a.button { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.8rem; color: inherit; text-decoration: none; text-align: center; }
a.button:hover { border-color: var(--accent); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
input, select { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; max-width: 100%; }
input:disabled, input[readonly] { color: var(--muted); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.session-row { justify-content: space-between; margin-bottom: 0; }
.session-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.session-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.75rem; padding: 0.5rem 0; border-top: 1px solid var(--border); }
.session-place { font-weight: 600; }
.session-meta { flex: 1 1 12rem; font-size: 0.85rem; }
.session-actions { display: flex; gap: 0.5rem; }
.stack { display: flex; flex-direction: column; gap: 0.4rem; max-width: 28rem; }
.stack label { font-weight: 600; margin-top: 0.4rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.actions.end { justify-content: flex-end; }
.form-error, .field-error { color: var(--bad); margin: 0.25rem 0 0; font-size: 0.9rem; }
.form-status { color: var(--ok); margin: 0.75rem 0 0; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* label / field pairs */
.form-grid { display: grid; grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr); gap: 0.6rem 1rem; align-items: center; }
.form-grid > label, .form-grid > .label { color: var(--muted); }
.form-grid > .label:has(+ #account-sites) { align-self: start; padding-top: 0.1rem; }
.site-list { list-style: none; margin: 0; padding: 0; max-height: 10rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.site-list li { padding: 0.1rem 0.5rem; line-height: 1.35; }
.site-list li + li { border-top: 1px solid var(--border); }
.form-grid input, .form-grid select { width: 100%; max-width: 26rem; }
.form-grid .field-error, .form-grid .hint { grid-column: 2; margin-top: -0.3rem; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem 1.5rem; width: min(24rem, 100%); margin: 0; border-top: 3px solid var(--accent); }
.login-brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.25rem; margin-bottom: 1.25rem; }
.instance-badge { display: inline-block; font-size: 0.75rem; line-height: 1.6; font-weight: 600; padding: 0 0.6rem; border-radius: 999px; background: var(--warn); color: var(--bg); white-space: nowrap; }
.logo { align-items: center; gap: 0.6rem; }
.login-mark { width: 2rem; height: 2rem; }
.login-box .stack { max-width: none; }
.login-box h2 { font-size: 1rem; margin-bottom: 0.25rem; }
.login-box .actions { margin-top: 0.75rem; }
.login-box button.primary, .login-box a.button.primary { width: 100%; box-sizing: border-box; }
.login-box input { width: 100%; }

/* ------------------------------------------------------------- status bits */
.pill { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); font-size: 0.85rem; }
.pill[data-state="live"] { color: var(--ok); border-color: var(--ok); }
.pill[data-state="reconnecting"], .pill[data-state="connecting"] { color: var(--warn); border-color: var(--warn); }
.pill[data-state="closed"] { color: var(--bad); border-color: var(--bad); }
.pill[data-state="live"]::before { content: "\25CF\00a0"; }

/* badges: accent by default; .neutral, .warn, .ok, .stale/.bad */
.badge { display: inline-block; font-size: 0.72rem; line-height: 1.5; padding: 0 0.5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); margin-left: 0.4rem; font-family: var(--font); font-weight: 500; vertical-align: 1px; white-space: nowrap; }
.last-status { white-space: nowrap; }
.status-changed { margin-left: 0.35rem; color: var(--warn); font-weight: 600; cursor: help; }
.badge:first-child { margin-left: 0; }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.badge.warn { background: var(--bar-slow); color: var(--warn); }
.badge.ok { background: transparent; box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok); }
.badge.stale, .badge.bad { background: var(--bar-err); color: var(--bad); }

/* status dots: green healthy, amber warning, red stale */
.status-dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: 1px; background: var(--faint); }
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--warn-dot); }
.status-dot.bad { background: var(--bad); }
.status-dot.gone { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.gone-note { font-size: 0.85rem; margin: 0 0 0.75rem; }
tr.gone { opacity: 0.65; }

/* gauges: setStyle(fill, '--fill', '42%') */
.gauge { height: 0.4rem; background: var(--neutral-soft); border-radius: 3px; margin-top: 0.4rem; overflow: hidden; }
.gauge-fill { display: block; height: 100%; width: var(--fill, 0%); max-width: 100%; border-radius: 3px; background: var(--accent); }
.gauge-fill.warn { background: var(--warn-dot); }
.gauge-fill.bad { background: var(--bad); }

/* system page: one-line facts and pool gauges */
.fact { margin: 0 0 0.35rem; }
.fact b.num, .pool-head .num { font-variant-numeric: tabular-nums; }
.fact-list { margin: 0.25rem 0 0.5rem; padding-left: 1.1rem; }
.fact-list li { margin: 0.15rem 0; overflow-wrap: anywhere; }
.pool + .pool { margin-top: 0.75rem; }
.pool-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; }
.pool .gauge { display: block; }
.pool .hint { margin-top: 0.25rem; font-size: 0.8rem; }

/* ----------------------------------------------------------------- audience */
/* The Overview's audience switch: a segmented control of <button aria-pressed>,
   shaped like the range picker's .control. */
.audience-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.4rem; }
.segmented { display: inline-flex; flex-wrap: wrap; }
.segmented button { position: relative; border-radius: 0; margin-left: -1px; padding: 0.35rem 0.6rem; background: var(--surface); }
.segmented button:first-child { margin-left: 0; border-radius: 8px 0 0 8px; }
.segmented button:last-child { border-radius: 0 8px 8px 0; }
.segmented button:hover:not(:disabled), .segmented button:focus-visible { z-index: 1; }
.segmented button[aria-pressed="true"] { z-index: 2; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.audience-label { font-weight: 600; font-size: 0.9rem; margin: 0; }
.split-note { margin-top: 0.25rem; }
.audience-head + .hint { margin-bottom: 0.5rem; }

/* --------------------------------------------------------------- stat strip */
/* <div class="stat-strip"> of .stat (a <button aria-pressed> when it selects
   the chart metric). Delta colours say good/bad, not up/down. */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.25rem 0; margin: 0 0 0.75rem; }
.stat { display: block; text-align: left; padding: 0.5rem 0.9rem; border: 0; border-left: 1px solid var(--grid); border-radius: 0; background: none; color: var(--text); min-width: 0; }
.stat:first-child { border-left-color: transparent; }
button.stat { cursor: pointer; border-radius: 8px; }
button.stat:hover:not(:disabled) { border-color: var(--grid); background: var(--neutral-soft); }
button.stat:first-child:hover:not(:disabled) { border-left-color: transparent; }
.stat[aria-pressed="true"], .stat.selected { background: var(--selected); color: var(--text); border-left-color: transparent; border-radius: 8px; }
button.stat[aria-pressed="true"]:hover:not(:disabled) { background: var(--selected); border-left-color: transparent; }
.stat[aria-pressed="true"] + .stat, .stat.selected + .stat { border-left-color: transparent; }
.stat-label, .stat-value, .stat-sub { display: block; }
.stat-label { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.45rem; font-weight: 600; margin-top: 0.2rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value small { font-size: 0.8rem; font-weight: 400; color: var(--muted); }
.stat-value.bad { color: var(--bad); }
.stat-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta { font-size: 0.78rem; font-weight: 500; margin-left: 0.35rem; white-space: nowrap; color: var(--muted); }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--bad); }
.delta[data-dir="up"]::before { content: "\2197\00a0"; }
.delta[data-dir="down"]::before { content: "\2198\00a0"; }

/* -------------------------------------------------------------- flat style */
/* <body class="flat"> is every analytics page: no card chrome, tiles pick the
   metric, charts and tables sit on the page, and stacked sections are split by
   a hairline. Admin, profile and sign-in pages keep their cards (forms). */
.flat main .card { background: none; box-shadow: none; padding: 0; margin-bottom: 1.25rem; }
.flat main .card + .card { border-top: 1px solid var(--border); padding-top: 1rem; }
.flat main .card.danger { border: 1px solid var(--danger-border); padding: 1rem; border-radius: var(--radius); }
.flat .card-grid { gap: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.flat .card-grid > .card, .flat .card-grid > .card + .card { border-top: 0; padding-top: 0; }
.flat .stat-strip { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.flat .stat, .flat .stat:first-child { background: var(--surface); border: 1.5px solid transparent; border-radius: var(--radius); padding: 0.6rem 0.8rem; }
.flat button.stat:hover:not(:disabled) { background: var(--surface); border-color: var(--border); }
.flat .stat[aria-pressed="true"], .flat .stat.selected, .flat button.stat[aria-pressed="true"]:hover:not(:disabled) { background: var(--surface); border-color: var(--accent); }
.flat .stat-label { text-transform: none; letter-spacing: 0; font-size: 0.8rem; font-weight: 400; }
.flat .stat-value { font-weight: 500; }
.flat .top-row { padding: 0.3rem 0; margin: 0; border-radius: 0; border-bottom: 1px solid var(--row-line); }
.flat .top-row::before { inset: auto auto -1px 0; height: 2px; border-radius: 0; opacity: 0.7; }
.flat .top-list { --bar: var(--series); }
.flat .top-list.err { --bar-err: var(--series-err); }
.flat .top-list.slow { --bar-slow: var(--warn-dot); }
.flat th:first-child, .flat td:first-child { padding-left: 0; }
.flat th:last-child, .flat td:last-child { padding-right: 0; }
.overview-cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.overview-cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .overview-cols, .overview-cols3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .overview-cols, .overview-cols3 { grid-template-columns: minmax(0, 1fr); } }

/* -------------------------------------------------------- top-N with bars */
/* <ol class="top-list [err|slow]"><li class="top-row"> label + value; the bar
   width comes from setStyle(row, '--share', '62%'). */
.top-list { list-style: none; margin: 0; padding: 0; }
.top-row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.3rem 0.5rem; margin: 0.15rem 0; font-size: 0.88rem; border-radius: 4px; isolation: isolate; }
.top-row::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--share, 0%); max-width: 100%; background: var(--bar); border-radius: 4px; z-index: -1; }
.top-list.err .top-row::before { background: var(--bar-err); }
.top-list.slow .top-row::before { background: var(--bar-slow); }
.top-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
a.top-label:hover { text-decoration: underline; }
.top-label.mono { font-family: var(--mono); font-size: 0.8rem; }
.top-value { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-empty { color: var(--muted); font-size: 0.88rem; padding: 0.3rem 0.5rem; }
.top-list + .hint, .top-empty + .hint { margin-top: 0.5rem; font-size: 0.8rem; }

/* ------------------------------------------------------------------ charts */
.chart { position: relative; width: 100%; }
/* A long press reads the values (pointerdown/move); it must not select text or the graph, or open the callout. */
.chart, .chart svg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .axis-line { stroke: var(--border); stroke-width: 1; }
.chart .area { fill: var(--series); fill-opacity: 0.1; stroke: none; }
.chart .line, .chart .line-err, .chart .line-compare { fill: none; stroke: var(--series); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-extra { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: butt; opacity: 0.7; }
.chart .line-extra.dashed { stroke-dasharray: 6 4; }
.chart .line-extra.dashdot { stroke-dasharray: 8 3 2 3; }
.chart .line-extra.dotted { stroke-dasharray: 1.5 3.5; stroke-linecap: round; }
.chart .dot-extra { fill: var(--series); opacity: 0.7; }
.chart .line-err { stroke: var(--series-err); stroke-width: 1.5; }
.chart .line-compare { stroke: var(--series-compare); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-linecap: butt; }
.chart .line-proj { fill: none; stroke: var(--series); stroke-width: 2.25; stroke-dasharray: 5 4; stroke-linecap: butt; opacity: 0.75; }
.chart .stem-proj { stroke: var(--series); stroke-width: 1.5; stroke-dasharray: 1.5 3.5; stroke-linecap: round; opacity: 0.75; }
.chart .dot-proj { fill: var(--surface); stroke: var(--series); stroke-width: 2; }
.chart .rule { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Attack bands sit under the series; the series let clicks through to them. */
.chart .band { fill: var(--series-err); fill-opacity: 0.13; }
.chart .band.clickable { cursor: pointer; }
.chart .band.clickable:hover { fill-opacity: 0.24; }
.chart .line-proj, .chart .stem-proj, .chart .dot-proj, .chart .area, .chart .line, .chart .line-err, .chart .line-compare, .chart .line-extra, .chart .dot-extra, .chart .rule, .chart .dot, .chart .grid-line { pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.swatch { display: inline-block; width: 1rem; height: 0; border-top: 2px solid var(--series); margin-right: 0.35rem; vertical-align: 3px; }
.swatch.err { border-top-color: var(--series-err); }
.swatch.extra { border-top: 2px dashed var(--series); }
.swatch.extra.dashdot { border-top-style: dashed; }
.swatch.extra.dotted { border-top-style: dotted; }
.swatch.proj { border-top: 2px dashed var(--series); opacity: 0.75; }
.swatch.compare { border-top: 2px dashed var(--series-compare); }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--grid); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.85rem; box-shadow: var(--shadow-pop); width: max-content; max-width: 100%; box-sizing: border-box; transform: translate(-50%, -100%); }
.tooltip div { font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); text-align: center; padding: 5rem 1rem; margin: 0; }
.chart + .hint { margin-top: 0.6rem; }

/* --------------------------------------------------------------- all sites */
/* sites-page.js: compact cards, four per row at 1200 px; the left edge is
   the site's status (data-status ok | warn | bad | none). */
.sites-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.75rem; margin: 0.25rem 0 1rem; }
.sites-head .page-title { margin: 0; }
.sites-head > .muted, .sites-sort label { font-size: 0.85rem; }
.sites-sort { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.site-card { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border-left: 4px solid var(--faint); padding: 0.6rem 0.9rem 0.6rem; }
.site-card[data-status="ok"] { border-left-color: var(--ok); }
.site-card[data-status="warn"] { border-left-color: var(--warn-dot); }
.site-card[data-status="bad"] { border-left-color: var(--bad); }
.site-card.site-total { border-left-color: var(--accent); }
/* The site's identity colour (--site-accent, set inline by sites-page.js) is a top edge and a faint tint; the left edge stays the status. */
.site-card.has-accent { border-top: 4px solid var(--site-accent); background: color-mix(in srgb, var(--site-accent) 7%, var(--surface)); }
/* A very dark accent would vanish on the dark surface: lift the top edge towards the text colour. After the base rule, which resets the colour. */
@media (prefers-color-scheme: dark) {
  .site-card.has-accent { border-top-color: color-mix(in srgb, var(--site-accent) 70%, var(--text)); }
}
.site-icon { flex: none; width: 2rem; height: 2rem; border-radius: 6px; object-fit: contain; align-self: center; }
.site-badge { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; color: var(--text); background: color-mix(in srgb, var(--site-accent) 22%, var(--surface)); }
.site-env { margin-left: 0.4rem; padding: 0.05rem 0.4rem; border-radius: 999px; border: 1px solid var(--grid); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); vertical-align: 0.1em; }
.site-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; min-width: 0; }
.site-card-head.has-mark { align-items: center; }
.site-card-head h2 { display: flex; align-items: baseline; font-size: 0.98rem; min-width: 0; margin-right: auto; overflow: hidden; white-space: nowrap; }
.site-card-head .site-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card-head .site-env, .site-card-head .site-note { flex: none; }
.site-name { color: var(--text); text-decoration: none; }
.site-name:hover { text-decoration: underline; }
.site-card.is-link { position: relative; }
.site-card.is-link:hover { box-shadow: var(--shadow), 0 0 0 1px var(--accent); }
.stretched-link::after { content: ""; position: absolute; inset: 0; }
.site-note { font-weight: 400; font-size: 0.8rem; margin-left: 0.3em; }
.site-live { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.site-live .live-dot { width: 0.45rem; height: 0.45rem; margin-right: 0.3rem; }
.site-live[data-idle="true"] .live-dot { background: var(--faint); }
.spark { display: block; width: 100%; height: 1.75rem; overflow: visible; }
.spark-line { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--series); fill-opacity: 0.12; stroke: none; }
.site-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 0.75rem; margin: 0; }
.site-stat { min-width: 0; }
.site-stat dt { font-size: 0.65rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.site-stat dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-stat-value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.site-stat .delta { margin-left: 0.3rem; font-size: 0.72rem; }
.site-foot-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-top: auto; min-width: 0; }
.site-foot-row .site-foot { margin-top: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-region { flex: none; margin-left: auto; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.site-picker .site-region { margin-left: 0; font-size: 0.85rem; }
.site-region-icon { margin-right: 0.25rem; }
.site-foot { margin-top: auto; font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.site-foot:hover { color: var(--text); }
.site-unavailable { flex: 1 1 auto; color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0; }
.sites-legend .status-dot { margin-left: 0.25rem; }

/* ------------------------------------------------------------------ tables */
.table-wrap { position: relative; overflow-x: auto; margin-bottom: 1rem; } /* relative: keeps .sr-only cells inside the scroller */
.card .table-wrap:last-child { margin-bottom: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--row-line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; border-bottom-color: var(--grid); }
th[aria-sort] { cursor: pointer; }
.sort-btn { background: none; border: 0; border-radius: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.sort-btn:hover:not(:disabled) { border: 0; color: var(--text); }
th[aria-sort="ascending"]::after { content: "\00a0\25B4"; }
th[aria-sort="descending"]::after { content: "\00a0\25BE"; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }
td.key .url-origin { display: block; font-size: 0.72rem; line-height: 1.3; color: var(--muted); }
td.key .url-path { display: block; padding-left: 1ch; text-indent: -1ch; }
td.key { overflow-wrap: anywhere; min-width: 8rem; max-width: 32rem; font-family: var(--mono); font-size: 0.85rem; }
td.actions-cell { display: table-cell; }
td.actions-cell button { margin: 0 0.25rem 0.25rem 0; }
tr.link-row { cursor: pointer; }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
td.chevron { color: var(--faint); text-align: right; width: 1.5rem; }
tr.link-row:hover td { background: var(--surface-2); }
/* Clients page: the instance name is the button that opens its detail panel. */
.lib-outdated { color: var(--warn-dot); }
.lib-incompatible { color: var(--bad); font-weight: 600; }
.instance-btn { background: none; border: 0; border-radius: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.instance-btn:hover:not(:disabled) { border: 0; text-decoration: underline; }
.instance-btn[aria-expanded="true"] { font-weight: 600; }
/* client instance cards: 1 column on a phone, 2 on a normal screen, more on a large one */
.client-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); gap: 0.75rem; }
.client-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; min-width: 0; background: var(--surface, transparent); }
.client-card.bad { border-color: var(--bad); }
.client-card.warn { border-color: var(--warn-dot); }
.client-card.gone { opacity: 0.7; }
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.cc-title { display: flex; flex-direction: column; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.cc-site { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.cc-lib { font-size: 0.75rem; white-space: nowrap; }
.cc-figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.4rem 0.75rem; margin: 0; }
.cc-fig { min-width: 0; }
.cc-fig dt { font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.cc-fig dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cc-fig dd.bad { color: var(--bad); font-weight: 600; }
.cc-error { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.cc-error::before { content: "\2713\00a0"; color: var(--ok); }
.cc-error.past::before { content: none; }
.cc-error.failing { color: var(--bad); font-weight: 600; }
.cc-error.failing::before { content: "\26A0\00a0"; color: var(--bad); }
.client-panel { border-top: 1px solid var(--grid); margin-top: 1rem; padding-top: 0.75rem; }
.client-panel h3 { font-size: 0.85rem; margin: 0.75rem 0 0.25rem; }
/* Attacks: the notice under the Overview chart and the detail panel's lists. */
.attack-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin-top: 0.6rem; font-size: 0.85rem; }
.attack-notice .badge { margin-left: 0; }
.attack-notice .more { margin: 0 0 0 auto; }
.attack-btn { font: inherit; font-size: 0.8rem; font-variant-numeric: tabular-nums; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--danger-border); background: var(--surface); color: var(--text); cursor: pointer; }
.attack-btn[aria-expanded="true"] { background: var(--bar-err); border-color: var(--bad); }
.attack-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 1.5rem; }
.attack-flags { white-space: nowrap; }
.attack-flag { cursor: default; margin-right: .25em; }
.attack-country, .top-label.other { color: var(--muted); font-family: var(--font); }
td.instance { white-space: nowrap; overflow-wrap: normal; }
td.time { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 0.85rem; }
.share-cell { display: inline-flex; flex-direction: column; align-items: stretch; min-width: 4.5rem; text-align: right; }
.share-cell .gauge { height: 0.3rem; margin-top: 0.2rem; }
td .badge { vertical-align: 1px; }

/* ----------------------------------------------- dialogs and one-time secrets */
dialog { background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 1.25rem; width: min(30rem, calc(100% - 2rem)); }
dialog > h2 { margin-bottom: 1rem; }
dialog .form-grid .secret-row { margin: 0; flex-wrap: nowrap; }
dialog .form-grid .secret-row input { flex: 1 1 auto; min-width: 0; }
/* Confirm dialog: the password manager's popup opens under the field, so only the error line sits below it. */
.confirm-form { position: relative; max-width: none; }
.confirm-form > h2 { margin-right: 2rem; }
.dialog-close { position: absolute; top: -0.5rem; right: -0.5rem; width: 2rem; height: 2rem; padding: 0; line-height: 1; font-size: 1.25rem; background: transparent; border: 0; color: var(--muted); }
.confirm-passkey { align-self: flex-start; }
.confirm-or { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9em; }
.confirm-row { display: flex; gap: 0.5rem; align-items: stretch; }
.confirm-row input { flex: 1 1 auto; min-width: 0; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.secret-box { border: 2px solid var(--warn); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 1rem 0; background: var(--surface); }
.secret-box .warning { color: var(--warn); font-weight: 600; }
.secret-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.4rem 0; }
.secret-row code { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 0.25rem 0.5rem; border-radius: 4px; overflow-wrap: anywhere; user-select: all; }
.secret-box h4 { margin: 1rem 0 0.25rem; }
.integration-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.75rem; margin: 0.5rem 0; }
.integration-block summary { cursor: pointer; font-weight: 600; }
.integration-block pre { font-family: var(--mono); font-size: 0.85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem; margin: 0.4rem 0; max-height: 24rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.check-list { display: grid; gap: 0.3rem; margin: 0.5rem 0; max-height: 14rem; overflow-y: auto; }
.check-list label { display: flex; gap: 0.5rem; align-items: center; font-weight: normal; margin: 0; }
.site-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.4rem 1rem; }
.site-form-grid label { display: block; font-weight: 600; margin-top: 0.4rem; }
.site-form-grid input { width: 100%; }
.site-form-grid .inline-form { margin-bottom: 0; flex-wrap: nowrap; }
.site-form-grid .inline-form button { white-space: nowrap; }
.site-form-grid .inline-form input { flex: 1 1 auto; min-width: 0; }


/* ------------------------------------------------------------------ mobile */
@media (max-width: 720px) {
  /* Tabs on a phone: no scrolling, no More page; what does not fit goes in a menu at the end of the bar (shell.js, fitPhone). */
  .page-tabs.tabs-menu { overflow: visible; }
  .page-tabs.tabs-menu::before, .page-tabs.tabs-menu::after { display: none; }
  .more-layout > .more-nav { display: none; }
  .tab-menu { position: relative; flex: none; margin-left: auto; }
  .tab-menu-button { display: flex; align-items: center; justify-content: center; gap: 0.15rem; margin: 0; min-width: 2.75rem; height: 100%; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; font: inherit; cursor: pointer; }
  .tab-menu-button:hover:not(:disabled) { background: none; color: var(--text); border-color: transparent; }
  .tab-menu-button[aria-expanded="true"] { color: var(--text); }
  .tab-menu-button[aria-current="page"], .tab-menu-button[aria-current="page"]:hover:not(:disabled) { color: var(--text); border-bottom-color: var(--accent); }
  .tab-menu-list { right: 0; top: 100%; min-width: 12rem; max-width: calc(100vw - 1.5rem); }
  .tab-menu-list .menu-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.75rem; }
  .tab-menu-list .menu-item[aria-current="page"] { background: var(--selected); font-weight: 600; }
  .menu-label { margin: 0.4rem 0 0.1rem; padding: 0 0.75rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; }
  .burger { display: block; width: 1.15rem; height: 2px; border-radius: 1px; background: currentColor; box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor; }
  /* logo and avatar share the first row; pickers wrap below */
  .app-header > .logo { order: -2; flex: 1 0 calc(100% - 4rem); }
  .app-header > .menu-wrap { order: -1; }
  .app-header > .spacer { display: none; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-strip { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
}

@media (max-width: 480px) {
  main { padding: 0.75rem; }
  .app-header { padding: 0.75rem 0.75rem 0.5rem; }
  .page-tabs { padding: 0 0.75rem; }
  .card, .panel { padding: 0.85rem; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { border-left-color: transparent; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .form-grid .field-error, .form-grid .hint { grid-column: 1; margin-top: 0; }
  .form-grid > label { margin-top: 0.5rem; }
  .control { max-width: 12rem; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .page-tab { transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
}
.range-step { display: flex; align-items: center; gap: 0.25rem; }
.range-step button { min-width: 2rem; padding: 0.25rem 0.5rem; }
.range-step button:disabled { opacity: 0.4; cursor: default; }
.range-label { min-width: 6.5rem; text-align: center; font-size: 0.9rem; }
button.range-label { background: none; border: 1px solid transparent; border-radius: 8px; padding: 0.25rem 0.5rem; color: inherit; cursor: pointer; }
button.range-label:hover, button.range-label[aria-expanded="true"] { background: var(--surface); border-color: var(--border); }
.range-pop-wrap { position: relative; }
.range-pop { position: absolute; left: 0; top: calc(100% + 0.4rem); z-index: 20; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-pop); border: 1px solid var(--grid); padding: 0.5rem; width: 16.5rem; }
.range-pop-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.range-pop-nav button { min-width: 2rem; padding: 0.2rem 0.5rem; }
.range-pop-nav button:disabled { opacity: 0.4; cursor: default; }
.range-pop-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.range-pop-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.range-pop-dow { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 0.2rem 0; }
.range-pop-cell { padding: 0.35rem 0; font-size: 0.85rem; background: none; border: 1px solid transparent; border-radius: 6px; color: inherit; cursor: pointer; font-variant-numeric: tabular-nums; }
.range-pop-cell:hover:not(:disabled) { background: var(--grid); }
.range-pop-cell:disabled { opacity: 0.35; cursor: default; }
.range-pop-cell.other-month { color: var(--muted); }
.range-pop-cell.chosen, .range-pop-cell[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* ------------------------------------------------------------ docs page
   The documentation reader (/analytics/docs): a side column with the doc list
   and the page's outline, and the Markdown rendered as a quiet article. */
main.docs-main { max-width: 74rem; }
.docs-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2rem; align-items: start; }
.docs-side { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; font-size: 0.9rem; }
.docs-side ul { list-style: none; margin: 0; padding: 0; }
.docs-list a, .docs-toc a { display: block; padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; }
.docs-list a:hover, .docs-toc a:hover { background: var(--neutral-soft); color: var(--text); }
.docs-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.docs-toc { margin-top: 1.25rem; }
.docs-toc h2 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; margin: 0 0 0.35rem 0.6rem; }
.docs-toc a { padding: 0.2rem 0.6rem; font-size: 0.85rem; }
.docs-toc .l3 a { padding-left: 1.4rem; }
.docs-tools { display: flex; flex-direction: column; gap: 0.35rem; margin: 1.25rem 0 0 0.6rem; font-size: 0.85rem; }
.docs-tools a { color: var(--muted); }
.docs-tools a:hover { color: var(--accent-strong); }

.md { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 2rem 2rem; min-width: 0; line-height: 1.6; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 1rem; }
.md h2 { font-size: 1.25rem; margin: 2.2rem 0 0.7rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--grid); }
.md h3 { font-size: 1.05rem; margin: 1.6rem 0 0.5rem; }
.md h4 { font-size: 0.95rem; margin: 1.3rem 0 0.4rem; }
.md h2, .md h3, .md h4 { scroll-margin-top: 1rem; }
.md .doc-figure { margin: 1rem 0 1.4rem; overflow-x: auto; } /* a phone scrolls the figure sideways instead of shrinking its text */
.md .doc-figure img { display: block; width: 100%; min-width: 40rem; max-width: 54rem; height: auto; }
.md .anchor { margin-left: 0.4rem; color: var(--faint); text-decoration: none; font-weight: 400; opacity: 0; }
.md :is(h2, h3, h4):hover .anchor, .md .anchor:focus-visible { opacity: 1; }
.md p, .md ul, .md ol, .md blockquote, .md .code, .md .table-wrap { margin: 0 0 1rem; }
.md ul, .md ol { padding-left: 1.5rem; }
.md li { margin: 0.25rem 0; }
.md li > :is(p, ul, ol, .code) { margin: 0.4rem 0; }
.md li.task { list-style: none; margin-left: -1.25rem; }
.md li.task input { margin: 0 0.5rem 0 0; vertical-align: -1px; }
.md a { color: var(--accent-strong); }
.md code { font-family: var(--mono); font-size: 0.86em; background: var(--neutral-soft); padding: 0.1em 0.35em; border-radius: 4px; }
.md blockquote { border-left: 3px solid var(--accent); background: var(--surface-2); padding: 0.6rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); }
.md blockquote > :last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--grid); margin: 1.5rem 0; }
.md .code { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.md .code-head { display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 0.4rem 0.25rem 0.75rem; border-bottom: 1px solid var(--grid); font-size: 0.75rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.md .code pre { margin: 0; padding: 0.75rem 1rem; overflow-x: auto; tab-size: 4; line-height: 1.5; }
.md .code pre code { background: none; padding: 0; font-size: 0.84rem; white-space: pre; }
.md .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.md table { font-size: 0.88rem; line-height: 1.45; }
.md th { text-align: left; background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md th, .md td { padding: 0.45rem 0.7rem; vertical-align: top; border-bottom: 1px solid var(--row-line); }
.md tr:last-child td { border-bottom: 0; }
.md .a-right { text-align: right; }
.md .a-center { text-align: center; }
button.copy { font-size: 0.75rem; padding: 0.15rem 0.55rem; text-transform: none; letter-spacing: 0; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
button.copy:hover { color: var(--text); background: var(--neutral-soft); }
button.copy.wide { align-self: flex-start; font-size: 0.85rem; padding: 0.25rem 0.7rem; }

@media (max-width: 52rem) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .docs-side { position: static; max-height: none; }
  .docs-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .docs-list a[aria-current="page"] { box-shadow: none; border-radius: var(--radius-sm); } /* wrapped pills: no side bar */
  .docs-toc { display: none; }
  .md { padding: 1rem 1.1rem 1.4rem; }
}
.cc-error.notice { color: var(--notice-text); background: var(--notice-bg); padding: 0.35rem 0.5rem; border-radius: var(--radius-sm); }
.cc-error.notice::before { content: "\24D8\00a0"; color: var(--warn); }

/* Admin site page: a summary band, a section nav and one section at a time. */
.site-chips { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-block; font-size: 0.8rem; padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--neutral-soft); color: var(--text); text-decoration: none; }
a.chip:hover { background: var(--accent-soft); }
.chip.warn { background: var(--bar-slow); color: var(--warn); font-weight: 500; }
.site-layout { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.site-layout.no-nav { grid-template-columns: minmax(0, 1fr); }
.site-nav { display: flex; flex-direction: column; gap: 0.15rem; position: sticky; top: 1rem; }
.site-nav a { padding: 0.4rem 0.7rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.nav-count { display: inline-block; min-width: 1.15rem; margin-left: 0.4rem; padding: 0 0.35rem; border-radius: 999px; background: var(--bad); color: #fff; font-size: 0.72rem; font-weight: 600; line-height: 1.15rem; text-align: center; vertical-align: 0.08em; }
.site-nav a:has(.nav-count) { display: flex; align-items: center; justify-content: space-between; }
.facts { display: grid; grid-template-columns: minmax(8rem, 11rem) minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0 0 0.75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.site-nav-label { margin: 0.9rem 0 0.2rem; padding: 0 0.7rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; }
.more-layout { max-width: 1200px; margin: 0 auto; padding: 1rem 1rem 0; }
.more-layout.no-side { grid-template-columns: minmax(0, 1fr); }
.more-layout.no-side > .more-nav { display: none; }
.more-layout > main { max-width: none; margin: 0; padding: 0; }
.site-nav a:hover { background: var(--neutral-soft); }
.site-nav a[aria-current="page"] { background: var(--selected); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; } /* square on the bar's side, or the inset shadow follows the corner curve */
.privacy-urls { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line, var(--border, #ddd)); }
.privacy-urls h3 { font-size: 0.95rem; margin: 0; overflow-wrap: anywhere; }
.privacy-urls h3:focus { outline: none; }
.privacy-urls td.key { white-space: normal; overflow-wrap: anywhere; }
#privacy-filter { margin: 0.5rem 0 0.75rem; }
.kind-row th { text-align: left; padding-top: 1rem; border-bottom: 0; white-space: normal; max-width: 0; font-size: 0.9rem; color: var(--text); }
.kind-row .hint { margin: 0.15rem 0 0; font-weight: 400; }
#privacy-table tr.past td { opacity: 0.65; }
@media (max-width: 720px) {
  .site-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .site-nav { flex-direction: row; overflow-x: auto; position: static; box-shadow: inset 0 -1px 0 var(--border); }
  .site-nav { scrollbar-width: none; }
  .site-nav-label { display: none; }
  .site-nav a { white-space: nowrap; }
  .more-layout { padding: 0.75rem 0.75rem 0; }
  .site-nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  #privacy-table .col-urls { display: none; }
  #privacy-table th, #privacy-table td { padding-left: 0.3rem; padding-right: 0.3rem; }
  #privacy-table td.key { min-width: 6rem; }
}

/* Overview: client and privacy notices above the report. */
.banner.notices { border-color: var(--warn); background: var(--notice-bg); color: var(--notice-text); }
.banner.notices .notice-line { margin: 0.2rem 0; }
.banner.notices a { color: inherit; font-weight: 600; white-space: nowrap; }
.flat #url-groups section + section { margin-top: 1rem; }
#url-groups h3 { font-size: 0.9rem; margin: 0 0 0.35rem; }

/* Passkeys: login button and profile list */
.passkey-box { margin-bottom: 1rem; }
.passkey-box .hint { margin: 0.5rem 0 0; text-align: center; }
.passkey-or { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0 0; color: var(--muted, inherit); font-size: 0.85rem; }
.passkey-or::before, .passkey-or::after { content: ""; flex: 1; border-top: 1px solid currentColor; opacity: 0.25; }
.passkey-list { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.passkey-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; padding: 0.5rem 0; border-top: 1px solid currentColor; border-top-color: color-mix(in srgb, currentColor 15%, transparent); }
.passkey-name { font-weight: 600; }
.passkey-meta { flex: 1 1 12rem; font-size: 0.85rem; }
.passkey-actions { display: flex; gap: 0.5rem; }
.passkey-rename { flex: 1; margin-bottom: 0; }
#passkey-form h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }

/* Settings: what the client sent about the site */
.sent-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; align-items: center; }
.sent-list dt { color: var(--muted, inherit); }
.sent-list dd { margin: 0; }
.sent-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; border: 1px solid rgba(128, 128, 128, 0.5); }
.sent-icon { border-radius: 6px; vertical-align: middle; }

/* Admin › Background: one card per periodic task, grouped by node. */
.bg-node { margin-bottom: 1rem; }
.bg-node.stale { opacity: 0.6; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.6rem; }
.bg-card { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem; background: var(--surface-2); min-width: 0; }
.bg-card.running { border-color: var(--ok); }
.bg-card.behind { border-color: var(--warn-dot); background: var(--bar-slow); }
.bg-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.bg-card-head h3 { font-size: 0.9rem; margin: 0; overflow-wrap: anywhere; }
.bg-line { margin: 0 0 0.35rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bg-sub { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bg-sub.warn { color: var(--warn); }
.bg-bar { height: 0.5rem; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; position: relative; }
.bg-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bg-card.behind .bg-bar-fill { background: var(--warn-dot); }
.bg-bar.indeterminate .bg-bar-fill { width: 30%; position: absolute; animation: bg-slide 1.4s ease-in-out infinite alternate; }
@keyframes bg-slide { from { left: 0; } to { left: 70%; } }
@media (prefers-reduced-motion: reduce) { .bg-bar.indeterminate .bg-bar-fill { animation: none; width: 100%; opacity: 0.4; } }
#bg-log td.bad { color: var(--bad); }
#bg-log td.warn { color: var(--warn); }

/* ------------------------------------------------------------ locations map */
.worldmap { position: relative; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.worldmap svg { display: block; width: 100%; height: auto; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.worldmap svg.dragging { cursor: grabbing; }
.worldmap .geo { fill: var(--grid); stroke: var(--surface); stroke-width: 0.6; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill-opacity 0.15s; }
.worldmap .geo.l1, .worldmap .geo.l2, .worldmap .geo.l3, .worldmap .geo.l4, .worldmap .geo.l5 { fill: var(--series); }
.worldmap.err .geo.l1, .worldmap.err .geo.l2, .worldmap.err .geo.l3, .worldmap.err .geo.l4, .worldmap.err .geo.l5 { fill: var(--series-err); }
.worldmap .geo.l1 { fill-opacity: 0.22; }
.worldmap .geo.l2 { fill-opacity: 0.42; }
.worldmap .geo.l3 { fill-opacity: 0.6; }
.worldmap .geo.l4 { fill-opacity: 0.8; }
.worldmap .geo.l5 { fill-opacity: 1; }
.worldmap .geo:hover { stroke: var(--text); stroke-width: 1.2; }
.worldmap .geo.sel { stroke: var(--text); stroke-width: 2; }
.worldmap g[hidden] { display: none; }
/* A city is a round dot of one size (a zero-length line with round caps and a width in screen pixels); only the colour says how active. */
.worldmap .city { fill: none; stroke: var(--series-city); stroke-width: 6px; stroke-linecap: round; vector-effect: non-scaling-stroke; cursor: pointer; }
.worldmap .city.l1 { stroke-opacity: 0.4; }
.worldmap .city.l2 { stroke-opacity: 0.55; }
.worldmap .city.l3 { stroke-opacity: 0.7; }
.worldmap .city.l4 { stroke-opacity: 0.85; }
.worldmap .city.l5 { stroke-opacity: 1; }
/* Both layers: the countries become a soft background, the cities an orange of their own on top. */
.worldmap.both .geo.l1 { fill-opacity: 0.1; }
.worldmap.both .geo.l2 { fill-opacity: 0.18; }
.worldmap.both .geo.l3 { fill-opacity: 0.27; }
.worldmap.both .geo.l4 { fill-opacity: 0.36; }
.worldmap.both .geo.l5 { fill-opacity: 0.46; }
.worldmap.both .city { stroke: var(--series-city); stroke-opacity: 1; filter: drop-shadow(0 0 1.5px var(--surface)); }
.worldmap.both .city.l1 { stroke-opacity: 0.6; }
.worldmap.both .city.l2 { stroke-opacity: 0.72; }
.worldmap.both .city.l3 { stroke-opacity: 0.84; }
.worldmap.both .city.l4, .worldmap.both .city.l5 { stroke-opacity: 1; }
.worldmap .city:hover { stroke-width: 9px; }
.worldmap .city.sel { stroke-width: 9px; stroke: var(--text); }
.worldmap .tooltip { transform: translate(-50%, -100%); }
.worldmap svg[hidden] { display: none; }
.worldmap svg.globe { max-width: 30rem; margin: 0 auto; touch-action: none; overflow: visible; } /* zoomed in, the globe fills the frame, not just its square */
.worldmap svg.globe:focus-visible { outline-offset: -2px; }
.worldmap .ocean { fill: var(--surface); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  /* An update of the numbers: the country's outline lights up and settles; the table row fades in. */
  .worldmap .geo.pulse { animation: geo-pulse 3.2s ease-out; }
  .worldmap .city.pulse { animation: city-pulse 3.2s ease-out; }
  #country-table tr.pulse td { animation: row-pulse 3.2s ease-out; }
}
@keyframes geo-pulse { from { stroke: var(--accent); stroke-width: 2.4; filter: drop-shadow(0 0 4px var(--accent)); } }
@keyframes city-pulse { from { stroke: var(--accent); stroke-width: 12px; stroke-opacity: 1; filter: drop-shadow(0 0 4px var(--accent)); } }
@keyframes row-pulse { from { background-color: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); } }
.map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.map-zoom { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.map-zoom button { width: 1.9rem; height: 1.9rem; padding: 0; line-height: 1; font-size: 1.1rem; }
.map-legend { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; margin: 0.4rem 0 0; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-legend .sws { display: inline-flex; border-radius: 3px; overflow: hidden; }
.map-legend .sw { width: 1.6rem; height: 0.55rem; background: var(--series); }
.map-legend.err .sw { background: var(--series-err); }
.map-legend .sw.l1 { opacity: 0.22; }
.map-legend .sw.l2 { opacity: 0.42; }
.map-legend .sw.l3 { opacity: 0.6; }
.map-legend .sw.l4 { opacity: 0.8; }
.map-legend .lg-name { margin-right: 0.15rem; }
.map-legend.city { margin-top: 0.1rem; }
.map-legend.city .sw { background: var(--series-city); }
.map-detail { margin: 0.6rem 0 0; padding: 0.45rem 0.7rem; background: var(--accent-soft); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
#map-note { margin: 0.4rem 0 1rem; }
#map-note:empty { display: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.cc-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.cc-btn:hover { color: var(--accent); }
#country-table tr:has(.cc-btn.sel) td { background: var(--accent-soft); }

/* "Export CSV" under a report table */
.table-tools { display: flex; justify-content: flex-end; margin: -0.5rem 0 1rem; }
.card .table-tools:last-child { margin-bottom: 0; }
.install-keys { list-style: none; padding: 0; margin: 0.4rem 0; }
/* Allowed origins: a list of chips, then one input with an Add button. */
.origin-list { list-style: none; padding: 0; margin: 0.4rem 0 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; max-width: 40rem; }
.origin-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.25rem 0.25rem 0.25rem 0.6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.origin-actions { display: flex; gap: 0.35rem; flex: none; }
.origin-list code { font-family: var(--mono); overflow-wrap: anywhere; }
.origin-add { display: flex; gap: 0.5rem; max-width: 40rem; margin: 0.4rem 0 0.4rem; }
.origin-add input { flex: 1 1 auto; min-width: 0; font-family: var(--mono); }
#install-controls > .origin-label { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.75rem; }
.origin-label label { font-weight: 600; }
.help { position: relative; display: inline-block; }
.help-btn { width: 1.3rem; height: 1.3rem; padding: 0; border-radius: 50%; font-size: 0.8rem; line-height: 1; font-weight: 700; color: var(--muted); }
.help-pop { visibility: hidden; opacity: 0; transition: opacity 0.12s 0.3s, visibility 0s 0.42s; position: absolute; z-index: 20; left: 0; top: calc(100% + 0.3rem); width: min(24rem, 80vw); padding: 0.6rem 0.75rem; font-size: 0.85rem; font-weight: 400; line-height: 1.4; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15); }
/* An invisible bridge over the gap between the "?" and the popover, and a short delay before it hides, so the pointer can travel onto the link. */
.help-pop::before { content: ''; position: absolute; left: 0; right: 0; top: -0.5rem; height: 0.5rem; }
.help:hover .help-pop, .help:focus-within .help-pop, .help.open .help-pop { visibility: visible; opacity: 1; transition-delay: 0s; }

/* Clients page: the "is the site receiving data" banner and the Connect block. */
.connect-status { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; margin-top: 0; }
.connect-status::before { content: ''; flex: none; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: currentColor; }
.connect-status.receiving { border-color: var(--ok); color: var(--ok); }
.connect-status.stalled { border-color: var(--bad); color: var(--bad); }
.connect-status.waiting { background: var(--notice-bg); color: var(--notice-text); border-color: transparent; }
.connect-block { margin: 0 0 1rem; }
.connect-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.4rem; }
.connect-details > summary { cursor: pointer; font-weight: 600; padding: 0.5rem 0; }
.connect-details[open] > summary { margin-bottom: 0.5rem; }

.install-section { margin: 0 0 1rem; }
/* The two installation sections look alike: a rule above each (the flat theme unboxes cards). */
#install-script, #client-library { border-top: 1px solid var(--border); padding-top: 1rem; margin-bottom: 1.25rem; }
