:root {
  --bg: #f7f4ef;
  --surface: #fffdf9;
  --surface-2: #eee8dc;
  --text: #241f1a;
  --muted: #6f665d;
  --line: #d9d0c3;
  --accent: #8f2f3f;
  --accent-2: #b48b52;
  --ok: #247158;
  --warn: #9b6514;
  --error: #9a2632;
  --shadow: 0 24px 70px rgba(36, 31, 26, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(143, 47, 63, 0.08), transparent 28%),
    linear-gradient(315deg, rgba(180, 139, 82, 0.1), transparent 32%),
    var(--bg);
  color: var(--text);
}

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

.app-shell {
  min-height: 100vh;
}

.login-page,
.thanks-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.thanks-panel {
  width: min(100%, 560px);
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 42px);
}

.brand-lockup {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark,
.checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

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

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.login-form,
.diagnostic-form {
  display: grid;
  gap: 18px;
}

.login-form label,
.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  min-height: 46px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(143, 47, 63, 0.15);
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.link-btn {
  border: 0;
  border-radius: 6px;
  min-height: 46px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 750;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
}

.ghost-btn,
.link-btn {
  background: transparent;
  color: var(--accent);
}

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

.form-message {
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.95rem;
}

.form-message.error {
  background: rgba(154, 38, 50, 0.1);
  color: var(--error);
}

.form-message.warn {
  background: rgba(155, 101, 20, 0.1);
  color: var(--warn);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 239, 0.92);
  backdrop-filter: blur(12px);
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 44px;
}

.steps-nav {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 8px;
}

.step-pill {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  min-height: 42px;
}

.step-pill span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
}

.step-pill.active {
  border-color: rgba(143, 47, 63, 0.25);
  background: rgba(143, 47, 63, 0.08);
  color: var(--text);
}

.step-pill.done span {
  background: var(--ok);
  color: #fff;
}

.form-panel {
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 38px);
}

.progress-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.intro {
  margin-bottom: 24px;
}

.intro p,
.consent-box p,
.thanks-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.required {
  color: var(--accent);
}

.option-row,
.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option-row label,
.option-grid label,
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
}

.option-row input,
.option-grid input,
.checkline input {
  width: auto;
  min-height: 0;
}

.invalid input,
.invalid textarea,
.invalid select {
  border-color: var(--error);
}

.invalid small {
  color: var(--error);
}

.hidden {
  display: none !important;
}

.doc-list {
  display: grid;
  gap: 14px;
}

.doc-item {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, 0.7fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.doc-item textarea {
  grid-column: 2 / -1;
}

.consent-box {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.sync-status {
  margin: 14px 0 0;
  color: var(--ok);
  font-weight: 650;
}

.sync-status.pending {
  color: var(--warn);
}

.thanks-panel {
  text-align: center;
}

.thanks-panel .checkmark {
  margin: 0 auto 20px;
  background: var(--ok);
  font-size: 1.8rem;
}

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

  .steps-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .step-pill {
    min-width: 220px;
  }

  .doc-item {
    grid-template-columns: 1fr;
  }

  .doc-item textarea {
    grid-column: auto;
  }
}

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

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .option-row,
  .option-grid {
    display: grid;
  }
}
