:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e5ea;
  --text: #1c1f26;
  --muted: #596170;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --bar: #eef0ff;
  --danger: #b42318;
  --good: #067647;
  --radius: 8px;
  --gap: 1rem;
  --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: #111318;
    --surface: #1a1d24;
    --border: #2a2e38;
    --text: #e6e8ee;
    --muted: #9aa1ae;
    --accent: #8b8cf8;
    --accent-soft: #2a2b55;
    --bar: #23264a;
    --danger: #f97066;
    --good: #47cd89;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1 { font-size: 1.25rem; margin: 0 0 .5rem; }

.mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: .75rem max(1rem, calc((100% - 1100px) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-weight: 600; color: var(--text); }

.container {
  flex: 1;
  width: 100%;
  max-width: 1150px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.logout { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

button {
  font: inherit;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  padding: .55rem 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.link { background: none; color: var(--accent); padding: 0; }
button.link:hover { text-decoration: underline; filter: none; }

input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: .5rem .65rem;
  width: 100%;
}
input:focus-visible { outline-offset: 0; border-color: var(--accent); }

.login { max-width: 22rem; margin: 3rem auto; }
.login form { display: grid; gap: .5rem; }
.login label { font-size: .875rem; color: var(--muted); margin-top: .5rem; }
.login button { margin-top: 1rem; }
.error { color: var(--danger); margin: 0 0 .5rem; }

/* dashboard */
.dash-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1rem; }
.dash-head .site { font-size: 1.15rem; margin: 0; margin-right: auto; }
.period { display: flex; align-items: center; gap: .25rem; }
.arrow { padding: .3rem .55rem; border-radius: var(--radius); color: var(--text); font-size: 1.1rem; line-height: 1; }
.arrow:hover { background: var(--surface); text-decoration: none; }
.picker { position: relative; }
.picker summary { list-style: none; cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .4rem .8rem; font-weight: 500; min-width: 10rem; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary::after { content: " ▾"; color: var(--muted); }
.picker-menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .12);
  padding: .4rem; min-width: 15rem; }
.picker-menu nav { display: grid; }
.picker-menu nav a { color: var(--text); padding: .35rem .6rem; border-radius: calc(var(--radius) - 2px); }
.picker-menu nav a:hover { background: var(--bg); text-decoration: none; }
.picker-menu nav a[aria-current] { background: var(--accent-soft); font-weight: 600; }
.custom { display: grid; gap: .4rem; border-top: 1px solid var(--border); margin-top: .4rem; padding: .6rem .3rem .2rem; }
.custom label { display: grid; gap: .15rem; font-size: .8rem; color: var(--muted); }
.segmented { display: flex; gap: .15rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .15rem; }
.segmented a { color: var(--muted); padding: .25rem .55rem; border-radius: calc(var(--radius) - 3px); font-size: .85rem;
  white-space: nowrap; }
.segmented a[aria-current] { background: var(--accent-soft); color: var(--text); }
.segmented a:hover { text-decoration: none; color: var(--text); }
.live-count { color: var(--text); font-size: .9rem; white-space: nowrap; }
.live-count:hover { text-decoration: none; color: var(--accent); }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); margin-right: .2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: -.25rem 0 1rem; padding: 0; }
.chip { display: flex; align-items: center; gap: .35rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .25rem .4rem .25rem .8rem; font-size: .85rem; }
.chip a { color: var(--muted); border-radius: 50%; width: 1.3rem; height: 1.3rem; display: inline-grid;
  place-items: center; font-size: .75rem; }
.chip a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.chips .clear { font-size: .85rem; line-height: 2rem; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: .6rem .9rem; margin: 0 0 1rem;
  font-size: .85rem; }

.card.overview { padding: 0; overflow: hidden; margin-bottom: 1rem; }
.loading { color: var(--muted); padding: 1.25rem; margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.metric { display: grid; gap: .1rem; padding: .9rem 1.1rem; color: var(--text); border-right: 1px solid var(--border);
  border-bottom: 3px solid transparent; }
.metric:last-child { border-right: 0; }
.metric:hover { text-decoration: none; background: var(--bg); }
.metric.active { border-bottom-color: var(--accent); }
.metric-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.metric-value { font-size: 1.35rem; font-weight: 650; }
.muted-tile .metric-value, .muted-tile .metric-label { color: var(--muted); }
.muted-tile:hover { background: none; }
.change { font-size: .78rem; font-weight: 500; }
.change.good { color: var(--good); }
.change.bad { color: var(--danger); }
.change.flat { color: var(--muted); }
.chart-wrap { padding: .75rem 1rem 0; }
.compared { font-size: .75rem; margin: 0; padding: 0 1rem .75rem; }

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axis.y { opacity: .8; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.dashed { stroke-dasharray: 5 5; }
.chart .line.secondary { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 3; }
.chart.bars .col rect.bar, .chart.bars .col:hover rect.bar { fill: var(--accent); opacity: .85; }
.chart.bars .col rect.bg { fill: transparent; }
.chart.bars .col:hover rect.bg { fill: var(--accent); opacity: .06; }
.chart .axis.secondary { fill: var(--muted); opacity: .8; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .dot { fill: var(--accent); }
.chart .col rect { fill: transparent; }
.chart .col circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; opacity: 0; }
.chart .col:hover rect { fill: var(--accent); opacity: .06; }
.chart .col:hover circle { opacity: 1; }

.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel { padding: 1rem 1.1rem; min-height: 22rem; display: flex; flex-direction: column; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.panel-head h2 { font-size: 1rem; margin: 0; }
.tabs { display: flex; gap: .75rem; font-size: .85rem; }
.tabs a { color: var(--muted); padding-bottom: .15rem; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.rows { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-size: .9rem; table-layout: fixed; }
.rows th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 600; padding: 0 .5rem .25rem; }
.rows td { padding: 0; }
.rows .num { text-align: right; width: 5.5rem; padding-right: .5rem; font-weight: 500; }
.rows .label { position: relative; height: 2rem; }
.rows .bar { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 4px; }
.rows .text { position: relative; display: block; padding: 0 .5rem; line-height: 2rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: var(--text); }
a.text:hover { text-decoration: underline; text-decoration-color: var(--muted); }
.live-head { padding: 1rem 1.1rem 0; margin-bottom: 1rem; }
.live-now { margin: 0 0 .75rem; font-size: 1.05rem; }
.sub { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.live-panels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.live-visitors { padding: 1rem 1.1rem; margin-bottom: 1rem; }
.table-scroll { overflow-x: auto; }
.visitors { width: 100%; border-collapse: collapse; font-size: .88rem; }
.visitors th, .visitors td { text-align: left; padding: .45rem .45rem; border-top: 1px solid var(--border); white-space: nowrap; }
.visitors thead th { border-top: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.visitors tbody th { font-weight: 500; }
.visitor-name { font-family: var(--mono); font-size: .85em; color: var(--accent); }
.visitors .num { text-align: right; }
.visitors .path { max-width: 15rem; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.live-panels .panel { min-height: 14rem; }
.icon { width: 1em; height: 1em; fill: currentColor; color: var(--muted); vertical-align: -.125em;
  margin-right: .45rem; flex: none; }
.mono-icon { display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; margin-right: .4rem;
  border-radius: 50%; background: var(--muted); color: var(--surface); font-size: .7em; font-weight: 700;
  vertical-align: .05em; line-height: 1; }
.flag { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.empty { margin: auto; }
.note { font-size: .78rem; margin: .5rem 0 0; }
.details-link { margin-top: auto; align-self: center; font-size: .85rem; padding-top: .6rem; }

#modal:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 5vh 1rem; }
.modal { width: min(46rem, 100%); max-height: 90vh; display: flex; flex-direction: column; padding: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1rem; margin: 0; }
.modal .close { color: var(--muted); font-size: 1.1rem; padding: .2rem .45rem; border-radius: 6px; }
.modal .close:hover { background: var(--bg); text-decoration: none; }
.modal-body { overflow: auto; padding: .75rem 1.1rem 1rem; }
.standalone .modal-backdrop { position: static; background: none; padding: 0; display: block; }
.standalone .modal { max-height: none; width: 100%; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 0; }
  .metric { border-bottom: 1px solid var(--border); }
  .metric:nth-child(4n) { border-right: 0; }
  .metric.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .live-panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .metric.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .chart .axis { font-size: 16px; }
}
@media (max-width: 720px) {
  .visitors thead { display: none; }
  .visitors tr { display: block; padding: .6rem 0; border-top: 1px solid var(--border); }
  .visitors tbody tr:first-child { border-top: 0; }
  .visitors th, .visitors td { display: inline; border: 0; padding: 0 .5rem 0 0; white-space: normal; }
  .visitors td.path { display: block; max-width: none; margin: .1rem 0 .2rem; }
  .visitors td.num::after { content: " pages"; }
  .visitors td.since::before { content: "since "; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .panel { min-height: 0; }
  .dash-head .site { width: 100%; }
}
@media (max-width: 480px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-right: 1px solid var(--border); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric-value { font-size: 1.2rem; }
  .chart .axis { font-size: 20px; }
  .container { padding: 1rem .75rem; }
}

.w0 { width: 0%; }
.w1 { width: 1%; }
.w2 { width: 2%; }
.w3 { width: 3%; }
.w4 { width: 4%; }
.w5 { width: 5%; }
.w6 { width: 6%; }
.w7 { width: 7%; }
.w8 { width: 8%; }
.w9 { width: 9%; }
.w10 { width: 10%; }
.w11 { width: 11%; }
.w12 { width: 12%; }
.w13 { width: 13%; }
.w14 { width: 14%; }
.w15 { width: 15%; }
.w16 { width: 16%; }
.w17 { width: 17%; }
.w18 { width: 18%; }
.w19 { width: 19%; }
.w20 { width: 20%; }
.w21 { width: 21%; }
.w22 { width: 22%; }
.w23 { width: 23%; }
.w24 { width: 24%; }
.w25 { width: 25%; }
.w26 { width: 26%; }
.w27 { width: 27%; }
.w28 { width: 28%; }
.w29 { width: 29%; }
.w30 { width: 30%; }
.w31 { width: 31%; }
.w32 { width: 32%; }
.w33 { width: 33%; }
.w34 { width: 34%; }
.w35 { width: 35%; }
.w36 { width: 36%; }
.w37 { width: 37%; }
.w38 { width: 38%; }
.w39 { width: 39%; }
.w40 { width: 40%; }
.w41 { width: 41%; }
.w42 { width: 42%; }
.w43 { width: 43%; }
.w44 { width: 44%; }
.w45 { width: 45%; }
.w46 { width: 46%; }
.w47 { width: 47%; }
.w48 { width: 48%; }
.w49 { width: 49%; }
.w50 { width: 50%; }
.w51 { width: 51%; }
.w52 { width: 52%; }
.w53 { width: 53%; }
.w54 { width: 54%; }
.w55 { width: 55%; }
.w56 { width: 56%; }
.w57 { width: 57%; }
.w58 { width: 58%; }
.w59 { width: 59%; }
.w60 { width: 60%; }
.w61 { width: 61%; }
.w62 { width: 62%; }
.w63 { width: 63%; }
.w64 { width: 64%; }
.w65 { width: 65%; }
.w66 { width: 66%; }
.w67 { width: 67%; }
.w68 { width: 68%; }
.w69 { width: 69%; }
.w70 { width: 70%; }
.w71 { width: 71%; }
.w72 { width: 72%; }
.w73 { width: 73%; }
.w74 { width: 74%; }
.w75 { width: 75%; }
.w76 { width: 76%; }
.w77 { width: 77%; }
.w78 { width: 78%; }
.w79 { width: 79%; }
.w80 { width: 80%; }
.w81 { width: 81%; }
.w82 { width: 82%; }
.w83 { width: 83%; }
.w84 { width: 84%; }
.w85 { width: 85%; }
.w86 { width: 86%; }
.w87 { width: 87%; }
.w88 { width: 88%; }
.w89 { width: 89%; }
.w90 { width: 90%; }
.w91 { width: 91%; }
.w92 { width: 92%; }
.w93 { width: 93%; }
.w94 { width: 94%; }
.w95 { width: 95%; }
.w96 { width: 96%; }
.w97 { width: 97%; }
.w98 { width: 98%; }
.w99 { width: 99%; }
.w100 { width: 100%; }

.sr-only { position: absolute; 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: .75rem; top: -3rem; z-index: 100; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .8rem; }
.skip:focus { top: .75rem; }
main:focus { outline: none; }
a.text:focus-visible, .tabs a:focus-visible, .metric:focus-visible { outline-offset: -2px; }
.error { color: var(--danger); margin: 1rem 0; }
.error-page { max-width: 32rem; margin: 3rem auto; }
.setup { padding: 1rem 1.2rem; margin-bottom: 1rem; }
.setup h2 { font-size: 1rem; margin: 0 0 .5rem; }
.setup ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.setup li.ok span { color: var(--good); }
.setup li.todo span { color: var(--muted); }
.legend { white-space: nowrap; }
.key { display: inline-block; width: 1.2rem; height: 0; vertical-align: middle; margin: 0 .3rem 0 .1rem; }
.key.solid { border-top: 2px solid var(--accent); }
.key.dotted { border-top: 2px dotted var(--muted); }

.footer {
  display: flex;
  justify-content: center;
  gap: .5rem;
  padding: 1rem;
  font-size: .8rem;
  color: var(--muted);
}
.footer a { color: var(--muted); }
