/* 项目凭据管理页（#projectCredentialsView）与流程设置里的项目凭据选择（#workflowProjectCredentials）。
 * 令牌与按钮、输入框基础规范来自 app/harness-ui.css；本文件只定义布局与页面差异。
 */
#projectCredentialsView .harness-icon {
  flex: none;
}

#projectCredentialsView .page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 0 0 18px;
}

#projectCredentialsView .page-heading > div:first-child {
  min-width: 0;
  max-width: none;
}

#projectCredentialsView .page-heading .heading-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
}

#projectCredentialsView .project-credential-heading-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

#projectCredentialsView .project-credential-heading-title h1 {
  margin: 0;
}

#projectCredentialsView .project-credential-project-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border: 1px solid var(--hui-border);
  border-radius: 999px;
  background: var(--hui-soft);
  color: var(--hui-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

#projectCredentialsView .project-credential-page-desc {
  margin: 6px 0 0;
  color: var(--hui-secondary);
  font-size: 13px;
  line-height: 1.55;
}

#projectCredentialsView .project-credential-shell {
  min-width: 0;
}

#projectCredentialsView .project-credential-panel {
  box-sizing: border-box;
  border: 1px solid var(--hui-border);
  border-radius: 14px;
  background: var(--hui-surface);
  box-shadow: var(--hui-panel-shadow);
  overflow: hidden;
}

/* ---------- Panel head / foot & loading / empty states ---------- */
#projectCredentialsView .project-credential-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 52px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hui-border);
}

#projectCredentialsView .project-credential-panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--hui-text);
  font: 600 14px/1.3 var(--hui-sans);
}

#projectCredentialsView .project-credential-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--hui-soft);
  color: var(--hui-muted);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#projectCredentialsView .project-credential-panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

#projectCredentialsView .project-credential-panel-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--hui-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

#projectCredentialsView .project-credential-panel-hint .harness-icon {
  color: var(--hui-tertiary);
}

#projectCredentialsView .project-credential-panel-foot {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--hui-border-soft);
  background: var(--hui-canvas);
  color: var(--hui-muted);
  font-size: 12.5px;
  line-height: 1.55;
}

#projectCredentialsView .project-credential-panel-foot .harness-icon {
  margin-top: 2px;
  color: var(--hui-tertiary);
}

#projectCredentialsView .project-credential-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 32px 18px;
  color: var(--hui-muted);
  font-size: 13px;
}

#projectCredentialsView .project-credential-loading svg {
  animation: pc-spin .9s linear infinite;
}

@keyframes pc-spin {
  to { transform: rotate(360deg); }
}

#projectCredentialsView .project-credential-empty {
  display: grid;
  justify-items: center;
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 20px 52px;
  text-align: center;
}

#projectCredentialsView .project-credential-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--hui-accent-soft);
  color: var(--hui-accent);
}

#projectCredentialsView .project-credential-empty.is-error .project-credential-empty-icon {
  background: color-mix(in srgb, var(--hui-error) 10%, var(--hui-surface));
  color: var(--hui-error);
}

#projectCredentialsView .project-credential-empty h2 {
  margin: 0 0 6px;
  color: var(--hui-text);
  font: 600 16px/1.35 var(--hui-sans);
}

#projectCredentialsView .project-credential-empty p {
  margin: 0;
  color: var(--hui-secondary);
  font-size: 13px;
  line-height: 1.6;
}

#projectCredentialsView .project-credential-guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin: 22px 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

#projectCredentialsView .project-credential-guide-steps li {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--hui-border);
  border-radius: 10px;
  background: var(--hui-canvas);
  color: var(--hui-muted);
  font-size: 12px;
  line-height: 1.5;
}

#projectCredentialsView .project-credential-guide-steps b {
  color: var(--hui-text);
  font-size: 13px;
  font-weight: 500;
}

#projectCredentialsView .project-credential-ro-note {
  margin-top: 6px;
  color: var(--hui-tertiary);
  font-size: 12.5px;
}

#projectCredentialsView .project-credential-empty > .button {
  margin-top: 18px;
}

#projectCredentialsView .project-credential-guide-steps + .button {
  margin-top: 0;
}

/* ---------- List rows ---------- */
#projectCredentialsView .project-credential-row-head,
#projectCredentialsView .project-credential-item {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(240px, 1.55fr) 100px 88px;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
}

#projectCredentialsView .project-credential-row-head {
  height: 36px;
  border-bottom: 1px solid var(--hui-border-soft);
  color: var(--hui-tertiary);
  font-size: 12px;
  font-weight: 400;
}

#projectCredentialsView .project-credential-row-head .is-end,
#projectCredentialsView .project-credential-actions {
  display: flex;
  justify-content: flex-end;
}

#projectCredentialsView .project-credential-item {
  min-height: 62px;
  padding-block: 12px;
  transition: background-color .16s var(--hui-ease-flow);
}

#projectCredentialsView .project-credential-item:hover {
  background: color-mix(in srgb, var(--hui-text) 2.5%, transparent);
}

#projectCredentialsView .project-credential-item + .project-credential-item {
  border-top: 1px solid var(--hui-border-soft);
}

#projectCredentialsView .project-credential-item.is-disabled .project-credential-main {
  opacity: .72;
}

#projectCredentialsView .project-credential-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#projectCredentialsView .project-credential-tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--hui-soft);
  color: var(--hui-secondary);
}

#projectCredentialsView .project-credential-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#projectCredentialsView .project-credential-copy strong {
  color: var(--hui-text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

#projectCredentialsView .project-credential-kind {
  color: var(--hui-tertiary);
  font-size: 12px;
  line-height: 1.4;
}

#projectCredentialsView .project-credential-variables {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

#projectCredentialsView .project-credential-variables code {
  border: 1px solid var(--hui-border-soft);
  border-radius: 6px;
  background: var(--hui-soft);
  padding: 3px 7px;
  color: var(--hui-text);
  font: 500 12px/1.35 var(--hui-mono);
  overflow-wrap: anywhere;
}

#projectCredentialsView .project-credential-status {
  display: flex;
  align-items: center;
}

#projectCredentialsView .project-credential-ro-hint {
  color: var(--hui-tertiary);
  font-size: 12px;
}

/* ---------- Create / Edit 2-column layout ---------- */
#projectCredentialsView .project-credential-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 16px;
  align-items: start;
}

#projectCredentialsView .project-credential-editor-head {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--hui-border);
}

#projectCredentialsView .project-credential-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--hui-tertiary);
  font-size: 13px;
}

#projectCredentialsView .project-credential-crumb-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 4px 6px;
  margin-inline-start: -6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--hui-muted);
  font: 400 13px/1 var(--hui-sans);
  cursor: pointer;
  transition: color .16s var(--hui-ease-flow), background-color .16s var(--hui-ease-flow);
}

#projectCredentialsView .project-credential-crumb-link:hover {
  background: var(--hui-soft);
  color: var(--hui-text);
}

#projectCredentialsView .project-credential-crumb-link:focus-visible {
  outline: 2px solid var(--hui-focus-ring);
  outline-offset: 1px;
}

#projectCredentialsView .project-credential-crumb-current {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--hui-text);
  font: 600 14px/1.3 var(--hui-sans);
}

#projectCredentialsView .project-credential-form {
  display: block;
}

#projectCredentialsView .project-credential-editor-body {
  display: grid;
  gap: 20px;
  padding: 20px;
}

#projectCredentialsView .project-credential-form-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

#projectCredentialsView .project-credential-field-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#projectCredentialsView .project-credential-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--hui-secondary);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}

#projectCredentialsView .project-credential-req {
  color: var(--hui-error);
}

#projectCredentialsView .project-credential-hint {
  color: var(--hui-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

#projectCredentialsView .input,
#projectCredentialsView .select {
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  min-height: 36px;
  padding: 0 11px;
  font: 400 13px/1.4 var(--hui-sans);
}

#projectCredentialsView .input.project-credential-mono {
  font-family: var(--hui-mono);
  font-size: 12.5px;
}

#projectCredentialsView .input:is([aria-invalid="true"], :user-invalid) {
  border-color: var(--hui-error);
}

#projectCredentialsView .project-credential-section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--hui-border-soft);
}

#projectCredentialsView .project-credential-section-head h3 {
  margin: 0;
  color: var(--hui-text);
  font: 600 13.5px/1.4 var(--hui-sans);
}

#projectCredentialsView .project-credential-section-head p {
  margin: 3px 0 0;
  color: var(--hui-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

#projectCredentialsView .project-credential-fields {
  display: grid;
  gap: 10px;
}

#projectCredentialsView .project-credential-field {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--hui-border);
  border-radius: 10px;
  background: var(--hui-canvas);
}

#projectCredentialsView .project-credential-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hui-border-soft);
}

#projectCredentialsView .project-credential-field-head > span {
  color: var(--hui-secondary);
  font-size: 12px;
  font-weight: 500;
}

#projectCredentialsView .project-credential-remove {
  height: 26px;
  min-height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

#projectCredentialsView .project-credential-remove:hover:not(:disabled) {
  color: var(--hui-error);
  border-color: color-mix(in srgb, var(--hui-error) 35%, var(--hui-border));
  background: color-mix(in srgb, var(--hui-error) 6%, var(--hui-surface));
}

#projectCredentialsView .project-credential-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

#projectCredentialsView .project-credential-secret-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#projectCredentialsView .project-credential-secret-wrap .input {
  padding-inline-end: 38px;
}

#projectCredentialsView .project-credential-eye {
  position: absolute;
  inset-inline-end: 4px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

#projectCredentialsView [data-add-variable] {
  justify-self: start;
}

#projectCredentialsView .project-credential-disabled {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border: 1px solid var(--hui-border);
  border-radius: 10px;
  background: var(--hui-canvas);
  cursor: pointer;
}

#projectCredentialsView .project-credential-disabled-copy {
  display: grid;
  gap: 2px;
}

#projectCredentialsView .project-credential-disabled-copy b {
  color: var(--hui-text);
  font-size: 13px;
  font-weight: 500;
}

#projectCredentialsView .project-credential-disabled-copy small {
  color: var(--hui-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

#projectCredentialsView .project-credential-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--hui-error) 28%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--hui-error) 8%, var(--hui-surface));
  color: var(--hui-error);
  font-size: 12.5px;
  line-height: 1.5;
}

#projectCredentialsView .project-credential-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--hui-border-soft);
  background: var(--hui-canvas);
}

#projectCredentialsView [data-delete-credential] {
  margin-inline-end: auto;
}

/* ---------- Right guidance & live preview aside ---------- */
#projectCredentialsView .project-credential-aside {
  display: grid;
  gap: 14px;
  min-width: 0;
}

#projectCredentialsView .project-credential-aside-card {
  box-sizing: border-box;
  padding: 16px 18px;
  border: 1px solid var(--hui-border);
  border-radius: 14px;
  background: var(--hui-surface);
  box-shadow: var(--hui-panel-shadow);
}

#projectCredentialsView .project-credential-aside-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

#projectCredentialsView .project-credential-aside-head .harness-icon {
  color: var(--hui-accent);
}

#projectCredentialsView .project-credential-aside-head h3,
#projectCredentialsView .project-credential-aside-head h4 {
  margin: 0;
  color: var(--hui-text);
  font: 600 13.5px/1.3 var(--hui-sans);
}

#projectCredentialsView .project-credential-aside-status {
  margin-inline-start: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hui-success) 12%, var(--hui-surface));
  color: var(--hui-success);
  font-size: 11.5px;
  font-weight: 500;
}

#projectCredentialsView .project-credential-aside-status.is-disabled {
  background: var(--hui-soft);
  color: var(--hui-muted);
}

#projectCredentialsView .project-credential-aside-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#projectCredentialsView .project-credential-aside-list li {
  display: grid;
  gap: 3px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--hui-muted);
}

#projectCredentialsView .project-credential-aside-list b {
  color: var(--hui-text);
  font-size: 12.5px;
  font-weight: 500;
}

#projectCredentialsView .project-credential-aside-list code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--hui-soft);
  color: var(--hui-secondary);
  font: 400 11.5px/1.4 var(--hui-mono);
}

#projectCredentialsView .project-credential-preview {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--hui-border-soft);
  border-radius: 10px;
  background: var(--hui-canvas);
}

#projectCredentialsView .project-credential-preview-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font: 400 12px/1.45 var(--hui-mono);
}

#projectCredentialsView .project-credential-preview-row code {
  color: var(--hui-text);
  overflow-wrap: anywhere;
}

#projectCredentialsView .project-credential-preview-row code.is-placeholder {
  color: var(--hui-tertiary);
}

#projectCredentialsView .project-credential-preview-eq,
#projectCredentialsView .project-credential-preview-val {
  color: var(--hui-muted);
}

#projectCredentialsView .project-credential-preview-tag {
  margin-inline-start: auto;
  flex: none;
  color: var(--hui-tertiary);
  font: 400 11px/1 var(--hui-sans);
}

#projectCredentialsView .project-credential-preview-warn {
  margin: 10px 0 0;
  color: var(--hui-warn);
  font-size: 12px;
  line-height: 1.45;
}

#projectCredentialsView [hidden],
#workflowProjectCredentials[hidden] {
  display: none !important;
}

/* ---------- SOP flow settings credential selector ---------- */
#workflowProjectCredentials .project-credential-choice {
  display: flex;
  align-items: center;
  gap: 8px;
}

#workflowProjectCredentials .project-credential-choices {
  display: grid;
  gap: 8px;
  max-height: 168px;
  overflow: auto;
}

/* ---------- Responsive & reduced motion ---------- */
@media (max-width: 960px) {
  #projectCredentialsView .project-credential-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  #projectCredentialsView .project-credential-row-head {
    display: none;
  }

  #projectCredentialsView .project-credential-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
  }

  #projectCredentialsView .project-credential-variables {
    grid-column: 1 / -1;
  }

  #projectCredentialsView .project-credential-status {
    grid-column: 1;
  }

  #projectCredentialsView .project-credential-actions {
    grid-column: 2;
  }

  #projectCredentialsView .project-credential-guide-steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  #projectCredentialsView .project-credential-form-meta,
  #projectCredentialsView .project-credential-field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #projectCredentialsView .project-credential-editor-body {
    padding: 16px;
  }

  #projectCredentialsView .project-credential-form-actions {
    padding: 12px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #projectCredentialsView .project-credential-loading svg {
    animation: none !important;
  }

  #projectCredentialsView * {
    transition: none !important;
  }
}
