/*
  Design rules of the monitoring:
  - calm when healthy, loud when broken: an ok item is neutral, only a
    problem gets a tinted surface and an accent, and it sorts first;
  - a state is never a color alone: every state has its own icon shape and
    a text label next to the color;
  - unknown is gray, never green;
  - numbers are tabular, so they do not jump when they refresh.
*/

/* Public Sans, the text font of the Rankacy web, for everything: plain
   and clear, as an admin should be. Variable, served from here (SIL Open
   Font License). */
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;

  /* Neutral surfaces, with the green of rankacy.com as the one accent,
     toned down so it reads as text: darkened on a light surface, softened
     on a dark one. The dark theme is gray, not the navy of the web: an
     admin is read for hours. */
  --brand: #02ea96;
  --brand-2: #c026d3;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #e8edf3;
  --border: #d5dce6;
  --border-strong: #94a3b8;
  --text: #020617;
  --text-muted: #51607a;
  --ok: #047857;
  --warning: #b45309;
  --down: #dc2626;
  --pending: #64748b;
  --light-off: #e2e8f0;
  --info: #2563eb;
  /* The color of the interface itself: navigation, headings, actions. */
  --accent: #047857;
  --accent-2: #c026d3;
  --accent-contrast: #ffffff;
  --shadow: none;
  --chart-1: #2563eb;
  --chart-2: #047857;
  --chart-3: #b45309;
  --chart-4: #c026d3;
  --chart-5: #dc2626;
  --chart-6: #0e8a94;

  --radius: 6px;
  --radius-small: 4px;
  --sidebar-width: 232px;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: var(--font);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* One shape for each state, used as a mask filled with its color. */
  --icon-ok: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.36-8.24a.75.75 0 0 0-1.22-.88L7.3 9.83 5.78 8.3a.75.75 0 0 0-1.06 1.06l2.15 2.15a.75.75 0 0 0 1.14-.09l3.35-4.66Z'/></svg>");
  --icon-warning: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M6.7 2.25c.58-1 2.02-1 2.6 0l5.2 9c.57 1-.15 2.25-1.3 2.25H2.8c-1.15 0-1.87-1.25-1.3-2.25l5.2-9ZM8 5a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 5Zm0 6.5a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z'/></svg>");
  --icon-critical: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M5.1 1h5.8L15 5.1v5.8L10.9 15H5.1L1 10.9V5.1L5.1 1Zm.62 4.72a.75.75 0 0 1 1.06 0L8 6.94l1.22-1.22a.75.75 0 1 1 1.06 1.06L9.06 8l1.22 1.22a.75.75 0 1 1-1.06 1.06L8 9.06l-1.22 1.22a.75.75 0 0 1-1.06-1.06L6.94 8 5.72 6.78a.75.75 0 0 1 0-1.06Z'/></svg>");
  --icon-unknown: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm0 1.5a5.5 5.5 0 1 1 0 11 5.5 5.5 0 0 1 0-11ZM5 7.25h6v1.5H5v-1.5Z'/></svg>");
  --icon-stale: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm0 1.5a5.5 5.5 0 1 1 0 11 5.5 5.5 0 0 1 0-11Zm-.75 2h1.5v3.19l2.03 2.03-1.06 1.06-2.47-2.47V4.5Z'/></svg>");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #20242d;
    --border: #2b303b;
    --border-strong: #4a5162;
    --text: #f1f3f5;
    --text-muted: #9aa3b2;
    --ok: #34d399;
    --warning: #fbbf24;
    --down: #f87171;
    --pending: #7c8594;
    --light-off: #2b303b;
    --info: #60a5fa;
    --accent: #34d399;
    --accent-2: #c084fc;
    --accent-contrast: #06281c;
    --shadow: none;
    --chart-1: #60a5fa;
    --chart-2: #34d399;
    --chart-3: #fbbf24;
    --chart-4: #c084fc;
    --chart-5: #f87171;
    --chart-6: #4fd1d9;
  }
}

/* The theme chosen with the button of the sidebar. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #20242d;
  --border: #2b303b;
  --border-strong: #4a5162;
  --text: #f1f3f5;
  --text-muted: #9aa3b2;
  --ok: #34d399;
  --warning: #fbbf24;
  --down: #f87171;
  --pending: #7c8594;
  --light-off: #2b303b;
  --info: #60a5fa;
  --accent: #34d399;
  --accent-2: #c084fc;
  --accent-contrast: #06281c;
  --shadow: none;
  --chart-1: #60a5fa;
  --chart-2: #34d399;
  --chart-3: #fbbf24;
  --chart-4: #c084fc;
  --chart-5: #f87171;
  --chart-6: #4fd1d9;
}

* {
  box-sizing: border-box;
}

/* A display set by a class must not bring a hidden element back. */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

/* ---- States -------------------------------------------------------- */

/* The state of an element and of what is inside it: its color and icon. */
[data-state] {
  --state: var(--pending);
  --state-icon: var(--icon-unknown);
}

[data-state="ok"] {
  --state: var(--ok);
  --state-icon: var(--icon-ok);
}

[data-state="warning"] {
  --state: var(--warning);
  --state-icon: var(--icon-warning);
}

[data-state="down"],
[data-state="critical"] {
  --state: var(--down);
  --state-icon: var(--icon-critical);
}

[data-state="stale"] {
  --state: var(--warning);
  --state-icon: var(--icon-stale);
}

/* The same for the tone of a badge, a banner, a counter, a row. */
[data-tone="ok"] {
  --tone: var(--ok);
  --tone-icon: var(--icon-ok);
}

[data-tone="warning"] {
  --tone: var(--warning);
  --tone-icon: var(--icon-warning);
}

[data-tone="down"] {
  --tone: var(--down);
  --tone-icon: var(--icon-critical);
}

[data-tone="info"] {
  --tone: var(--info);
  --tone-icon: none;
}

[data-tone="muted"] {
  --tone: var(--pending);
  --tone-icon: none;
}

.status-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  background: var(--state, var(--pending));
  -webkit-mask: var(--state-icon, var(--icon-unknown)) center / contain
    no-repeat;
  mask: var(--state-icon, var(--icon-unknown)) center / contain no-repeat;
}

/* ---- Shell --------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  padding: 20px 12px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}

.brand-name span {
  display: block;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
}

/* A pulse line on a rounded square. */
.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M6 0h12a6 6 0 0 1 6 6v12a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6V6a6 6 0 0 1 6-6Zm4.1 5.6a1 1 0 0 0-1.9.1L6.7 11H4v2h3.5a1 1 0 0 0 1-.7l.8-2.9 2.8 8a1 1 0 0 0 1.9 0l1.7-4.4H20v-2h-5a1 1 0 0 0-.9.6l-1 2.7-3-8.7Z'/></svg>")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill-rule='evenodd' d='M6 0h12a6 6 0 0 1 6 6v12a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6V6a6 6 0 0 1 6-6Zm4.1 5.6a1 1 0 0 0-1.9.1L6.7 11H4v2h3.5a1 1 0 0 0 1-.7l.8-2.9 2.8 8a1 1 0 0 0 1.9 0l1.7-4.4H20v-2h-5a1 1 0 0 0-.9.6l-1 2.7-3-8.7Z'/></svg>")
    center / contain no-repeat;
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  font-size: 0.875rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* A group starts under a line, with its name set apart from its pages. */
.nav-group + .nav-group {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.nav-label {
  padding: 0 8px 8px;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav a {
  padding: 5px 8px;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
}

.theme-toggle {
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.site-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  color: var(--text-muted);
}

.site-user button {
  flex: none;
  white-space: nowrap;
}

.site-user strong {
  color: var(--text);
  font-weight: 600;
}

.site-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

/* The navigation and what is under it; a block of its own only on a
   narrow screen, where a button opens it. */
.sidebar-menu {
  display: contents;
}

.nav-toggle {
  display: none;
}

/* The sidebar becomes a bar above the page, its pages behind "Menu". */
@media (max-width: 860px) {
  .app {
    display: block;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: auto;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .brand {
    padding: 0;
  }

  .nav-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    color: var(--text);
    cursor: pointer;
  }

  /* Three lines; a cross while the menu is open. */
  .nav-toggle-icon,
  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
  }

  .nav-toggle-icon {
    position: relative;
  }

  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    position: absolute;
    left: 0;
    content: "";
  }

  .nav-toggle-icon::before {
    top: -6px;
  }

  .nav-toggle-icon::after {
    top: 6px;
  }

  .sidebar[data-open] .nav-toggle-icon {
    background: transparent;
  }

  .sidebar[data-open] .nav-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
  }

  .sidebar[data-open] .nav-toggle-icon::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .sidebar-menu {
    display: none;
    width: 100%;
  }

  .sidebar[data-open] .sidebar-menu {
    display: block;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
    gap: 16px;
    padding: 4px 0 12px;
  }

  .nav-group + .nav-group {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .nav-label {
    padding: 0 8px 4px;
  }

  .nav a {
    padding: 7px 8px;
  }

  .sidebar-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 2px;
  }

  .site-main {
    padding: 20px 16px 40px;
  }
}

/* ---- Page ---------------------------------------------------------- */

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h3 {
  font-weight: 600;
}

section + section {
  margin-top: 40px;
}

.section-header h2 {
  margin: 0;
}

section > .section-header {
  margin-bottom: 14px;
}

.lead {
  max-width: 78ch;
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.lead:empty {
  display: none;
}

/* When the numbers of the page were loaded: a dot, how long ago, and the
   reason when they could not be. */
.checked-at {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.checked-at:empty {
  display: none;
}

.checked-at[data-state="critical"],
.checked-at[data-state="stale"] {
  padding: 3px 10px;
  background: color-mix(in srgb, var(--state) 12%, var(--surface));
  border-radius: 999px;
  color: var(--state);
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--state, var(--pending));
  border-radius: 50%;
}

/* ---- Overall status ------------------------------------------------ */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Calm when healthy: only a problem tints the surface. */
.hero[data-state="critical"],
.hero[data-state="warning"] {
  background: color-mix(in srgb, var(--state) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--state) 50%, var(--border));
}

.hero .status-icon {
  font-size: 1.75rem;
}

.hero-text {
  flex: 1;
  min-width: 200px;
}

.hero-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero-detail {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.hero-detail:empty {
  display: none;
}

/* How many checks are in each state, the worst first. */
.hero-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero-counts li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.hero-counts strong {
  color: var(--text);
  font-weight: 650;
}

/* What is wrong, the worst first: the list under the overall status. */
.issues {
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  overflow: hidden;
}

.issue {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  padding: 11px 16px 11px 18px;
  box-shadow: inset 3px 0 0 var(--state);
}

.issue + .issue {
  border-top: 1px solid var(--border);
}

.issue .status-icon {
  grid-row: span 2;
  font-size: 1.125rem;
}

.issue-title {
  margin: 0;
  font-weight: 600;
}

.issue-detail {
  grid-column: 2;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.issue-detail:empty {
  display: none;
}

.issue-side {
  display: flex;
  grid-column: 3;
  grid-row: 1 / span 2;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .issue-side .badge {
    display: none;
  }
}

/* ---- Cards --------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Many small items: services, dependencies. */
.cards-compact {
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 10px;
}

.cards-wide {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

.card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* A problem stands out and comes first; an ok card stays neutral. */
.card[data-state="warning"],
.card[data-state="stale"] {
  order: -1;
}

.card[data-state="down"],
.card[data-state="critical"] {
  order: -2;
}

.card[data-state="warning"],
.card[data-state="stale"],
.card[data-state="down"],
.card[data-state="critical"] {
  background: color-mix(in srgb, var(--state) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--state) 45%, var(--border));
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.card h3 {
  min-width: 0;
  margin: 0;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

/* The state as a pill: its icon and its name, in its color. */
.card-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  width: fit-content;
  margin: 10px 0 0;
  padding: 1px 9px 1px 7px;
  background: color-mix(in srgb, var(--state) 13%, transparent);
  border-radius: 999px;
  color: var(--state);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.card-state::before {
  width: 0.9em;
  height: 0.9em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--state-icon, var(--icon-unknown)) center / contain
    no-repeat;
  mask: var(--state-icon, var(--icon-unknown)) center / contain no-repeat;
  content: "";
}

.card-header .card-state {
  margin: 0;
}

.card-value {
  margin: 10px 0 0;
  font-size: 1.5rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.card-value:empty {
  display: none;
}

.card-detail {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.card-detail:empty {
  display: none;
}

.dot {
  width: 9px;
  height: 9px;
  flex: none;
  background: var(--state);
  border-radius: 50%;
}

/* The checks of a service, under its name. */
.service-checks {
  gap: 6px;
  margin: 10px 0 0;
}

/* Many items of one kind, as lines on one surface instead of a box each:
   the name and what is known about it, and the state at the end. */
.rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  overflow: hidden;
}

.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 12px;
  padding: 10px 16px;
  /* Lines on the right and under; the ones at the edge are clipped. A
     last row that is not full still closes the row above it. */
  box-shadow:
    1px 0 0 var(--border),
    0 1px 0 var(--border);
}

.row-item[data-state="warning"],
.row-item[data-state="stale"] {
  order: -1;
}

.row-item[data-state="down"],
.row-item[data-state="critical"] {
  order: -2;
}

.row-item[data-state="warning"],
.row-item[data-state="stale"],
.row-item[data-state="down"],
.row-item[data-state="critical"] {
  background: color-mix(in srgb, var(--state) 9%, var(--surface));
}

.row-item h3 {
  min-width: 0;
  margin: 0;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.row-item .card-detail {
  grid-column: 1;
  margin: 0;
}

.row-item .card-state {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
}

/* The numbers of the system: a line for each group on one sheet. */
.groups {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.group {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px 24px;
  padding: 16px 20px;
}

.group + .group {
  border-top: 1px solid var(--border);
}

.group h3 {
  margin: 0;
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  .group {
    grid-template-columns: 1fr;
  }
}

/* The depth of a queue over the last 7 days, under its numbers. */
.spark {
  margin-top: 10px;
}

.spark-chart {
  display: block;
  width: 100%;
  height: 48px;
}

.spark-line {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 1.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.spark-area {
  fill: var(--accent-2);
  opacity: 0.14;
}

.spark-average {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}

.spark-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.spark-dot {
  fill: var(--accent-2);
}

/* Columns side by side: the failure rate by hour, the rows by day. */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 48px;
}

.bar {
  flex: 1;
  min-width: 2px;
  min-height: 2px;
  background: var(--tone, var(--accent));
  border-radius: 2px 2px 0 0;
}

.bar[data-tone="accent"] {
  --tone: var(--accent);
}

.bar[data-tone="muted"] {
  --tone: color-mix(in srgb, var(--accent) 45%, var(--surface));
}

.bar[data-empty="true"] {
  background: var(--light-off);
}

.bar:hover {
  filter: brightness(1.25);
}

/* The states of a service hour by hour. */
.ticks {
  display: flex;
  gap: 2px;
}

.tick {
  flex: 1;
  height: 14px;
  background: var(--light-off);
  border-radius: 2px;
}

.tick[data-state] {
  background: var(--state);
}

/* Healthy hours step back, so the bad ones are what is seen. */
.tick[data-state="ok"] {
  opacity: 0.55;
}

.row-item .history {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.card .history {
  margin-top: 12px;
}

.stat dd.stat-chart {
  display: block;
  margin: 12px 0 0;
}

.stat-chart .bars {
  height: 36px;
}

.spark-cell {
  width: 150px;
}

.spark-cell .spark-chart {
  height: 24px;
}

/* A pipeline: its failure rate and its queue, each with its own state. */
.pipeline-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 14px 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric .card-state {
  margin: 0;
}

.metric .card-value {
  margin-top: 6px;
}

.metric[data-state="warning"] .card-value,
.metric[data-state="critical"] .card-value {
  color: var(--state);
}

/* ---- Counters ------------------------------------------------------ */

.counters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  gap: 10px;
  margin: 0;
}

.counter {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.counter dt {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.counter dd {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.counter[data-tone] dd {
  color: var(--tone);
}

.counter[data-tone="warning"],
.counter[data-tone="down"] {
  background: color-mix(in srgb, var(--tone) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--tone) 45%, var(--border));
}

/* Numbers side by side, a tile each: however they wrap on a narrow
   screen, no row looks cut off. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 10px;
  margin: 0;
}

.stat {
  padding: 14px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat dt {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.stat dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 6px 0 0;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat[data-zero="true"] .stat-value {
  color: var(--text-muted);
}

.stat-delta {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-delta[data-zero="true"] {
  color: var(--text-muted);
}

/* A number that is zero steps back, so the ones that are not stand out. */
.counter[data-zero="true"] dd,
.statuses [data-zero="true"] dd {
  color: var(--text-muted);
  font-weight: 500;
}

.counter-note {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* Counters sharing the surface of a panel: the tiles lose their own. */
.counters-flat {
  grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr));
  gap: 14px 20px;
}

.counters-flat .counter {
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.counters-flat .counter[data-tone="warning"],
.counters-flat .counter[data-tone="down"] {
  margin: -6px -8px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--tone) 10%, transparent);
  border-radius: var(--radius-small);
}

.counters-flat .counter dd {
  font-size: 1.25rem;
}

/* Rows of a table by status, inside a card. */
.statuses {
  margin: 8px 0 0;
  font-size: 0.875rem;
}

.statuses > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.statuses > div + div {
  border-top: 1px solid var(--border);
}

.statuses dt {
  color: var(--text-muted);
}

.statuses dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Tables -------------------------------------------------------- */

.table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-spacing: 0;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 8px 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A long name wraps between its words; a table that is still too wide
   scrolls inside its container, it does not break a word in two. */
.table th:first-child,
.table td[colspan] {
  text-align: left;
  overflow-wrap: break-word;
}

.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table tbody th {
  font-weight: 500;
}

.table tbody th,
.table tbody td {
  border-top: 1px solid var(--border);
}

.table tbody tr:hover th,
.table tbody tr:hover td {
  background: var(--surface-2);
}

.table td {
  font-weight: 600;
}

.table td[colspan] {
  color: var(--text-muted);
  font-weight: 400;
}

.table .failed td {
  color: var(--down);
}

/* A table wider than its container scrolls inside it. */
.table-scroll {
  overflow-x: auto;
}

.table-left th,
.table-left td {
  text-align: left;
}

.table tr[data-tone] td,
.table tr[data-tone] th {
  background: color-mix(in srgb, var(--tone) 9%, transparent);
}

.table tr[data-tone] th:first-child {
  box-shadow: inset 3px 0 0 var(--tone);
}

.table tbody tr.clickable {
  cursor: pointer;
}

.table tbody tr.clickable:hover th,
.table tbody tr.clickable:hover td {
  background: var(--surface-2);
}

.table .badge {
  margin-left: 8px;
}

/* Rows by status: a line for each table, its shares as a bar. */
[data-bucket="waiting"] {
  --bucket: var(--info);
}

[data-bucket="working"] {
  --bucket: var(--accent-2);
}

[data-bucket="done"] {
  --bucket: var(--ok);
}

[data-bucket="failed"] {
  --bucket: var(--down);
}

[data-bucket="other"] {
  --bucket: var(--pending);
}

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  background: var(--bucket);
  border-radius: 2px;
}

.status-table .dist-column {
  width: 28%;
  min-width: 140px;
}

.dist {
  display: flex;
  gap: 2px;
  height: 8px;
  background: var(--light-off);
  border-radius: 4px;
  overflow: hidden;
}

.dist span {
  background: var(--bucket);
}

.status-table td[data-zero="true"] {
  color: var(--text-muted);
  font-weight: 400;
}

.expand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.expand::before {
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  content: "";
}

.expand[aria-expanded="true"]::before {
  transform: rotate(45deg);
}

.table .status-detail td {
  padding: 4px 16px 14px 30px;
  border-top: 0;
  color: var(--text);
}

.table .status-detail:hover td {
  background: none;
}

.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.status-chips > div {
  display: flex;
  gap: 8px;
  padding: 2px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 0.8125rem;
}

.status-chips dt {
  color: var(--text-muted);
}

.status-chips dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.status-chips [data-zero="true"] dd {
  color: var(--text-muted);
  font-weight: 400;
}

/* ---- Login --------------------------------------------------------- */

.guest .site-main {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login .brand {
  margin-bottom: 24px;
  padding: 0;
}

.login-hint {
  margin: 4px 0 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form label {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 600;
}

.form input {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text);
  font: inherit;
}

.form button {
  margin-top: 16px;
  padding: 9px 12px;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-small);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.form-error {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--down) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--down) 50%, var(--border));
  border-radius: var(--radius-small);
  color: var(--down);
  font-size: 0.875rem;
  font-weight: 600;
}

.login-back {
  display: inline-block;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---- Controls ------------------------------------------------------ */

/* Controls of a page or of a section: selects, inputs, buttons. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.toolbar label,
.field label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input,
select,
.toolbar input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.field textarea,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
  min-height: 34px;
  padding: 5px 10px;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}

.input:hover,
select:hover,
.toolbar input:hover,
.field textarea:hover,
.field input:hover {
  border-color: var(--text-muted);
}

.input:focus-visible,
select:focus-visible,
.toolbar input:focus-visible,
.field textarea:focus-visible,
.field input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  outline: none;
}

.input::placeholder,
.field input::placeholder,
.toolbar input::placeholder {
  color: var(--pending);
}

/* A select draws its own arrow, the same in every browser. The filter
   that only looks like one (.dropdown) gets it too. */
select:not([multiple]),
.dropdown > summary {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='m4 6 4 4 4-4'/></svg>");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 14px;
  cursor: pointer;
}

select:not([multiple]) {
  -webkit-appearance: none;
  appearance: none;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: ellipsis;
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* Fields of a form side by side, wrapping. */
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 12px 16px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.875rem;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 400;
}

.button,
.button-plain {
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.button:hover {
  opacity: 0.88;
}

.button-danger {
  background: var(--down);
  border-color: var(--down);
  color: #ffffff;
}

.button-plain {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.button-plain:hover {
  background: var(--surface-2);
}

.button:disabled,
.button-plain:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-plain[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--text-muted);
  font-weight: 600;
}

/* Switch between the views of a page: a row of buttons, one pressed. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented button {
  padding: 4px 12px;
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel > h3 {
  margin: 0 0 12px;
  font-size: 0.9375rem;
}

.panel + .panel {
  margin-top: 12px;
}

/* Panels side by side. */
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 12px;
}

.columns > .panel + .panel {
  margin-top: 0;
}

/* Message above the page: what went wrong, or what was done. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--tone, var(--ok)) 11%, var(--surface));
  border: 1px solid
    color-mix(in srgb, var(--tone, var(--ok)) 50%, var(--border));
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.banner::before,
.form-error::before {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  margin-top: 0.15em;
  background: var(--tone, var(--ok));
  -webkit-mask: var(--tone-icon, var(--icon-ok)) center / contain no-repeat;
  mask: var(--tone-icon, var(--icon-ok)) center / contain no-repeat;
  content: "";
}

.form-error::before {
  background: var(--down);
  -webkit-mask-image: var(--icon-critical);
  mask-image: var(--icon-critical);
}

.banner[data-tone="info"]::before,
.banner[data-tone="muted"]::before {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  background: color-mix(in srgb, var(--tone, var(--pending)) 14%, transparent);
  border-radius: 999px;
  color: var(--tone, var(--pending));
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* The tones that judge get their shape, so they are not a color alone. */
.badge[data-tone="ok"]::before,
.badge[data-tone="warning"]::before,
.badge[data-tone="down"]::before {
  width: 0.9em;
  height: 0.9em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--tone-icon) center / contain no-repeat;
  mask: var(--tone-icon) center / contain no-repeat;
  content: "";
}

.meter {
  display: block;
  height: 6px;
  min-width: 60px;
  background: var(--light-off);
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  display: block;
  height: 100%;
  background: var(--tone, var(--info));
  border-radius: 3px;
}

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

.muted {
  color: var(--text-muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pagination div {
  display: flex;
  gap: 6px;
}

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.3);
  color: var(--text);
}

.dialog-wide {
  width: min(960px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1rem;
}

.dialog-header h2::before {
  display: none;
}

.dialog-body {
  padding: 16px;
  overflow-wrap: anywhere;
}

.dialog-body > :first-child {
  margin-top: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* ---- Charts -------------------------------------------------------- */

.chart-frame {
  position: relative;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-line-dashed {
  stroke-dasharray: 5 4;
}

.chart-area {
  opacity: 0.12;
}

.chart-column {
  opacity: 0.85;
}

.chart-reference {
  stroke: var(--info);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}

.chart-reference-label {
  fill: var(--info);
}

.chart-guide {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 8px 0 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  list-style: none;
}

.chart-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-empty {
  margin: 0;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}

.bar-list {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr max-content;
  align-items: center;
  gap: 6px 12px;
  margin: 0;
  padding: 0;
  font-size: 0.875rem;
  list-style: none;
}

.bar-list li {
  display: contents;
}

.bar-label {
  overflow-wrap: anywhere;
}

.bar-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---- Management dashboard ------------------------------------------ */

/* More or less than before. More is the accent, less a warning: on this
   dashboard everything counted is something we want more of. */
.stat-delta[data-trend="down"] {
  color: var(--warning);
}

.stat-delta[data-trend="flat"] {
  color: var(--text-muted);
}

.kpis .stat-value {
  font-size: 2rem;
}

/* The number a card is about. */
.delivery-rate {
  margin: 10px 0 0;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.delivery-unit {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
}

.delivery-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.delivery-facts dt {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.delivery-facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The age of the oldest row, under the number of the waiting ones. */
.delivery-facts .counter-note {
  display: block;
  margin: 0;
  font-weight: 400;
}

.delivery .spark,
.trend .spark {
  margin-top: 12px;
}

.totals-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 24px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.totals-line strong {
  color: var(--text);
  font-weight: 600;
}

/* Sections a script fills in, between the sections of the page. */
section + .sections,
.sections + section {
  margin-top: 40px;
}

.text-down {
  color: var(--down);
}

/* Today and the subscriptions: two sections of one band. */
.band {
  display: grid;
  gap: 40px;
  margin-top: 40px;
}

.band > section {
  margin-top: 0;
  min-width: 0;
}

.management .cards-wide {
  grid-template-columns: 1fr;
}

@media (min-width: 1180px) {
  .management .cards-wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Two numbers in a row on a phone, so five of them are not a column. */
@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 12px 14px 14px;
  }

  .kpis .stat-value,
  .delivery-rate {
    font-size: 1.75rem;
  }

  section + section,
  .band,
  .band + section,
  section + .sections,
  .sections + section {
    margin-top: 28px;
  }

  .band {
    gap: 28px;
  }
}

.band + section {
  margin-top: 40px;
}

/* On a wall: no navigation, the whole width, type that scales with the
   screen so the page fills a 1080p display without scrolling. */
html:has(body.tv) {
  font-size: clamp(13px, 0.78vw, 22px);
}

.app.tv {
  display: block;
}

.tv .sidebar {
  display: none;
}

.tv .site-main {
  max-width: none;
  padding: 16px 32px 16px;
}

.tv .management > .section-header {
  margin-bottom: 12px;
}

/* Nobody reads the introduction twice, and the list says what it is. */
.tv .management .lead,
.tv #attention > h2 {
  display: none;
}

.tv .management section + section,
.tv .management .band,
.tv .management .band + section {
  margin-top: 14px;
}

.tv .management .band {
  grid-template-columns: 5fr 4fr;
  gap: 16px;
}

.tv .management .cards-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tv .management .totals-line {
  margin-top: 12px;
}

/* Shorter charts and a tighter overall state leave room for the list of
   problems. */
.tv .management .spark-chart,
.tv .management .bars {
  height: 32px;
}

.tv .management .hero {
  padding-top: 10px;
  padding-bottom: 10px;
}

.tv .management .delivery-facts {
  margin-top: 8px;
  padding-top: 8px;
}

.tv .management .delivery .spark,
.tv .management .trend .spark {
  margin-top: 8px;
}

/* ---- Narrow screens ------------------------------------------------- */

/* What sits in a grid or next to something may shrink under its content,
   and a control is never wider than what holds it: a long option or a
   long word wraps or is cut, it does not push the page sideways. */
.columns > *,
.cards > *,
.fields > *,
.counters > *,
.field,
.panel {
  min-width: 0;
}

select,
input,
textarea {
  max-width: 100%;
}

/* A select with a long option next to its label, in the controls of a
   page: it shrinks and cuts the option instead of leaving the screen. */
.toolbar,
.toolbar label {
  min-width: 0;
  max-width: 100%;
}

.toolbar select {
  min-width: 0;
  flex: 0 1 auto;
}

.field > select,
.field > textarea {
  width: 100%;
}

/* A bar with its label above it, not squeezed next to it. */
@media (max-width: 560px) {
  .bar-list {
    grid-template-columns: minmax(0, 1fr) max-content;
  }

  .bar-label {
    grid-column: 1 / -1;
    margin-top: 6px;
  }

  .range-spread {
    display: block;
    margin-left: 0;
  }
}
