/*
 * harbour admin — components
 *
 * Reads only :root variables declared in tokens-admin.css.
 * Structurally inherits the rail + main + header skeleton from
 * the client surface; reshapes the row density and the colour
 * register for the operator's job.
 */

/* ---- reset + base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--brand-body-font);
  font-size: var(--size-base);
  line-height: var(--leading-base);
  color: var(--colour-ink);
  font-feature-settings: "tnum", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--brand-display-font);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin: 0;
}

p { margin: 0; }
button { font-family: inherit; font-size: inherit; }

a {
  color: var(--accent-strong);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--accent); }

/* ---- layout shell ---- */

.app {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--colour-surface-soft);
  border-right: 1px solid var(--colour-line);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  min-height: 36px;
}

.rail__brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-weight: var(--weight-bold);
  font-size: var(--size-sm);
  letter-spacing: var(--tracking-wide);
}

.rail__brand-name {
  font-family: var(--brand-display-font);
  font-weight: var(--weight-semibold);
  font-size: var(--size-md);
  color: var(--colour-ink-strong);
}

.rail__brand-context {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: 2px;
}

.rail__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.rail__nav-group-label {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-3) var(--space-2) var(--space-2);
}

.rail__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--colour-ink-soft);
  font-size: var(--size-sm);
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.rail__nav-item:hover {
  background: var(--colour-surface);
  color: var(--colour-ink);
}

.rail__nav-item--active {
  background: var(--accent-tint);
  color: var(--accent-strong);
}

.rail__nav-item--active .rail__nav-icon { color: var(--accent-strong); }

.rail__nav-icon {
  width: 16px;
  height: 16px;
  color: var(--colour-ink-muted);
  flex-shrink: 0;
}

.rail__nav-item span { flex: 1; }

.rail__nav-badge {
  background: var(--colour-line);
  color: var(--colour-ink-soft);
  font-size: var(--size-xs);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-weight: var(--weight-medium);
}

.rail__nav-badge--failure {
  background: var(--pill-failure-bg);
  color: var(--pill-failure-ink);
}

.rail__nav-deferred {
  opacity: 0.45;
  pointer-events: none;
}

.rail__nav-deferred-tag {
  font-size: 0.6125rem;
  color: var(--colour-ink-muted);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.rail__footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  border-top: 1px solid var(--colour-line);
  padding-top: var(--space-3);
}

.rail__user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
}

.rail__user-initials {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--colour-line);
  color: var(--colour-ink);
  font-weight: var(--weight-semibold);
  font-size: 0.6875rem;
  display: grid;
  place-items: center;
}

.rail__footer-link {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  padding: var(--space-1) var(--space-2);
}

.rail__footer-link:hover { color: var(--colour-ink); }

/* ---- main + header ---- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.header {
  height: var(--header-height);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--colour-line);
  background: var(--colour-surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 4;
}

.header__title {
  font-size: var(--size-md);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-strong);
}

.header__meta {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
}

.header__meta-stat {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.header__meta-stat-value {
  font-family: var(--font-mono);
  color: var(--colour-ink);
  font-weight: var(--weight-semibold);
  font-size: var(--size-sm);
  font-feature-settings: "tnum";
}

.header__meta-stat-label {
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  font-size: 0.6125rem;
}

.content { padding: var(--space-5); max-width: var(--content-max-width); width: 100%; }

/* ---- environment banner (dev-fixture marker) ----
   When HARBOUR_DEV_FIXTURES=1 the surface is showing
   synthetic data. The banner makes that obvious so no one
   ever reads fixture numbers as real numbers. */

.envbar {
  background: repeating-linear-gradient(
    -45deg,
    rgba(200, 148, 86, 0.08),
    rgba(200, 148, 86, 0.08) 12px,
    transparent 12px,
    transparent 24px
  );
  border-bottom: 1px solid var(--pill-awaiting-bg);
  color: var(--pill-awaiting-ink);
  font-size: var(--size-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-2) var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.envbar strong { font-weight: var(--weight-semibold); }

/* ---- filter bar ---- */

.filterbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.filterbar__group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
}

.filterbar__group-label {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-size: 0.6125rem;
}

.filterbar__pill {
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
  color: var(--colour-ink-soft);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--size-xs);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.filterbar__pill:hover {
  border-color: var(--accent);
  color: var(--colour-ink);
}

.filterbar__pill--active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.filterbar__search {
  flex: 1;
  min-width: 200px;
  padding: var(--space-2) var(--space-3);
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-sm);
  color: var(--colour-ink);
  font-size: var(--size-sm);
  font-family: inherit;
}

.filterbar__search::placeholder { color: var(--colour-ink-muted); }
.filterbar__search:focus {
  outline: none;
  border-color: var(--accent);
}

.filterbar__hits {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

/* ---- cross-tenant table ---- */

.worktable {
  width: 100%;
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  overflow: hidden;
  border-collapse: collapse;
  font-size: var(--size-sm);
}

.worktable thead th {
  text-align: left;
  font-weight: var(--weight-medium);
  font-size: var(--size-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
  background: var(--colour-surface-soft);
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--colour-line);
}

.worktable thead th.worktable__col--sortable { cursor: pointer; }
.worktable thead th.worktable__col--sortable:hover { color: var(--colour-ink); }
.worktable thead th.worktable__col--sortable.is-active { color: var(--accent-strong); }

.worktable__sort-indicator {
  display: inline-block;
  width: 8px;
  text-align: center;
  margin-left: 4px;
  color: var(--accent);
}

.worktable tbody tr {
  border-bottom: 1px solid var(--colour-line);
  transition: background var(--duration-fast) var(--ease-out);
}

.worktable tbody tr:last-child { border-bottom: none; }

.worktable tbody tr:hover {
  background: var(--colour-surface-soft);
  cursor: pointer;
}

.worktable td {
  padding: var(--space-2) var(--space-3);
  color: var(--colour-ink);
  vertical-align: middle;
}

.worktable td.worktable__cell--mono {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--colour-ink-soft);
  font-feature-settings: "tnum";
}

.worktable td.worktable__cell--right {
  text-align: right;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.worktable td.worktable__cell--placeholder {
  color: var(--colour-ink-muted);
  font-style: italic;
}

.worktable td.worktable__cell--stale { color: var(--pill-failure-ink); }

.worktable__empty {
  padding: var(--space-7);
  text-align: center;
  color: var(--colour-ink-muted);
  font-size: var(--size-sm);
}

/* Tenant chip — a small accent dot plus the display name. The
   admin surface always carries this chip because the operator's
   primary question on every row is "which tenant?". */

.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  white-space: nowrap;
}

.tenant-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  flex-shrink: 0;
}

/* Status pill — same names as the client surface, dark-mode
   colours. The pill name maps to a signal class via the data
   driving the row, not to a status string-match in CSS. */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.pill--neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill--active { background: var(--pill-active-bg); color: var(--pill-active-ink); }
.pill--success { background: var(--pill-success-bg); color: var(--pill-success-ink); }
.pill--awaiting { background: var(--pill-awaiting-bg); color: var(--pill-awaiting-ink); }
.pill--failure { background: var(--pill-failure-bg); color: var(--pill-failure-ink); }
.pill--holding { background: var(--pill-holding-bg); color: var(--pill-holding-ink); }

/* Stage chip — a slightly different shape from the status pill
   so the eye doesn't read them as the same thing. */

.stage {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  white-space: nowrap;
}

.stage__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--signal-idle-fill);
}

.stage--live .stage__dot { background: var(--signal-live-fill); }
.stage--waiting .stage__dot { background: var(--signal-waiting-fill); }
.stage--failure .stage__dot { background: var(--signal-failure-fill); }
.stage--terminal .stage__dot { background: var(--pill-success-ink); opacity: 0.6; }

/* Time-in-status: humanised duration, red when past a threshold. */

.dur { font-family: var(--font-mono); font-feature-settings: "tnum"; font-size: var(--size-xs); color: var(--colour-ink-soft); }
.dur--stale { color: var(--pill-failure-ink); }

/* Cost cell: monospace, right-aligned. Placeholder rendered as
   a single em-dash in muted ink when the production path can't
   yet join llm.calls to enquiries (no enquiry_id column on
   llm.calls today). The fixture path fills it. */

.cost { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.cost--placeholder { color: var(--colour-ink-muted); }

/* ---- gap-marker callouts ----
   The three honest gaps the production path leaves visible. A
   tiny inline note next to a placeholder row explains why it's
   blank, so a future operator doesn't read the blank as "no
   data". Hidden when fixtures are on (the fixture path fills
   the gap). */

.gapnote {
  font-size: 0.625rem;
  color: var(--colour-ink-muted);
  font-style: italic;
  letter-spacing: 0;
}

/* ---- header back-link + title divider ---- */

.header__back {
  font-size: var(--size-sm);
  color: var(--colour-ink-soft);
  font-weight: var(--weight-medium);
}
.header__back:hover { color: var(--accent-strong); }

.header__title-divider {
  margin: 0 var(--space-2);
  color: var(--colour-ink-muted);
}

/* ---- worktable row link (stretched anchor pattern) ---- */

.worktable tbody tr.worktable__row { position: relative; }

.worktable__rowlink {
  color: inherit;
  display: inline-block;
  position: relative;
}
.worktable__rowlink::after {
  content: "";
  position: absolute;
  top: calc(-1 * var(--space-2));
  bottom: calc(-1 * var(--space-2));
  left: -100vw;
  right: -100vw;
  z-index: 1;
}
.worktable__rowlink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- per-enquiry header ---- */

.enquiry-header {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-5);
  align-items: start;
}

.enquiry-header__tenant {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  padding-top: var(--space-2);
}

.enquiry-header__contract { padding-top: var(--space-1); }

.enquiry-header__contractor {
  font-size: var(--size-lg);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-strong);
}

.enquiry-header__contract-name {
  font-size: var(--size-sm);
  color: var(--colour-ink-soft);
  margin-top: 2px;
}

.enquiry-header__meta {
  display: grid;
  gap: var(--space-1);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  text-align: right;
  font-family: var(--font-mono);
}

.enquiry-header__meta-label {
  display: inline-block;
  min-width: 90px;
  color: var(--colour-ink-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-size: 0.625rem;
  font-family: var(--brand-body-font);
  margin-right: var(--space-2);
}

.enquiry-header__meta code { color: var(--colour-ink); }

/* ---- cross-stage gap panel ---- */

.gappanel {
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
  border-left: 3px solid var(--pill-awaiting-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--size-xs);
}

.gappanel__label {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--pill-awaiting-ink);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  font-size: 0.625rem;
}

.gappanel__list {
  margin: 0;
  padding-left: var(--space-4);
  color: var(--colour-ink-soft);
  line-height: var(--leading-snug);
}

.gappanel__list li { margin-bottom: var(--space-1); }

/* ---- timeline ---- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.timeline__item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: var(--space-3);
  position: relative;
}

.timeline__rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline__dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-pill);
  margin-top: 18px;
  background: var(--signal-idle-fill);
  box-shadow: 0 0 0 4px var(--colour-bg);
  z-index: 2;
}

.timeline__item--completed .timeline__dot { background: var(--signal-live-fill); }
.timeline__item--current .timeline__dot { background: var(--signal-waiting-fill); animation: timelinePulse 1.8s ease-in-out infinite; }
.timeline__item--failed .timeline__dot { background: var(--signal-failure-fill); }
.timeline__item--skipped .timeline__dot { background: var(--colour-line); }
.timeline__item--pending .timeline__dot { background: var(--colour-line); opacity: 0.6; }

@keyframes timelinePulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--colour-bg), 0 0 0 6px rgba(200, 148, 86, 0.0); }
  50% { box-shadow: 0 0 0 4px var(--colour-bg), 0 0 0 10px rgba(200, 148, 86, 0.18); }
}

.timeline__line {
  width: 2px;
  flex: 1;
  background: var(--colour-line);
  margin-top: 4px;
  min-height: 24px;
}

/* ---- stage card ---- */

.stagecard {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.stagecard--pending,
.stagecard--skipped { opacity: 0.55; }

.stagecard--current { border-color: var(--signal-waiting-fill); }
.stagecard--failed { border-color: var(--signal-failure-fill); }

.stagecard__head { border-bottom: 1px solid var(--colour-line); padding-bottom: var(--space-2); margin-bottom: var(--space-3); }

.stagecard__title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
}

.stagecard__title {
  font-size: var(--size-md);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-strong);
}

.stagecard__state-tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
  background: var(--colour-surface-soft);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.stagecard--completed .stagecard__state-tag { color: var(--pill-success-ink); background: var(--pill-success-bg); }
.stagecard--current .stagecard__state-tag { color: var(--pill-awaiting-ink); background: var(--pill-awaiting-bg); }
.stagecard--failed .stagecard__state-tag { color: var(--pill-failure-ink); background: var(--pill-failure-bg); }

.stagecard__outcome {
  font-size: var(--size-sm);
  color: var(--colour-ink);
  margin-top: var(--space-1);
}

.stagecard__when {
  display: flex;
  gap: var(--space-4);
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}

.stagecard__section { margin-top: var(--space-3); }

.stagecard__section-label {
  font-size: 0.6125rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
  margin-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
}

.stagecard__line { color: var(--colour-ink-soft); font-size: var(--size-sm); }

.stagecard__prose {
  color: var(--colour-ink);
  font-size: var(--size-sm);
  line-height: var(--leading-relaxed);
  background: var(--colour-surface-soft);
  border-left: 2px solid var(--accent);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.stagecard__details {
  margin-top: var(--space-2);
}

.stagecard__details summary {
  cursor: pointer;
  font-size: var(--size-xs);
  color: var(--accent-strong);
  user-select: none;
}

.stagecard__pre {
  margin-top: var(--space-2);
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--colour-ink);
  overflow-x: auto;
  line-height: var(--leading-snug);
  white-space: pre-wrap;
  word-break: break-word;
}

.stagecard__pre--prompt { color: var(--colour-ink-soft); font-style: italic; }
.stagecard__pre--json { color: var(--colour-ink); }

/* ---- AI call list ---- */

.aicall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

.aicall > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--size-xs);
}

.aicall dt {
  color: var(--colour-ink-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-size: 0.625rem;
}

.aicall dd {
  margin: 0;
  color: var(--colour-ink);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.aicall__trace {
  font-size: 0.6875rem;
  color: var(--colour-ink-soft);
}

/* ---- artefacts ---- */

.artefacts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.artefacts__item {
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.artefacts__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--size-sm);
}

.artefacts__label { color: var(--colour-ink); }
.artefacts__kind {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
}

.artefacts__meta {
  display: flex;
  gap: var(--space-3);
  margin-top: 2px;
  font-size: 0.6875rem;
  color: var(--colour-ink-muted);
  font-family: var(--font-mono);
}

.artefacts__path { color: var(--colour-ink-soft); }
.artefacts__sha { color: var(--colour-ink-muted); }

.stagecard__gaps {
  margin: 0;
  padding-left: var(--space-4);
  color: var(--colour-ink-soft);
  font-size: var(--size-xs);
  line-height: var(--leading-snug);
}

.stagecard__gaps li { margin-bottom: var(--space-1); }

/* ---- per-row action buttons ---- */

.actionbtn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  border: 1px solid var(--colour-line);
  background: var(--colour-surface-soft);
  color: var(--colour-ink-soft);
  font-size: var(--size-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  margin-left: var(--space-1);
}

.actionbtn:hover:not(:disabled) {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.actionbtn:disabled,
.actionbtn--deferred {
  opacity: 0.6;
  cursor: not-allowed;
}

.actionbtn__tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
  background: var(--colour-line);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

/* ---- manual-intervention reason cell ---- */

.manual-reason {
  max-width: 420px;
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  line-height: var(--leading-snug);
}

.manual-reason--placeholder { color: var(--colour-ink-muted); font-style: italic; }

/* ---- cost strip + per-tenant cost meter ---- */

.coststrip {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.coststrip__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-4);
}

.coststrip__title {
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.coststrip__sub {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
}

.coststrip__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.coststrip__empty {
  font-size: var(--size-sm);
  color: var(--colour-ink-muted);
  text-align: center;
  padding: var(--space-4);
}

.costrow {
  display: grid;
  gap: var(--space-1);
}

.costrow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.costrow__numbers {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: var(--size-sm);
}

.cost--cap { color: var(--colour-ink-muted); }
.costrow__sep { color: var(--colour-ink-muted); }

.costrow__percent {
  margin-left: var(--space-3);
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  min-width: 48px;
  text-align: right;
}

.costrow__meter {
  width: 100%;
  height: 6px;
  background: var(--meter-track);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.costrow__meter-fill {
  height: 100%;
  background: var(--meter-ok-fill);
  border-radius: var(--radius-pill);
  transition: width var(--duration-base) var(--ease-out);
}

.costrow--warn .costrow__meter-fill { background: var(--meter-warn-fill); }
.costrow--warn .costrow__percent { color: var(--meter-warn-fill); }
.costrow--danger .costrow__meter-fill { background: var(--meter-danger-fill); }
.costrow--danger .costrow__percent { color: var(--meter-danger-fill); font-weight: var(--weight-semibold); }
.costrow--capless .costrow__percent { color: var(--colour-ink-muted); }

/* ---- /admin/tenants per-tenant cards ---- */

.costdetail {
  margin-top: var(--space-5);
}

.costdetail__head { margin-bottom: var(--space-3); }

.costdetail__title {
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.costdetail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

.costcard {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.costcard__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.costcard__name {
  font-size: var(--size-md);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-strong);
}

.costcard__id {
  display: block;
  font-size: 0.6875rem;
  color: var(--colour-ink-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
}

.costcard__metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

.costcard__metrics > div {
  background: var(--colour-surface-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.costcard__metrics dt {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--colour-ink-muted);
}

.costcard__metrics dd {
  margin: 0;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: var(--size-sm);
  color: var(--colour-ink);
}

.costcard__note {
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  line-height: var(--leading-snug);
  border-top: 1px solid var(--colour-line);
  padding-top: var(--space-2);
}

.costcard__note code { color: var(--colour-ink); }

/* ---- Machine view ---- */

.machine {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto auto auto auto;
  gap: var(--space-4);
  grid-template-areas:
    "head head"
    "waiting transport"
    "spine transport"
    "terminals transport";
}

.machine__head { grid-area: head; }
.machine__waiting { grid-area: waiting; display: flex; gap: var(--space-3); flex-wrap: wrap; }
.machine__spine { grid-area: spine; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3) 0; background: var(--colour-surface-soft); border: 1px solid var(--colour-line); border-radius: var(--radius-md); padding-left: var(--space-3); padding-right: var(--space-3); }
.machine__terminals { grid-area: terminals; display: flex; gap: var(--space-3); }
.machine__transport { grid-area: transport; }

.machine__title {
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}

.machine__sub {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
}

.machine__sub code { color: var(--colour-ink-soft); }

/* Box base + signal variants. The `signal` field on
   MachineBox drives the colour. */

.mbox {
  display: block;
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  min-width: 130px;
  text-align: center;
  color: var(--colour-ink);
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.mbox:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.mbox__label {
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}

.mbox__count {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: var(--size-xl);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-strong);
}

.mbox__status {
  font-size: 0.625rem;
  color: var(--colour-ink-muted);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
}

/* Signal-driven box treatments — only border + count colour
   shift; chrome stays consistent. */

.mbox--idle .mbox__count { color: var(--signal-idle-fill); }
.mbox--working { border-color: var(--signal-live-fill); }
.mbox--working .mbox__count { color: var(--signal-live-fill); }
.mbox--waiting { border-color: var(--signal-waiting-fill); }
.mbox--waiting .mbox__count { color: var(--signal-waiting-fill); }
.mbox--failure { border-color: var(--signal-failure-fill); background: var(--signal-failure-track); }
.mbox--failure .mbox__count { color: var(--signal-failure-fill); }
.mbox--terminal .mbox__count { color: var(--pill-success-ink); }

/* Pipe — quiet line between two boxes. `.pipe--pulse` is
   added by SSE later; the heartbeat keyframe is defined here
   ready. */

.pipe {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--colour-ink-muted);
  font-size: var(--size-sm);
}

.pipe__line {
  width: 28px;
  height: 1px;
  background: var(--colour-line);
  transition: background var(--duration-base) var(--ease-out);
}

.pipe__arrow { color: var(--colour-ink-muted); }

.pipe--pulse .pipe__line {
  animation: pipePulse 800ms var(--ease-out);
}

@keyframes pipePulse {
  0% { background: var(--colour-line); }
  40% { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
  100% { background: var(--colour-line); }
}

/* Transport terminal box */

.machine__transport {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  align-self: start;
}

.transport__head { margin-bottom: var(--space-3); }
.transport__title {
  font-size: var(--size-sm);
  font-weight: var(--weight-semibold);
  color: var(--colour-ink);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.transport__sub {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  margin-top: var(--space-1);
}

.transport__metrics {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

.transport__metrics > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--colour-line);
  padding-bottom: var(--space-2);
}

.transport__metrics > div:last-child { border-bottom: none; padding-bottom: 0; }

.transport__metrics dt {
  font-size: var(--size-xs);
  color: var(--colour-ink-soft);
}

.transport__metrics dd {
  margin: 0;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: var(--size-sm);
  color: var(--colour-ink);
}

.transport__note {
  font-size: var(--size-xs);
  color: var(--colour-ink-muted);
  line-height: var(--leading-snug);
  border-top: 1px solid var(--colour-line);
  padding-top: var(--space-2);
}

@media (max-width: 1024px) {
  .machine {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "waiting"
      "spine"
      "terminals"
      "transport";
  }
}

/* =============================================================
   Visual register pass — "forensic instrument panel"
   =============================================================
   Refinements over the base components above. Tightens density,
   refactors the status-pill family to a fill / outline / dot
   vocabulary, adds machine-box LED indicators, refines the cost
   meter chrome, and lifts every card off the background with a
   1px inner highlight.

   No structural changes; pure CSS layered after the base. The
   token surface stayed in tokens-admin.css and grew three
   instrument-panel tokens (--edge-highlight, --inset-trough,
   --inset-card-top) that this pass consumes.
   ============================================================= */

/* ---- body grain + edge scanline ----
   The page reads as the inside of an instrument: a hairline
   gradient line just below the header gives the feel of a
   panel seam without ever being loud. */

.header {
  box-shadow:
    inset 0 -1px 0 var(--colour-line),
    0 1px 0 var(--edge-highlight);
}

.header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--accent-tint) 20%,
    var(--accent-tint) 80%,
    transparent
  );
  opacity: 0.5;
  pointer-events: none;
}

.header { position: relative; }

/* ---- type refinement: data cells get tabular num + slashed zero
   wherever they read as numbers. The font-feature-settings cascade
   was already in place; this hardens it on every mono surface so
   columns of numbers always align cleanly. */

.cost,
.dur,
.worktable__cell--mono,
.worktable__cell--right,
.mbox__count,
.aicall dd,
.transport__metrics dd,
.costcard__metrics dd,
.costrow__numbers,
.costrow__percent {
  font-feature-settings: "tnum", "zero", "ss01";
  font-variant-numeric: tabular-nums slashed-zero;
}

/* ---- card lift: every surface card gets a hairline top-edge
   highlight that lifts it 1px off the dark base. The eye reads
   this as "card", not "rectangle". */

.worktable,
.coststrip,
.costcard,
.machine__transport,
.machine__spine,
.stagecard,
.enquiry-header,
.gappanel,
.filterbar {
  box-shadow:
    var(--inset-card-top),
    var(--shadow-sm);
}

/* ---- worktable: tighter density + cleaner cell rhythm ---- */

.worktable thead th {
  font-size: 0.625rem;
  padding: var(--space-2) var(--space-3);
  letter-spacing: 0.08em;
  background: linear-gradient(
    to bottom,
    var(--colour-surface) 0%,
    var(--colour-surface-soft) 100%
  );
}

.worktable td {
  padding: 7px var(--space-3);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.worktable tbody tr {
  border-bottom: 1px solid var(--colour-line-soft);
}

.worktable tbody tr:hover {
  background: linear-gradient(
    to right,
    var(--colour-surface-soft),
    var(--colour-surface) 30%,
    var(--colour-surface) 70%,
    var(--colour-surface-soft)
  );
}

.worktable__cell--mono {
  font-size: 0.75rem;
  letter-spacing: -0.01em;
}

/* The leftmost tenant chip column gets a thin vertical accent
   strip in the tenant's colour — a quiet visual key that lets
   the operator scan tenants without reading names. */
.worktable td:first-child {
  position: relative;
  padding-left: calc(var(--space-3) + 3px);
}

/* ---- status pill family: fill / outline / dot vocabulary ----
   The base .pill chrome stays for compatibility; this pass adds
   variant-specific treatments that differentiate by SHAPE not
   colour alone. Same colour family, different intensity. */

.pill {
  padding: 1px 8px;
  font-size: 0.65rem;
  letter-spacing: 0.025em;
  font-weight: var(--weight-medium);
  text-transform: lowercase;
  font-feature-settings: "tnum";
  position: relative;
  line-height: 1.5;
}

/* Active / working: dimmer fill, brighter ink. Reads as live. */
.pill--active {
  background: transparent;
  color: var(--signal-live-fill);
  box-shadow: inset 0 0 0 1px var(--signal-live-fill);
}

.pill--active::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--signal-live-fill);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 4px var(--led-glow-live);
}

/* Awaiting / waiting: amber outline pill, hollow ring */
.pill--awaiting {
  background: transparent;
  color: var(--signal-waiting-fill);
  box-shadow: inset 0 0 0 1px var(--signal-waiting-fill);
}

.pill--awaiting::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid var(--signal-waiting-fill);
  margin-right: 6px;
  vertical-align: middle;
}

/* Failure: the only filled pill in the family. The eye finds
   it instantly because it's the only one that breaks the
   outlined-pill convention. */
.pill--failure {
  background: var(--signal-failure-fill);
  color: #1a0e0c;
  box-shadow: 0 0 12px rgba(198, 106, 90, 0.25);
  font-weight: var(--weight-semibold);
}

.pill--failure::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #1a0e0c;
  margin-right: 6px;
  vertical-align: middle;
}

/* Success: muted green, dim. Won is for the client surface;
   here Sent is just a completed state, no celebration. */
.pill--success {
  background: transparent;
  color: var(--pill-success-ink);
  box-shadow: inset 0 0 0 1px rgba(143, 191, 149, 0.4);
}

.pill--neutral {
  background: transparent;
  color: var(--pill-neutral-ink);
  box-shadow: inset 0 0 0 1px var(--colour-line);
}

/* ---- stage chip: tighter dot ---- */

.stage {
  font-family: var(--brand-body-font);
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  color: var(--colour-ink-soft);
}

.stage__dot {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 2px var(--colour-surface);
}

.stage--live .stage__dot { box-shadow: 0 0 0 2px var(--colour-surface), 0 0 6px var(--led-glow-live); }
.stage--waiting .stage__dot { box-shadow: 0 0 0 2px var(--colour-surface), 0 0 6px var(--led-glow-waiting); }
.stage--failure .stage__dot { box-shadow: 0 0 0 2px var(--colour-surface), 0 0 6px var(--led-glow-failure); }

/* ---- duration cell: monospace, tighter tracking ---- */

.dur {
  font-size: 0.7rem;
  letter-spacing: -0.01em;
  font-weight: var(--weight-medium);
}

.dur--stale {
  text-shadow: 0 0 8px rgba(198, 106, 90, 0.3);
}

/* ---- tenant chip: tighter, with optional micro accent ---- */

.tenant-chip {
  font-size: 0.7rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0.005em;
}

.tenant-chip__dot {
  width: 7px;
  height: 7px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 4px currentColor;
}

/* ---- filter bar: more "instrument tab" feel ---- */

.filterbar {
  padding: var(--space-2) var(--space-3);
  gap: var(--space-2);
  border-radius: var(--radius-sm);
}

.filterbar__group-label {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-muted);
}

.filterbar__pill {
  font-size: 0.7rem;
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--colour-line);
  color: var(--colour-ink-soft);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  font-family: var(--brand-body-font);
}

.filterbar__pill--active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-strong);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.3),
    0 0 8px rgba(94, 159, 184, 0.12);
}

.filterbar__search {
  font-size: 0.8125rem;
  padding: 5px var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-trough);
}

.filterbar__search:focus {
  box-shadow: var(--inset-trough), 0 0 0 1px var(--accent);
}

.filterbar__hits {
  font-size: 0.7rem;
  color: var(--colour-ink-muted);
  letter-spacing: 0;
}

/* ---- header meta refinement: smaller labels, larger values ---- */

.header__title {
  font-size: 0.875rem;
  letter-spacing: 0.005em;
  font-weight: var(--weight-semibold);
}

.header__meta-stat-label {
  font-size: 0.575rem;
  letter-spacing: 0.1em;
  color: var(--colour-ink-muted);
}

.header__meta-stat-value {
  font-size: 0.8125rem;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}

/* ---- machine view: instrument-panel boxes with LED indicators ----
   Each box gets a tiny 6px LED in the top-right corner. The LED
   glows in the box's signal colour; when "working" it breathes
   subtly. This is what oscilloscope channel indicators do. */

.machine__spine {
  padding: var(--space-3) var(--space-4);
  gap: 0;
  border-radius: var(--radius-md);
  background:
    linear-gradient(to bottom, var(--colour-surface) 0%, var(--colour-surface-soft) 100%);
}

.mbox {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 10px var(--space-3) 8px;
  min-width: 110px;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.mbox::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal-idle-fill);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transition:
    background var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.mbox--working::after {
  background: var(--signal-live-fill);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 6px var(--led-glow-live);
  animation: ledBreathe 2.4s var(--ease-out) infinite;
}

.mbox--waiting::after {
  background: var(--signal-waiting-fill);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 5px var(--led-glow-waiting);
}

.mbox--failure::after {
  background: var(--signal-failure-fill);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 8px var(--led-glow-failure);
  animation: ledAlarm 1.8s var(--ease-out) infinite;
}

.mbox--terminal::after {
  background: var(--pill-success-ink);
  opacity: 0.4;
}

@keyframes ledBreathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes ledAlarm {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 8px var(--led-glow-failure);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 14px var(--led-glow-failure);
  }
}

.mbox__label {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  font-weight: var(--weight-semibold);
  color: var(--colour-ink-muted);
  margin-bottom: 2px;
}

.mbox__count {
  font-family: var(--font-mono);
  font-feature-settings: "tnum", "zero";
  font-size: 1.625rem;
  font-weight: var(--weight-medium);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.mbox__status {
  font-size: 0.6rem;
  letter-spacing: -0.01em;
  color: var(--colour-ink-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
  opacity: 0.7;
}

.mbox:hover {
  border-color: var(--accent);
  background: linear-gradient(
    to bottom,
    var(--colour-surface) 0%,
    var(--accent-tint) 100%
  );
}

/* Pipe gets slightly more presence and a refined pulse: the
   arrow gains a glow + accent colour during the pulse. */

.pipe {
  gap: 2px;
  padding: 0 4px;
}

.pipe__line {
  width: 24px;
  height: 1px;
  background: var(--colour-line);
}

.pipe__arrow {
  font-size: 0.875rem;
  color: var(--colour-ink-muted);
  opacity: 0.7;
  transition: color var(--duration-fast), opacity var(--duration-fast);
}

.pipe--pulse .pipe__line {
  animation: pipePulseRefined 800ms var(--ease-out);
}

.pipe--pulse .pipe__arrow {
  color: var(--accent);
  opacity: 1;
  text-shadow: 0 0 8px var(--accent);
  animation: pipeArrowGlow 800ms var(--ease-out);
}

@keyframes pipePulseRefined {
  0% { background: var(--colour-line); }
  30% {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(94, 159, 184, 0.3);
  }
  100% { background: var(--colour-line); }
}

@keyframes pipeArrowGlow {
  0%, 100% { transform: translateX(0); }
  40% { transform: translateX(3px); }
}

/* ---- cost meter: instrument chrome ----
   Track gets an inset shadow (reads as a milled groove). Fill
   gets a top hairline highlight (reads as a backlit bar). */

.costrow__meter {
  height: 8px;
  background: var(--meter-track);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.6),
    inset 0 -1px 0 var(--edge-highlight);
  border-radius: 2px;
}

.costrow__meter-fill {
  border-radius: 1px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0 8px currentColor;
  color: var(--meter-ok-fill);
}

.costrow--warn .costrow__meter-fill { color: var(--meter-warn-fill); }
.costrow--danger .costrow__meter-fill {
  color: var(--meter-danger-fill);
  animation: meterDangerPulse 2.2s var(--ease-out) infinite;
}

@keyframes meterDangerPulse {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 6px var(--meter-danger-fill); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 14px var(--meter-danger-fill); }
}

.costrow {
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--colour-surface-soft);
  border: 1px solid var(--colour-line);
}

.costrow__head { padding: 0 4px; }

.costrow__numbers {
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
}

.costrow__percent {
  font-size: 0.7rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}

.coststrip__title,
.machine__title,
.costdetail__title,
.transport__title {
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  color: var(--colour-ink-soft);
}

.coststrip__sub,
.machine__sub,
.transport__sub {
  font-size: 0.7rem;
  margin-top: 2px;
}

/* ---- transport-terminal box: the side-instrument panel ---- */

.machine__transport {
  background:
    linear-gradient(180deg, var(--colour-surface) 0%, var(--colour-surface-soft) 100%);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.transport__metrics > div {
  padding: 6px 0;
  border-bottom-color: var(--colour-line-soft);
}

.transport__metrics dt {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  font-weight: var(--weight-semibold);
}

.transport__metrics dd {
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
}

.transport__inflight {
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  color: var(--signal-live-fill);
}

.transport__model code {
  font-size: 0.7rem;
  color: var(--colour-ink-soft);
}

.transport__note {
  font-size: 0.65rem;
  line-height: 1.5;
  letter-spacing: 0;
}

/* ---- per-tenant cost card refinement ---- */

.costcard {
  padding: var(--space-3) var(--space-4);
}

.costcard__name { font-size: 0.875rem; letter-spacing: -0.005em; }
.costcard__id { font-size: 0.65rem; letter-spacing: -0.005em; }

.costcard__metrics dt { font-size: 0.6rem; letter-spacing: 0.09em; font-weight: var(--weight-semibold); }
.costcard__metrics dd { font-size: 0.8125rem; letter-spacing: -0.01em; }
.costcard__metrics > div { padding: 6px var(--space-3); }

.costcard__note {
  font-size: 0.65rem;
  line-height: 1.55;
}

/* ---- journey-view stage card: numbered timeline ----
   The timeline dot becomes a labelled badge carrying the stage
   number (1, 2, 3...). Reads as a precise sequence rather than a
   procession of identical dots. */

.timeline__item { gap: var(--space-3); grid-template-columns: 28px 1fr; }

.timeline__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-top: 14px;
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  display: grid;
  place-items: center;
  color: var(--colour-ink-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: var(--weight-semibold);
  box-shadow: 0 0 0 3px var(--colour-bg);
}

.timeline__item--completed .timeline__dot {
  background: var(--colour-surface);
  border-color: var(--signal-live-fill);
  color: var(--signal-live-fill);
}

.timeline__item--current .timeline__dot {
  background: var(--colour-surface);
  border-color: var(--signal-waiting-fill);
  color: var(--signal-waiting-fill);
  box-shadow:
    0 0 0 3px var(--colour-bg),
    0 0 10px var(--led-glow-waiting);
}

.timeline__item--failed .timeline__dot {
  background: var(--signal-failure-fill);
  border-color: var(--signal-failure-fill);
  color: #1a0e0c;
}

.timeline__line {
  background: var(--colour-line-soft);
}

.stagecard {
  padding: var(--space-3) var(--space-4);
}

.stagecard__title {
  font-size: 0.95rem;
  letter-spacing: -0.005em;
}

.stagecard__state-tag {
  font-size: 0.55rem;
  letter-spacing: 0.12em;
}

.stagecard__section-label {
  font-size: 0.575rem;
  letter-spacing: 0.12em;
  color: var(--colour-ink-muted);
}

.stagecard__pre {
  font-size: 0.7rem;
  background: var(--colour-bg);
  box-shadow: var(--inset-trough);
  border-color: transparent;
}

.stagecard__pre--prompt { color: var(--colour-ink-soft); }

/* AI call dl — tighter rhythm */
.aicall {
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--colour-surface-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--inset-trough);
}

.aicall dt { font-size: 0.55rem; letter-spacing: 0.1em; }
.aicall dd { font-size: 0.75rem; letter-spacing: -0.01em; }

/* ---- gappanel: instrument-warning chrome ---- */

.gappanel {
  border-left-width: 2px;
  border-left-color: var(--signal-waiting-fill);
  background: linear-gradient(
    to right,
    rgba(200, 148, 86, 0.04),
    transparent 200px
  ),
  var(--colour-surface);
}

.gappanel__label {
  font-size: 0.575rem;
  letter-spacing: 0.12em;
  color: var(--signal-waiting-fill);
}

.gappanel__list { font-size: 0.7rem; }

/* ---- action button refinement ---- */

.actionbtn {
  padding: 3px var(--space-2) 3px var(--space-3);
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  font-family: var(--brand-body-font);
}

.actionbtn__tag {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  padding: 1px 5px;
}

/* ---- rail nav: tighter, more instrument-rail feel ---- */

.rail {
  padding: var(--space-3) var(--space-2);
  background:
    linear-gradient(to right, var(--colour-surface-soft), var(--colour-bg) 100%);
}

.rail__brand-mark {
  width: 26px;
  height: 26px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-strong), var(--accent) 70%);
  color: var(--colour-bg);
  font-size: 0.75rem;
  font-weight: var(--weight-bold);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 8px var(--led-glow-live),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.rail__brand-name {
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.rail__brand-context {
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  margin-top: 1px;
  color: var(--colour-ink-muted);
}

.rail__nav-group-label {
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  font-weight: var(--weight-semibold);
  padding: var(--space-3) var(--space-2) var(--space-1);
}

.rail__nav-item {
  font-size: 0.75rem;
  padding: 6px var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-medium);
  letter-spacing: 0.005em;
}

.rail__nav-icon { width: 14px; height: 14px; }

.rail__nav-item--active {
  background: var(--accent-tint);
  color: var(--accent-strong);
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding-left: calc(var(--space-2) + 2px);
}

.rail__nav-badge {
  font-size: 0.6rem;
  letter-spacing: 0;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.rail__nav-badge--failure {
  box-shadow:
    inset 0 0 0 1px rgba(198, 106, 90, 0.4),
    0 0 6px rgba(198, 106, 90, 0.15);
}

.rail__user-initials {
  width: 20px;
  height: 20px;
  font-size: 0.625rem;
  background:
    linear-gradient(to bottom right, var(--colour-line), var(--colour-surface-soft));
  box-shadow: inset 0 0 0 1px var(--colour-line);
}

.rail__footer-link {
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

/* ---- environment banner refinement ---- */

.envbar {
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  padding: 4px var(--space-4);
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(200, 148, 86, 0.06),
      rgba(200, 148, 86, 0.06) 8px,
      transparent 8px,
      transparent 16px
    ),
    var(--colour-surface-soft);
  border-bottom: 1px solid rgba(200, 148, 86, 0.18);
}

/* ---- gap note: smaller, italic-by-rule ---- */

.gapnote {
  font-size: 0.6rem;
  color: var(--colour-ink-muted);
  font-style: italic;
  letter-spacing: 0;
  line-height: 1.5;
}

/* ---- manual-intervention reason cell: cleaner wrap ---- */

.manual-reason {
  font-size: 0.7rem;
  line-height: 1.55;
}

/* ---- enquiry-header refinement ---- */

.enquiry-header {
  padding: var(--space-3) var(--space-4);
}

.enquiry-header__contractor { font-size: 1.0625rem; letter-spacing: -0.01em; }
.enquiry-header__contract-name { font-size: 0.75rem; }

.enquiry-header__meta {
  font-size: 0.625rem;
}

.enquiry-header__meta-label {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  min-width: 80px;
}

.enquiry-header__meta code {
  font-size: 0.65rem;
  letter-spacing: -0.01em;
}

/* ---- user-management forms ---- */

.userform {
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--inset-card-top), var(--shadow-sm);
}

.userform__title {
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--colour-ink-soft);
  margin-bottom: var(--space-3);
  font-weight: var(--weight-semibold);
}

.userform__row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: var(--space-3);
  align-items: end;
}

.userform__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.userform__field label {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--colour-ink-muted);
  font-weight: var(--weight-semibold);
}

.userform__field input {
  padding: 6px var(--space-3);
  background: var(--colour-bg);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-sm);
  color: var(--colour-ink);
  font-family: var(--brand-body-font);
  font-size: var(--size-sm);
  box-shadow: var(--inset-trough);
}

.userform__field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset-trough), 0 0 0 1px var(--accent);
}

.userform__field--actions {
  display: flex;
  flex-direction: row;
  align-items: end;
  gap: var(--space-2);
}

.userform__error {
  background: var(--signal-failure-track);
  border-left: 2px solid var(--signal-failure-fill);
  color: var(--pill-failure-ink);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-size: var(--size-sm);
}

.userform__note {
  margin-top: var(--space-2);
}

/* ---- delete confirm details ---- */

.userdelete {
  display: inline-block;
  position: relative;
  margin-left: var(--space-1);
}

.userdelete summary {
  list-style: none;
  cursor: pointer;
}

.userdelete summary::-webkit-details-marker { display: none; }

.actionbtn--danger {
  background: var(--signal-failure-track);
  border-color: var(--signal-failure-fill);
  color: var(--pill-failure-ink);
}

.actionbtn--danger:hover {
  background: var(--signal-failure-fill);
  color: #1a0e0c;
}

.actionbtn--danger-strong {
  background: var(--signal-failure-fill);
  color: #1a0e0c;
  border-color: var(--signal-failure-fill);
  font-weight: var(--weight-semibold);
}

.actionbtn--primary {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: var(--weight-medium);
}

.actionbtn--primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.userdelete__form {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--colour-surface);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 200px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* ---- per-tenant card actions strip ---- */

.costcard__actions {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--colour-line);
  display: flex;
  gap: var(--space-2);
}

/* ---- login surface ----
   The login card is the one admin surface without the rail/main
   skeleton: a centred card, standalone. It reuses the same component
   shapes as the client login (.login / .field / .button) -- the only
   difference is the colour layer, which it gets for free from
   tokens-admin.css (the tokens are infrastructure, identical names;
   the components are decisions but this one is deliberately the same
   shape across both surfaces). */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.login__card {
  background: var(--colour-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--colour-line);
  box-shadow: var(--inset-card-top), var(--shadow-md);
  padding: var(--space-7);
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login__heading {
  font-family: var(--brand-display-font);
  font-size: var(--size-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--colour-ink-strong);
}

.login__intro {
  color: var(--colour-ink-soft);
  font-size: var(--size-sm);
  line-height: var(--leading-relaxed);
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--size-sm);
  font-weight: var(--weight-medium);
  color: var(--colour-ink);
}

.field__input {
  font-family: inherit;
  font-size: var(--size-base);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--colour-line);
  border-radius: var(--radius-md);
  background: var(--colour-bg);
  color: var(--colour-ink);
  box-shadow: var(--inset-trough);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--inset-trough), 0 0 0 1px var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--size-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.button--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button--primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button--primary:active {
  transform: translateY(0);
}

.login__confirmation {
  background: var(--pill-success-bg);
  color: var(--pill-success-ink);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--size-sm);
  line-height: var(--leading-relaxed);
}

/* Staggered page-load reveal (the client surface's cue, dark register). */
@keyframes harbour-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  animation: harbour-rise var(--duration-slow) var(--ease-out) forwards;
}

.reveal[data-stagger="0"] { animation-delay: 0ms; }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .button--primary:hover { transform: none; }
}

/* ---- responsive ---- */

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; }
}
