/* Atlas_Trace — warm-dark link-analysis console.
   Palette from the Atlas_Trace direction: near-black warm neutral, red primary,
   green for confirmed movement. The board is the app; panels float over it. */

:root {
  --bg:        oklch(0.10 0.003 40);
  --bg-2:      oklch(0.13 0.004 45);
  --surface:   oklch(0.15 0.006 50);
  --surface-2: oklch(0.19 0.008 50);
  --line:      oklch(0.27 0.008 50);
  --line-soft: oklch(0.22 0.008 50);

  --text:  oklch(0.95 0.008 50);
  --dim:   oklch(0.72 0.008 50);
  --muted: oklch(0.55 0.008 50);
  --faint: oklch(0.40 0.008 50);

  --red:      oklch(0.60 0.19 25);
  --red-soft: oklch(0.60 0.19 25 / 0.14);
  --green:    oklch(0.65 0.16 150);
  --amber:    oklch(0.76 0.15 75);
  --cyan:     oklch(0.72 0.11 210);

  /* Risk bands. Distinct from the entity palette on purpose — the subject is
     red, so red alone must not be what "dangerous" looks like. */
  --risk-low:      oklch(0.62 0.03 240);
  --risk-elevated: oklch(0.78 0.14 85);
  --risk-high:     oklch(0.70 0.17 45);
  --risk-critical: oklch(0.62 0.24 12);

  --mono: 'JetBrains Mono', 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
  --sans: 'Space Grotesk', system-ui, sans-serif;

  --shadow: 0 18px 44px oklch(0 0 0 / 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* Panels and menus set `display`, which would otherwise beat the UA rule for
   the hidden attribute and make them impossible to close. */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: repeating-linear-gradient(
    to bottom, oklch(1 0 0 / 0.012) 0 1px, transparent 1px 3px);
}
body.is-dragging { user-select: none; cursor: grabbing; }

::selection { background: var(--red-soft); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ── top bar ───────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; flex-shrink: 0; z-index: 60;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--bg));
}

.brand { display: flex; align-items: baseline; gap: 9px; flex-shrink: 0; }
.brand-mark {
  font-family: var(--mono); font-weight: 700; font-size: 19px; color: var(--red);
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.35; } }
.brand-name { font-family: var(--mono); font-weight: 500; font-size: 19px; letter-spacing: -0.02em; }
.brand-sub {
  font-size: 10.5px; color: var(--muted); text-transform: lowercase;
  letter-spacing: 0.06em; padding-left: 9px; border-left: 1px solid var(--line);
}

.toolbar {
  display: flex; gap: 3px; padding: 3px; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.tool {
  min-width: 32px; padding: 4px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  border: 1px solid transparent; transition: all 0.12s;
}
.tool:hover { color: var(--text); background: var(--surface-2); }
.tool.is-active { color: var(--red); background: var(--red-soft); border-color: oklch(0.60 0.19 25 / 0.4); }

.add-type {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; font-family: var(--mono); font-size: 12px; color: var(--dim);
}

.board-stats { display: flex; gap: 14px; margin-left: 4px; }
.bstat { text-align: center; line-height: 1.1; }
.bstat b { display: block; font-family: var(--mono); font-size: 15px; color: var(--text); }
.bstat b.red { color: var(--red); }
.bstat span {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint);
}

.search {
  display: flex; align-items: center; gap: 7px; margin-left: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; height: 30px; width: 190px;
}
.search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search-sig { font-family: var(--mono); color: var(--faint); font-size: 12px; }
.search input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  font-family: var(--mono); font-size: 12px;
}
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.4); }

.status-strip { display: flex; gap: 7px; flex-shrink: 0; }
.chip {
  font-family: var(--mono); font-size: 10.5px; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface); color: var(--dim); white-space: nowrap;
}
.chip-ok      { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.4); }
.chip-warn    { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.4); }
.chip-bad     { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.45); background: var(--red-soft); }
.chip-pending { color: var(--faint); }
.chip-operator { color: var(--dim); font-family: var(--mono); cursor: default; }
.chip-operator::before { content: '◍ '; color: var(--green); }
.chip-operator.is-admin { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.4); }
.chip-operator.is-admin::before { color: var(--amber); }

.chip-logout {
  color: var(--muted); font-family: var(--mono); cursor: pointer;
  transition: all 0.12s;
}
.chip-logout:hover {
  color: var(--red); border-color: oklch(0.60 0.19 25 / 0.45);
  background: var(--red-soft);
}
.chip-logout:disabled { opacity: 0.5; cursor: progress; }

/* ── the board ─────────────────────────────────────────────────────────── */

.stage { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.board-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }

/* ── panel rail ────────────────────────────────────────────────────────── */

.rail {
  width: 76px; flex-shrink: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  padding: 10px 6px; overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, var(--surface), var(--bg));
}
.case-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; margin-bottom: 8px; border-radius: 7px;
  border: 1px solid oklch(0.60 0.19 25 / 0.35); background: var(--red-soft);
  color: var(--red); transition: all 0.12s;
}
.case-btn:hover { filter: brightness(1.25); }
.case-btn-glyph { font-family: var(--mono); font-size: 15px; line-height: 1; }
.case-btn-name {
  font-family: var(--mono); font-size: 8.5px; line-height: 1.2; text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rail-label {
  font-family: var(--mono); font-size: 8.5px; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--faint); text-align: center; padding-bottom: 6px;
}
.rail-panels { display: flex; flex-direction: column; gap: 3px; }
.rail-spacer { flex: 1; min-height: 10px; }

.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px; border-radius: 7px; border: 1px solid transparent;
  color: var(--muted); transition: all 0.12s;
}
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn.is-open {
  color: var(--red); background: var(--red-soft);
  border-color: oklch(0.60 0.19 25 / 0.35);
}
.rail-glyph { font-family: var(--mono); font-size: 15px; line-height: 1; }
.rail-name {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.04em;
  text-align: center; line-height: 1.2; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-util {
  padding: 6px 2px; border-radius: 6px; color: var(--muted);
  font-family: var(--mono); font-size: 14px; border: 1px solid transparent;
}
.rail-util:hover { color: var(--red); border-color: var(--line); background: var(--surface-2); }

#board { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
#board[data-mode='add']    { cursor: crosshair; }
#board[data-mode='link']   { cursor: cell; }
#board[data-mode='delete'] { cursor: not-allowed; }
body.is-dragging #board { cursor: grabbing; }

.at-node { cursor: grab; }
.at-node:active { cursor: grabbing; }
.at-label {
  fill: var(--text); font-family: var(--mono); font-weight: 500;
  user-select: none; pointer-events: none;
}
.at-sublabel {
  fill: var(--faint); font-family: var(--mono); user-select: none; pointer-events: none;
}
.at-glyph { user-select: none; pointer-events: none; font-family: var(--mono); }
.at-ring { animation: ringSpin 12s linear infinite; transform-origin: center; }
@keyframes ringSpin { to { stroke-dashoffset: -80; } }
.at-edge { cursor: pointer; }
.at-edge-label { font-family: var(--mono); user-select: none; pointer-events: none; }
.at-edge-dash { animation: edgeDash 1.4s linear infinite; }
@keyframes edgeDash { to { stroke-dashoffset: -24; } }

.hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 18px; z-index: 30; pointer-events: none;
  background: var(--red-soft); border: 1px solid oklch(0.60 0.19 25 / 0.35);
  color: var(--red); font-family: var(--mono); font-size: 12px;
}

.tooltip {
  position: fixed; top: 0; left: 0; z-index: 300; pointer-events: none;
  min-width: 190px; max-width: 300px; padding: 9px 11px; border-radius: 8px;
  background: oklch(0.13 0.004 45 / 0.97); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-family: var(--mono); font-size: 11px;
}
.tip-head { color: var(--text); font-size: 12px; margin-bottom: 3px; }
.tip-addr { color: var(--faint); font-size: 10px; word-break: break-all; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.tip-row b { color: var(--dim); font-weight: 500; }
.tip-labels { margin-top: 5px; color: var(--amber); font-size: 10.5px; }
.tip-hint { margin-top: 6px; color: var(--faint); font-size: 9.5px; }

.minimap {
  position: absolute; right: 16px; bottom: 16px; z-index: 30;
  background: oklch(0.13 0.004 45 / 0.92); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; line-height: 0;
}

.zoom-stack {
  position: absolute; left: 16px; bottom: 16px; z-index: 30;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.zoom-btn {
  width: 30px; height: 30px; border-radius: 7px;
  background: oklch(0.13 0.004 45 / 0.92); border: 1px solid var(--line);
  color: var(--muted); font-family: var(--mono); font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s;
}
.zoom-btn:hover { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.4); }
.zoom-level { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }

/* ── floating windows ──────────────────────────────────────────────────── */

.windows { position: absolute; inset: 0; pointer-events: none; }

.win {
  position: absolute; pointer-events: auto;
  display: flex; flex-direction: column; overflow: hidden;
  background: oklch(0.15 0.006 50 / 0.96);
  border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}
.win.is-active { border-color: oklch(0.60 0.19 25 / 0.45); }
.win.is-min .win-body, .win.is-min .win-resize { display: none; }

.win-head {
  display: flex; align-items: center; gap: 8px; height: 28px; flex-shrink: 0;
  padding: 0 8px 0 10px; cursor: grab; user-select: none;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.win-head:active { cursor: grabbing; }
.win-grip { font-family: var(--mono); color: var(--faint); font-size: 11px; letter-spacing: -1px; }
.win-title {
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--dim);
}
.win.is-active .win-title { color: var(--red); }
.win-rule {
  flex: 1; height: 1px; color: var(--line);
  background-image: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px);
}
.win-tag {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win-btn {
  width: 18px; height: 18px; border-radius: 4px; color: var(--muted);
  font-family: var(--mono); font-size: 12px; line-height: 1;
}
.win-btn:hover { background: var(--surface-2); color: var(--text); }
.win-btn[data-act='close']:hover { background: var(--red-soft); color: var(--red); }

.win-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }

/* Resize handles — thin strips on every edge, larger pads at the corners. */
.win-edge { position: absolute; z-index: 2; }
.win.is-min .win-edge:not(.win-edge-e):not(.win-edge-w) { display: none; }

.win-edge-n { top: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-edge-s { bottom: -3px; left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.win-edge-e { right: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-edge-w { left: -3px; top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.win-edge-ne { top: -3px; right: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-edge-nw { top: -3px; left: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.win-edge-sw { bottom: -3px; left: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.win-edge-se {
  bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize;
  color: var(--faint); font-size: 9px; line-height: 16px; text-align: right;
  padding-right: 1px;
}
.win-edge-se:hover { color: var(--red); }

/* ── command panel ─────────────────────────────────────────────────────── */

.cmd-picker {
  margin: 10px 12px 0; padding: 7px 9px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; color: var(--text); outline: none;
}
.cmd-picker:focus { border-color: var(--red); }

.blurb {
  padding: 8px 12px 2px; font-size: 12px; line-height: 1.45;
  color: var(--muted); text-transform: lowercase;
}

.fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 10px; padding: 8px 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font-family: var(--mono); font-size: 12px;
  outline: none; transition: border-color 0.12s, box-shadow 0.12s; min-width: 0;
}
.field textarea { resize: vertical; min-height: 54px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field .hint { font-size: 10px; color: var(--faint); text-transform: lowercase; }

.toggle {
  display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 5px 0;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
}
.toggle input { display: none; }
.toggle .box {
  font-family: var(--mono); color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px;
}
.toggle input:checked + .box { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.45); }

.preview {
  margin: 4px 12px 0; padding: 7px 9px; border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; color: var(--green);
  background: var(--bg); border: 1px solid var(--line-soft);
  overflow-x: auto; white-space: nowrap;
}
.preview.invalid { color: var(--amber); }

.lint:empty { display: none; }
.lint { display: flex; flex-direction: column; gap: 4px; margin: 7px 12px 0; }
.lint-note {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.45;
  padding: 6px 8px; border-radius: 5px; border-left: 2px solid;
}
.lint-note.is-error { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.lint-note.is-warn { color: var(--amber); background: oklch(0.76 0.15 75 / 0.1); border-color: var(--amber); }
.lint-note::before { content: '! '; }

.preview-row {
  display: flex; gap: 8px; padding: 10px 12px; margin-top: auto;
  border-top: 1px solid var(--line-soft);
}
.btn {
  font-family: var(--mono); font-size: 11.5px; border-radius: 6px;
  padding: 7px 12px; white-space: nowrap; transition: filter 0.12s, background 0.12s;
}
.btn-primary { background: var(--red); color: oklch(0.98 0.01 25); font-weight: 700; flex: 1; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { border: 1px solid var(--line); color: var(--dim); background: var(--surface-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { border: 1px solid var(--red); color: var(--red); background: var(--red-soft); }

/* ── terminal ──────────────────────────────────────────────────────────── */

.term {
  flex: 1; min-height: 0; overflow: auto; background: var(--bg);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  padding: 10px 12px; color: var(--dim);
  white-space: pre-wrap; word-break: break-word;
}
.term:focus { outline: none; }
.term .l-banner { color: var(--red); }
.term .l-cmd { color: var(--text); }
.term .l-cmd .sig { color: var(--red); }
.term .l-err { color: var(--red); }
.term .l-ok { color: var(--green); }
.term .l-note { color: var(--faint); }
.term .cursor {
  display: inline-block; width: 7px; height: 13px; vertical-align: -2px;
  background: var(--red); animation: blink 1s steps(1) infinite;
}

/* ── trace readout ─────────────────────────────────────────────────────── */

.map { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.map .empty, .win-body > .empty {
  color: var(--faint); font-size: 12px; line-height: 1.6;
  text-transform: lowercase; padding: 12px;
}
.map-stats { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 5px 9px; min-width: 66px;
}
.stat .k {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--faint);
}
.stat .v { font-family: var(--mono); font-size: 14px; color: var(--text); }
.stat .v.red { color: var(--red); }
.stat .v.green { color: var(--green); }

.tree { font-family: var(--mono); font-size: 11.5px; line-height: 1.7; }
.hop { white-space: pre; display: block; cursor: pointer; }
.hop:hover { background: oklch(1 0 0 / 0.04); }
.hop .stem { color: var(--faint); }
.hop .addr { color: var(--text); }
.hop .arrow { color: var(--red); }
.hop .amount { color: var(--green); }
.hop .usd { color: var(--dim); }
.hop .bar { color: var(--red); }
.hop .bar .off { color: var(--line); }
.hop .swap { color: var(--cyan); }
.hop .meta { color: var(--faint); }

.section-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--faint);
  margin: 14px 12px 7px; display: flex; align-items: center; gap: 8px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.map .section-label { margin-left: 0; margin-right: 0; }

.terminal-node {
  font-family: var(--mono); font-size: 11px; line-height: 1.55; cursor: pointer;
  padding: 5px 8px; border-left: 2px solid var(--line); margin-bottom: 4px;
  background: var(--surface-2); border-radius: 0 5px 5px 0;
}
.terminal-node:hover { background: oklch(0.22 0.008 50); }
.terminal-node.r-labeled-entity { border-left-color: var(--green); }
.terminal-node.r-mixer { border-left-color: var(--red); }
.terminal-node.r-bridge { border-left-color: var(--cyan); }
.terminal-node.r-max-depth { border-left-color: var(--amber); }
.terminal-node .reason { color: var(--muted); }
.terminal-node .labels { color: var(--amber); }

/* ── inspector ─────────────────────────────────────────────────────────── */

.insp-head {
  display: flex; gap: 10px; align-items: center;
  padding: 12px; border-bottom: 1px solid var(--line-soft);
}
.insp-glyph {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 16px; color: var(--red);
  background: var(--red-soft); border: 1px solid oklch(0.60 0.19 25 / 0.35);
}
.insp-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.insp-addr { font-family: var(--mono); font-size: 10px; color: var(--faint); word-break: break-all; }

/* ── risk block ────────────────────────────────────────────────────────── */

.risk-block {
  margin: 10px 12px; padding: 10px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.risk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.risk-score {
  font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1;
  min-width: 44px; text-align: center; padding: 5px 6px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.risk-score.is-low { color: var(--risk-low); }
.risk-score.is-elevated { color: var(--risk-elevated); border-color: var(--risk-elevated); }
.risk-score.is-high { color: var(--risk-high); border-color: var(--risk-high); }
.risk-score.is-critical {
  color: var(--risk-critical); border-color: var(--risk-critical);
  background: color-mix(in oklch, var(--risk-critical) 12%, transparent);
}
.risk-meta { display: flex; flex-direction: column; gap: 2px; }
.risk-band {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--dim);
}
.risk-origin { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.risk-filed { font-family: var(--mono); font-size: 9.5px; color: var(--green); cursor: help; }
.risk-filed.is-unfiled { color: var(--faint); }

.risk-slider { width: 100%; accent-color: var(--risk-high); cursor: pointer; }

.risk-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.risk-chip {
  font-family: var(--mono); font-size: 9.5px; padding: 3px 7px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--line); color: var(--risk-elevated);
  cursor: help;
}
.risk-acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.tip-risk {
  font-family: var(--mono); font-size: 10.5px; margin-bottom: 6px;
  padding: 3px 6px; border-radius: 4px; border-left: 2px solid;
}
.tip-risk.is-low { color: var(--risk-low); border-color: var(--risk-low); }
.tip-risk.is-elevated { color: var(--risk-elevated); border-color: var(--risk-elevated); }
.tip-risk.is-high { color: var(--risk-high); border-color: var(--risk-high); }
.tip-risk.is-critical {
  color: var(--risk-critical); border-color: var(--risk-critical);
  background: color-mix(in oklch, var(--risk-critical) 14%, transparent);
}
.tip-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tip-flags span { font-size: 9.5px; color: var(--risk-elevated); }

.at-flag { cursor: help; }
.at-risk-value { font-family: var(--mono); user-select: none; pointer-events: none; }

.insp-facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  margin: 10px 12px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-radius: 6px; overflow: hidden;
}
.insp-fact {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 5px 8px; background: var(--surface);
  font-family: var(--mono); font-size: 10.5px;
}
.insp-fact .k { color: var(--faint); }
.insp-fact .v { color: var(--dim); }

.insp-link {
  display: flex; gap: 8px; align-items: baseline; width: calc(100% - 24px);
  margin: 0 12px 3px; padding: 5px 8px; border-radius: 5px; text-align: left;
  background: var(--surface-2); font-family: var(--mono); font-size: 10.5px; color: var(--dim);
}
.insp-link:hover { background: oklch(0.23 0.008 50); }
.insp-link .dir { color: var(--red); }
.insp-link .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-link .amt { color: var(--green); }

.insp-hash {
  font-family: var(--mono); font-size: 10px; color: var(--dim); cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; word-break: break-all;
}
.insp-hash:hover { color: var(--text); border-color: var(--muted); }

.insp-actions {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 12px; margin-top: auto;
}
.insp-action {
  font-family: var(--mono); font-size: 10.5px; padding: 5px 9px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--dim);
  transition: all 0.12s;
}
.insp-action:hover { color: var(--text); border-color: var(--muted); background: oklch(0.23 0.008 50); }
.insp-action.danger { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.35); background: var(--red-soft); }

/* ── run log ───────────────────────────────────────────────────────────── */

.history { list-style: none; overflow-y: auto; padding: 8px 10px; }
.history li {
  font-family: var(--mono); font-size: 11px; color: var(--dim);
  padding: 4px 7px; border-radius: 5px; display: flex; gap: 7px;
  align-items: baseline; cursor: pointer;
}
.history li:hover { background: var(--surface-2); }
.history .dot { font-size: 8px; }
.history .dot.ok { color: var(--green); }
.history .dot.bad { color: var(--red); }
.history .dot.run { color: var(--amber); }
.history .cmd { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .ms { color: var(--faint); font-size: 10px; }
.history .empty { color: var(--faint); cursor: default; }

/* ── legend ────────────────────────────────────────────────────────────── */

.legend { padding: 4px 0 12px; }
.legend .section-label { margin-top: 12px; }
.legend-row {
  display: flex; align-items: center; gap: 9px; padding: 3px 12px;
  font-family: var(--mono); font-size: 11px; color: var(--dim); cursor: default;
}
.legend-row:hover { background: var(--surface-2); }
.legend-glyph { width: 16px; text-align: center; font-size: 13px; }
.legend-line { width: 22px; letter-spacing: -1px; }
.legend-label { flex: 1; }
.legend-shape, .legend-count { color: var(--faint); font-size: 10px; }
.legend-count { color: var(--text); font-size: 11px; }

/* ── agent panel ───────────────────────────────────────────────────────── */

.agent-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.agent-msg { display: flex; flex-direction: column; gap: 3px; }
.agent-role {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--faint);
}
.agent-msg.is-you .agent-role { color: var(--red); }
.agent-text {
  font-size: 12.5px; line-height: 1.55; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.agent-msg.is-you .agent-text {
  color: var(--dim); border-left: 2px solid var(--red);
  padding-left: 9px; background: var(--red-soft); border-radius: 0 6px 6px 0;
  padding: 6px 9px;
}
.agent-note {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.5; color: var(--faint);
  text-transform: lowercase;
}
.agent-note.is-err {
  color: var(--red); background: var(--red-soft); border-left: 2px solid var(--red);
  padding: 6px 8px; border-radius: 0 5px 5px 0; text-transform: none;
}
.agent-tool {
  display: flex; gap: 8px; align-items: baseline; padding: 5px 8px;
  border-radius: 5px; background: var(--surface-2); border-left: 2px solid var(--green);
  font-family: var(--mono); font-size: 10.5px;
}
.agent-tool-name { color: var(--green); }
.agent-tool-name::before { content: '▸ '; }
.agent-tool-args {
  color: var(--faint); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.agent-form {
  flex-shrink: 0; padding: 10px 12px; border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.agent-input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 9px; font-family: var(--sans); font-size: 12.5px; color: var(--text);
  outline: none; resize: vertical; min-height: 44px;
}
.agent-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.agent-input::placeholder { color: var(--faint); }
.agent-controls { display: flex; gap: 7px; }
.agent-controls .btn-primary { flex: 1; }

/* ── csv panel ─────────────────────────────────────────────────────────── */

.csv-bar {
  display: flex; gap: 7px; padding: 10px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.csv-name {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font-family: var(--mono); font-size: 12px;
  outline: none;
}
.csv-name:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.csv-bar .btn-primary { flex: 0 0 auto; }

.csv-notes { padding: 8px 12px 0; display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.csv-note { font-family: var(--mono); font-size: 10px; color: var(--faint); }

.csv-table-wrap { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 12px; }
.csv-table { border-collapse: collapse; font-family: var(--mono); font-size: 10.5px; }
.csv-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  background: var(--surface-2); color: var(--dim); font-weight: 500;
  padding: 5px 8px; border-bottom: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 9.5px;
}
.csv-table td {
  padding: 4px 8px; color: var(--dim); border-bottom: 1px solid var(--line-soft);
  white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis;
}
.csv-table td.num { color: var(--red); }
.csv-table tbody tr:hover td { background: oklch(1 0 0 / 0.03); color: var(--text); }

.csv-status {
  font-family: var(--mono); font-size: 10.5px; padding: 7px 12px; flex-shrink: 0;
  border-top: 1px solid var(--line-soft);
}
.csv-status.is-ok { color: var(--green); }
.csv-status.is-err { color: var(--red); background: var(--red-soft); }

/* ── case folder panel ─────────────────────────────────────────────────── */

.files-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.files-case {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.files-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.files-list .empty { padding: 12px 6px; }

.file-row { display: flex; align-items: stretch; gap: 4px; }
.file-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line-soft);
  background: var(--surface-2); transition: all 0.12s;
}
.file-open:hover { border-color: var(--muted); background: oklch(0.23 0.008 50); }
.file-glyph { font-family: var(--mono); color: var(--green); font-size: 13px; }
.file-text { min-width: 0; display: flex; flex-direction: column; }
.file-name {
  font-family: var(--mono); font-size: 11.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta { font-family: var(--mono); font-size: 9.5px; color: var(--faint); }
.file-act {
  display: flex; align-items: center; justify-content: center; width: 26px;
  border-radius: 6px; border: 1px solid var(--line-soft); background: var(--surface-2);
  color: var(--muted); font-family: var(--mono); font-size: 13px; text-decoration: none;
  transition: all 0.12s;
}
.file-act:hover { color: var(--text); border-color: var(--muted); }
.file-act.danger:hover { color: var(--red); background: var(--red-soft); border-color: var(--red); }

/* ── one-off question ──────────────────────────────────────────────────── */

.ask-overlay {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background: oklch(0.10 0.003 40 / 0.8); backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
}
.ask-panel {
  width: min(520px, 100%); padding: 24px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.ask-title {
  font-family: var(--mono); font-size: 17px; color: var(--text); margin-bottom: 10px;
}
.ask-body {
  font-size: 12.5px; line-height: 1.55; color: var(--dim);
  text-transform: lowercase; margin-bottom: 16px;
}
.ask-options { display: flex; flex-direction: column; gap: 8px; }
.ask-option {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: all 0.12s;
}
.ask-option:hover { border-color: var(--red); background: var(--red-soft); }
.ask-option-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.ask-option-note {
  font-size: 11.5px; line-height: 1.45; color: var(--muted); text-transform: lowercase;
}
.ask-foot {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  margin-top: 14px; text-transform: lowercase;
}

/* Rows for entities still waiting to be placed. */
.csv-table tbody tr.is-unplaced { cursor: crosshair; }
.csv-table tbody tr.is-unplaced td { color: var(--amber); }
.csv-table tbody tr.is-unplaced td:first-child::before { content: '⊕ '; color: var(--amber); }
.csv-table tbody tr.is-unplaced:hover td {
  background: oklch(0.76 0.15 75 / 0.12); color: var(--text);
}
#board[data-mode='place'] { cursor: copy; }

/* ── case picker ───────────────────────────────────────────────────────── */

.case-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  background: oklch(0.10 0.003 40 / 0.86); backdrop-filter: blur(7px);
  animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.case-panel {
  width: min(860px, 100%); max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}

.case-head { padding: 22px 26px 16px; border-bottom: 1px solid var(--line-soft); }
.case-head .brand { margin-bottom: 6px; }
.case-head .brand-name { font-size: 24px; }
.case-head .brand-mark { font-size: 24px; }
.case-tagline { font-size: 12.5px; color: var(--muted); text-transform: lowercase; }

.case-columns {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 0;
  min-height: 0; flex: 1;
}
.case-col { padding: 16px 22px; min-height: 0; display: flex; flex-direction: column; }
.case-col-new { border-left: 1px solid var(--line-soft); background: var(--bg); }
.case-col .section-label { margin: 0 0 10px; }

.case-list { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; min-height: 140px; }
.case-empty {
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
  padding: 18px 4px; text-transform: lowercase;
}

.case-row {
  text-align: left; padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--surface-2);
  transition: all 0.12s;
}
.case-row:hover { border-color: var(--muted); background: oklch(0.23 0.008 50); }
.case-row.is-active { border-color: var(--red); background: var(--red-soft); }
.case-row-top { display: flex; align-items: baseline; gap: 8px; }
.case-id { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.case-name { font-family: var(--mono); font-size: 13px; color: var(--text); flex: 1; }
.case-status {
  font-family: var(--mono); font-size: 9.5px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--muted); text-transform: uppercase;
}
.case-status.is-open { color: var(--green); border-color: oklch(0.65 0.16 150 / 0.4); }
.case-desc { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.case-meta {
  display: flex; gap: 10px; margin-top: 5px;
  font-family: var(--mono); font-size: 10px; color: var(--faint);
}
.case-current { color: var(--red); }

.case-row-wrap { display: flex; align-items: stretch; gap: 5px; }
.case-row-wrap .case-row { flex: 1; min-width: 0; }
.case-acts { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.case-act {
  font-family: var(--mono); font-size: 9.5px; padding: 4px 8px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  transition: all 0.12s; min-width: 58px;
}
.case-act:hover { color: var(--text); border-color: var(--muted); }
.case-act.danger { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.3); }
.case-act.danger:hover { background: var(--red-soft); }

.case-col-new .field { margin-bottom: 10px; }
.case-col-new .btn-primary { width: 100%; }
.case-error {
  font-family: var(--mono); font-size: 10.5px; color: var(--red);
  background: var(--red-soft); border-left: 2px solid var(--red);
  padding: 6px 8px; border-radius: 5px; margin-top: 10px;
}
.case-hint {
  font-size: 11px; line-height: 1.5; color: var(--faint);
  text-transform: lowercase; margin-top: auto; padding-top: 14px;
}

.case-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 22px; border-top: 1px solid var(--line-soft);
}

@media (max-width: 720px) {
  .case-columns { grid-template-columns: 1fr; }
  .case-col-new { border-left: none; border-top: 1px solid var(--line-soft); }
}

/* ── context menu ──────────────────────────────────────────────────────── */

.ctx-menu {
  position: fixed; z-index: 400; min-width: 178px; padding: 4px;
  background: oklch(0.15 0.006 50 / 0.98); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.ctx-menu hr { border: none; height: 1px; background: var(--line-soft); margin: 4px 2px; }
.ctx-item {
  text-align: left; padding: 6px 10px; border-radius: 5px;
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
}
.ctx-item:hover { background: var(--surface-2); color: var(--text); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red-soft); }

/* ── transactions and the investigation's origin ───────────────────────── */

.at-origin-ring { animation: originSpin 18s linear infinite; transform-origin: center; }
@keyframes originSpin { to { stroke-dashoffset: -60; } }
.at-origin-tag {
  font-family: var(--mono); letter-spacing: 0.12em;
  user-select: none; pointer-events: none;
}

.origin-note {
  margin: 10px 12px 0; padding: 7px 9px; border-radius: 6px;
  border-left: 2px solid var(--green);
  background: color-mix(in oklch, var(--green) 10%, transparent);
  font-family: var(--mono); font-size: 10.5px; color: var(--green);
}

/* The remembered answer, pre-selected so repeating it is one keypress. */
.ask-option.is-preferred {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px oklch(0.60 0.19 25 / 0.35);
}
.ask-option.is-preferred .ask-option-name::after {
  content: '  ⏎'; color: var(--red); font-size: 11px;
}
.ask-option:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ── account administration ────────────────────────────────────────────── */

.acct-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.acct {
  padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--line-soft); background: var(--surface-2);
}
.acct.is-disabled { opacity: 0.55; }
.acct-head { display: flex; align-items: baseline; gap: 8px; }
.acct-name { font-family: var(--mono); font-size: 13px; color: var(--text); }
.acct-role {
  font-family: var(--mono); font-size: 9px; padding: 1px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.08em;
  border: 1px solid var(--line); color: var(--muted);
}
.acct-role.is-admin { color: var(--amber); border-color: oklch(0.76 0.15 75 / 0.45); }
.acct-you { font-family: var(--mono); font-size: 9px; color: var(--green); }
.acct-off { font-family: var(--mono); font-size: 9px; color: var(--red); margin-left: auto; }
.acct-meta { font-family: var(--mono); font-size: 9.5px; color: var(--faint); margin-top: 3px; }
.acct-acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.acct-act {
  font-family: var(--mono); font-size: 10px; padding: 4px 8px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg); color: var(--dim); transition: all 0.12s;
}
.acct-act:hover { color: var(--text); border-color: var(--muted); }
.acct-act.danger { color: var(--red); border-color: oklch(0.60 0.19 25 / 0.35); }
.acct-act.danger:hover { background: var(--red-soft); }

.acct-add { flex-shrink: 0; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.acct-add .section-label { margin: 0 0 8px; }
.acct-row { display: flex; gap: 6px; flex-wrap: wrap; }
.acct-input {
  flex: 1; min-width: 96px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; font-family: var(--mono); font-size: 11.5px; outline: none;
}
.acct-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.acct-role { flex: 0 0 84px; }
.acct-status {
  font-family: var(--mono); font-size: 10.5px; padding: 7px 12px; flex-shrink: 0;
  border-top: 1px solid var(--line-soft);
}
.acct-status.is-ok { color: var(--green); }
.acct-status.is-err { color: var(--red); background: var(--red-soft); }

/* First-run setup reuses the login card. */
.login-card.is-setup { border-color: oklch(0.65 0.16 150 / 0.5); }
.login-card.is-setup .login-submit { background: var(--green); color: oklch(0.15 0.02 150); }
.login-hint {
  margin-top: 10px; font-family: var(--mono); font-size: 10px; line-height: 1.5;
  color: var(--faint); text-transform: lowercase;
}

.acct-audit {
  flex-shrink: 0; max-height: 190px; overflow-y: auto;
  padding: 0 12px 10px; border-top: 1px solid var(--line-soft);
}
.acct-audit .section-label { margin: 10px 0 6px; }
.audit-row {
  display: flex; gap: 8px; align-items: baseline;
  font-family: var(--mono); font-size: 9.5px; padding: 2px 0; color: var(--dim);
}
.audit-when { color: var(--faint); flex: 0 0 118px; }
.audit-what { flex: 0 0 118px; color: var(--muted); }
.audit-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-note { color: var(--amber); }
.audit-row.is-signin .audit-what { color: var(--green); }
.audit-row.is-signin-failed .audit-what { color: var(--amber); }
.audit-row.is-signin-throttled .audit-what { color: var(--red); }
.audit-row.is-account-delete .audit-what { color: var(--red); }
.audit-row.is-account-create .audit-what,
.audit-row.is-setup .audit-what { color: var(--green); }
