:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e1e4ed;
  --text-muted: #8b8fa3;
  --accent: #6c8cff;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
}

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

body {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 { font-size: 1.2rem; color: var(--accent); }
header nav { display: flex; gap: 1.5rem; align-items: center; }
header nav a { color: var(--text-muted); text-decoration: none; }
header nav a:hover { color: var(--text); }
header nav a.active { color: var(--accent); }

main { padding: 2rem; max-width: 1200px; margin: 0 auto; }

section { margin-bottom: 2rem; }
section h2 { margin-bottom: 0.75rem; font-size: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; }
th, td { padding: 0.5rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 0.85rem; }

.status { padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; }
.status-running { background: rgba(108, 140, 255, 0.2); color: var(--accent); }
.status-completed { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.status-failed { background: rgba(248, 113, 113, 0.2); color: var(--error); }
.status-queued { background: rgba(251, 191, 36, 0.2); color: var(--warning); }

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
}
button:hover { opacity: 0.9; }

.logs {
  background: var(--bg);
  padding: 1rem;
  border-radius: 4px;
  font-size: 0.8rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 0.5rem;
}

/* Login */
.login-container {
  max-width: 320px;
  margin: 20vh auto;
  text-align: center;
}
.login-container h1 { color: var(--accent); margin-bottom: 2rem; }
.login-container input {
  width: 100%;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  margin-bottom: 1rem;
}
.login-container button { width: 100%; padding: 0.75rem; font-size: 1rem; }
.error { color: var(--error); margin-bottom: 1rem; }

/* Settings */
.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }

h3 { font-size: 0.9rem; color: var(--text-muted); margin: 1.5rem 0 0.5rem; }

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

.inline-form input[type="text"] {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.inline-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-small {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 3px;
}

.btn-active { background: var(--success); color: #000; }
.btn-inactive { background: var(--border); color: var(--text-muted); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.8; }

.row-muted { opacity: 0.5; }
.text-muted { color: var(--text-muted); }

.add-project-controls { margin-bottom: 1rem; }
.add-project-controls > button { margin-bottom: 0.75rem; }

.project-picker { margin-top: 0.5rem; }
.project-picker td form { display: flex; gap: 0.3rem; }

details.manual-add { margin-top: 0.75rem; }
details.manual-add summary {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}

/* Audit Log */
.audit-filters { margin-bottom: 1rem; }
.audit-filters select {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}
.audit-filters input[type="text"] {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  width: 180px;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.audit-entry {
  background: var(--surface);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--border);
}
.audit-entry.audit-level-error { border-left-color: var(--error); }
.audit-entry.audit-level-warn { border-left-color: var(--warning); }

.audit-entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.audit-entry-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.audit-entry-detail {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
}

.audit-refs { color: var(--accent); }

.audit-badge {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}
.audit-badge-info { background: rgba(108, 140, 255, 0.2); color: var(--accent); }
.audit-badge-warn { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.audit-badge-error { background: rgba(248, 113, 113, 0.2); color: var(--error); }

.audit-category {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
}

.audit-meta {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: 3px;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.audit-meta-toggle {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  padding: 1px 4px;
  background: var(--border);
  color: var(--text-muted);
}

/* Repositories Page */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.section-header h3 { margin: 0; }

.summary-cell {
  max-width: 320px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.htmx-indicator {
  display: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.success { color: var(--success); margin-bottom: 1rem; }
