
:root {
  --paper: #f6f3ec;
  --paper-deep: #ebe7db;
  --ink: #191815;
  --ink-soft: #625d53;
  --rule: #dcd6c8;
  --signal: #b8381a;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --rail: 11rem;
  --gap: 4.5rem;
  --fade: 140ms ease;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  font-kerning: normal;
}

h1, h2, p, dl, dd, ol, ul, table, pre { margin: 0; }
ol, ul { padding: 0; list-style: none; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--fade);
}
a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 1px; }

.mono { font-family: var(--mono); font-size: 0.9em; }
.soft { color: var(--ink-soft); }
.absent { color: var(--ink-soft); font-style: italic; }

/* Frame: a narrow rail and one content column, pushed off-centre on purpose. */

.frame {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 61rem);
  column-gap: var(--gap);
  min-height: 100vh;
  padding: 5.5rem 2.5rem 7rem 5rem;
}

.rail {
  position: sticky;
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
  height: calc(100vh - 9rem);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.rail a { text-decoration-color: transparent; }
.rail a:hover { text-decoration-color: currentColor; }
.wordmark { font-weight: 600; letter-spacing: -0.01em; }
.rail-nodes { display: flex; flex-direction: column; gap: 0.45rem; color: var(--ink-soft); }
.rail-foot { margin-top: auto; }

.page { min-width: 0; }

/* The one large gesture on each page. */

.subject {
  margin-left: -0.04em;
  font-size: clamp(2.9rem, 6.4vw, 5.25rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}
.subject-count { font-variant-numeric: tabular-nums; }
.subject-word { color: var(--ink-soft); font-weight: 400; }
.subject-slug { font-family: var(--mono); font-size: clamp(2.5rem, 5.2vw, 4.25rem); font-weight: 500; line-height: 1; letter-spacing: -0.045em; }
.subject-note { margin-top: 1.1rem; color: var(--ink-soft); }
.subject-note .mono, .subject-note .state-ok, .subject-note .state-idle { color: var(--ink); }
.attention { color: var(--signal); }

.crumb {
  margin-bottom: 1.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.crumb a { text-decoration-color: transparent; }
.crumb a:hover { text-decoration-color: currentColor; }

.label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.flash { margin-bottom: 2.25rem; max-width: 46rem; overflow-wrap: anywhere; }
.flash-error { color: var(--signal); }

/* Controls. */

button, input, select { font: inherit; color: inherit; }

.quiet {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--fade);
}
.quiet:hover { text-decoration-color: currentColor; }

.primary {
  padding: 0.5rem 1.15rem;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--fade);
}
.primary:hover { opacity: 0.82; }

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field-name { font-size: 0.8rem; color: var(--ink-soft); }
.field input, .field select {
  width: 100%;
  height: 2.25rem;
  padding: 0 0.1rem;
  border: 0;
  border-bottom: 1px solid var(--ink-soft);
  border-radius: 0;
  background: transparent;
  transition: border-color var(--fade);
}
.field input:hover, .field select:hover { border-bottom-color: var(--ink); }
.field input::placeholder { color: var(--ink-soft); opacity: 1; }
.field .mono { font-size: 0.9rem; }

/* Overview: one section per node, tenants as a ledger. */

.node { margin-top: 5rem; scroll-margin-top: 2.5rem; }
.subject-note + .node, .subject + .node { margin-top: 4.5rem; }

.node-head { display: flex; align-items: baseline; gap: 1rem; padding-bottom: 0.9rem; }
.node-url { min-width: 0; font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.node-action { margin-left: auto; font-size: 0.87rem; }

.node-error, .node-empty { padding: 1.1rem 0; border-top: 1px solid var(--rule); }
.node-error { color: var(--signal); overflow-wrap: anywhere; }
.node-empty { color: var(--ink-soft); }

.ledger { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ledger th {
  padding: 0 1.5rem 0.55rem 0;
  font-size: 0.8rem;
  font-weight: 400;
  text-align: left;
  color: var(--ink-soft);
}
.ledger td {
  padding: 1.05rem 1.5rem 1.05rem 0;
  border-top: 1px solid var(--rule);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.ledger th:last-child, .ledger td:last-child { padding-right: 0; text-align: right; }
.col-tenant { width: 33%; }
.col-state { width: 13%; }
.col-plan { width: 13%; }
.col-date { width: 7.5rem; }

.slug { font-family: var(--mono); font-weight: 600; text-decoration-color: transparent; }
.tenant-url { display: block; margin-top: 0.15rem; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); }
.cell-sub { display: block; font-size: 0.87rem; color: var(--ink-soft); }
.cell-date { font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }

.state { display: inline-flex; align-items: baseline; gap: 0.5rem; white-space: nowrap; }
.dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transform: translateY(-0.03rem);
}
.state-ok .dot, .state-alert .dot { background: currentColor; }
.state-alert { color: var(--signal); }

.provision {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1.25fr) auto;
  gap: 1.5rem;
  align-items: end;
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule);
}

/* Tenant detail. */

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem 1.75rem; margin-top: 2.25rem; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 3.5rem 4.5rem;
  align-items: start;
  margin-top: 4.25rem;
}

.section { margin-top: 4.25rem; }
.split > .section { margin-top: 0; }
.section > .label { margin-bottom: 1rem; }
.section-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.section-head form { margin-left: auto; font-size: 0.87rem; }

.facts { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); }
.facts dt, .facts dd { padding: 0.62rem 0; border-top: 1px solid var(--rule); }
.facts dt { font-size: 0.87rem; color: var(--ink-soft); }
.facts dd { overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; }

.backups li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 1rem;
  padding: 0.62rem 0;
  border-top: 1px solid var(--rule);
}
.backup-file { grid-column: 1 / -1; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.backup-size { font-family: var(--mono); font-size: 0.85rem; }
.section-note { padding: 0.62rem 0; border-top: 1px solid var(--rule); color: var(--ink-soft); }
.section-note.attention { color: var(--signal); }

/* column-reverse makes the box open scrolled to its end, where the newest lines are, without a script. */
.log {
  display: flex;
  flex-direction: column-reverse;
  max-height: 26rem;
  padding: 1.1rem 1.25rem;
  overflow: auto;
  background: var(--paper-deep);
}
.log pre {
  font: 0.78rem/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.danger { margin-top: 7rem; max-width: 36rem; }
.danger .label { color: var(--signal); }
.danger-form { display: flex; align-items: end; gap: 1.5rem; margin-top: 1.4rem; }
.danger-form .field { flex: 1; max-width: 22rem; }
.destroy {
  height: 2.25rem;
  padding: 0 1.15rem;
  border: 1px solid var(--signal);
  border-radius: 2px;
  background: transparent;
  color: var(--signal);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--fade), color var(--fade);
}
.destroy:hover { background: var(--signal); color: var(--paper); }

/* The page that shows a sysadmin key, once. */

.key-block { margin-top: 4.25rem; max-width: 46rem; }
.key {
  margin-top: 1rem;
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--ink-soft);
  font: 500 1.35rem/1.45 var(--mono);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}
.key-note { margin-top: 1rem; max-width: 34rem; }
.onward { display: flex; flex-wrap: wrap; gap: 0.4rem 1.75rem; margin-top: 3.25rem; }

/* Sign in, and the short pages for refusals. */

.signin { display: flex; flex-direction: column; align-items: flex-start; gap: 1.75rem; margin-top: 3.25rem; }
.signin .field { width: min(100%, 21rem); }
.message { margin-top: 1.5rem; max-width: 34rem; }

@media (max-width: 1040px) {
  .frame { --gap: 3rem; padding: 4rem 2rem 6rem 3rem; }
  .rail { top: 4rem; height: calc(100vh - 7rem); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .provision { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .provision .primary { justify-self: start; }
}

@media (max-width: 760px) {
  .frame { display: block; padding: 1.5rem 1.25rem 4.5rem 1.5rem; }
  .rail {
    position: static;
    flex-flow: row wrap;
    align-items: baseline;
    gap: 0.6rem 1.25rem;
    height: auto;
    margin-bottom: 3.5rem;
  }
  .rail-nodes { flex-flow: row wrap; gap: 0.3rem 1.1rem; order: 3; width: 100%; }
  .rail-foot { margin-left: auto; }

  .node { margin-top: 4rem; }
  .node-head { flex-wrap: wrap; gap: 0.2rem 1rem; }
  .node-url { order: 3; width: 100%; }

  .ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ledger, .ledger tbody { display: block; }
  .ledger tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 1rem;
    padding: 1.05rem 0;
    border-top: 1px solid var(--rule);
  }
  .ledger td { display: block; padding: 0; border: 0; }
  .ledger td:last-child { text-align: right; }
  .cell-tenant { grid-area: 1 / 1; }
  .cell-state { grid-area: 1 / 2; }
  .cell-plan { grid-area: 2 / 1; }
  .cell-date { grid-area: 2 / 2; }
  .cell-contact { grid-area: 3 / 1 / auto / -1; }

  .provision { grid-template-columns: minmax(0, 1fr); gap: 1.1rem; }
  .split, .section { margin-top: 3.25rem; }
  .danger { margin-top: 5rem; }
  .danger-form { flex-wrap: wrap; }
  .danger-form .field { flex-basis: 100%; max-width: none; }
  .key { padding: 1.1rem 1.15rem; font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
