:root {
  /* Base monocromática (~90%) */
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  /* Un solo acento de marca */
  --accent: #FF4D1A;
  --accent-soft: #fff1ec;
  --accent-hover: #e63e0f;
  --navy: #0f172a;
  --blue: var(--accent);
  --blue-soft: var(--accent-soft);
  --blue-hover: var(--accent-hover);
  /* Estados pastel desaturados */
  --danger: #9f1239;
  --danger-soft: #fff1f2;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #92400e;
  --warn-soft: #fffbeb;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 20px 40px rgba(15, 23, 42, 0.08);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 8px; /* sin cápsulas globales */
  --font: "Manrope", system-ui, sans-serif;
  --display: "Sora", "Manrope", system-ui, sans-serif;
  --sidebar-w: 240px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 3rem;
  --content-pad-x: clamp(1rem, 2.5vw, 1.75rem);
  --content-pad-y: clamp(1rem, 2vw, 1.5rem);
  --topbar-h: 64px;
  --z-sidebar: 30;
  --z-topbar: 40;
  --z-dropdown: 50;
  --z-sticky: 20;
  --z-backdrop: 80;
  --z-drawer: 90;
  --z-loading: 95;
  --z-toast: 100;
  --workbench-h: calc(100dvh - var(--topbar-h) - 3rem);
  /* Dark tokens preparados (no activos) */
  --dark-bg: #0a0a0a;
  --dark-surface: #111827;
  --dark-ink: #f8fafc;
  --dark-muted: #94a3b8;
  --dark-line: #1f2937;
}
body.nav-locked { overflow: hidden; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: none; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
  position: relative;
}

/* Sidebar */
.sidebar {
  background: #ffffff;
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  padding: 1.15rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow-y: auto;
  z-index: var(--z-sidebar);
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-close { display: none; }
.sidebar-pin { display: none; }
.btn-icon {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background: var(--accent-soft); border-color: rgba(255, 77, 26, 0.25); }
.nav-section-label {
  margin: 0.35rem 0.85rem 0.15rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0.25rem 0.4rem;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex: none;
  display: none;
}
.brand-logo {
  height: 40px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  box-shadow: none;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: var(--display);
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}
.brand-text em {
  font-style: normal;
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.nav { display: flex; flex-direction: column; gap: 0.2rem; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.nav-item:hover { background: var(--blue-soft); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 77, 26, 0.18);
}
.nav-ico { width: 1.2rem; text-align: center; opacity: 0.9; display: grid; place-items: center; }
.nav-divider { height: 1px; background: var(--line); margin: 0.5rem 0.35rem; }

.sidebar-cta {
  margin-top: auto;
  border-radius: var(--radius-sm) !important;
  box-shadow: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 35, 50, 0.35);
  z-index: 35;
}

/* Workspace */
.workspace { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  min-height: var(--topbar-h);
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.5rem;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.menu-toggle { display: none; }
.menu-bars {
  width: 16px;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 5px 0 var(--ink), 0 -5px 0 var(--ink);
  display: block;
}
.search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1rem;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
}
.search-ico { color: var(--muted); }
.search input {
  border: 0;
  background: transparent;
  width: 100%;
  font: inherit;
  color: var(--ink);
  outline: none;
}
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-chip {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  min-width: 0;
  min-height: 0;
  padding: var(--content-pad-y) var(--content-pad-x) var(--space-8);
  width: 100%;
  max-width: none;
}
.content > * { width: 100%; max-width: none; }
.content--reading > * { max-width: 80ch; margin-inline: auto; }
.content--form > * { max-width: 960px; margin-inline: auto; }
.content--workbench,
.content--full { width: 100%; }
.content--workbench {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
}
.content--workbench > .page-head { flex: 0 0 auto; }
.content--workbench > .stack-gap > .page-head { flex: 0 0 auto; }
/* Shells de altura fija con su propio scroll interno (chat/copilot/inbox/conversations).
   Todo lo demás bajo .content--workbench ahora scrollea como página normal. */
.content--workbench > .chat-shell-min,
.content--workbench > .copilot-split,
.content--workbench > .inbox-split,
.content--workbench > .wa-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  padding-bottom: var(--space-2);
}
.page-head.compact { margin-bottom: var(--space-4); }
.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.page-head h2,
.section-title {
  margin: 0 0 var(--space-3);
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.subtitle { margin: 0.35rem 0 0; color: var(--muted); line-height: 1.5; max-width: 54ch; }
.page-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.hint, .muted { color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.crud-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: var(--space-3);
}
.crud-row-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  flex: none;
}
.mcp-server-row { align-items: stretch; }
.mcp-server-body { flex: 1; min-width: 0; }
.mcp-server-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.mcp-tool-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.mcp-tool-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.75rem;
  font-size: 0.86rem;
  line-height: 1.4;
}
.mcp-tool-list code {
  font-size: 0.85rem;
}
.mcp-check-list {
  display: grid;
  gap: 0.35rem;
  margin: 0.35rem 0 0.75rem;
}
.mcp-check-list .check {
  align-items: flex-start;
}
.mcp-check-list .check .muted {
  display: block;
  margin-top: 0.15rem;
}
.list-actions {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}
.inline-delete { display: inline; margin: 0; }
.panel-pad { padding: var(--space-5); }
.stack-gap { display: flex; flex-direction: column; gap: var(--space-4); }
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
}
.empty-state h2 { margin: 0 0 var(--space-2); font-family: var(--display); }
.empty-state p { margin: 0; color: var(--muted); }

/* Soft UI primitives */
.soft-card,
.settings-card,
.inv-card,
.channel-card,
.connect-card,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.soft-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Buttons — flat minimal */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: background 0.15s ease-in-out, border-color 0.15s ease-in-out, color 0.15s ease-in-out;
}
.btn:active { opacity: 0.92; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--bg-soft); text-decoration: none; }
.btn-soft { border-radius: var(--radius-sm) !important; padding-inline: 0.9rem; }
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #fecdd3;
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdd3;
}
.btn-danger:hover { background: #ffe4e6; text-decoration: none; }
.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.btn-ghost.danger { color: var(--danger); border-color: #fecdd3; }
.btn-ghost.danger:hover { background: var(--danger-soft); }

/* Chip único (estado muted) */
.chip,
.badge,
.soft-badge,
.tag,
.pill-navy,
.pill-accent,
.pill-muted,
.pill-ok,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
}
.chip-active,
.badge-active {
  background: var(--bg-soft);
  color: var(--ink);
  border-color: var(--line-strong);
}
.chip-error,
.badge-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdd3;
}
.chip-ok,
.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #a7f3d0;
}

/* Inventory */
.inventory-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  width: 100%;
}
.inv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 168px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.inv-card:hover { border-color: rgba(255, 77, 26, 0.35); transform: translateY(-1px); }
.inv-card.is-error { border-color: #ff8f73; }
.inv-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}
.inv-title {
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.02rem;
}
.inv-title:hover { color: var(--blue); }
.inv-meta { margin: 0; color: var(--muted); font-size: 0.84rem; }
.inv-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.inv-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}
.inv-warn { color: var(--danger); font-weight: 600; }
.inv-menu { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; }
.inv-menu a { font-weight: 600; font-size: 0.85rem; }
.inv-delete { display: inline; margin: 0; }
.inv-delete-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--danger);
  cursor: pointer;
}
.inv-delete-btn:hover { text-decoration: underline; }
.key-list .list-key-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: space-between;
}
.key-list .list-key-row > a { flex: 1; min-width: 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 6px;
  padding: 0.22rem 0.45rem;
}
.badge-active { background: var(--navy); color: #fff; }
.badge-idle { background: #ebecf0; color: #6b778c; }
.badge-error { background: var(--danger-soft); color: var(--danger); }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
}

/* Chat */
.chat-shell {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 1rem;
  width: 100%;
  height: var(--workbench-h);
  min-height: 480px;
  align-items: stretch;
}
.chat-config {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow);
  max-height: none;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}
.chat-config h2 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.field select,
.field input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.motor-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
}
.motor-panel h3 {
  margin: 0 0 0.7rem;
  font-size: 0.92rem;
}
.meter { margin-bottom: 0.7rem; }
.meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.meter-track {
  height: 6px;
  background: #dfe3ea;
  border-radius: 999px;
  overflow: hidden;
}
.meter-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #FF8A5C);
  border-radius: inherit;
}
.motor-nominal {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}
.motor-nominal.ok { color: var(--ok); }
.motor-nominal.bad { color: var(--danger); }
.debug-line {
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-word;
  margin: 0;
}
.mono { font-family: ui-monospace, Consolas, monospace; }
.chat-actions { display: grid; gap: 0.45rem; margin-top: auto; }

.run-log-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-height: 160px;
  max-height: 280px;
}
.run-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}
.run-log-head h3,
.feedback-box h3 {
  margin: 0;
  font-size: 0.92rem;
}
.run-log-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}
.run-log {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: grid;
  gap: 0.4rem;
  flex: 1;
}
.run-log-empty {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.35rem 0;
}
.run-step {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid #66758c;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  display: grid;
  gap: 0.15rem;
}
.run-step strong {
  font-size: 0.85rem;
  color: var(--ink);
}
.run-step span {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}
.run-step.level-ok { border-left-color: var(--ok); }
.run-step.level-info { border-left-color: var(--blue); }
.run-step.level-warn { border-left-color: #ff8b00; }
.run-step.level-error { border-left-color: var(--danger); background: #fff8f6; }

.feedback-box {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.75rem;
  display: grid;
  gap: 0.5rem;
}
.feedback-box.is-hidden,
.feedback-result.is-hidden { display: none; }
.feedback-box textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font: inherit;
  resize: vertical;
  min-height: 64px;
}
.feedback-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.feedback-result {
  font-size: 0.84rem;
  line-height: 1.4;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
}
.feedback-result p { margin: 0 0 0.45rem; }

.chat-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  scrollbar-gutter: stable;
}
.bubble {
  max-width: min(92%, 720px);
  padding: 0.8rem 1rem;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  animation: rise 0.22s ease;
  font-size: 0.95rem;
}
.bubble.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(18, 32, 58, 0.04);
}
.bubble.error {
  border-color: #ff8f73;
  background: var(--danger-soft);
}
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem;
  align-items: end;
  padding: 0.85rem 1rem 0.35rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.composer textarea {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  resize: none;
  min-height: 48px;
  max-height: 140px;
  color: var(--ink);
}
.send-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
}
.send-btn:hover { background: var(--blue-hover); }
.composer-hint {
  margin: 0;
  padding: 0 1rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: #fff;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* Shared panels used by prompts/rules/graph */
.panel, .editor-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.panel h2, .hero h1 {
  font-family: var(--display);
  margin: 0;
}
.hero { margin-bottom: 0.5rem; }
.hero h1 { font-size: 1.55rem; letter-spacing: -0.02em; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--blue);
  font-weight: 700;
}
.lede { color: var(--muted); margin: 0.35rem 0 0; }
.split {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.list-pane h2 { margin: 0 0 0.6rem; font-size: 0.95rem; color: var(--muted); }
.list-pane-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.key-list a {
  display: block;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  text-decoration: none;
}
.key-list a.is-active,
.key-list a:hover {
  background: var(--blue-soft);
  color: var(--blue);
}
.editor-form textarea {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.85rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink);
  background: #fbfcfe;
}
.list-pane .key-list {
  max-height: clamp(260px, 55vh, 620px);
  overflow-y: auto;
}
.editor-pane {
  display: flex;
  flex-direction: column;
  min-height: clamp(420px, calc(100vh - var(--topbar-h) - 12rem), 760px);
}
.editor-pane .editor-form,
.editor-pane form.stack-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.editor-pane textarea {
  flex: 1 1 auto;
  min-height: 200px;
}
.hint { color: var(--muted); font-size: 0.92rem; }
.toast {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  background: #e3fcef;
  border: 1px solid #abf5d1;
  color: var(--ok);
}
.toast.error {
  background: var(--danger-soft);
  border-color: #ffbdad;
  color: var(--danger);
}
.rule-form { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
}
.rule-grid label:not(.switch-field) {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.rule-grid .span-2 { grid-column: span 2; }
.rule-grid .check { flex-direction: row; align-items: center; gap: 0.4rem; }
.rule-grid input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  background: #fff;
}
.chip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.chip-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.chip-list span { color: var(--muted); font-size: 0.95rem; }
.graph-panel { overflow-x: auto; min-height: 340px; }

.graph-interactive {
  padding: 0.9rem 1rem 1rem;
  overflow: hidden;
}
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}
.graph-hint {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
}
.graph-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 0.85rem;
  min-height: 560px;
}
.graph-canvas {
  height: 560px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    radial-gradient(700px 220px at 0% 0%, rgba(0, 82, 204, 0.06), transparent 55%),
    radial-gradient(500px 180px at 100% 100%, rgba(0, 82, 204, 0.04), transparent 50%),
    #fbfcfe;
}
.graph-detail {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 560px;
}
.graph-detail h2 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-family: var(--font);
}
.graph-detail-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.graph-detail-body.is-hidden,
.graph-detail-empty.is-hidden,
#graphDetailToolsWrap.is-hidden {
  display: none;
}
.graph-detail-label {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.graph-detail-kind {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  display: flex;
  gap: 0.45rem;
  align-items: center;
}
.graph-detail-tools-title {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.graph-detail .chip-list li {
  justify-content: flex-start;
}

/* Section Copilot dock */
.section-with-copilot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: stretch;
}
.section-with-copilot:has(.section-copilot.is-collapsed) { grid-template-columns: minmax(0, 1fr); }
.section-main { min-width: 0; }
.section-copilot {
  position: sticky;
  top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  max-height: var(--workbench-h);
  min-height: 420px;
}
.section-copilot.is-collapsed {
  display: none;
}
.section-copilot-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.section-copilot-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.section-copilot-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}
.section-copilot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sc-chip {
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.sc-chip:hover { border-color: #b3c7ef; background: var(--blue-soft); color: var(--blue); }
.section-copilot-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.35rem 0.15rem;
  min-height: 180px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.sc-empty {
  margin: 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}
.sc-bubble {
  margin: 0 0.45rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  max-width: 95%;
}
.sc-bubble.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sc-bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.sc-actions {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}
.sc-actions-title {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.sc-actions ul {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}
.sc-actions li {
  font-size: 0.85rem;
  color: var(--muted);
}
.sc-actions-row {
  display: flex;
  gap: 0.4rem;
}
.section-copilot-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: end;
}
.section-copilot-form textarea {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  resize: vertical;
  min-height: 52px;
  max-height: 120px;
  color: var(--ink);
}
.section-with-copilot .graph-layout {
  grid-template-columns: 1fr;
}
.section-with-copilot .graph-detail {
  height: auto;
  min-height: 140px;
}
.section-with-copilot .graph-canvas {
  height: 480px;
}
.empty { color: var(--muted); }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  width: 100%;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}
.settings-card h2 { margin: 0 0 0.35rem; font-family: var(--display); font-size: 1.1rem; }
.kv { margin: 1rem 0 0; display: grid; gap: 0.55rem; }
.kv dt { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kv dd { margin: 0.15rem 0 0; }
.settings-links { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.65rem; }
.settings-links li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

/* Tutorial */
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  width: 100%;
}
.tutorial-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  position: relative;
}
.tutorial-card-wide { grid-column: 1 / -1; }
.tutorial-step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
  font-size: 0.92rem;
  margin-bottom: 0.55rem;
}
.tutorial-card h2 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-size: 1.15rem;
}
.tutorial-card p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}
.tutorial-card ol,
.tutorial-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
}
.tutorial-card li { margin-bottom: 0.35rem; }
.tutorial-links { list-style: disc; }
.tutorial-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

/* Compat aliases for old btn classes in remaining templates */
.btn.ghost, .btn.compact { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.btn { /* already defined */ }

/* Copilot floating access (global) */
.copilot-float {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem;
  box-shadow: var(--shadow);
}
.copilot-float.is-hidden { display: none; }
.copilot-float-main {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 0.48rem 0.75rem;
  text-decoration: none;
}
.copilot-float-main:hover {
  text-decoration: none;
  background: var(--blue-hover);
}
.copilot-float-hide {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.copilot-float-show {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  display: none;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.45rem 0.68rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.copilot-float-show.is-visible { display: inline-flex; }

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }
  body.nav-locked { overflow: hidden; }
  .menu-toggle { display: inline-grid !important; }
  .sidebar-close { display: inline-grid !important; }
  .sidebar-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(26, 28, 30, 0.42);
    z-index: 45;
  }
  .sidebar-backdrop[hidden] { display: none !important; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 88vw);
    height: 100dvh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
    padding: 1rem 0.9rem 1.25rem;
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .nav { flex-direction: column; flex-wrap: nowrap; }
  .sidebar-cta { margin-top: auto; }
  .sidebar .nav-label,
  .sidebar .brand-text { opacity: 1 !important; max-width: none !important; overflow: visible; }
  .sidebar .brand-icon { display: none !important; }
  .sidebar .brand-logo { display: block !important; height: 36px; max-width: 160px; }
  .sidebar .nav-item { justify-content: flex-start !important; padding: 0.7rem 0.85rem !important; gap: 0.55rem !important; }
  .chat-shell, .split, .copilot-split, .inbox-split { grid-template-columns: 1fr !important; }
  .chat-shell { height: auto; min-height: 0; }
  .chat-stage { min-height: 420px; height: auto; }
  .rule-grid { grid-template-columns: 1fr; }
  .rule-grid .span-2 { grid-column: auto; }
  .topbar { flex-wrap: wrap; gap: 0.65rem; padding: 0.75rem 1rem; }
  .search { max-width: none; order: 3; flex: 1 1 100%; }
  .content { padding: var(--space-4) var(--space-4) var(--space-7); }
  .channel-cards, .connect-grid { grid-template-columns: 1fr; }
  .crud-row { flex-direction: column; }
  .crud-row-actions { width: 100%; }
  .mcp-server-head { flex-direction: column; }
  .copilot-float,
  .copilot-float-show {
    right: 0.8rem;
    bottom: 0.8rem;
  }
  .graph-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .graph-canvas,
  .graph-detail {
    min-height: 0;
    height: 420px;
  }
  .graph-detail { height: auto; min-height: 160px; }
  .graph-hint { margin-left: 0; width: 100%; }
  .section-with-copilot {
    grid-template-columns: 1fr;
  }
  .section-copilot {
    position: static;
    max-height: none;
    min-height: 360px;
  }
}

.stack-form label:not(.switch-field) {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
}
.stack-form input:not([type="checkbox"]):not([type="radio"]),
.stack-form select,
.soft-input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.65rem 0.85rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.stack-form input:focus,
.stack-form select:focus,
.soft-input:focus {
  outline: none;
  border-color: rgba(255, 77, 26, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 77, 26, 0.12);
  background: #fff;
}
.banner-ok {
  background: var(--ok-soft);
  color: #065f46;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid #a7f3d0;
}
.banner-err {
  background: var(--danger-soft);
  color: #9f1239;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid #fecdd3;
}
.muted { color: var(--muted); font-size: 0.92rem; }

/* Channels / Inbox SaaS UX */
.ico { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }
.ico-lg { width: 22px; height: 22px; }
.page-ico { color: var(--accent); }
.banner-warn {
  background: var(--warn-soft);
  color: #9a3412;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid #fed7aa;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.banner-ok .ico, .banner-err .ico {
  margin-right: 0.45rem;
}
/* display:flex en banners anula [hidden] del UA — forzar oculto */
[hidden],
.is-hidden {
  display: none !important;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.05rem;
  margin: 0 0 1rem;
}
.channel-accounts { margin-bottom: 1.75rem; }
.channel-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  width: 100%;
}
.channel-card {
  padding: 1.1rem 1.15rem;
}
.channel-card--telegram { border-top: 3px solid #229ED9; }
.channel-card--whatsapp_cloud { border-top: 3px solid #25D366; }
.channel-card--whatsapp_qr { border-top: 3px solid var(--accent); }
.channel-card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.channel-brand {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
}
.channel-card--telegram .channel-brand { background: #e8f6fc; color: #229ED9; }
.channel-card--whatsapp_cloud .channel-brand,
.channel-card--whatsapp_qr .channel-brand { background: #e8f8ef; color: #128C7E; }
.channel-card-titles { flex: 1; min-width: 0; }
.channel-card-titles strong { display: block; font-size: 0.98rem; }
.channel-meta { font-size: 0.85rem; color: var(--muted); }
.status-pill {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: #374151;
}
.status-connected { background: var(--ok-soft); color: #065f46; }
.status-disconnected { background: var(--bg-soft); color: var(--muted); }
.status-error { background: var(--danger-soft); color: #9f1239; }
.status-experimental, .status-pending_qr { background: var(--accent-soft); color: var(--accent); }
.webhook-row label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.25rem; }
.copy-field { display: flex; gap: 0.35rem; }
.copy-field input {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: ui-monospace, monospace;
}
.btn-icon { padding: 0.45rem 0.6rem !important; min-height: 40px; border-radius: var(--radius-sm); }
.btn-icon.copied { background: var(--ok-soft); }
.channel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.sim-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.switch-field.channel-admin-switch {
  flex-basis: 100%;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  min-height: auto;
  margin: 0.35rem 0 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.sim-form .switch-field.channel-admin-switch { margin-bottom: 0; }
.channel-admin-switch small { margin-top: 0; }
.sim-form input[type="text"], .sim-form input:not([type]) {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.65rem;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.92rem;
  background: var(--bg);
}
.chk { font-size: 0.85rem; display: inline-flex; align-items: center; gap: 0.25rem; color: var(--muted); }
.connect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
  width: 100%;
}
.connect-card {
  padding: 1.25rem;
}
.connect-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}
.connect-telegram h2 { color: #1a7eab; }
.connect-wa h2 { color: #128C7E; }
.connect-qr h2 { color: #0f766e; }
.qr-panel {
  margin: 1.25rem 0;
  padding: 1.15rem 1.25rem;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  background: var(--warn-soft);
  box-shadow: var(--shadow-sm);
}
.qr-panel-inner {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}
.qr-img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  width: 200px;
  height: 200px;
  object-fit: contain;
}
.qr-live-status { font-size: 0.92rem; font-weight: 600; margin-top: 0.5rem; }
.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.inbox-row {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.inbox-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-bottom: 0.35rem; }
.badge {
  font-size: 0.78rem; font-weight: 600; padding: 0.25rem 0.55rem; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; gap: 0.3rem;
}
.badge-channel { background: var(--accent-soft); color: var(--accent); }
.badge-telegram { background: #e8f6fc; color: #0369a1; }
.badge-whatsapp_cloud, .badge-whatsapp_qr { background: #ecfdf5; color: #047857; }
.badge-admin { background: var(--accent); color: #fff; }
.badge-user { background: #d1fae5; color: #065f46; }
.badge-dir { background: var(--bg-soft); color: #4b5563; text-transform: uppercase; }
.inbox-body { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.empty-hint { display: flex; align-items: center; gap: 0.4rem; padding: 1rem 0; }
.nav-ico .ico { width: 16px; height: 16px; }

/* Login soft */
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg);
}
.login-card {
  width: min(420px, 100%);
  padding: 2rem;
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.login-logo {
  display: block;
  width: min(280px, 100%);
  height: auto;
  object-fit: contain;
}
.login-brand .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}
.login-card h1 {
  font-family: var(--display);
  font-size: 1.55rem;
  margin: 0;
}
.login-card .subtitle { margin-bottom: 1.25rem; }
.login-card label { display: block; font-size: 0.92rem; font-weight: 600; margin: 0.75rem 0 0.35rem; }
.login-card input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font: inherit;
}
.login-card .btn { margin-top: 1.25rem; width: 100%; border-radius: var(--radius-pill); }
.login-error {
  background: var(--danger-soft);
  color: #9f1239;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}
.login-hint { margin-top: 1rem; font-size: 0.85rem; color: var(--muted); }

.inventory-grid { gap: 1rem; }
.inv-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.inv-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(26, 35, 50, 0.08);
}
.settings-grid { gap: 1rem; }
.settings-card { padding: 1.2rem; }


/* ===== Minimal UI overrides (kill TWISTY pills/shadows) ===== */
.soft-card,
.settings-card,
.inv-card,
.channel-card,
.connect-card,
.login-card,
.tutorial-card,
.inbox-row,
.qr-panel,
.panel,
.editor-pane,
.section-copilot,
.graph-panel {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  background: var(--surface) !important;
}
.nav-item {
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
}
.nav-item.is-active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  box-shadow: none !important;
}
.btn {
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}
.btn-primary {
  background: var(--accent) !important;
  box-shadow: none !important;
  color: #fff !important;
}
.btn-primary:hover { background: var(--accent-hover) !important; }
.btn-soft { border-radius: var(--radius-sm) !important; }
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.metric {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
}
.metric strong {
  display: block;
  font-size: 1.35rem;
  font-family: var(--display);
  letter-spacing: -0.02em;
  color: var(--ink);
  font-weight: 600;
}
.metric span {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
.progress {
  height: 6px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 0.45rem;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.soft-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}
.soft-card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.key-row, .audit-row, .env-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.key-row:last-child, .audit-row:last-child, .env-row:last-child { border-bottom: 0; }
.pill-navy,
.pill-accent,
.pill-muted,
.pill-ok,
.chip {
  background: var(--bg-soft) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.15rem 0.5rem !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}
.pill-ok { color: var(--ok) !important; background: var(--ok-soft) !important; border-color: #a7f3d0 !important; }
.chip-warn {
  background: #fff7ed !important;
  color: #9a3412 !important;
  border-color: #fdba74 !important;
}
.chip-ok {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border-color: #a7f3d0 !important;
}
.chip-err {
  background: #fef2f2 !important;
  color: #b91c1c !important;
  border-color: #fecaca !important;
}
.chip-accent {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: #c7d2fe !important;
}
.chip-muted {
  background: var(--bg-soft) !important;
  color: var(--muted) !important;
}
.chip-lg {
  font-size: 0.88rem !important;
  padding: 0.35rem 0.75rem !important;
}
.channel-card.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.qr-manager-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.qr-account-picker label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  margin: 0;
}
.qr-account-picker select {
  min-width: 14rem;
  min-height: 36px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.qr-single-account { margin: 0; font-size: 0.88rem; }
.qr-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 0.5rem;
}
.qr-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.qr-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.qr-scan-hint {
  margin: 0;
  font-size: 0.88rem;
  text-align: center;
}
.qr-manager-body { flex: 1; min-width: 240px; }
.pill-accent { color: var(--ink) !important; }
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none;
  box-shadow: none;
}
.chat-config, .chat-main, .motor-panel, .run-log-panel, .composer {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid var(--line) !important;
}
.tag {
  border-radius: var(--radius-sm) !important;
  background: var(--bg-soft) !important;
  border: 1px solid var(--line) !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
}
.tutorial-step {
  background: var(--bg-soft) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}
.badge-user { background: var(--ok-soft) !important; color: var(--ok) !important; }
.badge-dir { background: var(--bg-soft) !important; color: var(--muted) !important; }
.page-ico { color: var(--muted) !important; }
.qr-panel { background: var(--warn-soft) !important; }
.qr-panel[data-phase="idle"] {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}
.qr-panel[data-phase="connected"] {
  background: var(--ok-soft) !important;
  border-color: #a7f3d0 !important;
}
.qr-panel[data-phase="pending"] {
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
}
.qr-panel[data-phase="reauth"],
.qr-panel[data-phase="error"] {
  background: var(--danger-soft) !important;
  border-color: #fecdd3 !important;
}
.qr-warn-compact {
  margin: 0 0 1rem !important;
  padding: 0.65rem 0.85rem !important;
  font-size: 0.88rem;
}
.qr-state-msg {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
}
.qr-panel[data-phase="idle"] .qr-state-msg {
  color: var(--muted);
}
.qr-panel[data-phase="connected"] .qr-state-msg {
  border-color: #a7f3d0;
  color: #065f46;
}
.qr-action-grid form[hidden],
.qr-action-grid form.is-hidden {
  display: none !important;
}
.qr-action-grid .btn {
  min-height: 42px;
  font-weight: 700;
}
.qr-footer-hint {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
}
.qr-img {
  width: 220px !important;
  height: 220px !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.settings-grid { gap: 1rem !important; }
.inventory-grid { gap: 0.85rem !important; }
.sidebar-cta { box-shadow: none !important; }
.brand-mark { box-shadow: none !important; background: var(--accent) !important; }
.btn-primary { box-shadow: none !important; }
.inv-card:hover {
  transform: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-color: var(--line-strong) !important;
}
.inv-menu a { color: var(--muted) !important; font-weight: 500 !important; }
.inv-menu a:hover { color: var(--ink) !important; }
.inv-delete-btn { color: var(--danger) !important; font-weight: 500 !important; }
.badge-active, .soft-badge.badge-active {
  background: var(--bg-soft) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}
.copilot-float,
.copilot-float-show { display: none !important; }
.copilot-float.is-hidden { display: none !important; }

/* Panels + chat bubbles TWISTY */
.panel, .editor-pane, .section-copilot, .graph-panel {
  background: var(--surface) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
}
.field input, .field select, .field textarea,
.stack-form input, .stack-form select, .stack-form textarea {
  border-radius: var(--radius-sm) !important;
  background: var(--bg) !important;
  border: 1px solid transparent !important;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(255, 77, 26, 0.35) !important;
  box-shadow: 0 0 0 3px rgba(255, 77, 26, 0.12) !important;
  background: #fff !important;
}
.inv-card { padding: 1.15rem 1.2rem !important; }
.inv-title { color: var(--ink) !important; }
.inv-title:hover { color: var(--accent) !important; }
.msg.user .bubble {
  background: var(--accent) !important;
  color: #fff !important;
  border-radius: 18px 18px 4px 18px !important;
}
.msg.bot .bubble, .msg.assistant .bubble {
  background: #fff !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px 18px 18px 4px !important;
  box-shadow: var(--shadow-sm) !important;
}

/* List panes + residual TWISTY polish */
.list-pane.soft-card, .list-pane {
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  border: none;
}
.key-list a.is-active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-radius: var(--radius-pill);
}
.send-btn { background: var(--accent) !important; }
.meter-track i { background: linear-gradient(90deg, var(--accent), #FF8A5C) !important; }
.avatar {
  background: #fff !important;
  color: inherit !important;
  border: none !important;
}
.user-chip {
  border-radius: var(--radius-pill);
  background: var(--bg);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.sim-form input {
  border-radius: var(--radius-pill) !important;
  background: var(--bg) !important;
  border: 1px solid transparent !important;
  padding: 0.55rem 0.9rem;
}
.qr-panel { padding: 1.25rem !important; }
.qr-img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  background: #fff;
  padding: 0.75rem;
}

/* ===== Layout full-width (sidebar estática) ===== */
@media (min-width: 981px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    height: 100dvh;
  }
  .workspace { grid-column: 2; }
  .sidebar-close { display: none !important; }
  .sidebar-pin { display: none !important; }
  .sidebar .brand-icon { display: none; }
  .sidebar .brand-logo { display: block; height: 42px; max-width: 188px; }
  .sidebar .nav-label { opacity: 1; max-width: none; overflow: visible; }
  .sidebar .nav-item {
    justify-content: flex-start;
    padding: 0.7rem 0.85rem;
    gap: 0.55rem;
  }
  .sidebar-cta {
    justify-content: center;
    gap: 0.35rem;
  }
  .sidebar .brand { justify-content: flex-start; padding: 0.25rem 0.4rem; }
  .sidebar-top { justify-content: flex-start; }
}

@media (min-width: 1400px) {
  .inventory-grid { grid-template-columns: repeat(4, 1fr); }
  .channel-cards { grid-template-columns: repeat(4, 1fr); }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .tutorial-grid { grid-template-columns: repeat(3, 1fr); }
}

.qr-panel { width: 100%; }
.channel-accounts, .channels-page { width: 100%; }

/* Copilot split */
.copilot-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.1rem;
}
.copilot-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.copilot-step-pill strong {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}
.copilot-split {
  display: grid;
  grid-template-columns: 42% 58%;
  gap: 1.1rem;
  width: 100%;
  min-height: var(--workbench-h);
  align-items: stretch;
}
.copilot-pane {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.copilot-pane h2 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.1rem;
}
.copilot-pane .field textarea { min-height: 140px; resize: vertical; }
.copilot-preview-body {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}
.copilot-empty {
  color: var(--muted);
  line-height: 1.5;
  margin: 1rem 0 0;
}

/* Inbox table + detail */
.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.inbox-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
}
.inbox-filter:hover { color: var(--ink); text-decoration: none; background: var(--bg); }
.inbox-filter.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.inbox-split {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 1rem;
  width: 100%;
  min-height: var(--workbench-h);
  align-items: stretch;
}
.inbox-table-wrap, .inbox-detail {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.inbox-table-wrap { overflow: auto; }
.inbox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.inbox-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1;
}
.inbox-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
.inbox-table tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.inbox-table tbody tr:hover { background: var(--bg); }
.inbox-table tbody tr.is-selected {
  background: var(--accent-soft);
}
.inbox-preview {
  color: var(--muted);
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-detail { padding: 1.25rem 1.35rem; }
.inbox-detail-empty {
  color: var(--muted);
  margin: auto;
  text-align: center;
  padding: 2rem 1rem;
}
.inbox-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.inbox-detail-body {
  white-space: pre-wrap;
  line-height: 1.5;
  flex: 1;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.inbox-internal-card {
  padding: 2rem;
  text-align: center;
  max-width: 520px;
  margin: 2rem auto;
}
.pager {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  align-items: center !important;
  gap: 0.75rem 1rem;
  padding: 0.9rem 1.1rem !important;
  border-top: 1px solid var(--line) !important;
  background: var(--bg-soft, #f1f5f9) !important;
  flex-shrink: 0;
}
.pager-meta {
  margin: 0 !important;
  font-size: 0.84rem !important;
  color: var(--muted) !important;
  justify-self: start;
}
.pager-meta strong { color: var(--ink) !important; font-weight: 600; }
.pager-controls {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 0.28rem !important;
  justify-self: center;
}
.pager-btn {
  display: inline-grid !important;
  place-items: center !important;
  min-width: 2rem !important;
  height: 2rem !important;
  padding: 0 0.45rem !important;
  border-radius: 8px !important;
  border: 1px solid var(--line, #e2e8f0) !important;
  background: #fff !important;
  color: var(--ink, #0f172a) !important;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}
.pager-btn:hover {
  background: var(--bg, #f8fafc) !important;
  color: var(--ink, #0f172a) !important;
  text-decoration: none !important;
  border-color: var(--line-strong, #cbd5e1) !important;
}
.pager-btn.is-current {
  background: var(--accent, #FF4D1A) !important;
  border-color: transparent !important;
  color: #fff !important;
  pointer-events: none;
}
.pager-btn.is-disabled,
.pager-btn[aria-disabled="true"] {
  opacity: 0.35 !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
}
.pager-ellipsis {
  min-width: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  user-select: none;
}
.pager-size {
  margin: 0 !important;
  justify-self: end;
}
.pager-size label {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  font-size: 0.84rem !important;
  color: var(--muted) !important;
  margin: 0 !important;
}
.pager-size select {
  min-height: 2rem !important;
  padding: 0.2rem 0.55rem !important;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  border: 1px solid var(--line, #e2e8f0) !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: var(--ink, #0f172a) !important;
}
.btn.is-disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}
@media (max-width: 720px) {
  .pager {
    grid-template-columns: 1fr !important;
    justify-items: center;
    text-align: center;
    gap: 0.65rem;
  }
  .pager-meta,
  .pager-controls,
  .pager-size { justify-self: center; }
}

/* ===== Redesign pass: spacing + responsive polish ===== */
.list-pane.soft-card,
.editor-pane.soft-card,
.panel.soft-card { padding: var(--space-5); }
.soft-card.panel-pad,
.panel-pad { padding: var(--space-5); }
.field { display: block; margin-bottom: var(--space-3); }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.stack-form input:not([type="checkbox"]):not([type="radio"]),
.stack-form select,
.stack-form textarea,
.rule-form input:not([type="checkbox"]):not([type="radio"]),
.rule-form select,
.rule-form textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg);
}
.field input:focus,
.stack-form input:focus,
.rule-form input:focus,
.field textarea:focus,
.stack-form textarea:focus {
  outline: none;
  border-color: rgba(255, 77, 26, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 77, 26, 0.12);
  background: #fff;
}
.hero.compact { margin-bottom: var(--space-5); }
.hero .eyebrow { color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 0.35rem; }
.hero h1 { font-family: var(--display); margin: 0; }
.hero .lede { color: var(--muted); margin: 0.4rem 0 0; max-width: 54ch; }
.channel-card { padding: var(--space-4); }
.tutorial-card { padding: var(--space-5); }
@media (max-width: 640px) {
  .page-head { gap: var(--space-3); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .topbar-actions .user-chip { display: none; }
  .inventory-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .tutorial-grid { grid-template-columns: 1fr; }
}
@media (min-width: 641px) and (max-width: 980px) {
  .inventory-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Minimal pass: inventory menu, chat shell, section copilot, tutorial ===== */
.inv-more { position: relative; }
.inv-more > summary {
  list-style: none;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
}
.inv-more > summary::-webkit-details-marker { display: none; }
.inv-more > summary:hover { color: var(--ink); background: var(--bg); }
.inv-more[open] > summary { color: var(--ink); border-color: var(--ink); }
.inv-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.inv-menu a,
.inv-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
.inv-menu a:hover,
.inv-menu button:hover { background: var(--bg); text-decoration: none; }
.inv-menu .danger { color: var(--danger); }
.inv-card-actions { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; }

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-toolbar-actions { display: flex; align-items: center; gap: 0.35rem; }
.chat-log-min {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-empty-min {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 28ch;
}
.chat-empty-min p { margin: 0 0 0.75rem; }
.composer-min {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer-min textarea {
  flex: 1;
  min-height: 2.75rem;
  max-height: 8rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font: inherit;
  background: var(--bg);
}
.composer-min textarea:focus {
  outline: none;
  border-color: rgba(255, 77, 26, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 77, 26, 0.12);
  background: #fff;
}

.section-copilot.is-collapsed .section-copilot-body { display: none; }
.section-copilot .section-copilot-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}
.section-copilot.is-collapsed {
  padding: var(--space-3);
  align-self: start;
}
.section-with-copilot {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: var(--space-4);
  align-items: stretch;
}
@media (max-width: 980px) {
  .section-with-copilot { grid-template-columns: 1fr; }
  .chat-shell-min.is-session-open { grid-template-columns: 1fr; }
}

.tutorial-list {
  list-style: none;
  counter-reset: tut;
  margin-block: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.tutorial-list > li {
  counter-increment: tut;
  position: relative;
  padding-left: 2.75rem;
}
.tutorial-list > li::before {
  content: counter(tut);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tutorial-list strong { display: block; margin-bottom: 0.2rem; }
.tutorial-list p { margin: 0; }

.inbox-filter {
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  border: 1px solid var(--line) !important;
  background: var(--surface) !important;
  color: var(--muted) !important;
}
.inbox-filter.is-active {
  background: var(--bg) !important;
  color: var(--ink) !important;
  border-color: var(--ink) !important;
}

.pill-navy, .pill-ok, .pill-muted, .status-pill, .soft-badge, .tag {
  display: inline-flex !important;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  background: var(--bg) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}
.page-ico { color: var(--muted) !important; }
.page-ico svg { stroke: var(--muted) !important; }

/* ===== Inventory ? menu + Chat shell (class names from templates) ===== */
.inv-card {
  min-height: 0 !important;
  padding: 0.85rem 1rem !important;
  box-shadow: none !important;
  gap: 0.45rem !important;
}
.inv-card:hover {
  border-color: var(--line-strong) !important;
  transform: none !important;
}
.inv-menu-wrap { position: relative; }
.inv-menu-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.inv-menu-btn:hover,
.inv-menu-wrap.is-open .inv-menu-btn {
  color: var(--ink);
  border-color: var(--ink);
}
.inv-menu-dropdown,
.chat-overflow-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 10.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.25rem;
  flex-direction: column;
}
.inv-menu-wrap.is-open .inv-menu-dropdown,
.chat-overflow.is-open .chat-overflow-menu {
  display: flex;
}
.inv-menu-dropdown a,
.inv-menu-dropdown button,
.chat-overflow-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
.inv-menu-dropdown a:hover,
.inv-menu-dropdown button:hover,
.chat-overflow-menu button:hover {
  background: var(--bg);
  text-decoration: none;
}
.inv-menu-dropdown .danger,
.chat-overflow-menu .danger { color: var(--danger); }
.inv-menu-dropdown form { margin: 0; }

.chat-shell-min {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: none;
}
.chat-shell-min.is-session-open {
  grid-template-columns: minmax(240px, 300px) 1fr;
}
.chat-session-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow: auto;
  max-height: var(--workbench-h);
}
.chat-shell-min.is-session-open .chat-session-panel { display: flex; }
.chat-main-min {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.chat-overflow { position: relative; }
.chat-main-min .chat-log {
  flex: 1;
  overflow: auto;
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: var(--surface);
}
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 28ch;
}
.chat-empty p { margin: 0; }
.chat-main-min .composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  align-items: flex-end;
}
.chat-main-min .composer textarea {
  flex: 1;
  min-height: 2.6rem;
  max-height: 8rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font: inherit;
  background: var(--bg);
}
.chat-main-min .composer textarea:focus {
  outline: none;
  border-color: rgba(255, 77, 26, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 77, 26, 0.12);
  background: #fff;
}
.composer-hint {
  margin: 0;
  padding: 0 1rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.run-log-panel-min { margin-top: var(--space-2); }
.chip-active, .chip-error {
  background: var(--bg) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
}
.chip-error { color: var(--danger) !important; border-color: #f0d0c8 !important; }

.copilot-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: 0.92rem;
}
.copilot-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
}
.copilot-step-pill strong {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface);
}

.status-pill,
.badge,
.badge-active,
.badge-channel,
.badge-admin {
  background: var(--bg) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  border-radius: var(--radius-sm) !important;
}
.brand-mark {
  background: var(--accent) !important;
  background-image: none !important;
  box-shadow: none !important;
}
.login-card .btn { border-radius: var(--radius-sm) !important; }
.btn-primary,
.btn-primary.btn-soft {
  box-shadow: none !important;
  background-image: none !important;
}

@media (max-width: 980px) {
  .chat-shell-min.is-session-open { grid-template-columns: 1fr; }
  .chat-session-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }
}

/* ===== Shell: breadcrumb + agent nav group ===== */
.top-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.top-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.top-breadcrumb a:hover { color: var(--ink); }
.top-breadcrumb .sep { color: var(--line-strong); }
.top-breadcrumb .current { color: var(--ink); font-weight: 600; }

.nav-agent-group { margin-top: 0.25rem; }
.nav-agent-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.nav-agent-toggle:hover { color: var(--ink); background: var(--bg); }
.nav-agent-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 1rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.nav-agent-group.is-open .nav-agent-chevron { transform: rotate(90deg); }
.nav-agent-items { display: none; flex-direction: column; gap: 0.15rem; }
.nav-agent-group.is-open .nav-agent-items { display: flex; }

.user-chip {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

.pill-accent,
a.pill-accent,
a.pill-muted {
  background: var(--bg) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: none !important;
  text-decoration: none;
  padding: 0.2rem 0.55rem !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
}
a.pill-accent:hover,
a.pill-muted:hover { color: var(--ink) !important; border-color: var(--ink) !important; }

/* Chat: keep composer visible on small viewports */
@media (max-width: 980px) {
  .chat-shell-min,
  .chat-main-min {
    min-height: var(--workbench-h) !important;
  }
  .chat-session-panel { max-height: none; }
  .page-head.compact .subtitle { display: none; }
}
/* ===== Loading modal (skeleton, flat) ===== */
body.g3n-loading-open { overflow: hidden; }
.g3n-loading {
  position: fixed;
  inset: 0;
  z-index: var(--z-loading);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(2px);
}
.g3n-loading[hidden] { display: none !important; }
.g3n-loading-card {
  width: min(320px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  padding: 1.35rem 1.4rem 1.25rem;
  text-align: left;
}
.g3n-loading-skel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.g3n-skel {
  display: block;
  height: 0.55rem;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-soft) 0%, #e8edf3 45%, var(--bg-soft) 90%);
  background-size: 200% 100%;
  animation: g3nSkel 1.15s ease-in-out infinite;
}
.g3n-skel-lg { width: 72%; height: 0.7rem; }
.g3n-skel-sm { width: 42%; }
.g3n-loading-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}
.g3n-loading-sub {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}
@keyframes g3nSkel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.rules-create-sticky { border-left: 3px solid var(--line-strong); }

.soft-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin: 0.5rem 0 0.75rem;
}
.soft-fieldset legend {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 0.35rem;
}
.soft-fieldset .chk {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 0;
  font-size: 0.86rem;
  font-weight: 500;
}
.docs-article h2 {
  margin: 1.5rem 0 0.65rem;
  font-size: 1.05rem;
}
.docs-article h2:first-child { margin-top: 0; }
.docs-article h3 {
  margin: 1.15rem 0 0.45rem;
  font-size: 0.95rem;
}
.docs-article p { margin: 0.35rem 0 0.7rem; }
.docs-article code {
  font-size: 0.86em;
}
.docs-article ol, .docs-article ul { margin: 0.35rem 0 0.75rem; padding-left: 1.25rem; }
.docs-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  overflow: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.5rem 0 1rem;
}
.docs-table th, .docs-table td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.docs-copy-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 0.65rem;
}

/* ===== Live chat WhatsApp Web ===== */
.wa-shell {
  display: flex;
  flex-direction: column;
  min-height: var(--workbench-h);
  overflow: hidden;
  padding: 0;
}
.wa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.wa-toolbar-left,
.wa-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}
.wa-label { font-size: 0.85rem; color: var(--muted); }
.wa-select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  background: #fff;
  min-width: 180px;
}
.wa-conn {
  font-size: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
}
.wa-conn-ok, .wa-conn-connected { background: #e8f7ef; color: #0f7a45; }
.wa-conn-warn, .wa-conn-disconnected { background: #fff4e5; color: #9a6700; }
.wa-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  cursor: pointer;
  user-select: none;
}
.wa-whitelist-panel {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.wa-whitelist-panel textarea {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  resize: vertical;
}
.wa-whitelist-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.wa-split {
  display: grid;
  grid-template-columns: minmax(260px, 34%) 1fr;
  flex: 1;
  min-height: 0;
}
.wa-list-col {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
}
.wa-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--muted);
}
.wa-list-count {
  background: var(--bg);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
}
.wa-chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}
.wa-chat-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.wa-chat-item {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}
.wa-chat-item:hover,
.wa-chat-item.is-active { background: var(--bg-soft); }
.wa-chat-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  align-items: start;
}
.wa-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  flex-shrink: 0;
}
.wa-avatar-sm { width: 44px; height: 44px; }
.wa-chat-meta { min-width: 0; }
.wa-chat-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.wa-chat-top strong {
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-chat-time { font-size: 0.78rem; color: var(--muted); flex-shrink: 0; }
.wa-chat-preview {
  font-size: 0.88rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.15rem;
}
.wa-badge-human {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: #e8f0ff;
  color: #1d4ed8;
  vertical-align: middle;
}
.wa-thread-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #e5ddd5;
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 18px 18px;
}
.wa-thread-empty {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  gap: 0.35rem;
  padding: 2rem;
}
.wa-thread-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.wa-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.wa-thread-contact {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.wa-thread-contact strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-thread-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}
.wa-control-toggle { flex-shrink: 0; }
.wa-banner {
  padding: 0.55rem 1rem;
  background: #fff8e6;
  border-bottom: 1px solid #f0dfa0;
  color: #7a5b00;
  font-size: 0.88rem;
}
.wa-messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.wa-bubble {
  max-width: min(78%, 560px);
  padding: 0.55rem 0.75rem 0.35rem;
  border-radius: 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 0.92rem;
}
.wa-bubble-in {
  align-self: flex-start;
  background: #fff;
  border-bottom-left-radius: 3px;
}
.wa-bubble-bot {
  align-self: flex-end;
  background: #dcf8c6;
  border-bottom-right-radius: 3px;
}
.wa-bubble-operator {
  align-self: flex-end;
  background: #d9ecff;
  border-bottom-right-radius: 3px;
}
.wa-bubble-label {
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.wa-bubble-time {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  margin-top: 0.2rem;
}
.wa-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  align-items: end;
  padding: 0.65rem 0.85rem;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
}
.wa-composer textarea {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  background: #fff;
}

/* Desktop operating-console foundation */
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid color-mix(in srgb, #295db8 38%, transparent);
  outline-offset: 2px;
}
.page-header { display:flex; align-items:flex-start; justify-content:space-between; gap:1.5rem; margin-bottom:1.5rem; }
.page-header h1 { margin:0; font-family:var(--display); color:#17233b; letter-spacing:-.025em; }
.page-header p { max-width:80ch; margin:.4rem 0 0; color:var(--muted); }
.page-header__actions,.action-bar { display:flex; align-items:center; justify-content:flex-end; gap:.6rem; flex-wrap:wrap; }
.inline-notice { display:grid; gap:.2rem; padding:.85rem 1rem; border:1px solid #b9cce9; border-left:4px solid #295db8; border-radius:var(--radius); background:#f3f7fd; color:#17233b; }
.inline-notice--error { border-color:#fecdd3; border-left-color:var(--danger); background:var(--danger-soft); }
.inline-notice--success { border-color:#a7f3d0; border-left-color:var(--ok); background:var(--ok-soft); }
.help-text { max-width:80ch; margin:.35rem 0 0; color:var(--muted); font-size:.82rem; line-height:1.45; }
.status-badge { display:inline-flex; align-items:center; min-height:26px; padding:.15rem .55rem; border:1px solid var(--line); border-radius:999px; background:var(--bg-soft); font-size:.75rem; font-weight:700; }
.status-badge--success { color:var(--ok); background:var(--ok-soft); border-color:#a7f3d0; }
.status-badge--danger { color:var(--danger); background:var(--danger-soft); border-color:#fecdd3; }
.empty-state { display:grid; justify-items:start; gap:.65rem; padding:clamp(1.5rem,4vw,3rem); border:1px dashed var(--line-strong); border-radius:var(--radius); background:var(--surface); }
.empty-state :is(h2,p) { margin:0; }
.switch-field { display:grid; grid-template-columns:auto minmax(0,1fr); gap:.7rem; align-items:start; min-height:40px; margin-bottom:.75rem; cursor:pointer; position:relative; }
.switch-field input { position:absolute; inset:0; width:100%; height:100%; margin:0; opacity:0; pointer-events:none; }
.switch-field__control { display:inline-block; flex-shrink:0; width:42px; height:24px; margin-top:2px; border:1px solid var(--line-strong); border-radius:99px; background:#cbd5e1; position:relative; transition:.15s; }
.switch-field__control::after { content:""; position:absolute; width:18px; height:18px; left:2px; top:2px; border-radius:50%; background:#fff; box-shadow:var(--shadow); transition:.15s; }
.switch-field input:checked + .switch-field__control { background:#295db8; border-color:#295db8; }
.switch-field input:checked + .switch-field__control::after { transform:translateX(18px); }
.switch-field input:focus-visible + .switch-field__control { outline:3px solid color-mix(in srgb,#295db8 38%,transparent); outline-offset:2px; }
.switch-field small { display:block; margin-top:.2rem; color:var(--muted); font-weight:400; }
.disclosure { border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.disclosure summary { min-height:40px; padding:.7rem 1rem; cursor:pointer; font-weight:700; }
.disclosure__body { padding:0 1rem 1rem; }
.section-header { margin-bottom:1rem; }.section-header :is(h2,p) { margin:0; }.section-header p { margin-top:.3rem; max-width:80ch; color:var(--muted); }
.form-field { display:grid; gap:.35rem; }.form-field > span,.checkbox-group legend,.scope-selector legend { font-weight:700; }
.checkbox-group,.scope-selector { min-width:0; margin:0; padding:0; border:0; }
.checkbox-group__items { display:grid; gap:.4rem; margin-top:.75rem; max-height:320px; overflow:auto; }
.scope-selector { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.6rem; }
.scope-selector legend { grid-column:1/-1; }.scope-selector label { display:flex; align-items:center; gap:.5rem; min-height:40px; padding:.5rem; border:1px solid var(--line); border-radius:var(--radius-sm); }
.data-table-wrap { max-width:100%; overflow:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.data-table { width:100%; border-collapse:collapse; }.data-table th { position:sticky; top:0; z-index:var(--z-sticky); background:var(--bg-soft); text-align:left; }.data-table :is(th,td) { padding:.7rem .8rem; border-bottom:1px solid var(--line); }
.drawer[hidden] { display:none !important; }.drawer { position:fixed; z-index:var(--z-drawer); inset:var(--topbar-h) 0 0 auto; width:min(520px,42vw); padding:1.25rem; overflow:auto; border-left:1px solid var(--line); background:var(--surface); box-shadow:var(--shadow-modal); }.drawer > header { display:flex; align-items:center; justify-content:space-between; gap:1rem; }.drawer > header h2 { margin:0; }
.is-loading { position:relative; pointer-events:none; opacity:.72; }.is-loading::after { content:attr(data-loading-label); position:absolute; inset:auto 1rem 1rem auto; padding:.4rem .65rem; border-radius:var(--radius-sm); background:#17233b; color:#fff; font-size:.78rem; }
.code-block { min-width:0; overflow:hidden; border:1px solid var(--line); border-radius:var(--radius); background:#111827; color:#e5edf8; }
.code-block__head { display:flex; align-items:center; justify-content:space-between; padding:.5rem .75rem; background:#17233b; }
.code-block pre { overflow:auto; margin:0; padding:1rem; }
.toast-region { position:fixed; z-index:var(--z-toast); top:calc(var(--topbar-h) + 1rem); right:1rem; display:grid; gap:.6rem; width:min(420px,calc(100vw - 2rem)); pointer-events:none; }
.toast { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:.75rem; padding:.85rem 1rem; border:1px solid #b9cce9; border-left:4px solid #295db8; border-radius:var(--radius); background:#fff; box-shadow:var(--shadow-modal); pointer-events:auto; }
.toast--error { border-left-color:var(--danger); }.toast--success { border-left-color:var(--ok); }
.toast p { margin:0; overflow-wrap:anywhere; }.toast__close { border:0; background:transparent; font:inherit; font-size:1.25rem; line-height:1; cursor:pointer; }
.confirm-panel[hidden] { display:none !important; }
.confirm-panel { position:fixed; inset:0; z-index:var(--z-drawer); display:grid; grid-template-columns:minmax(0,1fr) minmax(360px,460px); }
.confirm-panel__backdrop { position:absolute; inset:0; z-index:-1; width:100%; height:100%; border:0; background:rgba(15,23,42,.48); cursor:default; }
.confirm-panel__surface { grid-column:2; display:flex; flex-direction:column; align-self:stretch; padding:clamp(1.5rem,3vw,2.25rem); background:var(--surface); box-shadow:var(--shadow-modal); overflow:auto; }
.confirm-panel__eyebrow { color:var(--danger); font-size:.75rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.confirm-panel h2 { margin:.55rem 0; font-family:var(--display); }.confirm-panel p { color:var(--muted); line-height:1.55; }
.confirm-panel__actions { display:flex; justify-content:flex-end; gap:.6rem; margin-top:auto; padding-top:2rem; }
body.confirm-panel-open { overflow:hidden; }
.form-dialog[hidden] { display: none !important; }
.form-dialog {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  display: grid; place-items: center; padding: 1.5rem;
}
.form-dialog__backdrop {
  position: absolute; inset: 0; z-index: -1;
  background: rgba(15, 23, 42, .48); border: 0; cursor: default;
}
.form-dialog__surface {
  width: min(640px, 100%); max-height: calc(100dvh - 3rem); overflow: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-modal);
  padding: clamp(1.25rem, 3vw, 2rem); display: flex; flex-direction: column; gap: 1rem;
}
.form-dialog__surface.is-wide { width: min(760px, 100%); }
.form-dialog__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.form-dialog__head h2 { margin: 0; font-family: var(--display); }
.form-dialog__actions { display: flex; justify-content: flex-end; gap: .6rem; }
body.form-dialog-open { overflow: hidden; }
.context-rail { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1px; overflow:hidden; border:1px solid var(--line); border-left:4px solid #295db8; border-radius:var(--radius); background:var(--line); }
.context-rail > * { min-width:0; padding:.8rem 1rem; background:var(--surface); display:flex; flex-direction:column; gap:.2rem; }
.context-rail small { display:block; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-size:.72rem; }
.context-rail strong { display:block; font-size:.95rem; font-weight:600; line-height:1.35; }
.flush { margin:0; }.flush-top { margin-top:0; }.action-bar--start { justify-content:flex-start; }
.environments-grid { display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:1rem; align-items:stretch; }
.environments-list,.audit-list { display:flex; flex-direction:column; }
.rail-list-body { flex:1 1 auto; min-height:0; max-height:22rem; overflow-y:auto; }
.credentials-center { grid-column:span 9; align-self:start; }.cli-context { grid-column:span 3; align-self:start; }.audit-list { grid-column:1/-1; }.environments-list { grid-column:1/-1; }
.audit-list .rail-list-body { height:26rem; max-height:26rem; }
.key-create-form { margin-bottom:var(--space-5); }
.scope-selector label span { min-width:0; }.scope-selector label small { display:block; margin-top:.2rem; color:var(--muted); line-height:1.35; }.scope-selector--permissions { grid-template-columns:repeat(3,minmax(0,1fr)); }
.agent-picker { border-top:1px solid var(--line); padding-top:.9rem; }.agent-picker__toolbar { display:grid; grid-template-columns:auto minmax(180px,1fr) auto; align-items:center; gap:.65rem; }.agent-picker__list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.45rem; max-height:260px; overflow:auto; margin-top:.75rem; }.check-card { display:grid; grid-template-columns:auto minmax(0,1fr); gap:.55rem; min-height:44px; padding:.55rem; border:1px solid var(--line); border-radius:var(--radius-sm); background:#fff; }.check-card small { display:block; color:var(--muted); }
.one-time-secret { gap:.75rem; }.secret-value { display:block; max-width:100%; padding:.75rem; overflow:auto; border-radius:var(--radius-sm); background:#17233b; color:#fff; }.cli-builder { display:grid; gap:.7rem; margin-top:.75rem; }.cli-preview { max-width:100%; max-height:300px; margin:0; padding:1rem; overflow:auto; border-radius:var(--radius); background:#111827; color:#e5edf8; white-space:pre-wrap; overflow-wrap:anywhere; }
.key-table small { display:block; margin-top:.25rem; color:var(--muted); }.key-actions { display:flex; gap:.4rem; flex-wrap:wrap; }.key-scope-editor { margin-top:.5rem; min-width:220px; border:0; background:transparent; }.key-scope-editor summary { display:inline-flex; align-items:center; width:fit-content; min-height:34px; padding:.35rem .6rem; font-size:.8rem; font-weight:600; border-radius:var(--radius-sm); color:var(--muted); }.key-scope-editor summary:hover { background:var(--bg-soft); color:var(--ink); }.key-scope-editor[open] summary { color:var(--ink); }.key-scope-editor .disclosure__body { padding:.75rem 0 0; }.steps-list { display:grid; gap:.75rem; padding-left:1.25rem; color:var(--muted); }.env-row__identity,.audit-row__body { flex:1; min-width:140px; }.env-select { width:auto; min-width:120px; margin:0; }
.section-spaced { width:100%; margin-top:var(--space-6); }.section-note { margin-top:var(--space-3); }.form-narrow { max-width:640px; }.compact-empty { padding:var(--space-5); }.field-help { display:block; margin-top:.2rem; color:var(--muted); font-size:.78rem; font-weight:400; }.list-create-form { margin-top:var(--space-4); padding-top:var(--space-4); border-top:1px solid var(--line); }.row-meta { margin:.25rem 0 0; }.card-title-actions { display:flex; justify-content:space-between; gap:.75rem; align-items:center; margin-bottom:var(--space-3); }.card-title { margin:0; font-size:1.05rem; }.field-title { margin:0 0 .25rem; font-size:.9rem; font-weight:700; }.table-id { font-size:.8rem; }.table-date { white-space:nowrap; font-size:.78rem; }.debug-meta { font-size:.75rem; }.section-title--sm { font-size:.9rem; }.inline-actions { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }.compact-check { display:inline-flex; align-items:center; gap:.35rem; font-size:.82rem; }.field-grow { flex:1; }.field-full { max-width:100%; }.copilot-generate-form { display:flex; flex:1; flex-direction:column; gap:var(--space-3); margin-top:var(--space-4); }
.check,.chk { min-height:40px; padding:.45rem .55rem; border-radius:var(--radius-sm); }.check { display:flex; align-items:center; gap:.5rem; }.check input,.chk input { flex-shrink:0; width:18px; height:18px; accent-color:#295db8; }.mcp-check-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.4rem; max-height:clamp(280px,45vh,560px); overflow:auto; padding:.35rem; border:1px solid var(--line); border-radius:var(--radius); }.mcp-check-list .check { margin:0; border:1px solid transparent; }.mcp-check-list .check:hover { border-color:var(--line); background:var(--bg-soft); }
.mcp-server-name { font-weight: 800; font-size: 1.05rem; font-family: var(--display); }
.panel-pad > .section-title:first-child { margin-bottom: .65rem; }
.mcp-tool-label { display:flex; align-items:center; gap:.35rem; min-width:0; flex:1; }
.mcp-tool-name { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; word-break:normal; }
.btn-help { width:26px; height:26px; flex:0 0 26px; color:var(--muted); }
.btn-help:hover { color:var(--blue); background:var(--blue-soft); }
.kb-docs-available { margin:0 0 var(--space-3); }
.rules-section__summary { cursor:pointer; font-family:var(--display); font-size:1.05rem; font-weight:700; }
.rules-section__body { margin-top:var(--space-4); }
.picker-search { display:grid; gap:.35rem; margin:.6rem 0; font-size:.82rem; font-weight:700; }
.section-with-copilot,.section-main { min-width:0; }.section-copilot { position:sticky; top:calc(var(--topbar-h) + 1rem); z-index:var(--z-sticky); max-height:var(--workbench-h); overflow:auto; }.inbox-split { grid-template-columns:minmax(0,5fr) minmax(0,7fr); height:100%; }.inbox-table-wrap { overflow:auto; }.inbox-table thead th { position:sticky; top:0; z-index:var(--z-sticky); }.copilot-split,.wa-shell { height:100%; }.chat-composer,.wa-composer { position:sticky; bottom:0; z-index:var(--z-sticky); }.inv-menu-dropdown { z-index:var(--z-dropdown); max-width:min(360px,calc(100vw - 2rem)); }
.section-bottom { margin-bottom:var(--space-5); }.table-flat { border-radius:var(--radius-sm); box-shadow:none; }.section-copilot-toggle { width:100%; padding:0; color:var(--ink); font-size:.95rem; letter-spacing:0; text-transform:none; }.env-row--plain { padding:.55rem 0; border:0; flex-wrap:nowrap; }.env-row--plain .grow { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.env-row__actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:.4rem; flex-shrink:0; }.grow { flex:1; }
@media (max-width:1366px) { .credentials-center { grid-column:span 8; }.cli-context { grid-column:span 4; }.scope-selector--permissions { grid-template-columns:1fr; }.key-table th:nth-child(2),.key-table td:nth-child(2) { display:none; } }

@media (min-width: 1280px) {
  .content { padding-inline:clamp(1.25rem,2.2vw,2.5rem); }
  .workbench-grid { display:grid; grid-template-columns:clamp(260px,22vw,360px) minmax(0,1fr); }
}
@media (min-width: 1680px) {
  :root { --sidebar-w:260px; }
  .content { padding-inline:clamp(2rem,3vw,4rem); }
  .workbench-grid { grid-template-columns:360px minmax(0,1fr); }
}
@media (min-width: 1280px) {
  .editor-workbench-grid { grid-template-columns:clamp(400px,30vw,520px) minmax(0,1fr); }
}
.editor-workbench-grid { margin-top:0; }
.editor-workbench-grid > .editor-pane { margin-top:0; }
.editor-key-link { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.skills-workbench-grid { padding-bottom:var(--space-6); }
@media (max-width: 1366px) {
  :root { --sidebar-w:220px; --content-pad-x:1rem; }
  .sidebar { padding-inline:.75rem; }
  .nav-item { padding-inline:.65rem; }
  .context-rail { grid-template-columns:1fr; }
  .inbox-split { grid-template-columns:minmax(0,55fr) minmax(0,45fr); }
  .mcp-check-list,.agent-picker__list { grid-template-columns:1fr; }
  .section-with-copilot { grid-template-columns:minmax(0,1fr) minmax(280px,34%); }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior:auto !important; transition-duration:.01ms !important; animation-duration:.01ms !important; } }
@media (max-width: 980px) {
  .wa-split { grid-template-columns: 1fr; }
  .wa-list-col { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
  .wa-thread-col { min-height: 420px; }
}

/* Feature opt-in gates (Feedback / Logs) + spacing polish */
.feature-gate { display: flex; flex-direction: column; gap: var(--space-4); }
.feature-gate--off {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fff7ed 0%, var(--surface) 48%);
}
.feature-gate--on {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #ecfdf5 0%, var(--surface) 48%);
}
.feature-gate__form { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.feature-gate__switch { margin-bottom: 0; }
.feature-gate__extras { margin: 0; }
.feature-gate__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.stack-gap--tight { gap: var(--space-3); }
.crud-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.crud-row__meta { margin: 0; }
.crud-row__form { margin-top: 0.35rem; }
.stack-gap > .banner-warn,
.stack-gap > .toast { margin: 0; }
.data-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.data-table :is(th, td) { vertical-align: top; }
.graph-toolbar__switch { margin: 0 0 0 auto; }
@media (max-width: 720px) {
  .feature-gate__actions { width: 100%; }
  .graph-toolbar__switch { margin-left: 0; width: 100%; }
}
