/* Invaris Brokerage — trading layer.
 *
 * Built on the Coherence-derived foundation, this file adds only what trading
 * needs: the environment banner, the order ticket, the risk-limit gauges, and
 * the Decision Inspector. Everything here uses foundation tokens, so a change
 * to the design system propagates rather than needing to be re-applied.
 */

/* ---- environment distinction (FR-UI-06) --------------------------------
 * Not a badge in a corner. A rail across the top of the workspace, an
 * outlined shell, and a token override that colors every accent in the app.
 * The requirement is "impossible to miss", and a small label is missable.
 */

.env-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 24px;
  border-bottom: 1px solid var(--env-line);
  background: var(--env-soft);
  color: var(--env);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.env-strip::before {
  content: var(--env-label);
}

.env-strip .env-detail {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: none;
}

:root[data-environment="live"] .app-shell {
  box-shadow: inset 0 0 0 2px var(--env-line);
}

.env-pill {
  border-color: var(--env-line);
  background: var(--env-soft);
  color: var(--env);
}

/* ---- Auto Invest ------------------------------------------------------- */

.rail-note {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
}

.rail-note.warn {
  color: var(--amber);
}

.auto-block {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.block-label {
  color: var(--dim);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.class-chip {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.class-chip.on {
  border-color: var(--electric-blue-line);
  background: var(--electric-blue-soft);
  color: var(--electric-blue);
}

/* A class the operator can select but the venue cannot yet trade. Shown as
 * selected-but-pending rather than silently ignored. */
.class-chip.pending {
  border-style: dashed;
}

.class-chip.on.pending {
  border-color: rgba(245, 193, 93, 0.6);
  background: var(--amber-soft);
  color: var(--amber);
}

.risk-slider {
  width: 100%;
  height: 4px;
  margin: 4px 0;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--electric-green) 0%,
    var(--electric-blue) 45%,
    var(--amber) 75%,
    var(--danger) 100%
  );
}

.risk-slider::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 2px solid var(--page);
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.risk-label {
  color: var(--text);
  font-size: 11px;
  font-weight: 780;
}

.risk-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  margin: 2px 0 0;
}

.risk-detail dt {
  color: var(--dim);
  font-size: 10px;
}

.risk-detail dd {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}

.segmented button {
  min-height: 27px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.segmented button.active {
  background: #f3f6fb;
  color: #050608;
}

/* Toggle switch */
.switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  display: inline-flex;
  align-items: center;
  width: 34px;
  height: 19px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 140ms ease, border-color 140ms ease;
}

.switch-thumb {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.switch input:checked + .switch-track {
  border-color: var(--electric-green-line);
  background: var(--electric-green-soft);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(15px);
  background: var(--electric-green);
}

.switch input:disabled + .switch-track {
  opacity: 0.35;
  cursor: not-allowed;
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--electric-blue-line);
  outline-offset: 2px;
}

/* ---- strategies -------------------------------------------------------- */

.strategy-item {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}

.strategy-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.strategy-item.active {
  border-left-color: var(--electric-blue);
  background: rgba(255, 255, 255, 0.06);
}

.strategy-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 780;
}

.strategy-meta {
  color: var(--dim);
  font-size: 10px;
}

.envelope-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 5px 14px;
  margin: 0;
}

.envelope-grid dt {
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.envelope-grid dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.fit-report {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: 9px;
  background: var(--danger-soft);
  font-size: 11px;
}

.fit-report.fits {
  border-color: var(--electric-green-line);
  background: var(--electric-green-soft);
}

.fit-breach {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

/* ---- portfolio metric stack (right rail) ------------------------------- */

/* Cell separation is drawn with real borders rather than a 1px grid gap over a
 * tinted background. The gap trick needs `overflow: hidden` to clip its
 * corners, and an overflow container contributes zero intrinsic height to the
 * parent grid track — which collapsed this whole block to 2px. */
.metric-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.metric {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metric:nth-child(1),
.metric:nth-child(2) {
  border-top: 0;
}

.metric:nth-child(odd),
.metric.wide {
  border-left: 0;
}

.metric.wide {
  grid-column: 1 / -1;
}

.metric-label {
  color: var(--dim);
  font-size: 9px;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric-value {
  color: var(--text);
  font-size: 14px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.metric-value.lg {
  font-size: 18px;
}

/* ---- CRE adjudication banner -------------------------------------------
 * The hot-swappable runtime sits between the committee and the risk gate.
 * Showing which runtime is loaded, and its version, is what makes "hot-
 * swappable" auditable rather than merely configurable.
 */

.cre-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(
    to right,
    var(--electric-blue-soft),
    transparent 60%
  );
  font-size: 11px;
}

.cre-banner .cre-name {
  color: var(--electric-blue);
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cre-banner .cre-detail {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cre-banner .cre-state {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
}

.cre-banner.unloaded {
  background: linear-gradient(to right, rgba(245, 193, 93, 0.12), transparent 60%);
}

.cre-banner.unloaded .cre-name {
  color: var(--amber);
}

/* ---- system status ----------------------------------------------------- */

.status-stack {
  display: grid;
  gap: 6px;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  font-size: 11px;
}

.status-row .label {
  color: var(--muted);
  font-weight: 720;
}

.status-row.halted {
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

/* ---- risk limit gauges (FR-UI-02) -------------------------------------- */

.gauge {
  display: grid;
  gap: 5px;
}

.gauge-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.gauge-name {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.gauge-value {
  color: var(--dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.gauge-track {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.gauge-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--electric-blue);
  transition: width 220ms ease;
}

.gauge-fill.warn {
  background: var(--amber);
}

.gauge-fill.bad {
  background: var(--danger);
}

/* ---- order ticket ------------------------------------------------------ */

.ticket {
  display: grid;
  gap: 12px;
}

.ticket-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0.08em;
}

.side-button[data-side="BUY"].active {
  border-color: var(--electric-green-line);
  background: var(--electric-green-soft);
  color: var(--electric-green);
}

.side-button[data-side="SELL"].active {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.field input,
.field select {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #000;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--electric-blue-line);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ticket-preview {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 11px;
  color: var(--muted);
}

.ticket-preview strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* The rejection surface. FR-RISK rejections name the specific check that
 * failed — "order rejected" with no reason trains an operator to click
 * through warnings, which disarms every control beneath it. */
.ticket-result {
  display: grid;
  gap: 6px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
}

.ticket-result.rejected {
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.ticket-result.accepted {
  border-color: var(--electric-green-line);
  background: var(--electric-green-soft);
}

.ticket-result.pending {
  border-color: rgba(245, 193, 93, 0.5);
  background: var(--amber-soft);
}

.ticket-result .check-name {
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.ticket-result .check-detail {
  color: var(--muted);
}

/* ---- decision inspector (FR-UI-04) -------------------------------------
 * The most valuable screen in the product. Rendered as a vertical chain so
 * that a gap in provenance is visually obvious rather than something you have
 * to notice is missing from a table.
 */

.chain {
  display: grid;
  gap: 0;
  margin: 4px 0 0;
}

.chain-node {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 0 0 20px 26px;
  border-left: 1px solid var(--line-strong);
}

.chain-node:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.chain-node::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 3px;
  width: 9px;
  height: 9px;
  border: 1px solid var(--electric-blue-line);
  border-radius: 999px;
  background: var(--page);
}

.chain-node.done::before {
  background: var(--electric-blue);
}

.chain-node.failed::before {
  border-color: var(--danger-line);
  background: var(--danger);
}

.chain-node.absent::before {
  border-style: dashed;
  border-color: var(--dim);
  background: var(--page);
}

.chain-stage {
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chain-detail {
  color: var(--muted);
  font-size: 11px;
}

.chain-detail .kv {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 4px 10px;
  margin-top: 4px;
}

.chain-detail .kv dt {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chain-detail .kv dd {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.chain-node.absent .chain-stage,
.chain-node.absent .chain-detail {
  color: var(--dim);
}

/* ---- checks run list --------------------------------------------------- */

.check-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.check-chip {
  padding: 3px 8px;
  border: 1px solid var(--electric-green-line);
  border-radius: 999px;
  background: var(--electric-green-soft);
  color: var(--electric-green);
  font-family: var(--mono);
  font-size: 10px;
}

.check-chip.failed {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---- staleness indicator (FR-UI-09) ------------------------------------ */

.stale-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--electric-green);
}

.stale-dot.stale {
  background: var(--danger);
}

.stale-dot.aging {
  background: var(--amber);
}

/* ==========================================================================
   Surface v2 — briefing, desk cards, the drawer, and the frontier.

   One rule governs colour here: green, amber and red mean an *engine state*
   and nothing else. A card is not amber because it is important; it is amber
   because a binding seat restricted it. Everything decorative stays in the
   neutral ramp, so a colour on this screen is always information.
   ========================================================================== */

:root {
  --ok: #4ea88a;
  --warn: #d9a441;
  --bad: #d4645f;
  --quiet: rgba(255, 255, 255, 0.45);
  --card: rgba(255, 255, 255, 0.028);
  --card-hover: rgba(255, 255, 255, 0.045);
  --lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* ---- top rail additions -------------------------------------------------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--card-hover); border-color: rgba(255,255,255,0.18); }
.bars { display: grid; gap: 3px; }
.bars i { display: block; width: 13px; height: 1.5px; background: currentColor; opacity: 0.75; }

/* ---- the gate strip ------------------------------------------------------ */

.gate-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--hairline);
  font-size: 11px;
  background: linear-gradient(to bottom, rgba(78, 168, 138, 0.05), transparent);
}
.gate-strip.unloaded { background: linear-gradient(to bottom, rgba(212, 100, 95, 0.07), transparent); }
.gate-name { font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 10px; }
.gate-obligations { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.obligation {
  padding: 1px 7px;
  border: 1px solid rgba(78, 168, 138, 0.3);
  border-radius: 999px;
  color: var(--ok);
  font-size: 10px;
  white-space: nowrap;
}
.gate-note { color: var(--bad); }
.gate-state { opacity: 0.5; font-variant-numeric: tabular-nums; }

/* ---- the briefing (centre, when there is no conversation) ---------------- */

.briefing { display: grid; gap: 18px; padding: 30px 4px; max-width: 640px; }
.briefing-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.briefing-sub { margin: 6px 0 0; font-size: 13px; line-height: 1.6; opacity: 0.7; }

.briefing-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}
.briefing-stat { background: var(--bg, #0b0d10); padding: 12px 14px; display: grid; gap: 3px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.45; }
.stat-value { font-size: 17px; font-variant-numeric: tabular-nums; }
.briefing-stat.quiet .stat-value { opacity: 0.4; }
.briefing-stat.live .stat-value { color: var(--ok); }

.briefing-waiting {
  margin: 0;
  padding: 11px 14px;
  border-left: 2px solid var(--hairline);
  font-size: 13px;
  line-height: 1.6;
  opacity: 0.8;
}
.briefing-waiting.bad { border-left-color: var(--bad); color: var(--bad); opacity: 1; }

.briefing-prompts-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.4;
}
.briefing-prompts { display: grid; gap: 7px; }
.prompt-chip {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: var(--card);
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}
.prompt-chip:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateX(2px);
}

/* ---- the desk card ------------------------------------------------------- */

@keyframes settle {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.desk-card {
  display: grid;
  gap: 11px;
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--quiet);
  border-radius: 11px;
  background: var(--card);
  box-shadow: var(--lift);
  animation: settle 220ms ease both;
}
.desk-card.ok   { border-left-color: var(--ok); }
.desk-card.warn { border-left-color: var(--warn); }
.desk-card.bad  { border-left-color: var(--bad); }

.desk-card-head { display: flex; align-items: center; gap: 10px; }
.outcome-pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}
.outcome-pill.ok { color: var(--ok); }
.outcome-pill.warn { color: var(--warn); }
.outcome-pill.bad { color: var(--bad); }
.outcome-pill.quiet { color: var(--quiet); }
.desk-subject { font-size: 11px; opacity: 0.5; letter-spacing: 0.04em; }

.desk-conclusion { margin: 0; font-size: 14px; line-height: 1.62; }

.desk-seats { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.seat-dot.small { width: 19px; height: 19px; font-size: 9px; }
.desk-seat-note { font-size: 11px; opacity: 0.5; margin-left: 4px; }

.binding-ruling {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(217, 164, 65, 0.07);
  border: 1px solid rgba(217, 164, 65, 0.22);
  font-size: 12px;
  line-height: 1.55;
}
.binding-tag {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn);
}
.binding-seat { font-weight: 600; }
.binding-remedy { opacity: 0.75; }

.desk-invalidations ul, .transcript-violations ul { margin: 4px 0 0; padding-left: 17px; }
.desk-invalidations li { font-size: 12px; line-height: 1.6; opacity: 0.72; }
.micro-label {
  display: block;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.42;
  margin-bottom: 3px;
}

.desk-transcript > summary {
  cursor: pointer;
  font-size: 11px;
  opacity: 0.55;
  padding: 4px 0;
  list-style: none;
}
.desk-transcript > summary::-webkit-details-marker { display: none; }
.desk-transcript > summary::before { content: '▸ '; }
.desk-transcript[open] > summary::before { content: '▾ '; }
.desk-transcript > summary:hover { opacity: 0.85; }
.transcript-body {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.transcript-notice { font-size: 11px; opacity: 0.5; line-height: 1.6; }
.transcript-violations li { font-size: 11px; color: var(--warn); }

.message.system.bad .message-text { color: var(--bad); }
.message-sub { font-size: 11px; opacity: 0.6; margin-top: 3px; }

/* ---- rails: density and status ------------------------------------------ */

.empty-state {
  display: grid;
  gap: 4px;
  padding: 14px 12px;
  font-size: 12px;
  line-height: 1.55;
}
.empty-headline { opacity: 0.72; }
.empty-detail { opacity: 0.42; font-size: 11px; }

.row-label { display: inline-flex; align-items: center; gap: 7px; }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--quiet);
  flex: none;
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.buy { background: var(--ok); }
.dot.sell { background: var(--bad); }

.mandate-status {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 14px;
}
.mandate-head { display: flex; align-items: center; justify-content: space-between; }
.mandate-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.5;
}
.mandate-line {
  margin: 8px 0 4px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0.45;
  transition: opacity 160ms ease, color 160ms ease;
}
.mandate-status.live .mandate-line { opacity: 1; color: var(--ok); }

/* ---- the drawer ---------------------------------------------------------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 180ms ease;
  z-index: 40;
}
.scrim.open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg, #0b0d10);
  border-left: 1px solid var(--hairline);
  box-shadow: -24px 0 48px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 41;
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-body { overflow-y: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }

.drawer-field { display: grid; gap: 6px; }
.drawer-label { font-size: 11px; opacity: 0.7; }
.drawer-hint { font-size: 11px; opacity: 0.45; line-height: 1.55; }
.drawer-hint.bad { color: var(--bad); opacity: 1; }
.drawer-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
}
.drawer-input:focus-visible,
.inline-select:focus-visible,
.inline-number:focus-visible { outline: 2px solid var(--ok); outline-offset: 1px; }

.intent-sentence {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 15px; line-height: 2;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--card);
}
.inline-select, .inline-number {
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
  color: var(--ok);
  font: inherit;
  font-size: 15px;
  padding: 0 2px 1px;
  cursor: pointer;
}
.inline-number { width: 3.5em; text-align: center; }
.inline-select option { background: #14171c; color: #e8eefb; }

.drawer-section { display: grid; gap: 9px; }
.drawer-section h3 {
  margin: 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; opacity: 0.5;
}
.drawer-list { margin: 0; padding-left: 17px; font-size: 12px; line-height: 1.65; opacity: 0.7; }
.drawer-list li { margin-bottom: 5px; }

.engine-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--quiet);
  border-radius: 8px;
  font-size: 12px;
}
.engine-row.ok { border-left-color: var(--ok); }
.engine-row.bad { border-left-color: var(--bad); }
.engine-name { font-weight: 600; }
.engine-state { opacity: 0.5; font-variant-numeric: tabular-nums; }

.scenario-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scenario-cell {
  display: grid; gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  font-size: 11px;
}
.scenario-id { font-weight: 600; }
.scenario-move { opacity: 0.5; font-variant-numeric: tabular-nums; }

.authority-tag {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 1px 6px; border-radius: 999px; border: 1px solid currentColor;
}
.authority-tag.block { color: var(--bad); }
.authority-tag.restrict { color: var(--warn); }

.btn.wide, .text-action.wide { width: 100%; text-align: center; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--hairline);
  color: inherit;
}
.btn.ghost:hover { background: var(--card-hover); }

/* ---- the frontier -------------------------------------------------------- */

.frontier-summary {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
}
.frontier-note { margin: 14px 0 4px; font-size: 12px; line-height: 1.6; opacity: 0.6; }

.candidate {
  display: grid; gap: 11px;
  margin: 14px 0;
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--card);
  animation: settle 220ms ease both;
}
.candidate.lead { box-shadow: var(--lift); }
.candidate-head { display: flex; align-items: center; gap: 11px; }
.candidate-index {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  flex: none;
}
.candidate-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.005em; }

.score-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px; margin: 0;
  padding: 12px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.score dt {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.07em; opacity: 0.45;
}
.score dd { margin: 3px 0 0; font-size: 17px; font-variant-numeric: tabular-nums; }

.candidate-why { margin: 0; font-size: 13px; line-height: 1.62; }
.leg-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.leg-list li {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.022);
}
.leg-what { font-variant-numeric: tabular-nums; }
.leg-role { opacity: 0.45; text-align: right; }

.candidate-tradeoff { margin: 0; font-size: 12px; line-height: 1.6; opacity: 0.78; }
.candidate-cost { margin: 0; font-size: 12px; opacity: 0.6; font-variant-numeric: tabular-nums; }

.candidate-notes > summary {
  cursor: pointer; font-size: 11px; color: var(--warn); opacity: 0.85; list-style: none;
}
.candidate-notes > summary::-webkit-details-marker { display: none; }
.candidate-notes > summary::before { content: '▸ '; }
.candidate-notes[open] > summary::before { content: '▾ '; }
.candidate-notes ul { margin: 7px 0 0; padding-left: 17px; }
.candidate-notes li { font-size: 11px; line-height: 1.6; color: var(--warn); opacity: 0.8; }

.candidate-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-top: 4px;
}
.replay-tag {
  font-size: 10px; opacity: 0.35; font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.accept-result {
  display: grid; gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  font-size: 12px;
  animation: settle 200ms ease both;
}
.accept-result.ok { border-left: 2px solid var(--ok); }
.accept-result.warn { border-left: 2px solid var(--warn); }
.accept-result.bad { border-left: 2px solid var(--bad); color: var(--bad); }
.accept-head { font-weight: 600; }
.accept-result ul { margin: 0; padding-left: 17px; }
.accept-result li { line-height: 1.6; }
.accept-result li.ok { color: var(--ok); }
.accept-result li.bad { color: var(--bad); }
.accept-leg { font-weight: 600; }
.accept-warning { margin: 4px 0 0; color: var(--warn); line-height: 1.6; }

.tradeoff-card, .aux-card, .warn-card {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: 11px;
}
.warn-card { border-left: 2px solid var(--warn); }
.refusal-card { border-left: 2px solid var(--quiet); }
.caveat-card { opacity: 0.75; }
.aux-card h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.aux-note { margin: 0 0 10px; font-size: 12px; opacity: 0.55; line-height: 1.6; }
.aux-list, .tradeoff-list {
  margin: 0; padding-left: 17px; font-size: 12px; line-height: 1.7; opacity: 0.78;
}
.aux-list li { margin-bottom: 6px; }
.refusal-rule {
  display: inline-block; margin-right: 7px;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  opacity: 0.5;
}
.refusal-what { font-weight: 600; }
.refusal-why { display: block; opacity: 0.62; }

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 220px 1fr; }
  .side-rail { display: none; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .nav-rail { display: none; }
  .briefing { padding: 20px 2px; }
  .drawer { width: 100vw; }
}

body.offline .env-strip { background: rgba(212, 100, 95, 0.12); }
body.offline .env-detail { color: var(--bad); }

/* ---- instrument detail, ticket, ledger ----------------------------------- */

.glyph { font-size: 13px; opacity: 0.75; line-height: 1; }

.mechanics-card { border-left: 2px solid var(--warn); }

.proxy-row { display: flex; flex-wrap: wrap; gap: 7px; }
.proxy-chip {
  padding: 6px 11px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--card);
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.proxy-chip:hover { background: var(--card-hover); border-color: rgba(255,255,255,0.2); }
.proxy-chip.current {
  border-color: var(--ok);
  color: var(--ok);
  cursor: default;
}

/* A leg is a link to the instrument, and should look like one without
   becoming a blue underline in a dark interface. */
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.25);
}
.linkish:hover { border-bottom-color: var(--ok); color: var(--ok); }

.segmented button.active { background: var(--card-hover); }

/* When the live stream drops, the poll still carries state — say so quietly
   rather than alarming the operator about something already handled. */
body.stream-degraded .gate-state::after {
  content: ' · polling';
  opacity: 0.6;
}
