:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65727d;
  --line: #dce3e8;
  --accent: #176b87;
  --accent-2: #bf6b3f;
  --ok: #26805c;
  --wait: #9a6b00;
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #172026;
  color: #f8fafb;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: #20313a;
  font-weight: 800;
  color: #9fd2e4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.note span,
.eyebrow,
.section-head span {
  color: var(--muted);
}

.sidebar .brand p,
.sidebar .note span {
  color: #aebcc5;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item,
#refresh,
#send-chat {
  border: 0;
  cursor: pointer;
}

.nav-item {
  text-align: left;
  padding: 11px 12px;
  color: #dbe5ea;
  background: transparent;
  border-left: 3px solid transparent;
}

.nav-item.active {
  color: #ffffff;
  background: #20313a;
  border-left-color: #9fd2e4;
}

.note {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 12px;
  background: #20313a;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

main {
  min-width: 0;
  padding: 22px;
}

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

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

#refresh,
#send-chat {
  color: #ffffff;
  background: var(--accent);
  padding: 10px 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.agent-card,
.task-card,
.session-item,
.draft-card,
.protocol-meta,
.conversation,
section > .section-head {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.agent-card,
.task-card,
.session-item,
.draft-card,
.protocol-meta {
  border-radius: 8px;
  padding: 14px;
}

.agent-card {
  display: grid;
  gap: 10px;
}

.status {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--wait);
  font-size: 12px;
}

.status.active,
.status.done,
.status.webhook_connected {
  background: var(--ok);
}

.status.in_progress {
  background: var(--accent);
}

.status.pending_webhook {
  background: var(--wait);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

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

.task-card {
  border-left: 4px solid var(--accent);
}

.task-card.pending_review {
  border-left-color: var(--accent-2);
}

.task-card.not_started {
  border-left-color: #9aa8b2;
}

.task-card h4,
.session-item h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 0.7fr);
  gap: 10px;
  margin-bottom: 12px;
}

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

.conversation {
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 156px);
  overflow: auto;
}

.message {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #f7f9fa;
  border: 1px solid #e8eef2;
  white-space: pre-wrap;
}

.message.assistant {
  background: #eef7f9;
  border-color: #cfe7ef;
}

.message .byline {
  color: var(--muted);
  font-size: 12px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #172026;
  color: #eff8fb;
  border-radius: 8px;
  padding: 16px;
  min-height: 420px;
  overflow: auto;
}

.draft-card textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
}

.draft-actions {
  margin-top: 10px;
  color: var(--muted);
}

.composer {
  display: grid;
  gap: 14px;
  max-width: 920px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.composer textarea {
  min-height: 150px;
  resize: vertical;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#send-chat:disabled {
  cursor: wait;
  opacity: 0.65;
}

#send-status {
  color: var(--muted);
  font-size: 13px;
}

.send-log {
  display: grid;
  gap: 10px;
  max-width: 920px;
  margin-top: 14px;
}

.send-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  padding: 12px;
}

.send-row.failed {
  border-left-color: #b23b3b;
}

.send-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.agent-reply {
  margin-top: 10px;
  padding: 10px 12px;
  background: #eef7f9;
  border: 1px solid #cfe7ef;
  border-radius: 8px;
  white-space: pre-wrap;
}

.send-row pre {
  min-height: 0;
  margin: 10px 0 0;
  padding: 10px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .shell,
  .split,
  .agent-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}
