/*
 * Legacy RAM Admin — the console design system.
 *
 * Tokens, type and layout follow docs/superpowers/plans/2026-08-18-admin-web-application.md
 * §"Design direction" exactly. Every colour used anywhere in this file is one
 * of the six tokens below (or that colour's opacity varied) — no new hue is
 * introduced. The console is an instrument, not a dashboard: hairline rules,
 * generous whitespace, no cards, no shadows, no gradients. The heartbeat is
 * the one bold element.
 */

:root {
  --ledger: #E4E5DF; /* Ground. Warm grey-green, the colour of ledger stock. */
  --ink: #1B1F1A;    /* Text. Near-black with a green cast. */
  --rule: #C3C5BB;   /* Hairlines, dividers, tick baselines. */
  --ran: #2E6F4E;    /* The job ran. */
  --held: #B87A2B;   /* The job ticked and correctly did nothing. */
  --fault: #9B3320;  /* The job failed. */

  --font-display: "Archivo", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-data: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--ledger);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}

a {
  color: var(--ink);
}

/* Every control gets a visible focus ring; nothing relies on the browser
   default, and nothing suppresses it. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .tick,
  button,
  a {
    transition: opacity 120ms ease, background-color 120ms ease;
  }
}

/* ---------- Chrome ---------- */

.chrome-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.chrome-header__title {
  font-size: 1.05rem;
  text-transform: uppercase;
}

.chrome-header__user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-data);
  font-size: 0.9rem;
}

.chrome-header__logout {
  font: inherit;
  font-family: var(--font-body);
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  border-radius: 2px;
}

.chrome-header__logout:hover {
  border-color: var(--ink);
}

.chrome-main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.chrome-main--narrow {
  max-width: 26rem;
}

/* ---------- Dashboard ---------- */

.headline {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0 0 1.5rem;
}

.headline--fault {
  color: var(--fault);
}

/* ---------- Heartbeat ---------- */

.heartbeat {
  margin-bottom: 2rem;
}

.heartbeat__scroll {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.heartbeat__strip {
  display: grid;
  grid-template-columns: repeat(168, minmax(3px, 1fr));
  align-items: end;
  gap: 1px;
  height: 3rem;
  min-width: 42rem;
  border-bottom: 1px solid var(--rule);
}

.tick {
  display: block;
  width: 100%;
  border-radius: 0;
}

.tick--ran {
  height: 100%;
  background: var(--ran);
}

.tick--held {
  height: 78%;
  background: var(--held);
}

.tick--failed {
  height: 100%;
  background: var(--fault);
}

.tick--missed {
  height: 100%;
  background: var(--fault);
  opacity: 0.4;
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--ink) 35%, transparent) 0,
    color-mix(in srgb, var(--ink) 35%, transparent) 1px,
    transparent 1px,
    transparent 3px
  );
}

.tick--notyet {
  height: 30%;
  background: var(--rule);
  opacity: 0.6;
}

/* An hour the clocks skipped: it never existed, so it is neither a fault nor
   a hole in the record. Drawn as a full-height hairline outline in --rule so
   it reads as "nothing to report here" rather than "nothing happened here",
   and never in --fault. Finding H. */
.tick--clockchange {
  height: 100%;
  background: transparent;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.heartbeat__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-width: 42rem;
  margin-top: 0.4rem;
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--ink);
}

.heartbeat__day {
  text-align: left;
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  font-family: var(--font-data);
  font-size: 0.8rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Shape carries meaning alongside hue, so the legend (and by extension the
   strip) reads without colour alone. */
.legend__swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  flex: none;
}

.legend__swatch--ran {
  background: var(--ran);
  border-radius: 50%;
}

.legend__swatch--held {
  background: var(--held);
  transform: rotate(45deg);
  width: 0.7rem;
  height: 0.7rem;
}

.legend__swatch--failed {
  background: var(--fault);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.legend__swatch--missed {
  background: transparent;
  border: 2px solid var(--fault);
  opacity: 0.7;
  background-image: repeating-linear-gradient(
    45deg,
    var(--fault) 0,
    var(--fault) 1px,
    transparent 1px,
    transparent 3px
  );
}

.legend__swatch--notyet {
  background: transparent;
  border-bottom: 2px dashed var(--rule);
  height: 0;
  align-self: center;
}

.legend__swatch--clockchange {
  background: transparent;
  border-left: 2px solid var(--rule);
  border-right: 2px solid var(--rule);
}

/* ---------- Run summary ---------- */

.run-summary {
  display: grid;
  grid-template-columns: 8rem 1fr;
  row-gap: 0.75rem;
  column-gap: 1rem;
  margin: 0 0 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.run-summary dt {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.run-summary dd {
  margin: 0;
  font-family: var(--font-data);
  font-size: 0.95rem;
}

@media (max-width: 30rem) {
  .run-summary {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
  }

  .run-summary dt {
    margin-top: 0.5rem;
  }
}

/* ---------- Warnings and the dry-run banner ---------- */

.warnings {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.warning {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  font-family: var(--font-body);
}

.warning:last-child {
  border-bottom: 1px solid var(--rule);
}

.warning__icon {
  color: var(--fault);
  flex: none;
}

/* The verbatim sync_errors text under the warnings. The warning sentence
   above says what it means; this says exactly which server and exactly what
   it answered. No colour of its own -- it is evidence for a warning already
   marked, not a second alarm. Reuses .preview-block for the text itself. */
.sync-errors {
  margin: 0 0 1.5rem;
}

.sync-errors__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}

/* Deliberately quiet: no accent colour, no icon. An idle-but-correct system
   (dry-run) is not an error state and must not be styled to look like one. */
.banner--quiet {
  margin: 0 0 1.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}

/* A dry-run preview: acknowledged, nothing wrong -- the same semantic
   --held (amber) carries on the heartbeat for a correctly-held tick. Text
   and colour both say so; this must never share --fault's red. */
.banner--held {
  margin: 0 0 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--held);
  border-bottom: 1px solid var(--held);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}

/* ---------- Forms (login) ---------- */

.field {
  margin: 0 0 1rem;
}

.field label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.field input,
.field select {
  width: 100%;
  font: inherit;
  font-family: var(--font-data);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  background: var(--ledger);
  color: var(--ink);
  border-radius: 2px;
}

.field input:disabled,
.field select:disabled {
  opacity: 0.6;
}

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.field-row .field {
  flex: 1 1 10rem;
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field--checkbox input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  flex: none;
  accent-color: var(--ink);
}

.field--checkbox label {
  margin: 0;
  text-transform: none;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: normal;
}

.field__hint {
  font-size: 0.85rem;
  color: var(--ink);
  opacity: 0.75;
}

.field__secret-state {
  display: block;
  font-family: var(--font-data);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.field code {
  font-family: var(--font-data);
  background: var(--rule);
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
}

.button-primary {
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--ink);
  color: var(--ledger);
  border: 1px solid var(--ink);
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border-radius: 2px;
}

.button-primary:hover {
  opacity: 0.9;
}

/* Disabled never relies on colour alone: the label text itself changes
   (see Settings.cshtml, "A run is already in progress") and the cursor and
   opacity both shift together. */
.button-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Settings ---------- */

.chrome-header__nav {
  display: flex;
  gap: 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.settings-title {
  font-size: 1.4rem;
  margin: 0 0 1.5rem;
}

.settings-section {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

.settings-section:last-child {
  border-bottom: 1px solid var(--rule);
}

.settings-section h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.settings-section h3 {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

.settings-section p {
  margin: 0 0 1rem;
}

.server-row {
  padding: 1rem 0;
  border-top: 1px dashed var(--rule);
}

.server-row:first-of-type {
  border-top: none;
}

.form-error {
  color: var(--fault);
  font-family: var(--font-body);
}

@media (max-width: 30rem) {
  .chrome-main {
    padding: 1.25rem 1rem 3rem;
  }
}

/* ---------- Invoices, invoice detail, job history ---------- */

/* Wide, genuinely tabular data (the invoice list, an invoice's lines, the
   run history) scrolls inside its own container rather than the page --
   every wide element here follows the same rule the heartbeat strip set. */
.table-scroll {
  overflow-x: auto;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 0.9rem;
}

.ledger-table th,
.ledger-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.ledger-table th {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--ink);
}

.ledger-table th:first-child,
.ledger-table td:first-child {
  padding-left: 0;
}

/* Square/outcome failure text: colour plus the word itself ("Failed"), never
   colour alone. */
.ledger-table__cell--fault {
  color: var(--fault);
  font-weight: 600;
}

/* Dry-run preview: --held, not --fault -- a preview is not a failure.
   Finding K: #B87A2B on #E4E5DF is 2.83:1, below AA for text, and this is the
   state every invoice carries throughout the go-live confidence period. The
   ruling allowed either darkening --held or keeping the token and rendering
   held TEXT in --ink with --held beside it. Darkening far enough (>= 4.5:1
   needs about #8A5A1F) lands the amber at the same relative luminance as
   --ran (#2E6F4E, 4.73:1 on the ground) -- a ratio of 1.02 between them --
   which would leave the heartbeat's two most important states, Ran and Held,
   separated by hue alone at 3px wide. So the second option: the word carries
   --ink at 13.18:1 and --held becomes an adjacent dot. Same pattern
   .banner--held already uses, and --held stays exactly as specified for the
   heartbeat, where it is a graphic and not text. */
.ledger-table__cell--held {
  color: var(--ink);
  font-weight: 600;
}

.ledger-table__cell--held::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  transform: rotate(45deg);
  background: var(--held);
}

/* The dry-run request/order payload, exactly as it would have been sent.
   Wide, so it scrolls inside itself rather than the page. */
.preview-block {
  overflow-x: auto;
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  background: var(--ledger);
  font-family: var(--font-data);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  margin-top: 1.25rem;
  font-family: var(--font-data);
  font-size: 0.9rem;
}

/* The DERIVED marker (plan finding 3): work_orders.status is inferred from
   item state, not synced. Quiet by design -- it is context, not a warning --
   but always present next to the value it qualifies, never only in a code
   comment. */
.derived-tag {
  display: inline-block;
  margin-left: 0.4rem;
  font-family: var(--font-data);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.05rem 0.35rem;
  opacity: 0.75;
}

@media (max-width: 30rem) {
  .ledger-table {
    font-size: 0.8rem;
  }

  .ledger-table th,
  .ledger-table td {
    padding: 0.5rem 0.5rem;
  }
}
