:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #151a22;
  --panel-2: #1c2330;
  --text: #edf2f7;
  --muted: #97a3b6;
  --line: #2a3342;
  --accent: #51d59b;
  --warn: #f5c15c;
  --bad: #ff6b6b;
  --blue: #78a6ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, .button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #06110c;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  padding: 10px 14px;
}
input, select {
  background: #0f141c;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}
label { color: var(--muted); display: grid; gap: 6px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.sidebar {
  background: #0b0e13;
  border-right: 1px solid var(--line);
  bottom: 0;
  left: 0;
  padding: 20px 14px;
  position: fixed;
  top: 0;
  width: 250px;
}
.brand { align-items: center; display: flex; gap: 10px; margin-bottom: 24px; }
.brand span {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #07110c;
  display: inline-flex;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 42px;
}
.nav-link {
  border-radius: 6px;
  color: var(--muted);
  display: block;
  margin: 4px 0;
  padding: 10px 12px;
}
.nav-link.active, .nav-link:hover { background: var(--panel); color: var(--text); }
.account { bottom: 18px; color: var(--muted); display: grid; gap: 4px; left: 16px; position: absolute; right: 16px; }
.account span { color: var(--text); overflow-wrap: anywhere; }
.app-shell { margin-left: 250px; padding: 28px; }
.auth-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}
.auth-card form, .stack-form { display: grid; gap: 14px; }
.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}
.auth-links a { color: var(--accent); font-weight: 700; }
.mark { color: var(--accent); font-size: 13px; font-weight: 900; letter-spacing: .08em; }
.page-head { align-items: center; display: flex; justify-content: space-between; margin-bottom: 20px; }
.page-head h1, .panel h1, .panel h2 { margin: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  overflow: hidden;
  padding: 18px;
}
.panel-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head p { color: var(--muted); margin: 4px 0 0; }
.ops-console {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 280px;
  margin-bottom: 18px;
}
.chat-panel { display: grid; gap: 14px; }
.chat-thread {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
}
.chat-message {
  background: #101720;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}
.chat-message.user { background: #15261f; border-color: rgba(81, 213, 155, .25); }
.chat-message header {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-message header strong { color: var(--text); }
.chat-message p { margin: 0; white-space: normal; }
.action-badge, .attachment-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-compose {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 14px;
}
textarea {
  background: #0f141c;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 130px;
  padding: 10px;
  resize: vertical;
  width: 100%;
}
.agent-rail { display: grid; gap: 18px; align-content: start; }
.chat-history, .agent-list { display: grid; gap: 10px; }
.chat-history h2, .agent-list h2 { margin: 0; }
.new-chat-link, .chat-link {
  background: #111720;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}
.new-chat-link {
  color: var(--accent);
  font-weight: 800;
}
.chat-link strong {
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-link span, .chat-link small, .empty-history { color: var(--muted); }
.active-chat { border-color: rgba(81, 213, 155, .7); box-shadow: inset 3px 0 0 var(--accent); }
.agent-row {
  background: #111720;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}
.agent-row span, .agent-row small { color: var(--muted); }
.agent-row.active-agent { border-color: rgba(81, 213, 155, .7); box-shadow: inset 3px 0 0 var(--accent); }
.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 18px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.metric span { color: var(--muted); display: block; text-transform: capitalize; }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.agent-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.agent-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 16px;
}
.agent-card h3 { margin: 0; }
.agent-card p { color: var(--muted); margin: 0; }
.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  justify-self: start;
  padding: 4px 8px;
}
.status.APPROVED, .status.COMPLETED, .status.IDLE { color: var(--accent); }
.status.WORKING, .status.PLANNING, .status.QUEUED { color: var(--blue); }
.status.BLOCKED, .status.FAILED, .status.REJECTED { color: var(--bad); }
.detail dl {
  display: grid;
  gap: 10px;
  grid-template-columns: 160px 1fr;
}
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.inline-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr .8fr 1fr 1.2fr auto;
  margin-bottom: 16px;
}
.pipeline {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 18px;
}
.gate {
  background: #111720;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}
.gate.APPROVED { border-color: rgba(81, 213, 155, .6); }
.gate.WORKING { border-color: rgba(120, 166, 255, .6); }
.gate.PENDING { opacity: .72; }
.flash {
  background: rgba(81, 213, 155, .14);
  border: 1px solid rgba(81, 213, 155, .4);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}
@media (max-width: 860px) {
  .sidebar { position: static; width: auto; }
  .account { position: static; margin-top: 18px; }
  .app-shell { margin-left: 0; padding: 18px; }
  .inline-form { grid-template-columns: 1fr; }
  .detail dl { grid-template-columns: 1fr; }
  .ops-console { grid-template-columns: 1fr; }
}
