/* ═══════════════════════════════════════════════
   MHP AI Sandbox — Use Case Factory
   Design tokens & global reset
   Brand tokens below are NEUTRAL DEFAULTS — the server injects a per-tenant
   <style id="brand-vars"> override after this file, so the whole app re-themes
   from tenants/<id>/brand.json with zero CSS edits.
════════════════════════════════════════════════ */
:root {
  /* Brand (default = MHP electric blue; overridden per tenant at runtime) */
  --ku: #1612FF;
  --ku-d: #0B0A66;
  --ku-soft: #EEEDFF;
  --ku-soft2: #DEDCFF;

  /* Typography */
  --ink: #1A1A1A;
  --ink2: #404040;
  --muted: #767676;
  --faint: #A3A3A3;

  /* Surfaces */
  --bg: #FFFFFF;
  --surface: #FAF9F7;
  --surface2: #F2F0EB;
  --line: #E8E6E1;

  /* Misc */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(26,26,26,.04), 0 8px 30px -12px rgba(26,26,26,.12);
  --shadow-sm: 0 1px 2px rgba(26,26,26,.06), 0 2px 8px -4px rgba(26,26,26,.08);

  /* Semantic status */
  --green: #15803D;
  --green-bg: #DCFCE7;
  --amber: #B45309;
  --amber-bg: #FEF3C7;
  --red: #B91C1C;
  --red-bg: #FEE2E2;

  /* Sidebar width */
  --sidebar-w: 244px;
  --header-h: 64px;
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  overflow: hidden;
  height: 100dvh;
}

/* ═══ Progress bar ═══════════════════════════════ */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--ku-d), var(--ku) 60%, #ff8a4d);
  z-index: 1000;
  transition: width .4s ease, opacity .4s ease;
  opacity: 0;
  border-radius: 0 2px 2px 0;
}
#progress-bar.active { opacity: 1; }

/* ═══ Toast ══════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 900;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  pointer-events: all;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1) both;
  max-width: 340px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(-8px); opacity: 0; }
}

/* ═══ Shell layout ═══════════════════════════════ */
.shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  height: 100dvh;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.wordmark {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--ku);
  line-height: 1;
  margin-bottom: 4px;
}
.wordmark-cursor {
  display: inline-block;
  animation: blink 1.2s step-end infinite;
  font-size: 1.1rem;
  vertical-align: middle;
  margin-left: 1px;
}
.wordmark-logo {
  display: block;
  height: 26px;
  width: auto;
  margin: 2px 0 4px;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.wordmark-sub {
  font-size: .6875rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Nav */
.nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink2);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--ink); }
.nav-item.active {
  background: var(--ku-soft);
  color: var(--ku);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--ku);
  border-radius: 0 3px 3px 0;
  left: -10px;
}
.nav-icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
  padding: 16px 16px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 10px 5px 8px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink2);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.status-dot.live { background: #22C55E; box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.status-dot.demo { background: var(--ku); box-shadow: 0 0 0 2px rgba(242,92,25,.2); }

.sidebar-region {
  font-size: .6875rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--faint);
  padding-left: 4px;
  letter-spacing: .02em;
}

/* ─── Main area ──────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  height: 100dvh;
  position: relative;
}

.view-mount {
  min-height: 100%;
}

/* ─── View transitions ───────────────────────── */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-enter {
  animation: viewIn .24s cubic-bezier(.22,1,.36,1) both;
}

/* ─── View header ────────────────────────────── */
.view-header {
  padding: 32px 40px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.view-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.2;
}
.view-subtitle {
  font-size: .8125rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ─── View body ──────────────────────────────── */
.view-body { padding: 32px 40px; }

/* ═══ Cards ══════════════════════════════════════ */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-sm {
  padding: 18px 20px;
  border-radius: var(--radius-sm);
}

/* ═══ KPI stat cards ════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label {
  font-size: .6875rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 1.625rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
  letter-spacing: -.03em;
  line-height: 1.1;
}
.kpi-value.accent { color: var(--ku); }
.kpi-sub {
  font-size: .75rem;
  color: var(--faint);
  font-family: 'JetBrains Mono', monospace;
}

/* ═══ Section headers ═══════════════════════════ */
.section-title {
  font-size: .875rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: -.01em;
}
.section-gap { margin-top: 32px; }

/* ═══ Bar chart ══════════════════════════════════ */
.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 90px;
  gap: 12px;
  align-items: center;
}
.bar-label {
  font-size: .8125rem;
  color: var(--ink2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.bar-track {
  height: 22px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ku-d), var(--ku) 60%, #ff8a4d);
  border-radius: 6px;
  transform-origin: left;
  animation: barGrow .6s cubic-bezier(.22,1,.36,1) both;
  will-change: transform;
}
@keyframes barGrow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
.bar-val {
  font-size: .8125rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--ink2);
  white-space: nowrap;
}

/* Exposure bar (custom sizing) */
.exposure-track {
  height: 14px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  flex: 1;
}
.exposure-fill {
  height: 100%;
  border-radius: 4px;
  animation: barGrow .5s cubic-bezier(.22,1,.36,1) both;
}
.exposure-fill.ok { background: #22C55E; }
.exposure-fill.over { background: var(--red); }

/* ═══ Tables ══════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink2);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--ku-soft); }
.data-table .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}

/* ═══ Group P&L table (UC-F1 Consolidate) ═══════ */
.pnl-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.pnl-table th:not(:first-child)  { text-align: right; }
.pnl-table tr.subtotal td {
  font-weight: 700;
  color: var(--ink);
  border-top: 1px solid var(--border, var(--line));
  background: var(--surface);
}
.pnl-table td.neg, .pnl-table tr.subtotal td.neg { color: var(--red); }
.var-pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .6875rem; font-weight: 700; white-space: nowrap;
}
.var-up   { color: var(--green); }
.var-down { color: var(--red); }

/* ═══ Status chips ═══════════════════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip-green  { background: var(--green-bg);  color: var(--green); }
.chip-amber  { background: var(--amber-bg);  color: var(--amber); }
.chip-red    { background: var(--red-bg);    color: var(--red); }
.chip-orange { background: var(--ku-soft2);  color: var(--ku-d); }
.chip-grey   { background: var(--surface2);  color: var(--muted); }
.chip-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .03em;
  background: var(--ku-soft);
  color: var(--ku-d);
  border-radius: 6px;
  padding: 2px 8px;
}

/* ═══ Buttons ════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, color .15s, box-shadow .15s, transform .08s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--ku);
  color: #fff;
  box-shadow: 0 1px 2px rgba(242,92,25,.2), 0 4px 12px rgba(242,92,25,.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--ku-d);
  box-shadow: 0 1px 2px rgba(216,72,15,.3), 0 4px 16px rgba(216,72,15,.25);
}

.btn-secondary {
  background: var(--bg);
  color: var(--ink2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface); }

.btn-ghost {
  background: transparent;
  color: var(--ku);
  border: 1px solid var(--ku-soft2);
}
.btn-ghost:hover:not(:disabled) { background: var(--ku-soft); }

.btn-sm { padding: 7px 14px; font-size: .8125rem; border-radius: var(--radius-xs); }

/* ═══ Dashboard tools strip ═════════════════════ */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.tool-card:hover {
  border-color: var(--ku-soft2);
  box-shadow: 0 0 0 3px var(--ku-soft), var(--shadow-sm);
  transform: translateY(-1px);
}
.tool-card-icon {
  width: 36px; height: 36px;
  background: var(--ku-soft);
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--ku);
}
.tool-card-name {
  font-size: .875rem;
  font-weight: 700;
  color: var(--ink);
}
.tool-card-desc { font-size: .75rem; color: var(--muted); line-height: 1.45; }

/* ═══ Chat / Ask ══════════════════════════════════ */
.ask-layout {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}
.ask-layout .view-header {
  flex-shrink: 0;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 0;
}
.chat-empty-icon {
  width: 60px; height: 60px;
  background: var(--ku-soft);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ku);
}
.chat-empty-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}
.chat-empty-sub {
  font-size: .875rem;
  color: var(--muted);
  text-align: center;
  max-width: 400px;
}
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.suggestion-chip {
  padding: 8px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.suggestion-chip:hover { border-color: var(--ku); background: var(--ku-soft); color: var(--ku); }

/* Bubbles */
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800;
}
.msg-avatar.ai {
  background: var(--ku);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
}
.msg-avatar.user-av {
  background: var(--surface2);
  color: var(--ink2);
  font-weight: 700;
}

.msg-bubble {
  max-width: 74%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  line-height: 1.65;
}
.msg.user .msg-bubble {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm) var(--radius-sm) 4px var(--radius-sm);
}
.msg.ai .msg-bubble {
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 4px;
}

.msg-sql-toggle {
  display: block;
  width: 100%;
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ku);
  padding-top: 10px;
  list-style: none;
  user-select: none;
}
.msg-sql-toggle::-webkit-details-marker { display: none; }
details[open] .msg-sql-toggle::after { content: ' ▲'; }
.msg-sql-toggle::after { content: ' ▼'; opacity: .6; }
.msg-sql-block {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink2);
  line-height: 1.7;
}
.msg-meta {
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  color: var(--faint);
}

.thinking-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ku);
  margin: 0 2px;
  animation: dotBounce 1.2s infinite both;
}
.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotBounce {
  0%,80%,100% { transform: translateY(0); opacity: .4; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* Composer */
.chat-composer {
  flex-shrink: 0;
  padding: 16px 40px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 10px 10px 16px;
  transition: border-color .2s, box-shadow .2s;
}
.composer-inner:focus-within {
  border-color: var(--ku);
  box-shadow: 0 0 0 3px var(--ku-soft);
}
.composer-textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .9375rem;
  color: var(--ink);
  resize: none;
  outline: none;
  max-height: 160px;
  min-height: 24px;
  line-height: 1.5;
}
.composer-textarea::placeholder { color: var(--faint); }
.composer-send {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--ku);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: background .15s, transform .08s;
}
.composer-send:hover { background: var(--ku-d); }
.composer-send:active { transform: scale(.94); }
.composer-send:disabled { opacity: .5; cursor: not-allowed; }

/* ═══ Exceptions ══════════════════════════════════ */
.exception-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.exception-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.exception-card-body { padding: 20px 24px; }
.exception-order-id {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: .875rem;
  color: var(--ink);
}
.exception-customer { font-size: .8125rem; color: var(--muted); }
.exception-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.exception-why { font-size: .8125rem; color: var(--muted); line-height: 1.65; margin: 10px 0 0; }
.exception-block-reason {
  font-size: .8125rem;
  color: var(--ink2);
  margin-top: 4px;
}
.exception-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══ Signals — UC-SC1 open-order exception queue ═══════════════ */
.sig-select {
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: .8125rem; color: var(--ink2);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 7px 10px; cursor: pointer;
}
.signals-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.signals-queue-wrap { min-width: 0; }
.signals-queue { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 70vh; overflow-y: auto; }
.signals-panel { min-width: 0; }
.signal-row {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .12s, background .12s;
}
.signal-row:hover { border-color: var(--ku-soft2); background: var(--ku-soft); }
.signal-row.selected { border-color: var(--ku); box-shadow: 0 0 0 2px var(--ku-soft); }
.signal-row-main { min-width: 0; }
.signal-row-top { display: flex; align-items: center; gap: 7px; }
.signal-row-order { font-size: .8125rem; font-weight: 600; color: var(--ink); }
.signal-row-cust { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.signal-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; white-space: nowrap; }
.signal-row-value { font-size: .8125rem; font-weight: 700; color: var(--ink); }
.signal-type-chip { letter-spacing: .02em; }
.sev-dot { width: 8px; height: 8px; border-radius: 99px; flex: 0 0 auto; display: inline-block; }
.sev-critical { background: var(--red); }
.sev-high { background: var(--amber); }
.sev-medium { background: var(--ku); }
.sev-low { background: var(--faint); }
@media (max-width: 900px) {
  .signals-grid { grid-template-columns: 1fr; }
  .signals-queue { max-height: 420px; }
}

.exposure-panel {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.exposure-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  margin-bottom: 14px;
}
.exposure-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ═══ Master data ════════════════════════════════ */
.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.score-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  text-align: center;
}
.score-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ku);
  letter-spacing: -.03em;
}
.score-label {
  font-size: .6875rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-top: 4px;
}

/* Confidence mini bar in table */
.conf-bar-wrap {
  display: flex; align-items: center; gap: 8px;
}
.conf-track {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.conf-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ku-d), var(--ku));
}
.conf-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  color: var(--muted);
  white-space: nowrap;
}

.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.loading-state .loading-label {
  font-size: .875rem;
  font-weight: 500;
}
.loading-state .loading-sub {
  font-size: .8125rem;
  color: var(--faint);
  font-family: 'JetBrains Mono', monospace;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--surface2);
  border-top-color: var(--ku);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Success banner */
.success-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--green-bg);
  border: 1px solid rgba(21,128,61,.2);
  border-radius: var(--radius-sm);
  color: var(--green);
  font-weight: 600;
  font-size: .875rem;
  animation: viewIn .25s ease both;
}

/* ═══ Memory ═════════════════════════════════════ */
.cost-audit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.cost-audit-item {}
.cost-audit-label {
  font-size: .6875rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 4px;
}
.cost-audit-value {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ink);
}

.relationship-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: .8125rem;
}
.relationship-row:last-child { border-bottom: none; }
.rel-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: .8125rem;
  color: var(--ink2);
}
.rel-arrow { color: var(--faint); flex-shrink: 0; font-size: .75rem; }
.rel-conf {
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  color: var(--faint);
  margin-left: auto;
  white-space: nowrap;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.glossary-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.glossary-term {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.glossary-def {
  font-size: .8125rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 10px;
}
.glossary-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.variant-chip {
  display: inline-flex;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface2);
  border-radius: var(--radius-xs);
  font-family: 'JetBrains Mono', monospace;
  font-size: .625rem;
  color: var(--muted);
}
.variant-key { color: var(--faint); }

/* ═══ Skeleton loaders ═══════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
  display: block;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ═══ Empty & error states ═══════════════════════ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--faint);
  font-size: .8125rem;
}
.error-state {
  padding: 16px 20px;
  background: var(--red-bg);
  border: 1px solid rgba(185,28,28,.15);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: .875rem;
}

/* ═══ Intro text ═════════════════════════════════ */
.intro-text {
  font-size: .9375rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 640px;
  margin-bottom: 24px;
}

/* ═══ Dividers & helpers ═════════════════════════ */
.gap-8  { display: flex; flex-direction: column; gap: 8px;  }
.gap-12 { display: flex; flex-direction: column; gap: 12px; }
.gap-16 { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bold { font-weight: 700; }
.mono { font-family: 'JetBrains Mono', monospace; }
.text-muted { color: var(--muted); }
.text-faint  { color: var(--faint); }

/* ═══ Scrollbar ══════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ═══ Responsive ══════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }
  .wordmark-sub, .nav-item span:last-child, .sidebar-region { display: none; }
  .sidebar-header { padding: 16px 14px; }
  .nav { padding: 8px 6px; }
  .nav-item { padding: 10px; justify-content: center; }
  .nav-icon { width: 22px; height: 22px; }
  .sidebar-footer { padding: 12px 8px; align-items: center; }
  .status-chip { padding: 6px; }
  #status-label { display: none; }
  .view-header, .view-body { padding-left: 24px; padding-right: 24px; }
  .chat-scroll, .chat-composer { padding-left: 20px; padding-right: 20px; }
  .bar-row { grid-template-columns: 100px 1fr 70px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ═══ Orchestrate — live node graph ═══════════════ */
.orch-graph {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px 0;
  margin-bottom: 8px;
}
.orch-node {
  width: 158px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 14px 12px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .25s ease, background .25s ease, box-shadow .25s ease, opacity .25s ease;
}
.orch-node-ic { color: var(--ink2); display: flex; }
.orch-node.orch-opus   .orch-node-ic { color: var(--ku); }
.orch-node.orch-memory .orch-node-ic { color: var(--ku-d); }
.orch-node.orch-sap    .orch-node-ic { color: var(--ink2); }
.orch-node.orch-human  .orch-node-ic { color: var(--green); }
.orch-node-label { font-weight: 600; font-size: .8125rem; line-height: 1.25; }
.orch-node-detail {
  font-size: .6875rem; color: var(--muted); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.4em;
}
.orch-node-ms { font-size: .625rem; color: var(--faint); margin-top: auto; }

.orch-node.is-pending { opacity: .45; }
.orch-node.is-skipped { opacity: .3; }
.orch-node.is-running {
  border-color: var(--ku);
  box-shadow: 0 0 0 3px rgba(242, 92, 25, .15);
  animation: orchpulse 1.1s ease-in-out infinite;
}
.orch-node.is-done { border-color: var(--ku); background: var(--ku-soft); }
.orch-node.is-error { border-color: var(--red); background: var(--red-bg); }

.orch-edge {
  align-self: center;
  width: 22px; height: 2px;
  background: var(--line);
  transition: background .3s ease;
}
.orch-edge.lit { background: var(--ku); }

@keyframes orchpulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(242, 92, 25, .15); }
  50%      { box-shadow: 0 0 0 5px rgba(242, 92, 25, .28); }
}

.orch-gate { border-left: 3px solid var(--ku); }
.orch-why { font-size: .875rem; color: var(--ink2); line-height: 1.5; max-width: 60ch; }

@media (max-width: 900px) {
  .orch-node { width: calc(50% - 16px); }
  .orch-edge { display: none; }
  .orch-graph { gap: 10px; }
}

/* ═══ Data-source toggle (sidebar) ═══════════════ */
.source-toggle {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  padding: 3px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
}
.src-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: .6875rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.src-btn:hover { color: var(--ink); }
.src-btn.active { background: var(--ku); color: #fff; }
.source-hint { font-size: .625rem; color: var(--faint); margin-top: 6px; text-align: center; }

@media (max-width: 900px) {
  .source-toggle, .source-hint { display: none; }
}

/* ═══ Ask query-engine selector (Auto · synthetic store · Databricks) ═══ */
.ask-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ask-engine { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ask-engine-label { font-size: .625rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-right: 2px; }
.eng-btn {
  font-family: inherit; font-size: .75rem; font-weight: 600;
  padding: 5px 11px; color: var(--muted);
  background: var(--surface2); border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.eng-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--ku); }
.eng-btn.active { background: var(--ku); color: #fff; }
.eng-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ═══ Showcase — guided stepper ═══════════════════ */
.showcase-track {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 760px;
}
.showcase-step {
  display: flex;
  gap: 16px;
  padding: 0 0 28px 0;
  position: relative;
}
/* vertical connector line between steps */
.showcase-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px; top: 36px; bottom: 0;
  width: 2px;
  background: var(--line);
}
.showcase-step.done:not(:last-child)::before { background: var(--ku); }
.showcase-num {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9375rem;
  background: var(--surface2);
  color: var(--muted);
  border: 2px solid var(--line);
  z-index: 1;
  transition: background .25s ease, color .25s ease, border-color .25s ease;
}
.showcase-step.active .showcase-num { border-color: var(--ku); color: var(--ku); }
.showcase-step.done .showcase-num { background: var(--ku); color: #fff; border-color: var(--ku); }
.showcase-main { flex: 1; padding-top: 4px; }
.showcase-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.showcase-step:not(.active):not(.done) .showcase-title { color: var(--muted); }
.showcase-blurb { font-size: .8125rem; color: var(--muted); line-height: 1.5; max-width: 56ch; }
.showcase-result {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--ku-soft);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  line-height: 1.5;
}
.showcase-main .showcase-go { margin-top: 12px; }
.link { color: var(--ku); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ═══ Service Desk — IT incident triage (UC-IT1) ═══ */
.sd-frontdoor { margin: 4px 0 24px; }
.sd-frontdoor-label { font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.sd-frontdoor .composer-inner { margin: 0; }

.itsm-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.itsm-inbox-wrap { min-width: 0; }
.itsm-inbox {
  margin-top: 12px;
  max-height: calc(100dvh - 360px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-right: 4px;
}
.itsm-ticket {
  position: relative;
  text-align: left;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  font: inherit;
  color: inherit;
}
.itsm-ticket:hover { background: var(--ku-soft); border-color: var(--ku-soft2); }
.itsm-ticket.active { background: var(--ku-soft); border-color: var(--ku); }
.itsm-ticket.active::before {
  content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px;
  width: 3px; background: var(--ku); border-radius: 0 3px 3px 0;
}
.itsm-ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.itsm-ticket-id { font-size: .75rem; font-weight: 700; color: var(--ink); }
.itsm-ticket-subj { font-size: .8125rem; color: var(--ink2); margin: 6px 0; line-height: 1.4; }
.itsm-ticket-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .6875rem; }

.itsm-panel { min-width: 0; }
.sd-result .exception-card-header { align-items: flex-start; }
.sd-section-label {
  font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--faint); margin: 18px 0 8px;
}
.sd-section-label:first-child { margin-top: 0; }
.sd-kb-list { display: flex; flex-direction: column; gap: 6px; }
.sd-kb-hit {
  border: 1px solid var(--line); border-radius: var(--radius-xs);
  background: var(--surface); padding: 0;
}
.sd-kb-hit > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 9px 12px; list-style: none; font-size: .8125rem;
}
.sd-kb-hit > summary::-webkit-details-marker { display: none; }
.sd-kb-id { font-size: .75rem; font-weight: 700; color: var(--ku-d); flex-shrink: 0; }
.sd-kb-title { color: var(--ink2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-kb-hit .conf-bar-wrap { width: 110px; flex-shrink: 0; }
.sd-kb-snippet {
  padding: 0 12px 12px; font-size: .75rem; color: var(--muted); line-height: 1.6;
  border-top: 1px solid var(--line); margin-top: 2px; padding-top: 10px;
}
.sd-rationale { font-size: .75rem; line-height: 1.55; margin-top: 8px; }
.sd-ctx-profile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8125rem; margin-bottom: 10px; }

@media (max-width: 900px) {
  .itsm-grid { grid-template-columns: 1fr; }
  .itsm-inbox { max-height: 360px; }
}

/* ═══════════════════════════════════════════════
   CORPORATE-MEMORY CONSTELLATION (Memory → Graph)
════════════════════════════════════════════════ */
/* Generic segmented toggle (Graph | Records) */
.seg-toggle { display: inline-flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 99px; padding: 3px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font: 600 .8125rem/1 'Plus Jakarta Sans', sans-serif; padding: 6px 14px; border-radius: 99px; cursor: pointer; transition: color .18s ease, background .18s ease; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--bg); color: var(--ku); box-shadow: var(--shadow-sm); }

/* Filter bar */
.cm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; }
.cm-filter-grp { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cm-filter-lbl { font: 600 .6875rem/1 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin-right: 2px; }
.cm-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--ink2); font: 600 .75rem/1 'Plus Jakarta Sans', sans-serif; padding: 5px 10px; border-radius: 99px; cursor: pointer; transition: border-color .15s ease, opacity .15s ease; }
.cm-chip:hover { border-color: var(--ku); }
.cm-chip.is-off { opacity: .4; text-decoration: line-through; background: var(--surface2); }
.cm-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cm-slider { accent-color: var(--ku); width: 108px; cursor: pointer; }

/* Canvas + side panel */
.cm-graph-wrap { display: grid; grid-template-columns: 1fr 264px; gap: 14px; align-items: start; }
.cm-graph-canvas { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 64vh; box-shadow: var(--shadow-sm); }
.cm-svg { display: block; }
.cm-bg { fill: transparent; }
.cm-lane { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.cm-lane-label { fill: var(--faint); font: 600 .6875rem/1 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .06em; }

/* Edges (typed) */
.cm-edge { fill: none; stroke: #94A3B8; stroke-width: 1.5; opacity: .2; transition: opacity .2s ease, stroke-width .2s ease; }
.cm-edge[data-rel="SAME_AS"] { stroke: var(--ku); }
.cm-edge[data-rel="MAPS_TO_GROUP_ACCOUNT"] { stroke: #2563EB; stroke-dasharray: 5 3; }
.cm-edge.is-lit { opacity: .95; stroke-width: 2.5; }
.cm-edge.is-dim { opacity: .04; }

/* Nodes */
.cm-node { cursor: pointer; }
.cm-dot { stroke: var(--bg); stroke-width: 2; transition: opacity .2s ease; }
.cm-node:hover .cm-dot { stroke: var(--ink); }
.cm-golden { fill: none; stroke: #B45309; stroke-width: 1.5; stroke-dasharray: 2 2; }
.cm-node-label { text-anchor: middle; fill: var(--muted); font: 500 .625rem/1 'JetBrains Mono', monospace; pointer-events: none; }
.cm-node.is-focus .cm-dot { stroke: var(--ink); stroke-width: 2.5; }
.cm-node.is-focus .cm-node-label,
.cm-node.is-lit .cm-node-label { fill: var(--ink); font-weight: 700; }
.cm-node.is-dim { opacity: .22; }

/* Side detail */
.cm-side { position: sticky; top: 8px; }
.cm-side-empty { padding: 18px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: .8125rem; color: var(--ink2); line-height: 1.6; }
.cm-card { padding: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.cm-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cm-card-key { font-size: .9375rem; font-weight: 700; color: var(--ink); }
.cm-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cm-card-sub { font-size: .75rem; color: var(--muted); }
.cm-rel { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .8125rem; }
.cm-rel-key { border: 0; background: none; color: var(--ku); font: 600 .8125rem/1 'JetBrains Mono', monospace; cursor: pointer; padding: 0; text-align: left; }
.cm-rel-key:hover { text-decoration: underline; }

/* Legend */
.cm-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: .75rem; color: var(--ink2); }
.cm-leg-grp { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cm-leg { display: inline-flex; align-items: center; gap: 6px; }
.cm-leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cm-leg-dot.ring { background: transparent; border: 1.5px dashed #B45309; }
.cm-leg-line { width: 18px; border-top: 2px solid #94A3B8; flex-shrink: 0; }
.cm-leg-line.same { border-color: var(--ku); }
.cm-leg-line.maps { border-top-style: dashed; border-color: #2563EB; }
.cm-leg-hint { color: var(--faint); margin-left: auto; }

@media (max-width: 900px) {
  .cm-graph-wrap { grid-template-columns: 1fr; }
  .cm-side { position: static; }
}

/* ═══════════════════════════════════════════════
   SYSTEMS OVERVIEW (live topology + ▶ Play trace)
════════════════════════════════════════════════ */
.sys-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.sys-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px; font: 600 .8125rem/1 'Plus Jakarta Sans', sans-serif; border: 1px solid var(--line); background: var(--bg); color: var(--ink2); }
.sys-badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.sys-badge.on { background: var(--green-bg); color: var(--green); border-color: transparent; }
.sys-badge.on .sys-badge-dot { background: #22C55E; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.sys-badge.off { background: var(--surface2); color: var(--muted); }
.sys-badge.off .sys-badge-dot { background: #CBD5E1; }
.sys-badge.neutral { background: var(--surface); color: var(--muted); }
.sys-badge.neutral .sys-badge-dot { background: var(--ku); }
.sys-play { margin-left: auto; }

/* Landscape (SAP estate) drill-down header */
.sys-land-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.sys-land-title { font: 700 1.0625rem/1.2 'Plus Jakarta Sans', sans-serif; color: var(--ink); }
.sys-land-meta { font: 500 .8125rem/1.3 'JetBrains Mono', monospace; color: var(--muted); margin-top: 3px; }

.sys-wrap { display: grid; grid-template-columns: 1fr 264px; gap: 14px; align-items: start; }
.sys-canvas { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-sm); overflow: auto; }
.sys-svg { display: block; width: 100%; }
.sys-lane { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.sys-lane-label { fill: var(--faint); font: 600 .6875rem/1 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .06em; }

/* Edges + flowing pulses */
.sys-edge { fill: none; stroke: #B9C0CB; stroke-width: 1.6; opacity: .55; transition: stroke .25s ease, stroke-width .25s ease, opacity .25s ease; }
.sys-edge.is-off { opacity: .18; stroke-dasharray: 3 4; }
.sys-edge.lit { stroke: var(--ku); stroke-width: 3; opacity: 1; }
.sys-pulse { fill: var(--ku); opacity: .9; }

/* Cards */
.sys-node { cursor: pointer; }
.sys-card { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; transition: stroke .2s ease, filter .2s ease; }
.sys-node:hover .sys-card { stroke: var(--ku); }
.sys-card-live { stroke: rgba(34,197,94,.5); }
.sys-card-off { fill: var(--surface2); }
.sys-card-fo { box-sizing: border-box; width: 100%; height: 100%; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.sys-fo-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sys-fo-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sys-fo-label { font: 700 .8rem/1.15 'Plus Jakarta Sans', sans-serif; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sys-fo-sub { font: 500 .66rem/1.2 'JetBrains Mono', monospace; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-dot { stroke: var(--bg); stroke-width: 1.5; }
.sys-dot-live { fill: #22C55E; background: #22C55E; }
.sys-dot-wired { fill: #2563EB; background: #2563EB; }
.sys-dot-ready { fill: var(--ku); background: var(--ku); }
.sys-dot-off { fill: #CBD5E1; background: #CBD5E1; }
.sys-node.is-focus .sys-card { stroke: var(--ku); stroke-width: 2.5; }
.sys-node.firing .sys-card { stroke: var(--ku); stroke-width: 2.5; filter: drop-shadow(0 0 7px rgba(242,92,25,.5)); }
.sys-node.firing .sys-fo-dot { background: var(--ku); }

@media (max-width: 900px) {
  .sys-wrap { grid-template-columns: 1fr; }
  .sys-play { margin-left: 0; }
}
