:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #687083;
  --border: #e2e5eb;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --chart-1: #9db9ef;
  --chart-2: #2f6fde;
  --ok: #1e8e4e;
  --warn: #b7791f;
  --bad: #c53030;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a;
    --surface: #1a1e26;
    --text: #e6e9ef;
    --muted: #9099ab;
    --border: #2b313d;
    --accent: #5b8ff0;
    --chart-1: #2c4677;
    --chart-2: #5b8ff0;
    --ok: #48bb78;
    --warn: #ecc94b;
    --bad: #fc8181;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.mainnav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.footer { max-width: 1200px; margin: 0 auto; padding: 1rem; color: var(--muted); font-size: .85rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }

form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.stack { display: grid; gap: .8rem; }
.row-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
input, select, button, .button { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: .45rem .65rem; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button { cursor: pointer; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }

.notice { padding: .6rem .8rem; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); }
.notice.ok { border-color: var(--ok); }
.notice.err { border-color: var(--bad); }

.sitehead { margin-bottom: 1rem; }
.sitetitle { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.sitetitle h1 { margin: 0; }
.live { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .85rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.tabs { display: flex; gap: .25rem; margin: .75rem 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: .45rem .75rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.rangeform { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.custom-range { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.filterbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.chip { padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .85rem; }
.chip i { color: var(--muted); font-style: normal; }
.chip:hover { border-color: var(--bad); text-decoration: none; }
.addfilter summary { cursor: pointer; color: var(--accent); font-size: .9rem; list-style: none; padding: .2rem .4rem; }
.addfilter summary::-webkit-details-marker { display: none; }
.addfilter[open] summary { margin-bottom: .4rem; }
.filterform { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.filterform input { min-width: 10rem; }
table.metric td.label .exclude { position: absolute; right: .3rem; top: .3rem; padding: 0 .35rem; border-radius: 4px; color: var(--muted); background: var(--surface); visibility: hidden; }
table.metric tr:hover td.label .exclude, table.metric td.label .exclude:focus { visibility: visible; }
table.metric td.label .exclude:hover { color: var(--bad); text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cards .card { margin: 0; }
.stat { display: grid; gap: .15rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 650; }
.delta { font-size: .82rem; width: fit-content; padding: 0 .4rem; border-radius: 5px; }
.delta.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.delta.flat { color: var(--muted); }
.vital.good .value { color: var(--ok); }
.vital.needs-improvement .value { color: var(--warn); }
.vital.poor .value { color: var(--bad); }
.rating-good { color: var(--ok); }
.rating-needs-improvement { color: var(--warn); }
.rating-poor { color: var(--bad); }

.chartcard { height: 300px; }
.chartcard canvas { width: 100% !important; }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.panels .card { margin: 0; min-width: 0; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.ptabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ptabs button { border: 0; background: none; color: var(--muted); padding: .2rem .5rem; border-radius: 6px; font-size: .88rem; }
.ptabs button.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: .82rem; padding: .3rem .4rem; border-bottom: 1px solid var(--border); }
td { padding: .35rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.metric td.label { position: relative; max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.metric td.label a { color: var(--text); }
table.metric progress { display: block; width: 100%; height: 4px; margin-top: 3px; appearance: none; border: 0; background: var(--border); border-radius: 2px; }
table.metric progress::-webkit-progress-bar { background: var(--border); border-radius: 2px; }
table.metric progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
table.metric progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }
tr.selected td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.empty { padding: 1rem 0; text-align: center; }
.scroll { overflow-x: auto; }

.badge { font-size: .75rem; padding: .05rem .45rem; border-radius: 5px; border: 1px solid var(--border); white-space: nowrap; }
.badge.view { color: var(--accent); }
.badge.event { color: var(--ok); }
.badge.warn { color: var(--warn); }
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.toplist li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sitegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.sitecard { display: grid; gap: .4rem; color: var(--text); margin: 0; }
.sitecard:hover { border-color: var(--accent); text-decoration: none; }
.sitecard h2 { margin: 0; }
.mini { display: flex; gap: 1.5rem; margin: .3rem 0; }
.mini dt { color: var(--muted); font-size: .8rem; }
.mini dd { margin: 0; font-size: 1.3rem; font-weight: 650; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.timeline li.visit-start { border-bottom: 2px solid var(--accent); }
.propkey { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: .7rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; cursor: copy; }
pre.code.copied { border-color: var(--ok); }

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .panels, .twocol { grid-template-columns: 1fr; }
  .chartcard { height: 220px; }
}

.qr svg { width: 220px; height: 220px; display: block; margin: .5rem 0; background: #fff; padding: 8px; border-radius: 8px; }
pre.code.recovery { font-size: 1.05rem; letter-spacing: .05em; }
details > summary { cursor: pointer; color: var(--accent); }

.subtabs { display: flex; gap: .4rem; margin: -.25rem 0 1rem; flex-wrap: wrap; }
.subtabs a { padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface); font-size: .9rem; }
.subtabs a.active { color: var(--text); border-color: var(--accent); }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pill { padding: .2rem .6rem; border-radius: 6px; color: var(--muted); font-size: .88rem; }
.pill.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.pill:hover { text-decoration: none; color: var(--text); }
.ratecell { min-width: 9rem; }
.ratecell .rate { font-weight: 650; margin-right: .4rem; }
.ratecell progress { display: block; width: 100%; height: 4px; margin-top: 4px; }
.journeys { list-style: none; margin: 0; padding: 0; }
.journeys li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.journeys li:last-child { border-bottom: 0; }
.journeys .path { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.journeys .step { padding: .1rem .5rem; border-radius: 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: .88rem; word-break: break-all; }
.journeys .step.event { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.journeys .arrow { color: var(--muted); }
.journeys .pathstats { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.journeys progress { display: block; width: 100%; height: 4px; }
table.retention td.heat { color: var(--text); }
.heat-0 { background: color-mix(in srgb, var(--accent) 0%, transparent); }
.heat-1 { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.heat-2 { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.heat-3 { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.heat-4 { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.heat-5 { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.heat-6 { background: color-mix(in srgb, var(--accent) 48%, transparent); }
.heat-7 { background: color-mix(in srgb, var(--accent) 56%, transparent); }
.heat-8 { background: color-mix(in srgb, var(--accent) 64%, transparent); }
.heat-9 { background: color-mix(in srgb, var(--accent) 72%, transparent); }
.heat-10 { background: color-mix(in srgb, var(--accent) 80%, transparent); color: var(--accent-text) !important; }
progress { accent-color: var(--accent); }
pre.code.stack { cursor: auto; white-space: pre; font-size: .85rem; }
.funnel { list-style: none; margin: 0; padding: 0; }
.funnel li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.funnel li:last-child { border-bottom: 0; }
.funnel-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .3rem; }
.funnel .step { padding: .1rem .5rem; border-radius: 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: .9rem; word-break: break-all; }
.funnel .step.event { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.funnel progress { display: block; width: 100%; height: 8px; }
.funnel .pathstats { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.stack-form .row-form { margin-bottom: .5rem; }
.badge.alert { color: var(--accent-text); background: var(--bad); border-color: var(--bad); font-weight: 650; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.alerts li:last-child { border-bottom: 0; }
.card.alerting { border-color: var(--bad); }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); column-gap: 1rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: auto; }
