/*
  INTERLOCK console.

  Instrument panel, not a landing page. One accent colour used sparingly, red
  reserved strictly for failure, every number monospaced and tabular so nothing
  shifts as figures update. No build step: this file is served as written.
*/

/*
  Self-hosted, not a CDN link. Neither face is installed on a typical Windows
  machine, so without these the whole design silently degrades to Segoe UI and
  Consolas — which is most of the gap between this and the design mock. Both
  are variable fonts, one file each.
*/
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-var.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0A0B0D;
  --inlay: #000000;   /* level 2 — inset terminal + code surfaces */
  --surface: #101215;
  --surface-2: #16181C;
  --surface-3: #1B1E23;
  --border: #23262B;
  --border-2: #2E3339;
  --text: #E8E8E6;
  --muted: #8B9099;
  --dim: #5E646D;
  --accent: #7DD3FC;   /* the colour the facilitator itself uses for Algorand */
  --pending: #F5A524;
  --fail: #FF4D4D;

  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

/* Several elements below are display:flex/grid, which silently overrides the
   [hidden] attribute. Everything that toggles does so via .hidden = true. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ── header ──────────────────────────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #111318 0%, var(--bg) 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 0;
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--accent);
  border-radius: 0;
  opacity: .35;
}

.brand-name {
  font-weight: 600;
  letter-spacing: .24em;
  font-size: 14px;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--dim);
  text-transform: uppercase;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.chips { display: flex; align-items: center; gap: 8px; }

.chip-hd {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-hd .ck { color: var(--dim); }
.chip-hd .mono { color: var(--text); letter-spacing: .02em; }
.mock-chip { border-color: var(--pending); color: var(--pending); }

.dot {
  width: 7px;
  height: 7px;
  background: var(--dim);
  display: inline-block;
  flex: none;
}
.dot.up { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.dot.pending { background: var(--pending); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pending) 18%, transparent); }
.dot.down { background: var(--fail); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fail) 18%, transparent); }

/* ── layout ──────────────────────────────────────────────────────────────── */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas:
    "controls  rail"
    "graph     rail"
    "output    rail"
    "inspector inspector"
    "agentdef  agentdef";
  gap: 16px;
  padding: 16px 24px 40px;
  align-items: start;
}

.controls  { grid-area: controls; }
.graph-wrap{ grid-area: graph; }
.output-panel { grid-area: output; }
.rail      { grid-area: rail; display: flex; flex-direction: column; gap: 16px; }
.inspector { grid-area: inspector; }
.agentdef  { grid-area: agentdef; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
}

/* Section headers carry real weight and sit on a rule, per the design mock.
   At 11px they read as captions and the panels have no hierarchy at all. */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  min-height: 28px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.panel-label {
  font-size: 15px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text);
  font-weight: 600;
}

/* The collapsed strips keep the small treatment - they are affordances, not
   sections, and giving them 15px would flatten the hierarchy again. */
.inspector .panel-label,
.agentdef .panel-label {
  font-size: 11px;
  letter-spacing: .1em;
  font-weight: 500;
  color: var(--muted);
}

.panel-note {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .02em;
}
.panel-note b { color: var(--muted); font-weight: 500; }

/* ── controls ────────────────────────────────────────────────────────────── */

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px 132px auto;
  gap: 12px;
  align-items: end;
}

.field-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.input-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dim);
}

.num {
  width: 100%;
  height: 38px;
  background: var(--inlay);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.num:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* The PR field is a command line, not a form field — no box, one rule that
   lights up on focus. It is the only place a human types a target. */
.cmd {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border-2);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.cmd:focus-within {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}
.cmd-prompt {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  color: var(--accent);
  flex: none;
}

.task {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}
.task:focus { outline: none; }
.task::placeholder { color: var(--dim); }

/* :has scopes the rule to the wrapper; the text colour is the fallback if a
   browser misses it, so the flagged state is never invisible. */
.cmd:has(.task.flagged) { border-bottom-color: var(--fail); box-shadow: 0 1px 0 0 var(--fail); }
.cmd:has(.task.flagged) .cmd-prompt { color: var(--fail); }
.task.flagged { color: var(--fail); }

.run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  min-width: 132px;
  background: var(--accent);
  border: none;
  border-radius: 0;
  color: #05202b;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  padding: 0 22px;
  cursor: pointer;
  transition: filter .16s var(--ease), opacity .16s var(--ease);
}
.run:hover:not(:disabled) { filter: brightness(1.12); }
.run:disabled { opacity: .35; cursor: default; }
.run-glyph { font-size: 10px; }

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.toggles-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dim);
  margin-right: 4px;
}

.tg-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.toggle, .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  height: 30px;
  padding: 0 11px;
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.toggle:hover, .chip:hover { border-color: var(--border-2); color: var(--text); }

/* A hardware switch, not an iOS pill. Square throw, square knob. */
.tg {
  width: 22px;
  height: 12px;
  background: var(--inlay);
  border: 1px solid var(--border-2);
  position: relative;
  flex: none;
  transition: border-color .16s var(--ease);
}
.tg::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 8px;
  height: 8px;
  background: var(--dim);
  transition: transform .16s var(--ease), background .16s var(--ease);
}
.toggle[data-armed="true"] {
  border-color: var(--fail);
  color: var(--fail);
  background: color-mix(in srgb, var(--fail) 9%, var(--surface-2));
}
.toggle[data-armed="true"] .tg { border-color: var(--fail); }
.toggle[data-armed="true"] .tg::after { transform: translateX(10px); background: var(--fail); }

/* ── pipeline graph ──────────────────────────────────────────────────────── */

.phaserail {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.phaserail span {
  color: var(--dim);
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  padding-bottom: 5px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
  position: relative;
}
.phaserail span + span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 1px;
  height: 9px;
  background: var(--border);
}
.phaserail span[data-on="past"] { color: var(--muted); border-bottom-color: var(--border-2); }
.phaserail span[data-on="now"]  { color: var(--pending); border-bottom-color: var(--pending); }
.phaserail span[data-on="done"] { color: var(--accent); border-bottom-color: var(--accent); }
.phaserail span[data-on="fail"] { color: var(--fail); border-bottom-color: var(--fail); }

.graph-stage {
  position: relative;
  padding: 8px 0 4px;
  background-image:
    linear-gradient(to right, rgba(125, 211, 252, .028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(125, 211, 252, .028) 1px, transparent 1px);
  background-size: 32px 32px;
  border-radius: 0;
}

.graph {
  display: flex;
  align-items: stretch;
  transition: opacity .25s var(--ease), filter .25s var(--ease);
}

.grp { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.grp-outer { flex: 2 1 0; }
.grp-inner { flex: 5 1 0; }

.grp-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--dim);
  padding-left: 2px;
  white-space: nowrap;
}
.grp-label b { color: var(--muted); font-weight: 500; }

.grp-nodes { display: flex; align-items: stretch; flex: 1; min-width: 0; }

/* the 1 → 5 fan-out. one payment in, five payments out. */
.fan {
  flex: 0 0 46px;
  align-self: stretch;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
}
.fan::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 1px;
  background: repeating-linear-gradient(
    to bottom, var(--border-2) 0 3px, transparent 3px 6px);
}
.fan span {
  position: relative;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  background: var(--surface);
  padding: 3px 4px;
  letter-spacing: .04em;
}

.node {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 9px 10px 8px;
  position: relative;
  cursor: pointer;
  opacity: .5;
  transition: border-color .2s var(--ease), background .2s var(--ease),
              opacity .2s var(--ease), transform .2s var(--ease);
}
.node:hover { border-color: var(--border-2); }
.node.selected-node {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.nname {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nprice {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  margin-top: 5px;
  color: var(--text);
  letter-spacing: -.01em;
}
.nprice .t { color: var(--dim); }

.nstate {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  height: 14px;
}
.nstate .glyph { font-size: 13px; line-height: 1; color: var(--dim); }
.nstate .slabel {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node .tx {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  height: 13px;
  white-space: nowrap;
  overflow: hidden;
}
.node .tx[href] { color: var(--accent); }
.node .tx[href]:hover { text-decoration: underline; }

.edge {
  flex: 0 0 26px;
  align-self: center;
  height: 1px;
  background: var(--border);
  position: relative;
  margin-top: 4px;
}
.edge .pulse {
  position: absolute;
  top: -2px;
  left: 0;
  width: 5px;
  height: 5px;
  background: var(--accent);
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0;
}
.edge.moving .pulse { animation: travel .4s var(--ease) forwards; }

@keyframes travel {
  from { left: 0; opacity: 1; }
  to   { left: calc(100% - 5px); opacity: 0; }
}

/* ── node states ─────────────────────────────────────────────────────────── */

.node[data-state="selected"] { opacity: .72; }
.node[data-state="selected"] .glyph,
.node[data-state="selected"] .slabel { color: var(--muted); }

.node[data-state="verifying"],
.node[data-state="verified"] {
  opacity: 1;
  border-color: var(--pending);
  background: color-mix(in srgb, var(--pending) 6%, var(--surface-2));
}
.node[data-state="verifying"] .glyph,
.node[data-state="verified"] .glyph,
.node[data-state="verifying"] .slabel,
.node[data-state="verified"] .slabel { color: var(--pending); }

.node[data-state="settling"] {
  opacity: 1;
  border-color: var(--pending);
  background: color-mix(in srgb, var(--pending) 9%, var(--surface-2));
  animation: working 1.1s ease-in-out infinite;
}
.node[data-state="settling"] .glyph,
.node[data-state="settling"] .slabel { color: var(--pending); }

.node[data-state="settled"],
.node[data-state="returned"] {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.node[data-state="settled"] .glyph,
.node[data-state="returned"] .glyph { color: var(--accent); }
.node[data-state="settled"] .slabel,
.node[data-state="returned"] .slabel { color: color-mix(in srgb, var(--accent) 70%, var(--muted)); }

.node[data-state="failed"] {
  opacity: 1;
  border-color: var(--fail);
  background: color-mix(in srgb, var(--fail) 10%, var(--surface-2));
}
.node[data-state="failed"] .glyph,
.node[data-state="failed"] .slabel { color: var(--fail); }

.node[data-state="refunded"] {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  border-style: dashed;
}
.node[data-state="refunded"] .glyph,
.node[data-state="refunded"] .slabel { color: var(--accent); }

/* not charged — must read as "we did not take your money", not as "broken" */
.node[data-state="skipped"] {
  opacity: .42;
  border-style: dashed;
  background: transparent;
}
.node[data-state="skipped"] .nprice { color: var(--dim); text-decoration: line-through; }

/* the moment a transaction lands */
.node.landed { animation: land .5s var(--ease); }

@keyframes land {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  35%  { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes working {
  0%, 100% { border-color: var(--pending); }
  50%      { border-color: color-mix(in srgb, var(--pending) 40%, var(--border)); }
}

/*
  Pre-flight: every node pulses AT ONCE and resolves AT ONCE. That single
  synchronised moment is the two-phase-commit story. The commit phase is its
  visual opposite — strictly one node at a time. Never animate pre-flight
  sequentially.
*/
.graph.preflight .node[data-state="verifying"] {
  animation: preflight-pulse 1.15s ease-in-out infinite;
}

@keyframes preflight-pulse {
  0%, 100% {
    border-color: var(--pending);
    background: color-mix(in srgb, var(--pending) 12%, var(--surface-2));
  }
  50% {
    border-color: color-mix(in srgb, var(--pending) 30%, var(--border));
    background: color-mix(in srgb, var(--pending) 3%, var(--surface-2));
  }
}

/* ── zero-spend abort: a system refusing, not a system breaking ──────────── */

.graph.aborted { opacity: .22; filter: grayscale(.55); }

.abort-band {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 13%, rgba(10, 11, 13, .93)) 0%,
    rgba(10, 11, 13, .93) 55%);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-left: 3px solid var(--accent);
  border-radius: 0;
  animation: band-in .28s var(--ease);
}

@keyframes band-in {
  from { opacity: 0; transform: scaleY(.92); }
  to   { opacity: 1; transform: scaleY(1); }
}

.ab-glyph { font-size: 26px; color: var(--accent); line-height: 1; flex: none; }
.ab-body { min-width: 0; flex: 1; }
.ab-title {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text);
}
.ab-reason { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.ab-figure { text-align: right; flex: none; }
.ab-figure .big {
  display: block;
  font-size: 30px;
  color: var(--accent);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.ab-figure .sub {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-top: 4px;
}

/* ── narration: the line that explains what the blocks are doing ─────────── */

.narration {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  padding: 13px 14px;
  min-height: 52px;
  background: var(--inlay);
  border: 1px solid var(--border);
  border-left: 2px solid var(--dim);
  border-radius: 0;
  transition: border-color .2s var(--ease);
}

.nr-glyph {
  font-size: 14px;
  line-height: 1.5;
  color: var(--dim);
  flex: none;
  width: 16px;
  text-align: center;
  transition: color .2s var(--ease);
}

.nr-text {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  letter-spacing: .002em;
}
.nr-text b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}
.nr-text a { font-family: var(--mono); text-decoration: none; }
.nr-text a:hover { text-decoration: underline; }
.nr-text .q { color: var(--muted); }

.nr-metric {
  flex: none;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-top: 4px;
  white-space: nowrap;
}

.narration[data-tone="active"]  { border-left-color: var(--pending); }
.narration[data-tone="active"]  .nr-glyph { color: var(--pending); }
.narration[data-tone="good"]    { border-left-color: var(--accent); }
.narration[data-tone="good"]    .nr-glyph { color: var(--accent); }
.narration[data-tone="good"]    .nr-text b { color: var(--accent); }
.narration[data-tone="bad"]     { border-left-color: var(--fail); }
.narration[data-tone="bad"]     .nr-glyph { color: var(--fail); }
.narration[data-tone="bad"]     .nr-text b { color: var(--fail); }
.narration[data-tone="hold"]    { border-left-color: var(--accent); }
.narration[data-tone="hold"]    .nr-glyph { color: var(--accent); }

.nr-text.swap { animation: swap-in .22s var(--ease); }
@keyframes swap-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

/* persistent verdict — must not be overwritten by transient status */
.notice {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--muted);
  border-radius: 0;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}
.notice b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.notice.fail { border-left-color: var(--fail); color: var(--text); }
.notice.fail b { color: var(--fail); }

/* ── budget ──────────────────────────────────────────────────────────────── */

.figure {
  font-size: 46px;
  letter-spacing: -.03em;
  line-height: 1.05;
  color: var(--text);
  transition: color .25s var(--ease);
  display: block;
}
.figure .fig-tail { color: var(--dim); }
.figure.refunding, .figure.refunding .fig-tail { color: var(--accent); }

.delta {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: .04em;
  animation: swap-in .25s var(--ease);
}

.meter {
  height: 4px;
  background: var(--border);
  border-radius: 0;
  margin: 14px 0 16px;
  overflow: hidden;
}
.meter.thin { height: 3px; margin: 8px 0 0; }
.meter-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width .3s var(--ease), background .2s var(--ease);
}
.outlay-fill { width: 0; background: color-mix(in srgb, var(--accent) 65%, var(--surface-3)); }

/* Boxed stat tiles, from the design mock. Two figures side by side scan far
   faster than three stacked label/value rows. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tile-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.tile b { font-size: 15px; font-weight: 400; color: var(--text); }
.tile:last-child b { color: var(--accent); }

.netbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 12px 13px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
}
.netbox span {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.netbox b { font-size: 18px; font-weight: 400; color: var(--text); }

.outlay { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.outlay-head { display: flex; justify-content: space-between; align-items: baseline; }
.outlay-head span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.outlay-head b { font-size: 11.5px; color: var(--text); font-weight: 400; }

/* The one figure on screen that is not scoped to a single run. */
.wallet {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.wallet span {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.wallet b { font-size: 13px; font-weight: 400; color: var(--text); }
.wallet b.low { color: var(--pending); }

/* ── ledger ──────────────────────────────────────────────────────────────── */

.count { font-size: 10.5px; color: var(--dim); letter-spacing: .06em; }

.row-head, .row {
  display: grid;
  /* Budgeted against a 380px rail (348px inner). The tx cell must never wrap:
     a two-line row breaks the fixed 32px height the whole table depends on. */
  grid-template-columns: 78px 48px 66px 72px 26px 10px;
  gap: 5px;
  align-items: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.row > *, .row-head > * { min-width: 0; white-space: nowrap; overflow: hidden; }

.row-head {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dim);
  height: 24px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border-2);
}
.row-head span:nth-child(2),
.row-head span:nth-child(5) { text-align: right; }

.ledger .rows {
  display: flex;
  flex-direction: column;
  max-height: 268px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.empty { color: var(--dim); font-size: 12px; padding: 14px 0; font-family: var(--sans); }

/* Fixed 32px rows with a faint zebra. Nothing here may reflow as rows arrive. */
.row {
  height: 32px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  overflow: hidden;
  animation: row-in .24s var(--ease);
}
.row:nth-child(even) { background: rgba(255, 255, 255, .022); }
@keyframes row-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: none; }
}

.row .s-name  { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s-amt   { text-align: right; color: var(--text); }
.row .s-tx    { color: var(--accent); text-decoration: none; }
.row .s-tx:hover { text-decoration: underline; }
.row .s-tx.none { color: var(--dim); }
.row .s-ms    { text-align: right; color: var(--dim); }
.row .s-go    { color: var(--dim); text-decoration: none; font-size: 10px; }
.row .s-go:hover { color: var(--accent); }

/* Tinted status pills, from the design mock — a state reads as a badge rather
   than as another column of grey text. */
.s-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.row.is-fail .s-status {
  color: var(--fail);
  background: color-mix(in srgb, var(--fail) 12%, transparent);
  border-color: color-mix(in srgb, var(--fail) 35%, transparent);
}
.row.is-refund .s-amt::before { content: "+"; color: var(--accent); }

/* Footer bar, inset, pinned under the rows. */
.totals {
  margin: 14px -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-2);
  background: var(--surface-2);
  font-size: 11px;
}
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals span { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.totals b { font-weight: 400; font-size: 13px; }
.totals a { color: var(--accent); text-decoration: none; }
.totals a:hover { text-decoration: underline; }

/* ── delivered work ──────────────────────────────────────────────────────── */

.out-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--dim);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.out-head .by {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.report {
  background: var(--inlay);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0;
  padding: 16px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}
.report p { margin: 0 0 10px; }
.report p.muted { color: var(--muted); font-size: 12px; }

.verdict {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 5px 10px;
  border-radius: 0;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.verdict.v-approve { border-color: var(--accent); color: var(--accent); }
.verdict.v-comment { border-color: var(--pending); color: var(--pending); }
.verdict.v-request-changes { border-color: var(--fail); color: var(--fail); }

.finding {
  display: grid;
  grid-template-columns: 62px minmax(0, auto) 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.finding .sev {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pending);
}
.finding .sev.bad { color: var(--fail); }
.finding code { font-family: var(--mono); font-size: 11px; color: var(--accent); word-break: break-all; }
.finding span:last-child { color: var(--muted); line-height: 1.5; }

.report.missing {
  border-left-color: var(--fail);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
}
.report.missing b { color: var(--fail); font-weight: 500; }

.report.refused {
  border-left-color: var(--accent);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
}
.report.refused b { color: var(--accent); font-weight: 500; }

.findings {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.findings li {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  padding-left: 14px;
  position: relative;
}
.findings li::before { content: "·"; position: absolute; left: 3px; color: var(--accent); }

.chips-out { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip-out {
  font-family: var(--mono);
  font-size: 10px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--muted);
}
.chip-out b { color: var(--text); font-weight: 500; }
.chip-out.bad { border-color: var(--fail); }
.chip-out.bad b { color: var(--fail); }

/* ── inspector / agent def ───────────────────────────────────────────────── */

.inspector, .agentdef { padding: 14px 16px; }

.toggle-open {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.toggle-open:hover { color: var(--text); }
.caret { transition: transform .18s var(--ease); display: inline-block; color: var(--dim); }
.toggle-open[aria-expanded="true"] .caret { transform: rotate(90deg); color: var(--accent); }
.hint {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10.5px;
}

.json {
  margin: 14px 0 0;
  padding: 14px;
  background: var(--inlay);
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.json b { color: var(--accent); font-weight: 400; }
.json i { color: var(--muted); font-style: normal; }

.yaml { color: var(--text); max-height: none; }
.yaml .c { color: var(--dim); }
.yaml .k { color: var(--accent); }
.yaml .s { color: var(--pending); }

.agentnote {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 76ch;
}
.agentnote b { color: var(--text); font-weight: 500; }

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1280px) {
  .graph { overflow-x: auto; padding-bottom: 6px; }
  .grp-outer { flex: 0 0 260px; }
  .grp-inner { flex: 0 0 660px; }
  .node { flex: 1 1 118px; min-width: 118px; }
}

@media (max-width: 1080px) {
  main {
    grid-template-columns: 1fr;
    grid-template-areas: "controls" "graph" "rail" "output" "inspector" "agentdef";
  }
  .control-grid { grid-template-columns: 1fr 1fr; }
  .control-grid .field-block:first-child { grid-column: 1 / -1; }
}

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