/* Design tokens from DESIGN.md — never invent new ones. */
:root {
  --color-primary: #1a1c1e;
  --color-secondary: #6c7278;
  --color-accent: #b8422e;
  --color-background: #f7f5f2;
  --color-success: #2e7d32;
  --color-failure: #c62828;
  --color-running: #f9a825;
  --font-family: Inter, sans-serif;
  --mono-family: "JetBrains Mono", ui-monospace, monospace;
  --base-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--base-size);
  color: var(--color-primary);
  background: var(--color-background);
}

.site-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--color-secondary);
}

.site-name {
  font-weight: 700;
  color: var(--color-primary);
}

main {
  padding: 1.25rem;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

a {
  color: var(--color-accent);
}

.empty-state {
  color: var(--color-secondary);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-header nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.site-header nav a {
  color: var(--color-primary);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--color-accent);
}

.login-form,
.project-form {
  display: grid;
  gap: 0.5rem;
  max-width: 28rem;
}

.login-form label,
.project-form label {
  color: var(--color-secondary);
  font-size: 0.875rem;
}

.login-form input,
.project-form input {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
  font: inherit;
}

button {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 3px;
  background: var(--color-accent);
  color: var(--color-background);
  font: inherit;
  cursor: pointer;
}

.form-error {
  color: var(--color-failure);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-head h1 {
  margin: 0;
}

a.button {
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  background: var(--color-accent);
  color: var(--color-background);
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-secondary);
}

th {
  color: var(--color-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

td.meta {
  color: var(--color-secondary);
}

.webhook-info {
  margin-top: 2rem;
}

.webhook-info h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.webhook-info dt {
  color: var(--color-secondary);
  font-size: 0.875rem;
}

.webhook-info dd {
  margin: 0.125rem 0 0.5rem;
}

code {
  font-family: var(--mono-family);
  font-size: 0.875rem;
}

.delete-form {
  margin-top: 2rem;
}

button.danger {
  background: var(--color-failure);
}

/* Status badge: dot + label, used identically everywhere. Never color alone. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.badge .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--color-secondary);
}

.badge-success .dot {
  background: var(--color-success);
}

.badge-failed .dot {
  background: var(--color-failure);
}

/* Running doubles as pending/queued per DESIGN.md. */
.badge-running .dot,
.badge-queued .dot {
  background: var(--color-running);
}

.run-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin-bottom: 1.5rem;
}

.run-meta dt {
  color: var(--color-secondary);
  font-size: 0.875rem;
}

.run-meta dd {
  margin: 0;
}

.step-log {
  margin-bottom: 0.75rem;
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
}

.step-log summary {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-weight: 500;
}

.step-log pre {
  margin: 0;
  padding: 0.75rem;
  border-top: 1px solid var(--color-secondary);
  font-family: var(--mono-family);
  font-size: 0.875rem;
  overflow-x: auto;
  white-space: pre-wrap;
}


/* Stage pipeline strip: beta → gamma → production as connected segments;
   the promote button sits on the gamma→production boundary (DESIGN.md). */
.stage-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stage-segment {
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
  padding: 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 9rem;
}

.stage-segment.stage-this-run {
  border-color: var(--color-success);
}

.stage-name {
  font-weight: 500;
  text-transform: capitalize;
}

.stage-state {
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stage-strip .meta {
  color: var(--color-secondary);
}

.stage-arrow {
  color: var(--color-secondary);
}

.stage-arrow form {
  display: inline;
}

/* Review states: awaiting-review shares the running/pending color per
   DESIGN.md; rejected shares failure. */
.badge-awaiting-review .dot {
  background: var(--color-running);
}

.badge-rejected .dot {
  background: var(--color-failure);
}

.review-actions {
  border: 1px solid var(--color-running);
  border-radius: 3px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.review-actions form {
  display: inline-block;
  margin-right: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Unified diff (review page): monoFamily, add/del tints per DESIGN, one
   .diff-line per line so comment affordances and anchored comments can sit
   between lines. */
.diff-file h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.9375rem;
}

.diff {
  margin: 0 0 1rem;
  padding: 0.35rem 0;
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
  font-family: var(--mono-family);
  font-size: 0.875rem;
  overflow-x: auto;
}

.diff-line {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.diff-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-add {
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
}

.diff-del {
  background: color-mix(in srgb, var(--color-failure) 12%, transparent);
}

.diff-meta {
  color: var(--color-secondary);
}

.comment-affordance summary {
  cursor: pointer;
  list-style: none;
  opacity: 0.35;
  user-select: none;
}

.comment-affordance summary:hover,
.comment-affordance[open] summary {
  opacity: 1;
}

.comment-affordance form {
  padding: 0.35rem 0;
  font-family: var(--font-family);
}

.comment-affordance textarea {
  display: block;
  width: 22rem;
  max-width: 100%;
  margin-bottom: 0.35rem;
  font-family: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
}

/* Anchored comment: reviewer feedback pinned under its diff line. */
.diff-comment {
  margin: 0.25rem 0.5rem 0.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--color-running);
  background: color-mix(in srgb, var(--color-running) 8%, transparent);
  font-family: var(--font-family);
}

.diff-comment p {
  margin: 0 0 0.25rem;
}

.diff-comment form {
  display: inline-block;
  margin-left: 0.75rem;
}

.review-previous {
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
  padding: 0.5rem 1rem;
  margin-bottom: 1.5rem;
}

.commit-list,
.file-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.review-actions textarea {
  display: block;
  width: 100%;
  max-width: 40rem;
  margin: 0.35rem 0 0.75rem;
  font-family: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-secondary);
  border-radius: 3px;
}
