:root {
  color-scheme: light dark;
  --ink: #16131f;
  --secondary: #6e6b7d;
  --canvas: #f9f8fc;
  --raised: #fdfcff;
  --surface: #ffffff;
  --hover: #f6f4fd;
  --line: #dcdbe2;
  --violet: #6d28ff;
  --violet-soft: #eee7ff;
  --violet-tint-ink: #52338a;
  --magenta: #b31366;
  --magenta-soft: #fff0f7;
  --magenta-tint-ink: #713756;
  --cyan: #006b7c;
  --cyan-soft: #e3f7fa;
  --cyan-tint-ink: #315c63;
  --success: #0c7332;
  --success-soft: #e8f7ed;
  --danger: #b7192e;
  --danger-soft: #fff0f1;
  --danger-tint-ink: #7d303c;
  --warning: #915000;
  --warning-soft: #fff1d9;
  --warning-tint-ink: #70491b;
  --primary-action: #16131f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background: var(--canvas);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1edfa;
    --secondary: #b0abbf;
    --canvas: #0c0a12;
    --raised: #120f19;
    --surface: #17141f;
    --hover: #251f30;
    --line: #34323c;
    --violet: #bba0ff;
    --violet-soft: #2b1d44;
    --violet-tint-ink: #c9b5ef;
    --magenta: #ff7aba;
    --magenta-soft: #3b1a2d;
    --magenta-tint-ink: #f5b4d2;
    --cyan: #47d6ea;
    --cyan-soft: #143037;
    --cyan-tint-ink: #addce3;
    --success: #70dc90;
    --success-soft: #143021;
    --danger: #ff7a84;
    --danger-soft: #3b191f;
    --danger-tint-ink: #ffafb5;
    --warning: #ffc063;
    --warning-soft: #3b2914;
    --warning-tint-ink: #f0cf9d;
    --primary-action: #4f24ad;
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; scrollbar-color: var(--secondary) var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
::selection { color: var(--ink); background: color-mix(in srgb, var(--violet) 22%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--violet) 60%, transparent); outline-offset: 3px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(20px, 4vw, 56px);
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 720; letter-spacing: -.025em; }
.brand img { display: block; width: 27px; height: 27px; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.range-control { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 12px; }
.range-control span { font-size: 12px; font-weight: 650; }
select, input {
  min-height: 38px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
select { min-width: 108px; }
input { width: min(390px, 100%); font-size: 13px; }
input::selection { color: var(--ink); background: var(--violet-soft); }
.button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: default; opacity: .5; }
.button-quiet { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button-quiet:hover:not(:disabled) { background: var(--hover); border-color: var(--violet); }
.button-primary { color: #fff; background: var(--primary-action); }
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }

.page-shell { width: min(1280px, calc(100% - 48px)); margin: 0 auto; padding: 38px 0 34px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.page-heading h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 720; letter-spacing: -.035em; }
.page-heading p { margin: 8px 0 0; color: var(--secondary); font-size: 13px; }
.connection { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 8px 10px; color: var(--secondary); background: var(--raised); border: 1px solid var(--line); border-radius: 7px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--secondary); }
.connection[data-state="connected"] { color: var(--success); }
.connection[data-state="connected"] .connection-dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 15%, transparent); }
.connection[data-state="error"] { color: var(--danger); }
.connection[data-state="error"] .connection-dot { background: var(--danger); }

.access-panel, .report { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.access-panel { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 1fr); align-items: center; gap: 32px; padding: 22px 24px; margin-bottom: 22px; }
.access-copy h2, .report-heading h2 { margin: 0; font-size: 15px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.access-copy p, .report-heading p { margin: 6px 0 0; color: var(--secondary); font-size: 12px; line-height: 1.5; }
.access-form { display: grid; gap: 7px; }
.access-form label { color: var(--secondary); font-size: 12px; font-weight: 700; }
.access-controls { display: flex; gap: 8px; }
.access-message { min-height: 14px; margin: 0; color: var(--secondary); font-size: 12px; }
.access-message[data-state="error"] { color: var(--danger); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 4px 0 9px; }
.summary-item {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 118px;
  padding: 16px 17px;
  border-radius: 12px;
  background: var(--metric-bg);
  color: var(--metric-ink);
}
.summary-item--requests { --metric-bg: var(--violet-soft); --metric-ink: var(--violet); }
.summary-item--failures { --metric-bg: var(--danger-soft); --metric-ink: var(--danger); }
.summary-item--response { --metric-bg: var(--cyan-soft); --metric-ink: var(--cyan); }
.summary-item--slow { --metric-bg: var(--warning-soft); --metric-ink: var(--warning); }
.summary-label { color: var(--metric-ink); font-size: 12px; font-weight: 680; line-height: 1.3; }
.summary-item strong { color: var(--ink); font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.summary-detail { color: var(--metric-ink); font-size: 12px; line-height: 1.4; }
.latency-coverage { margin: 0 0 15px; color: var(--secondary); font-size: 12px; line-height: 1.5; }

.report { margin-bottom: 16px; }
.report-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 15px 18px 14px; background: var(--section-tint); }
.report-heading h2 { color: var(--section-accent); }
.report-heading p { color: var(--section-muted); }
.report--timing { --section-accent: var(--violet); --section-tint: var(--violet-soft); --section-muted: var(--violet-tint-ink); }
.report--trend { --section-accent: var(--violet); --section-tint: var(--violet-soft); --section-muted: var(--violet-tint-ink); }
.report--models { --section-accent: var(--cyan); --section-tint: var(--cyan-soft); --section-muted: var(--cyan-tint-ink); }
.report--features { --section-accent: var(--magenta); --section-tint: var(--magenta-soft); --section-muted: var(--magenta-tint-ink); }
.report--errors { --section-accent: var(--danger); --section-tint: var(--danger-soft); --section-muted: var(--danger-tint-ink); }
.report--slow { --section-accent: var(--warning); --section-tint: var(--warning-soft); --section-muted: var(--warning-tint-ink); }
.report-body { padding: 15px 18px 17px; }

.timing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.timing-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 20px; padding: 3px 20px 4px 0; }
.timing-item + .timing-item { padding-left: 22px; border-left: 1px solid var(--line); }
.timing-label { color: var(--timing-ink); font-size: 12px; font-weight: 650; }
.timing-item--network { --timing-ink: var(--magenta); }
.timing-item--model { --timing-ink: var(--cyan); }
.timing-item--service { --timing-ink: var(--violet); }
.timing-item strong { color: var(--ink); font-size: 25px; line-height: 1; font-variant-numeric: tabular-nums; }
.timing-detail { grid-column: 1 / -1; color: var(--secondary); font-size: 12px; line-height: 1.4; }
.timing-note { margin: 14px 0 0; color: var(--secondary); font-size: 12px; line-height: 1.45; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 15px; color: var(--secondary); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--violet); }
.legend-swatch.failures { background: var(--magenta); }
.chart-wrap { min-height: 210px; overflow: hidden; }
.chart-wrap svg { display: block; width: 100%; height: 210px; overflow: visible; }
.chart-empty { display: grid; min-height: 190px; margin: 0; place-items: center; color: var(--secondary); font-size: 12px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label { fill: var(--secondary); font: 12px var(--sans); }
.chart-request-line { fill: none; stroke: var(--violet); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-error-line { fill: none; stroke: var(--magenta); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-request-point { fill: var(--surface); stroke: var(--violet); stroke-width: 2; }
.chart-error-point { fill: var(--surface); stroke: var(--magenta); stroke-width: 2; }

.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { padding: 0 14px 9px 0; color: var(--secondary); font-size: 12px; font-weight: 650; white-space: nowrap; }
td { padding: 11px 14px 11px 0; border-top: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
th:last-child, td:last-child { padding-right: 0; text-align: right; }
td.numeric { font-variant-numeric: tabular-nums; }
.latency-cell { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.latency-cell strong { color: var(--ink); font-size: 13px; line-height: 1.2; }
.latency-cell small { color: var(--secondary); font-size: 12px; line-height: 1.3; }
.provider-cell { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.provider-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.provider-mark.anthropic { background: var(--magenta); }
.provider-mark.unknown { background: var(--secondary); }
.count-label { font-weight: 650; font-variant-numeric: tabular-nums; }
.count-label--clear { color: var(--success); }
.count-label--error, .error-report td:first-child { color: var(--danger); font-weight: 650; }
.mobile-context { display: none; }
.error-report td:first-child { min-width: 150px; white-space: normal; }
.error-report td:first-child .mobile-context { color: var(--secondary); font-weight: 400; }
.slow-report td:first-child { white-space: normal; }
.table-empty { margin: 0; padding: 13px 0 2px; color: var(--secondary); font-size: 12px; }
.privacy-note { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 2px; color: var(--secondary); font-size: 12px; line-height: 1.5; }
.text-button { padding: 8px 0; color: var(--secondary); background: none; border: 0; font-size: 12px; font-weight: 700; }
.text-button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.is-loading .button-primary { pointer-events: none; }

@media (max-width: 960px) {
  .topbar { min-height: 60px; padding-inline: 18px; }
  .page-shell { width: min(100% - 32px, 760px); padding-top: 30px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .access-panel { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; }
  .toolbar { gap: 7px; }
  .range-control { gap: 5px; }
  .range-control span { display: none; }
  select { min-width: 86px; }
  .button { padding-inline: 10px; }
  .page-shell { width: calc(100% - 28px); padding-top: 25px; }
  .page-heading h1 { font-size: 27px; }
  .access-panel { padding: 16px; }
  .access-controls { align-items: stretch; }
  .access-controls input { min-width: 0; }
  .report-heading { align-items: flex-start; flex-direction: column; gap: 10px; padding-inline: 14px; }
  .report-body { padding: 13px 14px 15px; }
  th { white-space: normal; }
  .chart-legend { gap: 8px 12px; }
  .summary-grid { gap: 8px; }
  .summary-item { min-height: 108px; padding: 13px 12px; }
  .summary-item strong { font-size: 24px; }
  .summary-label { font-size: 12px; }
  .summary-detail { font-size: 12px; }
  .timing-item { grid-template-columns: 1fr; gap: 7px; padding-right: 12px; }
  .timing-item + .timing-item { padding-left: 14px; }
  .timing-item strong { font-size: 22px; }
  .timing-label { min-height: 30px; }
  .error-desktop-column, .slow-desktop-column { display: none; }
  .mobile-context { display: block; margin-top: 3px; color: var(--secondary); font-size: 12px; font-weight: 400; line-height: 1.35; }
  .error-report td:first-child { min-width: 140px; }
  .slow-report td:first-child { min-width: 110px; }
  .privacy-note { align-items: flex-start; flex-direction: column; gap: 6px; }
}
@media (max-width: 760px) {
  .timing-grid { grid-template-columns: 1fr; gap: 13px; }
  .timing-item, .timing-item + .timing-item { padding: 0; border: 0; }
  .timing-item { grid-template-columns: minmax(0, 1fr) auto; }
  .timing-label { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
