﻿/* =========================================================
   System Manager AI Studio - clean, functional, Apple-like
   SF Pro · neutral grays · light + dark · navy accent
   ========================================================= */

:root {
  color-scheme: light dark;

  /* Apple-like SF stack */
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Light theme (default) */
  --bg:        #f5f5f7;     /* page bg, Apple light gray */
  --surface:   #ffffff;
  --surface-2: #fbfbfd;
  --hover:     #f2f2f5;
  --rule:      #e5e5ea;     /* hairline */
  --rule-2:    #d2d2d7;
  --rule-strong: #b9b9c0;

  --ink:       #1d1d1f;     /* primary */
  --ink-2:     #424245;
  --ink-3:     #6e6e73;     /* muted */
  --ink-4:     #86868b;

  /* Accent - navy / dark blue */
  --accent:     #1d4ed8;
  --accent-2:   #2447a8;
  --accent-bg:  #e6ebf6;
  --accent-ink: #16317d;

  /* Status (subtle, neutral-leaning) */
  --ok:        #1c8f5a;
  --ok-bg:     #e3f2eb;
  --warn:      #b15c00;
  --warn-bg:   #fbeed5;
  --bad:       #b42a2a;
  --bad-bg:    #f5dada;

  --shadow-1:  0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-2:  0 4px 16px -4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);

  --radius:    8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: .18s;
  --duration-normal: .24s;

  --sidebar-bg: #fbfbfd;
  --sidebar-rule: #e5e5ea;
  --sidebar-ink: #1d1d1f;
  --sidebar-muted: #6e6e73;
  --sidebar-active-bg: #eef0f4;

  /* Design tokens - painel */
  --color-bg-base: var(--bg);
  --color-bg-side: var(--sidebar-bg);
  --color-surface: var(--surface);
  --color-surface-2: var(--surface-2);
  --color-surface-3: var(--hover);
  --color-border: var(--rule);
  --color-primary: var(--accent);
  --color-primary-hover: var(--accent-2);
  --color-primary-soft: var(--accent-bg);
  --color-success: var(--ok);
  --color-warning: var(--warn);
  --color-danger: var(--bad);
  --color-info: var(--accent);
  --color-text: var(--ink);
  --color-text-muted: var(--ink-3);
  --color-text-disabled: var(--ink-4);
  --color-text-inverse: #ffffff;
  --font-family: var(--ui);
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 13.5px;
  --font-size-lg: 15px;
  --font-size-xl: 18px;
  --font-size-2xl: 22px;
  --font-size-3xl: 28px;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --radius-md: var(--radius);
  --radius-pill: 999px;
  --border-width: 1px;
  --shadow-sm: var(--shadow-1);
  --shadow-md: var(--shadow-2);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.18);
  --ease-default: cubic-bezier(.2, .8, .2, 1);
  --duration-fast: 150ms;
  --duration-medium: 250ms;
  --duration-slow: 400ms;

  /* Legacy aliases expected by older snippets/tests */
  --side: var(--sidebar-bg);
  --surf: var(--surface);
  --surf2: var(--surface-2);
  --surf3: var(--hover);
  --acc: var(--accent);
  --acc2: var(--accent-2);
  --acc3: var(--accent-bg);
  --err: var(--bad);
  --txt: var(--ink);
  --mut: var(--ink-3);
  --bdr: var(--rule);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0b0b0d;
  --surface:   #131316;
  --surface-2: #17171b;
  --hover:     #1c1c20;
  --rule:      #26262b;
  --rule-2:    #34343a;
  --rule-strong: #55555f;

  --ink:       #f5f5f7;
  --ink-2:     #d1d1d6;
  --ink-3:     #98989d;
  --ink-4:     #6e6e73;

  --accent:     #5b8def;
  --accent-2:   #4a78d8;
  --accent-bg:  #1a2440;
  --accent-ink: #b6cbf6;

  --ok:        #4ec48a;
  --ok-bg:     #18301f;
  --warn:      #e0a060;
  --warn-bg:   #2e2210;
  --bad:       #e88080;
  --bad-bg:    #321414;

  --shadow-1:  0 1px 2px rgba(0,0,0,0.4);
  --shadow-2:  0 8px 24px -8px rgba(0,0,0,0.5);

  --sidebar-bg: #0f0f12;
  --sidebar-rule: #26262b;
  --sidebar-ink: #f5f5f7;
  --sidebar-muted: #98989d;
  --sidebar-active-bg: #1c1c22;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
.boot-loading {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--ink-3);
  text-align: center;
}
.boot-mark {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border-radius: 8px;
  background: #050505;
  object-fit: cover;
  display: block;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea { font-family: inherit; }

/* ========== Keyframes ========== */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes cardEntrance { from { opacity: 0; transform: translateY(14px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes shimmer { from { background-position: -600px 0 } to { background-position: 600px 0 } }
@keyframes spin { to { transform: rotate(360deg) } }

.stagger-children > * { animation: cardEntrance .22s ease-out both }
.stagger-children > *:nth-child(1) { animation-delay: .03s }
.stagger-children > *:nth-child(2) { animation-delay: .06s }
.stagger-children > *:nth-child(3) { animation-delay: .09s }
.stagger-children > *:nth-child(4) { animation-delay: .12s }
.stagger-children > *:nth-child(5) { animation-delay: .15s }
.stagger-children > *:nth-child(6) { animation-delay: .18s }
.stagger-children > *:nth-child(n+7) { animation-delay: .21s }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important }
}

/* ========== Shell ========== */
.shell {
  display: grid;
  grid-template-columns: 64px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .22s cubic-bezier(.4,0,.2,1);
}
.shell:has(.sidebar:hover),
.shell:has(.sidebar.pinned) {
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-rule);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  width: 64px;
  overflow: hidden;
  overflow-y: auto;
  transition: width .24s cubic-bezier(.4,0,.2,1);
}
.sidebar:hover,
.sidebar.pinned {
  width: 248px;
}
.sidebar:not(:hover):not(.pinned) {
  overflow: visible;
}
.sidebar:not(:hover):not(.pinned) .sb-brand {
  padding: 16px 0 14px;
  justify-content: center;
}
.sidebar:not(:hover):not(.pinned) .sb-brand > div,
.sidebar:not(:hover):not(.pinned) .sb-pin-btn {
  display: none;
}
.sidebar:not(:hover):not(.pinned) .sb-brand-mark {
  width: 34px;
  height: 34px;
}
.sidebar:not(:hover):not(.pinned) .sb-section-label {
  height: 1px;
  margin: 10px 16px 7px;
  padding: 0;
  overflow: hidden;
  opacity: 1;
  border-top: 1px solid color-mix(in srgb, var(--sidebar-rule) 70%, transparent);
  color: transparent;
  font-size: 0;
}
.sidebar:not(:hover):not(.pinned) .sb-nav {
  padding: 0 12px;
  gap: 7px;
  align-items: center;
}
.sidebar:not(:hover):not(.pinned) .sb-item {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  gap: 0;
  border-radius: 10px;
}
.sidebar:not(:hover):not(.pinned) .sb-item svg {
  flex: 0 0 auto;
  margin: 0;
}
.sidebar:not(:hover):not(.pinned) .sb-item > span,
.sidebar:not(:hover):not(.pinned) .sb-item .count {
  display: none !important;
}
.sidebar:not(:hover):not(.pinned) .setup-cta {
  margin: 10px 12px 6px;
}
.sidebar:not(:hover):not(.pinned) .sb-foot {
  display: none !important;
}
/* labels/text fade in on expand */
.sidebar .sb-brand-name,
.sidebar .sb-brand-tag,
.sidebar .sb-section-label,
.sidebar .sb-item span,
.sidebar .sb-item .count,
.sidebar .sb-foot .row span:last-child {
  opacity: 0;
  white-space: nowrap;
  transition: opacity .14s;
}
.sidebar:hover .sb-brand-name,
.sidebar:hover .sb-brand-tag,
.sidebar:hover .sb-section-label,
.sidebar:hover .sb-item span,
.sidebar:hover .sb-item .count,
.sidebar:hover .sb-foot .row span:last-child,
.sidebar.pinned .sb-brand-name,
.sidebar.pinned .sb-brand-tag,
.sidebar.pinned .sb-section-label,
.sidebar.pinned .sb-item span,
.sidebar.pinned .sb-item .count,
.sidebar.pinned .sb-foot .row span:last-child {
  opacity: 1;
}
/* pin button */
.sb-pin-btn {
  position: absolute; top: 18px; right: 10px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--sidebar-muted);
  border-radius: 5px;
  opacity: 0;
  transition: opacity .14s, color .12s;
}
.sidebar:hover .sb-pin-btn { opacity: 1; }
.sb-pin-btn:hover { background: var(--hover); color: var(--ink); }
.sb-pin-btn.active { color: var(--accent); opacity: 1; }
.sb-brand { position: relative; }

.sb-brand {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--sidebar-rule);
}
.sb-brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: #050505;
  object-fit: cover;
  display: block;
  flex: 0 0 auto;
}
.sb-brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-ink);
  letter-spacing: 0;
}
.sb-brand-tag {
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-top: 1px;
}

.sb-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--sidebar-muted);
  padding: 18px 18px 6px;
  font-weight: 500;
}
.sb-nav + .sb-section-label { padding-top:14px; border-top:1px solid color-mix(in srgb, var(--sidebar-rule) 50%, transparent); margin-top:4px; }

.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  color: var(--sidebar-ink);
  font-size: 13px;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: 6px;
  width: 100%;
}
.sb-item { position: relative; }
.sb-item:hover { background: var(--hover); }
.sb-item.active {
  background: var(--sidebar-active-bg);
  color: var(--ink);
  font-weight: 500;
}
.sb-item.active svg { color: var(--accent); }
.sb-item.active::before {
  content:''; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:3px; height:60%; border-radius:0 3px 3px 0;
  background:var(--accent); transition: height .2s;
}
/* Tooltip on collapsed sidebar */
.sidebar:not(:hover):not(.pinned) .sb-item[data-tooltip] { overflow:visible; }
.sidebar:not(:hover):not(.pinned) .sb-item[data-tooltip]:hover::after {
  content:attr(data-tooltip);
  position:absolute; left:calc(100% + 8px); top:50%; transform:translateY(-50%);
  background:var(--ink); color:var(--bg); font-size:11.5px; font-weight:500;
  padding:4px 10px; border-radius:6px; white-space:nowrap; z-index:100;
  pointer-events:none; box-shadow:var(--shadow-2);
  animation: sbTooltipIn .15s ease-out;
}
@keyframes sbTooltipIn { from { opacity:0; transform:translateY(-50%) translateX(-4px) } to { opacity:1; transform:translateY(-50%) translateX(0) } }
.setup-cta {
  margin: 10px 8px 2px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--rule));
  background: color-mix(in srgb, var(--accent-bg) 52%, var(--surface));
}
.setup-cta .pill { margin-left: auto; }
.sb-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.sb-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-rule);
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11.5px;
  color: var(--sidebar-muted);
}
.sb-foot .row { display: flex; justify-content: space-between; }
.sb-foot .ok { color: var(--ok); }

/* ========== Main column ========== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.crumbs {
  font-size: 13px;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 6px;
}
.crumbs .sep { color: var(--ink-4); }
.crumbs .here { color: var(--ink); font-weight: 500;}

.topbar-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 6px 11px;
  border-radius: 8px;
  width: 300px;
  color: var(--ink-3);
}
.topbar-search input {
  border: none; background: transparent; outline: none;
  flex: 1; color: var(--ink); font-size: 13px;
}
.topbar-kbd {
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.tb-btn {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 6px 11px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s ease;
}
.tb-btn:hover { background: var(--hover); }
.tb-btn.primary {
  background: var(--accent); color: #fff; border-color: transparent;
}
.tb-btn.primary:hover { background: var(--accent-2); }
.tb-btn.ghost {
  background: transparent; border-color: transparent;
}
.tb-btn.ghost:hover { background: var(--hover); }

.theme-toggle {
  width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid var(--rule);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--ink-2);
}
.theme-toggle:hover { background: var(--hover); }

/* ========== Page header ========== */
.page-head {
  padding: 24px 24px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
}
.page-eyebrow {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 6px;
  font-weight: 500;
}
.page-title {
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.page-sub {
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 13.5px;
  max-width: 640px;
}
.page-meta {
  display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end;
}
.meta-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.meta-row .sw { width: 8px; height: 8px; border-radius: 50%;}

/* ========== Cards / panels ========== */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  gap: 10px;
}
.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}
.panel-eyebrow {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.panel-actions { display: flex; align-items: center; gap: 8px; }

/* KPI */
.kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.kpi-label {
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink);
  line-height: 1;
  display: flex; align-items: baseline; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
  letter-spacing: 0;
}
.kpi-foot {
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: auto;
}
.delta { font-variant-numeric: tabular-nums; font-weight: 500;}
.delta.up { color: var(--ok); }
.delta.dn { color: var(--bad); }

.spark { height: 28px; width: 100%; display: block; }

/* ========== Badges ========== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}
.badge .sw { width: 6px; height: 6px; border-radius: 50%; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.accent { background: var(--accent-bg); color: var(--accent-ink); }
.mini-spinner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: mini-spin .75s linear infinite;
}
@keyframes mini-spin { to { transform: rotate(360deg); } }
.notify-target-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 24px;
}
.chip-x {
  border: 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font: inherit;
  padding: 0 0 0 4px;
  opacity: .75;
}
.chip-x:hover { opacity: 1; }

[data-theme="dark"] .badge.accent { color: var(--accent); }

.sw {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-4);
}
.sw.ok { background: var(--ok); }
.sw.warn { background: var(--warn); }
.sw.bad { background: var(--bad); }
.sw.accent { background: var(--accent); }
.sw.ink { background: var(--ink); }

/* ========== Table ========== */
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}
.dt th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
  white-space: nowrap;
}
.dt td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  vertical-align: middle;
  line-height: 1.4;
}
.dt tr:last-child td { border-bottom: none; }
.dt tr:hover td { background: var(--hover); }
.dt td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.dt th.num { text-align: right; }

/* ========== Heatmap ========== */
.hm {
  display: grid;
  grid-template-columns: 32px repeat(24, 1fr);
  gap: 3px;
  font-size: 10.5px;
  color: var(--ink-3);
}
.hm .cell {
  aspect-ratio: 1 / 1;
  background: var(--hover);
  border-radius: 3px;
}
.hm .cell.l1 { background: #d8e0f0; }
.hm .cell.l2 { background: #aebbe0; }
.hm .cell.l3 { background: #6f87ca; }
.hm .cell.l4 { background: var(--accent); }
.hm .cell.l5 { background: var(--accent-2); }

[data-theme="dark"] .hm .cell.l1 { background: #1f2a44; }
[data-theme="dark"] .hm .cell.l2 { background: #2c3e6e; }
[data-theme="dark"] .hm .cell.l3 { background: #3f5aa3; }
[data-theme="dark"] .hm .cell.l4 { background: var(--accent); }
[data-theme="dark"] .hm .cell.l5 { background: #80a4f5; }

.hm .row-label { display: flex; align-items: center; padding-right: 4px; justify-content: flex-end;}
.hm .col-label { text-align: center; padding-bottom: 2px;}

/* Bar chart */
.barchart { width: 100%; height: 220px; display: block; }

/* Helpers */
.muted { color: var(--ink-3); }
.tabular { font-variant-numeric: tabular-nums; }

/* Layout helpers */
.page { padding: 0 24px 60px; display: flex; flex-direction: column; gap: 16px; }
.grid-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* Filter pills (segmented control feel) */
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.channel-filter-row { margin-top: 8px; }
.filter-divider {
  display: grid;
  grid-template-columns: auto minmax(24px, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 8px 0 6px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.filter-divider i { display: block; height: 1px; background: var(--rule); }
.fp {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
}
.fp:hover { background: var(--hover); }
.fp.active {
  background: var(--ink);
  color: var(--surface);
  border-color: transparent;
}
.fp .count { font-size: 11px; color: var(--ink-3); }
.fp.active .count { color: rgba(255,255,255,0.7); }

[data-theme="dark"] .fp.active { background: var(--ink); color: var(--bg); }
.select-filter {
  height: 31px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12px;
}

/* Conversations */
.conv-shell {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  flex: 1;
  height: clamp(520px, calc(100dvh - 138px), 760px);
  min-height: 0;
  max-height: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.conv-page {
  height: calc(100dvh - 220px);
  min-height: 520px;
  overflow: hidden;
  padding-bottom: 24px;
}
.conv-page .conv-shell {
  height: 100%;
  min-height: 0;
  max-height: none;
}
.agent-conv-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 12px 0;
}
.agent-conv-page {
  height: calc(100dvh - 315px);
  min-height: 520px;
  padding: 0;
}
.agent-scope-row.compact { margin-top: 10px; }
.agent-chip.static { cursor: default; }
.conv-list { border-right: 1px solid var(--rule); overflow: auto; min-height: 0; }
.conv-list-head { padding: 12px; border-bottom: 1px solid var(--rule); }
.conv-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px;
  cursor: pointer;
}
.conv-row:hover { background: var(--hover); }
.conv-row.active { background: var(--accent-bg); }
[data-theme="dark"] .conv-row.active { background: var(--accent-bg); }

.conv-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--ink-3); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 500;
}
.conv-name { font-weight: 500; font-size: 13.5px; color: var(--ink);}
.conv-snippet { color: var(--ink-3); font-size: 12.5px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;}
.conv-time { font-size: 11px; color: var(--ink-3); text-align: right;}
.conv-meta { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }

.conv-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conv-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
}
.conv-msgs { flex: 1; overflow: auto; padding: 20px 22px; background: var(--bg);}
.msg { max-width: 70%; margin-bottom: 12px; }
.msg.in  { margin-right: auto; }
.msg.out { margin-left: auto; }
.msg-bubble {
  padding: 9px 13px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.45;
}
.msg.out .msg-bubble {
  background: var(--accent); color: #fff; border-color: transparent;
}
.msg.system .msg-bubble {
  background: var(--surface-2);
  border: 1px dashed var(--rule-2);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11.5px;
  border-radius: 6px;
}
.msg-meta {
  font-size: 10.5px; color: var(--ink-3); margin-top: 3px;
}
.msg.out .msg-meta { text-align: right; }

.conv-composer { border-top: 1px solid var(--rule); padding: 12px 14px; background: var(--surface);}
.conv-composer textarea {
  width: 100%;
  border: 1px solid var(--rule);
  padding: 9px 12px;
  font-size: 13px;
  resize: none;
  height: 56px;
  outline: none;
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
}
.conv-composer textarea:focus { border-color: var(--accent); }
.conv-composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.agent-test-panel { overflow: hidden; }
.agent-test-redirect {
  margin: 0 14px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-3);
  font-size: 12.5px;
}
.agent-test-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  min-height: 520px;
  border-top: 1px solid var(--rule);
}
.agent-test-sessions {
  border-right: 1px solid var(--rule);
  background: var(--surface-2);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.test-session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  max-height: 410px;
}
.test-session-row {
  text-align: left;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  padding: 9px;
  display: grid;
  gap: 5px;
  cursor: pointer;
}
.test-session-row:hover,
.test-session-row.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule));
  background: var(--hover);
}
.session-title,
.session-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-title { font-weight: 700; font-size: 12.5px; }
.session-meta { color: var(--ink-3); font-size: 11.5px; }
.agent-test-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.agent-test-header { background: var(--surface); }
.agent-test-msgs { min-height: 360px; max-height: 520px; }
.agent-test-composer textarea { height: 68px; }
.agent-test-runtime {
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  background: var(--surface-2);
}
@media (max-width: 920px) {
  .agent-test-shell { grid-template-columns: 1fr; }
  .agent-test-sessions { border-right: 0; border-bottom: 1px solid var(--rule); }
  .agent-test-runtime { border-left: 0; border-top: 1px solid var(--rule); }
  .test-session-list { max-height: 220px; }
  .agent-test-redirect { align-items: stretch; flex-direction: column; }
  .table-profile-summary { grid-template-columns: 1fr 1fr; }
}

.runtime { border-left: 1px solid var(--rule); overflow-y: auto; min-height: 0; max-height: 100%; background: var(--surface-2); scrollbar-gutter: stable; overscroll-behavior: contain;}
.runtime-section { padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.runtime-section:last-child { padding-bottom: 24px; }
.rt-label { font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; font-weight: 500;}
.rt-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px;}
.rt-kv dt { color: var(--ink-3); }
.rt-kv dd { margin: 0; color: var(--ink); }
.rt-list { display: flex; flex-direction: column; gap: 6px; }
.rt-list .item {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
}
.rt-list .item .t { font-size: 11px; color: var(--ink-3); display: block; margin-bottom: 2px;}
.rt-kv.compact { grid-template-columns: minmax(82px, auto) 1fr; }
.rt-kv.compact dd { word-break: break-word; }
.runtime-objectives { display: grid; gap: 9px; }
.objective-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
}
.objective-row em {
  font-style: normal;
  color: var(--ink-3);
  font-size: 11px;
  text-align: right;
}
.objective-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: transparent;
}
.objective-dot.ok { background: var(--ok); border-color: var(--ok); }
.objective-dot.warn { background: var(--warn); border-color: var(--warn); }
.objective-dot.bad { background: var(--bad); border-color: var(--bad); }
.runtime-card,
.condition-card { line-height: 1.35; word-break: break-word; }
.condition-card { border-left: 2px solid var(--bad); }
.empty.tiny { padding: 8px 0; font-size: 12px; text-align: left; border: 0; }
.bad-text { color: var(--bad); }

/* Tickets */
.ticket-tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--ink-2);
  margin-right: 4px;
}

/* Avatar pill */
.av { display: inline-flex; align-items: center; gap: 8px; }
.av-mark {
  width: 26px; height: 26px;
  background: var(--ink-3); color: #fff;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 500;
}
.av-name { font-size: 13px; color: var(--ink); font-weight: 500;}

/* Instances */
.instance {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.instance:last-child { border-bottom: none; }
.instance-icon {
  width: 32px; height: 32px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}
.instance-name { font-weight: 500; font-size: 13px; color: var(--ink);}
.instance-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 1px;}

/* Handoff */
.handoff-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  align-items: center;
  font-size: 13px;
}
.handoff-row:last-child { border-bottom: none; }
.handoff-name { font-weight: 500; color: var(--ink);}
.handoff-reason { font-size: 11.5px; color: var(--ink-3); margin-top: 2px;}
.handoff-time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;}
.handoff-take {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink);
  border-radius: 6px;
}
.handoff-take:hover { background: var(--accent); color: #fff; border-color: transparent;}

/* Kanban mini */
.kanban-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.km-col {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px;
}
.km-col-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.km-col-head .n { font-size: 11.5px; color: var(--ink-3);}
.km-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.km-card .who {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-3); margin-bottom: 3px;
}

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  width: 34px; height: 34px;
  border-radius: 7px;
  align-items: center; justify-content: center;
  padding: 0; color: var(--ink);
}
.mobile-menu-btn span,
.mobile-menu-btn span::before,
.mobile-menu-btn span::after {
  display: block; width: 16px; height: 1.5px; background: currentColor;
}
.mobile-menu-btn span { position: relative; }
.mobile-menu-btn span::before { content: ""; position: absolute; top: -5px; left: 0; right: 0; }
.mobile-menu-btn span::after  { content: ""; position: absolute; top:  5px; left: 0; right: 0; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--accent); }

.bar {
  height: 6px;
  background: var(--hover);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar > span {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 999px;
}

/* Objectives */
.objective {
  display: grid; grid-template-columns: 16px 1fr auto; gap: 8px;
  padding: 6px 0;
  font-size: 12.5px;
}
.check {
  width: 14px; height: 14px;
  border: 1px solid var(--rule-2);
  border-radius: 50%;
  display: grid; place-items: center;
  margin-top: 2px;
}
.check.done { background: var(--ok); border-color: var(--ok); color: #fff;}
.check.active { background: var(--warn); border-color: var(--warn); color: #fff;}
.objective-status { font-size: 11px; color: var(--ink-3); }

/* ====================== Responsive ====================== */
@media (max-width: 1180px) {
  .grid-kpis { grid-template-columns: repeat(3, minmax(0, 1fr));}
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr;}
  .module-grid-2,
  .module-grid-even,
  .tables-workbench,
  .profile-workbench,
  .crm-grid { grid-template-columns: 1fr; }
  .module-grid-3,
  .module-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kanban-mini { grid-template-columns: repeat(2, minmax(0, 1fr));}
  .conv-shell { grid-template-columns: 280px 1fr; }
  .runtime { display: none;}
}

@media (max-width: 760px) {
  body { font-size: 13px; }
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 260px; height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .sidebar.open:not(.pinned) {
    overflow-y: auto;
    width: 260px;
  }
  .sidebar.open:not(.pinned) .sb-brand {
    padding: 18px 18px 14px;
    justify-content: flex-start;
  }
  .sidebar.open:not(.pinned) .sb-brand > div { display: block; }
  .sidebar.open:not(.pinned) .sb-pin-btn { display: flex; }
  .sidebar.open:not(.pinned) .sb-brand-mark {
    width: 28px;
    height: 28px;
  }
  .sidebar.open:not(.pinned) .sb-section-label {
    height: auto;
    margin: 0;
    padding: 18px 18px 6px;
    overflow: visible;
    border-top: 0;
    color: var(--sidebar-muted);
    font-size: 10.5px;
  }
  .sidebar.open:not(.pinned) .sb-nav {
    padding: 0 8px;
    gap: 1px;
    align-items: stretch;
  }
  .sidebar.open:not(.pinned) .sb-item {
    width: 100%;
    height: auto;
    padding: 7px 10px;
    justify-content: flex-start;
    gap: 10px;
    border-radius: 6px;
  }
  .sidebar.open:not(.pinned) .sb-item > span,
  .sidebar.open:not(.pinned) .sb-item .count {
    display: inline-flex !important;
  }
  .sidebar.open:not(.pinned) .sb-foot { display: flex !important; }

  .topbar { padding: 10px 14px; gap: 10px;}
  .crumbs { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar-search { display: none; }
  .topbar-actions .tb-btn:not(.primary) { display: none; }
  .topbar-actions .tb-btn.primary {
    width: 40px;
    min-width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 0;
    overflow: hidden;
  }
  .topbar-actions .tb-btn.primary svg { width: 15px; height: 15px; }

  .page { padding: 0 14px 50px; gap: 12px;}
  .page-head { grid-template-columns: 1fr; padding: 18px 14px 12px; gap: 10px;}
  .page-meta { align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 8px;}
  .page-title { font-size: 24px;}

  .grid-kpis { grid-template-columns: 1fr; gap: 8px;}
  .kpi { padding: 12px;}
  .kpi-value { font-size: 22px;}
  .kpi, .panel, .page, .page-head, .topbar, .grid-kpis, .grid-2, .grid-3 { min-width: 0; max-width: 100%; }
  .kpi-label, .kpi-value, .kpi-foot, .page-sub, .handoff-reason, .km-card { overflow-wrap: anywhere; }

  .grid-2 { grid-template-columns: 1fr;}
  .grid-3 { grid-template-columns: 1fr;}
  .module-grid-2,
  .module-grid-even,
  .module-grid-3,
  .module-grid-4,
  .tables-workbench,
  .profile-workbench,
  .crm-grid { grid-template-columns: 1fr; }
  .kanban-mini { grid-template-columns: 1fr;}

  .panel-head { padding: 12px 14px; flex-wrap: wrap;}
  .panel-actions { width: 100%; flex-wrap: wrap;}

  /* Tables → cards */
  .dt thead { display: none;}
  .dt, .dt tbody, .dt tr, .dt td { display: block; width: 100%;}
  .dt tr {
    border-bottom: 1px solid var(--rule);
    padding: 12px 14px;
  }
  .dt tr:hover td { background: transparent;}
  .dt td { padding: 3px 0; border: none;
    display: flex; justify-content: space-between; gap: 12px; align-items: center;}
  .dt td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--ink-3);
    font-weight: 500;
  }
  .dt td:first-child::before { display: none; }
  .dt td:first-child {
    padding-bottom: 8px; margin-bottom: 6px;
    border-bottom: 1px dashed var(--rule);
  }
  .dt td.num { text-align: right;}
  .actions-cell,
  .summary-cell,
  .tickets-table .summary-cell,
  .tickets-table .ticket-tags-cell { width: 100%; min-width: 0; white-space: normal; max-width: none; }
  .actions-cell .row-actions { flex-wrap: wrap; }
  .summary-text { -webkit-line-clamp: 6; }
  .agent-identity { max-width: 100%; }
  .entity-card { align-items: flex-start; flex-direction: column; }
  .detail-metrics { grid-template-columns: 1fr; }
  .module-grid-3 > .panel,
  .module-grid-4 > .panel { min-width: 0; }

  /* Conversations */
  .conv-page { height: auto; min-height: 0; overflow: visible; padding-bottom: 60px; }
  .conv-shell { grid-template-columns: 1fr; height: auto; min-height: 0; max-height: none; border: none; background: transparent;}
  .conv-list, .conv-thread, .runtime { border: none;}
  .conv-list { border: 1px solid var(--rule); border-radius: 8px; max-height: 70vh;}
  .conv-thread { border: 1px solid var(--rule); border-radius: 8px; margin-top: 12px; height: 75vh;}
  .conv-thread.mobile-hidden, .conv-list.mobile-hidden { display: none; }
  .runtime { display: none;}

  .filter-row { overflow-x: auto; padding-bottom: 4px;}
  .fp { white-space: nowrap; flex-shrink: 0;}
  .handoff-row { grid-template-columns: 1fr; align-items: start; }
  .handoff-take { justify-self: start; }

  /* Heatmap scroll */
  .hm-wrap { overflow-x: auto;}
  .hm { min-width: 600px;}
}

@media (max-width: 420px) {
  .grid-kpis { grid-template-columns: 1fr; }
  .kanban-mini { grid-template-columns: 1fr; }
}

.hidden { display: none !important; }
.empty { padding: 36px; text-align: center; color: var(--ink-3); font-size: 12.5px;}

/* ========== Backend-connected React screens ========== */
.toolbar-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.local-search { width: min(360px, 100%); margin: 0; }
.mono { font-family: var(--mono); font-size: 12px; }
.subline { display: block; margin-top: 2px; color: var(--ink-3); font-size: 11.5px; }

.table-link {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}
.table-link:hover .av-name,
.table-link:hover { color: var(--accent); }

.table-link:focus-visible,
.tb-btn:focus-visible,
.fp:focus-visible,
.soft-row:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.actions-cell {
  width: 1%;
  white-space: nowrap;
}
.actions-cell .row-actions { flex-wrap: nowrap; }

.summary-cell {
  max-width: 46ch;
  color: var(--ink-2);
}
.summary-text,
.cell-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.summary-text { -webkit-line-clamp: 4; }
.cell-preview { -webkit-line-clamp: 3; }

.tb-btn.danger {
  color: var(--bad);
  border-color: var(--bad-bg);
  background: transparent;
}
.tb-btn.danger:hover { background: var(--bad-bg); }
.tb-btn:disabled { opacity: .55; cursor: not-allowed; }

.sync-state {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 7px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.sync-state.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.toast {
  margin: 12px 24px 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
}
.toast.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.stack-list {
  padding: 12px;
  display: grid;
  gap: 8px;
}
.compact-stack { padding-top: 0; }
.sub-head {
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}
.profile-workbench {
  display: grid;
  grid-template-columns: minmax(320px, .72fr) minmax(0, 1.28fr);
  gap: 14px;
  align-items: start;
}
.profile-list-panel,
.profile-detail-panel { min-width: 0; }
.profile-detail-panel .panel-head { align-items: flex-start; }
.profile-detail-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.panel-subtitle {
  color: var(--ink);
  font-weight: 650;
  font-size: 13px;
  margin-top: 2px;
}
.compact-table .dt,
.dt.compact-table { font-size: 12px; }

.soft-row {
  width: 100%;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}
.soft-row > span:first-child,
.entity-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.soft-row strong,
.entity-title {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
}
.soft-row .badge,
.entity-card .badge { flex: 0 0 auto; }
.soft-row .subline,
.entity-sub {
  display: block;
  margin-top: 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.soft-row.selectable { cursor: pointer; }
.soft-row.selectable:hover,
.soft-row.selectable.active {
  border-color: transparent;
  background: var(--accent-bg);
}

.entity-card {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
}
.entity-card.selectable { cursor: pointer; }
.entity-card.selectable:hover,
.entity-card.selectable.active {
  background: var(--accent-bg);
  border-color: transparent;
}
.entity-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.entity-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tool-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 14px;
  gap: 14px;
}
.tool-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.metric-tile {
  min-height: 86px;
  align-content: center;
}
.metric-tile .mono,
.metric-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.metric-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
}

.tag-card {
  position: relative;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
}
.tag-card .muted {
  line-height: 1.45;
  max-width: 70ch;
}
.tag-swatch {
  width: 10px;
  height: 100%;
  min-height: 58px;
  border-radius: 999px;
}

.agent-identity {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  max-width: 54ch;
}
.identity-copy { gap: 2px; }
.identity-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}
.identity-sub {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.agents-table .spark { min-width: 86px; }
.agent-actions .tb-btn { padding-inline: 9px; }

/* ========== Agent Grid View ========== */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px;
}
.agent-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.agent-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.agent-card-head { display: flex; align-items: center; gap: 10px; }
.agent-card-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-mark.lg { width: 36px; height: 36px; font-size: 15px; flex-shrink: 0; }
.agent-card-stats { display: flex; justify-content: space-between; }
.agent-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.agent-stat-val { font-size: 15px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.agent-stat-lbl { font-size: 10.5px; color: var(--ink-3); }
.agent-card-foot { display: flex; align-items: center; justify-content: space-between; }
.agent-card-actions { display: flex; gap: 6px; border-top: 1px solid var(--rule); padding-top: 10px; }
.agent-card-actions .tb-btn { flex: 1; justify-content: center; }

/* view toggle active state */
.icon-btn.active { background: var(--accent-bg); color: var(--accent); }

.module-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, .65fr);
  gap: 14px;
}
.module-grid-even {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.module-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.module-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.channel-card-grid,
.tool-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.channel-card,
.tool-catalog-card {
  padding: 14px;
  display: grid;
  gap: 12px;
  text-align: left;
  align-content: start;
}
.channel-card-head,
.tool-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.channel-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.channel-meta div {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 8px;
  min-width: 0;
}
.channel-meta span {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
}
.channel-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-qr-inline {
  min-height: 156px;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.channel-qr-inline img {
  max-width: 148px;
  max-height: 148px;
}
.kb-test-panel {
  border-top: 1px solid var(--rule);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}
.kb-test-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.kb-test-results,
.tool-catalog-card {
  display: grid;
  gap: 10px;
}
.kb-result-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}
.kb-result-card p {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.45;
}
.compact-select {
  max-width: 220px;
}
.squad-flow {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: var(--surface);
}
.squad-node {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 3px;
  background: var(--bg);
}
.squad-node span,
.squad-node small {
  color: var(--ink-3);
  font-size: 11.5px;
}
.squad-node.manager { border-color: color-mix(in srgb, var(--accent) 38%, var(--rule)); }
.squad-node.fallback { border-style: dashed; }
.squad-members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.squad-arrow {
  color: var(--ink-3);
  font-size: 11px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.squad-checklist {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.weight-visual {
  display: grid;
  gap: 8px;
}
.weight-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.weight-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.tables-workbench {
  display: grid;
  grid-template-columns: minmax(360px, .72fr) minmax(0, 1.28fr);
  gap: 14px;
  align-items: start;
}
.table-list-panel,
.table-detail-panel { min-width: 0; }
.table-profile-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}
.table-profile-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 12px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}
.table-profile-card:hover,
.table-profile-card.active {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--rule));
  background: color-mix(in srgb, var(--accent-bg) 22%, var(--surface-2));
}
.table-profile-card span,
.table-profile-card em {
  color: var(--ink-3);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
}
.table-profile-kicker {
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  font-size: 10.5px !important;
}
.table-detail-panel .panel-head {
  align-items: flex-start;
}
.table-profile-summary {
  border-top: 1px solid var(--rule);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(110px, .5fr));
  gap: 10px;
}
.table-profile-summary div {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 10px;
  display: grid;
  gap: 4px;
}
.table-profile-summary span {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 650;
}
.table-profile-summary strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}
.table-profile-records {
  border-top: 1px solid var(--rule);
}
.table-profile-fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}
.table-profile-fullscreen .data-table-wrap {
  max-height: none;
  flex: 1;
}
.table-profile-fullscreen .data-table-wrap .dt th,
.table-profile-fullscreen .data-table-wrap .dt td {
  max-width: 520px;
}
.data-table-wrap {
  overflow: auto;
  max-height: 560px;
}
.data-table-wrap .dt {
  min-width: 980px;
}
.data-table-wrap .dt th,
.data-table-wrap .dt td {
  max-width: 240px;
}
.data-table-wrap .record-long {
  min-width: 260px;
  max-width: 360px;
}
.record-count-pill {
  color: var(--ink-3);
  font-size: 11.5px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px 7px;
}
.table-name-link {
  display: inline-flex;
  max-width: 42ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--hover);
}

.tickets-table .summary-cell { min-width: 360px; }
.tickets-table .ticket-tags-cell {
  min-width: 150px;
}
.ticket-tag {
  margin: 2px 4px 2px 0;
}
.ticket-origin,
.ticket-type {
  display: inline-flex;
  align-items: center;
  max-width: 160px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--ink-2);
  background: var(--surface);
  font-size: 11px;
  white-space: nowrap;
}

.crm-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(520px, .65fr);
}

.page-meta .row-actions { justify-content: flex-end; }

.profile-tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.profile-tab.active {
  color: var(--ink);
  font-weight: 500;
  border-bottom-color: var(--accent);
}

.form-grid {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.studio-dialog {
  max-width: 560px;
}
.confirm-dialog {
  max-width: 460px;
}
.field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}
.field-helper {
  color: var(--ink-3);
  font-size: 11.5px;
  line-height: 1.35;
}
.site-install-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.connection-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.connection-flow-note {
  margin: 0 16px;
  padding: 10px 0;
  color: var(--ink-2);
  font-size: 12px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.connections-dual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 14px;
  padding: 14px;
}
.shared-security-panel {
  margin: 0 14px 14px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
}
.shared-security-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.security-card {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
  display: grid;
  gap: 10px;
  align-content: start;
}
.security-card label {
  display: grid;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
}
.security-card input,
.security-card select,
.security-card textarea {
  width: 100%;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
}
.security-card textarea { resize: vertical; min-height: 58px; }
.security-fields { display: grid; gap: 8px; }
.checkline {
  grid-template-columns: auto 1fr !important;
  align-items: center;
  gap: 8px !important;
}
.checkline input {
  width: 14px;
  height: 14px;
  padding: 0;
}
.limit-preview {
  display: grid;
  gap: 6px;
}
.limit-preview span {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink-2);
  background: var(--surface);
  font-size: 12px;
}
.connection-section {
  min-width: 0;
}
.connection-qr-panel {
  padding: 0;
}
.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.code-input {
  min-height: 190px;
  font-family: var(--mono);
  font-size: 11.5px;
  resize: vertical;
  white-space: pre;
}
.prose-input {
  font-family: var(--ui);
  line-height: 1.55;
}

@media (max-width: 920px) {
  .connections-dual-grid {
    grid-template-columns: 1fr;
  }
  .shared-security-grid {
    grid-template-columns: 1fr;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(16px) saturate(140%);
}
.modal-backdrop.open { display: flex; }
.create-modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(86vh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule) 72%, #fff 18%);
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
}
.create-modal.wide { width: min(920px, calc(100vw - 32px)); }
.create-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, var(--hover)), var(--surface));
}
.create-title {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 650;
}
.create-sub {
  margin-top: 5px;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.4;
}
.create-body {
  padding: 18px 20px;
  display: grid;
  gap: 14px;
}
.create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.create-grid .span-2 { grid-column: 1 / -1; }
.create-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}
.fg { display: grid; gap: 6px; }
.fl {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 550;
}
.field-hint {
  color: var(--ink-3);
  font-size: 11.5px;
}
.file-input {
  padding: 9px 10px;
  height: auto;
}
.truncate-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-resource-grid,
.kb-source-composer {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, .75fr);
  gap: 12px;
}
.kb-source-composer {
  padding: 14px;
  border-bottom: 1px solid var(--rule);
}
.detail-progress {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 4px;
}
.builder-progress-track {
  height: 3px;
  background: var(--rule);
  overflow: hidden;
}
.builder-progress-track span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  transition: width .28s cubic-bezier(.16, 1, .3, 1);
}
.builder-memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.builder-memory-card {
  border: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}
.builder-memory-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-memory-name span {
  color: var(--ink-3);
  font-weight: 500;
}
.builder-memory-desc {
  color: var(--ink-3);
  font-size: 11.5px;
  margin-top: 2px;
}
.builder-stepbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 8px;
  padding: 14px 20px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}
.builder-stepbar button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-3);
  border-radius: 8px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.builder-stepbar button span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
}
.builder-stepbar button em {
  font-style: normal;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-stepbar button.done span,
.builder-stepbar button.active span {
  background: var(--accent);
  color: white;
}
.builder-stepbar button.active {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 58%, var(--rule));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.builder-kb-step {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, .75fr);
  gap: 12px;
}
.builder-kb-step .fg:first-of-type { grid-row: span 2; }
.kb-drop-card {
  grid-column: 1 / -1;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 13px 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.kb-drop-card p {
  margin: 5px 0 0;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.4;
}
.inline-error {
  border: 1px solid color-mix(in srgb, var(--bad) 48%, var(--rule));
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  color: var(--bad);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
}
.builder-working {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
}
.builder-working > span {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  animation: studio-spin .8s linear infinite;
}
.builder-working b { display: block; font-size: 12.5px; }
.builder-working em {
  display: block;
  font-style: normal;
  color: var(--ink-3);
  font-size: 11.5px;
  margin-top: 2px;
}
.success-modal {
  width: min(520px, calc(100vw - 32px));
  padding-top: 26px;
  text-align: center;
}
.success-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 999px;
  color: white;
  background: var(--ok);
}
.success-modal .create-sub {
  max-width: 420px;
  margin: 8px auto 0;
}
.success-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 18px 20px 4px;
}
.success-facts span {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink-3);
  font-size: 11.5px;
}
.success-facts b {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 2px;
}
@keyframes studio-spin {
  to { transform: rotate(360deg); }
}
.qr-modal-card { width: min(460px, calc(100vw - 32px)); }
.qr-panel {
  padding: 20px;
  display: grid;
  gap: 14px;
}
.qrbox {
  min-height: 320px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px;
}
.qrbox img {
  width: min(300px, 76vw);
  height: auto;
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
}
.qr-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-3);
  font-size: 12.5px;
}
.qr-status.bad { color: var(--bad); }
.qr-help {
  border: 1px solid var(--rule);
  background: var(--surface-2);
  color: var(--ink-3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
}

.tb-btn.icon-danger,
.tb-btn.danger {
  border-color: color-mix(in srgb, var(--bad) 30%, var(--rule));
  color: var(--bad);
  background: color-mix(in srgb, var(--bad-bg) 45%, transparent);
}
.tb-btn.icon-danger:hover,
.tb-btn.danger:hover {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}

.switch-btn {
  width: 34px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: var(--rule-2);
  padding: 2px;
  position: relative;
}
.switch-btn span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
}
.switch-btn span.on {
  transform: translateX(14px);
  background: #fff;
}
.switch-btn[data-on="true"] { background: var(--accent); }
.switch-btn:has(span.on) { background: var(--accent); }

.data-table-wrap {
  overflow: auto;
  max-height: 560px;
}

.agent-scope-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}
.agent-chip {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 8px;
  min-height: 42px;
  padding: 7px 8px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}
.agent-chip span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-chip b {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
}
.agent-chip.active {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--rule));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--ink);
}

/* ========== Guided setup and design system components ========== */
.tooltip[data-tip] {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: help;
}
.tooltip[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: max-content;
  max-width: min(280px, calc(100vw - 40px));
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--duration-fast) var(--ease-default), transform var(--duration-fast) var(--ease-default);
}
.tooltip[data-tip]:hover::after,
.tooltip[data-tip]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.pill,
.b-g,
.b-y,
.b-r,
.b-0 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.pill-sm { min-height: 18px; padding: 2px 7px; font-size: 10.5px; }
.pill-ok,
.b-g { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.pill-warn,
.b-y { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.pill-bad,
.pill-err,
.b-r { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.pill-muted,
.b-0 { background: var(--hover); color: var(--ink-3); border-color: var(--rule); }
.pill-accent { background: var(--accent-bg); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
[data-theme="dark"] .pill-accent { color: var(--accent); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.banner-info { background: color-mix(in srgb, var(--accent-bg) 42%, var(--surface)); }
.banner-warn { background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface)); }
.banner-title { font-weight: 650; color: var(--ink); }
.banner-body { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }

.progress {
  height: 7px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--hover);
  border: 1px solid var(--rule);
}
.progress > span,
.progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--duration-medium) var(--ease-default);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}
.step {
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-3);
  border-radius: 8px;
  padding: 9px 6px;
  font-size: 11.5px;
}
.step:hover { background: var(--hover); }
.step.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, var(--rule)); background: color-mix(in srgb, var(--ok-bg) 55%, var(--surface)); }
.step.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 44%, var(--rule)); }
.step-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--rule-2);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.step.done .step-dot { background: var(--ok); }
.step.active .step-dot { background: var(--accent); }

.checklist {
  display: grid;
  gap: 7px;
}
.check-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  text-align: left;
  padding: 7px 9px;
}
.check-item:hover { background: var(--hover); }
.check-item.done { color: var(--ok); background: color-mix(in srgb, var(--ok-bg) 46%, var(--surface)); }
.check-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--rule-2);
  background: var(--surface);
}
.check-item.done .check-dot { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--ok-bg); }

.help-card {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px;
  color: var(--ink-2);
}
.help-card-title { font-size: 12px; font-weight: 650; color: var(--ink); margin-bottom: 5px; }
.help-card-body { color: var(--ink-3); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; }

.skel,
.skel-line,
.skel-card {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--hover);
}
.skel::after,
.skel-line::after,
.skel-card::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: skel-shimmer 1.3s infinite;
}
.skel-line { height: 12px; }
.skel-card { min-height: 110px; border: 1px solid var(--rule); }
@keyframes skel-shimmer { to { transform: translateX(100%); } }

.empty-cta {
  border: 1px dashed var(--rule-2);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 24px;
  text-align: center;
  color: var(--ink-3);
}
.empty-cta .tb-btn { margin-top: 12px; }

.fl-required::after,
.field-label.fl-required::after {
  content: " *";
  color: var(--bad);
}
.fc-error,
.input.fc-error {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad-bg) 45%, var(--surface));
}
.inline-help,
.field-helper {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
}

.setup-page {
  display: grid;
  gap: 14px;
}
/* Setup hero strip */
.setup-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.setup-hero.ok { border-left: 4px solid var(--ok); }
.setup-hero.warn { border-left: 4px solid var(--warn); }
.setup-hero.bad { border-left: 4px solid var(--bad); }
.setup-hero.accent { border-left: 4px solid var(--accent); }
.setup-hero-left { display: flex; align-items: center; gap: 16px; }
.setup-hero-pct { font-size: 32px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; min-width: 56px; }
.setup-hero-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.setup-hero-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.setup-hero-bar { height: 6px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.setup-hero-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.setup-hero-actions { display: flex; gap: 8px; }

/* Setup steps rail */
.setup-steps-rail { display: grid; gap: 6px; }
.setup-step-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.setup-step-row:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-bg) 25%, var(--surface)); }
.setup-step-row.done { border-color: color-mix(in srgb, var(--ok) 28%, var(--rule)); }
.setup-step-row.done .setup-step-num { background: var(--ok); color: #fff; }
.setup-step-row.current { border-color: var(--accent); border-width: 1.5px; }
.setup-step-row.current .setup-step-num { background: var(--accent); color: #fff; }
.setup-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--rule);
  color: var(--ink-3);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .12s;
}
.setup-step-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.setup-step-desc { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; }

/* Sandbox response */
.sandbox-response {
  margin: 0 12px 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.sandbox-response-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; }
.sandbox-response-body { font-size: 13.5px; color: var(--ink); white-space: pre-wrap; line-height: 1.5; }
.sandbox-kb-badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 11px; color: var(--accent); }

/* Setup blockers panel */
.setup-blockers-panel .panel-head { display: flex; align-items: center; justify-content: space-between; }
.blocker { display: flex; align-items: flex-start; gap: 8px; }
.blocker-icon { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.blocker.required .blocker-icon { background: var(--bad-bg); color: var(--bad); }
.blocker .blocker-icon { background: var(--warn-bg); color: var(--warn); }

.setup-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
.setup-workbench-single {
  grid-template-columns: 1fr;
}
.setup-main,
.setup-side {
  display: grid;
  gap: 14px;
}
.setup-side {
  position: sticky;
  top: 78px;
}
.setup-blockers-banner {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px;
  background:color-mix(in srgb, var(--warn-bg) 60%, var(--surface));
  border:1px solid color-mix(in srgb, var(--warn) 22%, var(--rule));
  border-radius:var(--radius); padding:10px 14px;
}
.setup-blockers-banner .blocker { font-size:12.5px; }
.setup-step-blockers { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.setup-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}
.setup-stage-card {
  display: grid;
  gap: 7px;
  min-height: 118px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  padding: 12px;
  color: var(--ink-2);
}
.setup-stage-card:hover { border-color: color-mix(in srgb, var(--accent) 34%, var(--rule)); background: color-mix(in srgb, var(--accent-bg) 20%, var(--surface)); }
.setup-stage-card.done { border-color: color-mix(in srgb, var(--ok) 24%, var(--rule)); }
.setup-stage-card.active { border-color: color-mix(in srgb, var(--accent) 44%, var(--rule)); background: color-mix(in srgb, var(--accent-bg) 28%, var(--surface)); }
.setup-stage-card strong { color: var(--ink); }
.setup-stage-card span:last-child { color: var(--ink-3); font-size: 12px; line-height: 1.4; }
.sandbox-mini {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
}
.setup-blockers {
  display: grid;
  gap: 7px;
  padding: 12px;
}
.blocker {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--warn);
  text-align: left;
  padding: 8px 10px;
  font-size: 12.5px;
}
.blocker.required {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 30%, var(--rule));
  background: color-mix(in srgb, var(--bad-bg) 40%, var(--surface));
}
.publish-actions {
  display: grid;
  gap: 8px;
}
.publish-actions .tb-btn {
  justify-content: center;
}
.next-steps {
  display: grid;
  gap: 8px;
  padding: 18px 20px 4px;
}
.next-steps button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  padding: 11px;
  text-align: left;
}
.next-steps button:hover { background: var(--hover); }
.next-steps .pill { grid-row: span 2; }
.next-steps small { color: var(--ink-3); }
.qr-progress { margin-top: -6px; }
.qr-progress > span { background: var(--warn); }
.qr-success {
  display: grid;
  place-items: center;
  gap: 6px;
  color: var(--ink-3);
  text-align: center;
}
.qr-success strong { color: var(--ok); }
.qr-status.ok { color: var(--ok); }

.assistants-page { display: grid; gap: 14px; }
.assistant-control,
.assistant-side { display: grid; gap: 12px; }
.assistant-chat { min-height: 620px; display: flex; flex-direction: column; min-width: 0; }
.assistant-messages { flex: 1; min-height: 360px; max-height: 520px; overflow-y: auto; padding: 14px; }
.assistant-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--rule);
}
.assistant-composer textarea {
  min-height: 62px;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
}
.assistant-report { display: grid; gap: 14px; min-width: 0; }
.report-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.assistant-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.report-list {
  display: grid;
  gap: 7px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}
.report-list .item {
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 8px 9px;
  background: var(--surface);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.patch-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
}
.patch-card input { margin-top: 3px; }
.patch-card pre {
  margin: 8px 0 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .setup-workbench { grid-template-columns: 1fr; }
  .setup-side { position: static; }
  .report-head { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .banner { align-items: flex-start; flex-direction: column; }
  .steps { grid-template-columns: 1fr 1fr; }
  .setup-stage-grid,
  .sandbox-mini { grid-template-columns: 1fr; }
  .sandbox-mini .tb-btn { justify-content: center; }
  .assistant-report-grid { grid-template-columns: 1fr; }
  .assistant-composer { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .toast { margin: 10px 14px 0; }
  .row-actions { justify-content: flex-start; }
  .soft-row { align-items: flex-start; flex-direction: column; }
  .table-profile-summary { grid-template-columns: 1fr; }
  .tag-card { grid-template-columns: 8px 1fr; }
  .tag-card .tb-btn { grid-column: 2; justify-self: start; }
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .create-modal,
  .create-modal.wide,
  .qr-modal-card {
    width: 100%;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
  }
  .create-grid,
  .builder-memory-grid,
  .builder-resource-grid,
  .builder-kb-step,
  .kb-source-composer,
  .success-facts { grid-template-columns: 1fr; }
  .create-actions { flex-wrap: wrap; justify-content: stretch; }
  .create-actions .tb-btn { flex: 1 1 auto; justify-content: center; }
}

/* Guided ecosystem and assistant redesign */
.ecosystem-redesign,
.assistants-redesign { gap: 16px; }
.assistant-command-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}
.assistant-command-copy,
.ecosystem-recommendations,
.assistant-feature-panel {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.assistant-command-copy {
  padding: 18px 22px;
  display: grid;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.assistant-command-copy:after {
  content: "";
  position: absolute;
  right: -120px;
  top: -120px;
  width: 260px;
  height: 260px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  pointer-events: none;
}
.command-kicker,
.assistant-command-copy > span,
.global-guide-kicker {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 650;
}
.assistant-command-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}
.assistant-command-copy p {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-3);
  line-height: 1.55;
}
.ecosystem-progress-line {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.ecosystem-progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .45s var(--ease-default);
}
.ecosystem-recommendations { padding: 16px; }
.recommendation-list { display: grid; gap: 8px; }
.recommendation-row {
  display: grid;
  grid-template-columns: auto 110px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 10px;
  color: var(--ink);
  text-align: left;
  transition: transform .2s var(--ease-default), background .2s var(--ease-default);
}
.recommendation-row:hover,
.assistant-switch-card:hover { transform: translateY(-2px); }
.recommendation-number,
.assistant-switch-index {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
}
.recommendation-row strong { font-size: 12.5px; }
.recommendation-row p {
  margin: 0;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.45;
}
.recommendation-row em {
  color: var(--ink-3);
  font-size: 11px;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.recommendation-row.warning { border-color: color-mix(in srgb, var(--warn) 32%, var(--rule)); }
.recommendation-row.success { border-color: color-mix(in srgb, var(--ok) 32%, var(--rule)); }
.ecosystem-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .75fr);
  gap: 14px;
  align-items: stretch;
}
.ecosystem-overview-copy,
.ecosystem-overview-metrics,
.ecosystem-empty-state,
.ecosystem-agent-board {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.ecosystem-overview-copy {
  padding: 22px;
  display: grid;
  gap: 14px;
}
.ecosystem-overview-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.06;
}
.ecosystem-overview-copy p {
  margin: 0;
  max-width: 76ch;
  color: var(--ink-3);
  line-height: 1.55;
}
.ecosystem-overview-metrics {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ecosystem-overview-metrics div,
.eco-health-grid div {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 11px;
}
.ecosystem-overview-metrics span,
.eco-health-grid span {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ecosystem-overview-metrics strong,
.eco-health-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1.25;
}
.eco-health-grid strong.ok { color: var(--ok); }
.eco-health-grid strong.warn { color: var(--warn); }
.eco-health-grid strong.bad { color: var(--bad); }
.ecosystem-empty-state {
  min-height: 300px;
  padding: 34px 20px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}
.ecosystem-empty-state p {
  margin: 0;
  max-width: 560px;
  color: var(--ink-3);
  line-height: 1.55;
}
.ecosystem-agent-map { display: grid; gap: 14px; }
.ecosystem-agent-board {
  padding: 16px;
  display: grid;
  gap: 14px;
  animation: soft-rise .28s var(--ease-default) both;
}
.eco-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eco-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.eco-board-lanes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.eco-board-lanes > div { display: grid; gap: 7px; align-content: start; }
.eco-mini-row {
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
  display: grid;
  gap: 2px;
  transition: border-color .15s var(--ease-default), transform .15s var(--ease-default);
}
.eco-mini-row:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--rule));
  transform: translateY(-1px);
}
.eco-mini-row strong { font-size: 12.5px; }
.eco-mini-row em {
  color: var(--ink-3);
  font-style: normal;
  font-size: 11.5px;
}
.eco-mini-row.muted-row { color: var(--ink-3); }
.eco-mini-row.warn-row { border-color: color-mix(in srgb, var(--warn) 28%, var(--rule)); }
.eco-mini-row.ok-row { border-color: color-mix(in srgb, var(--ok) 28%, var(--rule)); color: var(--ok); }
.assistant-error-card {
  border: 1px solid color-mix(in srgb, var(--bad) 28%, var(--rule));
  border-radius: 10px;
  background: var(--bad-bg);
  color: var(--bad);
  padding: 12px 14px;
  display: grid;
  gap: 3px;
}
.assistant-error-card span {
  color: color-mix(in srgb, var(--bad) 72%, var(--ink-3));
  font-size: 12px;
}
.assistant-switchboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.assistant-switch-card {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 16px 18px;
  min-height: 118px;
  text-align: left;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "idx title"
    "idx status"
    "idx copy";
  column-gap: 14px;
  row-gap: 6px;
  transition: transform .2s var(--ease-default), border-color .2s var(--ease-default), background .2s var(--ease-default);
}
.assistant-switch-card.active {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--rule));
  background: color-mix(in srgb, var(--accent-bg) 36%, var(--surface));
}
.assistant-switch-card strong { font-size: 14px; }
.assistant-switch-card .assistant-switch-index { grid-area: idx; }
.assistant-switch-card strong { grid-area: title; align-self:end; }
.assistant-switch-card em { grid-area: status; }
.assistant-switch-card p { grid-area: copy; }
.assistant-switch-card em {
  color: var(--accent);
  font-style: normal;
  font-size: 11.5px;
  font-weight: 650;
}
.assistant-switch-card p {
  margin: 0;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.4;
}
.assistant-stage {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.optimizer-stage {
  grid-template-columns: minmax(0, 1fr);
}
.optimizer-stage .optimizer-steps-bar { grid-column: 1; }
.optimizer-stage .assistant-control,
.optimizer-stage .assistant-report { grid-column: 1; }
.assistant-stage.guide-layout { grid-template-columns: minmax(0, 1fr) 300px; }
.assistant-feature-panel {
  padding: 14px;
}
.assistant-left-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.assistant-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.assistant-stage .assistant-chat {
  min-height: 640px;
  display: flex;
  flex-direction: column;
}
.assistant-empty-state {
  min-height: 220px;
  border: 1px dashed var(--rule);
  border-radius: 12px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--ink-3);
  padding: 24px;
}
.assistant-empty-state strong {
  color: var(--ink);
  font-size: 16px;
}

.global-guide {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
}
.guide-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 580;
}
.global-guide-panel {
  position: fixed;
  right: 22px;
  top: 68px;
  width: min(420px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 88px));
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  overflow: hidden;
  z-index: 30;
  animation: slideUp .18s ease;
}
.global-guide-head {
  padding: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--rule);
}
.global-guide-head strong {
  display: block;
  margin-top: 3px;
}
.global-guide-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.global-guide-messages {
  padding: 14px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}
.guide-message {
  display: grid;
  gap: 4px;
  max-width: 86%;
}
.guide-message.user {
  justify-self: end;
}
.guide-message span {
  color: var(--ink-3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.guide-message > p,
.guide-message-content {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 11px;
  font-size: 12.5px;
  line-height: 1.45;
}
.guide-message.user > p {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.guide-message-content {
  display: grid;
  gap: 8px;
  overflow-wrap: anywhere;
}
.guide-message-content p {
  margin: 0;
}
.guide-message-content strong {
  font-weight: 750;
  color: var(--ink);
}
.guide-message-content ol,
.guide-message-content ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}
.guide-message-content li {
  padding-left: 2px;
}
.guide-message-content li::marker {
  color: var(--ink-3);
  font-weight: 700;
}
.guide-inline-error { margin: 10px 14px 0; }
.global-guide-prompts {
  padding:10px 14px 0;
  display:flex;
  gap:7px;
  flex-wrap:wrap;
}
.guide-prompt-chip {
  border:1px solid var(--rule);
  background:color-mix(in srgb, var(--accent-bg) 34%, var(--surface));
  color:var(--ink-2);
  border-radius:999px;
  padding:6px 9px;
  font-size:11.5px;
  line-height:1.2;
  cursor:pointer;
  transition:transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}
.guide-prompt-chip:hover:not(:disabled) {
  transform:translateY(-1px);
  border-color:color-mix(in srgb, var(--accent) 42%, var(--rule));
  color:var(--accent);
}
.guide-prompt-chip:disabled { opacity:.55; cursor:not-allowed; }
.guide-typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.guide-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: typDotGuide 1.3s infinite ease-in-out; }
.guide-typing span:nth-child(2) { animation-delay: .18s; }
.guide-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typDotGuide { 0%,80%,100%{transform:scale(0);opacity:.4}40%{transform:scale(1);opacity:1} }
.global-guide-compose {
  border-top: 1px solid var(--rule);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}
.global-guide-compose .tb-btn {
  height: 42px;
  min-height: 42px;
  padding: 0 14px;
  align-self: end;
}
.global-guide-compose textarea {
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--ink);
}

.agent-auto-test {
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--rule));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent-bg) 26%, var(--surface));
  padding: 14px;
  display: grid;
  gap: 12px;
}
.agent-auto-copy {
  display: grid;
  gap: 4px;
}
.agent-auto-copy span {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 650;
}
.agent-auto-copy strong {
  color: var(--ink);
  font-size: 16px;
}
.agent-auto-copy p {
  margin: 0;
  color: var(--ink-3);
  line-height: 1.45;
}
.agent-auto-controls {
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.agent-auto-error {
  margin: 0;
}
.agent-auto-report {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  display: grid;
  gap: 12px;
}
.agent-auto-score {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.agent-auto-score small {
  display: block;
  color: var(--ink-3);
  margin-top: 3px;
}
.agent-auto-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.agent-auto-list {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
  display: grid;
  gap: 7px;
}
.agent-auto-list span {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 650;
}
.agent-auto-list p {
  margin: 0;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.4;
}
.agent-auto-optimizer {
  border: 1px solid color-mix(in srgb, var(--ok) 28%, var(--rule));
  border-radius: 10px;
  background: color-mix(in srgb, var(--ok-bg) 42%, var(--surface));
  padding: 10px;
  display: grid;
  gap: 4px;
}
.agent-auto-optimizer span {
  color: var(--ink-3);
  font-size: 12.5px;
}

@keyframes soft-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes status-breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 20%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
}

@media (max-width: 980px) {
  .ecosystem-overview,
  .assistant-command-center,
  .assistant-stage,
  .assistant-stage.guide-layout {
    grid-template-columns: 1fr;
  }
  .assistant-switchboard,
  .eco-board-lanes,
  .agent-auto-columns {
    grid-template-columns: 1fr;
  }
  .agent-auto-controls {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .ecosystem-overview-metrics,
  .eco-health-grid {
    grid-template-columns: 1fr;
  }
  .recommendation-row,
  .agent-auto-score {
    grid-template-columns: 1fr;
  }
  .global-guide {
    right: 14px;
    bottom: 14px;
  }
  .global-guide-panel {
    width: calc(100vw - 28px);
    right: 14px;
    top: 60px;
    max-height: calc(100vh - 80px);
  }
  .global-guide-head,
  .global-guide-compose {
    grid-template-columns: 1fr;
  }
  .global-guide-compose {
    display: grid;
  }
  .global-guide-compose .tb-btn {
    width: 100%;
  }
  .topbar-actions .guide-topbar-btn {
    display: inline-flex;
    width: 40px;
    font-size: 0;
    padding: 0;
    justify-content: center;
  }
  .topbar-actions .guide-topbar-btn svg { margin: 0; }
  .public-test-actions {
    justify-content: flex-start;
  }
}

/* Ecosystem agent identity */
.eco-agent-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.eco-agent-info {
  display: grid;
  gap: 2px;
  overflow: hidden;
}
.eco-agent-info strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eco-agent-info span {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-test-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.public-link-hint {
  max-width: 360px;
  border: 1px solid color-mix(in srgb, var(--warn) 32%, var(--rule));
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.35;
}
.public-link-hint code {
  font-family: var(--mono);
  font-size: 11px;
}

/* Guide topbar active state */
.guide-topbar-btn:has(+ .global-guide-panel),
.guide-topbar-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* =========================================================
   Phase 0 — Reusable Components
   ========================================================= */

/* --- ThinkingAnimation --- */
@keyframes thinkDotBounce {
  0%,80%,100% { transform: translateY(0); opacity:.4 }
  40% { transform: translateY(-5px); opacity:1 }
}
.thinking-dots { display:inline-flex; gap:4px; align-items:center; padding:6px 0; }
.thinking-dots span {
  width:6px; height:6px; border-radius:50%;
  background: var(--ink-3);
  animation: thinkDotBounce .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay:.15s }
.thinking-dots span:nth-child(3) { animation-delay:.3s }
.thinking-dots-label { font-size:12px; color:var(--ink-3); margin-right:6px; }
.thinking-steps { display:flex; flex-direction:column; gap:6px; padding:10px 0; }
.thinking-step {
  display:flex; align-items:center; gap:8px;
  font-size:13px; color:var(--ink-3);
  transition: color .2s, opacity .2s;
}
.thinking-step.active { color:var(--ink); font-weight:500; }
.thinking-step.done { color:var(--ok); }
.thinking-step-icon {
  width:18px; height:18px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--hover); flex:0 0 auto;
  font-size:10px; transition: background .2s;
}
.thinking-step.done .thinking-step-icon { background:var(--ok-bg); color:var(--ok); }
.thinking-step.active .thinking-step-icon { background:var(--accent-bg); color:var(--accent); }
.thinking-dot-pulse {
  width:5px; height:5px; border-radius:50%;
  background:var(--ink-3);
  animation: thinkDotBounce .9s ease-in-out infinite;
}
.thinking-inline { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--ink-3); }

/* --- StepIndicator --- */
.step-indicator { display:flex; align-items:center; gap:0; padding:8px 0; }
.step-indicator.vertical { flex-direction:column; align-items:flex-start; }
.step-node {
  width:28px; height:28px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:600;
  background:var(--hover); color:var(--ink-3);
  border:2px solid var(--rule);
  flex:0 0 auto; transition: all .2s;
}
.step-node.done { background:var(--ok-bg); color:var(--ok); border-color:var(--ok); }
.step-node.active { background:var(--accent-bg); color:var(--accent); border-color:var(--accent); }
.step-connector { flex:1; height:2px; min-width:24px; background:var(--rule); }
.step-indicator.vertical .step-connector { width:2px; height:16px; min-width:0; margin-left:13px; }
.step-node.compact { width:22px; height:22px; font-size:10px; }
.step-label { font-size:11px; color:var(--ink-3); margin-top:4px; text-align:center; max-width:80px; }
.step-node.done + .step-connector,
.step-node.active + .step-connector { background:var(--accent); }

/* --- SkeletonLoader --- */
@keyframes shimmer {
  0% { background-position:-200px 0 }
  100% { background-position:calc(200px + 100%) 0 }
}
.skeleton { display:flex; flex-direction:column; gap:10px; padding:8px 0; }
.skeleton-line {
  height:12px; border-radius:6px;
  background: linear-gradient(90deg, var(--hover) 25%, var(--rule) 37%, var(--hover) 63%);
  background-size:200px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-line:nth-child(odd) { width:90% }
.skeleton-line:nth-child(even) { width:70% }
.skeleton-line:last-child { width:45% }
.skeleton-card {
  height:80px; border-radius:var(--radius);
  background: linear-gradient(90deg, var(--hover) 25%, var(--rule) 37%, var(--hover) 63%);
  background-size:400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-chat { display:flex; flex-direction:column; gap:12px; }
.skeleton-bubble {
  border-radius:12px; padding:12px 16px; max-width:70%;
  background: linear-gradient(90deg, var(--hover) 25%, var(--rule) 37%, var(--hover) 63%);
  background-size:400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-bubble.left { height:48px; align-self:flex-start; width:60%; }
.skeleton-bubble.right { height:36px; align-self:flex-end; width:50%; }

/* --- EmptyState --- */
.ui-empty-state {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:40px 24px; gap:12px; color:var(--ink-3);
}
.ui-empty-state-icon { font-size:28px; opacity:.5; }
.ui-empty-state-title { font-size:15px; font-weight:600; color:var(--ink-2); }
.ui-empty-state-desc { font-size:13px; max-width:340px; line-height:1.5; }

/* --- ErrorState --- */
.ui-error-state {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:32px 24px; gap:10px;
  background:var(--bad-bg); border:1px solid color-mix(in srgb, var(--bad) 20%, var(--rule));
  border-radius:var(--radius); color:var(--bad);
}
.ui-error-state-msg { font-size:14px; font-weight:500; }
.ui-error-state-detail { font-size:12px; opacity:.8; max-width:360px; }
.ui-error-state button { margin-top:4px; }

/* --- ChatBubble --- */
.chat-bubble {
  display:flex; gap:10px; padding:8px 0;
  animation: chatBubbleIn .25s ease-out both;
}
@keyframes chatBubbleIn {
  from { opacity:0; transform:translateY(6px) }
  to { opacity:1; transform:translateY(0) }
}
.chat-bubble-avatar {
  width:28px; height:28px; border-radius:50%;
  background:var(--hover); display:flex; align-items:center; justify-content:center;
  font-size:12px; flex:0 0 auto; color:var(--ink-3);
}
.chat-bubble-body {
  background:var(--surface-2); border:1px solid var(--rule);
  border-radius:12px 12px 12px 4px; padding:10px 14px;
  max-width:72%; min-width:120px;
}
.chat-bubble-role { font-size:11px; font-weight:500; color:var(--ink-3); margin-bottom:3px; }
.chat-bubble-text { font-size:13.5px; line-height:1.55; color:var(--ink); white-space:pre-wrap; }
.chat-bubble-footer { display:flex; gap:8px; margin-top:6px; font-size:11px; color:var(--ink-4); }

.chat-bubble-tester .chat-bubble-body {
  background:color-mix(in srgb, var(--accent-bg) 60%, var(--surface));
  border-color:color-mix(in srgb, var(--accent) 18%, var(--rule));
  border-radius:12px 12px 4px 12px;
}
.chat-bubble-tester .chat-bubble-role { color:var(--accent); }
.chat-bubble-tester { flex-direction:row-reverse; }

.chat-bubble-agent .chat-bubble-body { background:var(--surface); }

.chat-bubble-system .chat-bubble-body {
  background:var(--hover); border-style:dashed;
  text-align:center; max-width:100%; border-radius:8px;
}
.chat-bubble-system .chat-bubble-role { display:none; }
.chat-bubble-system .chat-bubble-text { font-size:12px; color:var(--ink-3); }

.chat-bubble-user .chat-bubble-body {
  background:color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-radius:12px 12px 4px 12px;
}
.chat-bubble-user { flex-direction:row-reverse; }

/* --- ScoreRing --- */
.score-ring { display:block; }

/* --- Tester Conversation View --- */
.tester-score-header {
  display:flex; align-items:center; gap:16px; padding:16px 0;
  border-bottom:1px solid var(--rule); margin-bottom:16px;
}
.tester-score-header .panel-title { margin-bottom:2px; }
.tester-score-header .tb-btn { margin-left:auto; flex:0 0 auto; }
.tester-conversation { padding:8px 0 16px; }
.tester-conversation .rt-label { margin-bottom:12px; }
.tester-round { margin-bottom:20px; padding-bottom:16px; border-bottom:1px solid var(--rule); }
.tester-round:last-child { border-bottom:none; margin-bottom:0; }
.tester-round-header {
  display:flex; align-items:center; gap:8px; margin-bottom:8px; font-size:12px;
}
.tester-round-label { font-weight:600; color:var(--ink-2); }
.tester-round-name { color:var(--ink-3); }
.tester-round-context {
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(220px, 320px);
  gap:12px;
  align-items:start;
}
.tester-round-context > div,
.tester-agent-response {
  display:grid;
  gap:8px;
}
.tester-round-context span,
.tester-agent-response > span {
  color:var(--ink-3);
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.tester-round-context .chat-bubble-tester {
  padding-top:0;
}
.tester-expectation {
  border:1px solid var(--rule);
  border-radius:10px;
  background:var(--surface-2);
  padding:11px 12px;
}
.tester-expectation p {
  margin:0;
  color:var(--ink-2);
  font-size:12.5px;
  line-height:1.5;
}
.tester-agent-response {
  margin-top:10px;
}
.tester-conversation .chat-bubble-body {
  max-width:min(860px, 78%);
}
.tester-criteria {
  display:flex; flex-wrap:wrap; gap:6px; padding:12px 0;
  border-top:1px solid var(--rule); border-bottom:1px solid var(--rule); margin:8px 0 16px;
}
.tester-criteria .pill {
  display:inline-flex;
  align-items:center;
  min-height:28px;
  white-space:normal;
  overflow-wrap:anywhere;
  line-height:1.25;
}
.tester-history-card {
  border:1px solid var(--rule);
  border-radius:12px;
  background:var(--surface);
  overflow:hidden;
}
.tester-history-head {
  width:100%;
  border:0;
  background:transparent;
  color:var(--ink);
  padding:12px 13px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  cursor:pointer;
}
.tester-history-title {
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-weight:750;
  font-size:13px;
}
.tester-history-count {
  min-width:28px;
  height:24px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:var(--surface-2);
  border:1px solid var(--rule);
  color:var(--ink-3);
  font-family:var(--mono);
  font-size:11px;
}
.tester-history-body {
  border-top:1px solid var(--rule);
  padding:10px;
  display:grid;
  gap:9px;
}
.tester-history-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  color:var(--ink-3);
  font-size:11.5px;
}
.tester-history-list {
  display:grid;
  gap:7px;
  max-height:360px;
  overflow:auto;
  padding-right:2px;
}
.tester-history-row {
  border:1px solid var(--rule);
  border-radius:9px;
  background:color-mix(in srgb, var(--surface-2) 62%, var(--surface));
  color:var(--ink);
  padding:10px;
  display:grid;
  gap:5px;
  text-align:left;
  transition:border-color .15s var(--ease-default), transform .15s var(--ease-default), background .15s var(--ease-default);
}
.tester-history-row:hover {
  border-color:color-mix(in srgb, var(--accent) 36%, var(--rule));
  background:var(--hover);
  transform:translateY(-1px);
}
.tester-history-row-top,
.tester-history-row-meta {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.tester-history-row-top strong,
.tester-history-row-preview,
.tester-history-row-result {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.tester-history-row-top strong { font-size:12.5px; }
.tester-history-row-meta,
.tester-history-row-preview {
  color:var(--ink-3);
  font-size:11.5px;
}
.tester-history-row-result {
  color:var(--ink-2);
  font-size:12px;
  font-weight:650;
}
.tester-history-row-actions {
  display:flex;
  justify-content:flex-end;
  margin-top:2px;
}
.tester-history-more { width:100%; justify-content:center; }
.tester-history-modal {
  width:min(1040px, calc(100vw - 32px));
  max-height:min(820px, calc(100vh - 32px));
  border:1px solid var(--rule);
  border-radius:16px;
  background:var(--surface);
  box-shadow:var(--shadow-lg);
  overflow:hidden;
  display:grid;
  grid-template-rows:auto minmax(0, 1fr);
}
.tester-history-modal-head {
  padding:16px;
  border-bottom:1px solid var(--rule);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
.tester-history-detail-grid {
  min-height:0;
  display:grid;
  grid-template-columns:260px minmax(0, 1fr);
}
.tester-history-detail-side {
  border-right:1px solid var(--rule);
  background:var(--surface-2);
  padding:16px;
  display:grid;
  align-content:start;
  gap:14px;
  overflow:auto;
}
.tester-history-objective,
.tester-history-metadata,
.tester-history-summary {
  border:1px solid var(--rule);
  border-radius:10px;
  background:var(--surface);
  padding:11px 12px;
}
.tester-history-objective span,
.tester-history-metadata > span,
.tester-history-summary span {
  display:block;
  margin-bottom:5px;
  color:var(--ink-3);
  font-size:11px;
  font-weight:750;
  text-transform:uppercase;
  letter-spacing:.05em;
}
.tester-history-metadata .rt-kv { margin:0; }
.tester-history-objective p,
.tester-history-summary p {
  margin:0;
  color:var(--ink-2);
  font-size:12.5px;
  line-height:1.5;
}
.tester-history-detail-main {
  min-width:0;
  overflow:auto;
  padding:16px;
  display:grid;
  align-content:start;
  gap:14px;
}
.tester-history-transcript {
  display:grid;
  gap:10px;
}
.report-overview-grid {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap:12px;
  margin:14px 0 16px;
}
.report-metric {
  min-width:0;
  border:1px solid var(--rule);
  border-radius:12px;
  background:var(--surface);
  padding:14px;
  display:grid;
  gap:5px;
  position:relative;
  overflow:hidden;
}
.report-metric::before {
  content:"";
  position:absolute;
  inset:0 auto 0 0;
  width:4px;
  background:var(--accent);
}
.report-metric span {
  color:var(--ink-3);
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.06em;
  font-weight:700;
}
.report-metric strong {
  color:var(--ink);
  font-size:22px;
  line-height:1.1;
}
.report-metric em {
  color:var(--ink-3);
  font-style:normal;
  font-size:12px;
  line-height:1.35;
}
.report-metric.positive::before { background:var(--ok); }
.report-metric.warn::before { background:var(--warn); }
.report-metric.risk::before { background:var(--bad); }
.report-metric.improvement::before { background:var(--accent); }
.report-metric.scenario::before { background:#8b5cf6; }
.report-dashboard-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap:14px;
  align-items:start;
}
.report-section {
  min-width:0;
  border:1px solid var(--rule);
  border-radius:12px;
  background:var(--surface);
  padding:14px;
  display:grid;
  gap:12px;
  box-shadow:0 10px 26px rgba(15,23,42,.04);
}
.report-section.positive,
.report-section.preserve {
  border-color:color-mix(in srgb, var(--ok) 22%, var(--rule));
  background:color-mix(in srgb, var(--ok) 6%, var(--surface));
}
.report-section.risk {
  border-color:color-mix(in srgb, var(--bad) 24%, var(--rule));
  background:color-mix(in srgb, var(--bad) 6%, var(--surface));
}
.report-section.improvement,
.report-section.next {
  border-color:color-mix(in srgb, var(--accent) 24%, var(--rule));
  background:color-mix(in srgb, var(--accent-bg) 28%, var(--surface));
}
.report-section.knowledge {
  border-color:color-mix(in srgb, #14b8a6 28%, var(--rule));
  background:color-mix(in srgb, #14b8a6 7%, var(--surface));
}
.report-section.scenario,
.report-section.recommendation {
  border-color:color-mix(in srgb, #8b5cf6 24%, var(--rule));
  background:color-mix(in srgb, #8b5cf6 6%, var(--surface));
}
.report-section-head {
  display:flex;
  align-items:flex-start;
  gap:10px;
}
.report-section-head .rt-label {
  color:var(--ink);
  font-size:12px;
  letter-spacing:.06em;
}
.report-section-head span:not(.report-section-icon) {
  color:var(--ink-3);
  font-size:11.5px;
}
.report-section-icon,
.report-item-index {
  width:26px;
  height:26px;
  border-radius:8px;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  color:var(--accent);
  background:color-mix(in srgb, var(--accent-bg) 54%, var(--surface));
  border:1px solid color-mix(in srgb, var(--accent) 16%, var(--rule));
}
.report-section.positive .report-section-icon,
.report-section.preserve .report-section-icon,
.report-section.positive .report-item-index,
.report-section.preserve .report-item-index { color:var(--ok); background:color-mix(in srgb, var(--ok) 10%, var(--surface)); border-color:color-mix(in srgb, var(--ok) 20%, var(--rule)); }
.report-section.risk .report-section-icon,
.report-section.risk .report-item-index { color:var(--bad); background:color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color:color-mix(in srgb, var(--bad) 22%, var(--rule)); }
.report-section.scenario .report-section-icon,
.report-section.recommendation .report-section-icon { color:#7c3aed; background:color-mix(in srgb, #8b5cf6 10%, var(--surface)); border-color:color-mix(in srgb, #8b5cf6 22%, var(--rule)); }
.report-section-items {
  display:grid;
  gap:10px;
}
.report-item {
  min-width:0;
  display:grid;
  grid-template-columns:auto minmax(0, 1fr);
  gap:10px;
  padding:11px;
  border:1px solid color-mix(in srgb, var(--rule) 84%, transparent);
  border-radius:10px;
  background:color-mix(in srgb, var(--surface-2) 62%, var(--surface));
}
.report-item-empty {
  opacity:.78;
  border-style:dashed;
}
.report-item-copy {
  min-width:0;
  display:grid;
  gap:5px;
  color:var(--ink-2);
  font-size:13px;
  line-height:1.45;
  overflow-wrap:anywhere;
  white-space:normal;
}
.report-item-title-row {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}
.report-item-title-row strong {
  color:var(--ink);
  font-size:13.5px;
  line-height:1.35;
}
.report-item-copy em {
  font-style:normal;
  color:var(--ink-3);
  line-height:1.45;
}
.report-priority {
  flex:0 0 auto;
  border-radius:999px;
  padding:3px 8px;
  font-size:10.5px;
  line-height:1.15;
  font-weight:750;
  border:1px solid var(--rule);
  color:var(--ink-3);
  background:var(--surface);
}
.report-priority.high {
  color:var(--bad);
  border-color:color-mix(in srgb, var(--bad) 28%, var(--rule));
  background:color-mix(in srgb, var(--bad) 8%, var(--surface));
}
.report-priority.medium {
  color:#a16207;
  border-color:color-mix(in srgb, var(--warn) 36%, var(--rule));
  background:color-mix(in srgb, var(--warn) 11%, var(--surface));
}
.report-priority.low {
  color:var(--accent);
  border-color:color-mix(in srgb, var(--accent) 24%, var(--rule));
  background:color-mix(in srgb, var(--accent-bg) 50%, var(--surface));
}

/* --- Optimizer Workflow --- */
.optimizer-steps-bar {
  background:var(--surface); border:1px solid var(--rule);
  border-radius:var(--radius); padding:16px 20px; margin-bottom:2px;
}
.optimizer-preview-head {
  grid-template-columns:minmax(0, 1fr) auto;
  align-items:flex-start;
  border-bottom:1px solid var(--rule);
  padding-bottom:14px;
}
.optimizer-preview-actions {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:10px;
}
.optimizer-patches {
  display:grid;
  grid-template-columns:1fr;
  gap:16px;
  margin:16px 0 0;
}
.optimizer-patch-card {
  align-items:flex-start;
  gap:14px;
  padding:16px;
  border-radius:12px;
  background:color-mix(in srgb, var(--surface-2) 78%, var(--surface));
}
.optimizer-patch-card input {
  width:16px;
  height:16px;
  margin-top:4px;
  accent-color:var(--accent);
}
.optimizer-patch-body { flex:1; min-width:0; }
.optimizer-patch-title {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.optimizer-patch-title strong {
  color:var(--ink);
  font-size:15px;
  line-height:1.25;
}
.optimizer-patch-title span {
  flex:0 0 auto;
  border:1px solid var(--rule);
  border-radius:999px;
  color:var(--ink-3);
  background:var(--surface);
  padding:3px 9px;
  font-size:11.5px;
  font-weight:650;
}
.optimizer-diff {
  display:grid; grid-template-columns:minmax(0, 1fr) minmax(0, 1fr); gap:12px; margin-top:8px;
}
.optimizer-diff-side {
  border-radius:10px;
  padding:14px;
  font-size:13px;
  overflow:visible;
  max-height:none;
  min-height:168px;
}
.optimizer-patch-card pre,
.optimizer-diff-side pre {
  white-space:pre-wrap;
  word-break:normal;
  overflow-wrap:anywhere;
  margin:0;
  max-height:none;
  overflow:visible;
  font-family:var(--ui);
  font-size:13.25px;
  line-height:1.55;
  color:var(--ink-2);
}
.optimizer-diff-side.old { background:color-mix(in srgb, var(--bad) 6%, var(--surface-2)); border:1px solid color-mix(in srgb, var(--bad) 14%, var(--rule)); }
.optimizer-diff-side.new { background:color-mix(in srgb, var(--ok) 6%, var(--surface-2)); border:1px solid color-mix(in srgb, var(--ok) 14%, var(--rule)); }
.optimizer-diff-label { font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; margin-bottom:10px; display:block; }
.optimizer-diff-side.old .optimizer-diff-label { color:var(--bad); }
.optimizer-diff-side.new .optimizer-diff-label { color:var(--ok); }
.optimizer-context { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:12px; }
@media (max-width:800px) {
  .optimizer-diff { grid-template-columns:1fr; }
  .optimizer-preview-head { grid-template-columns:1fr; }
  .optimizer-preview-actions { justify-content:flex-start; }
  .optimizer-patch-card { grid-template-columns:1fr; }
  .optimizer-patch-title { align-items:flex-start; flex-direction:column; }
  .optimizer-context { grid-template-columns:1fr; }
  .tester-round-context { grid-template-columns:1fr; }
  .tester-conversation .chat-bubble-body { max-width:100%; }
  .tester-score-header { flex-wrap:wrap; }
  .tester-score-header .tb-btn { width:100%; }
  .tester-history-modal-head { flex-direction:column; }
  .tester-history-detail-grid { grid-template-columns:1fr; }
  .tester-history-detail-side { border-right:0; border-bottom:1px solid var(--rule); }
  .setup-blockers-banner { flex-direction:column; align-items:flex-start; }
}

/* --- Live agent/tester feedback --- */
.live-status {
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  border:1px solid color-mix(in srgb, var(--accent) 20%, var(--rule));
  background:color-mix(in srgb, var(--accent-bg) 30%, var(--surface));
  border-radius:12px;
  padding:10px 12px;
  color:var(--ink-2);
}
.live-status.compact {
  border:0;
  background:transparent;
  padding:0;
}
.live-status-orb {
  width:22px;
  height:22px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:color-mix(in srgb, var(--accent) 15%, var(--surface));
  flex:0 0 auto;
}
.live-status-orb span {
  width:9px;
  height:9px;
  border-radius:50%;
  background:var(--accent);
  animation:statusPulse 1.1s ease-in-out infinite;
}
.live-status-copy {
  min-width:0;
  display:grid;
  gap:2px;
  flex:1;
}
.live-status-copy strong {
  font-size:11px;
  color:var(--ink);
  line-height:1.1;
}
.live-status-copy span {
  color:var(--ink-3);
  font-size:12.5px;
  line-height:1.35;
}
.assistant-flow-strip,
.optimizer-steps-bar {
  grid-column:1 / -1;
}
.assistant-live-run {
  display:grid;
  gap:16px;
  padding:22px;
}
.flow-step-indicator {
  width:100%;
  display:flex;
  align-items:flex-start;
  gap:0;
}
.flow-step-indicator.vertical {
  flex-direction:column;
  align-items:stretch;
  gap:0;
}
.flow-step {
  min-width:0;
  display:grid;
  justify-items:center;
  gap:7px;
  color:var(--ink-3);
  font-size:12px;
  font-weight:650;
  flex:0 0 auto;
}
.flow-step-indicator:not(.vertical) .flow-step {
  width:116px;
}
.flow-step-indicator.vertical .flow-step {
  width:100%;
  grid-template-columns:auto 1fr;
  justify-items:start;
  align-items:center;
  gap:10px;
}
.flow-step .step-node {
  width:24px;
  height:24px;
  border-radius:50%;
  display:grid;
  place-items:center;
  font-size:11px;
  font-weight:800;
  background:var(--surface-2);
  color:var(--ink-3);
  border:1px solid var(--rule);
  transition:background .2s, border-color .2s, color .2s, transform .2s;
}
.flow-step.done .step-node {
  background:var(--ok-bg);
  color:var(--ok);
  border-color:color-mix(in srgb, var(--ok) 45%, var(--rule));
}
.flow-step.running .step-node {
  background:var(--accent-bg);
  color:var(--accent);
  border-color:var(--accent);
  transform:scale(1.04);
  box-shadow:0 0 0 5px color-mix(in srgb, var(--accent) 10%, transparent);
}
.flow-step.warn .step-node {
  background:var(--warn-bg);
  color:var(--warn);
  border-color:color-mix(in srgb, var(--warn) 45%, var(--rule));
}
.flow-step.error .step-node {
  background:var(--bad-bg);
  color:var(--bad);
  border-color:color-mix(in srgb, var(--bad) 45%, var(--rule));
}
.flow-step .step-node-label {
  color:inherit;
  max-width:120px;
  text-align:center;
  line-height:1.25;
}
.flow-step-indicator.vertical .step-node-label {
  max-width:none;
  text-align:left;
}
.flow-step-indicator .step-connector {
  flex:1;
  min-width:24px;
  height:2px;
  margin:12px 0 0;
  background:linear-gradient(90deg,var(--accent),var(--rule));
}
.flow-step-indicator.vertical .step-connector {
  width:2px;
  min-width:0;
  height:16px;
  margin:4px 0 4px 11px;
  background:linear-gradient(180deg,var(--accent),var(--rule));
}
.step-spinner {
  width:12px;
  height:12px;
  border-radius:50%;
  border:2px solid currentColor;
  border-right-color:transparent;
  animation:spinStep .72s linear infinite;
}
.assistant-flow-strip {
  border:1px solid var(--rule);
  border-radius:12px;
  background:var(--surface);
  padding:14px 16px;
}
.optimizer-patch-reason {
  margin:-4px 0 10px;
  color:var(--ink-3);
  font-size:12.5px;
  line-height:1.45;
}
.version-history {
  margin-top:14px;
  border:1px solid var(--rule);
  border-radius:12px;
  background:var(--surface-2);
  padding:12px;
}
.version-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border-top:1px solid var(--rule);
  padding:10px 0;
}
.version-row:first-of-type { border-top:0; }
.version-row strong {
  display:block;
  color:var(--ink);
  font-size:13px;
}
.version-row span {
  display:block;
  color:var(--ink-3);
  font-size:12px;
  margin-top:2px;
}
.agent-thinking-msg .msg-bubble {
  min-width:260px;
}
@keyframes statusPulse {
  0%, 100% { transform:scale(.72); opacity:.55; box-shadow:0 0 0 0 color-mix(in srgb, var(--accent) 26%, transparent); }
  50% { transform:scale(1); opacity:1; box-shadow:0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@keyframes spinStep { to { transform:rotate(360deg); } }
@media (max-width:900px) {
  .flow-step-indicator:not(.vertical) {
    overflow-x:auto;
    padding-bottom:4px;
  }
  .flow-step-indicator:not(.vertical) .flow-step {
    width:96px;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .thinking-dots span,
  .thinking-dot-pulse,
  .live-status-orb span,
  .step-spinner,
  .skeleton-line,
  .skeleton-card,
  .skeleton-bubble,
  .chat-bubble { animation:none; }
  .score-ring circle { transition:none; }
  .sidebar { transition:none; }
  .sb-item.active::before { transition:none; }
  .sidebar:not(:hover):not(.pinned) .sb-item[data-tooltip]:hover::after { animation:none; }
  .setup-step-row,
  .setup-hero-bar span,
  .step-node,
  .thinking-step { transition:none; }
}
