/* The SUPPLY cockpit stylesheet (H5 / #148) — a compact, phone-friendly dark cockpit shared by the
   standalone shell and the console App-View embed, so the two render identically. The three-state
   liveness dot keys off `data-liveness` (live | stale | down). It styles the SUPPLY worker list only
   — no demand×supply matrix / diversity-SLO light (deferred to enrolment epic #152). */

:root {
  --cockpit-bg: #0b0f14;
  --cockpit-panel: #131a22;
  --cockpit-edge: #223041;
  --cockpit-text: #e6edf3;
  --cockpit-muted: #8b98a5;
  --cockpit-green: #2ea043;
  --cockpit-amber: #d29922;
  --cockpit-red: #f85149;
}

.cockpit-shell {
  color: var(--cockpit-text);
  background: var(--cockpit-bg);
  font: 14px/1.4 ui-sans-serif, system-ui, sans-serif;
  display: grid;
  gap: 12px;
  padding: 12px;
  min-height: 100%;
}

.cockpit-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.cockpit-title {
  font-size: 16px;
  margin: 0;
}

.cockpit-supply-summary {
  color: var(--cockpit-muted);
  font-variant-numeric: tabular-nums;
}

.cockpit-supply-region,
.cockpit-past-region,
.cockpit-agent-region,
.cockpit-agent-detail-region,
.cockpit-terminal {
  background: var(--cockpit-panel);
  border: 1px solid var(--cockpit-edge);
  border-radius: 8px;
  padding: 12px;
}

.cockpit-panel-title {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--cockpit-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cockpit-leaf {
  margin-bottom: 12px;
}

.cockpit-leaf-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.cockpit-leaf-name {
  font-weight: 600;
}

.cockpit-leaf-count {
  color: var(--cockpit-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cockpit-supply-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.cockpit-th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cockpit-muted);
  padding: 4px 8px;
  border-bottom: 1px solid var(--cockpit-edge);
}

.cockpit-td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(34, 48, 65, 0.5);
}

.cockpit-supply-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cockpit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  background: var(--cockpit-muted);
}

.cockpit-dot[data-liveness="live"] { background: var(--cockpit-green); }
.cockpit-dot[data-liveness="stale"] { background: var(--cockpit-amber); }
.cockpit-dot[data-liveness="down"] { background: var(--cockpit-red); }

.cockpit-worker,
.cockpit-worker-drill,
.cockpit-worker-detail-back,
.cockpit-worker-current-job {
  background: none;
  border: none;
  color: var(--cockpit-text);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cockpit-worker-drill {
  color: var(--cockpit-muted);
  font-size: 12px;
}

.cockpit-worker:hover,
.cockpit-worker-drill:hover,
.cockpit-worker-detail-back:hover,
.cockpit-worker-current-job:hover { color: #58a6ff; }

.cockpit-supply-process { color: var(--cockpit-muted); }

.cockpit-correlation {
  background: none;
  border: none;
  color: var(--cockpit-text);
  cursor: pointer;
  display: block;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cockpit-correlation:hover { color: #58a6ff; }

.cockpit-supply-liveness { color: var(--cockpit-muted); }

.cockpit-supply-empty {
  color: var(--cockpit-muted);
  padding: 8px 0;
}

.cockpit-terminal-host {
  min-height: 220px;
  background: #05080b;
  border-radius: 6px;
}

/* The "connected — waiting for output" status note under the terminal (blank-terminal defect fix):
   hidden until a live drill is connected-but-quiet, so a blank panel reads as "waiting" not "broken". */
.cockpit-terminal-note {
  margin: 8px 0 0;
  font-size: 0.85em;
  color: #7c8794;
  font-style: italic;
}
.cockpit-terminal-note[data-terminal-note="none"] {
  display: none;
}

/* ── Past sessions (H3 read path / #222): the captured-session history + replay. ──────────────── */

.cockpit-past-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cockpit-past-title {
  font-size: 13px;
  margin: 0;
  color: var(--cockpit-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cockpit-past-summary {
  color: var(--cockpit-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cockpit-past-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.cockpit-past-replay {
  background: none;
  border: none;
  color: var(--cockpit-text);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cockpit-past-replay:hover { color: #58a6ff; }

.cockpit-past-session[data-active="true"] {
  background: rgba(88, 166, 255, 0.12);
}

.cockpit-past-status { color: var(--cockpit-muted); }
.cockpit-past-size { color: var(--cockpit-muted); }
.cockpit-past-captured { color: var(--cockpit-muted); font-size: 12px; }

.cockpit-past-empty {
  color: var(--cockpit-muted);
  padding: 8px 0;
}

/* ── Agent history (engine-native settled AgentInstance/AgentHistory, #745/#747). ─────────────── */

.cockpit-agent-header,
.cockpit-agent-transcript-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cockpit-agent-title,
.cockpit-agent-transcript-title {
  font-size: 13px;
  margin: 0;
  color: var(--cockpit-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cockpit-agent-summary,
.cockpit-agent-transcript-metrics {
  color: var(--cockpit-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cockpit-agent-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.cockpit-agent-select {
  background: none;
  border: none;
  color: var(--cockpit-text);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cockpit-agent-select:hover { color: #58a6ff; }

.cockpit-agent-session[data-active="true"] {
  background: rgba(88, 166, 255, 0.12);
}

.cockpit-agent-status { color: var(--cockpit-muted); }
.cockpit-agent-metrics { color: var(--cockpit-muted); font-size: 12px; }
.cockpit-agent-captured { color: var(--cockpit-muted); font-size: 12px; }

.cockpit-agent-empty,
.cockpit-agent-transcript-empty {
  color: var(--cockpit-muted);
  padding: 8px 0;
}

.cockpit-agent-turn {
  border-top: 1px solid var(--cockpit-edge);
  padding: 8px 0;
}

.cockpit-agent-turn-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.cockpit-agent-turn-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #58a6ff;
}

.cockpit-agent-turn-iter,
.cockpit-agent-turn-metrics {
  font-size: 11px;
  color: var(--cockpit-muted);
  font-variant-numeric: tabular-nums;
}

.cockpit-agent-turn-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.cockpit-agent-turn-tools {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--cockpit-muted);
  font-size: 12px;
}

/* ── Worker detail route (#/cockpit/worker/<instance>): header + current job + filtered history. ── */

.cockpit-worker-detail {
  display: grid;
  gap: 12px;
}

.cockpit-worker-detail-back {
  justify-self: start;
  color: var(--cockpit-muted);
}

.cockpit-worker-detail-header {
  display: grid;
  gap: 8px;
}

.cockpit-worker-detail-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 0;
}

.cockpit-worker-detail-meta-item {
  border: 1px solid rgba(34, 48, 65, 0.7);
  border-radius: 6px;
  padding: 8px;
}

.cockpit-worker-detail-meta-item dt {
  color: var(--cockpit-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cockpit-worker-detail-meta-item dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.cockpit-worker-current {
  border-top: 1px solid rgba(34, 48, 65, 0.7);
  padding-top: 10px;
}

.cockpit-worker-current-empty,
.cockpit-worker-detail-empty {
  color: var(--cockpit-muted);
}

/* Distinguish a live terminal from a replayed (static) past session at a glance. */
.cockpit-terminal[data-terminal-mode="replay"] {
  border-color: #8957e5;
}
.cockpit-terminal[data-terminal-mode="replay"] .cockpit-panel-title {
  color: #b392f0;
}
.cockpit-terminal[data-terminal-mode="live"] .cockpit-panel-title {
  color: var(--cockpit-green);
}

/* ── Rendered transcript (#660): the derived message turns + tool/diff/permission cards the Worker ──
   terminal shows for both a live drill and a past-session replay, in place of a raw nwfTranscriptEvent
   dump. Mounted into `.cockpit-terminal-host` by renderDerivedTranscript(). */

/* No own scroll container: the transcript grows with its content and the single
   outer scroller — the `appView` iframe viewport (fill: min(80vh,48rem)), or the
   phone page in the standalone shell — scrolls it. A `max-height`/`overflow` here
   nested a second scrollbar inside the already-bounded iframe (scroll-in-scroll). */
.cockpit-transcript-derived {
  display: grid;
  gap: 12px;
  padding: 8px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.cockpit-transcript-empty {
  color: var(--cockpit-muted);
  font-style: italic;
  padding: 8px;
}

.cockpit-transcript-turn {
  display: grid;
  gap: 8px;
  border-left: 2px solid var(--cockpit-edge);
  padding-left: 10px;
}

.cockpit-transcript-turn-title {
  font-size: 11px;
  margin: 0;
  color: var(--cockpit-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cockpit-transcript-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(34, 48, 65, 0.35);
}

.cockpit-transcript-message[data-role="user"] { border-left: 3px solid #58a6ff; }
.cockpit-transcript-message[data-role="assistant"] { border-left: 3px solid var(--cockpit-green); }
.cockpit-transcript-message[data-role="system"],
.cockpit-transcript-message[data-role="tool"] { border-left: 3px solid var(--cockpit-muted); color: var(--cockpit-muted); }

.cockpit-transcript-tool {
  border: 1px solid var(--cockpit-edge);
  border-radius: 6px;
  padding: 8px;
  background: rgba(19, 26, 34, 0.6);
}

.cockpit-transcript-tool-name {
  font-weight: 600;
  color: #b392f0;
}

.cockpit-transcript-tool[data-status="error"] .cockpit-transcript-tool-name { color: var(--cockpit-red); }
.cockpit-transcript-tool[data-status="ok"] .cockpit-transcript-tool-name::after { content: " ✓"; color: var(--cockpit-green); }

.cockpit-transcript-tool-args,
.cockpit-transcript-tool-result,
.cockpit-transcript-diff {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #05080b;
  border-radius: 4px;
  padding: 6px 8px;
}

.cockpit-transcript-diff-line[data-diff-line="add"] { color: var(--cockpit-green); }
.cockpit-transcript-diff-line[data-diff-line="del"] { color: var(--cockpit-red); }
.cockpit-transcript-diff-line[data-diff-line="ctx"] { color: var(--cockpit-muted); }

.cockpit-transcript-permission {
  border: 1px solid var(--cockpit-amber);
  border-radius: 6px;
  padding: 8px;
  background: rgba(210, 153, 34, 0.08);
}

.cockpit-transcript-permission-title { font-weight: 600; }
.cockpit-transcript-permission-reason,
.cockpit-transcript-permission-note { color: var(--cockpit-muted); font-size: 12px; }

.cockpit-transcript-permission[data-status="allowed"] { border-color: var(--cockpit-green); }
.cockpit-transcript-permission[data-status="denied"] { border-color: var(--cockpit-red); }

.cockpit-transcript-permission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.cockpit-transcript-permission-option {
  cursor: pointer;
  font: inherit;
  color: var(--cockpit-text);
  background: var(--cockpit-panel);
  border: 1px solid var(--cockpit-edge);
  border-radius: 6px;
  padding: 4px 10px;
}

.cockpit-transcript-permission-option[data-allowed="true"]:hover { border-color: var(--cockpit-green); }
.cockpit-transcript-permission-option[data-allowed="false"]:hover { border-color: var(--cockpit-red); }

.cockpit-transcript-raw {
  color: var(--cockpit-muted);
  font-size: 11px;
  border-top: 1px solid var(--cockpit-edge);
  padding-top: 6px;
}
