/* Stafett control plane.
 *
 * Design tokens and hairline-grid conventions come from the approved
 * dashboard direction: zero border-radius, no shadows, --ink for structural
 * borders and --line for internal dividers.
 *
 * Inter is loaded as a webfont in base.html because the design leans on its 850
 * display weight and nothing here synthesises it (ADR 0023). The stack keeps a
 * locally installed Inter ahead of the webfont and system-ui behind it, so the
 * dashboard still renders if the font origin is blocked or offline.
 *
 * Mono stays on the platform stack: the mock used JetBrains Mono for
 * prototyping only, and the handoff asks production not to add a second face.
 */

:root {
  --ink: #11110f;
  --paper: #f4f1e8;
  --muted: #68675f;
  --line: #cfcbc0;
  --signal: #ff4d00;
  --green: #16794b;
  --amber: #a76000;
  --red: #b42318;

  --font-sans: Inter, "Inter var", system-ui, -apple-system, "Segoe UI",
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;

  --sidebar-width: 220px;
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- primitives */

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

.eyebrow {
  font: 600 0.68rem/1 var(--font-sans);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow-dense {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
}

.eyebrow-amber {
  color: var(--amber);
}
.eyebrow-red {
  color: var(--red);
}
.eyebrow-green {
  color: var(--green);
}
.eyebrow-signal {
  color: var(--signal);
}

.btn {
  font: 600 12px/1 var(--font-sans);
  padding: 10px 16px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

.btn.danger {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
}

.btn.small {
  font-size: 11px;
  padding: 6px 10px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
}

.input {
  font: 13px var(--font-sans);
  padding: 9px 12px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 0;
}

.input:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}

/* ------------------------------------------------------------------- shell */

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

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--ink);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  font: 850 1.15rem/1 var(--font-sans);
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
}

.navgroup {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navlabel {
  font: 600 0.62rem/1 var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}

.navitem {
  font: 500 13px/1 var(--font-sans);
  padding: 9px 10px;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navitem.active {
  border-left-color: var(--signal);
  background: rgba(0, 0, 0, 0.04);
  font-weight: 700;
}

.navitem:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-badge {
  margin-left: auto;
  font: 600 11px/1 var(--font-mono);
  color: var(--red);
}

.sidebar-foot {
  margin-top: auto;
  font-size: 11px;
  color: var(--muted);
}

.main {
  padding: 32px 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

/* Re-establishes the main column's vertical rhythm inside a wrapper element.
 * The DLQ needs one form around both its header button and its table, and that
 * form would otherwise collapse the spacing into a single flex child. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.pagehead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 16px;
}

.pagehead h1 {
  margin: 0;
  font: 850 2.1rem/1 var(--font-sans);
  letter-spacing: -0.04em;
}

.pagehead h1.mono {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.timestamp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.backlink {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  align-self: flex-start;
}

.backlink:hover {
  text-decoration: underline;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.viewall {
  font: 600 11px var(--font-sans);
  color: var(--ink);
  text-decoration: underline;
}

/* ------------------------------------------------------------ metric strip */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ink);
}

.metric {
  padding: 20px 22px;
  border-right: 1px solid var(--ink);
  min-width: 0;
}

.metric:last-child {
  border-right: none;
}

.metric-value {
  font: 850 3rem/0.9 var(--font-sans);
  letter-spacing: -0.04em;
  margin-top: 8px;
}

.metric-value.amber {
  color: var(--amber);
}
.metric-value.red {
  color: var(--red);
}
.metric-value.green {
  color: var(--green);
}

/* --------------------------------------------------------------- sparkline */

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 48px;
  border-bottom: 1px solid var(--line);
}

.sparkline .bar {
  flex: 1;
  background: var(--ink);
  min-height: 1px;
}

/* The design fades the window's older end out rather than drawing every bar at
 * one weight, so the eye lands on the recent right-hand side. Opacity ramps
 * with recency across the twenty buckets the read model returns. */
.sparkline .bar:nth-child(1) {
  opacity: 0.15;
}
.sparkline .bar:nth-child(2) {
  opacity: 0.17;
}
.sparkline .bar:nth-child(3) {
  opacity: 0.2;
}
.sparkline .bar:nth-child(4) {
  opacity: 0.22;
}
.sparkline .bar:nth-child(5) {
  opacity: 0.24;
}
.sparkline .bar:nth-child(6) {
  opacity: 0.27;
}
.sparkline .bar:nth-child(7) {
  opacity: 0.29;
}
.sparkline .bar:nth-child(8) {
  opacity: 0.31;
}
.sparkline .bar:nth-child(9) {
  opacity: 0.34;
}
.sparkline .bar:nth-child(10) {
  opacity: 0.36;
}
.sparkline .bar:nth-child(11) {
  opacity: 0.39;
}
.sparkline .bar:nth-child(12) {
  opacity: 0.41;
}
.sparkline .bar:nth-child(13) {
  opacity: 0.43;
}
.sparkline .bar:nth-child(14) {
  opacity: 0.46;
}
.sparkline .bar:nth-child(15) {
  opacity: 0.48;
}
.sparkline .bar:nth-child(16) {
  opacity: 0.5;
}
.sparkline .bar:nth-child(17) {
  opacity: 0.53;
}
.sparkline .bar:nth-child(18) {
  opacity: 0.55;
}
.sparkline .bar:nth-child(19) {
  opacity: 0.58;
}
.sparkline .bar:nth-child(20) {
  opacity: 0.6;
}

.sparkline .bar.now {
  background: var(--signal);
  opacity: 1;
}

/* Bar heights are classes rather than inline styles: `style-src 'self'` also
 * governs style attributes, so an inline height would be blocked. Steps of 5%
 * are indistinguishable at this size. */
.bar-h-0 {
  height: 0;
}
.bar-h-5 {
  height: 5%;
}
.bar-h-10 {
  height: 10%;
}
.bar-h-15 {
  height: 15%;
}
.bar-h-20 {
  height: 20%;
}
.bar-h-25 {
  height: 25%;
}
.bar-h-30 {
  height: 30%;
}
.bar-h-35 {
  height: 35%;
}
.bar-h-40 {
  height: 40%;
}
.bar-h-45 {
  height: 45%;
}
.bar-h-50 {
  height: 50%;
}
.bar-h-55 {
  height: 55%;
}
.bar-h-60 {
  height: 60%;
}
.bar-h-65 {
  height: 65%;
}
.bar-h-70 {
  height: 70%;
}
.bar-h-75 {
  height: 75%;
}
.bar-h-80 {
  height: 80%;
}
.bar-h-85 {
  height: 85%;
}
.bar-h-90 {
  height: 90%;
}
.bar-h-95 {
  height: 95%;
}
.bar-h-100 {
  height: 100%;
}

/* --------------------------------------------------------- endpoint health */

.endpoints {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--ink);
  border-top: none;
}

.endpoint {
  padding: 12px 16px;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--line);
  min-width: 0;
}

.endpoint:last-child {
  border-right: none;
}

.endpoint-host {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.endpoint-stat {
  font-size: 11px;
  margin-top: 3px;
}

.endpoint-stat.green {
  color: var(--green);
}
.endpoint-stat.amber {
  color: var(--amber);
}
.endpoint-stat.red {
  color: var(--red);
}

/* ------------------------------------------------------------------- facts */

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ink);
}

.fact {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.fact:last-child {
  border-right: none;
}

.fact-value {
  font-family: var(--font-mono);
  font-size: 12.5px;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.notice {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.02);
  padding: 10px 14px;
  font-size: 11px;
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font: 600 0.64rem/1 var(--font-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font: 13px/1.2 var(--font-sans);
}

td.mono {
  font-family: var(--font-mono);
}

.col-check {
  width: 24px;
}

.rowlink {
  font-size: 11px;
  color: var(--ink);
}

/* Turns a table cell's own text into the row's link without reading as a link
 * until hover. Used where the design has no separate "view" column. */
.cell-link {
  color: var(--ink);
  text-decoration: none;
}

.cell-link:hover {
  text-decoration: underline;
}

.empty {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 12px;
}

.error-cell {
  color: var(--red);
}

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

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

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
  background: currentColor;
}

.status-pill {
  font: 600 0.64rem/1 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid currentColor;
  display: inline-block;
}

.st-delivered {
  color: var(--green);
}
.st-dead {
  color: var(--red);
}
.st-retry,
.st-retrying {
  color: var(--amber);
}
.st-delivering {
  color: var(--signal);
}
.st-queued {
  color: var(--muted);
}

/* ------------------------------------------------------------------- chips */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font: 600 11px var(--font-mono);
  padding: 6px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border-radius: 0;
}

.chip.chip-retrying {
  border-color: var(--amber);
  color: var(--amber);
}
.chip.chip-dead {
  border-color: var(--red);
  color: var(--red);
}
.chip.chip-delivered {
  border-color: var(--green);
  color: var(--green);
}
.chip.chip-delivering {
  border-color: var(--signal);
  color: var(--signal);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* -------------------------------------------------------------- pagination */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

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

.pagination .page {
  padding: 6px 10px;
  border: 1px solid var(--ink);
  color: var(--ink);
  text-decoration: none;
}

.pagination .page.disabled {
  border-color: var(--line);
  color: var(--muted);
  pointer-events: none;
}

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

.reveal {
  border: 1px solid var(--signal);
  background: rgba(255, 77, 0, 0.06);
  padding: 14px 16px;
}

.reveal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.reveal-secret {
  font-family: var(--font-mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.create-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.create-row .grow {
  flex: 1;
}

.create-row .grow .input {
  width: 100%;
  padding: 10px 12px;
}

/* A submit button that reads as an inline link. Used where the action must be a
 * real form post (revoke, single-row replay, log out) but should not look like
 * a primary button. */
.linkbtn {
  color: var(--ink);
  font: 11px var(--font-sans);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
}

.revoke {
  color: var(--red);
  font: 11px var(--font-sans);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
}

.inline-form {
  display: inline;
}

/* A handful of spacing/width utilities. These exist so no template needs an
 * inline style attribute, which the CSP blocks. */
.stack-label {
  margin-bottom: 10px;
}

.field-label {
  margin-bottom: 6px;
}

.search-input {
  width: 260px;
}

.flash {
  border: 1px solid var(--ink);
  padding: 10px 14px;
  font-size: 12px;
}

.flash.flash-error {
  border-color: var(--red);
  color: var(--red);
}

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--ink);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card h1 {
  margin: 0;
  font: 850 1.6rem/1 var(--font-sans);
  letter-spacing: -0.03em;
}

.login-card .input {
  width: 100%;
  padding: 10px 12px;
}

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

/* ----------------------------------------------------------------- landing */

.landing {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.landing h1 {
  margin: 0;
  font: 850 clamp(2.4rem, 6vw, 3.6rem) / 0.95 var(--font-sans);
  letter-spacing: -0.045em;
}

.landing p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  max-width: 58ch;
}

.landing pre {
  margin: 0;
  border: 1px solid var(--ink);
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Sections below the hero. The rule above each one carries the page's rhythm,
 * so a section needs no border of its own. */
.landing-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--ink);
  padding-top: 28px;
  margin-top: 12px;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.steps li {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.6;
}

.steps li:first-child {
  border-top: none;
  padding-top: 0;
}

.step-n {
  font: 850 0.95rem/1.5 var(--font-sans);
  letter-spacing: -0.02em;
  color: var(--signal);
  flex: 0 0 2.2ch;
}

.cardgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--ink);
}

.card {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.card:nth-child(2n) {
  border-right: none;
}

.card:nth-last-child(-n + 2) {
  border-bottom: none;
}

.card p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  max-width: none;
}

.landing-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 14px;
  line-height: 1.7;
  max-width: 58ch;
}

.landing-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--ink);
  padding-top: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
}

.landing-foot a {
  font-weight: 600;
  color: var(--ink);
}

/* -------------------------------------------------------------------- docs */

.prose {
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.7;
}

/* OpenAPI explorer page. Swagger UI ships its own layout, so this only supplies
   the outer gutter and the link back to the prose reference. */
.explorer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px 48px;
}

.prose h1,
.prose h2,
.prose h3 {
  letter-spacing: -0.02em;
  margin: 1.8em 0 0.5em;
}

.prose h1 {
  margin-top: 0;
  font-weight: 850;
}

.prose pre {
  border: 1px solid var(--line);
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.prose pre code {
  font-size: inherit;
}

.prose table {
  margin: 1.2em 0;
}

.prose a {
  color: var(--ink);
}

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

/* htmx swaps ride the View Transitions API where the browser supports it. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 120ms linear;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--ink);
  }

  .main {
    padding: 24px 20px 40px;
  }

  .metrics,
  .facts {
    grid-template-columns: repeat(2, 1fr);
  }

  .endpoints {
    grid-template-columns: 1fr;
  }

  .cardgrid {
    grid-template-columns: 1fr;
  }

  /* One column: no card has a neighbour to its right, and only the last card
   * sits on the container's own bottom border. */
  .card,
  .card:nth-child(2n),
  .card:nth-last-child(-n + 2) {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .card:last-child {
    border-bottom: none;
  }

  .landing {
    padding: 48px 20px 64px;
  }
}
