:root {
  --bg: #E9EDF2;
  --bg-soft: #DEE3EA;
  --surface: #ffffff;
  --ink: #1A1C1E;
  --muted: #9A9FA5;
  --line: #E2E6EC;
  --line-strong: #C8CED8;
  --accent: #FF4D1A;
  --accent-soft: #FFE8E0;
  --accent-hover: #E63E0F;
  --navy: #1A1C1E;
  --blue: var(--accent);
  --blue-soft: var(--accent-soft);
  --blue-hover: var(--accent-hover);
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #FF4D1A;
  --warn-soft: #FFF0EB;
  --shadow: 0 18px 40px rgba(26, 28, 30, 0.07);
  --shadow-sm: 0 6px 18px rgba(26, 28, 30, 0.05);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Sora", "Manrope", sans-serif;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 65% 45% at 8% 0%, rgba(255, 77, 26, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 8%, rgba(154, 159, 165, 0.12), transparent 50%),
    var(--bg);
}

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

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

/* Sidebar */
.sidebar {
  background: #F4F6F9;
  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;
  height: 100vh;
  z-index: 40;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-close { display: none; }
.sidebar-pin { display: none; }
.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: 12px;
  background: linear-gradient(145deg, #FF6A33, var(--accent));
  box-shadow: 0 10px 22px rgba(255, 77, 26, 0.35);
  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.68rem;
  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-pill) !important;
  box-shadow: 0 12px 26px rgba(255, 77, 26, 0.32);
}

.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 {
  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.8rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  padding: 1.5rem 1.75rem 2.5rem;
  width: 100%;
  max-width: none;
}
.content > * { width: 100%; max-width: none; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head.compact { margin-bottom: 1rem; }
.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;
}
.subtitle { margin: 0.35rem 0 0; color: var(--muted); line-height: 1.45; }
.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* 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.72rem;
  font-weight: 700;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(255, 77, 26, 0.28);
}
.btn-primary:hover { background: var(--blue-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-soft { border-radius: var(--radius-pill) !important; padding-inline: 1.1rem; }
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #fecdd3;
}
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 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: #b3c7ef; 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.72rem;
  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.78rem;
  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; }
.inv-menu a { font-weight: 600; font-size: 0.78rem; }

.badge {
  font-size: 0.65rem;
  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: calc(100vh - 160px);
  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.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; 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.85rem;
}
.meter { margin-bottom: 0.7rem; }
.meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  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.82rem;
  font-weight: 700;
  color: var(--muted);
}
.motor-nominal.ok { color: var(--ok); }
.motor-nominal.bad { color: var(--danger); }
.debug-line {
  font-size: 0.72rem;
  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.85rem;
}
.run-log-hint {
  margin: 0;
  font-size: 0.75rem;
  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.82rem;
  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.8rem;
  color: var(--ink);
}
.run-step span {
  font-size: 0.75rem;
  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:
    radial-gradient(800px 200px at 100% 0%, rgba(255, 77, 26, 0.05), transparent 50%),
    #fbfcfe;
  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.75rem;
  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.9rem; color: var(--muted); }
.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.8rem;
  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;
}
.hint { color: var(--muted); font-size: 0.85rem; }
.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 {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  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.9rem; }
.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.78rem;
  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.78rem;
  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.75rem;
  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: start;
}
.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: calc(100vh - 5.5rem);
  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.78rem;
  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.72rem;
  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.72rem;
  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.8rem;
  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.75rem; 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.85rem;
  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.9rem;
  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.82rem;
  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; }
  .menu-toggle { display: grid; }
  .sidebar-pin { display: none !important; }
  .sidebar-close { display: grid; }
  .sidebar-backdrop { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 88vw);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1.15rem 1rem 1.25rem;
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .sidebar-backdrop { display: block; }
  .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: 40px; max-width: 180px; }
  .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; }
  .search { max-width: none; order: 3; flex: 1 1 100%; }
  .content { padding: 1rem 1rem 2rem; }
  .channel-cards, .connect-grid { grid-template-columns: 1fr; }
  .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 {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.stack-form input,
.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.85rem; }

/* 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, .banner-err {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.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.78rem; color: var(--muted); }
.status-pill {
  font-size: 0.68rem;
  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.72rem; 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.72rem;
  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;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.sim-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
}
.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.85rem;
  background: var(--bg);
}
.chk { font-size: 0.78rem; display: inline-flex; align-items: center; gap: 0.25rem; color: var(--muted); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  min-height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-ghost.danger { color: var(--danger); }
.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.85rem; 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.72rem; 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: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(255, 77, 26, 0.12), transparent 55%),
    radial-gradient(ellipse 55% 45% at 90% 85%, rgba(154, 159, 165, 0.18), transparent 50%),
    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.85rem; 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.9rem;
  margin-bottom: 1rem;
}
.login-hint { margin-top: 1rem; font-size: 0.8rem; 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; }


/* TWISTY Soft UI extras */
.soft-card,
.settings-card,
.inv-card,
.channel-card,
.connect-card,
.login-card,
.tutorial-card,
.inbox-row,
.qr-panel {
  border: none !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  background: var(--surface) !important;
}
.nav-item { border-radius: var(--radius-pill) !important; }
.nav-item.is-active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  box-shadow: var(--shadow-sm) !important;
}
.btn { border-radius: var(--radius-pill) !important; }
.btn-primary {
  background: var(--accent) !important;
  box-shadow: 0 10px 22px rgba(255, 77, 26, 0.28) !important;
}
.btn-primary:hover { background: var(--accent-hover) !important; }
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.85rem;
  margin: 0.75rem 0 1rem;
}
.metric {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}
.metric strong {
  display: block;
  font-size: 1.45rem;
  font-family: var(--display);
  letter-spacing: -0.03em;
  color: var(--ink);
}
.metric span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
.progress {
  height: 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.45rem;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #FF8A5C);
  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; }
.key-row, .audit-row, .env-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}
.key-row:last-child, .audit-row:last-child, .env-row:last-child { border-bottom: 0; }
.pill-navy {
  background: var(--navy); color: #fff; border-radius: var(--radius-pill);
  padding: 0.22rem 0.6rem; font-size: 0.72rem; font-weight: 700;
}
.pill-accent {
  background: var(--accent); color: #fff; border-radius: var(--radius-pill);
  padding: 0.22rem 0.6rem; font-size: 0.72rem; font-weight: 700;
}
.pill-muted {
  background: var(--bg-soft); color: var(--muted); border-radius: var(--radius-pill);
  padding: 0.22rem 0.6rem; font-size: 0.72rem; font-weight: 700;
}
.pill-ok {
  background: var(--ok-soft); color: #065f46; border-radius: var(--radius-pill);
  padding: 0.22rem 0.6rem; font-size: 0.72rem; font-weight: 700;
}
.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.chat-config, .chat-main, .motor-panel, .run-log-panel, .composer {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  border-color: transparent !important;
}
.tag {
  border-radius: var(--radius-pill) !important;
  background: var(--bg) !important;
  border: none !important;
}
.tutorial-step {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 2px solid var(--accent) !important;
}
.badge-user { background: var(--ok-soft) !important; color: #065f46 !important; }
.badge-dir { background: var(--navy) !important; color: #fff !important; }
.page-ico { color: var(--accent) !important; }
.qr-panel { background: var(--warn-soft) !important; }
.settings-grid { gap: 1.1rem !important; }
.inventory-grid { gap: 1.1rem !important; }

/* Panels + chat bubbles TWISTY */
.panel, .editor-pane, .section-copilot, .graph-panel {
  background: var(--surface) !important;
  border: none !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !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.8rem;
  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-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.8rem;
  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.75rem;
}
.copilot-split {
  display: grid;
  grid-template-columns: 42% 58%;
  gap: 1.1rem;
  width: 100%;
  min-height: calc(100vh - 220px);
  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: 220px; 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.8rem;
  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.82rem;
  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: calc(100vh - 220px);
  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.72rem;
  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;
}
