:root {
  --ink: #16211f;
  --muted: #64716d;
  --paper: #f7f6f1;
  --panel: #fffefa;
  --line: #d9d5c9;
  --red: #c62828;
  --red-deep: #941f1f;
  --steel: #24413d;
  --teal: #0f766e;
  --amber: #c17d0f;
  --shadow: 0 18px 50px rgba(22, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(22, 33, 31, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(22, 33, 31, 0.03) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: white;
  background: var(--red);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--red-deep);
}

button:disabled {
  cursor: not-allowed;
  background: #bcb6aa;
}

button.secondary {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

button.secondary:hover {
  color: var(--red-deep);
  background: #fff8f5;
}

button.ghost {
  color: var(--steel);
  background: transparent;
  border: 1px solid var(--line);
}

button.ghost:hover {
  color: var(--red-deep);
  background: #fff8f5;
}

button.tiny-inline {
  width: auto;
  min-height: 0;
  margin-left: 8px;
  padding: 4px 8px;
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 440px);
}

.brand-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(32px, 6vw, 82px);
  color: var(--ink);
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(247, 246, 241, 0.9), rgba(247, 246, 241, 0.94)),
    url("/misumi-visual.png");
  background-size: cover;
  background-position: center;
}

.brand-panel h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 1;
  letter-spacing: 0;
}

.login-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 680px;
}

.login-metrics span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 254, 250, 0.76);
}

.login-metrics b {
  display: block;
  font-size: 30px;
}

.login-card {
  align-self: center;
  width: min(390px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  display: grid;
  gap: 18px;
}

.login-card h2,
.topbar h2,
.panel h3,
.side h1 {
  margin: 0;
  letter-spacing: 0;
}

.login-card label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.run-config-status {
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--steel);
  background: rgba(36, 65, 61, 0.06);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.run-config-status.error {
  border-color: rgba(198, 40, 40, 0.35);
  color: var(--red);
  background: rgba(198, 40, 40, 0.06);
}

.run-config-status.warn {
  border-color: rgba(193, 125, 15, 0.38);
  color: var(--amber);
  background: rgba(193, 125, 15, 0.08);
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  color: var(--ink);
  background: rgba(255, 254, 250, 0.94);
  border-right: 1px solid var(--line);
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--red);
  font-weight: 900;
}

.side nav {
  display: grid;
  gap: 8px;
}

.side a {
  color: var(--steel);
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 12px;
}

.side a:hover {
  background: rgba(198, 40, 40, 0.06);
}

.side a.active {
  color: var(--red-deep);
  background: rgba(198, 40, 40, 0.08);
  border-left: 3px solid var(--red);
  padding-left: 9px;
  font-weight: 700;
}

.session-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.workbench {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 254, 250, 0.94);
}

.topbar {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-strip span,
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--steel);
  background: rgba(255, 254, 250, 0.86);
  font-size: 12px;
  font-weight: 700;
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.grid-secondary {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 20px;
  align-items: start;
}

.workspace-setup-panel {
  margin-bottom: 20px;
}

.setup-grid,
.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.ops-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 253, 247, 0.78);
  display: grid;
  gap: 5px;
}

.ops-card b {
  color: var(--ink);
}

.ops-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.button-row,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.inline-form input {
  min-width: 220px;
}

.inline-form select {
  width: 130px;
}

.project-edit-form {
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.stage-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.stage b {
  display: block;
  margin-bottom: 6px;
}

.stage span {
  color: var(--muted);
  font-size: 13px;
}

pre {
  max-height: 430px;
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  padding: 14px;
  color: #eff8f4;
  background: #17201d;
  line-height: 1.45;
}

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

.agent-card {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.agent-card b {
  display: block;
}

.agent-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.35;
}

.agent-card small {
  color: var(--teal);
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

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

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

.temp-pass {
  margin-top: 12px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 6px;
  padding: 12px;
  color: #075e57;
  background: rgba(15, 118, 110, 0.08);
  font-weight: 800;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.blueprint-list,
.run-list {
  display: grid;
  gap: 10px;
}

.blueprint-card,
.run-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.blueprint-card h4,
.run-card h4 {
  margin: 0 0 6px;
}

.blueprint-card p,
.run-card p {
  margin: 0;
  color: var(--muted);
}

.run-steps {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.run-step {
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 6px;
  padding: 8px;
  color: #075e57;
  background: rgba(15, 118, 110, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.upload-row input[type="file"] {
  padding: 8px 12px;
  background: var(--panel);
}

.upload-row input[type="file"]::file-selector-button {
  min-height: 26px;
  margin-right: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--steel);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.mapping-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.dataset-profile-card {
  margin-top: 10px;
  border: 1px solid rgba(47, 95, 159, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: rgba(47, 95, 159, 0.05);
}

.dataset-profile-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.dataset-profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 8px;
}

.dataset-profile-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 13px;
}

.dataset-profile-card dt {
  color: var(--steel);
  font-weight: 900;
}

.dataset-profile-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.dataset-profile-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--panel-strong);
  color: var(--steel);
  font-size: 12px;
  font-weight: 800;
}

.mapping-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.mapping-title .muted {
  text-transform: none;
  font-weight: 600;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.mapping-grid label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.mapping-grid select {
  min-height: 38px;
  font-size: 13px;
}

@media (max-width: 1040px) {
  .mapping-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.settings-label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

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

.preview-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.preview-controls span {
  margin-right: auto;
  font-size: 13px;
}

.export-box {
  margin-top: 14px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  padding: 14px;
  background: rgba(15, 118, 110, 0.06);
}

.export-box p {
  margin: 0;
  color: #075e57;
  font-weight: 700;
}

#batchPicker select {
  max-width: 320px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  color: white;
  background: var(--red);
  font-weight: 700;
  text-decoration: none;
}

.download-btn:hover {
  background: var(--red-deep);
}

.download-btn.secondary-link {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.run-export-links {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
}

.run-export-links a {
  color: var(--red-deep);
  font-weight: 700;
  font-size: 13px;
}

.run-card .run-execution-note {
  margin-top: 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.compact-row {
  margin-top: 0;
}

.compact-row select {
  min-width: 150px;
}

.audit-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.audit-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.audit-entry.warn {
  border-color: rgba(193, 125, 15, 0.35);
  background: rgba(193, 125, 15, 0.06);
}

.audit-entry.error,
.audit-entry.failed {
  border-color: rgba(198, 40, 40, 0.35);
  background: rgba(198, 40, 40, 0.06);
}

.audit-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.audit-main b,
.audit-main p {
  margin: 0;
}

.audit-main p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.audit-main time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.audit-level {
  min-width: 54px;
  border-radius: 999px;
  padding: 4px 8px;
  color: white;
  background: var(--steel);
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.audit-entry.warn .audit-level {
  background: var(--amber);
}

.audit-entry.error .audit-level,
.audit-entry.failed .audit-level {
  background: var(--red);
}

.audit-entry pre {
  max-height: 210px;
  margin-top: 10px;
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

/* ---------- views ---------- */

.view {
  display: grid;
  gap: 20px;
}

.inline-link {
  color: var(--red-deep);
  font-weight: 700;
}

.flow-callout,
.empty-state {
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(15, 118, 110, 0.06);
}

.flow-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.flow-callout b,
.flow-callout span,
.empty-state b,
.empty-state span {
  display: block;
}

.flow-callout span,
.empty-state span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.manual-run-callout {
  margin-bottom: 0;
}

.manual-run-callout h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.35;
}

.empty-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.empty-state span {
  flex: 1 1 320px;
}

/* ---------- copilot view ---------- */

.copilot-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.96fr) minmax(380px, 1.04fr);
  gap: 18px;
  align-items: start;
}

.start-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.start-card {
  min-height: 124px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: var(--panel);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  text-align: left;
  align-content: start;
}

.start-card:hover {
  border-color: rgba(198, 40, 40, 0.28);
  color: var(--ink);
  background: #fff8f5;
}

.start-card span {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--red-deep);
  background: rgba(198, 40, 40, 0.08);
  font-weight: 800;
  font-size: 12px;
}

.start-card b,
.start-card small {
  display: block;
}

.start-card small {
  color: var(--muted);
  line-height: 1.45;
  font-weight: 500;
}

.copilot-command textarea {
  min-height: 240px;
}

.safe-runner-box {
  margin-top: 14px;
  border: 1px solid rgba(193, 125, 15, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: rgba(193, 125, 15, 0.06);
  display: grid;
  gap: 10px;
}

.safe-runner-box p {
  margin: 0;
  line-height: 1.45;
}

.safe-runner-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.safe-runner-grid label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.copilot-file-review {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.upload-row.compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.copilot-file-card {
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: rgba(15, 118, 110, 0.05);
}

.copilot-file-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.copilot-file-card-head b,
.copilot-file-card-head span {
  overflow-wrap: anywhere;
}

.copilot-file-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.copilot-file-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 13px;
}

.copilot-file-card dt {
  color: var(--steel);
  font-weight: 900;
}

.copilot-file-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.copilot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.copilot-suggestions button {
  min-height: 36px;
  font-size: 12px;
}

.copilot-reply {
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  padding: 14px;
  color: #075e57;
  background: rgba(15, 118, 110, 0.05);
  line-height: 1.55;
  font-weight: 600;
}

.workflow-review {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfaf5;
  margin-bottom: 14px;
}

.workflow-review ol {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.workflow-review li {
  padding-left: 4px;
}

.workflow-review b,
.workflow-review span {
  display: block;
}

.workflow-review b {
  font-size: 13px;
}

.workflow-review span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.copilot-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.copilot-action-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  display: grid;
  gap: 10px;
}

.copilot-action-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.copilot-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--red-deep);
  background: rgba(198, 40, 40, 0.08);
  font-weight: 800;
  flex: none;
}

.copilot-action-card b,
.copilot-action-card small {
  display: block;
}

.copilot-action-card small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.copilot-action-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.copilot-action-card code {
  display: block;
  overflow-wrap: anywhere;
  border-radius: 6px;
  padding: 10px;
  color: #eff8f4;
  background: #17201d;
  line-height: 1.45;
}

.copilot-results {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.copilot-result {
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.copilot-result.ok {
  color: #075e57;
  background: rgba(15, 118, 110, 0.09);
}

.copilot-result.fail {
  color: var(--red-deep);
  background: rgba(198, 40, 40, 0.09);
}

.copilot-result span {
  line-height: 1.45;
}

.copilot-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- pipeline stepper ---------- */

.stepper {
  list-style: none;
  margin: 0;
  padding: 14px 18px;
  display: flex;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 254, 250, 0.94);
}

.stepper li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.stepper li:not(:last-child)::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin: 0 4px;
}

.step-dot {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.stepper li.active .step-dot {
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.stepper li.active {
  color: var(--ink);
}

.stepper li.done .step-dot {
  border-color: var(--teal);
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal);
}

.stepper li.done {
  color: var(--teal);
}

.stepper li.clickable {
  cursor: pointer;
}

.stepper li.clickable:hover .step-label {
  text-decoration: underline;
}

.step-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.step-footer .muted {
  margin-right: auto;
  font-size: 13px;
}

/* ---------- blueprint picker (step 2) ---------- */

.bp-options {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.bp-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  cursor: pointer;
}

.bp-option.selected {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

.bp-option input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
  accent-color: var(--red);
}

.bp-option-body b {
  display: block;
  margin-bottom: 4px;
}

.bp-option-body span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- run progress (step 3) ---------- */

.progress-track {
  height: 10px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--red);
  transition: width 0.4s ease;
}

.run-step {
  border-color: var(--line);
  color: var(--muted);
  background: var(--panel);
}

.run-step small {
  display: block;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.run-step.done {
  border-color: rgba(15, 118, 110, 0.24);
  color: #075e57;
  background: rgba(15, 118, 110, 0.08);
}

.run-step.active {
  border-color: rgba(193, 125, 15, 0.35);
  color: #8a5708;
  background: rgba(193, 125, 15, 0.1);
}

.run-step.paused {
  border-color: rgba(193, 125, 15, 0.45);
  color: #8a5708;
  background: rgba(193, 125, 15, 0.14);
}

@media (max-width: 1040px) {
  .dashboard,
  .login-shell,
  .grid-main,
  .grid-secondary,
  .copilot-layout,
  .setup-grid,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
  }

  .brand-panel {
    min-height: 46vh;
  }
}

@media (max-width: 680px) {
  .workbench,
  .side {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .button-row,
  .inline-form,
  .flow-callout {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-grid,
  .login-metrics,
  .run-steps,
  .start-cards,
  .safe-runner-grid {
    grid-template-columns: 1fr;
  }

  .stepper {
    flex-direction: column;
    align-items: stretch;
  }

  .stepper li:not(:last-child)::after {
    display: none;
  }

  .step-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .step-footer .muted {
    margin-right: 0;
  }

  .brand-panel h1 {
    font-size: 42px;
  }
}

/* ---------- projects view ---------- */

.project-list,
.pipeline-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.project-card,
.pipeline-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 16px 18px;
  display: grid;
  gap: 8px;
}

.project-card {
  cursor: pointer;
}

.project-card:hover {
  border-color: var(--steel);
}

.project-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.project-card-actions .muted {
  margin-right: auto;
}

.project-card-actions button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.project-run-stamp {
  margin: 0;
  color: var(--steel);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.project-card-head,
.pipeline-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sub-head {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.field-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.field-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.45fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.field-card b,
.field-card span,
.field-card small {
  display: block;
}

.field-card span,
.field-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.project-card-head h4,
.pipeline-card-head b {
  margin: 0;
  flex: 1;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill.completed { color: var(--teal); background: rgba(15, 118, 110, 0.12); }
.status-pill.queued { color: var(--steel); background: rgba(36, 65, 61, 0.1); }
.status-pill.processing { color: var(--amber); background: rgba(193, 125, 15, 0.12); }
.status-pill.paused { color: var(--amber); background: rgba(193, 125, 15, 0.14); }
.status-pill.failed { color: var(--red); background: rgba(198, 40, 40, 0.12); }
.status-pill.idle { color: var(--muted); background: rgba(100, 113, 109, 0.1); }

.mini-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf7;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  width: 0%;
  transition: width 0.4s ease;
}

.mini-fill.teal { background: var(--teal); }
.mini-fill.amber { background: var(--amber); }
.mini-fill.red { background: var(--red); }

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.criteria-grid input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}

.settings-label.full-width {
  display: block;
  margin-top: 10px;
}

.settings-label.full-width textarea {
  width: 100%;
  min-height: 86px;
}

.criteria-grid input:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

button.ghost.danger {
  color: var(--red);
  border-color: rgba(198, 40, 40, 0.4);
}

/* ---------- run config (step 2) ---------- */

.run-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.run-config-grid select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}

/* ---------- AI draft blueprint (step 1) ---------- */

.draft-blueprint {
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--panel);
  display: grid;
  gap: 8px;
}

/* ---------- score distribution (step 4) ---------- */

.dist-bars {
  display: grid;
  gap: 6px;
  margin: 8px 0 16px;
}

.dist-row {
  display: grid;
  grid-template-columns: 64px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.dist-label { color: var(--muted); }
.dist-count { text-align: right; }

.dist-track {
  display: block;
  height: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}

.dist-fill {
  display: block;
  height: 100%;
}

.dist-fill.teal { background: var(--teal); }
.dist-fill.amber { background: var(--amber); }
.dist-fill.red { background: var(--red); }

/* ---------- pipeline builder (node canvas) ---------- */

.bp-builder {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bp-title-group { display: flex; flex-direction: column; gap: 4px; }

.bp-name-input {
  width: auto;
  min-width: 240px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  margin-left: -8px;
}

.bp-name-input:hover:not(:disabled) { border-color: var(--line); }
.bp-name-input:focus { border-color: var(--red); background: var(--panel); }
.bp-name-input:disabled { color: var(--muted); background: transparent; }

.bp-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bp-status { margin: 0; }

.bp-stage {
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.bp-canvas {
  position: relative;
  flex: 1;
  min-height: 460px;
  height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(22, 33, 31, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(22, 33, 31, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
}

.bp-canvas:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }

.bp-edges {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.bp-edge {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  opacity: 0.65;
}

.bp-edge.done { stroke: var(--teal); opacity: 1; }

.bp-nodes { position: relative; }

.bp-node {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-sizing: border-box;
  transition: border-color 0.15s, outline-color 0.15s;
}

.bp-node:hover { border-color: var(--steel); }
.bp-node:active { cursor: grabbing; }
.bp-node.selected {
  border-color: var(--red);
  outline: 3px solid rgba(198, 40, 40, 0.12);
}

.bp-node-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink);
}

.bp-node-head b { line-height: 1.4; }

.bp-node-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  flex: 0 0 auto;
}

.bp-node.parallel .bp-node-dot { background: var(--steel); }
.bp-node.done .bp-node-dot { background: var(--teal); }
.bp-node.active .bp-node-dot { background: var(--amber); }

.bp-node-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
}

.bp-node-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }

.bp-node.done { border-color: var(--teal); }
.bp-node.active {
  border-color: var(--amber);
  outline: 3px solid rgba(193, 125, 15, 0.14);
}

/* run states */
.bp-node.active .bp-node-head { color: var(--amber); }

/* inspector */
.bp-inspector {
  flex: 0 0 300px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}

.bp-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bp-inspector-head h4 { margin: 0; color: var(--ink); }

.icon-btn {
  min-height: 28px;
  width: 28px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.icon-btn:hover { background: #fff7f0; color: var(--red-deep); }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 4px 0 0;
}

.bp-inspector textarea { min-height: 120px; }

.bp-checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.bp-checkline input { width: auto; min-height: auto; accent-color: var(--red); }

.bp-agent-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
}

.bp-agent-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.bp-agent-option input { width: auto; min-height: auto; accent-color: var(--red); }

.bp-inspector-actions { margin-top: auto; padding-top: 8px; }

.danger-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--line);
  width: 100%;
}
.danger-ghost:hover { background: #fff1f1; color: var(--red-deep); }

.bp-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

/* command modal */
.bp-modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(22, 33, 31, 0.12);
  max-width: 560px;
  width: calc(100% - 48px);
}
.bp-modal::backdrop { background: rgba(22, 33, 31, 0.4); }
.bp-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.bp-modal-body textarea { min-height: 150px; }
.bp-modal-actions { justify-content: flex-end; }

@media (max-width: 900px) {
  .bp-stage { flex-direction: column; }
  .bp-inspector { flex-basis: auto; max-height: none; }
}

/* run-from-project flow */
.run-context-banner {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.07);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.pipeline-card-actions {
  display: inline-flex;
  gap: 8px;
  margin-left: auto;
}

.pipeline-card-actions button { min-height: 34px; padding: 0 14px; }

.pipeline-name-input {
  min-width: 220px;
  flex: 1;
}

.pipeline-description-input {
  min-width: 260px;
  flex: 1.4;
}

.pipeline-blueprint-select {
  width: 190px;
}

/* per-provider API key settings */
.keys-eyebrow { margin-top: 16px; }
.keys-grid { display: flex; flex-direction: column; gap: 12px; }

.key-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
}
.key-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.key-row-head b { font-size: 14px; }
.key-status { font-size: 12px; }
.key-row-input { display: flex; gap: 8px; align-items: center; }
.key-row-input input { flex: 1; }
.key-row-input button { min-height: 38px; padding: 0 12px; flex: 0 0 auto; }

/* row review */
.review-panel { margin-top: 18px; }
.row-review-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.row-review-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  font-size: 13px;
}
.row-review-table th,
.row-review-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.row-review-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: rgba(217, 213, 201, 0.24);
}
.row-review-table td b,
.row-review-table td span {
  display: block;
}
.row-review-table tr.review {
  background: rgba(193, 125, 15, 0.07);
}
.row-review-table tr.fail {
  background: rgba(198, 40, 40, 0.06);
}
.qa-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}
.qa-chip.pass { color: #075e57; background: rgba(15, 118, 110, 0.12); }
.qa-chip.review { color: #8a5708; background: rgba(193, 125, 15, 0.14); }
.qa-chip.fail { color: var(--red); background: rgba(198, 40, 40, 0.12); }
.decision-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(100, 113, 109, 0.12);
  color: var(--muted);
}
.decision-chip.approved { color: #075e57; background: rgba(15, 118, 110, 0.12); }
.decision-chip.rejected { color: var(--red); background: rgba(198, 40, 40, 0.12); }
.row-review-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.review-actions {
  min-width: 190px;
}
.review-actions .tiny {
  min-height: 28px;
  padding: 0 8px;
  margin: 0 4px 4px 0;
  font-size: 12px;
}
