:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --panel: #ffffff;
  --ink: #1a1f29;
  --muted: #667085;
  --line: #d9dee8;
  --brand: #111827;
  --green: #0f7a5a;
  --blue: #2459a9;
  --amber: #a76619;
  --red: #b42318;
  --shadow: 0 12px 36px rgba(24, 34, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 38px;
}

button.secondary {
  background: #eef1f6;
  color: var(--ink);
}

button.danger {
  background: #f3d6d0;
  color: #8f1f16;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.small {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

a.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  text-decoration: none;
}

a.button-link.secondary {
  background: #eef1f6;
  color: var(--ink);
}

a.button-link.small {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.loading {
  padding: 40px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
}

.auth-copy {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #111827;
  color: white;
}

.auth-copy h1 {
  max-width: 820px;
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.95;
  margin: 36px 0 22px;
  letter-spacing: 0;
}

.auth-copy p {
  max-width: 650px;
  color: #d5d9e1;
  font-size: 18px;
  line-height: 1.6;
}

.auth-panel {
  padding: 56px;
  display: flex;
  align-items: center;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  background: #ece7de;
  border-radius: 6px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tabs button {
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.active {
  background: white;
  color: var(--ink);
}

.form {
  display: grid;
  gap: 12px;
}

.demo-line {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.invite-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.invite-summary div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 10px 12px;
}

.invite-summary span {
  color: var(--muted);
  font-size: 12px;
}

.invite-summary strong {
  overflow-wrap: anywhere;
}

.invite-login-link {
  width: 100%;
  margin-top: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: #171b22;
  color: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workspace {
  color: #cfd5df;
  font-size: 13px;
  line-height: 1.4;
}

.workspace-switch {
  display: grid;
  gap: 8px;
}

.workspace-switch span {
  color: #cfd5df;
}

.workspace-switch select {
  background: #242a35;
  color: white;
  border-color: #343c4a;
  min-height: 34px;
  padding: 7px 9px;
}

.workspace-switch button {
  width: 100%;
}

.nav {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.nav button {
  text-align: left;
  background: transparent;
  color: #d5d9e1;
  border-radius: 6px;
  padding: 10px 12px;
}

.nav button.active,
.nav button:hover {
  background: #242a35;
  color: white;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar .ghost {
  color: white;
  border-color: #343c4a;
}

.main {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(31, 28, 22, 0.04);
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.list.compact {
  margin-top: 10px;
}

.list.compact .row {
  padding: 9px 10px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 28px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef1f6;
  color: var(--ink);
  font-size: 12px;
}

.pill.green {
  background: #dff3eb;
  color: var(--green);
}

.pill.blue {
  background: #e0eaff;
  color: var(--blue);
}

.pill.amber {
  background: #f7ead7;
  color: var(--amber);
}

.pill.red {
  background: #fee4e2;
  color: var(--red);
}

.list {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.row-title {
  font-weight: 650;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions.left {
  justify-content: flex-start;
}

.build-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox-line input {
  width: auto;
}

.api-key-form {
  margin-bottom: 12px;
}

.scope-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkbox-card {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 10px;
  color: var(--ink);
}

.checkbox-card input {
  width: auto;
  margin-top: 3px;
}

.checkbox-card span {
  display: grid;
  gap: 3px;
}

.checkbox-card small {
  color: var(--muted);
  line-height: 1.35;
}

.api-key-scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.task-console {
  align-items: start;
}

.task-create {
  align-self: start;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.task-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.task-status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-meta span {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: white;
  color: var(--muted);
  font-size: 12px;
}

.task-reason,
.task-output {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.task-output {
  color: var(--ink);
  border-left: 3px solid #b9c7e8;
  padding-left: 10px;
}

.page-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-strip a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--ink);
  text-decoration: none;
  background: white;
  font-size: 12px;
}

.page-strip a span {
  color: var(--muted);
}

.compact-list {
  display: grid;
  gap: 6px;
}

.compact-list div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.compact-list span {
  color: var(--muted);
}

.runtime-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-color: #c7d7fe;
  background: #fbfdff;
}

.runtime-strip h2,
.runtime-strip p {
  margin: 0;
}

.runtime-strip p {
  margin-top: 4px;
  color: var(--muted);
}

.live-agent-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 14px;
  align-items: stretch;
  background: #111827;
  border-color: #263244;
  color: #f8fafc;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.16);
}

.live-agent-status {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.live-agent-status h2,
.live-agent-status p {
  margin: 0;
}

.live-agent-status h2 {
  font-size: 16px;
  line-height: 1.25;
}

.live-agent-status p {
  margin-top: 6px;
  color: #d5dce8;
  line-height: 1.45;
  font-size: 13px;
}

.live-agent-kicker {
  margin-bottom: 6px;
  color: #90a4c7;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.live-mood-face {
  min-height: 92px;
  white-space: pre;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #ffd166;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.18;
}

.live-agent-meta,
.live-stream-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.live-agent-meta span,
.live-stream-meta span {
  min-height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  padding: 3px 8px;
  font-size: 11px;
}

.live-stream-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.live-stream-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 54px;
  border: 1px solid #263244;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 10px;
}

.live-stream-dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
}

.live-stream-title {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.live-stream-body {
  margin-top: 4px;
  color: #b8c2d4;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.live-stream-item.blue .live-stream-dot {
  background: #7aa2ff;
  box-shadow: 0 0 0 4px rgba(122, 162, 255, 0.18);
}

.live-stream-item.green .live-stream-dot {
  background: #6ee7b7;
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.18);
}

.live-stream-item.amber .live-stream-dot {
  background: #fbbf24;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18);
}

.live-stream-item.red .live-stream-dot {
  background: #f87171;
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.18);
}

.live-agent-panel .row {
  border-color: #263244;
  background: rgba(255, 255, 255, 0.05);
}

.live-agent-panel .row-sub {
  color: #b8c2d4;
}

.execution-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffefa;
}

.execution-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.execution-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.runtime-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.runtime-grid div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.runtime-grid span {
  color: var(--muted);
  font-size: 12px;
}

.runtime-grid strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tool-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.runtime-tool-list {
  display: grid;
  gap: 8px;
}

.runtime-tool-detail {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.runtime-tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.runtime-tool-meta div {
  grid-template-columns: 88px 1fr;
}

.runtime-tool-meta span {
  overflow-wrap: anywhere;
}

.runtime-output {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--ink);
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.agent {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 14px;
}

.agent-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.agent h3 {
  margin: 0;
}

.agent p {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
  font-size: 13px;
}

.progress {
  height: 7px;
  background: #ece7de;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
}

.usage-bars {
  display: grid;
  gap: 14px;
}

.usage-bar {
  display: grid;
  gap: 8px;
}

.usage-bar > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.usage-bar strong {
  color: var(--ink);
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  align-items: start;
}

.timeline-item > span {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px #dff3eb;
}

.doc-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffefa;
}

.doc-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.chat {
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto;
  height: calc(100vh - 140px);
}

.messages {
  overflow: auto;
  display: grid;
  gap: 10px;
  align-content: start;
  padding-right: 4px;
}

.message {
  max-width: 780px;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.5;
  background: #fffefa;
  border: 1px solid var(--line);
}

.message.user {
  justify-self: end;
  background: #111827;
  color: white;
  border-color: #111827;
}

.message .tools {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message .tools span {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: white;
  color: var(--muted);
}

.message.user .tools {
  color: #d5d9e1;
}

.message-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chat-tool-details {
  margin-top: 8px;
}

.ceo-chat-shell {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  align-items: start;
}

.chat-work-list {
  margin-top: 12px;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.split {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
}

.onboarding-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.onboarding-card {
  display: grid;
  gap: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  background: #ece7de;
  border-radius: 6px;
  padding: 4px;
}

.mode-switch button {
  background: transparent;
  color: var(--muted);
}

.mode-switch button.active {
  background: white;
  color: var(--ink);
}

.mood-card {
  display: grid;
  gap: 14px;
  align-content: start;
  background: #101820;
  color: white;
  border-color: #101820;
}

.mood-card h2,
.mood-card p {
  margin: 0;
}

.mood-card p {
  color: #d5d9e1;
  line-height: 1.5;
}

.mood-face {
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #ffd166;
  background: #17212b;
  border: 1px solid #293442;
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
}

.autonomy-stream {
  display: grid;
  gap: 8px;
}

.autonomy-stream div {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: center;
}

.autonomy-stream strong {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #dff3eb;
  color: var(--green);
}

.autonomy-stream span {
  color: #eef2f7;
  font-size: 13px;
}

.onboarding-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-color: #b9d9c9;
  background: #f7fffb;
}

.onboarding-strip h2,
.onboarding-strip p {
  margin: 0;
}

.onboarding-strip p {
  margin-top: 4px;
  color: var(--muted);
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #171b22;
  color: #f9fafb;
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
}

.code.mini {
  padding: 8px 10px;
  font-size: 11px;
}

.notice {
  border: 1px solid #c7d7fe;
  background: #edf3ff;
  color: #1f3f73;
  padding: 12px;
  border-radius: 8px;
}

.error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

@media (max-width: 900px) {
  .auth-shell,
  .app-shell,
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .field-grid,
  .inline-form,
  .runtime-grid,
  .onboarding-layout,
  .scope-picker,
  .split {
    grid-template-columns: 1fr;
  }

  .auth-copy,
  .auth-panel {
    padding: 28px;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }

  .app-shell {
    display: block;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .chat {
    height: auto;
  }

  .onboarding-strip,
  .runtime-strip,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .task-head {
    grid-template-columns: 1fr;
  }

  .live-agent-panel,
  .live-agent-status {
    grid-template-columns: 1fr;
  }

  .live-mood-face {
    min-height: auto;
  }

  .task-status-stack {
    justify-content: flex-start;
  }
}
