:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #10b981;
  --accent-hover: #14cc93;
  --link: #58a6ff;
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.18);
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
pre { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; }
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
header .brand { font-weight: 600; font-size: 15px; letter-spacing: 0.01em; }
header nav { flex: 1; display: flex; gap: 4px; }
header nav a {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background-color 0.15s, color 0.15s;
}
header nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
header .session { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); }
main { padding: 20px; }
.page-layout { display: flex; gap: 20px; max-width: 1300px; margin: 0 auto; align-items: flex-start; }
.page-layout main { flex: 1; min-width: 0; }

.lab-panel { width: 280px; flex-shrink: 0; padding: 20px 16px; }
.lab-panel h3 { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.lab-block {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.lab-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 600; font-size: 13px; }
.lab-block-actions { display: flex; gap: 6px; margin-bottom: 10px; }
.component-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 12px; flex-wrap: wrap; }
.component-row button, .lab-block-actions button { font-size: 11px; padding: 4px 8px; }
.mcp-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.mcp-section-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }

button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
button:hover { background: #262e38; border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled:hover { background: var(--surface-2); border-color: var(--border-strong); }

table { border-collapse: collapse; width: 100%; margin-bottom: 16px; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.status-pill.running { background: rgba(245, 171, 7, 0.15); color: #f5ab07; border-color: rgba(245, 171, 7, 0.3); }
.status-pill.pending, .status-pill.stopped, .status-pill.unreachable {
  background: rgba(139, 148, 158, 0.15); color: var(--text-dim); border-color: rgba(139, 148, 158, 0.25);
}
.status-pill.partial { background: rgba(255, 152, 0, 0.15); color: #ff9800; border-color: rgba(255, 152, 0, 0.3); }
.status-pill.completed, .status-pill.no_changes, .status-pill.connected {
  background: rgba(16, 185, 129, 0.15); color: var(--accent); border-color: rgba(16, 185, 129, 0.3);
}
.status-pill.failed, .status-pill.failed_compile, .status-pill.failed_max_turns,
.status-pill.failed_review, .status-pill.failed_planning, .status-pill.error,
.status-pill.crashed, .status-pill.failed_to_start {
  background: rgba(244, 67, 54, 0.15); color: var(--danger); border-color: rgba(244, 67, 54, 0.3);
}
.status-pill.cancelled, .status-pill.interrupted { background: rgba(139, 148, 158, 0.15); color: var(--text-dim); border-color: rgba(139, 148, 158, 0.25); }
.status-pill.waiting-approval { background: rgba(245, 171, 7, 0.15); color: #f5ab07; border-color: rgba(245, 171, 7, 0.3); }
.status-pill.generating, .status-pill.awaiting-clarification {
  background: rgba(139, 148, 158, 0.15); color: var(--text-dim); border-color: rgba(139, 148, 158, 0.25);
}

.workitem-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.workitem-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.workitem-card-header { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 6px; }
.workitem-card-prompt { margin: 0 0 4px; font-size: 13px; }
.workitem-card-meta { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); }
.workitem-card-actions { display: flex; align-items: center; gap: 10px; }
.workitem-card-actions form { margin: 0; }
.workitem-list-empty { color: var(--text-dim); font-size: 13px; }

.error-banner {
  background: rgba(244, 67, 54, 0.1);
  color: var(--danger);
  border: 1px solid rgba(244, 67, 54, 0.3);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.error-text { color: var(--danger); font-size: 12px; margin-left: 8px; }

.stats-strip {
  display: flex;
  gap: 28px;
  padding: 10px 0 18px;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.stats-strip .stat-block h4 { margin: 0 0 6px; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stats-strip .stat-block > div { font-size: 22px; font-weight: 700; color: var(--text); }

.workitems-controls { display: flex; gap: 10px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 10px; max-width: 300px; }
.login-form input {
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.log-turn { margin-bottom: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.turn-header { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.turn-text { white-space: pre-wrap; margin-bottom: 6px; }
.tool-call { margin: 6px 0 6px 14px; font-size: 13px; }
.tool-call summary { cursor: pointer; color: var(--link); }
.tool-call.error summary { color: var(--danger); }
.tool-args, .tool-result {
  background: var(--bg);
  color: #7ee787;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-x: auto;
  margin-top: 4px;
}
.log-phase-summary {
  margin: 14px 0;
  padding: 10px 12px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
  font-size: 13px;
}
.git-actions, .compile-failures { margin-top: 20px; }
.git-row { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 3px 0; }
.git-row.error { color: var(--danger); }
