/* ==========================================================================
   The Builder Itinerary: Agent Core Creation & Management (Impeccable Design)
   ========================================================================== */

/* 1. Builder Itinerary Stepper */
.builder-itinerary-rail {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  background: var(--paper-light);
  overflow-x: auto;
}
.builder-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  opacity: 0.65;
  transition: opacity 0.18s ease;
}
.builder-step.is-active {
  opacity: 1;
}
.step-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  font: 700 11px/1 "DM Mono", ui-monospace, monospace;
}
.builder-step.is-active .step-num {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}
.step-info {
  display: grid;
  gap: 1px;
}
.step-info strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.builder-step.is-active .step-info strong {
  color: var(--brand);
}
.step-info small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.step-arrow {
  color: var(--line-strong);
  font-size: 14px;
  user-select: none;
}

/* 2. Visual Harness Selector Cards */

/* 3. Prompt Presets Bar */

/* 5. Core Empty State */
.core-empty-workbench {
  padding: 42px 32px;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  background: var(--paper-light);
  text-align: center;
}
.core-empty-workbench h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
.core-empty-workbench p {
  max-width: 560px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.core-empty-itinerary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  max-width: 720px;
  margin: 0 auto 28px;
  text-align: left;
}
.empty-itinerary-item {
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.empty-itinerary-item span {
  font: 700 11px/1 "DM Mono", ui-monospace, monospace;
  color: var(--brand);
}
.empty-itinerary-item strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 12px;
  color: var(--ink);
}
.empty-itinerary-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

/* 6. Delete Action Confirmation */
.btn-delete-core {
  color: var(--red) !important;
  border-color: color-mix(in srgb, var(--red) 35%, var(--line)) !important;
}
.btn-delete-core:hover {
  background: var(--red-bg) !important;
  border-color: var(--red) !important;
  color: var(--red) !important;
}

@media (max-width: 800px) {
  .core-empty-itinerary {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   Agent & Workspace Lifecycle Redesign Styles (Phase 2b)
   ========================================================================== */

/* 1. Modal Backdrops & Dialogs */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 34, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.is-open {
  display: flex;
}
.modal-dialog {
  background: #ffffff;
  border-radius: 8px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 12px 32px rgba(15, 30, 34, 0.18);
  border: 1px solid var(--rule, #d5e3df);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: modalPop 0.15s ease-out;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule-light, #e6eeec);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #162b31);
  margin: 0;
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--ink-faint, #809699);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}
.modal-close-btn:hover {
  color: var(--ink, #162b31);
  background: var(--rule-light, #e6eeec);
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--ink, #162b31);
  line-height: 1.5;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--rule-light, #e6eeec);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-subtle, #f8faf9);
}

/* 2. Two-Dimensional Capability Badges & Status Tags */
.badge-source-agent {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
  white-space: nowrap;
}
.badge-source-override {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
  white-space: nowrap;
}
.badge-auth-personal {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
  white-space: nowrap;
}
.cap-status-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.cap-status-tag.ready {
  background: #e8f5ec;
  color: var(--leaf-deep, #0e562a);
}
.cap-status-tag.loading {
  background: #fffbeb;
  color: #b45309;
}
.cap-status-tag.error {
  background: #fef2f2;
  color: var(--danger, #b91c1c);
}
.installed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 5px;
}
.installed-dot.ready { background: #16803f; }
.installed-dot.loading { background: #d97706; }
.installed-dot.error { background: #b91c1c; }
.spinner-dark {
  width: 9px;
  height: 9px;
  border-width: 1.5px;
  border-style: solid;
  border-color: rgba(3, 105, 161, 0.25);
  border-top-color: #0369a1;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

/* 3. Installed Capability Cards */
.installed-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 6px;
  margin-bottom: 8px;
}
.installed-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.installed-titles strong {
  font-size: 13px;
  color: var(--ink, #162b31);
}
.installed-titles p {
  font-size: 11.5px;
  color: var(--ink-muted, #52666a);
  margin: 2px 0 0;
}
.installed-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}
.installed-save-hint {
  font-size: 10.5px !important;
  color: var(--ink-faint, #809699) !important;
  margin-top: 2px !important;
}
.btn-save-item-agent {
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  color: var(--leaf-deep, #0e562a);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-save-item-agent:hover:not(:disabled) {
  background: #e8f5ec;
  border-color: var(--leaf, #16803f);
}
.btn-save-item-agent:disabled {
  background: #f1f5f4;
  color: var(--ink-faint, #809699);
  border-color: var(--rule-light, #e6eeec);
  cursor: not-allowed;
  opacity: 0.7;
}

/* 4. Editor Dirty Tracking & Status Pills */
.flow-status-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  background: #e8f5ec;
  color: var(--leaf-deep, #0e562a);
}
.flow-status-live.is-dirty {
  background: #fef3c7 !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
}
.flow-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16803f;
}
.flow-status-live.is-dirty .flow-status-dot {
  background: #f59e0b !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25) !important;
}
.editor-dirty-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #92400e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#btn-header-save.is-dirty, .btn-header-save.is-dirty {
  border-color: var(--leaf, #16803f) !important;
  color: var(--leaf-deep, #0e562a) !important;
}
.unsaved-changes-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #b45309;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.unsaved-changes-chip:hover {
  background: #fde68a;
  border-color: #f59e0b;
}
.behind-pill {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  font-family: var(--font-mono, monospace);
  display: inline-block;
}

/* 5. Save to Agent Modal Components */
.save-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule-light, #e6eeec);
}
.save-item-row:last-child {
  border-bottom: none;
}
.save-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.save-item-info > div { min-width: 0; overflow-wrap: anywhere; }
.save-item-info label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 500;
}
.save-item-info input[type="checkbox"] { width: 14px; height: 14px; padding: 0; margin: 0; flex-shrink: 0; }
.save-item-status { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .save-item-row { flex-wrap: wrap; padding: 10px 0; }
  .save-item-info { width: 100%; align-items: flex-start; }
  .save-item-status { width: 100%; }
}
.save-item-badge.add {
  background: #dcfce7;
  color: #15803d;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.save-item-badge.remove {
  background: #fee2e2;
  color: #b91c1c;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.badge-synced {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}
.badge-already-synced {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}
.badge-unsaved-err {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

/* 6. Revisions Slide-Over Drawer */
.revision-slideover-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 34, 0.35);
  backdrop-filter: blur(1.5px);
  z-index: 990;
}
.revision-slideover-backdrop.is-open {
  display: block;
}
.revision-slideover {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(520px, 92vw);
  background: #ffffff;
  z-index: 1000;
  box-shadow: -8px 0 28px rgba(15, 30, 34, 0.14);
  border-left: 1px solid var(--rule, #d5e3df);
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}
.revision-slideover.is-open {
  transform: translateX(0);
  visibility: visible;
}
.slideover-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--rule-light, #e6eeec);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.slideover-close-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--ink-faint, #809699);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.slideover-close-btn:hover { color: var(--ink, #162b31); }
.slideover-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.slideover-explainer {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.45;
}
.rev-timeline-item {
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 6px;
  padding: 12px 14px;
  background: #ffffff;
}
.rev-timeline-item.active-deployed {
  border-color: #2e9e62;
  box-shadow: 0 0 0 1px #2e9e62;
}

/* 7. Overflow Menus (Z-Index Fixed to Prevent Card Clash) */
.overflow-menu-container {
  position: relative;
  display: inline-block;
}
.overflow-btn {
  background: transparent;
  border: 1px solid var(--rule, #d5e3df);
  color: var(--ink-muted, #52666a);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.overflow-btn:hover {
  background: var(--surface-subtle, #f8faf9);
  color: var(--ink, #162b31);
}
.overflow-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 170px;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 30, 34, 0.16);
  z-index: 250;
  padding: 4px 0;
}
.overflow-dropdown.is-open {
  display: block;
}
.overflow-item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--ink, #162b31);
  cursor: pointer;
  transition: background 0.1s ease;
  white-space: nowrap;
}
.overflow-item:hover {
  background: var(--surface-subtle, #f8faf9);
}
.overflow-item.danger {
  color: var(--danger, #b91c1c);
}
.overflow-item.danger:hover {
  background: #fef2f2;
}
.overflow-divider {
  height: 1px;
  background: var(--rule-light, #e6eeec);
  margin: 4px 0;
}
.core-card-item.has-open-menu {
  z-index: 100 !important;
  position: relative !important;
}

/* 8. Deploy Target Modal Cards */
.model-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.model-option-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  background: #ffffff;
}
.model-option-card:hover {
  border-color: #94a3b8;
  background: var(--surface-subtle, #f8faf9);
}
.model-option-card.is-selected {
  border-color: var(--leaf, #16803f);
  background: #f0fdf4;
  box-shadow: 0 0 0 1px var(--leaf, #16803f);
}
.env-id-pill {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--ink-faint, #809699);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

/* 10. Phase 2b Unified Flow Header & Layout Components */
.unified-flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  height: 50px;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: var(--radius-md, 4px);
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
}
.flow-identity-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.flow-crumb-back {
  background: transparent;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted, #52666a);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.flow-crumb-back:hover {
  color: var(--leaf, #16803f);
}
.flow-crumb-divider {
  color: var(--rule-light, #e6eeec);
  font-size: 13px;
  flex-shrink: 0;
}
.flow-title-text {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink, #162b31);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  flex-shrink: 1;
}
.flow-chip-rev {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  background: #f1f5f9;
  color: #475569;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.flow-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body, "Manrope", sans-serif);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-md, 4px);
  padding: 6px 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.3;
  text-decoration: none;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 11.5px;
}
.btn-primary {
  background: var(--brand, #16803f);
  color: #ffffff;
  border-color: var(--brand, #16803f);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover, #0d6630);
  border-color: var(--brand-hover, #0d6630);
  color: #ffffff;
}
.btn-secondary {
  background: #ffffff;
  color: var(--ink, #162b31);
  border-color: var(--rule, #d5e3df);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle, #f8faf9);
  border-color: #94a3b8;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Header unsaved changes */
.btn-unsaved-chip {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.btn-unsaved-chip:hover {
  background: #fef3c7;
  border-color: #fcd34d;
}
/* Workspace Agent Updated Banner */
.ws-agent-updated-banner {
  display: none;
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #166534;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}
.ws-agent-updated-banner.is-visible {
  display: flex;
}
.ws-agent-updated-left {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ws-agent-updated-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .ws-agent-updated-banner { flex-wrap: wrap; padding: 10px 12px; }
  .ws-agent-updated-actions { margin-left: auto; }
}
.btn-ws-banner-cta {
  background: #16803f;
  color: #ffffff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.btn-ws-banner-cta:hover {
  background: #116833;
}
.btn-ws-banner-dismiss {
  background: transparent;
  border: none;
  color: #166534;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
}

/* Builder card & Editor Layout */
.builder-card {
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: var(--radius-md, 4px);
  padding: 24px 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  margin-bottom: 24px;
}
.form-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #162b31);
}
.field-helper {
  font-size: 12px;
  color: var(--ink-muted, #52666a);
}
.input-text, .input-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-body, "Manrope", sans-serif);
  border: 1px solid var(--rule, #d5e3df);
  border-radius: var(--radius-md, 4px);
  background: #ffffff;
  color: var(--ink, #162b31);
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}
.input-text:focus, .input-textarea:focus {
  border-color: var(--leaf, #16803f);
  box-shadow: 0 0 0 2px rgba(22, 128, 63, 0.12);
}
.input-textarea {
  font-family: var(--font-mono, monospace);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 90px;
}

/* Engine Cards Grid */
.engine-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 768px) {
  .engine-cards-grid {
    grid-template-columns: 1fr;
  }
}
.engine-card {
  border: 1.5px solid var(--rule, #d5e3df);
  border-radius: var(--radius-md, 4px);
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  transition: all 0.15s ease;
  position: relative;
  text-align: left;
}
.engine-card:hover {
  border-color: #bccbc7;
  background: var(--surface-subtle, #f8faf9);
}
.engine-card.is-selected {
  border-color: var(--leaf, #16803f);
  background: #f6fcf8;
  box-shadow: 0 0 0 1.5px var(--leaf, #16803f);
}
.engine-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.engine-pill {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 2px;
  letter-spacing: 0.04em;
}
.engine-pill.codex { background: #e0f2fe; color: #0369a1; }
.engine-pill.dsh { background: #fef3c7; color: #92400e; }
.engine-pill.opencode { background: #f3e8ff; color: #7e22ce; }
.engine-radio-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.engine-selected-text {
  display: none;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--leaf, #16803f);
  background: #e8f5ec;
  padding: 1px 6px;
  border-radius: 3px;
}
.engine-radio-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--rule, #d5e3df);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.engine-radio-circle .radio-inner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--leaf, #16803f);
  display: none;
}
.engine-card.is-selected .engine-selected-text {
  display: inline-block;
}
.engine-card.is-selected .engine-radio-circle {
  border-color: var(--leaf, #16803f);
}
.engine-card.is-selected .engine-radio-circle .radio-inner-dot {
  display: block;
}
.engine-card strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #162b31);
}
.engine-card p {
  font-size: 11.5px;
  color: var(--ink-muted, #52666a);
  line-height: 1.4;
  margin: 0;
}

/* Prompt Template Pills */
.prompt-template-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.prompt-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--surface-subtle, #f8faf9);
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 3px;
  color: var(--ink-muted, #52666a);
  cursor: pointer;
  transition: all 0.15s ease;
}
.prompt-pill:hover {
  background: #eaf5ed;
  color: var(--leaf, #16803f);
  border-color: #c2e2ce;
}

/* Model Row Compact */
.model-row-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: var(--radius-md, 4px);
  padding: 10px 14px;
}
.model-summary-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.model-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--leaf, #16803f);
  box-shadow: 0 0 0 2px rgba(22, 128, 63, 0.2);
  flex-shrink: 0;
}
.model-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.model-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #162b31);
}
.model-sub {
  font-size: 11.5px;
  color: var(--ink-muted, #52666a);
}

/* Step 1 Action Bar */
.step1-action-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-light, #e6eeec);
}

/* All Agents List Inventory */
.inventory-header-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.inventory-heading-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inventory-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.inventory-title-row h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink, #162b31);
  letter-spacing: 0;
  margin: 0;
}
.inventory-count-pill {
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted, #52666a);
  background: var(--surface-subtle, #f8faf9);
  border: 1px solid var(--rule, #d5e3df);
  padding: 2px 8px;
  border-radius: 12px;
}
.inventory-desc {
  font-size: 13px;
  color: var(--ink-muted, #52666a);
  margin: 0;
  max-width: 600px;
  line-height: 1.4;
}
.inventory-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.inventory-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inv-search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 320px;
  display: flex;
  align-items: center;
}
.inv-search-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--ink-faint, #809699);
  pointer-events: none;
}
.inv-search-input {
  width: 100%;
  height: 34px;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 8px;
  padding: 6px 28px 6px 32px;
  font-family: var(--font-body, "Manrope", sans-serif);
  font-size: 12.5px;
  color: var(--ink, #162b31);
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  box-sizing: border-box;
}
.inv-search-input:focus {
  border-color: var(--leaf, #16803f);
  box-shadow: 0 0 0 3px #eaf5ed;
}
.inv-search-clear {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--ink-faint, #809699);
  font-size: 14px;
  cursor: pointer;
  display: none;
}
.inv-search-clear:hover { color: var(--ink, #162b31); }
.inv-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.inv-engine-pills {
  display: flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.inv-pill-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-muted, #52666a);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.inv-pill-btn:hover { color: var(--ink, #162b31); }
.inv-pill-btn.is-active {
  background: #ffffff;
  color: var(--ink, #162b31);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.inv-select {
  width: auto;
  flex: 0 0 auto;
  height: 32px;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 8px;
  padding: 0 10px;
  font-family: var(--font-body, "Manrope", sans-serif);
  font-size: 11.5px;
  color: var(--ink, #162b31);
  cursor: pointer;
  outline: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: border-color 0.12s ease;
}
.inv-select:focus {
  border-color: var(--leaf, #16803f);
}
.inv-view-toggle {
  display: flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.view-toggle-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink-muted, #52666a);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s ease;
}
.view-toggle-btn:hover { color: var(--ink, #162b31); }
.view-toggle-btn.is-active {
  background: #ffffff;
  color: var(--leaf-deep, #0e562a);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Core Cards List */
.core-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.core-card-item {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border: 1px solid var(--rule, #d5e3df);
  border-radius: 8px;
  padding: 16px 20px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}
.core-card-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}
.core-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.core-card-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}
.core-engine-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  flex-shrink: 0;
}
.core-engine-avatar.codex { background: #f0fdf4; color: #16a34a; border: 1px solid #dcfce7; }
.core-engine-avatar.dsh { background: #eef2ff; color: #4f46e5; border: 1px solid #e0e7ff; }
.core-engine-avatar.opencode { background: #faf5ff; color: #9333ea; border: 1px solid #f3e8ff; }
.core-card-title-group {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.core-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.core-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #162b31);
  line-height: 1.25;
  letter-spacing: 0;
}
.core-card-role-desc {
  font-size: 12.5px;
  color: var(--ink-muted, #52666a);
  margin: 0;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 720px;
}
.core-card-meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted, #52666a);
  margin-top: 2px;
}
.core-card-meta-line .meta-sep {
  color: #cbd5e1;
  font-size: 10px;
}
.core-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.1s ease;
}
.core-status-pill:hover { opacity: 0.85; }
.core-status-pill.production {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.core-status-pill.staging {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.core-status-pill.ready {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.core-status-pill.draft {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.core-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.core-status-pill.production .core-status-dot { background: #16a34a; }
.core-status-pill.staging .core-status-dot { background: #2563eb; }
.core-status-pill.ready .core-status-dot { background: #059669; }
.core-status-pill.draft .core-status-dot { background: #d97706; }
.core-card-tag {
  background: var(--surface-subtle, #f8faf9);
  border: 1px solid var(--rule-light, #e6eeec);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--ink-muted, #52666a);
}
.core-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  justify-content: flex-end;
}

/* Empty Workbench State */
.empty-workbench {
  padding: 48px 24px;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface-subtle, #f8faf9);
  border: 1px solid var(--rule, #d5e3df);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted, #52666a);
  margin-bottom: 12px;
}
.empty-workbench h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink, #162b31);
  margin: 12px 0 6px;
}
.empty-workbench p {
  font-size: 13px;
  color: var(--ink-muted, #52666a);
  line-height: 1.5;
  margin-bottom: 20px;
}
@media (max-width: 680px) {
}

/* Environment Cards - Apple/Vercel Serenity */
.env-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .env-cards-grid { grid-template-columns: 1fr; }
}
.env-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--rule, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.env-card:hover {
  border-color: var(--rule-focus, #cbd5e1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.env-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule-light, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-subtle, #fafbfc);
}
.env-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.env-title-group h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink, #162b31);
  margin: 0;
}
.env-id-pill {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--ink-faint, #64748b);
  background: var(--surface-raised, #f1f5f9);
  padding: 2px 6px;
  border-radius: 4px;
}
.badge-env-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  background: #dcfce7;
  padding: 3px 8px;
  border-radius: 12px;
}
.badge-env-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}
.env-card-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.env-agent-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink, #162b31);
  margin-bottom: 2px;
}
.env-details-strip {
  padding: 12px 0 0;
  border-top: 1px solid var(--rule-light, #f1f5f9);
  font-size: 11.5px;
  color: var(--ink-muted, #52666a);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.env-details-strip strong {
  color: var(--ink, #162b31);
}
.env-card-footer {
  padding: 12px 20px;
  background: var(--surface-subtle, #fafbfc);
  border-top: 1px solid var(--rule-light, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--ink-faint, #64748b);
}
.env-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Approved lifecycle Console surfaces. */
.sidebar nav a.active { background: rgb(255 255 255 / 12%); border-radius: 4px; }
.agent-inventory { width: 100%; }
.deployments-inventory { max-width: 960px; margin: 0 auto; }
.agent-inventory [hidden], .deployments-inventory [hidden] { display: none; }
.agent-inventory .inv-search-wrap > .ui-icon { position: absolute; left: 10px; pointer-events: none; }
.agent-inventory .inv-search-wrap svg { position: static; }
.agent-inventory .core-card-meta-line { flex-wrap: wrap; }
.agent-inventory .core-card-name, .agent-inventory td, .flow-title-text { overflow-wrap: anywhere; }
.core-data-table td > small { display: block; color: var(--ink-muted); margin-top: 4px; }
.agent-inventory .core-table-container { overflow: visible; }
.agent-inventory .revision-actions > div, .env-card .revision-actions > div { z-index: 50; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.agent-editor .unified-flow-header { min-height: 50px; height: auto; padding: 10px 16px; }
.agent-editor-layout > #form { padding: 24px 0; }
.agent-editor .editor-dirty-banner { max-width: 800px; margin: 0 auto; }
.editor-instructions-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.agent-editor .field-group { margin: 0; }
.agent-editor .field-label { font-size: 13px; text-transform: none; letter-spacing: 0; }
.agent-editor .engine-card { min-width: 0; white-space: normal; min-height: 150px; }
.agent-editor .engine-card strong { font-size: 12px; }
.agent-editor .engine-pill { letter-spacing: 0; }
.agent-editor .prompt-pill { min-height: 24px; padding: 2px 8px; font-size: 11px; }
.agent-editor .model-connection-field { display: flex; gap: 8px; }
.agent-editor #model-picker { padding-top: 8px; }
.agent-editor #model-summary[hidden], .agent-editor #model-picker[hidden], .agent-editor .inline-connection-form[hidden] { display: none; }
.agent-editor .model-title, .agent-editor .model-sub { overflow-wrap: anywhere; }
.agent-editor .model-connection-field #connection-summary { margin: 0; padding: 0; border: 0; background: transparent; }
.agent-editor .editor-advanced { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; }
.editor-advanced-fields { display: grid; gap: 18px; padding-top: 16px; }
.editor-advanced-fields fieldset { padding: 0; border: 0; background: transparent; min-width: 0; }
.editor-advanced-fields legend { margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.editor-advanced-fields textarea { min-height: 100px; }
.agent-editor .step1-action-bar { align-items: flex-start; }
.env-title-group { flex-wrap: wrap; min-width: 0; }
.env-title-group h3, .env-agent-name { overflow-wrap: anywhere; }
.env-card-footer { flex-wrap: wrap; }
.env-card-actions { flex-wrap: wrap; }
.env-release-time { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.badge-env-live.is-paused { background: #f1f5f4; color: var(--ink-muted); }
.badge-env-live.is-paused::before { background: var(--ink-muted); }
.env-card:has(.revision-actions[open]) { z-index: 20; }
.env-audit-box { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 24px; }
.env-audit-header h2 { font-size: 13px; margin: 0 0 12px; }
.env-audit-item, .env-audit-left { display: flex; align-items: baseline; gap: 14px; }
.env-audit-item { justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); font-size: 12px; }
.env-audit-time { color: var(--ink-muted); font-size: 11px; min-width: 150px; }
.env-audit-desc { overflow-wrap: anywhere; }
.env-audit-digest { color: var(--ink-muted); font-size: 11px; }
.revision-slideover .file-diff { min-width: 0; }
.revision-slideover .file-diff pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.revision-slideover .slideover-title-group { min-width: 0; overflow-wrap: anywhere; }
.revision-slideover .slideover-title-group h3 { font-size: 15px; margin: 0; }
.revision-slideover .slideover-title-group p { font-size: 11px; margin: 4px 0 0; }
@media (max-width: 800px) {
  .inventory-header-strip { flex-wrap: wrap; gap: 12px; }
  .inventory-actions-right { margin-left: auto; }
  .inventory-control-bar { align-items: stretch; }
  .inv-search-wrap { max-width: none; flex-basis: 100%; }
  .inv-filter-group { min-width: 0; width: 100%; flex-wrap: wrap; }
  .inv-engine-pills { flex: 1 0 100%; min-width: 0; flex-wrap: nowrap; }
  .inv-pill-btn { flex: 1; padding: 6px 8px; }
  .agent-inventory .core-card-top { align-items: stretch; flex-direction: column; gap: 12px; }
  .agent-inventory .core-card-identity { align-items: flex-start; }
  .agent-inventory .core-card-actions { justify-content: flex-end; }
  .agent-inventory .core-data-table, .agent-inventory .core-data-table tbody { display: block; }
  .agent-inventory .core-data-table thead { display: none; }
  .agent-inventory .core-data-table tr { display: grid; padding: 12px; border-bottom: 1px solid var(--line); }
  .agent-inventory .core-data-table td { display: block; padding: 6px 0; border: 0; }
  .agent-inventory .core-data-table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ink-muted); margin-bottom: 3px; }
  .agent-editor .unified-flow-header { align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .agent-editor .flow-identity-group { width: 100%; flex-wrap: wrap; }
  .agent-editor .flow-title-text { max-width: 100%; white-space: normal; }
  .agent-editor #flow-header-center-info { display: none !important; }
  .agent-editor .flow-nav-actions { margin-left: auto; }
  .agent-editor-layout > #form { padding: 20px 0; }
  .agent-editor .engine-card { min-height: 130px; }
  .agent-editor .prompt-pill { min-height: 36px; }
  .agent-editor .model-row-compact { flex-wrap: wrap; }
  .editor-dirty-banner { flex-wrap: wrap; }
  .env-audit-left { flex-direction: column; gap: 4px; }
  .env-audit-item { align-items: flex-start; }
  .view-toggle-btn, .revision-actions summary, .slideover-close-btn { min-width: 36px; min-height: 36px; }
}
