* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a0a0f;
  color: #e0e0e0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding: 24px;
  min-height: 100vh;
}

#header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
#header-right { display: flex; align-items: center; gap: 12px; }
#auth-logged-out, #auth-logged-in { display: flex; align-items: center; gap: 8px; }
h1 { font-size: 20px; color: #f59e0b; margin-bottom: 0; }
#help-link, #setup-link { font-size: 12px; color: #666; text-decoration: none; }
#help-link:hover, #setup-link:hover { color: #f59e0b; }
#setup-link { color: #34d399; }
.subtitle { font-size: 12px; color: #666; margin-bottom: 16px; }

/* Knowledge Base URL bar */
#kb-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #111118;
  border: 1px solid #222;
  border-radius: 8px;
  margin-bottom: 20px;
}
#kb-bar label { font-size: 12px; color: #888; white-space: nowrap; }
#kb-bar input {
  flex: 1;
  min-width: 200px;
  background: #0a0a0f;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
#kb-bar input:focus { outline: none; border-color: #f59e0b; }
#kb-connect {
  background: #f59e0b;
  color: #0a0a0f;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
#kb-connect:hover { background: #fbbf24; }
#kb-connect:disabled { background: #333; color: #666; cursor: not-allowed; }

#solid-login {
  background: #f59e0b;
  color: #0a0a0f;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
#solid-login:hover { background: #fbbf24; }
#solid-login:disabled { background: #444; color: #888; cursor: wait; }
#solid-logout {
  background: transparent;
  border: 1px solid #333;
  color: #888;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
#solid-logout:hover { border-color: #555; color: #ccc; }
#auth-user {
  font-size: 13px;
  color: #34d399;
  font-weight: 500;
}
#solid-status, #solid-status-in {
  font-size: 11px;
  color: #666;
}
#solid-status.connected, #solid-status-in.connected { color: #34d399; }
#solid-status.error, #solid-status-in.error { color: #ef4444; }
#solid-progress {
  font-size: 11px;
  color: #a78bfa;
}

/* Filters */
#filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
#filters button {
  background: #1a1a24;
  border: 1px solid #333;
  color: #aaa;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
#filters button:hover { border-color: #555; color: #fff; }
#filters button.active { background: #2a2a3a; border-color: #4a9eff; color: #4a9eff; }

/* Stats bar */
#stats {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: #111118;
  border-radius: 8px;
  border: 1px solid #222;
}
.stat { text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 11px; color: #666; margin-top: 2px; }
.stat-p1 .stat-value { color: #ef4444; }
.stat-active .stat-value { color: #4a9eff; }
.stat-done .stat-value { color: #34d399; }
.stat-parked .stat-value { color: #9ca3af; }
.stat-open .stat-value { color: #f59e0b; }

/* Cards */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #222;
}

.epic-group { margin-bottom: 24px; }
.epic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.epic-header:hover .epic-name { color: #fff; }
.epic-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.epic-name { font-size: 15px; font-weight: 600; color: #ccc; }
.epic-id { font-size: 11px; color: #555; }
.epic-status { font-size: 11px; padding: 2px 8px; border-radius: 3px; }

.task-list { margin-left: 20px; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: #111118;
  border: 1px solid #1a1a24;
}
.task:hover { border-color: #333; }
.task-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.task-content { flex: 1; }
.task-name { font-size: 13px; color: #ccc; }
.task-meta { font-size: 11px; color: #555; margin-top: 2px; }
.task-meta span { margin-right: 12px; }
.task-desc { font-size: 11px; color: #666; margin-top: 4px; }
.task-trigger {
  font-size: 10px;
  color: #a78bfa;
  margin-top: 3px;
}

/* Status colours */
.status-active { background: #1a2a3a; color: #4a9eff; }
.status-done { background: #1a2a2a; color: #34d399; }
.status-open { background: #2a2a1a; color: #f59e0b; }
.status-blocked { background: #2a1a1a; color: #ef4444; }
.status-parked { background: #1a1a1a; color: #9ca3af; }

.dot-active { background: #4a9eff; }
.dot-done { background: #34d399; }
.dot-open { background: #f59e0b; }
.dot-blocked { background: #ef4444; }
.dot-parked { background: #9ca3af; }

/* Trigger section */
.trigger-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #111118;
  border: 1px solid #222;
  border-radius: 6px;
  margin-right: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.trigger-icon { font-size: 14px; }
.trigger-name { color: #ccc; }
.trigger-date { color: #555; font-size: 11px; }
.trigger-count { color: #a78bfa; font-size: 11px; }

/* Agent summary */
.agent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #1a1a24;
}
.agent-name { font-size: 13px; font-weight: 500; min-width: 100px; }
.agent-bar { height: 6px; border-radius: 3px; }
.agent-count { font-size: 11px; color: #666; min-width: 40px; }

/* SPARQL section */
#sparql-section { margin-top: 32px; }
#sparql-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
#sparql-presets button {
  background: #1a1a24;
  border: 1px solid #333;
  color: #a78bfa;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
#sparql-presets button:hover { border-color: #a78bfa; color: #fff; }
#sparql-input {
  width: 100%;
  min-height: 100px;
  background: #111118;
  border: 1px solid #333;
  border-radius: 6px;
  color: #ccc;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  padding: 12px;
  resize: vertical;
  margin-bottom: 8px;
}
#sparql-input:focus { outline: none; border-color: #a78bfa; }
#sparql-run {
  background: #a78bfa;
  color: #0a0a0f;
  border: none;
  padding: 6px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
#sparql-run:hover { background: #c4b5fd; }
#sparql-run:disabled { background: #444; color: #888; cursor: wait; }
#sparql-engine-status {
  display: inline-block;
  margin-left: 12px;
  font-size: 12px;
  color: #666;
}
#sparql-results {
  margin-top: 12px;
  overflow-x: auto;
}
#sparql-results table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
#sparql-results th {
  background: #1a1a24;
  color: #a78bfa;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #333;
  font-weight: 600;
}
#sparql-results td {
  padding: 5px 10px;
  border-bottom: 1px solid #1a1a24;
  color: #ccc;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sparql-results tr:hover td { background: #111118; }
#sparql-error {
  color: #ef4444;
  font-size: 12px;
  padding: 8px;
  background: #1a1111;
  border-radius: 4px;
  margin-top: 8px;
}

/* Add / Create buttons */
.add-btn {
  background: transparent;
  border: 1px solid #333;
  color: #34d399;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  margin-left: 10px;
  vertical-align: middle;
}
.add-btn:hover { border-color: #34d399; color: #fff; }
.add-btn:disabled { color: #444; border-color: #222; cursor: not-allowed; }

/* Create forms */
.create-form {
  background: #111118;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
}
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.form-row label {
  font-size: 12px;
  color: #888;
  min-width: 80px;
}
.form-row input,
.form-row select {
  flex: 1;
  background: #0a0a0f;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.form-row input:focus,
.form-row select:focus { outline: none; border-color: #34d399; }
.form-row select { cursor: pointer; }
.form-row select option { background: #111118; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.save-btn {
  background: #34d399;
  color: #0a0a0f;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}
.save-btn:hover { background: #6ee7b7; }
.save-btn:disabled { background: #444; color: #888; cursor: wait; }
.cancel-btn {
  background: transparent;
  border: 1px solid #333;
  color: #888;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.cancel-btn:hover { border-color: #555; color: #ccc; }

/* Footer */
#carapace-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 48px;
  padding: 16px 0;
  border-top: 1px solid #222;
  font-size: 12px;
  color: #555;
}
#carapace-footer a {
  color: #666;
  text-decoration: none;
}
#carapace-footer a:hover { color: #f59e0b; }
