:root {
  --bg: #f8f9fa;
  --fg: #212529;
  --accent: #0d6efd;
  --card: #ffffff;
  --border: #dee2e6;
  --danger: #dc3545;
  --success: #198754;
  --warning: #ffc107;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.navbar a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}

.navbar a:hover { color: var(--accent); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand { font-size: 1.25rem; font-weight: 700; }

.inline { display: inline; margin: 0; padding: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.card:hover { border-color: var(--accent); }

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form label { font-weight: 500; }

.form input,
.form textarea,
.form select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  font-family: inherit;
}

.form textarea { resize: vertical; }

.btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--card);
  cursor: pointer;
  text-decoration: none;
  color: var(--fg);
  display: inline-block;
}

.btn:hover { background: var(--bg); }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover { background: #0b5ed7; }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.25rem;
  margin-bottom: 1rem;
}

.alert-error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  margin-top: 1rem;
}

.table th, .table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background: #e9ecef;
  font-size: 0.85rem;
}

.status-draft { background: #e2e3e5; }
.status-queued { background: #cfe2ff; }
.status-blocked { background: #f8d7da; }
.status-leased { background: #fff3cd; }
.status-running { background: #d1e7dd; }
.status-awaiting_review { background: #cff4fc; }
.status-changes_requested { background: #f8d7da; }
.status-testing { background: #d1e7dd; }
.status-ready_to_merge { background: #d1e7dd; }
.status-awaiting_approval { background: #fff3cd; }
.status-done { background: #d1e7dd; color: #0f5132; }
.status-failed { background: #f8d7da; color: #842029; }
.status-cancelled { background: #e2e3e5; }

.chat-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  height: 400px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  max-width: 80%;
  padding: 0.75rem;
  border-radius: 0.5rem;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: #e9ecef;
}

.message-meta {
  font-size: 0.75rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

.message-link { margin-top: 0.25rem; }
.message-link a { color: inherit; text-decoration: underline; }

.chat-form {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
}

.chat-form textarea { flex: 1; }

.log-viewer {
  background: #212529;
  color: #f8f9fa;
  padding: 1rem;
  border-radius: 0.25rem;
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  max-height: 400px;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin: 1rem 0;
}

.tabs a {
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 2px solid transparent;
}

.tabs a.active { border-bottom-color: var(--accent); font-weight: 500; }

.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .nav-content { flex-direction: column; align-items: flex-start; }
  .chat-form { flex-direction: column; }
}
