/* ================================================================
   TheEarth Group OS · Commander V2
   Palette: deep green, restrained gold, soft neutral surfaces.
   Command center, not a landing page. High readability first.
   ================================================================ */

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

:root {
  color-scheme: light;
  --deep:   #0b2f29;   /* deep green primary */
  --deep-2: #0f3d35;   /* raised deep green */
  --deep-3: #103b34;
  --ink:    #10201b;   /* near-black text */
  --muted:  #5f6d67;   /* secondary text */
  --faint:  #8a968f;
  --line:   #d7e0da;   /* hairlines */
  --line-2: #e6ede9;
  --bg:     #eef3f0;   /* app background */
  --surface:#ffffff;   /* cards */
  --soft:   #f2f7f4;   /* soft fill */
  --soft-2: #eaf1ec;
  --gold:   #a98b58;   /* restrained gold */
  --gold-2: #c9b184;
  --gold-soft:#f6efe1;
  --ok:     #1d8d61;
  --ok-soft:#e2f1ea;
  --warn:   #a15c00;
  --warn-soft:#f7ecd8;
  --bad:    #b3261e;
  --bad-soft:#f6e0de;
  --info:   #2a6f97;
  --radius: 8px;      /* cards ≤ 8px per R41–R44 spec */
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(12, 40, 33, .07);
  --shadow-sm: 0 3px 10px rgba(12, 40, 33, .05);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, monospace;
}

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

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
a { color: var(--info); }
code { font-family: var(--mono); font-size: .92em; background: var(--soft-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--deep); color: #f2fbf7; border-color: var(--deep); }
.btn.primary:hover { background: var(--deep-2); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.gold:hover { background: #9a7d4c; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #dcece5; }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; padding: 3px 4px; color: var(--bad); font-weight: 700; cursor: pointer; }
.btn.mini { padding: 5px 9px; font-size: 12px; }

/* ---------- Shell layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}
body.locked .shell { filter: blur(3px); pointer-events: none; user-select: none; }

/* ---------- Left rail ---------- */
.rail {
  background: linear-gradient(180deg, var(--deep) 0%, #082722 100%);
  color: #dcece5;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand-mark { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold-2); font-weight: 800; }
.brand-title { font-size: 25px; font-weight: 800; margin-top: 6px; color: #fff; letter-spacing: -0.02em; }
.brand-title span { color: var(--gold-2); }
.brand-sub { font-size: 12px; color: #9fb6ad; margin-top: 2px; }

.workspaces { display: grid; gap: 8px; }
.ws-btn {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color: #dcece5;
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.ws-btn:hover { background: rgba(255,255,255,.08); }
.ws-btn.is-active { background: rgba(201,177,132,.14); border-color: var(--gold-2); }
.ws-ico { font-size: 18px; color: var(--gold-2); width: 22px; text-align: center; }
.ws-txt b { display: block; font-size: 14px; color: #fff; }
.ws-txt small { display: block; font-size: 11px; color: #9fb6ad; }

.rail-status { border-top: 1px solid rgba(255,255,255,.10); padding-top: 14px; display: grid; gap: 8px; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(179,38,30,.2); }
body.unlocked .conn-dot { background: #4fe6a0; box-shadow: 0 0 0 3px rgba(79,230,160,.22); }
.rail-meta { font-size: 11px; color: #9fb6ad; font-family: var(--mono); }

.rail-actions { display: grid; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #cfe1da; cursor: pointer; }
.toggle input { accent-color: var(--gold-2); width: 15px; height: 15px; }

.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.fallback-link { color: var(--gold-2); font-size: 13px; font-weight: 700; text-decoration: none; }
.fallback-link:hover { text-decoration: underline; }
.rail-note { font-size: 11px; color: #8fa79e; line-height: 1.5; margin: 0; }

/* ---------- Main ---------- */
.main { padding: 22px 24px 40px; min-width: 0; position: relative; }
.workspace.is-hidden { display: none; }

.ws-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.ws-head h1 { font-size: 26px; }
.ws-desc { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; max-width: 640px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--soft-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg.small { width: 100%; }
.seg.small .seg-btn { flex: 1; text-align: center; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 13px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--deep); box-shadow: var(--shadow-sm); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { font-size: 16px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.55; }
.mini-actions { display: flex; gap: 6px; }
.ops-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 14px 0 8px; }

/* ---------- Pills / badges ---------- */
.pill { font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: var(--soft-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe3d2; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #ead6b0; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: #eeb9b5; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 7px; background: var(--soft-2); color: var(--muted); border: 1px solid var(--line); margin: 0 5px 5px 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe3d2; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #ead6b0; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #eeb9b5; }
.badge.gold { background: var(--gold-soft); color: #7a5f2c; border-color: var(--gold-2); }

/* state color mapping for job states */
.badge.state-done, .pill.state-done { background: var(--ok-soft); color: var(--ok); border-color:#bfe3d2; }
.badge.state-running { background:#e4eef6; color: var(--info); border-color:#bcd6e8; }
.badge.state-blocked, .badge.state-failed { background: var(--bad-soft); color: var(--bad); border-color:#eeb9b5; }
.badge.state-waiting-approval, .badge.state-waiting-worker { background: var(--warn-soft); color: var(--warn); border-color:#ead6b0; }

/* ================= OWNER COMMAND ================= */
.owner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}
.col-center { min-width: 0; }
.col-ops { min-width: 0; }
.view.is-hidden { display: none; }

/* Threads */
.thread-list { display: grid; gap: 8px; margin-bottom: 10px; max-height: 44vh; overflow-y: auto; }
.thread {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.thread:hover { background: var(--soft); }
.thread.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(169,139,88,.16); background: var(--gold-soft); }
.thread-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.thread-name { font-weight: 800; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.thread-check { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--faint); display: inline-flex; align-items:center; justify-content:center; flex: none; font-size: 11px; color: #fff; }
.thread.selected .thread-check { background: var(--gold); border-color: var(--gold); }
.thread-desc { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.thread-badges { margin-top: 7px; }
.selected-hint { font-size: 12px; color: var(--muted); background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.add-thread { margin-top: 12px; }
.add-thread summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--deep); }
.add-grid { display: grid; gap: 8px; margin-top: 10px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(11,47,41,.18); outline-offset: 1px; border-color: var(--deep-2); }
textarea { resize: vertical; }

/* Thread tabs — each tab is an independent chat */
.thread-tabbar {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px; padding-bottom: 10px;
}
.thread-tabs {
  display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
}
.thread-tabs::-webkit-scrollbar { height: 5px; }
.thread-tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.thread-tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--soft);
  border-radius: 999px; padding: 7px 13px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 13px; color: var(--muted);
  transition: background .12s, border-color .12s, color .12s;
}
.thread-tab:hover { background: var(--soft-2); color: var(--ink); }
.thread-tab.is-active { background: var(--deep); border-color: var(--deep); color: #f2fbf7; }
.thread-tab.is-active .tab-star { color: var(--gold-2); }
.thread-tab .tab-star { color: var(--gold); font-size: 11px; }
.thread-tab .tab-run { width: 7px; height: 7px; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 3px rgba(42,111,151,.18); }
.thread-tab .tab-x {
  border: 0; background: none; color: inherit; opacity: .6; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 0 0 2px; font-weight: 800;
}
.thread-tab .tab-x:hover { opacity: 1; }
.tab-add {
  flex: none; border: 1px dashed var(--line); background: transparent;
  border-radius: 999px; padding: 7px 12px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 12.5px; color: var(--deep); white-space: nowrap;
}
.tab-add:hover { background: var(--soft); border-color: var(--gold); }

.add-thread-panel { margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--soft); }
.add-thread-panel.is-hidden { display: none; }
.add-thread-panel .hint { margin: 10px 0 0; }

/* Parallel-send (secondary fan-out) */
.parallel-send { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); padding: 8px 10px; }
.parallel-send summary { cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--deep); }
.parallel-send .hint { margin: 8px 0; }
.parallel-list { display: flex; flex-wrap: wrap; gap: 6px; }
.parallel-list .empty { padding: 6px; }
.par-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.par-opt input { width: 14px; height: 14px; accent-color: var(--gold); }

/* Chat */
.chat-card { display: flex; flex-direction: column; min-height: 62vh; }
.chat-stream { flex: 1; overflow-y: auto; display: grid; gap: 12px; padding: 4px 2px 12px; align-content: start; max-height: 58vh; }
.chat-empty { color: var(--muted); text-align: center; padding: 40px 12px; font-size: 13px; }
.chat-entry { display: grid; gap: 8px; }
.bubble-user {
  justify-self: end; max-width: 88%;
  background: var(--deep); color: #eef8f3;
  border-radius: 10px 10px 3px 10px; padding: 10px 13px; font-size: 13.5px;
  white-space: pre-wrap; word-break: break-word;
}
.bubble-user .b-meta { font-size: 10.5px; color: #a9c7bd; margin-bottom: 4px; }
.bubble-sys {
  justify-self: start; max-width: 94%;
  background: var(--soft); border: 1px solid var(--line);
  border-radius: 10px 10px 10px 3px; padding: 11px 13px;
}
.bubble-sys .b-title { font-weight: 800; font-size: 12.5px; margin-bottom: 6px; }
.job-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; margin-top: 6px; cursor: pointer;
}
.job-chip:hover { border-color: var(--gold); }
.job-chip .jc-id { font-family: var(--mono); font-size: 11.5px; font-weight: 700; }
.job-chip .jc-sub { font-size: 11px; color: var(--muted); }
.blocked-note { color: var(--bad); font-size: 12px; font-weight: 700; }

/* Assistant working bubble — live progress in the chat stream */
.bubble-sys .b-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bubble-sys .b-head .b-title { margin: 0; }
.b-status { font-size: 11px; font-weight: 700; color: var(--info); display: inline-flex; align-items: center; gap: 6px; }
.b-status .spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(42,111,151,.28); border-top-color: var(--info); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-steps { display: grid; gap: 0; margin: 4px 0 2px; }
.cs-step { display: grid; grid-template-columns: 18px 1fr; gap: 8px; position: relative; padding-bottom: 9px; }
.cs-step:last-child { padding-bottom: 0; }
.cs-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--faint); background: #fff; margin-top: 2px; justify-self: center; z-index: 1; }
.cs-step:not(:last-child) .cs-dot::after { content: ""; position: absolute; left: 8px; top: 13px; bottom: 0; width: 2px; background: var(--line); }
.cs-step.done .cs-dot { background: var(--ok); border-color: var(--ok); }
.cs-step.active .cs-dot { background: var(--info); border-color: var(--info); box-shadow: 0 0 0 3px rgba(42,111,151,.18); animation: pulse 1.4s ease-in-out infinite; }
.cs-step.blocked .cs-dot { background: var(--bad); border-color: var(--bad); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(42,111,151,.10); } 50% { box-shadow: 0 0 0 5px rgba(42,111,151,.22); } }
.cs-label { font-size: 12px; font-weight: 700; }
.cs-step.pending .cs-label { color: var(--faint); font-weight: 600; }
.cs-step.blocked .cs-label { color: var(--bad); }
.cs-note { font-size: 10.5px; color: var(--muted); }

/* Assistant final response */
.b-summary { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; margin: 2px 0 4px; }
/* The answer reads first — the star of the bubble, like an AI chat reply. */
.b-answer { font-size: 13.5px; line-height: 1.66; color: var(--ink); white-space: pre-wrap; word-break: break-word; margin: 2px 0 10px; }

/* Secondary chat surfaces — payload, conversation, reasoning, progress,
   evidence, brain — all collapsed by default so the answer stays clean. */
.chat-collapse { border: 1px solid var(--line); border-radius: 9px; background: #fbfdfb; padding: 8px 11px; margin-top: 8px; }
.chat-collapse > summary { cursor: pointer; font-weight: 700; font-size: 11.5px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 7px; }
.chat-collapse > summary::-webkit-details-marker { display: none; }
.chat-collapse > summary::before { content: "▸"; font-size: 9px; color: var(--faint); transition: transform .12s; }
.chat-collapse[open] > summary { color: var(--deep); margin-bottom: 8px; }
.chat-collapse[open] > summary::before { transform: rotate(90deg); }
.chat-collapse .chat-steps { margin: 0; }
.cc-line { font-size: 12.5px; line-height: 1.5; padding: 7px 9px; margin-top: 6px; background: #fff; border: 1px solid var(--line-2); border-radius: 7px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.cc-role { font-weight: 800; color: var(--deep); }
.cc-note { font-size: 11px; color: var(--muted); line-height: 1.45; margin-top: 6px; }

.b-evidence { display: grid; gap: 6px; margin-top: 8px; }
.ev-brief { font-size: 11px; color: var(--muted); line-height: 1.45; }
.ev-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: #fff; margin-top: 6px; }
.ev-name { font-size: 11.5px; font-weight: 700; word-break: break-all; }
.ev-actions { display: flex; gap: 6px; flex: none; }
.b-track { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.b-audit { margin-top: 8px; }
.b-audit summary { cursor: pointer; font-size: 11px; font-weight: 700; color: var(--muted); }
.b-audit .audit-body { margin-top: 6px; font-size: 11px; color: var(--muted); display: grid; gap: 4px; }
.b-audit .audit-id { font-family: var(--mono); word-break: break-all; }
.b-audit .btn.link { color: var(--info); padding: 0; }
.hard-gate-note { font-size: 11px; color: var(--warn); background: var(--warn-soft); border: 1px solid #ead6b0; border-radius: 8px; padding: 7px 9px; margin-top: 8px; font-weight: 700; line-height: 1.5; }

/* Chat-readiness vs publication approval — two distinct axes, never conflated */
.readiness-sep { margin: 0 0 10px; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--radius-sm); background: #fbfdfb; padding: 8px 10px; }
.rs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-note { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 6px; }

/* Autonomous-supervisor signals (retry / stale / dead-letter) */
.recovery-note { font-size: 11px; color: var(--info); background: #eef5fa; border: 1px solid #cfe0ec; border-radius: 8px; padding: 6px 9px; margin-top: 8px; font-weight: 600; line-height: 1.5; }
.dead-letter-note { font-size: 11px; color: var(--bad); background: var(--bad-soft); border: 1px solid #eeb9b5; border-radius: 8px; padding: 7px 9px; margin-top: 8px; font-weight: 700; line-height: 1.5; }

/* Accessible focus states — visible keyboard ring on every interactive control */
.btn:focus-visible, .seg-btn:focus-visible, .ws-btn:focus-visible, .thread-tab:focus-visible,
.tab-add:focus-visible, .job:focus-visible, .toggle:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--radius-sm);
}
.btn.ghost:focus-visible { outline-color: var(--gold-2); }

.composer { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.composer-hint { font-size: 12px; color: var(--muted); }

/* Counts */
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.metric { background: var(--soft); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; }
.metric b { font-size: 19px; display: block; line-height: 1.1; }
.metric.warn b { color: var(--warn); }
.metric.bad b { color: var(--bad); }
.metric span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 800; }

/* Ops / job lists */
.audit-label { font-size: 12px; font-weight: 800; color: var(--deep); margin-bottom: 10px; }
.audit-label span { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); margin-top: 2px; text-transform: none; letter-spacing: 0; }
.ops-card { position: sticky; top: 16px; }
.ops-view.is-hidden { display: none; }
.job-list, .surface-body { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.job {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: #fff; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.job:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.job.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(169,139,88,.16); }
.job-id { font-family: var(--mono); font-size: 11.5px; font-weight: 700; word-break: break-all; }
.job-req { font-size: 12px; color: var(--ink); margin: 4px 0; }
.job-meta { font-size: 11px; color: var(--muted); }
.empty { color: var(--muted); font-size: 12.5px; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 9px; }

/* Output */
.output-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-family: var(--mono); word-break: break-all; }
.markdown {
  white-space: pre-wrap; word-break: break-word;
  background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; max-height: 42vh; overflow-y: auto; font-size: 12.5px; line-height: 1.6;
}
.file-list { max-height: 34vh; }
.file-row { border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: #fff; }
.file-name { font-size: 12px; font-weight: 700; word-break: break-all; }
.file-kind { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.file-actions { display: flex; gap: 6px; margin-top: 7px; }

/* Runtime readiness strip */
.readiness { margin-bottom: 12px; }
.rd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-chip { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; display: grid; gap: 1px; min-width: 60px; }
.rd-chip b { font-size: 15px; line-height: 1.1; }
.rd-chip span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 800; }
.rd-chip.ok b { color: var(--ok); }
.rd-chip.warn b { color: var(--warn); }
.rd-chip.bad b { color: var(--bad); }
.rd-block { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--bad); background: var(--bad-soft); border: 1px solid #eeb9b5; border-radius: 8px; padding: 7px 9px; line-height: 1.5; }

/* Guarded actions */
.guard { border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: var(--soft); margin-bottom: 12px; }
.guard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.guard-title { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--deep); }
.guard-note { font-size: 10.5px; color: var(--muted); }
.guard-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.guard-msg { font-size: 11.5px; margin-top: 8px; min-height: 14px; font-weight: 700; line-height: 1.45; }
.guard-msg.ok { color: var(--ok); }
.guard-msg.bad { color: var(--bad); }
.guard-msg.warn { color: var(--warn); }

/* Progress timeline */
.timeline { display: grid; gap: 0; margin-bottom: 12px; }
.tl-step { display: grid; grid-template-columns: 20px 1fr; gap: 9px; position: relative; padding-bottom: 11px; }
.tl-step:last-child { padding-bottom: 0; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--faint); background: #fff; margin-top: 1px; justify-self: center; z-index: 1; }
.tl-step:not(:last-child) .tl-dot::after { content: ""; position: absolute; left: 9px; top: 15px; bottom: 0; width: 2px; background: var(--line); }
.tl-step.done .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-step.active .tl-dot { background: var(--info); border-color: var(--info); box-shadow: 0 0 0 3px rgba(42,111,151,.18); }
.tl-step.blocked .tl-dot { background: var(--bad); border-color: var(--bad); }
.tl-label { font-size: 12.5px; font-weight: 700; }
.tl-step.pending .tl-label { color: var(--faint); }
.tl-step.blocked .tl-label { color: var(--bad); }
.tl-note { font-size: 11px; color: var(--muted); }

/* Event dry-run action */
.evt-actions { margin-top: 8px; }
.evt-note { font-size: 10.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* Manager flow */
.manager-flow { display: grid; gap: 10px; max-height: 66vh; overflow-y: auto; }
.mf-step { border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 9px; padding: 10px 12px; background: #fff; }
.mf-step h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--deep); }
.mf-step .mf-body { font-size: 12.5px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.mf-list { display: grid; gap: 5px; margin-top: 4px; }
.mf-li { font-size: 12px; padding: 6px 8px; background: var(--soft); border-radius: 7px; border: 1px solid var(--line-2); }
.mf-arrow { color: var(--gold); font-weight: 800; }

/* ================= MARKETING PIPELINE ================= */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stage { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 120px; }
.stage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stage-head b { font-size: 12px; }
.stage-count { font-size: 11px; font-weight: 800; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.stage.gated { border-color: var(--gold-2); background: var(--gold-soft); }
.stage-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 7px; font-size: 11.5px; cursor: pointer; }
.stage-card:hover { border-color: var(--gold); }
.stage-card .sc-id { font-family: var(--mono); font-size: 10.5px; color: var(--muted); word-break: break-all; }
.gate-banner { grid-column: 1 / -1; background: var(--warn-soft); border: 1px solid #ead6b0; color: var(--warn); border-radius: 9px; padding: 9px 12px; font-size: 12.5px; font-weight: 700; }

/* ================= SMART PLATFORM ================= */
.platform-brandbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.platform-brandbar .bb-title { font-weight: 800; font-size: 15px; color: var(--deep); }
.platform-brandbar .bb-sub { font-size: 12px; color: var(--muted); }

.platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.surface-wide { grid-column: 1 / -1; }
.surf-row { border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: #fff; }
.surf-row .sr-title { font-weight: 700; font-size: 12.5px; word-break: break-word; }
.surf-row .sr-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- Innobelle Sales Management (shadow monitor) ---------- */
#surf-innobelle-sm.is-hidden { display: none; }
.sm-body { display: grid; gap: 12px; min-width: 0; }

/* Quiet but prominent shadow-only status */
.sm-shadow-note {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; font-size: 12px; line-height: 1.5; color: var(--muted);
}
.sm-shadow-note b { color: var(--deep); font-size: 12.5px; }
.sm-shadow-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex: none;
  background: var(--gold); box-shadow: 0 0 0 3px rgba(169,139,88,.16); }

/* Operating loop */
.sm-loop { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.sm-loop-step {
  border: 1px solid var(--line); border-left: 3px solid var(--faint);
  border-radius: 9px; padding: 9px 10px; background: #fff; min-width: 0;
}
.sm-loop-step.done { border-left-color: var(--ok); }
.sm-loop-step.active { border-left-color: var(--info); background: #f4f9fc; }
.sm-loop-step.blocked { border-left-color: var(--bad); background: var(--bad-soft); }
.sm-loop-step.pending { opacity: .72; }
.sl-num { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.sl-name { font-size: 12px; font-weight: 800; margin-top: 2px; line-height: 1.3; }
.sl-state { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; margin-top: 5px; color: var(--faint); }
.sl-state.done { color: var(--ok); }
.sl-state.active { color: var(--info); }
.sl-state.blocked { color: var(--bad); }
.sl-note { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.45; word-break: break-word; }

/* Report tabs + body */
.sm-report-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.sm-report-tabs .seg.small { width: auto; }
.sm-report { max-height: 46vh; }
.sm-preview-head { margin-top: 4px; }
.sm-preview { max-height: 40vh; }
.sm-files-wrap { display: grid; gap: 6px; }
.sm-file-list { max-height: none; }

/* ================= AI CONTROL ================= */
/* Real underline tabs — deliberately not the .seg pill control. */
.aic-tabs {
  display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 18px;
  /* Horizontal scroll only. overflow-x:auto implicitly makes overflow-y compute to
     auto, which vertically clips the active tab's underline on touch scrollers —
     pin it to hidden so the active state is never cut off. */
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
}
.aic-tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 16px; cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; border-radius: 0;
}
.aic-tab:hover { color: var(--ink); }
.aic-tab.is-active { color: var(--deep); border-bottom-color: var(--gold); }
.aic-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

/* Compact transient status chip that belongs to the AI Control header —
   a bordered pill with a status dot, not detached floating mono body copy.
   Top-aligned to sit with the H1, matching the seg controls in sibling headers. */
.aic-stamp {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  max-width: 100%; margin-top: 3px;
  padding: 5px 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--soft); color: var(--muted);
  font-family: var(--mono); font-size: 11px; font-weight: 700; line-height: 1.4;
  box-shadow: var(--shadow-sm);
}
.aic-stamp::before {
  content: ""; flex: none;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold-2); box-shadow: 0 0 0 3px rgba(169,139,88,.16);
}
.aic-panel { display: grid; gap: 16px; min-width: 0; }
.aic-panel.is-hidden { display: none; }

.aic-sec-head { margin-top: 2px; }
.aic-sec-head h2 { font-size: 16px; color: var(--deep); }
.aic-sec-head .hint { margin: 4px 0 0; max-width: 760px; }
.aic-h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 800; margin: 2px 0 -6px; }
.aic-meta { align-items: center; }
.aic-src { font-size: 11px; color: var(--faint); font-family: var(--mono); align-self: center; word-break: break-word; }

/* Non-ready states */
.aic-empty { color: var(--muted); font-size: 12.5px; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.aic-empty.tight { padding: 8px 10px; text-align: left; }
.aic-error { color: var(--bad); font-size: 12.5px; font-weight: 700; padding: 12px; border: 1px solid #eeb9b5; background: var(--bad-soft); border-radius: var(--radius-sm); }
.aic-gate-note { font-size: 12px; font-weight: 700; color: var(--warn); background: var(--warn-soft); border: 1px solid #ead6b0; border-radius: var(--radius-sm); padding: 9px 12px; line-height: 1.5; }

/* Overview groups (compact metric groupings, not floating cards) */
.aic-ov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.aic-ov-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); min-width: 0; }
.aic-ov-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.aic-ov-head b { font-size: 13px; color: var(--deep); }
.aic-ov-head .btn.link { color: var(--info); }

/* Source freshness */
.aic-fresh { display: grid; gap: 6px; }
.aic-fresh-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); }
.aic-fresh-label { font-size: 12.5px; font-weight: 700; word-break: break-word; }

/* Adapter detail cards (Models tab) */
.aic-adp { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); padding: 8px 10px; display: grid; gap: 6px; }
.aic-adp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.aic-adp-rows { display: grid; gap: 4px; }
.aic-adp-rows .aic-fresh-row { background: var(--surface); }

/* Filters */
.aic-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.aic-filters > input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.aic-select { display: grid; gap: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 800; }
.aic-select select { min-width: 130px; }

/* Dense table with internal scroller */
.aic-table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 72vh; background: var(--surface); -webkit-overflow-scrolling: touch; }
.aic-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.aic-table thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  background: var(--soft-2); color: var(--faint);
  text-transform: uppercase; font-size: 10px; letter-spacing: .05em; font-weight: 800;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.aic-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.aic-table tbody tr:last-child td { border-bottom: 0; }
.aic-row { cursor: pointer; }
.aic-row:hover { background: var(--soft); }
.aic-row.is-selected { background: var(--gold-soft); }
.aic-c-id { font-family: var(--mono); font-weight: 700; word-break: break-word; }
.aic-c-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.aic-cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.45; word-break: break-word; }
.aic-subrow td { background: var(--soft); padding-top: 4px; }
.aic-boundary { font-size: 11px; color: var(--warn); font-weight: 600; }
.aic-table-foot { font-size: 11px; color: var(--faint); padding: 8px 10px; border-top: 1px solid var(--line-2); }
/* Keep multi-column tables readable on narrow screens: hold a stable minimum
   width so the surrounding .aic-table-wrap scrolls horizontally instead of the
   cells collapsing into forced word-wrap. Inert on desktop, where width:100%
   already exceeds this minimum. */
.aic-table-min { min-width: 640px; }

/* Agents body: table + detail drawer */
.aic-agents-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.aic-drawer { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px; position: sticky; top: 16px; max-height: 78vh; overflow-y: auto; min-width: 0; }
.aic-drawer-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 26px 10px; }
.aic-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.aic-drawer-title { font-family: var(--mono); font-weight: 800; font-size: 13px; color: var(--deep); word-break: break-word; }
.aic-drawer-badges { margin-bottom: 4px; }
.aic-kv-sec { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 10px; }
.aic-kv-sec h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 0 0 8px; }
.aic-kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 10px; margin: 0; }
.aic-kv dt { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.aic-kv dd { margin: 0; font-size: 12px; word-break: break-word; }
.aic-chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.aic-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 7px; background: var(--soft-2); border: 1px solid var(--line); color: var(--ink); word-break: break-word; }

/* Brain */
.aic-brain-steward { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px; display: grid; gap: 10px; }
.aic-queues { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.aic-queue { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); padding: 9px 11px; display: grid; gap: 2px; }
.aic-queue b { font-size: 18px; line-height: 1.1; color: var(--faint); }
.aic-queue.has b { color: var(--deep); }
.aic-queue span { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 800; }
.aic-brain-rows { display: grid; gap: 8px; }
.aic-brain-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--radius-sm); background: var(--surface); padding: 10px 12px; }
.aic-brain-main { min-width: 0; flex: 1; }
.aic-brain-id { font-family: var(--mono); font-weight: 800; font-size: 12px; word-break: break-word; }
.aic-brain-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.aic-brain-summary { font-size: 12.5px; margin-top: 6px; line-height: 1.5; word-break: break-word; }
.aic-brain-meta { margin-top: 7px; }
.aic-brain-acts { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* Recovery & readiness (Overview) — warnings vs blockers, verified state */
.aic-posture { margin: -6px 0 2px; }
.aic-rd-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.aic-rd-col { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 12px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.aic-rd-col-head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 800; }
.aic-rd-item { border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); padding: 8px 10px; min-width: 0; }
.aic-rd-item.bad { border-left-color: var(--bad); }
.aic-rd-item.warn { border-left-color: var(--warn); }
.aic-rd-item-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.aic-rd-item-head b { font-size: 12.5px; color: var(--ink); min-width: 0; word-break: break-word; }
.aic-rd-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex: none; }
.aic-rd-item.bad .aic-rd-dot { color: var(--bad); }
.aic-rd-item.warn .aic-rd-dot { color: var(--warn); }
.aic-rd-src { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; color: var(--faint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; margin-left: auto; }
.aic-rd-detail { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; word-break: break-word; }
.aic-verified-val { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.aic-verified-note { font-size: 11px; color: var(--muted); word-break: break-word; }
.aic-gate-note.ok-note { color: var(--ok); background: var(--ok-soft); border-color: #bfe3d2; }

/* AI Control loading / error-with-retry */
.aic-loading { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--muted); font-size: 12.5px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.aic-spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 999px; display: inline-block; animation: aic-spin .8s linear infinite; }
@keyframes aic-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .aic-spin { animation: none; } }
.aic-error-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* AI Control responsive */
@media (max-width: 1180px) {
  .aic-agents-body { grid-template-columns: minmax(0, 1fr); }
  .aic-drawer { position: static; max-height: none; }
}
@media (max-width: 900px) {
  .aic-ov-grid { grid-template-columns: minmax(0, 1fr); }
  .aic-rd-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .aic-kv { grid-template-columns: 104px 1fr; }
  .aic-brain-row { flex-direction: column; }
  .aic-brain-acts { flex-direction: row; }
  .aic-filters > input[type="search"], .aic-select, .aic-select select { flex: 1 1 100%; width: 100%; }

  /* Narrow viewports can't fit five underline tabs in one row, and a horizontal
     scroller hides tabs off-screen. Wrap the bar into equal-width boxed segments
     (3 + 2) so every tab is visible at 390px; active state stays clearly marked. */
  .aic-tabs {
    flex-wrap: wrap; gap: 6px;
    overflow: visible;            /* no off-screen tabs on mobile */
    border-bottom: 0; margin-bottom: 14px;
  }
  .aic-tab {
    flex: 1 1 28%; text-align: center;
    padding: 9px 8px; font-size: 13px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--soft); color: var(--muted);
  }
  .aic-tab.is-active {
    color: var(--deep); background: var(--surface);
    border-color: var(--gold); box-shadow: var(--shadow-sm);
  }

  /* Keep the status chip a compact pill under the stacked heading, left-aligned. */
  .aic-stamp { align-self: flex-start; }
}

/* ---------- Toast ---------- */
.toast {
  position: sticky; top: 0; z-index: 20; margin-bottom: 14px;
  background: var(--deep); color: #eef8f3;
  border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
}
.toast.warn { background: var(--warn); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- Auth gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(8, 30, 26, .55); backdrop-filter: blur(4px); padding: 20px;
}
body.locked .gate { display: flex; }
.gate-card {
  width: min(440px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.gate-card h2 { font-size: 20px; margin: 8px 0 6px; }
.gate-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
.gate-label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 6px; }
.gate-card input { margin-bottom: 12px; }
.gate-msg { font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.gate-msg.bad { color: var(--bad); }
.gate-msg.ok { color: var(--ok); }
.gate-adv { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.gate-adv summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--deep); }
.gate-adv input { margin: 10px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .owner-grid { grid-template-columns: minmax(0, 1fr); }
  .col-ops { grid-column: 1 / -1; }
  .ops-card { position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: column; }
  .rail-foot { margin-top: 12px; }
  .owner-grid { grid-template-columns: minmax(0, 1fr); }
  .platform-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .counts { grid-template-columns: repeat(3, 1fr); }
  .sm-loop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .main { padding: 16px; }
  .ws-head { flex-direction: column; }
  .seg { width: 100%; overflow-x: auto; }
  .pipeline { grid-template-columns: 1fr; }
  .counts { grid-template-columns: repeat(2, 1fr); }
  .chat-card { min-height: 70vh; }
  .chat-stream { max-height: none; }
  .bubble-user, .bubble-sys { max-width: 100%; }
  .composer { position: sticky; bottom: 0; background: var(--surface); }
  .sm-loop { grid-template-columns: 1fr; }
  .sm-report-tabs .seg.small { width: 100%; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Agent conversation payload ---------- */
.conversation-details { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfb; padding: 10px 12px; }
.conversation-details summary { cursor: pointer; font-weight: 800; color: var(--deep); }
.conversation-line { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #fff; color: var(--ink); font-size: 12.5px; line-height: 1.45; border: 1px solid rgba(11, 57, 49, .08); }

.chat-inline-assets { display: grid; gap: 10px; margin: 8px 0 12px; }
.chat-inline-asset { min-width: 0; }
.protected-image-frame { margin: 0; min-height: 54px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #f8fbf8; overflow: hidden; }
.chat-inline-image { width: 100%; max-height: 560px; object-fit: contain; margin: 0; border: 0; border-radius: 0; background: #f8fbf8; }
.chat-inline-caption { margin-top: 5px; font-size: 10.5px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.image-loading, .image-error { padding: 16px; font-size: 11px; color: var(--muted); text-align: center; }
.image-error { color: var(--danger); }
.evidence-image { width: 100%; max-height: 360px; object-fit: contain; display: block; margin: 8px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbf8; }
