/*
 * Railfan: the look of the whole app.
 *
 * Bootstrap 5.3 does layout and components. This file re-skins it through
 * Bootstrap's own CSS variables and adds the pieces Bootstrap doesn't have
 * (sidebar shell, status beacons, meters, readouts, chart cards).
 *
 * Colours are --am-* tokens, defined once for light and once for dark, and
 * everything else reads them, so a new component needs no dark-mode rules.
 * Which theme applies is the data-bs-theme attribute on <html>, set before
 * first paint by layouts/_theme.html.erb.
 *
 *   1. Fonts
 *   2. Tokens (light, dark)
 *   3. Base
 *   4. Bootstrap re-skin
 *   5. Shell: sidebar, mobile top bar, content
 *   6. Pieces
 *   7. Charts
 *   8. Sign-in pages
 *   9. The public page
 */

/* 1. Fonts ---------------------------------------------------------------- */

/* All are the "latin" builds from Fontsource (via jsDelivr), under the SIL
   Open Font License; the licence texts sit beside the files.
   Mona Sans (v4, variable) varies in weight and width: headings use the wider
   cut. Geist Mono (v6, variable) is for code, keys and container names.
   On the public page only: Doto (v5, variable in weight and dot roundness) is the dot-matrix
   face of the hero headline, like a departure board, and it is for that
   headline alone, since the dots run together below about 28px. Hubot Sans
   (v5, variable in weight and width), Mona Sans's mechanical sibling, sets
   its other headings. */
@font-face {
  font-family: "Mona Sans";
  src: url("/assets/fonts/mona-sans-5542c666.woff2") format("woff2");
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono-a600ad3f.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Doto";
  src: url("/assets/fonts/doto-6c3a6905.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Hubot Sans";
  src: url("/assets/fonts/hubot-sans-5d384252.woff2") format("woff2");
  font-weight: 200 900;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
}

/* 2. Tokens --------------------------------------------------------------- */

:root,
[data-bs-theme="light"] {
  --am-bg: #f5f4f9;
  --am-surface: #ffffff;
  --am-surface-2: #f8f7fb;
  --am-hover: #f2f0f8;
  --am-field: #ffffff;
  --am-sidebar: #fbfafd;
  --am-border: #e7e4ef;
  --am-border-strong: #d6d2e2;

  --am-text: #18142b;
  --am-text-2: #5c5770;
  --am-text-3: #736e87;

  --am-accent: #6246ea;
  --am-accent-rgb: 98, 70, 234;
  --am-accent-hover: #5236d6;
  --am-accent-ink: #4b33c4;
  --am-accent-ink-rgb: 75, 51, 196;
  --am-accent-ink-hover-rgb: 54, 35, 150;
  --am-accent-soft: #efecfd;

  /* Status: the bright step for dots and bars, the ink step for text. */
  --am-ok: #12a150;
  --am-ok-ink: #0b7a3b;
  --am-warn: #d98a00;
  --am-warn-ink: #9a5b00;
  --am-danger: #e5484d;
  --am-danger-ink: #c62a2f;

  --am-shadow: 0 1px 2px rgba(24, 20, 43, 0.05);
  --am-shadow-pop: 0 14px 36px -10px rgba(24, 20, 43, 0.22), 0 2px 6px rgba(24, 20, 43, 0.06);

  /* Chart series, in this fixed order. Checked for colour-blind separation
     between neighbours on both surfaces; don't reorder without re-checking. */
  --chart-1: #6250d6;
  --chart-2: #1baf7a;
  --chart-3: #eb6834;
  --chart-4: #2a78d6;
  --chart-5: #eda100;
  --chart-6: #e87ba4;
  --chart-7: #008300;
  --chart-8: #e34948;
  --chart-grid: #ebe9f2;
  --chart-crosshair: #b9b4cb;
}

[data-bs-theme="dark"] {
  --am-bg: #0f0d16;
  --am-surface: #171521;
  --am-surface-2: #1c1a28;
  --am-hover: #211e2f;
  --am-field: #110f1a;
  --am-sidebar: #0c0a12;
  --am-border: #272336;
  --am-border-strong: #383349;

  --am-text: #eceaf5;
  --am-text-2: #a9a4bd;
  --am-text-3: #8a85a0;

  --am-accent: #6f58f0;
  --am-accent-rgb: 111, 88, 240;
  --am-accent-hover: #8672f5;
  --am-accent-ink: #a596ff;
  --am-accent-ink-rgb: 165, 150, 255;
  --am-accent-ink-hover-rgb: 200, 190, 255;
  --am-accent-soft: #221c40;

  --am-ok: #3dd68c;
  --am-ok-ink: #3dd68c;
  --am-warn: #ffb224;
  --am-warn-ink: #ffb224;
  --am-danger: #ff6369;
  --am-danger-ink: #ff6369;

  --am-shadow: none;
  --am-shadow-pop: 0 18px 44px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.03);

  --chart-1: #9085e9;
  --chart-2: #199e70;
  --chart-3: #d95926;
  --chart-4: #3987e5;
  --chart-5: #c98500;
  --chart-6: #d55181;
  --chart-7: #0ca30c;
  --chart-8: #e66767;
  --chart-grid: #232031;
  --chart-crosshair: #4a4560;
}

/* Bootstrap's variables, pointed at the tokens above. */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-font-family: "Mona Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-font-monospace: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.5;

  --bs-body-color: var(--am-text);
  --bs-body-bg: var(--am-bg);
  --bs-emphasis-color: var(--am-text);
  --bs-heading-color: var(--am-text);
  --bs-secondary-color: var(--am-text-2);
  --bs-tertiary-color: var(--am-text-3);
  --bs-secondary-bg: var(--am-surface-2);
  --bs-tertiary-bg: var(--am-surface-2);

  --bs-link-color: var(--am-accent-ink);
  --bs-link-color-rgb: var(--am-accent-ink-rgb);
  --bs-link-hover-color-rgb: var(--am-accent-ink-hover-rgb);

  --bs-border-color: var(--am-border);
  --bs-border-color-translucent: var(--am-border);
  --bs-border-radius: 8px;
  --bs-border-radius-sm: 6px;
  --bs-border-radius-lg: 12px;

  --bs-primary: var(--am-accent);
  --bs-primary-rgb: var(--am-accent-rgb);
  --bs-code-color: var(--am-text);
  --bs-focus-ring-color: rgba(var(--am-accent-rgb), 0.3);
}

/* 3. Base ----------------------------------------------------------------- */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(var(--am-accent-rgb), 0.28);
}

a {
  text-decoration-color: rgba(var(--am-accent-ink-rgb), 0.35);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--am-accent-ink);
  outline-offset: 2px;
  border-radius: 6px;
}

code,
pre,
.font-monospace {
  font-feature-settings: "liga" 0;
}

code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--am-border);
  border-radius: 5px;
  background: var(--am-surface-2);
  font-size: 0.85em;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

hr {
  border-color: var(--am-border);
  opacity: 1;
}

/* Columns of figures line up; standalone figures keep their natural widths. */
.num {
  font-variant-numeric: tabular-nums;
}

.page-title {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 650;
  font-stretch: 112%;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.section-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 620;
  font-stretch: 106%;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.section-note {
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 400;
  font-stretch: 100%;
  letter-spacing: 0;
}

/* 4. Bootstrap re-skin ---------------------------------------------------- */

/* Buttons */
.btn {
  --bs-btn-font-size: 0.875rem;
  --bs-btn-font-weight: 550;
  --bs-btn-padding-x: 0.875rem;
  --bs-btn-padding-y: 0.4375rem;
  --bs-btn-border-radius: 8px;
  --bs-btn-focus-shadow-rgb: var(--am-accent-rgb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
}

/* Beside a field, or standing in for one, a button is as tall as a field. */
.inline-form > .btn,
.input-group > .btn,
.btn.w-100 {
  min-height: 2.5rem;
}

.btn-sm {
  --bs-btn-font-size: 0.8125rem;
  --bs-btn-padding-x: 0.625rem;
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-border-radius: 7px;
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--am-accent);
  --bs-btn-border-color: var(--am-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--am-accent-hover);
  --bs-btn-hover-border-color: var(--am-accent-hover);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--am-accent-hover);
  --bs-btn-active-border-color: var(--am-accent-hover);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--am-accent);
  --bs-btn-disabled-border-color: var(--am-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(24, 20, 43, 0.25);
}

/* The everyday button: quiet, bordered, sits on any surface. */
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-success {
  --bs-btn-color: var(--am-text);
  --bs-btn-bg: var(--am-surface);
  --bs-btn-border-color: var(--am-border-strong);
  --bs-btn-hover-color: var(--am-text);
  --bs-btn-hover-bg: var(--am-hover);
  --bs-btn-hover-border-color: var(--am-border-strong);
  --bs-btn-active-color: var(--am-text);
  --bs-btn-active-bg: var(--am-hover);
  --bs-btn-active-border-color: var(--am-border-strong);
  box-shadow: var(--am-shadow);
}

/* Destructive, but calm until you reach for it. */
.btn-outline-danger {
  --bs-btn-color: var(--am-danger-ink);
  --bs-btn-bg: var(--am-surface);
  --bs-btn-border-color: var(--am-border-strong);
  --bs-btn-hover-color: var(--am-danger-ink);
  --bs-btn-hover-bg: color-mix(in srgb, var(--am-danger) 10%, var(--am-surface));
  --bs-btn-hover-border-color: color-mix(in srgb, var(--am-danger) 45%, var(--am-surface));
  --bs-btn-active-color: var(--am-danger-ink);
  --bs-btn-active-bg: color-mix(in srgb, var(--am-danger) 16%, var(--am-surface));
  --bs-btn-active-border-color: color-mix(in srgb, var(--am-danger) 45%, var(--am-surface));
  --bs-btn-focus-shadow-rgb: 229, 72, 77;
  box-shadow: var(--am-shadow);
}

.btn-danger {
  --bs-btn-color: #fff;
  --bs-btn-bg: #d93a40;
  --bs-btn-border-color: #d93a40;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #c22d33;
  --bs-btn-hover-border-color: #c22d33;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #c22d33;
  --bs-btn-active-border-color: #c22d33;
  --bs-btn-focus-shadow-rgb: 229, 72, 77;
}

.btn-link {
  --bs-btn-color: var(--am-text-2);
  --bs-btn-hover-color: var(--am-text);
  --bs-btn-font-weight: 500;
  text-decoration: none;
}

/* Forms */
.form-label {
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 560;
}

.form-control,
.form-select {
  min-height: 2.5rem;
  padding: 0.4375rem 0.75rem;
  border-color: var(--am-border-strong);
  border-radius: 8px;
  background-color: var(--am-field);
  color: var(--am-text);
  font-size: 0.9375rem;
}

.form-select {
  padding-right: 2.25rem;
}

.form-select-sm {
  min-height: 0;
  padding: 0.25rem 2rem 0.25rem 0.625rem;
  border-radius: 7px;
  font-size: 0.8125rem;
}

.form-control::placeholder {
  color: var(--am-text-3);
  opacity: 0.8;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--am-accent);
  background-color: var(--am-field);
  color: var(--am-text);
  box-shadow: 0 0 0 3px rgba(var(--am-accent-rgb), 0.22);
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--am-surface-2);
  color: var(--am-text-2);
}

.form-control[readonly] {
  color: var(--am-text);
}

.form-text {
  margin-top: 0.375rem;
  color: var(--am-text-2);
  font-size: 0.8125rem;
}

.input-group-text {
  border-color: var(--am-border-strong);
  background-color: var(--am-surface-2);
  color: var(--am-text-2);
}

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--am-text);
  --bs-table-border-color: var(--am-border);
  --bs-table-hover-bg: var(--am-hover);
  --bs-table-hover-color: var(--am-text);
  margin: 0;
}

.table > thead > tr > th {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--am-border);
  background: var(--am-surface-2);
  color: var(--am-text-2);
  font-size: 0.78125rem;
  font-weight: 560;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 0.8125rem 1rem;
  vertical-align: middle;
}

.table > tbody > tr:last-child > td {
  border-bottom: 0;
}

.table > :not(caption) > tr > :first-child {
  padding-left: 1.25rem;
}

.table > :not(caption) > tr > :last-child {
  padding-right: 1.25rem;
}

/* Keeps absolutely placed bits (a visually hidden column heading) inside the
   scrolling box rather than widening the page. */
.table-responsive {
  position: relative;
}

/* Right-aligned on a full table, left-aligned once the hosts table folds. */
.col-end {
  text-align: right;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.7em;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--am-surface-2);
  color: var(--am-text-2);
  font-size: 0.75rem;
  font-weight: 560;
  line-height: 1.25;
  vertical-align: middle;
}

/* Alerts */
.alert {
  --bs-alert-padding-x: 1rem;
  --bs-alert-padding-y: 0.75rem;
  --bs-alert-border-radius: 10px;
  --am-alert-tone: var(--am-accent);
  border-color: color-mix(in srgb, var(--am-alert-tone) 30%, var(--am-surface));
  background: color-mix(in srgb, var(--am-alert-tone) 9%, var(--am-surface));
  color: var(--am-text);
  font-size: 0.9375rem;
}

.alert-success { --am-alert-tone: var(--am-ok); }
.alert-danger { --am-alert-tone: var(--am-danger); }
.alert-warning { --am-alert-tone: var(--am-warn); }

.alert-flash {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.alert-flash > .bi {
  margin-top: 0.1em;
  color: var(--am-alert-tone);
}

.alert-success > .bi { color: var(--am-ok-ink); }
.alert-danger > .bi { color: var(--am-danger-ink); }

.alert-dismissible .btn-close {
  padding: 1rem;
}

/* Dropdowns */
.dropdown-menu {
  --bs-dropdown-bg: var(--am-surface);
  --bs-dropdown-color: var(--am-text);
  --bs-dropdown-border-color: var(--am-border);
  --bs-dropdown-border-radius: 12px;
  --bs-dropdown-padding-x: 0.375rem;
  --bs-dropdown-padding-y: 0.375rem;
  --bs-dropdown-font-size: 0.875rem;
  --bs-dropdown-divider-bg: var(--am-border);
  --bs-dropdown-divider-margin-y: 0.375rem;
  --bs-dropdown-link-color: var(--am-text);
  --bs-dropdown-link-hover-color: var(--am-text);
  --bs-dropdown-link-hover-bg: var(--am-hover);
  --bs-dropdown-link-active-color: var(--am-text);
  --bs-dropdown-link-active-bg: var(--am-accent-soft);
  --bs-dropdown-item-padding-x: 0.625rem;
  --bs-dropdown-item-padding-y: 0.4375rem;
  --bs-dropdown-header-color: var(--am-text-3);
  --bs-dropdown-header-padding-x: 0.625rem;
  --bs-dropdown-header-padding-y: 0.375rem;
  min-width: 13.5rem;
  box-shadow: var(--am-shadow-pop);
}

[data-bs-theme="dark"] .dropdown-menu {
  --bs-dropdown-bg: var(--am-surface-2);
  --bs-dropdown-border-color: var(--am-border-strong);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border-radius: 7px;
}

.dropdown-item > .bi:first-child {
  color: var(--am-text-3);
}

.dropdown-item .bi-check2 {
  margin-left: auto;
  color: var(--am-accent-ink);
}

.dropdown-header {
  font-size: 0.75rem;
  font-weight: 560;
}

.dropdown-item-text {
  padding-inline: 0.625rem;
}

/* Breadcrumbs */
.breadcrumb {
  --bs-breadcrumb-divider: "/";
  --bs-breadcrumb-divider-color: var(--am-text-3);
  --bs-breadcrumb-item-active-color: var(--am-text);
  --bs-breadcrumb-item-padding-x: 0.5rem;
  --bs-breadcrumb-margin-bottom: 0.875rem;
  font-size: 0.8125rem;
}

.breadcrumb a {
  color: var(--am-text-2);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--am-text);
}

/* Lists of things to pick from (tenants) */
.list-group {
  --bs-list-group-bg: var(--am-surface);
  --bs-list-group-color: var(--am-text);
  --bs-list-group-border-color: var(--am-border);
  --bs-list-group-border-radius: 12px;
  --bs-list-group-item-padding-x: 1.25rem;
  --bs-list-group-item-padding-y: 0.875rem;
  --bs-list-group-action-color: var(--am-text);
  --bs-list-group-action-hover-color: var(--am-text);
  --bs-list-group-action-hover-bg: var(--am-hover);
  --bs-list-group-action-active-color: var(--am-text);
  --bs-list-group-action-active-bg: var(--am-hover);
  box-shadow: var(--am-shadow);
}

/* 5. Shell ---------------------------------------------------------------- */

.shell {
  display: flex;
  min-height: 100dvh;
}

.shell-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.content {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding: 1.25rem 1rem 3.5rem;
}

.content-bare {
  max-width: 60rem;
  padding-top: 3rem;
}

/* Below lg the sidebar is a Bootstrap offcanvas; from lg up it's a fixed column. */
.sidebar {
  --bs-offcanvas-width: 17.5rem;
  --bs-offcanvas-bg: var(--am-sidebar);
  --bs-offcanvas-border-color: var(--am-border);
}

.sidebar-inner {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.875rem;
  min-height: 0;
  padding: 0.875rem 0.75rem;
  background: var(--am-sidebar);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.375rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--am-text);
  font-size: 1rem;
  font-weight: 680;
  font-stretch: 116%;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: var(--am-text);
}

.brand-mark {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
}

.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--am-hover);
  box-shadow: inset 0 0 0 1px var(--am-border-strong);
  color: var(--am-text);
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.avatar-tenant {
  border-radius: 7px;
  background: var(--am-accent-soft);
  box-shadow: inset 0 0 0 1px rgba(var(--am-accent-rgb), 0.28);
  color: var(--am-accent-ink);
  font-size: 0.75rem;
}

.tenant-button,
.user-button {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.4375rem 0.5rem;
  border: 1px solid var(--am-border);
  border-radius: 10px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow);
  color: var(--am-text);
  font-size: 0.875rem;
  font-weight: 560;
  text-align: left;
}

.tenant-button:hover,
.user-button:hover,
.tenant-button[aria-expanded="true"],
.user-button[aria-expanded="true"] {
  background: var(--am-hover);
}

.tenant-button > .bi,
.user-button > .bi {
  flex: none;
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.user-button {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.truncate {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-lines {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.user-lines > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-lines small {
  color: var(--am-text-3);
  font-size: 0.75rem;
  font-weight: 450;
}

.sidebar .dropdown-menu {
  width: 100%;
}

.side-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.125rem;
  min-height: 0;
  overflow-y: auto;
}

.side-nav ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.6875rem;
  padding: 0.4375rem 0.625rem;
  border-radius: 8px;
  color: var(--am-text-2);
  font-size: 0.9rem;
  font-weight: 520;
  text-decoration: none;
}

.side-link > .bi {
  color: var(--am-text-3);
  font-size: 1rem;
}

.side-link:hover {
  background: var(--am-hover);
  color: var(--am-text);
}

.side-link.active {
  background: var(--am-accent-soft);
  color: var(--am-accent-ink);
  font-weight: 600;
}

.side-link.active > .bi {
  color: var(--am-accent-ink);
}

[data-bs-theme="dark"] .side-link.active {
  color: var(--am-text);
}

.sidebar-foot {
  display: grid;
  gap: 0.625rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--am-border);
}

.sidebar-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 0.5rem;
  color: var(--am-text-2);
  font-size: 0.8125rem;
}

/* A row of mutually exclusive choices: theme, chart time range. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--am-border);
  border-radius: 9px;
  background: var(--am-surface-2);
}

.seg > button {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 1.625rem;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.seg > button:hover {
  color: var(--am-text);
}

.seg > button.active,
.seg > button[aria-pressed="true"] {
  background: var(--am-surface);
  box-shadow: 0 0 0 1px var(--am-border-strong), 0 1px 2px rgba(24, 20, 43, 0.08);
  color: var(--am-text);
}

[data-bs-theme="dark"] .seg > button.active,
[data-bs-theme="dark"] .seg > button[aria-pressed="true"] {
  background: var(--am-hover);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--am-border);
  background: color-mix(in srgb, var(--am-bg) 86%, transparent);
  backdrop-filter: blur(10px);
}

.topbar-tenant {
  margin-left: auto;
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 520;
}

.icon-button {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--am-border);
  border-radius: 9px;
  background: var(--am-surface);
  color: var(--am-text);
  font-size: 1.125rem;
}

.icon-button:hover {
  background: var(--am-hover);
}

@media (min-width: 992px) {
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex: none;
    flex-direction: column;
    width: 16.5rem;
    height: 100dvh;
    border-right: 1px solid var(--am-border);
  }

  .sidebar-inner {
    padding: 1rem 0.875rem;
  }

  .content {
    padding: 2rem 2.25rem 4rem;
  }

  .content-bare {
    padding-top: 4rem;
  }
}

/* 6. Pieces --------------------------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.875rem 1.5rem;
  margin-bottom: 1.5rem;
}

.page-sub {
  max-width: 68ch;
  margin: 0.375rem 0 0;
  color: var(--am-text-2);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.125rem;
  margin: 0.5rem 0 0;
  padding: 0;
  color: var(--am-text-2);
  font-size: 0.875rem;
  list-style: none;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem 1rem;
  margin: 2.25rem 0 0.875rem;
}

/* The white (or raised, in the dark) box most content sits in. */
.panel {
  overflow: hidden;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow);
}

.panel-body {
  padding: 1.25rem;
}

.panel-note {
  padding: 1.125rem 1.25rem;
  color: var(--am-text-2);
}

.panel + .panel {
  margin-top: 1rem;
}

.chart-grid > .panel {
  margin-top: 0;
}

.form-panel {
  max-width: 40rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* One line of a form: fields that grow, a button that doesn't. Everything
   hangs from the top, so an error message under a field doesn't drag the
   button down with it; the button's margin is the height of a field's label. */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
}

.inline-form > .grow {
  flex: 1 1 14rem;
}

.inline-form > .btn {
  margin-top: 1.59375rem;
}

@media (max-width: 575.98px) {
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form > .grow {
    flex: none;
  }

  .inline-form > .btn {
    margin-top: 0.25rem;
  }
}

/* Rows that open something: a click anywhere on one follows its title link
   (row_link_controller.js). */
.row-link {
  cursor: pointer;
}

.row-title {
  color: var(--am-text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.row-link:hover .row-title,
a.row-title:hover {
  color: var(--am-accent-ink);
}

.row-sub {
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.cell-quiet {
  color: var(--am-text-2);
  font-size: 0.875rem;
}

.mono {
  font-family: var(--bs-font-monospace);
  font-size: 0.8125rem;
}

.is-revoked > td {
  color: var(--am-text-3);
}

/* Status: a dot that pings while the thing is alive, and its label. */
.beacon {
  position: relative;
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.status {
  border-color: color-mix(in srgb, var(--am-tone) 22%, transparent);
  background: color-mix(in srgb, var(--am-tone) 11%, var(--am-surface));
  color: var(--am-tone-ink);
}

.status-ok { --am-tone: var(--am-ok); --am-tone-ink: var(--am-ok-ink); }
.status-warn { --am-tone: var(--am-warn); --am-tone-ink: var(--am-warn-ink); }
.status-danger { --am-tone: var(--am-danger); --am-tone-ink: var(--am-danger-ink); }
.status-idle { --am-tone: var(--am-text-3); --am-tone-ink: var(--am-text-2); }

.status .beacon {
  background: var(--am-tone);
}

@media (prefers-reduced-motion: no-preference) {
  .status-ok .beacon::after {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--am-tone);
    content: "";
    animation: beacon-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
  }
}

@keyframes beacon-ping {
  0% { opacity: 0.6; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(2.8); }
}

.role-owner {
  border-color: rgba(var(--am-accent-rgb), 0.28);
  background: var(--am-accent-soft);
  color: var(--am-accent-ink);
}

.role-admin {
  border-color: var(--am-border-strong);
  background: var(--am-surface);
  color: var(--am-text);
}

.role-member,
.tag {
  border-color: var(--am-border);
  background: var(--am-surface-2);
  color: var(--am-text-2);
}

.tag {
  padding: 0.2em 0.6em;
  font-weight: 500;
}

/* How the hosts are doing overall, beside the page title. */
.fleet {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1.125rem;
  margin: 0;
  padding: 0;
  color: var(--am-text-2);
  font-size: 0.875rem;
  list-style: none;
}

.fleet li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.fleet strong {
  color: var(--am-text);
  font-weight: 650;
}

.fleet .beacon { color: var(--am-text-3); }
.fleet .tone-ok { color: var(--am-ok); }
.fleet .tone-warn { color: var(--am-warn); }
.fleet .tone-danger { color: var(--am-danger); }

/* A usage bar. The fill carries severity; the track is a tint of the fill. */
.meter {
  --am-tone: var(--am-accent);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 6.5rem;
}

[data-bs-theme="dark"] .meter {
  --am-tone: var(--am-accent-ink);
}

.meter-warn { --am-tone: var(--am-warn) !important; }
.meter-danger { --am-tone: var(--am-danger) !important; }

.meter-track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: color-mix(in srgb, var(--am-tone) 16%, var(--am-surface));
}

.meter-fill {
  width: calc(var(--value) * 1%);
  height: 100%;
  border-radius: 3px;
  background: var(--am-tone);
  transition: width 0.6s ease;
}

.meter-value {
  min-width: 2.375rem;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.meter-warn .meter-value { color: var(--am-warn-ink); font-weight: 600; }
.meter-danger .meter-value { color: var(--am-danger-ink); font-weight: 600; }

/* A note under a meter (which disk it is), hung below so the bar stays on
   the row's centre line with its neighbours. */
.meter-noted {
  position: relative;
}

.meter-note {
  position: absolute;
  top: 100%;
  left: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--am-text-3);
  font-size: 0.75rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Current readings on a host page: one panel, a cell per figure. */
.readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.readout-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.125rem 1.25rem 1.25rem;
  border-top: 1px solid var(--am-border);
  border-left: 1px solid var(--am-border);
}

.readout-cell:nth-child(-n + 2) { border-top: 0; }
.readout-cell:nth-child(odd) { border-left: 0; }

.readout-label {
  overflow: hidden;
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 520;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readout-value {
  font-size: 1.875rem;
  font-weight: 620;
  font-stretch: 108%;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.readout-value small {
  margin-left: 0.1em;
  color: var(--am-text-3);
  font-size: 0.55em;
  font-weight: 560;
  letter-spacing: 0;
}

.readout-foot {
  margin-top: auto;
  padding-top: 0.5rem;
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.readout .meter {
  margin-top: auto;
  padding-top: 0.5rem;
}

@media (min-width: 992px) {
  .readout {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .readout-cell,
  .readout-cell:nth-child(odd) {
    border-top: 0;
    border-left: 1px solid var(--am-border);
  }

  .readout-cell:first-child {
    border-left: 0;
  }
}

/* Nothing here yet: say what goes here and how to get it. */
.empty {
  display: grid;
  justify-items: center;
  gap: 0.375rem;
  padding: 3.5rem 1.5rem;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.625rem;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  background: var(--am-surface-2);
  color: var(--am-accent-ink);
  font-size: 1.375rem;
}

.empty h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 620;
}

.empty p {
  max-width: 46ch;
  margin: 0;
  color: var(--am-text-2);
}

.empty .btn {
  margin-top: 0.875rem;
}

/* Something to copy: a new ingest key, an invitation link. */
.reveal {
  margin-bottom: 1rem;
  padding: 1.125rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--am-ok) 35%, var(--am-surface));
  border-radius: 12px;
  background: color-mix(in srgb, var(--am-ok) 7%, var(--am-surface));
}

.reveal-info {
  border-color: rgba(var(--am-accent-rgb), 0.3);
  background: var(--am-accent-soft);
}

.reveal h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: 620;
}

.reveal h2 .bi { color: var(--am-ok-ink); }

.reveal p {
  margin: 0 0 0.75rem;
  color: var(--am-text-2);
  font-size: 0.875rem;
}

.reveal summary {
  width: fit-content;
  margin-top: 0.875rem;
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 520;
  cursor: pointer;
}

.code-block {
  margin: 0.625rem 0 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--am-border);
  border-radius: 9px;
  background: var(--am-field);
  font-size: 0.78125rem;
  line-height: 1.6;
}

/* Tenants to pick from */
.pick-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-weight: 560;
}

.pick-item > .bi {
  color: var(--am-text-3);
}

/* The confirm dialog (see confirm_dialog.js) */
.confirm {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--am-border);
  border-radius: 14px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow-pop);
  color: var(--am-text);
}

[data-bs-theme="dark"] .confirm {
  border-color: var(--am-border-strong);
  background: var(--am-surface-2);
}

.confirm::backdrop {
  background: rgba(12, 10, 18, 0.55);
  backdrop-filter: blur(3px);
}

.confirm h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 620;
  line-height: 1.35;
}

.confirm p {
  margin: 0.5rem 0 0;
  color: var(--am-text-2);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  .confirm[open] {
    animation: confirm-in 0.16s ease-out;
  }
}

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* The hosts table folds into one block per host on a phone. */
@media (max-width: 767.98px) {
  .host-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .host-table,
  .host-table tbody {
    display: block;
  }

  .host-table > tbody > tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.875rem 1rem;
    padding: 1rem 1.125rem;
    border-bottom: 1px solid var(--am-border);
  }

  .host-table > tbody > tr:last-child {
    border-bottom: 0;
  }

  .host-table > tbody > tr > td,
  .host-table > tbody > tr > td:first-child,
  .host-table > tbody > tr > td:last-child {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }

  .host-table td[data-label]::before {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--am-text-3);
    font-size: 0.75rem;
    content: attr(data-label);
  }

  .host-table .row-title {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .host-table .col-end { text-align: left; }
  .host-table .col-host { grid-column: 1 / 3; }
  .host-table .col-status { grid-column: 3; justify-self: end; }
  .host-table .col-load { grid-column: 1; }
  .host-table .col-seen { grid-column: 2 / 4; }

  .host-table .meter {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.3125rem;
    min-width: 0;
  }

  .host-table .meter-value {
    min-width: 0;
    text-align: left;
  }

  .host-table .meter-track {
    flex: none;
  }

  .host-table .meter-note {
    position: static;
    margin-top: 0.125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill,
  .chart-grid {
    transition: none;
  }
}

/* 7. Charts --------------------------------------------------------------- */

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  transition: opacity 0.2s;
}

.chart-grid.is-loading {
  opacity: 0.55;
}

@media (min-width: 992px) {
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1rem 1.25rem 0.875rem;
  overflow: visible;
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.chart-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.chart-latest {
  color: var(--am-text-2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.chart-latest strong {
  color: var(--am-text);
  font-weight: 620;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.25rem;
  margin: 0 -0.375rem;
  padding: 0;
  list-style: none;
}

.chart-legend button {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  max-width: 16rem;
  padding: 0.125rem 0.375rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--am-text-2);
  font-size: 0.78125rem;
}

.chart-legend button:hover {
  background: var(--am-hover);
  color: var(--am-text);
}

.chart-legend button[aria-pressed="false"] {
  color: var(--am-text-3);
  text-decoration: line-through;
}

.chart-legend button[aria-pressed="false"] .chart-key {
  opacity: 0.35;
}

.chart-legend .truncate {
  flex: 0 1 auto;
}

/* A short stroke of the series colour, dashed where the line is. */
.chart-key {
  flex: none;
  width: 0.875rem;
  height: 0;
  border-top: 2px solid var(--key);
  border-radius: 1px;
}

.chart-key.is-dashed {
  border-top-style: dashed;
}

/* The plot takes whatever height is left, so two cards in a row end on the
   same baseline even when only one has a legend. */
.chart-plot {
  position: relative;
  flex: 1 0 13.5rem;
}

.chart-plot > canvas {
  position: absolute;
  inset: 0;
}

.chart-tip {
  position: absolute;
  top: 0.25rem;
  z-index: 5;
  min-width: 9rem;
  max-width: 18rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--am-border);
  border-radius: 9px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow-pop);
  font-size: 0.78125rem;
  pointer-events: none;
}

[data-bs-theme="dark"] .chart-tip {
  border-color: var(--am-border-strong);
  background: var(--am-surface-2);
}

.chart-tip-time {
  margin-bottom: 0.3125rem;
  color: var(--am-text-2);
}

.chart-tip-rows {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 0.125rem 0.5rem;
}

.chart-tip-row {
  display: contents;
}

.chart-tip-row strong {
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-tip-row .truncate {
  color: var(--am-text-2);
}

.chart-tip-more {
  margin-top: 0.125rem;
  color: var(--am-text-3);
}

.chart-message {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  color: var(--am-text-2);
  text-align: center;
}

/* 8. Sign-in pages -------------------------------------------------------- */

.auth {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 100dvh;
  padding: clamp(2.5rem, 12vh, 7rem) 1rem 3rem;
  overflow: hidden;
}

/* Graph paper, fading out from the top. */
.auth::before {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--am-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--am-border) 1px, transparent 1px);
  background-position: center top;
  background-size: 2.5rem 2.5rem;
  content: "";
  mask-image: radial-gradient(ellipse 75% 60% at 50% 0%, #000 10%, transparent 75%);
  opacity: 0.8;
}

/* A stretch of telemetry running behind the form. */
.auth-trace {
  position: absolute;
  top: clamp(4rem, 15vh, 9rem);
  left: 0;
  width: 100%;
  height: 11rem;
  color: var(--am-accent);
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  opacity: 0.55;
}

.auth-trace path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

@media (prefers-reduced-motion: no-preference) {
  .auth-trace path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: trace-draw 1.8s 0.15s cubic-bezier(0.3, 0, 0.2, 1) forwards;
  }
}

@keyframes trace-draw {
  to { stroke-dashoffset: 0; }
}

.auth-box {
  position: relative;
  width: 100%;
  max-width: 25.5rem;
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.auth-brand .brand {
  font-size: 1.1875rem;
}

.auth-brand .brand-mark {
  width: 2.125rem;
  height: 2.125rem;
}

.auth-card {
  padding: 1.75rem;
  border: 1px solid var(--am-border);
  border-radius: 16px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow-pop);
}

.auth-title {
  margin: 0 0 1.125rem;
  font-size: 1.3125rem;
  font-weight: 650;
  font-stretch: 110%;
  letter-spacing: -0.01em;
}

.auth-title + .auth-lede {
  margin-top: -0.625rem;
}

.auth-lede {
  margin-bottom: 1.125rem;
  color: var(--am-text-2);
}

.auth-aside {
  margin: 1rem 0 0;
  color: var(--am-text-2);
  font-size: 0.875rem;
  text-align: center;
}

.auth-theme {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
}

/* ── Performance and errors ──────────────────────────────────────────────
   Range links reuse the segmented control; the trace waterfall, backtraces
   and span-kind colours use the same variables as everything above. */

.seg > a {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 1.625rem;
  padding: 0 0.5rem;
  border-radius: 7px;
  color: var(--am-text-2);
  font-size: 0.8125rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.seg > a:hover { color: var(--am-text); }

.seg > a.active {
  background: var(--am-surface);
  box-shadow: 0 0 0 1px var(--am-border-strong), 0 1px 2px rgba(24, 20, 43, 0.08);
  color: var(--am-text);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.filters .form-select,
.filters .form-control { width: auto; min-width: 10rem; }

.chart-box {
  position: relative;
  height: 240px;
}

/* For a pair of smaller charts side by side. */
.chart-box-short {
  height: 180px;
}

/* Span kinds: one colour each, shared by the waterfall and the badges. */
.span-request { --span: var(--chart-1); }
.span-sql { --span: var(--chart-2); }
.span-view { --span: var(--chart-3); }
.span-http { --span: var(--chart-4); }
.span-other { --span: var(--chart-6); }

.badge.span-kind {
  border-color: color-mix(in srgb, var(--span) 45%, transparent);
  background: color-mix(in srgb, var(--span) 14%, transparent);
  color: var(--am-text);
}

.waterfall {
  font-size: 0.8125rem;
}

.waterfall-row {
  display: grid;
  grid-template-columns: minmax(12rem, 40%) 1fr 5.5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.3rem 1.25rem;
  border-top: 1px solid var(--am-border);
}

.waterfall-row:first-child { border-top: 0; }

.waterfall-name {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  min-width: 0;
  padding-left: calc(var(--depth, 0) * 0.875rem);
}

.waterfall-name details { min-width: 0; }
.waterfall-name summary { list-style: none; cursor: pointer; }
.waterfall-name summary::-webkit-details-marker { display: none; }

.waterfall-track {
  position: relative;
  height: 0.75rem;
  border-radius: 4px;
  background: var(--am-surface-2);
}

.waterfall-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 2px;
  border-radius: 4px;
  background: var(--span);
}

.waterfall-row.is-error .waterfall-bar { background: var(--am-danger); }

.waterfall-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--am-text-2);
}

.sql-text {
  margin-top: 0.375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.breakdown {
  display: flex;
  height: 0.625rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--am-surface-2);
}

.breakdown > span { background: var(--span); }

.breakdown-key {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.625rem;
  color: var(--am-text-2);
  font-size: 0.8125rem;
}

.breakdown-key i {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  margin-right: 0.375rem;
  border-radius: 3px;
  background: var(--span);
}

.flag-n1 {
  border-color: color-mix(in srgb, var(--am-warn) 50%, transparent);
  background: color-mix(in srgb, var(--am-warn) 16%, transparent);
  color: var(--am-warn-ink);
}

.backtrace {
  margin: 0;
  padding: 0.5rem 0;
  list-style: none;
  font-size: 0.78125rem;
}

.backtrace li {
  padding: 0.125rem 1.25rem;
  color: var(--am-text-3);
  word-break: break-all;
}

.backtrace li.is-app {
  color: var(--am-text);
  font-weight: 550;
}

.error-message {
  margin: 0.25rem 0 0;
  color: var(--am-text-2);
  word-break: break-word;
}

.log-lines {
  max-height: 24rem;
  overflow: auto;
  margin: 0;
  padding: 0.75rem 1.25rem;
  font-size: 0.78125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-lines .lvl-error, .log-lines .lvl-fatal { color: var(--am-danger-ink); }
.log-lines .lvl-warn { color: var(--am-warn-ink); }

@media (max-width: 767.98px) {
  .waterfall-row { grid-template-columns: 1fr 4.5rem; }
  .waterfall-track { grid-column: 1 / -1; grid-row: 2; }
}

/* The open-errors count at the end of the Errors link. */
.side-count {
  margin-left: auto;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--am-danger) 16%, transparent);
  color: var(--am-danger-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

/* A collapsed run of identical spans; opens to show each one. */
.waterfall-repeat { border-top: 1px solid var(--am-border); }
.waterfall-repeat > summary { list-style: none; cursor: pointer; }
.waterfall-repeat > summary::-webkit-details-marker { display: none; }
.waterfall-repeat > summary .waterfall-row { border-top: 0; }
.waterfall-repeat > summary:hover { background: var(--am-hover); }
.waterfall-repeat[open] > summary .bi-chevron-down { transform: rotate(180deg); }
.waterfall-repeat > .waterfall-row { background: var(--am-surface-2); }
.min-w-0 { min-width: 0; }

/* Sub-pages under a sidebar item (Performance: slow requests, queries, N+1). */
.side-sub { display: grid; gap: 2px; margin: 0.125rem 0 0.25rem 1.375rem; padding: 0; list-style: none; }
.side-sub .side-link { padding-block: 0.3rem; font-size: 0.84rem; }

/* A cell that takes the leftover width and truncates its text rather than
   widening the table (long error messages, SQL). */
.cell-fill { width: 100%; max-width: 0; }

/* Log search: one line per row, wrapping long messages. */
.log-table { font-size: 0.78125rem; line-height: 1.55; }
.log-row {
  display: grid;
  grid-template-columns: 9.5rem 3.25rem minmax(6rem, 11rem) 1fr;
  gap: 0.75rem;
  padding: 0.25rem 1.25rem;
  border-top: 1px solid var(--am-border);
}
.log-row:first-child { border-top: 0; }
.log-time, .log-level { color: var(--am-text-3); white-space: nowrap; }
.log-source { color: var(--am-text-2); text-decoration: none; }
.log-message { word-break: break-word; }
.log-text { white-space: pre-wrap; }
.log-request { margin-left: 0.5rem; color: var(--am-text-3); text-decoration: none; white-space: nowrap; }
.log-request:hover, .log-source:hover { text-decoration: underline; }
.log-row.lvl-warn .log-level { color: var(--am-warn-ink); }
.log-row.lvl-error .log-level, .log-row.lvl-fatal .log-level { color: var(--am-danger-ink); }
.log-row.lvl-error, .log-row.lvl-fatal { background: color-mix(in srgb, var(--am-danger) 6%, transparent); }
@media (max-width: 767.98px) {
  .log-row { grid-template-columns: auto auto 1fr; }
  .log-message { grid-column: 1 / -1; }
}

/* The sidebar inside one app: the app switcher, then a heading over the
   tenant's own pages. */
.side-heading {
  margin: 0 0 0.375rem;
  padding-inline: 0.625rem;
  color: var(--am-text-3);
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app-button { padding-block: 0.5rem; }
.app-button-lines { display: flex; flex: 1; align-items: center; gap: 0.5rem; min-width: 0; }
.avatar-app {
  border-radius: 7px;
  background: var(--am-surface-2);
  color: var(--am-text-2);
  font-size: 0.875rem;
}
.app-menu { max-height: 70vh; overflow-y: auto; }
.app-menu .dropdown-item { display: flex; align-items: center; gap: 0.5rem; }

/* An app's Kamal destination beside its name (AppSignal's environment pill). */
.env-pill {
  flex: none;
  padding: 0.2em 0.55em;
  border: 1px solid rgba(var(--am-accent-rgb), 0.28);
  background: var(--am-accent-soft);
  color: var(--am-accent-ink);
  font-size: 0.6875rem;
  font-weight: 600;
}

/* The apps page: one card per app with its last 24 hours. */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.app-grid > .panel + .panel { margin-top: 0; }
.app-card {
  position: relative;
  display: grid;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.app-card:hover { border-color: var(--am-border-strong); box-shadow: var(--am-shadow-pop); }
.app-card-head { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.app-card-name { color: var(--am-text); font-size: 1rem; font-weight: 640; text-decoration: none; }
.app-card-name:focus-visible { outline: none; }
.app-card:has(.app-card-name:focus-visible) { outline: 2px solid var(--am-accent); outline-offset: 2px; }
.app-card-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; margin: 0; }
.app-card-stats dt { color: var(--am-text-3); font-size: 0.6875rem; font-weight: 550; white-space: nowrap; }
.app-card-stats dd { margin: 0; color: var(--am-text); font-size: 1rem; font-weight: 620; }
.app-card-stats dd small { margin-left: 0.125rem; color: var(--am-text-3); font-size: 0.6875rem; font-weight: 500; }
.app-card-stats dd.is-bad { color: var(--am-danger-ink); }

/* A figure that wants a look, wherever it is (a table cell takes its colour
   from Bootstrap's own rule unless it's outranked). */
.is-bad,
.table td.is-bad {
  color: var(--am-danger-ink);
}

/* A short list of facts, a label and its figure to a line (an app's traffic
   at the proxy). */
.fact-list {
  margin: 0;
  padding: 0.25rem 1.25rem;
}

.fact-list > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.6875rem 0;
  border-top: 1px solid var(--am-border);
}

.fact-list > div:first-child {
  border-top: 0;
}

.fact-list dt {
  color: var(--am-text-2);
  font-weight: 450;
}

.fact-list dd {
  margin: 0;
  text-align: right;
}

/* What an app leans on: a row per database, Redis or accessory, with the few
   figures worth a glance beside its status. */
.service-table td {
  vertical-align: top;
}

.service-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.service-name .bi {
  color: var(--am-text-3);
}

.service-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 1.25rem;
  margin: 0;
  font-size: 0.875rem;
}

.service-figures > div {
  display: flex;
  gap: 0.375rem;
}

.service-figures dt {
  color: var(--am-text-3);
  font-weight: 450;
}

.service-figures dd {
  margin: 0;
}

.service-problem {
  color: var(--am-danger-ink);
  font-size: 0.875rem;
}

/* On a phone it folds into one block per service, as the hosts table does. */
@media (max-width: 767.98px) {
  .service-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .service-table,
  .service-table tbody {
    display: block;
  }

  .service-table > tbody > tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    padding: 1rem 1.125rem;
    border-bottom: 1px solid var(--am-border);
  }

  .service-table > tbody > tr:last-child {
    border-bottom: 0;
  }

  .service-table > tbody > tr > td,
  .service-table > tbody > tr > td:first-child,
  .service-table > tbody > tr > td:last-child {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }

  .service-table td[data-label]::before {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--am-text-3);
    font-size: 0.75rem;
    content: attr(data-label);
  }

  /* Its name with its status beside it, then who looked and what they
     found, then how it's doing across the full width. */
  .service-table .col-service { grid-area: 1 / 1 / 2 / 3; overflow-wrap: anywhere; }
  .service-table .col-status { grid-area: 1 / 3 / 2 / 4; justify-self: end; }
  .service-table .col-from { grid-area: 2 / 1; }
  .service-table .col-doing { grid-column: 1 / -1; }
}
.app-card-foot { margin: 0; color: var(--am-text-3); font-size: 0.78125rem; }
.sparkline { display: block; width: 100%; height: 2rem; overflow: visible; }
.sparkline-line { fill: none; stroke: var(--chart-1); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sparkline-area { fill: color-mix(in srgb, var(--chart-1) 12%, transparent); stroke: none; }

/* Set up an app: numbered steps, each with code to copy. */
.setup-steps { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.setup-steps > .panel + .panel { margin-top: 0; }
.setup-step { position: relative; padding: 1.25rem 1.375rem 1.25rem 4rem; counter-increment: step; }
.setup-step::before {
  content: counter(step);
  position: absolute;
  top: 1.125rem;
  left: 1.25rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--am-accent-soft);
  color: var(--am-accent-ink);
  font-size: 0.8125rem;
  font-weight: 650;
}
.setup-title { margin: 0.1rem 0 0.5rem; font-size: 1.0625rem; font-weight: 640; }
.setup-step > p { max-width: 48rem; color: var(--am-text-2); }
.sample { margin: 0.625rem 0 1rem; }
.sample .code-block { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.sample-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.375rem 0.25rem 0.875rem;
  border: 1px solid var(--am-border);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: var(--am-surface-2);
  color: var(--am-text-3);
  font-size: 0.75rem;
}
.sample-copy { display: inline-flex; gap: 0.375rem; align-items: center; color: var(--am-text-2); font-size: 0.75rem; }
.sample-copy:hover { background: var(--am-hover); color: var(--am-text); }
@media (max-width: 575.98px) {
  .setup-step { padding: 3.5rem 1rem 1rem; }
  .setup-step::before { top: 1rem; left: 1rem; }
}
.setup-more > summary { width: fit-content; color: var(--am-text-2); font-size: 0.8125rem; font-weight: 520; cursor: pointer; }
.setup-more > p { color: var(--am-text-2); }

/* 9. The public page ------------------------------------------------------ */

/* What a visitor who isn't signed in gets at "/" (layouts/marketing and
   home/show). A railway runs through it: sample trains pass along a
   four-track main line under the headline, stopping at its signals, and are
   written down as they go (line_controller.js). On a wide screen a branch
   joins from the left margin and a line runs the length of the right one.
   One train is taken apart further down, and a line ends at the buffers,
   where the page says the beta is closed.

   The hero headline is set in --site-headline (Doto), the other headings in
   --site-display (Hubot Sans), and everything else stays in the app's faces.
   The headline's size is tuned to how wide Doto sets (0.6em a character), so
   a change of typeface means re-checking that it still fills its line. */

.site {
  --site-headline: "Doto", var(--bs-font-monospace);
  --site-display: "Hubot Sans", var(--bs-body-font-family);
  /* Hubot's headings run wide, as the app's run Mona wider. */
  --site-display-stretch: 112%;
  /* Shading for the trains: it has to sit on any wagon colour, in either
     theme, so it's ink and light rather than tokens. */
  --train-shade: rgba(24, 20, 43, 0.3);
  --train-light: rgba(255, 255, 255, 0.34);
  --train-glass: color-mix(in srgb, var(--am-text) 80%, transparent);
  --train-lamp: color-mix(in srgb, var(--am-warn) 30%, #fff);
  /* The page's side margin: the same one .site-wrap has, for the grids that
     let something run edge to edge. */
  --gutter: max(clamp(1rem, 4vw, 2.5rem), calc((100% - 70rem) / 2));
}

/* Graph paper behind the top of the page, as on the sign-in pages. */
.site::before {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 46rem;
  background-image:
    linear-gradient(var(--am-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--am-border) 1px, transparent 1px);
  background-position: center top;
  background-size: 2.5rem 2.5rem;
  content: "";
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 0%, transparent 72%);
  opacity: 0.75;
}

.site-wrap {
  width: 100%;
  max-width: 75rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
}

.site-nav-start,
.site-nav-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-nav .brand {
  font-size: 1.125rem;
}

@media (max-width: 575.98px) {
  .site-nav .tag {
    display: none;
  }
}

/* The narrowest phones: the bar only fits with a little less air in it. */
@media (max-width: 359.98px) {
  .site-nav,
  .site-nav-end {
    gap: 0.5rem;
  }

  .site-nav .brand {
    gap: 0.5rem;
    font-size: 1rem;
  }
}

.site-nav .brand-mark {
  width: 2rem;
  height: 2rem;
}

/* The hero is a grid with the page's margins as its outer columns, so the
   line can run through them while everything else keeps to the middle. On a
   phone the pitch comes before the line; from lg up the headline sits right on
   the line, with the pitch and the log side by side beneath it. */
.site-hero {
  --drop: 2.25rem;
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) var(--gutter);
  grid-template-areas:
    ". head ."
    ". pitch ."
    "line line line"
    ". log .";
  padding-top: clamp(1.75rem, 6vh, 4.5rem);
}

@media (min-width: 992px) {
  .site-hero {
    grid-template-columns: var(--gutter) minmax(0, 1fr) minmax(0, 35rem) var(--gutter);
    grid-template-areas:
      ". head head ."
      "line line line line"
      ". pitch log .";
  }
}

/* Three lines on a phone, two from there up, sized so the longest just fills
   the column; "the rails." always ends it, right above the line. */
.site-headline {
  grid-area: head;
  margin: 0;
  font-family: var(--site-headline);
  /* "It's always", the longest line, is 6.6em; two lines up, "It's always
     watching" is 12em. Tracking stays at 0 so the dots don't touch. */
  font-size: clamp(2.25rem, calc((100vw - 2rem) / 6.75), 4.875rem);
  font-weight: 900;
  /* Round dots, like a departure board's lamps (0 is square pixels). */
  font-variation-settings: "ROND" 100;
  line-height: 1;
  letter-spacing: 0;
  /* The board's amber: the ink shade, since plain amber on the light ground
     is under 3:1. */
  color: var(--am-warn-ink);
}

.site-headline > span {
  display: block;
}

@media (min-width: 576px) {
  .site-headline {
    font-size: clamp(2.5rem, calc((100vw - 5rem) / 12.3), 5.75rem);
  }

  .site-headline > span {
    display: inline;
  }

  .site-headline > .site-headline-last {
    display: block;
  }
}

.site-pitch {
  grid-area: pitch;
  margin-top: 1.5rem;
}

@media (min-width: 992px) {
  .site-pitch {
    margin-top: calc(var(--drop) + 0.25rem);
    padding-right: clamp(2rem, 5vw, 4.5rem);
  }
}

.site-lede {
  max-width: 34rem;
  margin: 0;
  font-size: clamp(1.1875rem, 1.9vw, 1.4375rem);
  line-height: 1.45;
  text-wrap: balance;
}

.site-status {
  margin: 1.375rem 0 1.25rem;
  color: var(--am-text-2);
}

.site-status strong {
  color: var(--am-text);
  font-weight: 650;
}

.site-status .signal {
  margin-right: 0.625rem;
  vertical-align: 0.05em;
}

.site-cta {
  --bs-btn-font-size: 1rem;
  --bs-btn-padding-x: 1.375rem;
  --bs-btn-padding-y: 0.625rem;
  --bs-btn-border-radius: 10px;
}

/* A three-aspect signal held at caution: not open yet. */
.signal {
  --head: var(--am-text);
  display: inline-flex;
  flex: none;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--head);
}

[data-bs-theme="dark"] .signal {
  --head: var(--am-field);
  box-shadow: inset 0 0 0 1px var(--am-border-strong);
}

.signal i {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--am-text-3) 45%, var(--head));
}

.signal i:nth-child(2) {
  background: var(--am-warn);
  box-shadow: 0 0 6px var(--am-warn);
}

/* Everything the railway runs through: the hero and the sections under it,
   down to the end of the line. The layer over it all is where
   line_controller draws the track the server doesn't (the branch and the
   right line) and the signals, and where the trains run once they're moving;
   it clips them at the page's edges. Every track, the main line's and the
   drawn ones, is --line-track wide, so a train is one size wherever it goes. */
.site-lines {
  --line-track: clamp(2.25rem, 4vw, 3.75rem);
  position: relative;
  overflow: clip;
}

.line-layer {
  --track: var(--line-track);
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.line-map {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
}

.line-sleepers { stroke: var(--am-border-strong); }
.line-rails { stroke: var(--am-text-3); }

/* A colour-light signal by the line, seen from above: three lamps, one lit.
   Red while the block it protects is occupied, amber while the one after it
   is, green when both are clear. line_controller places it, turned to face
   the way its trains run (+x here is the direction of travel), and sets
   data-aspect.

   So it's plain which track it's for and which way it faces: a post runs
   from its own track out to the head (--reach), the head comes to a point
   the way the trains go, and the lit lamp's light falls back along the
   line, towards the train it's speaking to. .lineside is a point at the
   head's centre; everything is drawn round it. */
.lineside {
  --head: var(--am-text);
  --aspect: transparent;
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
}

[data-bs-theme="dark"] .lineside {
  --head: var(--am-field);
}

.lineside[data-aspect="danger"] { --aspect: var(--am-danger); }
.lineside[data-aspect="caution"] { --aspect: var(--am-warn); }
.lineside[data-aspect="clear"] { --aspect: var(--am-ok); }

/* The post, out to the track: down (+y) for one on the driver's left, up for
   one on the right. */
.lineside::before {
  position: absolute;
  left: -1px;
  width: 2px;
  height: var(--reach);
  background: var(--am-text-3);
  content: "";
}

.lineside-left::before { top: 4px; }
.lineside-right::before { bottom: 4px; }

/* The light on the ground, back towards the oncoming train. */
.lineside::after {
  position: absolute;
  top: -7px;
  right: 12px;
  width: 30px;
  height: 14px;
  background: linear-gradient(to left, color-mix(in srgb, var(--aspect) 45%, transparent), transparent);
  clip-path: polygon(100% 34%, 0 0, 0 100%, 100% 66%);
  content: "";
}

.lineside-head {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px 2px 2px 999px;
  background: var(--head);
  translate: -50% -50%;
}

[data-bs-theme="dark"] .lineside-head {
  box-shadow: inset 0 0 0 1px var(--am-border-strong);
}

/* Its point, the way the trains run. */
.lineside-head::after {
  position: absolute;
  top: 0;
  left: 100%;
  border-block: 4.5px solid transparent;
  border-left: 5px solid var(--head);
  content: "";
}

.lineside-head i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--am-text-3) 45%, var(--head));
}

.lineside[data-aspect="danger"] i:nth-child(1),
.lineside[data-aspect="caution"] i:nth-child(2),
.lineside[data-aspect="clear"] i:nth-child(3) {
  background: var(--aspect);
  box-shadow: 0 0 5px var(--aspect);
}

/* Off the page: where line_controller measures routes. */
.line-ruler {
  position: absolute;
  width: 0;
  height: 0;
  visibility: hidden;
}

/* The line: a bed, edge to edge, with four tracks on it, and room between
   them for the signals. It takes the hero's columns (subgrid) so the watch
   post can stand over the log's column. */
.line {
  --ms-length: clamp(0.55px, 0.11vw, 1.6px);
  position: relative;
  grid-area: line;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: 1.5rem;
  margin-top: 1.75rem;
  padding-block: 1.5rem;
  border-block: 1px solid var(--am-border);
  background: color-mix(in srgb, var(--am-surface) 70%, transparent);
}

@media (min-width: 992px) {
  .line {
    margin-top: clamp(0.875rem, 1.8vw, 1.25rem);
  }
}

/* Sleepers, then two rails on top of them. */
.track {
  --track: 2.75rem;
  --gauge: calc(var(--track) * 0.41);
  --rail: 3px;
  position: relative;
  height: var(--track);
  overflow: hidden;
}

.line > .track {
  --track: var(--line-track);
  grid-column: 1 / -1;
}

.line > .track-down-fast { grid-row: 1; }
.line > .track-up-fast { grid-row: 2; }
.line > .track-up-slow { grid-row: 3; }
.line > .track-down-slow { grid-row: 4; }

.track::before,
.track::after {
  position: absolute;
  inset-inline: 0;
  content: "";
}

.track::before {
  inset-block: 0;
  background: repeating-linear-gradient(90deg, var(--am-border-strong) 0 calc(var(--track) * 0.12), transparent calc(var(--track) * 0.12) calc(var(--track) * 0.5));
}

.track::after {
  top: 50%;
  height: calc(var(--gauge) + 2 * var(--rail));
  border-block: var(--rail) solid var(--am-text-3);
  transform: translateY(-50%);
}

/* A train, seen from above. It waits off the edge of the page until it's
   placed: by --at (and --back) for one standing on the line, by
   line_controller once it's moving. Every train is built facing east; the
   westbound track turns its trains round. Inside a train 1em is the train's
   width across the track, so every detail below is drawn in ems and scales
   with it.

   There are two kinds, and neither carries anything the other would: an
   intercity express (a request) is a cab at each end with coaches between,
   a freight train (a job) a diesel and wagons. Either way every vehicle
   behind the engine is the same length (--car), so a span that took longer
   fills more of them rather than a longer one. */
.train {
  --car: 1.85em;
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 1;
  font-size: calc(var(--track) * 0.64);
  translate: 0 -50%;
  /* --at is where its left end stands, as a share of the page's width; with
     --back: 1 it's where its right end does. */
  transform: translateX(calc(var(--at, -1) * 100vw - var(--back, 0) * 100%));
  will-change: transform;
}

/* What's drawn behind the vehicles shows in the gaps between them: for a
   freight train, the couplings. */
.train-body {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  gap: 0.12em;
  align-items: center;
  height: 1em;
  background: linear-gradient(var(--am-text-3), var(--am-text-3)) center / 100% 0.07em no-repeat;
}

/* An express is close-coupled, with a gangway from each coach to the next.
   It stops short of both ends, which are noses. */
.train-passenger .train-body {
  gap: 0.06em;
  background: linear-gradient(var(--am-text-3), var(--am-text-3)) center / calc(100% - 3.2em) 0.58em no-repeat;
}

.track-west .train-body {
  transform: scaleX(-1);
}

/* A train once it's moving: line_controller places each vehicle on its own
   (and the headlamp's beam ahead of it), so the train can bend round a
   curve. The vehicles stay what they were; only the flex row goes. */
.train.is-running {
  top: 0;
  translate: none;
  transform: none;
}

.train.is-running .train-body {
  position: static;
  display: block;
  height: 0;
  background: none;
  transform: none;
}

.train.is-running .train-body::after {
  content: none;
}

.train.is-running .carriage,
.train-lamp {
  position: absolute;
  top: 0;
  left: 0;
}

.train-lamp {
  display: none;
  width: 3.2em;
  height: 1.54em;
}

[data-bs-theme="dark"] .train.is-running .train-lamp {
  display: block;
  background: linear-gradient(90deg, color-mix(in srgb, var(--am-warn) 42%, transparent), transparent);
  clip-path: polygon(0 36%, 100% 0, 100% 100%, 0 64%);
}

/* In the dark, a headlamp on the track ahead. */
[data-bs-theme="dark"] .train-body::after {
  position: absolute;
  top: -0.27em;
  bottom: -0.27em;
  left: calc(100% - 0.12em);
  width: 3.2em;
  background: linear-gradient(90deg, color-mix(in srgb, var(--am-warn) 42%, transparent), transparent);
  clip-path: polygon(0 36%, 100% 0, 100% 100%, 0 64%);
  content: "";
}

/* Anything on rails. Behind the engine, each vehicle carries one span, or
   part of a long one: its colour is the span's kind (--span, as in the trace
   waterfall). */
.carriage {
  position: relative;
  display: block;
  flex: none;
  width: var(--car);
  height: 1em;
  overflow: hidden;
  border-radius: 0.14em;
  background-color: var(--span);
  box-shadow: inset 0 0 0 1px var(--train-shade);
}

/* The express. The whole train is in one livery (--livery, the colour of a
   request) under one pale roof, so it reads as a set; what differs from coach
   to coach is the band down each side, which is the span's colour. */
.coach,
.engine-passenger {
  --livery: var(--chart-1);
  --side: 21%;
  --roof:
    linear-gradient(var(--span) 0 var(--side), transparent var(--side) calc(100% - var(--side)), var(--span) calc(100% - var(--side))),
    linear-gradient(var(--train-light), var(--train-light)),
    var(--livery);
}

/* A coach: air-conditioning pods along the roof, and doors at both ends. */
.coach {
  border-radius: 0.16em;
  background:
    linear-gradient(var(--train-shade), var(--train-shade)) 0.2em 0 / 0.16em var(--side) no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) 0.2em 100% / 0.16em var(--side) no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) calc(100% - 0.2em) 0 / 0.16em var(--side) no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) calc(100% - 0.2em) 100% / 0.16em var(--side) no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) 28% 50% / 0.44em 0.24em no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) 72% 50% / 0.44em 0.24em no-repeat,
    var(--roof);
}

/* Its cab car, one at each end: a long nose with the windscreen wrapped
   round it, the coaches' roof carried through, a pantograph behind the cab,
   and a pair of lamps: white at the front, red at the back. */
.engine-passenger {
  --lamp: var(--train-lamp);
  width: 2.5em;
  border-radius: 0.16em 1.3em 1.3em 0.16em / 0.16em 0.5em 0.5em 0.16em;
  background:
    linear-gradient(var(--train-shade), var(--train-shade)) 0.2em 0 / 0.16em var(--side) no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) 0.2em 100% / 0.16em var(--side) no-repeat,
    var(--roof);
}

.engine-rear {
  --lamp: var(--am-danger);
  transform: scaleX(-1);
}

.engine-passenger::after {
  position: absolute;
  top: 50%;
  right: 0.15em;
  width: 0.1em;
  height: 0.38em;
  translate: 0 -50%;
  background:
    radial-gradient(circle closest-side, var(--lamp) 0 76%, transparent 84%) top / 100% 0.1em no-repeat,
    radial-gradient(circle closest-side, var(--lamp) 0 76%, transparent 84%) bottom / 100% 0.1em no-repeat;
  content: "";
}

.engine-roof,
.engine-cab {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

.engine-passenger .engine-cab {
  right: 0.36em;
  width: 0.5em;
  height: 0.56em;
  border-radius: 0.08em 0.32em 0.32em 0.08em / 0.08em 0.28em 0.28em 0.08em;
  background: var(--train-glass);
}

.engine-passenger .engine-roof {
  left: 0.52em;
  width: 0.6em;
  height: 0.46em;
  border: 0.05em solid var(--train-shade);
  border-radius: 0.05em;
  background: linear-gradient(90deg, transparent 42%, var(--train-shade) 42% 58%, transparent 58%);
}

/* The freight train. Its engine: a diesel. Square-shouldered, a long hood
   with radiator fans and a walkway down each side, the cab across the full
   width near the front. (The roof gear and the cab are the two parts inside
   an engine: MarketingHelper#line_engine.) */
.engine-freight {
  width: 2.4em;
  border-radius: 0.1em 0.24em 0.24em 0.1em;
}

.engine-freight .engine-roof {
  right: 0.86em;
  left: 0.12em;
  height: 0.64em;
  border-radius: 0.05em;
  background:
    radial-gradient(circle closest-side, var(--train-shade) 0 34%, transparent 36% 60%, var(--train-shade) 62% 78%, transparent 80%) 0.06em 50% / 0.48em 0.48em repeat-x,
    linear-gradient(var(--train-shade), var(--train-shade));
}

.engine-freight .engine-cab {
  right: 0.34em;
  width: 0.44em;
  height: 0.86em;
  border-radius: 0.05em;
  background:
    linear-gradient(90deg, transparent 56%, var(--train-glass) 56% 86%, transparent 86%),
    linear-gradient(var(--train-light), var(--train-light));
}

/* A query: a tanker. A barrel, so dark at the edges with a streak of light
   along it, banded, with the filler dome on top. */
.wagon-tank {
  height: 0.8em;
  border-radius: 0.4em;
  background:
    radial-gradient(circle at center, var(--train-light) 0 0.1em, var(--train-shade) 0.11em 0.15em, transparent 0.16em),
    linear-gradient(90deg, transparent 0.44em, var(--train-shade) 0.44em 0.5em, transparent 0.5em calc(100% - 0.5em), var(--train-shade) calc(100% - 0.5em) calc(100% - 0.44em), transparent calc(100% - 0.44em)),
    linear-gradient(var(--train-shade) 0%, transparent 28%, var(--train-light) 42%, transparent 58%, var(--train-shade) 100%),
    var(--span);
}

/* A view: a covered van. The roof is ribbed from side to side, with a ridge
   along the middle. */
.wagon-van {
  height: 0.92em;
  border-radius: 0.07em;
  background:
    linear-gradient(transparent 44%, var(--train-light) 44% 56%, transparent 56%),
    repeating-linear-gradient(90deg, transparent 0 0.21em, var(--train-shade) 0.21em 0.25em),
    linear-gradient(var(--train-shade) 0%, transparent 24%, transparent 76%, var(--train-shade) 100%),
    var(--span);
}

/* A call to another service: two containers on a flat wagon. Corrugated
   tops, one box a shade darker, the wagon showing at the ends and between. */
.wagon-container {
  --deck: 0.09em;
  height: 0.86em;
  border-radius: 0.05em;
  background:
    repeating-linear-gradient(90deg, transparent 0 0.1em, var(--train-shade) 0.1em 0.13em) center / calc(100% - 2 * var(--deck)) 100% no-repeat,
    linear-gradient(var(--train-shade), var(--train-shade)) calc(100% - var(--deck)) 0 / calc(50% - var(--deck) - 0.03em) 100% no-repeat,
    linear-gradient(90deg, transparent calc(50% - 0.03em), var(--am-text-3) calc(50% - 0.03em) calc(50% + 0.03em), transparent calc(50% + 0.03em)),
    linear-gradient(var(--span), var(--span)) center / calc(100% - 2 * var(--deck)) 100% no-repeat,
    var(--am-text-3);
}

/* The exception a train ended on. An express that raised has a red tail cab,
   in warning stripes; a freight train gets one more wagon, the same. */
.carriage.is-failed {
  --span: var(--am-danger);
  --livery: var(--am-danger);
}

.carriage.is-failed:not(.engine) {
  background: var(--span);
}

.carriage.is-failed::before {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 0.13em, var(--train-shade) 0.13em 0.26em);
  content: "";
}

[data-bs-theme="dark"] .train .is-failed {
  box-shadow: inset 0 0 0 1px var(--train-shade), 0 0 0.6em color-mix(in srgb, var(--am-danger) 70%, transparent);
}

/* Where Railfan stands: its mark at the lineside, and a sightline across all
   four tracks and down to the log. */
.watch-post {
  position: relative;
  z-index: 2;
  grid-row: 1 / span 4;
  grid-column: 2;
  justify-self: start;
  width: 0;
  margin-left: 1.75rem;
}

@media (min-width: 992px) {
  .watch-post {
    grid-column: 3;
  }
}

.watch-post::before {
  position: absolute;
  top: -1rem;
  bottom: calc(-1rem - var(--drop));
  left: -1px;
  border-left: 2px dashed var(--am-accent);
  content: "";
}

.watch-mark {
  position: absolute;
  top: -1rem;
  left: 0;
  width: 2rem;
  height: 2rem;
  transform: translate(-50%, -50%);
}

.watch-mark .brand-mark {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 25%;
  box-shadow: 0 0 0 3px var(--am-bg);
}

.watch-ring {
  position: absolute;
  inset: 0;
  border-radius: 25%;
  background: var(--am-accent);
  opacity: 0;
}

.watch-post.is-spotting .watch-ring {
  animation: beacon-ping 0.9s cubic-bezier(0, 0, 0.2, 1);
}

/* The log: what just went past the post, newest first, each set out the way
   the app lists a request. */
.spotted {
  grid-area: log;
  align-self: start;
  margin-top: var(--drop);
  overflow: hidden;
  border: 1px solid var(--am-border);
  border-radius: 14px;
  background: var(--am-surface);
  box-shadow: var(--am-shadow-pop);
}

.spotted-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.375rem 0.5rem 0.375rem 1.125rem;
  border-bottom: 1px solid var(--am-border);
}

.spotted-title {
  margin: 0;
  font-family: var(--site-display);
  font-stretch: var(--site-display-stretch);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* None of it is anyone's real traffic. */
.spotted-note {
  margin-right: auto;
  color: var(--am-text-3);
  font-size: 0.78125rem;
}

.spotted-toggle {
  width: 2rem;
  height: 2rem;
}

.spotted-rows {
  --row: 3.375rem;
  height: calc(5 * var(--row));
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

/* Two lines: what ran, and under it how it came in. The time, the status,
   the bar and the duration stand beside both. */
.spotted-row {
  display: grid;
  grid-template-columns: 4.125rem minmax(0, 1fr) auto 4.5rem 3.5rem;
  grid-template-areas:
    "time name status bar took"
    "time via status bar took";
  gap: 0.125rem 0.75rem;
  align-content: center;
  align-items: center;
  height: var(--row);
  padding-inline: 1.125rem;
  overflow: hidden;
  border-bottom: 1px solid var(--am-border);
  font-size: 0.8125rem;
}

.spotted-time {
  grid-area: time;
  color: var(--am-text-3);
}

.spotted-name {
  grid-area: name;
  line-height: 1.3;
}

.spotted-via {
  grid-area: via;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
  color: var(--am-text-3);
  line-height: 1.3;
}

.spotted-via .truncate {
  flex: 0 1 auto;
  font-size: 0.75rem;
}

.spotted-via .badge {
  flex: none;
  padding: 0.08em 0.55em;
  font-size: 0.6875rem;
}

.spotted-status {
  grid-area: status;
}

.spotted-status .badge {
  padding: 0.2em 0.6em;
}

/* Where the time went, in the spans' colours; its share of the column is its
   share of the slowest sample's time. */
.spotted-bar {
  grid-area: bar;
  display: flex;
  gap: 1px;
  width: calc(var(--share) * 100%);
  height: 0.5rem;
}

.spotted-bar i {
  flex: var(--ms) 0 0;
  min-width: 2px;
  border-radius: 2px;
  background: var(--span);
}

.spotted-ms {
  grid-area: took;
  color: var(--am-text-2);
  text-align: right;
}

.spotted-row.is-error .spotted-ms {
  color: var(--am-danger-ink);
}

@media (max-width: 575.98px) {
  .spotted-row {
    grid-template-columns: minmax(0, 1fr) auto 3.25rem;
    grid-template-areas:
      "name status took"
      "via status took";
    column-gap: 0.625rem;
    padding-inline: 0.875rem;
  }

  .spotted-time,
  .spotted-bar {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .spotted-row.is-new {
    animation: spotted-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), spotted-lit 1.8s ease-out;
  }
}

@keyframes spotted-in {
  from { height: 0; opacity: 0; }
}

@keyframes spotted-lit {
  from { background: var(--am-accent-soft); }
}

/* Below the hero */

.site-section {
  margin-top: clamp(4.5rem, 11vw, 8.5rem);
}

.site-heading {
  margin: 0;
  font-family: var(--site-display);
  font-stretch: var(--site-display-stretch);
  font-size: clamp(1.75rem, 3.7vw, 2.75rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.site-copy {
  max-width: 33rem;
  margin: 1.125rem 0 0;
  color: var(--am-text-2);
  font-size: 1.0625rem;
  line-height: 1.55;
}

/* One request taken apart: the train on its track, and under it the same
   spans as the trace page draws them. */
.site-trace {
  display: grid;
  gap: 2rem clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.site-trace .site-copy:first-child {
  margin-top: 0;
}

@media (min-width: 992px) {
  .site-trace {
    grid-template-columns: minmax(0, 23rem) minmax(0, 1fr);
  }

  .site-trace .site-heading {
    grid-column: 1 / -1;
    margin-bottom: 0.75rem;
  }
}

.trace {
  margin: 0;
  box-shadow: var(--am-shadow-pop);
}

.trace-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--am-border);
}

.trace-head .mono {
  font-size: 0.875rem;
  font-weight: 560;
}

.trace-total {
  margin-left: auto;
  color: var(--am-text-2);
  font-size: 0.875rem;
}

.trace .waterfall-row {
  padding-block: 0.4375rem;
}

@media (min-width: 768px) {
  .trace .waterfall-row {
    grid-template-columns: minmax(0, 42%) minmax(0, 1fr) 3.5rem;
  }
}

.trace .waterfall-row:last-child {
  padding-bottom: 0.875rem;
}

/* The request as a train, standing on a track that runs the width of the
   figure. It faces left, where the request starts, and its vehicles stretch
   so the train fills the track however wide that is. */
.trace-train {
  padding-block: 0.875rem;
  background: var(--am-surface-2);
}

.trace-rail {
  --track: 2.875rem;
}

.trace-rail .train {
  right: 1.25rem;
  left: 1.25rem;
  transform: none;
  will-change: auto;
}

.trace-rail .train-body {
  transform: scaleX(-1);
}

.trace-rail .train-body::after {
  content: none;
}

.trace-rail .carriage {
  flex: 1 1 0;
  width: auto;
}

.trace-rail .engine {
  flex-grow: 1.3;
}

@media (max-width: 575.98px) {
  .trace .waterfall-row {
    padding-inline: 0.875rem;
  }

  .trace-rail {
    --track: 1.875rem;
  }

  .trace-rail .train {
    right: 0.875rem;
    left: 0.875rem;
  }
}

.watch-list {
  display: grid;
  gap: 0 clamp(1.5rem, 4vw, 3rem);
  margin: clamp(1.75rem, 4vw, 2.75rem) 0 0;
}

@media (min-width: 576px) {
  .watch-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .watch-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.watch-list > div {
  padding-block: 1.25rem 1.5rem;
  border-top: 1px solid var(--am-border-strong);
}

.watch-list dt {
  margin-bottom: 0.375rem;
  font-family: var(--site-display);
  font-stretch: var(--site-display-stretch);
  font-size: 1.1875rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.watch-list dd {
  margin: 0;
  color: var(--am-text-2);
}

/* The end of the line. */
.site-end {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr) var(--gutter);
  row-gap: 2rem;
  align-items: center;
  padding-block: clamp(3rem, 8vw, 5.5rem);
  border-block: 1px solid var(--am-border);
  background: var(--am-surface);
}

.end-line {
  position: relative;
  grid-column: 1 / 3;
  width: 72%;
}

.end-text {
  grid-column: 2;
}

.end-text .site-cta {
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .site-end {
    grid-template-columns: var(--gutter) minmax(0, 5fr) minmax(0, 6fr) var(--gutter);
  }

  .end-line {
    width: auto;
    margin-right: clamp(2.5rem, 6vw, 5rem);
  }

  .end-text {
    grid-column: 3;
  }
}

/* The buffers: a red beam across the rails, with a pad facing each one. */
.buffer-stop {
  position: absolute;
  top: 50%;
  right: -0.375rem;
  z-index: 1;
  width: 0.75rem;
  height: 3rem;
  border-radius: 3px;
  background: var(--am-danger);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--am-text) 18%, transparent);
  transform: translateY(-50%);
}

.buffer-stop::before,
.buffer-stop::after {
  position: absolute;
  right: 100%;
  width: 0.4375rem;
  height: 0.625rem;
  border-radius: 2px 0 0 2px;
  background: var(--am-text-2);
  content: "";
}

.buffer-stop::before { top: 0.4375rem; }
.buffer-stop::after { bottom: 0.4375rem; }

.site-foot {
  margin-top: clamp(3rem, 7vw, 5rem);
  color: var(--am-text-2);
  font-size: 0.9375rem;
}

.site-foot-grid {
  display: grid;
  gap: 2.25rem 2rem;
}

@media (min-width: 576px) {
  .site-foot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-foot-about {
    grid-column: 1 / -1;
  }
}

@media (min-width: 992px) {
  .site-foot-grid {
    grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 0.8fr)) minmax(0, 1.2fr);
    gap: 3rem;
  }

  .site-foot-about {
    grid-column: auto;
    padding-right: 1.5rem;
  }
}

.site-foot-about .brand {
  font-size: 1.125rem;
}

.site-foot-about .brand-mark {
  width: 2rem;
  height: 2rem;
}

.site-foot-about p {
  max-width: 24rem;
  margin: 0.875rem 0 0;
}

.site-foot-about .site-foot-by {
  margin-top: 1.5rem;
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.linden {
  display: inline-flex;
  margin-top: 0.5rem;
  color: var(--am-text);
}

.linden:hover {
  color: var(--am-accent-ink);
}

.linden-logo {
  display: block;
  width: auto;
  height: 2.75rem;
}

.site-foot-title {
  margin: 0.375rem 0 0.875rem;
  color: var(--am-text);
  font-family: var(--site-display);
  font-stretch: var(--site-display-stretch);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.site-foot ul {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-foot-grid a:not(.brand, .linden) {
  color: var(--am-text-2);
  text-decoration-color: transparent;
}

.site-foot-grid a:not(.brand, .linden):hover {
  color: var(--am-text);
  text-decoration-color: currentColor;
}

.site-foot-base {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: center;
  justify-content: space-between;
  margin-top: clamp(2.25rem, 5vw, 3.25rem);
  padding-block: 1.25rem 2rem;
  border-top: 1px solid var(--am-border);
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.site-foot-base p {
  margin: 0;
}

.site-foot .site-foot-social {
  display: flex;
  gap: 0.25rem;
}

.site-foot-social a {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  color: var(--am-text-2);
  font-size: 1.0625rem;
}

.site-foot-social a:hover {
  background: var(--am-hover);
  color: var(--am-text);
}

/* ── Uptime: checks and their bar per day ─────────────────────────────────── */

.uptime-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  height: 2rem;
}

.uptime-bar {
  display: block;
  min-width: 2px;
  border-radius: 2px;
  background: var(--am-ok);
}

.uptime-bar.tone-degraded { background: var(--am-warn); }
.uptime-bar.tone-partial { background: color-mix(in oklab, var(--am-warn), var(--am-danger)); }
.uptime-bar.tone-down { background: var(--am-danger); }
.uptime-bar.tone-none { background: var(--am-border); }

.uptime-bars .uptime-bar:hover { opacity: 0.7; }

/* On a phone, the last 30 days. */
@media (max-width: 575.98px) {
  .uptime-bars .uptime-bar:nth-last-child(n + 31) { display: none; }
}

.uptime-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 1rem;
  margin-top: 0.75rem;
  color: var(--am-text-2);
  font-size: 0.8125rem;
}

.uptime-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.uptime-legend .uptime-bar {
  width: 0.5rem;
  height: 0.875rem;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-row {
  display: grid;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
}

.check-row + .check-row { border-top: 1px solid var(--am-border); }

.check-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.check-row-name {
  display: flex;
  gap: 0.625rem;
  min-width: 0;
}

.check-row-name > .bi {
  margin-top: 0.125rem;
  color: var(--am-text-3);
}

.check-row-state {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.625rem;
}

.check-row-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  font-size: 0.8125rem;
}

.check-row-figures > div {
  display: flex;
  gap: 0.375rem;
}

.check-row-figures dt {
  color: var(--am-text-3);
  font-weight: 500;
}

.check-row-figures dd {
  margin: 0;
  font-weight: 600;
}

.check-row-figures dd.is-bad { color: var(--am-danger-ink); }

.suggestion-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.suggestion-list > li {
  padding: 0.75rem 1.25rem;
}

.suggestion-list > li + li { border-top: 1px solid var(--am-border); }

.suggestion-list .form-check {
  display: flex;
  gap: 0.625rem;
  margin: 0;
  cursor: pointer;
}

.suggestion-list .form-check-input { flex-shrink: 0; margin-top: 0.25rem; }

.panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--am-border);
  background: var(--am-surface-2);
}

.form-fieldset {
  padding: 1rem;
  border: 1px solid var(--am-border);
  border-radius: 10px;
}

.form-fieldset legend {
  float: none;
  width: auto;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.kind-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kind-card {
  align-content: start;
  display: grid;
  gap: 0.375rem;
  height: 100%;
  padding: 1.125rem 1.25rem;
  color: inherit;
  text-decoration: none;
}

.kind-card:hover {
  border-color: var(--am-accent);
  color: inherit;
}

.kind-card > .bi {
  color: var(--am-accent-ink);
  font-size: 1.25rem;
}

.kind-card-name { font-weight: 600; }

.kind-card-about {
  color: var(--am-text-2);
  font-size: 0.875rem;
}

.check-row-compact { padding-block: 0.75rem; }
.check-row-compact .uptime-bars { height: 1.25rem; }

/* ── Public status pages (layouts/status) ─────────────────────────────────── */

.status-site {
  --status-accent: var(--am-accent);
  min-height: 100vh;
  border-top: 4px solid var(--status-accent);
  background: var(--am-bg);
}

.status-wrap {
  max-width: 48rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) 1rem 2rem;
}

.status-preview {
  padding: 0.5rem 1rem;
  background: var(--am-warn);
  color: #1c1400;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
}

.status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.status-head .btn .bi { margin-left: 0.375rem; }

.status-logo {
  display: block;
  max-width: 14rem;
  max-height: 2.75rem;
}

.status-name {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
  padding: 1.125rem 1.25rem;
  border-radius: 12px;
  background: var(--status-tone, var(--am-ok));
  color: #fff;
}

.status-banner h1 {
  margin: 0;
  color: inherit;
  font-size: 1.25rem;
  font-weight: 650;
}

.status-banner .bi { font-size: 1.5rem; }

.status-banner.status-operational { --status-tone: var(--am-ok); }
.status-banner.status-degraded { --status-tone: var(--am-warn); color: #1c1400; }
.status-banner.status-partial-outage { --status-tone: color-mix(in oklab, var(--am-warn), var(--am-danger)); }
.status-banner.status-major-outage { --status-tone: var(--am-danger); }
.status-banner.status-unknown { --status-tone: var(--am-text-3); }

[data-bs-theme="dark"] .status-banner { color: #0f0d16; }

.status-intro {
  margin: 0 0 1.5rem;
  color: var(--am-text-2);
}

.status-group { margin-bottom: 1.5rem; }

.status-group-name {
  margin: 0 0 0.625rem;
  font-size: 1rem;
  font-weight: 650;
}

.status-components,
.status-incidents {
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-component,
.status-incidents > li {
  display: grid;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
}

.status-component + .status-component,
.status-incidents > li + li { border-top: 1px solid var(--am-border); }

.status-component-head,
.status-incident-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.status-component-name { font-weight: 600; }

.status-component-about {
  display: block;
  color: var(--am-text-2);
  font-size: 0.875rem;
}

.status-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.status-state .beacon { align-self: center; }
.status-state.state-operational { color: var(--am-ok-ink); }
.status-state.state-degraded { color: var(--am-warn-ink); }
.status-state.state-outage { color: var(--am-danger-ink); }
.status-state.state-unknown { color: var(--am-text-3); }

.status-response {
  margin-left: 0.25rem;
  color: var(--am-text-3);
  font-weight: 500;
}

.status-component-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--am-text-3);
  font-size: 0.75rem;
}

.status-incident-when,
.status-incident-length {
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.status-incident-what { font-weight: 600; }

.status-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--am-border);
  color: var(--am-text-3);
  font-size: 0.8125rem;
}

.status-foot a { color: var(--status-accent); }
.status-site .status-head .btn-outline-secondary:hover { border-color: var(--status-accent); }

.status-logo-preview {
  max-width: 10rem;
  max-height: 2.5rem;
  padding: 0.25rem;
  border: 1px solid var(--am-border);
  border-radius: 6px;
  background: var(--am-surface-2);
}

.component-table td { vertical-align: top; }
.component-table td:first-child { width: 1%; padding-top: 0.875rem; }

.dns-table td,
.dns-table th { font-size: 0.8125rem; }
