/* AVO Backup-Portal, stylesheet.
 *
 * DESIGN BRIEF
 * ------------
 * This is an instrument panel, not a product page. People open it when a backup
 * did not happen, often at a bad moment, and the screen has to be readable at a
 * glance from two metres. Everything here follows from that:
 *
 * 1. The chrome is achromatic. The only saturated colour in the whole interface
 *    is status. A coloured button would compete with a failing machine for the
 *    same attention, so buttons are ink and status is colour.
 * 2. State is encoded three times over: colour, a glyph, and the German word.
 *    Any one of them alone carries the meaning.
 * 3. The mono face carries what this portal is actually made of, which is
 *    hostnames, snapshot IDs, byte counts and cron lines. Prose gets the sans
 *    face. There is no web font: no build step, no CDN, and an operations tool
 *    has to render before the network is healthy.
 * 4. The signature element is the run history strip. A row of solid bars is
 *    calm; a broken bar is the first thing the eye lands on.
 *
 * Only the ASCII hyphen is used in this file (baseline section 11).
 */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  /* Type */
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", "JetBrains Mono",
    "Cascadia Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  --fs-micro: 0.6875rem;
  --fs-small: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.9375rem;

  /* Space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  --radius-sm: 3px;
  --radius: 5px;
  --radius-lg: 8px;

  --measure: 62ch;
  --page-max: 1360px;

  /* Neutrals, light. The page is a cool grey panel so that the white cards on
   * it read as instruments sitting on a surface, not as holes in a white page. */
  --bg-page: #eceef1;
  --bg-raised: #ffffff;
  --bg-sunken: #e1e5e9;
  --bg-inset: #f5f6f8;
  --bg-bar: #191d21;
  --bg-bar-text: #e7eaed;
  --bg-bar-muted: #97a1aa;

  --border: #ccd2d8;
  --border-strong: #a4aeb7;
  --text: #14181c;
  --text-muted: #57616b;
  --text-faint: #78828c;
  --text-inverted: #f4f6f8;

  /* Ink is the interactive colour. It is deliberately not a hue: reserving
   * saturation for status is the central rule of this interface. */
  --ink: #1f252b;
  --ink-hover: #363f48;
  --link: #1f252b;

  /* The focus ring is the one colour that appears nowhere else, so it can never
   * be confused with a status. */
  --focus: #6d2fd6;

  /* Status. Each has a foreground for text, a background for the tint, and a
   * line colour for the rail and the history bars. */
  --st-ok-fg: #10603a;
  --st-ok-bg: #dcefe3;
  --st-ok-line: #2c8f5f;

  --st-overdue-fg: #7a4700;
  --st-overdue-bg: #f8e9cf;
  --st-overdue-line: #bd820b;

  --st-failed-fg: #8f1119;
  --st-failed-bg: #fadedd;
  --st-failed-line: #cc3630;

  --st-never-fg: #364552;
  --st-never-bg: #e0e6eb;
  --st-never-line: #66798a;

  --st-disabled-fg: #5b646e;
  --st-disabled-bg: #e6e9ec;
  --st-disabled-line: #949ea8;

  --shadow-card: 0 1px 2px rgba(15, 22, 29, 0.06), 0 1px 1px rgba(15, 22, 29, 0.04);
  --shadow-lift: 0 8px 28px rgba(15, 22, 29, 0.18);
}

/* Dark is not an inversion. The panel gets darker than the cards so the same
 * "instruments on a surface" reading survives, and the status tints are muted
 * far more than their light counterparts, because a saturated block on a dark
 * ground glares. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #101317;
    --bg-raised: #1a1e23;
    --bg-sunken: #0b0e11;
    --bg-inset: #21262c;
    --bg-bar: #05070a;
    --bg-bar-text: #dfe4e9;
    --bg-bar-muted: #7d8791;

    --border: #2b3138;
    --border-strong: #414b55;
    --text: #e6eaee;
    --text-muted: #9aa4ae;
    --text-faint: #79838d;
    --text-inverted: #12161a;

    --ink: #dfe4e9;
    --ink-hover: #ffffff;
    --link: #cfd6dd;

    --focus: #b18cff;

    --st-ok-fg: #6fd39d;
    --st-ok-bg: #13291f;
    --st-ok-line: #3ea272;

    --st-overdue-fg: #efba5f;
    --st-overdue-bg: #2b2313;
    --st-overdue-line: #c2902b;

    --st-failed-fg: #ff8f86;
    --st-failed-bg: #331819;
    --st-failed-line: #d3554d;

    --st-never-fg: #a8b5c1;
    --st-never-bg: #1c2229;
    --st-never-line: #6a7885;

    --st-disabled-fg: #8b959f;
    --st-disabled-bg: #1a1e22;
    --st-disabled-line: #59626b;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 8px 28px rgba(0, 0, 0, 0.6);
  }
}

/* -------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure,
pre {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

code {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.35em;
}

.wrap {
  overflow-wrap: anywhere;
}

/* One focus treatment for everything. It is thick, offset, and in a colour
 * that means nothing else in this interface. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skiplink {
  position: absolute;
  left: var(--sp-3);
  top: -3rem;
  z-index: 50;
  background: var(--bg-raised);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-4);
  transition: top 120ms ease-out;
}

.skiplink:focus {
  top: var(--sp-3);
}

/* ------------------------------------------------------------------ chrome */

.topbar {
  background: var(--bg-bar);
  color: var(--bg-bar-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--sp-5);
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: inherit;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.14em;
  font-weight: 700;
}

/* The mark is a stack of three bars: the three copies every backup has, which
 * is the one idea this whole system is built on. */
.brand-mark {
  width: 0.85rem;
  height: 0.85rem;
  flex: none;
  background:
    linear-gradient(currentColor, currentColor) top left / 100% 3px no-repeat,
    linear-gradient(currentColor, currentColor) center left / 70% 3px no-repeat,
    linear-gradient(currentColor, currentColor) bottom left / 40% 3px no-repeat;
}

.brand-word-light {
  font-weight: 400;
  color: var(--bg-bar-muted);
}

.mainnav {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-right: auto;
}

.mainnav a {
  color: var(--bg-bar-muted);
  text-decoration: none;
  font-size: var(--fs-small);
  font-family: var(--font-mono);
  padding: var(--sp-2) 0;
  border-bottom: 2px solid transparent;
}

.mainnav a:hover {
  color: var(--bg-bar-text);
}

.mainnav a[aria-current="page"] {
  color: var(--bg-bar-text);
  border-bottom-color: currentColor;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-small);
}

.scope-chip {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  color: var(--bg-bar-text);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.45rem;
}

.account-name {
  color: var(--bg-bar-muted);
}

.logout-form {
  margin: 0;
}

.topbar .btn-quiet {
  background: transparent;
  color: var(--bg-bar-muted);
  border-color: rgba(255, 255, 255, 0.22);
}

.topbar .btn-quiet:hover {
  color: var(--bg-bar-text);
  border-color: rgba(255, 255, 255, 0.45);
}

.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) var(--sp-7);
}

.page:focus {
  outline: none;
}

.body-plain .page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sitefooter {
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-faint);
  font-size: var(--fs-small);
  padding: var(--sp-4) var(--sp-5);
}

.sitefooter p {
  max-width: var(--page-max);
  margin: 0 auto;
}

/* -------------------------------------------------------------- page heads */

.breadcrumb {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

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

.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.pagehead-main {
  max-width: var(--measure);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--sp-2);
}

/* The dashboard headline is the answer, stated before the table is read. It is
 * set in the mono face at display size, which is the one typographic risk this
 * design takes: it makes the sentence read like a machine reporting, which is
 * exactly what it is. */
.lede {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: var(--sp-2);
}

.lede-alarm {
  color: var(--st-failed-fg);
}

.pagehead-sub {
  color: var(--text-muted);
  font-size: var(--fs-small);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.pagehead-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.dotsep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
  display: inline-block;
}

.sectiontitle {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-3);
}

.section {
  margin-top: var(--sp-6);
}

.subtitle {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: var(--sp-4) 0 var(--sp-2);
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.2;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--text-muted);
  background: var(--bg-inset);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--text-inverted);
}

.btn-primary:hover {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
  color: var(--text-inverted);
}

/* Destructive actions are outlined in the failure colour rather than filled
 * with it. A solid red block on this screen must only ever mean a broken
 * machine. */
.btn-danger {
  border-color: var(--st-failed-line);
  color: var(--st-failed-fg);
  background: var(--bg-raised);
}

.btn-danger:hover {
  background: var(--st-failed-bg);
  border-color: var(--st-failed-fg);
}

.btn-small {
  font-size: var(--fs-micro);
  padding: 0.3rem 0.6rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-mark {
  font-weight: 700;
}

.badge-ok {
  color: var(--st-ok-fg);
  background: var(--st-ok-bg);
  border-color: var(--st-ok-line);
}

.badge-overdue {
  color: var(--st-overdue-fg);
  background: var(--st-overdue-bg);
  border-color: var(--st-overdue-line);
}

.badge-failed {
  color: var(--st-failed-fg);
  background: var(--st-failed-bg);
  border-color: var(--st-failed-line);
}

.badge-never {
  color: var(--st-never-fg);
  background: var(--st-never-bg);
  border-color: var(--st-never-line);
}

.badge-disabled {
  color: var(--st-disabled-fg);
  background: var(--st-disabled-bg);
  border-color: var(--st-disabled-line);
  border-style: dashed;
}

.statenote {
  display: inline-block;
  margin-left: var(--sp-2);
  font-size: var(--fs-micro);
  color: var(--text-muted);
}

.novalue {
  color: var(--text-faint);
  font-style: italic;
}

/* --------------------------------------------------- filter bar and chips */

.filterbar {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filterbar-wide .field-inline {
  min-width: 9rem;
}

.filteractions {
  display: flex;
  gap: var(--sp-2);
  margin-left: auto;
}

.chipset {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  border: 0;
  padding: 0;
  margin: 0;
}

/* A chip is a real radio input with a real label. The input is hidden from
 * sight but not from the keyboard or the accessibility tree, so the whole
 * filter is operable with the arrow keys like any radio group. */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-inset);
  cursor: pointer;
}

.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chip:hover {
  border-color: var(--border-strong);
}

.chip:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chip:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--text-inverted);
}

.chip-count {
  font-weight: 700;
}

.chip-mark {
  font-weight: 700;
}

.chip-failed:has(input:not(:checked)) .chip-mark {
  color: var(--st-failed-fg);
}

.chip-overdue:has(input:not(:checked)) .chip-mark {
  color: var(--st-overdue-fg);
}

.chip-ok:has(input:not(:checked)) .chip-mark {
  color: var(--st-ok-fg);
}

.chip-never:has(input:not(:checked)) .chip-mark {
  color: var(--st-never-fg);
}

.chip-disabled:has(input:not(:checked)) .chip-mark {
  color: var(--st-disabled-fg);
}

/* ------------------------------------------------------------------ tables */

.tablewrap {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.datatable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.datatable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-raised);
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.datatable tbody th,
.datatable tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  font-weight: 400;
}

.datatable tbody tr:last-child th,
.datatable tbody tr:last-child td {
  border-bottom: 0;
}

.datatable tbody tr:hover {
  background: var(--bg-inset);
}

.col-num {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.datatable thead th.col-num {
  text-align: right;
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.systemname {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-base);
}

.systemhost {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-faint);
}

.tablelegend {
  margin-top: var(--sp-2);
  font-size: var(--fs-micro);
  color: var(--text-faint);
  max-width: var(--measure);
}

.loadmore {
  text-align: center;
  padding: var(--sp-3);
}

/* The attention rail. A four pixel bar in the status colour on the left edge of
 * the row, plus a tinted row. Together with the badge, that is three signals
 * for one fact, which is what "impossible to miss" costs. */
.row-attention > *:first-child {
  box-shadow: inset 4px 0 0 0 var(--rail, var(--border-strong));
  padding-left: calc(var(--sp-3) + 4px);
}

.row-failed {
  --rail: var(--st-failed-line);
  background: var(--st-failed-bg);
}

.row-overdue {
  --rail: var(--st-overdue-line);
  background: var(--st-overdue-bg);
}

.row-never {
  --rail: var(--st-never-line);
  background: var(--st-never-bg);
}

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

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

.datatable tbody tr.row-failed:hover,
.datatable tbody tr.row-overdue:hover,
.datatable tbody tr.row-never:hover {
  filter: brightness(0.97);
  background: var(--st-failed-bg);
}

.datatable tbody tr.row-overdue:hover {
  background: var(--st-overdue-bg);
}

.datatable tbody tr.row-never:hover {
  background: var(--st-never-bg);
}

/* --------------------------------------------------- run history strip */

.histstrip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
}

.hist {
  width: 9px;
  height: 20px;
  flex: none;
  border-radius: 1px;
}

.hist-success {
  background: var(--st-ok-line);
}

/* Failure is a slashed outline, not just a red block: the shape differs from
 * success even in a screenshot printed in grey. */
.hist-failed {
  border: 1.5px solid var(--st-failed-line);
  background-image: linear-gradient(
    to top right,
    transparent calc(50% - 1px),
    var(--st-failed-line) calc(50% - 1px),
    var(--st-failed-line) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
}

.hist-missed {
  border: 1.5px dashed var(--st-overdue-line);
  background: transparent;
}

.hist-none {
  height: 6px;
  border: 1px solid var(--border);
  background: transparent;
}

/* ------------------------------------------------------------------- cards */

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: var(--sp-4);
  align-items: start;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-card);
}

.cardtitle {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.cardintro {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  max-width: var(--measure);
}

.card-key {
  border-color: var(--st-failed-line);
}

.keyvalue {
  margin: var(--sp-2) 0;
}

.keyvalue code {
  display: block;
  font-size: var(--fs-md);
  letter-spacing: 0.04em;
  padding: var(--sp-3);
  overflow-wrap: anywhere;
  user-select: all;
}

.datalist {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-small);
}

.datalist dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  padding-top: 0.15rem;
}

.datalist dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.pathlist {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.steps {
  list-style: decimal;
  padding-left: 1.5rem;
  display: grid;
  gap: var(--sp-2);
  max-width: var(--measure);
  margin-bottom: var(--sp-4);
}

.steps li {
  padding-left: var(--sp-1);
}

.output {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.5;
}

/* --------------------------------------------------------------- callouts */

.callout {
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
  max-width: var(--measure);
}

.callout-danger {
  border-color: var(--st-failed-line);
  background: var(--st-failed-bg);
  color: var(--st-failed-fg);
}

.callouttitle {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

/* ----------------------------------------------------------------- flashes */

.flashes {
  display: grid;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.flash {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  font-size: var(--fs-small);
}

.flash-mark {
  font-family: var(--font-mono);
  font-weight: 700;
}

.flash-body {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

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

.flash-success {
  border-color: var(--st-ok-line);
  background: var(--st-ok-bg);
  color: var(--st-ok-fg);
}

.flash-warning {
  border-color: var(--st-overdue-line);
  background: var(--st-overdue-bg);
  color: var(--st-overdue-fg);
}

.flash-error {
  border-color: var(--st-failed-line);
  background: var(--st-failed-bg);
  color: var(--st-failed-fg);
}

.flash-info {
  border-color: var(--st-never-line);
  background: var(--st-never-bg);
  color: var(--st-never-fg);
}

/* ------------------------------------------------------------ empty states */

.empty {
  background: var(--bg-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
}

.empty-title {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.empty-text {
  color: var(--text-muted);
  font-size: var(--fs-small);
  max-width: var(--measure);
  margin: 0 auto var(--sp-4);
}

/* ------------------------------------------------------------------- forms */

.formpage {
  display: grid;
  gap: var(--sp-4);
  max-width: 46rem;
}

.field {
  display: block;
  margin-bottom: var(--sp-4);
  border: 0;
  padding: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label,
.field > legend,
.sublabel {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
  padding: 0;
}

.field-inline {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.field-narrow {
  max-width: 7rem;
}

.fieldrow {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
}

textarea,
input.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
}

textarea {
  resize: vertical;
  min-height: 4rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--st-failed-line);
  border-width: 2px;
}

.fieldhint {
  font-size: var(--fs-micro);
  color: var(--text-faint);
  margin-top: var(--sp-1);
  max-width: var(--measure);
}

/* The error message repeats the field name in words rather than relying on the
 * red border, which is the same rule as everywhere else here. */
.fielderror {
  font-size: var(--fs-small);
  color: var(--st-failed-fg);
  margin-top: var(--sp-1);
  font-weight: 600;
}

.formerror {
  border: 1px solid var(--st-failed-line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--st-failed-bg);
  color: var(--st-failed-fg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-small);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-small);
  margin-bottom: var(--sp-2);
  cursor: pointer;
}

.choice input {
  margin-top: 0.25rem;
  accent-color: var(--ink);
}

.formactions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  align-items: center;
  margin-top: var(--sp-4);
}

/* ------------------------------------------------------------------- login */

.loginwrap {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: var(--sp-6) 0;
}

.loginpanel {
  width: min(24rem, 100%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
}

.loginbrand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
  margin-bottom: var(--sp-5);
}

.loginbrand .brand-word-light {
  color: var(--text-faint);
}

.logintitle {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-2);
}

.loginintro {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.loginform {
  display: block;
}

.loginform .btn {
  margin-top: var(--sp-2);
}

.loginfoot {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-micro);
  color: var(--text-faint);
}

/* ----------------------------------------------------------------- dialogs */

.dialog {
  width: min(34rem, calc(100vw - 2rem));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow-lift);
}

.dialog::backdrop {
  background: rgba(9, 12, 15, 0.55);
}

.dialog-form {
  padding: var(--sp-5);
  max-height: 80vh;
  overflow-y: auto;
}

.dialogtitle {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

.dialogintro {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

.dialog-warning {
  font-size: var(--fs-small);
  border: 1px solid var(--st-failed-line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--st-failed-bg);
  color: var(--st-failed-fg);
  padding: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.dialog-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* -------------------------------------------------------------- error page */

.errorpage {
  max-width: var(--measure);
  margin: var(--sp-7) auto;
  text-align: center;
}

.errorcode {
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--border-strong);
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-3);
}

.errortext {
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

.errorref {
  font-size: var(--fs-small);
  color: var(--text-faint);
}

.errorpage .formactions {
  justify-content: center;
}

/* ------------------------------------------------------------------- htmx */

/* HTMX sets this class on the element it is loading into. The indicator is a
 * one pixel line, not a spinner: an auto refreshing table must not flicker. */
.listregion.htmx-request {
  position: relative;
}

.listregion.htmx-request::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--ink);
  opacity: 0.5;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .page {
    padding: var(--sp-5) var(--sp-4) var(--sp-6);
  }

  .lede {
    font-size: var(--fs-lg);
  }
}

/* Below this width a dense table stops being a table. Each row becomes a card
 * with the column name in front of every value, so nothing has to be scrolled
 * horizontally to be understood. */
@media (max-width: 760px) {
  .datatable,
  .datatable tbody,
  .datatable tr,
  .datatable th,
  .datatable td {
    display: block;
  }

  .datatable thead {
    display: none;
  }

  .tablewrap {
    border: 0;
    background: transparent;
  }

  .datatable tr {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--sp-3);
    padding: var(--sp-3);
  }

  .datatable tbody th,
  .datatable tbody td {
    border-bottom: 0;
    padding: var(--sp-1) 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-4);
  }

  .datatable tbody [data-label]::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
  }

  .row-attention > *:first-child {
    box-shadow: none;
    padding-left: 0;
  }

  .row-attention {
    border-left: 4px solid var(--rail, var(--border-strong));
  }

  .col-num,
  .col-actions {
    text-align: right;
  }

  .systemhost {
    display: inline;
  }

  .topbar-inner {
    padding: var(--sp-2) var(--sp-4);
  }
}

/* -------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------- print */

@media print {
  .topbar,
  .filterbar,
  .pagehead-actions,
  .skiplink {
    display: none;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .tablewrap {
    overflow: visible;
  }
}

/* The indicator rules htmx would otherwise inject as an inline style element.
   They live here because the Content Security Policy forbids inline styles,
   and loosening the policy for a fade would be the wrong trade. Keep them in
   step with htmx's own defaults if the vendored version changes. */
.htmx-indicator {
  opacity: 0;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* A field that does not apply to the current choice, switched by depends.js.
   It stays visible rather than disappearing: a field that vanishes makes the
   form jump under the reader's hands and hides the fact that the choice they
   just made had an effect somewhere else. */
.field-inactive {
  opacity: 0.55;
}
.field-inactive label,
.field-inactive legend {
  color: var(--text-muted);
}
