:root {
  color-scheme: light;
  --bg: #f4f5ef;
  --surface: #fbfbf6;
  --surface-strong: #ffffff;
  --ink: #25231e;
  --muted: #6d6a61;
  --faint: #979286;
  --line: #dedbd0;
  --line-strong: #c7c2b6;
  --accent: #2f765f;
  --accent-ink: #114536;
  --accent-soft: #dcebe3;
  --amber: #ad6b2b;
  --amber-soft: #f2dfc2;
  --red: #a4483f;
  --red-soft: #f2d8d4;
  --steel: #526a72;
  --shadow: 0 28px 70px rgba(37, 35, 30, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    linear-gradient(135deg, rgba(47, 118, 95, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(173, 107, 43, 0.09), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: "Geist", "Aptos", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  gap: 18px;
  min-height: 100dvh;
  padding: 18px;
}

.side-rail {
  position: sticky;
  top: 18px;
  align-self: start;
  min-height: calc(100dvh - 36px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 251, 246, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 48%, var(--ink) 48%, var(--ink) 52%, transparent 52%),
    linear-gradient(0deg, transparent 48%, var(--accent) 48%, var(--accent) 52%, transparent 52%),
    var(--accent-soft);
}

.brand-lockup strong,
.brand-lockup small,
.scenario strong,
.scenario small,
.node strong,
.node small,
td span {
  display: block;
}

.brand-lockup strong {
  font-size: 1rem;
}

.brand-lockup small,
.scenario small,
td span,
.write-row p,
.trace-meta,
.quiet-panel p,
.conflict-shell p,
.runbook p {
  color: var(--muted);
}

.rail-section {
  margin-top: 22px;
}

.section-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-ink);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.71rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scenario-list {
  display: grid;
  gap: 8px;
}

.scenario {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.scenario:hover,
.action-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.scenario:active,
.action-button:active {
  transform: translateY(1px);
}

.scenario.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.scenario.active small {
  color: rgba(251, 251, 246, 0.7);
}

.action-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  transition: transform 180ms ease, background 180ms ease;
}

.runbook p {
  margin: 12px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 251, 246, 0.91);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.8fr);
  gap: 22px;
  align-items: end;
  padding: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 12px;
  font-size: 2.35rem;
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
  line-height: 1.18;
}

h3 {
  margin-bottom: 5px;
  font-size: 0.98rem;
}

.trace-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.91rem;
}

.trace-meta strong {
  color: var(--ink);
  font-family: "Geist Mono", "Aptos Mono", monospace;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.metric span {
  display: block;
  min-height: 30px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 1.8rem;
  line-height: 1;
}

.primary-grid,
.secondary-grid,
.tertiary-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.primary-grid {
  grid-template-columns: minmax(620px, 1.1fr) minmax(380px, 0.9fr);
}

.secondary-grid {
  grid-template-columns: minmax(620px, 1fr) minmax(360px, 0.64fr);
}

.tertiary-grid {
  grid-template-columns: minmax(420px, 0.85fr) minmax(520px, 1fr);
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel-head,
.workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.registry-tag,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.7rem;
  white-space: nowrap;
}

.pill.success {
  border-color: color-mix(in srgb, var(--accent) 42%, white);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.pill.warning {
  border-color: color-mix(in srgb, var(--amber) 38%, white);
  background: var(--amber-soft);
  color: #6f3f13;
}

.graph-canvas {
  position: relative;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--surface-strong);
  background-size: 36px 36px;
  overflow: hidden;
}

.graph-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.edge {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 0;
}

.success-edge {
  stroke: var(--accent);
}

.retry-edge {
  stroke: var(--amber);
  stroke-dasharray: 9 8;
  animation: dash 1.4s linear infinite;
}

.conflict-edge {
  stroke: var(--red);
  stroke-dasharray: 5 8;
}

.idle-edge {
  stroke: rgba(151, 146, 134, 0.32);
}

@keyframes dash {
  to {
    stroke-dashoffset: -34;
  }
}

.node {
  position: absolute;
  width: 158px;
  min-height: 72px;
  padding: 12px 10px 12px 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 44px rgba(37, 35, 30, 0.09);
}

.node small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.node-status {
  position: absolute;
  top: 16px;
  left: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--faint);
}

.node-source,
.node-active,
.node-confirmed {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.node-source .node-status,
.node-active .node-status,
.node-confirmed .node-status {
  background: var(--accent);
}

.node-retrying .node-status {
  background: var(--amber);
}

.node-conflict .node-status,
.node-held_for_review .node-status {
  background: var(--red);
}

.node.sws {
  left: 36px;
  top: 42px;
}

.node.mesh {
  left: calc(50% - 79px);
  top: 140px;
}

.node.shop {
  right: 38px;
  top: 42px;
}

.node.factories {
  right: 38px;
  top: 128px;
}

.node.kspcb {
  right: 38px;
  top: 214px;
}

.write-row {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.write-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.write-row p {
  margin-bottom: 0;
  font-size: 0.78rem;
}

pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #27241f;
  color: #f4f1e8;
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.74rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.duplicate-note,
.resolution-box {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  line-height: 1.4;
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(118px, 1fr));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mapping-grid-head,
.mapping-cell {
  min-height: 54px;
  padding: 11px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mapping-grid-head {
  min-height: 38px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
}

.mapping-cell.canonical {
  font-family: "Geist", "Aptos", sans-serif;
}

.mapping-cell.canonical span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.68rem;
}

.mapping-cell.hot {
  background: var(--amber-soft);
}

.quiet-panel,
.conflict-shell {
  min-height: 100%;
}

.quiet-panel p,
.conflict-shell p {
  line-height: 1.55;
}

.policy-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.policy-list div {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.policy-list dt {
  color: var(--ink);
  font-weight: 600;
}

.policy-list dd {
  margin: 2px 0 0;
  color: var(--muted);
}

.diff-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.diff-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.diff-box span,
.diff-box strong {
  display: block;
}

.diff-box span {
  color: var(--red);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.diff-box p {
  margin: 8px 0 0;
}

.audit-timeline {
  display: grid;
  gap: 0;
  overflow: auto;
}

.audit-event {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.audit-event:first-child {
  border-top: 0;
  padding-top: 0;
}

.audit-event time {
  color: var(--muted);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.72rem;
}

.audit-event span {
  color: var(--ink);
  font-weight: 600;
}

.audit-event p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.audit-event small {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.67rem;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.72);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
}

td {
  font-size: 0.86rem;
}

.submission-copy {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.submission-copy dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.submission-copy div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
}

.submission-copy dt {
  color: var(--muted);
  font-family: "Geist Mono", "Aptos Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.submission-copy dd {
  margin: 0;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .app-shell,
  .topbar,
  .primary-grid,
  .secondary-grid,
  .tertiary-grid {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: static;
    min-height: 0;
  }

  .scenario-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .panel,
  .side-rail {
    padding: 14px;
  }

  h1 {
    font-size: 1.72rem;
  }

  .scenario-list,
  .metrics,
  .submission-copy div {
    grid-template-columns: 1fr;
  }

  .graph-canvas {
    min-height: 560px;
  }

  .graph-lines {
    display: none;
  }

  .node {
    position: static;
    width: auto;
    margin: 12px;
  }

  .mapping-grid {
    grid-template-columns: 180px repeat(4, 150px);
  }
}
