:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222536;
  --border: #2e3147;
  --text: #e2e4f0;
  --muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #4f52d4;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 8px;
  --font: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ─────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.nav-logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.5px;
}
.nav-logo:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { color: var(--muted); font-size: 13px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ── Main ────────────────────────────────────────── */
main { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* ── Page header ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 20px; font-weight: 600; flex: 1; }
.back-link { color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-warn { border-color: var(--yellow); color: var(--yellow); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.btn-link:hover { color: var(--text); }

/* ── Alerts ──────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
}
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-warn { background: rgba(245,158,11,0.15); color: var(--yellow); }

/* ── Misc ────────────────────────────────────────── */
.muted { color: var(--muted); }
.hidden { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
input[type="text"], input[type="password"], input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

/* ── Login ───────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}
.login-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-box button[type="submit"] {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}
.login-box button[type="submit"]:hover { background: var(--accent-hover); }

/* ── Dashboard grid ──────────────────────────────── */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-card-header { display: flex; align-items: center; justify-content: space-between; }
.project-card-header h3 { font-size: 16px; font-weight: 600; }
.project-card-meta { color: var(--muted); font-size: 12px; }
.project-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Analyze ─────────────────────────────────────── */
.analyze-wrap { display: flex; flex-direction: column; gap: 20px; }
.analyze-form { display: flex; align-items: flex-end; gap: 16px; }
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-row label { font-size: 12px; color: var(--muted); }
.field-row input { width: 120px; }
.terminal-wrap {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.terminal {
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  padding: 16px;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #c9d1d9;
}
.result-bar {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
}
.result-bar-ok { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.result-bar-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.result-bar a { color: inherit; font-weight: 500; }

/* ── Reports ─────────────────────────────────────── */
.report-list { display: flex; flex-direction: column; gap: 8px; }
.report-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s;
}
.report-item:hover { border-color: var(--accent); text-decoration: none; }
.report-item-name { font-family: var(--font); font-size: 12px; }
.report-item-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }

/* ── Report content ──────────────────────────────── */
.report-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; }
.report-content h1, .report-content h2 { margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.report-content h1:first-child, .report-content h2:first-child { margin-top: 0; }
.report-content h3 { margin: 16px 0 8px; }
.report-content p { margin-bottom: 12px; }
.report-content ul, .report-content ol { margin: 8px 0 12px 20px; }
.report-content li { margin-bottom: 4px; }
.report-content code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-family: var(--font); font-size: 12px; }
.report-content pre { background: var(--surface2); padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 12px 0; }
.report-content strong { color: #fff; }
.report-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
/* Hide raw task blocks from rendered report */
.report-content .task-raw { display: none; }

/* ── Pending tasks ───────────────────────────────── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}
.task-card.loading { opacity: 0.5; pointer-events: none; }
.task-card.approved, .task-card.rejected { opacity: 0.4; }
.task-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.task-actions { display: flex; gap: 8px; flex-shrink: 0; }
.task-description { color: var(--muted); font-size: 13px; margin-bottom: 10px; white-space: pre-line; }
.task-ac { margin: 8px 0 10px 18px; font-size: 13px; color: var(--muted); }
.task-ac li { margin-bottom: 2px; }
.task-labels { display: flex; gap: 6px; flex-wrap: wrap; }
.label { background: var(--surface2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 8px; font-size: 11px; color: var(--muted); }
.task-done { padding: 8px 0; font-size: 13px; }
.priority-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 8px;
}
.priority-high { background: rgba(239,68,68,0.15); color: var(--red); }
.priority-medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.priority-low { background: rgba(99,102,241,0.15); color: var(--accent); }

/* ── Logs ────────────────────────────────────────── */
.log-filters { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }
.log-table-wrap { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--font); }
.log-table th { text-align: left; padding: 8px 10px; color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 500; white-space: nowrap; }
.log-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.log-table tr:hover td { background: var(--surface); }
.level-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.level-error { background: rgba(239,68,68,0.2); color: var(--red); }
.level-warn  { background: rgba(245,158,11,0.2); color: var(--yellow); }
.level-info  { background: rgba(99,102,241,0.15); color: var(--accent); }
.log-row.log-error td { color: #fca5a5; }
.status-err { color: var(--red); }
.status-ok  { color: var(--green); }
.log-ts, .log-action, .log-path { color: var(--text); }
.log-user { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.log-ip { font-family: monospace; font-size: 0.85em; }
.log-has-error { border-left: 3px solid var(--red); }

/* ── Kanban ──────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kanban-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kanban-col-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.kanban-count { background: var(--surface2); border-radius: 99px; padding: 1px 8px; font-size: 11px; color: var(--muted); font-weight: 400; }
.kanban-cards { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.kanban-empty { color: var(--muted); font-size: 12px; padding: 8px 4px; }
.kanban-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; transition: border-color 0.15s; }
.kanban-card:hover { border-color: var(--accent); }
.kanban-card-title { font-size: 13px; font-weight: 500; margin-bottom: 8px; line-height: 1.4; }
.kanban-card-meta { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.project-tag { background: rgba(99,102,241,0.12); color: var(--accent); border-radius: 99px; padding: 1px 7px; font-size: 11px; }
.kanban-card-status { margin-top: 4px; }
.status-select { width: 100%; font-size: 12px; padding: 4px 6px; }

/* ── Modals ──────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 520px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-header h3 { font-size: 16px; font-weight: 600; line-height: 1.4; }
.modal-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.modal-desc { color: var(--muted); font-size: 13px; white-space: pre-line; margin-bottom: 12px; }
.modal-ac-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 6px; }
.modal-footer { display: flex; align-items: center; padding: 14px 24px; border-top: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.modal-status-label { font-size: 12px; color: var(--muted); }
.modal-footer select { width: auto; }
.modal-footer form { display: contents; }
textarea { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 8px 12px; font-size: 13px; width: 100%; resize: vertical; font-family: inherit; }
textarea:focus { outline: none; border-color: var(--accent); }

.status-btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.task-id { font-family: var(--font); font-size: 11px; }
