:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --line: #cfd8e3;
  --text: #142033;
  --muted: #607086;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b91c1c;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #334155;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.2;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
}

h3 {
  font-size: 0.92rem;
  line-height: 1.25;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.sidebar,
.content {
  display: grid;
  align-content: start;
  gap: 16px;
}

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

.panel-heading {
  min-height: 34px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge,
.status-pill {
  display: inline-grid;
  min-width: 34px;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 0.78rem;
  font-weight: 750;
  padding: 0 9px;
  white-space: nowrap;
}

.status-pill {
  background: #ecfdf5;
  color: #047857;
}

.panel > label + label,
.form-block label + label,
.form-row + label,
.form-row + .form-row {
  margin-top: 10px;
}

.project-list,
.member-list,
.repository-list,
.environment-list,
.component-list,
.environment-target-list,
.gate-list,
.shared-config-list,
.environment-state-list,
.approval-list,
.audit-list,
.execution-list,
.execution-stage-list,
.source-event-list {
  display: grid;
  gap: 8px;
}

.project-row,
.member-row,
.repository-row,
.environment-row,
.component-row,
.environment-target-row,
.gate-row,
.shared-config-row,
.environment-state-row,
.approval-row,
.execution-row,
.execution-stage-row,
.audit-row,
.source-event-row {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.project-row,
.repository-row,
.environment-row,
.component-row,
.environment-target-row,
.gate-row,
.execution-row {
  cursor: pointer;
}

.project-row:hover,
.project-row.active,
.repository-row:hover,
.repository-row.active,
.environment-row:hover,
.environment-row.active,
.component-row:hover,
.component-row.active,
.environment-target-row:hover,
.environment-target-row.active,
.gate-row:hover,
.gate-row.active,
.shared-config-row.active,
.execution-row:hover,
.execution-row.active {
  border-color: var(--primary);
}

.row-title {
  font-weight: 750;
}

.row-meta {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.82rem;
}

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

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

.form-block,
.member-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.form-note {
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

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

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions button {
  flex: 1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-label input {
  width: auto;
}

.member-form {
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto;
  align-items: end;
  margin-bottom: 12px;
}

.member-row {
  grid-template-columns: minmax(0, 1fr) 160px auto;
  align-items: center;
}

.member-role {
  color: var(--accent);
  font-weight: 750;
}

.repository-row,
.environment-row,
.component-row,
.environment-target-row,
.gate-row,
.shared-config-row,
.approval-row,
.execution-row,
.execution-stage-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
}

.shared-config-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(96px, 130px) auto;
}

.shared-config-header {
  background: #e2e8f0;
  box-shadow: none;
  cursor: default;
}

.shared-config-header .row-meta {
  color: #334155;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.secret-mask {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0;
}

.stage-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.stage-actions button {
  min-width: 72px;
}

.log-output {
  width: 100%;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.repo-status {
  display: inline-grid;
  min-width: 76px;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.repo-status.disabled {
  background: #fee2e2;
  color: #991b1b;
}

.status-pill {
  display: inline-grid;
  min-width: 82px;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.status-queued,
.status-pending {
  background: #f3f4f6;
  color: #374151;
}

.status-running,
.status-in-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-waiting-approval,
.status-awaiting-approval,
.status-waiting-beta-deploy-approval,
.status-waiting-gamma-promotion-approval,
.status-waiting-prod-deploy-approval {
  background: #fef3c7;
  color: #92400e;
}

.status-succeeded,
.status-passed {
  background: #dcfce7;
  color: #166534;
}

.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-cancelled,
.status-skipped,
.status-not-deployed {
  background: #e5e7eb;
  color: #4b5563;
}

.promotion-attempt-summary {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.connection-status {
  display: inline-grid;
  min-width: 104px;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.connection-status.connected {
  background: #dcfce7;
  color: #166534;
}

.connection-status.failed {
  background: #fee2e2;
  color: #991b1b;
}

.audit-row,
.source-event-row {
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
}

.empty {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .repository-grid,
  .configuration-grid,
  .two-column,
  .three-column,
  .repository-row,
  .environment-row,
  .component-row,
  .environment-target-row,
  .gate-row,
  .shared-config-row,
  .approval-row,
  .execution-row,
  .execution-stage-row,
  .member-form,
  .member-row,
  .audit-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .workspace {
    padding: 10px;
  }
}
