:root {
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --soft: #f3f2ee;
  --accent: #2a78d6;
  --up: #09ab3b;
  --down: #e34948;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--grid);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

h1 { font-size: 18px; margin: 0; }
h3 { font-size: 18px; margin: 28px 0 8px; }

nav { display: flex; gap: 4px; }
nav button {
  border: 0;
  background: none;
  padding: 6px 12px;
  border-radius: 6px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
nav button[aria-selected="true"] { color: var(--ink); background: var(--soft); font-weight: 600; }

#session { margin-left: auto; color: var(--muted); font-size: 13px; }
#session button { font: inherit; border: 1px solid var(--grid); background: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; }

main { padding: 16px 24px 64px; max-width: 1400px; margin: 0 auto; overflow-wrap: break-word; }
main > * { max-width: 100%; }

.row { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0; }
.row > .col { min-width: 0; }

.metric { padding: 4px 0; min-width: 140px; }
.metric .label { font-size: 13px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.metric .value { font-size: 26px; line-height: 1.2; white-space: nowrap; }
.metric .delta { font-size: 13px; }
.metric .delta.up { color: var(--up); }
.metric .delta.down { color: var(--down); }

.help {
  display: inline-flex; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--baseline); color: var(--muted);
  font-size: 10px; align-items: center; justify-content: center; cursor: help; position: relative;
}
.help:hover::after, .help:focus::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: 20px; width: 280px; z-index: 20;
  background: var(--surface); border: 1px solid var(--baseline); border-radius: 6px;
  padding: 8px; color: var(--ink); font-size: 13px; white-space: normal;
}

.caption { color: var(--muted); font-size: 13px; margin: 6px 0; }
.caption code, .note code { background: var(--soft); padding: 0 4px; border-radius: 4px; font-size: 12px; overflow-wrap: anywhere; }
.note { padding: 10px 14px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.note.info { background: #e9f1fc; }
.note.warning { background: #fff6e0; }

.control { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; font-size: 14px; }
.control > .label { font-size: 13px; color: var(--muted); }
.control select { font: inherit; padding: 6px 8px; border: 1px solid var(--grid); border-radius: 6px; background: white; max-width: 100%; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--grid); border-radius: 8px; overflow: hidden; width: fit-content; }
.segmented button { border: 0; background: white; padding: 5px 12px; font: inherit; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--grid); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: white; }
.control.disabled { opacity: .45; pointer-events: none; }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--grid); background: white; border-radius: 999px; padding: 4px 12px; font: inherit; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); color: white; border-color: var(--ink); }

details { border: 1px solid var(--grid); border-radius: 8px; padding: 8px 14px; margin: 12px 0; }
summary { cursor: pointer; font-size: 14px; }

.table { overflow-x: auto; margin: 8px 0; }
.table table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 4px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
.table th:first-child, .table td:first-child { text-align: left; }

.plot { width: 100%; }

.login { max-width: 360px; margin: 18vh auto; text-align: center; }
.login button { font: inherit; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--grid); background: white; cursor: pointer; }

@media (max-width: 700px) {
  header { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  main { padding: 12px 16px 48px; }
  .row { flex-direction: column; gap: 4px; }
  .row > .col { flex: 1 1 auto !important; width: 100%; }
  .row.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .metric { min-width: 0; }
  .metric .value { font-size: 22px; }
}
