@font-face {
  font-family: "DM Sans";
  src: url("./fonts/DM-Sans.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

/* =========================================================
   Tokens — one light system. Code/stack evidence is the only
   dark surface, and it is always a contained block.
   ========================================================= */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --hover: #f3f5f8;
  --selected: #eef2fe;

  --ink: #12161c;
  --ink-2: #59616e;
  --ink-3: #8b929e;

  --line: #e7eaef;
  --line-strong: #d7dce4;

  --accent: #2f5bea;
  --accent-ink: #2546c0;
  --accent-bg: #edf1fe;

  --ok: #0f7a55;
  --ok-bg: #e8f5ef;
  --warn: #946000;
  --warn-bg: #fbf2e1;
  --bad: #ab2b21;
  --bad-bg: #fcebe9;

  --code: #12161d;
  --code-2: #1a202a;
  --code-ink: #e7eaf0;
  --code-ink-2: #9aa4b4;

  --sans: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, monospace;

  --r: 6px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.list,
.evidence,
.ledger-rows,
.palette-list,
.sheet-body,
.pipeline {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.list::-webkit-scrollbar,
.evidence::-webkit-scrollbar,
.ledger-rows::-webkit-scrollbar,
.palette-list::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar,
.pipeline::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

.list::-webkit-scrollbar-thumb,
.evidence::-webkit-scrollbar-thumb,
.ledger-rows::-webkit-scrollbar-thumb,
.palette-list::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb,
.pipeline::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: content-box;
  background-color: #cfd5df;
}

.list::-webkit-scrollbar-thumb:hover,
.evidence::-webkit-scrollbar-thumb:hover {
  background-color: #b3bccb;
}

.ic {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.ic.sm {
  width: 15px;
  height: 15px;
}

.skip {
  position: fixed;
  top: -40px;
  left: 12px;
  z-index: 50;
  padding: 8px 12px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r);
  text-decoration: none;
}

.skip:focus {
  top: 8px;
}

/* =========================================================
   Frame
   ========================================================= */
.app {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  height: 100dvh;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.rail-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}

.rail-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  color: var(--ink-3);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}

.rail-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.rail-btn[aria-current="page"] {
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.rail-bottom {
  margin-top: auto;
}

.shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
}

/* =========================================================
   Topbar — exactly one row, 48px
   ========================================================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  flex: none;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.tier {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tier[data-tier="TEST"] {
  background: #33415c;
}

.tier[data-tier="DATA"] {
  background: #1f4d43;
}

.tier[data-tier="LOCAL"] {
  background: #3d4a5c;
}

.tier[data-tier="OFFLINE"] {
  background: #6b7482;
}

#env-select {
  max-width: 240px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#env-select:focus {
  outline: none;
}

.topbar-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* Search is a quiet input, not a bordered field everywhere */
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  max-width: 420px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink-3);
  transition: background 120ms var(--ease), box-shadow 120ms var(--ease);
}

.search:focus-within {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
}

.search input:focus {
  outline: none;
}

.sel-count {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.tool-select {
  height: 30px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.arg {
  width: 240px;
  min-width: 90px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
}

.arg.narrow {
  width: 120px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 120ms var(--ease);
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-primary kbd,
.kbd-hint kbd {
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.btn-primary kbd {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.9);
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 6px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}

.btn-text:hover {
  color: var(--ink);
  background: var(--hover);
}

.kbd-hint {
  flex: none;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--ink-3);
}

.kbd-hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

/* =========================================================
   Workbench: list + evidence
   ========================================================= */
.workbench {
  display: grid;
  grid-template-columns: clamp(320px, 27%, 430px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.targets {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 38px;
  flex: none;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.list-title {
  font-size: 12px;
  color: var(--ink-3);
}

.list-title strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.ns-filter select {
  max-width: 190px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}

.ns-filter select:focus {
  outline: none;
}

.list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}

.list:focus {
  outline: none;
}

.group {
  padding: 16px 14px 6px;
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.group strong {
  color: var(--ink-2);
  font-weight: 600;
}

.group span {
  font-family: var(--mono);
  font-size: 11px;
}

.row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 58px;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 100ms var(--ease);
}

.row:hover {
  background: var(--hover);
}

.row.focused {
  background: var(--surface-2);
  border-left-color: var(--accent);
}

.row.checked {
  background: var(--selected);
  border-left-color: var(--accent);
}

.row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.row-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.row-id {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.row-gen {
  padding: 0 4px;
  border-radius: 3px;
  background: var(--warn-bg);
  color: var(--warn);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
}

.row-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--ink-3);
}

.dot.ready {
  background: var(--ok);
}

.dot.mounting {
  background: var(--warn);
}

.dot.discovered {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink-3);
}

.dot.offline {
  background: var(--line-strong);
}

.row-metric {
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
}

.row-metric.hot {
  color: var(--bad);
  font-weight: 600;
}

.list-foot {
  flex: none;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
  min-height: 33px;
}

.empty {
  padding: 28px 14px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}

/* =========================================================
   Evidence pane
   ========================================================= */
.evidence {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
  padding: 0 24px;
}

.ev-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

.ev-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 12px;
  background: var(--bg);
}

.ev-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.ev-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
}

.ev-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 12.5px;
  white-space: nowrap;
}

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

.run-picker {
  height: 30px;
  max-width: 300px;
  padding: 0 24px 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.back-btn {
  display: none;
}

.verdict {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.5;
}

.verdict .dot {
  width: 7px;
  height: 7px;
  transform: translateY(-1px);
}

.verdict.bad {
  color: var(--bad);
}

.verdict .hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
  white-space: nowrap;
}

/* Replica lanes: rows, not cards */
.lanes {
  margin: 6px 0 0;
}

.lane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 5px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.lane:last-child {
  border-bottom: 0;
}

.lane-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.lane-name {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lane-flag {
  font-size: 11px;
  color: var(--bad);
  white-space: nowrap;
}

.lane-value {
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.lane-value.bad {
  color: var(--bad);
}

.lane-value.ok {
  color: var(--ink-2);
  font-weight: 500;
}

.lane-value.muted {
  color: var(--ink-3);
  font-weight: 400;
}

.lane-track {
  grid-column: 1 / -1;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.lane-track svg {
  display: block;
  width: 100%;
  height: 2px;
}

.lane-fill {
  fill: var(--ok);
}

.lane-fill.bad {
  fill: var(--bad);
}

.lane-fill.pending {
  fill: var(--warn);
}

.lane.active .lane-name {
  color: var(--accent-ink);
  font-weight: 600;
}

/* Detail */
.detail {
  margin: 16px 0 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-head strong {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
}

.detail-head span {
  font-size: 12px;
  color: var(--ink-3);
}

.detail-head .metric {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
}

.detail-note {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

/* Flame rows */
.flame {
  padding: 8px 10px;
}

.flame-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
}

.flame-row + .flame-row {
  margin-top: 2px;
}

.fill-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fill-rect {
  fill: #eef1f6;
}

.fill-rect.warn {
  fill: #f6ecdb;
}

.fill-rect.bad {
  fill: #f8e3e0;
}

.flame-row .sig {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.flame-row .cost {
  position: relative;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.flame-row .cost.warn {
  color: var(--warn);
}

.flame-row .cost.bad {
  color: var(--bad);
}

.flame-row.d1 {
  padding-left: 26px;
}

.flame-row.d2 {
  padding-left: 44px;
}

/* Thread stack — the only dark surface */
.thread {
  border-top: 1px solid var(--line);
}

.thread-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px 8px;
  font-family: var(--mono);
  font-size: 12.5px;
}

.thread-head .state {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.state.BLOCKED {
  background: var(--bad-bg);
  color: var(--bad);
}

.state.RUNNABLE {
  background: var(--ok-bg);
  color: var(--ok);
}

.state.WAITING,
.state.TIMED_WAITING {
  background: #eef1f6;
  color: var(--ink-2);
}

.thread-head .cpu {
  margin-left: auto;
  color: var(--ink-2);
  font-weight: 600;
}

.thread-note {
  margin: 0 16px 8px;
  font-size: 12px;
  color: var(--bad);
  font-family: var(--mono);
}

.stack {
  margin: 0;
  padding: 12px 16px;
  background: var(--code);
  color: var(--code-ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.stack .frame-arrow {
  color: var(--code-ink-2);
}

/* Tables inside evidence (JVM props, samples) */
.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kv th,
.kv td {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.kv th {
  width: 32%;
  color: var(--ink-3);
  font-weight: 500;
  font-family: var(--mono);
  font-size: 12px;
}

.kv td {
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-word;
}

/* Progress */
.progress {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.progress h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.progress p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
}

.steps-line {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.step {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.step.done {
  color: var(--ok);
}

.step.active {
  color: var(--accent-ink);
  font-weight: 600;
}

.step .dot {
  width: 5px;
  height: 5px;
}

.ev-empty {
  padding: 28px 22px;
  color: var(--ink-3);
  font-size: 13px;
  max-width: 520px;
  line-height: 1.7;
}

/* =========================================================
   Overview & cluster nodes
   ========================================================= */
.overview,
.nodes {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 40px;
}

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

.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.page-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.fleet,
.node-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fleet-row,
.node-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.fleet-row:last-child,
.node-row:last-child {
  border-bottom: 0;
}

.fleet-row {
  grid-template-columns: minmax(0, 1.6fr) 90px 90px 90px 90px 80px 92px;
  cursor: pointer;
}

.node-row {
  grid-template-columns: minmax(150px, 1.4fr) 70px 80px 90px minmax(120px, 1fr) 92px 22px;
  cursor: pointer;
}

.fleet-row:hover,
.node-row:hover {
  background: var(--hover);
}

.fleet-row.head,
.node-row.head {
  min-height: 34px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-3);
  cursor: default;
}

.fleet-name,
.node-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fleet-name small,
.node-name small {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 400;
}

.n {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
}

.n.bad {
  color: var(--bad);
  font-weight: 600;
}

.n.ok {
  color: var(--ok);
  font-weight: 600;
}

.ns-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

.ns-chip {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.ns-chip.more {
  background: transparent;
  border-style: dashed;
  color: var(--ink-3);
}

.chev {
  color: var(--ink-3);
  font-size: 11px;
  transition: transform 140ms var(--ease);
}

.node-row.open .chev {
  transform: rotate(90deg);
}

.node-detail {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 14px 34px;
}

.node-detail:last-child {
  border-bottom: 0;
}

.ns-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) 70px 80px 90px 92px;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
  cursor: pointer;
}

.ns-row:last-child {
  border-bottom: 0;
}

.ns-row:hover .ns-name {
  color: var(--accent-ink);
}

.ns-name {
  font-family: var(--mono);
  font-size: 12px;
}

.muted-cap {
  font-size: 11px;
  color: var(--ink-3);
}

.back-link {
  margin-right: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-3);
  font-size: 12px;
}

.back-link:hover {
  background: var(--hover);
  color: var(--ink);
}

/* =========================================================
   Ledger
   ========================================================= */
.ledger {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.ledger-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.ledger-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.ledger-head h1 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 650;
}

.ledger-tools {
  display: flex;
  gap: 6px;
}

.ledger-tools input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  font-size: 12.5px;
}

.ledger-tools select {
  height: 30px;
  padding: 0 22px 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 12.5px;
}

.ledger-rows {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.ledger-row {
  display: block;
  width: 100%;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  border-left: 2px solid transparent;
}

.ledger-row:hover {
  background: var(--hover);
}

.ledger-row.active {
  background: var(--selected);
  border-left-color: var(--accent);
}

.ledger-row .t {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
}

.ledger-row .src {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.ledger-row .src.mcp {
  color: var(--accent-ink);
}

.ledger-row .s {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
}

/* =========================================================
   Pipeline
   ========================================================= */
.pipeline {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.pipeline-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.pipeline h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.lead {
  margin: 6px 0 26px;
  font-size: 14px;
  color: var(--ink-2);
  max-width: 60ch;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.steps li {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.steps h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.steps p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
}

.mcp {
  margin-top: 32px;
}

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

.mcp h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.mcp pre {
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--code);
  color: var(--code-ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  overflow-x: auto;
}

.env-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}

.env-table th,
.env-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.env-table th {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 12px;
}

.env-table td:last-child {
  text-align: right;
}

.env-table code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--ink-2);
}

/* =========================================================
   Palette & sheet
   ========================================================= */
.palette,
.sheet {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(560px, 92vw);
  width: 100%;
}

.palette::backdrop,
.sheet::backdrop {
  background: rgba(18, 22, 28, 0.32);
}

.palette-box {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(18, 22, 28, 0.18);
  overflow: hidden;
}

#palette-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

#palette-input:focus {
  outline: none;
}

.palette-list {
  max-height: 320px;
  overflow: auto;
  padding: 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r);
  text-align: left;
  font-size: 13px;
}

.palette-item:hover,
.palette-item.active {
  background: var(--hover);
}

.palette-item small {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
}

.palette-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--ink-3);
}

.sheet-box {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--mono);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  color: var(--ink-2);
}

.icon-btn:hover {
  background: var(--hover);
}

.sheet-body {
  padding: 14px 16px;
  max-height: 70vh;
  overflow: auto;
}

.idl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 12.5px;
}

.idl dt {
  color: var(--ink-3);
}

.idl dd {
  margin: 0;
  font-family: var(--mono);
  word-break: break-all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  max-width: 70vw;
  text-align: center;
}

/* =========================================================
   Narrow screens
   ========================================================= */
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 52px;
  }

  .rail {
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 0 8px;
  }

  .rail-mark {
    display: none;
  }

  .rail-btn {
    width: 44px;
    height: 44px;
  }

  .rail-bottom {
    margin-top: 0;
  }

  .shell {
    height: calc(100dvh - 52px);
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    gap: 8px;
  }

  .env {
    flex: 1;
  }

  #env-select {
    max-width: 160px;
    font-size: 13px;
  }

  .kbd-hint {
    display: none;
  }

  .topbar-slot {
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
  }

  .search {
    max-width: none;
  }

  .arg {
    flex: 1 1 120px;
    width: auto;
  }

  .workbench,
  .ledger {
    grid-template-columns: minmax(0, 1fr);
  }

  .targets {
    border-right: 0;
  }

  .evidence {
    display: none;
  }

  .workbench.show-evidence .targets {
    display: none;
  }

  .workbench.show-evidence .evidence {
    display: flex;
  }

  .ledger-list {
    border-right: 0;
  }

  .ledger .evidence {
    display: none;
  }

  .ledger.show-evidence .ledger-list {
    display: none;
  }

  .ledger.show-evidence .evidence {
    display: flex;
  }

  .back-btn {
    display: inline-flex;
  }

  .evidence {
    padding: 0 14px;
  }

  .ev-head {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 14px 0 10px;
  }

  .ev-head > div:first-child {
    flex: 1 1 100%;
    min-width: 0;
  }

  .ev-head h1 {
    font-size: 17px;
  }

  .ev-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .run-picker {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .verdict .hint {
    display: none;
  }

  .detail-head {
    flex-wrap: wrap;
    row-gap: 3px;
  }

  .detail-head span:not(.metric) {
    flex: 1 1 100%;
  }

  .detail-head .metric {
    margin-left: 0;
  }

  .page {
    padding: 18px 14px 28px;
  }

  .page-head h1 {
    font-size: 20px;
  }

  .fleet-row {
    grid-template-columns: minmax(0, 1.5fr) 52px 64px 62px;
    padding: 0 12px;
  }

  .node-row {
    grid-template-columns: minmax(110px, 1.4fr) 56px 52px 18px;
    padding: 0 12px;
  }

  .fleet-row > :nth-child(5),
  .fleet-row > :nth-child(6),
  .fleet-row > :nth-child(7),
  .node-row > :nth-child(2),
  .node-row > :nth-child(5),
  .node-row > :nth-child(6) {
    display: none;
  }

  .node-detail {
    padding-left: 16px;
  }

  .ns-row {
    grid-template-columns: minmax(110px, 1.4fr) 52px 56px 52px;
  }

  .ns-row > :last-child {
    display: none;
  }

  .steps li {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}

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