:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --border: #dddcd7;
  --grid: #e8e7e3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --accent: #2a78d6;
  --critical: #d03b3b;
  --good: #0ca30c;
  /* Categorical slots 1–7 in their validated order; Other is a neutral. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-other: #a3a29c;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #1a1a19;
    --surface-2: #242423;
    --border: #3a3a37;
    --grid: #2e2e2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-other: #6b6a65;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
header h1 { font-size: 16px; margin: 0; }
#whoami { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
#whoami[hidden] { display: none; }
main { max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }
section { margin-top: 24px; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 20px 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--text-3); font-size: 12px; margin: 0 0 8px; }
.error { color: var(--critical); min-height: 1em; margin: 4px 0; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; overflow-wrap: anywhere; }

input, select, button {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; background: var(--surface-2); }
button:hover { border-color: var(--text-3); }
/* A link that looks like a button, for what opens another view. */
a.button {
  display: inline-block; color: inherit; text-decoration: none; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px;
}
a.button:hover { border-color: var(--text-3); }
a.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.quiet { background: none; border-color: transparent; color: var(--text-2); }
button.danger { color: var(--critical); }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); }
.controls label { flex-direction: row; align-items: center; gap: 6px; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-forms { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; }
form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: end; }
form.grid .wide { grid-column: 1 / -1; }
form.grid button { justify-self: start; }
#token-form { display: flex; gap: 8px; max-width: 520px; }
#token-form input { flex: 1; }
.remember { display: block; margin-top: 8px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: none; color: var(--text-2); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 8px 14px; min-width: 130px; }
.tile .label { font-size: 12px; color: var(--text-2); }
.tile .value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chart { position: relative; width: 100%; height: 280px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .hover { fill: var(--text); opacity: 0; }
.chart .column:hover .hover { opacity: .05; }
.chart .empty { fill: var(--text-3); font-size: 13px; }
.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .12); padding: 8px 10px; font-size: 12px; min-width: 180px;
}
.tooltip .title { font-weight: 600; margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 6px; }
.tooltip .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tooltip .row .v { font-variant-numeric: tabular-nums; }
.tooltip .total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-weight: 600; color: var(--text-2); font-size: 12px; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.note { white-space: normal; min-width: 200px; }
#accounts tbody tr { cursor: pointer; }
#accounts tbody tr:hover { background: var(--surface-2); }
#accounts tbody tr.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#accounts td.check, #accounts th.check { width: 1%; padding-right: 0; }
#accounts td button, #accounts td a.button { padding: 2px 8px; font-size: 12px; }
.selection { color: var(--text-2); margin: 0 0 10px; min-height: 1.5em; }
.selection button { padding: 0 4px; color: var(--accent); }
.name-cell { display: inline-flex; align-items: center; gap: 8px; }
.status-blocked { color: var(--critical); font-weight: 600; }
.status-waitlisted { color: var(--text-3); font-style: italic; }
.negative { color: var(--critical); }

#account-page { padding-top: 16px; }
#account-page h2 { overflow-wrap: anywhere; margin-top: 8px; }
.back { color: var(--accent); text-decoration: none; font-size: 13px; }
.back:hover { text-decoration: underline; }
header h1 a { color: inherit; text-decoration: none; }
#account-summary { color: var(--text-2); }

@media (max-width: 600px) {
  form.grid { grid-template-columns: 1fr; }
  .chart { height: 220px; }
}

/* Tabs: one view of the page each, and a URL each. */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 16px; overflow-x: auto; }
.tabs a {
  color: var(--text-2); text-decoration: none; padding: 8px 12px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The account list's filters. */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; }
.filters input[type="search"] { flex: 1 1 240px; max-width: 360px; }
fieldset.checks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; border: 0; margin: 0; padding: 0; }
fieldset.checks legend { float: left; font-size: 12px; color: var(--text-3); margin-right: 4px; padding: 0; }
.check-label { flex-direction: row; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.check-label input { margin: 0; }

/* Sortable headers. */
th[data-sort] { padding: 0; }
th button.sort {
  all: unset; box-sizing: border-box; display: block; width: 100%; padding: 7px 10px; cursor: pointer;
  font-weight: 600; color: var(--text-2);
}
th.num button.sort { text-align: right; }
th button.sort:hover { color: var(--text); }
th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th[aria-sort="ascending"] button.sort::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"] button.sort::after { content: " ▼"; font-size: 9px; }

/* Endpoints. */
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.panel h3 { margin: 0; }
.panel .buttons { display: flex; gap: 8px; }
.panel .buttons .push { margin-left: auto; }
.panel input, .panel select, .panel textarea { background: var(--surface); }
textarea {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 9px; resize: vertical; width: 100%;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#endpoints tbody tr.endpoint { cursor: pointer; }
#endpoints tbody tr.endpoint:hover { background: var(--surface-2); }
#endpoints tbody tr.selected { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#endpoints .actions { display: flex; gap: 6px; justify-content: flex-end; }
#endpoints td button { padding: 2px 8px; font-size: 12px; }
#endpoints .sub { color: var(--text-3); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
#endpoints tr.detail > td { background: var(--surface-2); padding: 8px 12px 12px; white-space: normal; }
table.kinds { width: auto; min-width: 60%; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.url-cell { display: inline-flex; align-items: center; gap: 4px; }
button.copy { padding: 1px 6px; font-size: 12px; color: var(--accent); }
.badge {
  font-size: 11px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 7px;
}
