:root {
  color-scheme: light dark;
  --bg: #0a0e17;
  --panel: #131a2a;
  --panel-2: #0e1420;
  --border: #262f45;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --accent-hover: #5577f0;
  --accent-purple: #a78bfa;
  --accent-2: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-solid: #dc3545;
  --danger-solid-hover: #c22e3d;
}
* { box-sizing: border-box; }
/* Without this, elements with a `display` set by their own class (e.g. .badge's
   inline-block) stay visually shown even when marked [hidden] — the browser's
   default [hidden]{display:none} UA rule loses to an equal-specificity author
   rule. Found live: detail.ejs's #runStatus badge stayed visible while
   genuinely `hidden` in the DOM (confirmed via the element's own .hidden
   property reading true) specifically because of .badge's display:inline-block. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(108,140,255,0.05), transparent);
}
header a { color: var(--text); text-decoration: none; font-weight: 600; }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  display: inline-flex;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(108,140,255,0.6));
}
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.icon-text { display: inline-flex; align-items: center; gap: 5px; }
h3 .icon-text, h2 .icon-text { vertical-align: -2px; }
main {
  padding: 28px 24px 40px;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 13px; font-size: 12.5px; border-radius: 6px; }
.btn.icon-button { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn.compact-button { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: var(--danger-solid); }
.btn.danger:hover { background: var(--danger-solid-hover); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; background: var(--panel-2); }
tbody tr[onclick] { cursor: pointer; }
tr:hover td { background: rgba(108,140,255,0.04); }
tbody tr:last-child td { border-bottom: none; }
.mono-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--muted); }

.empty-state { text-align: center; padding: 56px 24px; }
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.6; }
.empty-state p { color: var(--muted); margin: 0 0 16px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.board-badge.jira { border-color: #2684ff; color: #6ba8ff; }
.board-badge.trello { border-color: #0079bf; color: #4fb6f0; }
.status-connected { border-color: var(--accent-2); color: var(--accent-2); }
.status-connected::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
}

/* Status pills — the header's RUNNING indicator and the log panel's LIVE indicator
   share this component. The dot only pulses in .running state, tied to the real
   runLock-backed `running` flag from GET /projects/:id/execution — never decorative. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}
.status-pill.small { font-size: 10px; padding: 2px 8px; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.status-pill.running { border-color: var(--accent-2); color: var(--accent-2); background: rgba(52,211,153,0.08); }
.status-pill.running .dot { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); animation: pulse-dot 1.2s ease-in-out infinite; }
.status-pill.error { border-color: var(--danger); color: var(--danger); background: rgba(248,113,113,0.08); }
.status-pill.error .dot { background: var(--danger); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  line-height: 1;
}
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%;
  padding: 8px 10px;
  background: #0c1119;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
details.manual-setup > summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.manual-setup[open] > summary { margin-bottom: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.error { color: var(--danger); margin-top: 12px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.field-group { display: none; }
.field-group.active { display: block; }
pre { white-space: pre-wrap; background: #0c1119; padding: 16px; border-radius: 8px; border: 1px solid var(--border); }
.run-result-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.report-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; margin: 0; }

/* ---------- Project / integration header ---------- */
.project-header {
  margin: 0;
  padding: 22px 24px 18px;
  background:
    radial-gradient(circle at 15% 0%, rgba(108,140,255,0.11), transparent 35%),
    var(--panel);
}
.project-header-top {
  display: flex;
  align-items: center;
  gap: 18px;
}
.project-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.project-icon.jira { background: rgba(38,132,255,0.12); }
.project-icon.trello { background: rgba(0,121,191,0.12); }
.project-header-main { flex: 1 1 430px; min-width: 0; }
.project-header-title { display: flex; align-items: center; gap: 10px; }
.project-header-title h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.project-header-meta { display: flex; gap: 18px; margin-top: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.project-header-webhook {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-left: auto;
}
.project-header-webhook form { display: inline; }
.connection-label { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: 0.08em; }

/* Execution stats strip — moved here from a separate side panel so Orchestration
   Flow below can use the full panel width instead of sharing it. */
.project-header-execution {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 34px;
  margin-top: 16px;
  padding: 15px 2px 0;
  border-top: 1px solid var(--border);
}
.exec-stat { display: flex; flex-direction: column; gap: 4px; min-width: 84px; }
.exec-label { font-size: 11px; color: var(--muted); }
.exec-value { font-size: 15px; font-weight: 700; }
.exec-value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 700px) {
  .project-header-top { flex-wrap: wrap; }
  .project-header-webhook { width: 100%; margin-top: 4px; }
  .project-header-execution { gap: 18px 24px; }
}

/* ---------- PRD source ---------- */
.source-panel {
  min-height: 86px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(108,140,255,0.045), transparent 42%), var(--panel);
}
.source-summary { display: flex; align-items: center; gap: 12px; min-width: 0; }
.source-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(108,140,255,0.26);
  border-radius: 9px;
  color: var(--accent);
  background: rgba(108,140,255,0.08);
  flex: 0 0 auto;
}
.source-panel h3 { margin: 0 0 3px; font-size: 15px; }
.source-status { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.source-details { flex: 0 0 auto; }
.source-details[open] { width: 100%; }
.source-details > summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: color .15s, border-color .15s, background .15s;
}
.source-details > summary::-webkit-details-marker { display: none; }
.source-details > summary::before { content: '⌄'; display: inline-block; margin-right: 6px; color: var(--accent); transition: transform .15s; }
.source-details[open] > summary { color: var(--text); border-color: rgba(108,140,255,.55); background: var(--panel-2); }
.source-details[open] > summary::before { transform: rotate(180deg); }
.source-form { width: min(540px, calc(100vw - 90px)); padding-top: 6px; }
.source-form label { margin-top: 12px; }
.source-form label span { color: var(--muted); font-weight: 400; }
.source-key-row, .source-actions { display: flex; align-items: center; gap: 8px; }
.source-key-row .btn { flex: 0 0 auto; white-space: nowrap; }
.source-detect-status { display: block; margin-top: 5px; }
.source-help { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 6px 0 0; }
.source-actions { margin-top: 12px; }

/* ---------- Orchestration flow ---------- */
.flow-panel {
  min-width: 0;
  padding: 22px 24px 18px;
  background:
    linear-gradient(180deg, rgba(108,140,255,0.035), transparent 42%),
    var(--panel);
}
.flow-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.flow-panel h3, .logs-panel h3 { margin: 0 0 3px; font-size: 16px; }
.flow-subtitle { margin: 0; color: var(--muted); font-size: 12.5px; }
.flow-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.flow-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot.active { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.legend-dot.completed { background: var(--accent-2); }
.legend-dot.queued { background: var(--border); }

.flow {
  margin-top: 20px;
  overflow-x: auto;
  padding: 8px 0 12px;
  min-width: 0;
}
.flow-track {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  margin-inline: auto;
}
.flow-arrow { display: flex; align-items: center; width: 28px; flex-shrink: 0; }
.flow-arrow span {
  width: calc(100% - 8px);
  height: 2px;
  background: var(--border);
  position: relative;
}
.flow-arrow span::after {
  content: '';
  position: absolute;
  right: -8px;
  top: -4px;
  border: 5px solid transparent;
  border-left-color: var(--border);
}
.flow-arrow.active span { background: var(--accent); box-shadow: 0 0 6px rgba(108,140,255,0.6); }
.flow-arrow.active span::after { border-left-color: var(--accent); }

/* ---------- Node cards — this is the "rich execution card" the redesign is about ---------- */
.node-card {
  width: clamp(110px, 10vw, 130px);
  flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.node-card.active {
  background: linear-gradient(160deg, rgba(108,140,255,0.12), rgba(167,139,250,0.06));
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(108,140,255,0.3), 0 0 22px rgba(108,140,255,0.28);
  animation: node-pulse 2.4s ease-in-out infinite;
}
@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(108,140,255,0.3), 0 0 22px rgba(108,140,255,0.28); }
  50% { box-shadow: 0 0 0 1px rgba(108,140,255,0.45), 0 0 30px rgba(108,140,255,0.42); }
}
/* Completed: a flat, static green fill — deliberately no glow/animation, so the
   active node's glow is the only thing drawing the eye at a glance. */
.node-card.completed { border-color: var(--accent-2); background: rgba(52,211,153,0.1); }
.node-card.queued { opacity: 0.55; }
.node-card.error { border-color: var(--danger); background: rgba(248,113,113,0.08); box-shadow: 0 0 16px rgba(248,113,113,0.25); }

.node-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.node-title-group { display: flex; align-items: flex-start; gap: 5px; min-width: 0; }
.node-name { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.25; }
.node-help { margin-top: 2px; }

/* "?" tooltip — replaces the always-visible description text, so cards stay
   short enough for the whole pipeline to fit without scrolling. CSS-only, no JS. */
.node-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  cursor: help;
  position: relative;
}
.node-help:hover, .node-help:focus { border-color: var(--accent); color: var(--accent); outline: none; }
.node-help:hover::after, .node-help:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  z-index: 30;
}
.node-help:hover::before, .node-help:focus::before {
  content: '';
  position: absolute;
  bottom: 118%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
  z-index: 30;
}
.node-operation {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.task-chip {
  display: inline-block;
  background: rgba(108,140,255,0.18);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px;
  color: var(--accent);
}
.node-context { margin: 8px 0 0; font-size: 10.5px; color: var(--muted); }

/* ---------- Live logs panel ---------- */
.logs-panel { margin: 0; padding: 18px 20px; }
.logs-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.logs-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.log-filters { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.filter-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.filter-btn.active { background: var(--accent); color: #fff; }
.autoscroll-toggle { margin: 0; line-height: 1; white-space: nowrap; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.autoscroll-toggle input { width: 13px; height: 13px; margin: 0; padding: 0; accent-color: var(--accent); }

.logs-box {
  max-height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.logs-empty { color: var(--muted); padding: 10px 0; text-align: center; }
.log-line { display: flex; align-items: baseline; gap: 10px; padding: 3px 0; white-space: pre-wrap; word-break: break-word; }
.log-time { color: var(--muted); flex-shrink: 0; }
.log-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.log-dot.info { background: var(--accent); }
.log-dot.warn { background: var(--warn); }
.log-dot.error { background: var(--danger); }
.log-message { color: var(--text); }

/* ---------- Run history ---------- */
.run-history-link { margin: -2px 2px 0; color: var(--muted); font-size: 12.5px; }
.run-history-link a { color: var(--accent); text-decoration: none; }
.runs-page, .run-detail-page { max-width: 1040px; }
.page-title { margin: 12px 0 8px; }
.page-title h2 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.03em; }
.page-title > p:last-child, .run-meta { margin: 0; color: var(--muted); }
.runs-table { padding: 0; overflow: hidden; }
.runs-table tr { cursor: pointer; }
.runs-table tbody tr:hover { background: rgba(108,140,255,.07); }
.run-status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.run-status.running { color: var(--accent); background: rgba(108,140,255,.12); border: 1px solid rgba(108,140,255,.38); }
.run-status.succeeded { color: var(--accent-2); background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.35); }
.run-status.failed { color: var(--danger); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35); }
.run-detail-page { gap: 16px; }
.run-result-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.run-result-header h2 { margin: 0 0 6px; }
/* One row however many cards there are (the cost card is optional); the mobile rule below stacks them 2-up. */
.run-stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.run-stats > div { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.run-stats span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.run-stats strong { font-size: 18px; }
.run-stats .stat-hint { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; margin: 4px 0 0; }
.runs-table .table-hint { color: var(--muted); font-size: 11px; }
.run-report { margin: 0; }
.run-report h3 { margin: 0 0 10px; }
.run-log-panel { margin: 0; }
.run-log-count { color: var(--muted); font-size: 12px; }

/* Compact nodes share one width, including both cards inside the branch. */
.node-card { overflow-wrap: anywhere; }
.model-settings { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.model-settings select {
  width: auto; max-width: 100%; margin: 0; padding: 5px 28px 5px 10px;
  appearance: none; border: 1px solid transparent; border-radius: 6px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4 3 3 3-3' fill='none' stroke='%2399a4b8' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.model-settings select:hover { background-color: var(--panel-2); border-color: var(--border); }
.model-settings select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-settings select:disabled { opacity: .6; cursor: wait; }
.model-settings option { background: var(--panel-2); color: var(--text); }
.model-save-status { font-size: 11px; color: var(--accent-2); }
.model-save-status:empty { display: none; }
.model-save-status.error { color: var(--danger); }
.project-header-meta { gap: 8px 18px; align-items: center; }
.model-settings label { margin: 0; }
.model-saved { color: var(--accent-2); font-size: 13px; }

/* ---------- Project settings ---------- */
.header-divider { color: var(--muted); }
.header-project-link { color: var(--muted); font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-page { max-width: 1060px; }
.settings-intro { margin: 12px 0 8px; }
.settings-intro h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.03em; }
.settings-intro > p:last-child { max-width: 620px; margin: 0; color: var(--muted); line-height: 1.5; }
.settings-notice { color: var(--accent-2); background: rgba(52,211,153,.08); border: 1px solid rgba(52,211,153,.26); border-radius: 9px; padding: 10px 12px; font-size: 13px; }
.settings-section { display: grid; grid-template-columns: minmax(190px, 0.42fr) minmax(0, 1fr); gap: 28px; align-items: start; padding: 26px 0; border-top: 1px solid var(--border); }
.settings-section-heading { padding: 5px 0; }
.settings-section-heading h2 { margin: 0 0 7px; font-size: 17px; }
.settings-section-heading > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.48; max-width: 280px; }
.settings-card { padding: 20px; }
.settings-form { max-width: 620px; }
.settings-form label { margin-top: 0; }
.settings-form label + input, .settings-form label + select, .settings-form label + .settings-inline-field { margin-top: 0; }
.settings-form > label:not(:first-child) { margin-top: 18px; }
.settings-form label span { color: var(--muted); font-weight: 400; }
.settings-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-inline-field { display: flex; align-items: center; gap: 9px; }
.settings-inline-field input { min-width: 0; }
.settings-inline-field .btn { flex: 0 0 auto; white-space: nowrap; }
.settings-help { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.settings-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.connection-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.connection-card strong { font-size: 14px; }
.connection-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.danger-section { border-top-color: rgba(248,113,113,.4); }
.danger-section .section-kicker { color: var(--danger); }
.danger-card { border-color: rgba(248,113,113,.35); background: linear-gradient(90deg, rgba(248,113,113,.055), transparent 50%), var(--panel); }

@media (max-width: 700px) {
  .settings-section { grid-template-columns: 1fr; gap: 12px; padding: 20px 0; }
  .design-extra-group { grid-column: 1; }
  .settings-section-heading { padding: 0; }
  .settings-section-heading > p:last-child { max-width: none; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .connection-card { align-items: flex-start; flex-direction: column; }
  .connection-actions { justify-content: flex-start; }
  .header-project-link { max-width: 150px; }
}

@media (max-width: 700px) {
  main { padding: 18px 14px 28px; gap: 12px; }
  .panel { border-radius: 12px; }
  .project-header { padding: 18px 16px 15px; }
  .source-panel { align-items: flex-start; flex-direction: column; gap: 12px; }
  .source-details { width: 100%; }
  .source-details > summary { display: inline-block; }
  .source-form { width: 100%; }
  .flow-panel { padding: 18px 16px 14px; }
  .run-stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Settings → UI screenshots: screen index + existing-card backfill */
/* Explicit column placement: .settings-section is a 2-column grid, and a bare
   3rd/4th direct child would auto-place into row 2's two columns side by side
   instead of stacking under the form above — this wrapper is one grid item
   (column 2) so its children can stack inside it instead. */
.design-extra-group { grid-column: 2; display: flex; flex-direction: column; }
.design-extra { margin-top: 14px; }
.design-card-title { margin: 0 0 4px; font-size: 15px; }
.design-status { margin: 14px 0 0; font-size: 13.5px; line-height: 1.5; }
.design-screen-list { margin-top: 12px; font-size: 13px; }
.design-screen-list summary { cursor: pointer; color: var(--muted); }
.design-screen-list ul { margin: 10px 0 0; padding-left: 18px; }
.design-screen-list li { margin-bottom: 8px; }
.design-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 13px; }
.design-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.design-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.error-text { color: var(--danger); }
.design-table td:first-child { white-space: nowrap; }

/* Navbar system-status icons (views/partials/statusIndicators.ejs, public/statusIndicators.js).
   Colour is never the only signal: each icon also has a tooltip and aria-label, and the panel spells the state out. */
.status-cluster { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.status-icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
}
.status-icon:hover, .status-icon:focus-visible { border-color: var(--accent); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-icon .status-dot { position: absolute; top: -3px; right: -3px; border: 1.5px solid var(--bg); box-sizing: content-box; }
.status-icon.ok, .status-row-head.ok { color: var(--accent-2); }
.status-icon.ok .status-dot, .status-row-head.ok .status-dot { background: var(--accent-2); }
.status-icon.warn, .status-row-head.warn { color: var(--warn); }
.status-icon.warn .status-dot, .status-row-head.warn .status-dot { background: var(--warn); }
.status-icon.bad, .status-row-head.bad { color: var(--danger); }
.status-icon.bad .status-dot, .status-row-head.bad .status-dot { background: var(--danger); }
.status-icon.pulse .status-dot { animation: pulse-dot 1.2s ease-in-out infinite; }
.status-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; width: 380px; max-width: calc(100vw - 32px);
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); font-size: 12.5px; font-weight: 400; line-height: 1.5;
}
.status-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: 0; }
.status-row-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12px; }
.status-row-word { font-weight: 500; color: var(--muted); margin-left: auto; }
.status-row-line { margin-top: 3px; color: var(--text); overflow-wrap: anywhere; }
.status-row-line a { color: var(--accent); font-weight: 600; }
@media (max-width: 700px) {
  .status-panel { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; max-width: none; }
}

/* Navbar model-spend meter, beside the status icons (views/partials/statusIndicators.ejs, public/statusIndicators.js). */
.spend-meter { position: relative; display: inline-flex; }
.spend-meter summary {
  list-style: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.spend-meter summary::-webkit-details-marker { display: none; }
.spend-meter summary:hover, .spend-meter[open] summary { border-color: var(--accent); }
.spend-meter summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spend-value { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.spend-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; width: 260px; max-width: calc(100vw - 32px);
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); font-weight: 400;
}
.spend-head { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.spend-rows { margin: 0; display: grid; gap: 6px; }
.spend-rows > div { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.spend-rows dt { color: var(--muted); }
.spend-rows dd { margin: 0; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.spend-rows > div:last-child { border-top: 1px solid var(--border); padding-top: 6px; }
.spend-note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
/* On a phone the header's left side wraps so the meter never pushes the page sideways, and its panel spans the width under the header. */
@media (max-width: 700px) {
  header { position: relative; }
  .header-left { flex-wrap: wrap; row-gap: 8px; }
  .spend-label { display: none; }
  .spend-meter { position: static; }
  .spend-panel { top: calc(100% + 6px); left: 16px; right: 16px; width: auto; max-width: none; }
}

.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: normal; cursor: pointer; }
.check-row input { width: auto; margin: 0; }

.routing-form { max-width: none; }
.routing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.routing-toolbar .settings-help { margin: 0; }
.routing-steps { display: flex; flex-direction: column; gap: 18px; }
.routing-step { display: flex; gap: 14px; align-items: flex-start; }
.routing-step-num { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.routing-step-body { flex: 1 1 auto; min-width: 0; }
.routing-step-body > label { display: block; font-weight: 600; margin-bottom: 2px; }
.routing-step-body .settings-help { margin: 0 0 8px; }
.routing-step-body select { width: 100%; }
.routing-summary { margin: 18px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 13px; line-height: 1.5; }
.routing-summary.error { color: var(--danger); border-color: var(--danger); margin-top: 18px; }
.routing-form .settings-actions { margin-top: 16px; }
@media (max-width: 640px) { .routing-toolbar { flex-direction: column; align-items: stretch; } }
