:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #697585;
  --line: #d8e0e7;
  --accent: #167a72;
  --accent-strong: #0f625c;
  --warn: #b16b00;
  --fail: #b83333;
  --pass: #177245;
  --idle: #8792a0;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

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

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

.workspace {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow,
.section-label,
.hint {
  margin: 0;
  color: var(--muted);
}

.eyebrow,
.section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
}

h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.25;
}

.state-pill,
.badge,
.stage-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.state-pill {
  color: #ffffff;
  background: #334155;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

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

.intake-panel,
.progress-panel,
.passport-panel {
  padding: 18px;
}

.passport-panel {
  grid-column: 1 / -1;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  background: #e7edf2;
  color: var(--ink);
  font-weight: 800;
}

.tab.active {
  background: var(--accent);
  color: #ffffff;
}

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

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: #263342;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c8d3dc;
  border-radius: 6px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(22, 122, 114, 0.24);
  outline-offset: 2px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-action {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.wide {
  width: 100%;
}

.progress-header,
.passport-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

#progressPercent {
  font-size: 32px;
  line-height: 1;
  color: var(--accent-strong);
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #dbe4eb;
  overflow: hidden;
  margin: 18px 0;
}

#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #167a72, #3f8f5d);
  transition: width 280ms ease;
}

.stage-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.stage-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.stage-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e2e9ef;
  color: #435062;
  font-size: 12px;
  font-weight: 900;
}

.stage-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.stage-status {
  background: #e5eaf0;
  color: var(--idle);
}

.stage-status.pass {
  background: #e5f4ec;
  color: var(--pass);
}

.stage-status.warning {
  background: #fff0d9;
  color: var(--warn);
}

.stage-status.failed {
  background: #fde8e8;
  color: var(--fail);
}

.stage-item.active {
  border-color: rgba(22, 122, 114, 0.5);
  background: #eef8f6;
}

.badge {
  background: #e5f4ec;
  color: var(--pass);
}

.badge.muted {
  background: #e5eaf0;
  color: var(--idle);
}

.passport-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.passport-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  min-height: 46px;
  border-bottom: 1px solid var(--line);
}

.passport-row:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.passport-row dt,
.passport-row dd {
  margin: 0;
  padding: 12px;
}

.passport-row dt {
  background: #f0f4f7;
  color: #344154;
  font-size: 12px;
  font-weight: 900;
}

.passport-row dd {
  overflow-wrap: anywhere;
  color: #273445;
}

.bottom-actions {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 320px);
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(238, 242, 245, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.secondary-action {
  background: #17202a;
  color: #ffffff;
  font-weight: 900;
}

.secondary-action:not(:disabled):hover {
  background: #0f625c;
}

@media (max-width: 860px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .progress-header,
  .passport-header {
    flex-direction: column;
  }

  .layout,
  .input-row,
  .field-grid,
  .passport-grid,
  .bottom-actions {
    grid-template-columns: 1fr;
  }

  .passport-row,
  .stage-item {
    grid-template-columns: 1fr;
  }

  .stage-status,
  .stage-index {
    justify-self: start;
  }
}
