:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --ink: #16201c;
  --muted: #63706a;
  --line: #dbe3df;
  --accent: #146c5f;
  --accent-soft: #dcefeb;
  --warn: #9a5b12;
  --fail: #a13b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

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

a:hover {
  text-decoration: underline;
}

/* Shared chrome (navbar, page shell, landing) is now Bootstrap 5 — see
 * core/templates/base.html / landing.html. The legacy .topbar / .nav* / .brand
 * / .content / .landing* rules were removed; the styles below remain for the
 * not-yet-migrated list/detail templates that still use these app-specific
 * classes (.button, .input, .form, .panel, .table, .status, .kind, etc.) and
 * for the lightbox helper that core/static/app.js binds. */

/* .nav-link-button is still used as a link-style submit button in
 * bugs/detail.html; keep a self-contained (chrome-independent) version. */
.nav-link-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0;
}

.nav-link-button:hover {
  text-decoration: underline;
}

.page-title {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-actions {
  align-items: center;
  display: flex;
  gap: 12px;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
}

/* Legacy .grid/.grid-N removed — Bootstrap .row / .row-cols-* own grid layout now.
   (The old display:grid here overrode Bootstrap's flex .row and collapsed columns.) */

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel,
.metric {
  padding: 18px;
}

.metric-value {
  font-size: 28px;
  font-weight: 750;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-top: 3px;
  text-transform: uppercase;
}

/* .environment-state-grid / .environment-state-card layout removed — Bootstrap
   .row.row-cols-* and .card / .card-body own it now. The old display:grid
   overrode Bootstrap's .row/.card and shrank the cards to ~1/4 width. */

.environment-state-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.environment-state-heading h2 {
  margin-bottom: 4px;
}

.environment-state-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.environment-state-list div {
  display: grid;
  gap: 8px;
  grid-template-columns: 82px minmax(0, 1fr);
}

.environment-state-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.environment-state-list dd {
  margin: 0;
  min-width: 0;
}

.environment-state-error {
  background: #f5dddd;
  border-radius: 6px;
  color: var(--fail);
  font-size: 13px;
  padding: 10px;
}

.form {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 6px;
}

.form-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.textarea {
  min-height: 116px;
  resize: vertical;
}

.checkbox-row {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 8px;
  font-weight: 650;
}

.button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  min-height: 38px;
  padding: 8px 14px;
}

.button:hover {
  background: #0e554b;
}

.button:disabled {
  background: #9fb1ab;
  cursor: not-allowed;
}

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

.button.danger:hover {
  background: #822d2d;
}

.filter-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  padding: 6px 10px;
  text-transform: uppercase;
}

.filter-pill.active {
  background: var(--accent-soft);
  border-color: #b8d8d1;
  color: var(--accent);
}

.subtle-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* Flash messages: base.html now layers Bootstrap .alert on top, but the legacy
 * .notice rules remain for snapshots/detail.html which still uses .notice info
 * standalone. Keeping them is harmless under .alert (alert wins on the shared
 * properties it sets). */
.notice {
  border-radius: 8px;
  font-weight: 650;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice.success {
  background: var(--accent-soft);
  color: var(--accent);
}

.notice.error {
  background: #f5dddd;
  color: var(--fail);
}

.notice.info {
  background: #e7edf8;
  color: #28558f;
}

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

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

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.status.failed {
  background: #f5dddd;
  color: var(--fail);
}

.status.creating {
  background: #f6ead7;
  color: var(--warn);
}

.status.queued,
.status.pending,
.status.running {
  background: #f6ead7;
  color: var(--warn);
}

.status.succeeded {
  background: var(--accent-soft);
  color: var(--accent);
}

.status.cancelled {
  background: #e7edf8;
  color: #28558f;
}

.status.closed {
  background: #e7ece9;
  color: #596762;
}

/* Custom Bootstrap-style badge for the ``blocked`` ticket status (purple — not a
   Bootstrap default). Paired with the .status pill colour below so the
   /workflow page, the bug list, and the detail page all read the same. */
.text-bg-blocked {
  background-color: #6f42c1 !important;
  color: #fff !important;
}

.status.blocked {
  background: #e7d6f7;
  color: #4a2c6b;
}

/* Merged-but-unverified: a distinct teal so "merged ahead of verification"
   stands apart from fixed/verified green (not a Bootstrap default). */
.text-bg-merged {
  background-color: #0d9488 !important;
  color: #fff !important;
}

.status.merged_unverified {
  background: #ccfbf1;
  color: #115e59;
}

.kind {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 750;
  padding: 3px 8px;
}

.kind.user {
  background: #e7edf8;
  color: #28558f;
}

.kind.bot {
  background: #f1e5c9;
  color: #76550f;
}

.path-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.path-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 190px minmax(0, 1fr);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 180px minmax(0, 1fr);
  padding: 0 0 10px;
}

.detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-list.compact {
  margin-top: 10px;
}

.detail-list.compact .detail-row {
  grid-template-columns: 120px minmax(0, 1fr);
}

.label-list,
.pr-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.label-pill {
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
}

.subsection-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin: 18px 0 10px;
  text-transform: uppercase;
}

.pr-list {
  display: grid;
  gap: 14px;
}

.followup-list {
  display: grid;
  gap: 12px;
}

.followup-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.followup-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.pr-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 14px;
}

.pr-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.restore-target {
  margin-bottom: 16px;
}

.detail-row dt,
.path-row dt {
  font-weight: 700;
}

.manifest {
  background: #10231f;
  border-radius: 8px;
  color: #e8f3f0;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
}

.bug-description {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.55;
  margin: 0;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.bug-description.compact {
  padding: 10px;
}

.attachment-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.attachment-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 14px;
}

.attachment-item:first-child,
.attachment-item:nth-child(2) {
  border-top: 0;
  padding-top: 0;
}

.attachment-preview {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #eef3f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.attachment-preview img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.attachment-preview.missing {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.attachment-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.attachment-meta div {
  display: grid;
  gap: 4px;
  grid-template-columns: 110px minmax(0, 1fr);
}

.attachment-meta dt {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.attachment-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

code {
  background: #eef3f1;
  border-radius: 4px;
  color: #22332e;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 2px 5px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 760px) {
  .content {
    padding: 18px;
  }

  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 8px;
    grid-template-columns: 1fr;
    justify-items: start;
    padding: 14px 18px;
  }

  .nav {
    align-items: flex-start;
    flex-wrap: wrap;
    grid-column: 1;
    justify-self: start;
  }

  .nav-auth {
    grid-column: 1;
    justify-self: start;
  }

  .nav-user {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .environment-state-grid {
    grid-template-columns: 1fr;
  }

  .path-row,
  .detail-row,
  .environment-state-list div,
  .detail-list.compact .detail-row,
  .attachment-meta div {
    grid-template-columns: 1fr;
  }

  .attachment-grid {
    grid-template-columns: 1fr;
  }

  .attachment-item:nth-child(2) {
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }
}
