:root {
  color-scheme: light;
  --ink: #18312c;
  --muted: #667872;
  --line: #d8e1dd;
  --paper: #ffffff;
  --canvas: #f3f6f4;
  --brand: #176b5b;
  --brand-dark: #0f5145;
  --brand-soft: #e6f1ed;
  --gold: #c8943d;
  --required: #c92a2a;
  --conditional: #1769aa;
  --optional: #6f7d78;
  --danger-soft: #fff0f0;
  --shadow: 0 16px 44px rgba(24, 49, 44, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(200, 148, 61, 0.13), transparent 27rem),
    linear-gradient(180deg, #edf4f1 0, var(--canvas) 22rem);
}

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

[hidden] {
  display: none !important;
}

.site-header {
  width: min(1120px, calc(100% - 32px));
  min-height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-header h1,
.site-header p {
  margin: 0;
}

.site-header h1 {
  margin-top: 2px;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: var(--brand);
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(23, 107, 91, 0.22);
}

.eyebrow,
.step-kicker {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.secure-chip {
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid rgba(23, 107, 91, 0.2);
  border-radius: 999px;
  color: var(--brand);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: calc(100vh - 164px);
  margin: 0 auto 44px;
}

.intro-card,
.progress-card,
.form-card,
.state-card,
.admin-card {
  border: 1px solid rgba(216, 225, 221, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.intro-card {
  padding: 26px 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  border-top: 4px solid var(--gold);
}

.intro-card h2,
.intro-card p,
.section-heading h2,
.section-heading p {
  margin: 0;
}

.intro-card h2 {
  margin: 5px 0 8px;
  font-size: clamp(21px, 3vw, 29px);
  letter-spacing: -0.02em;
}

.intro-card > div > p:last-child,
.section-heading > div > p:last-child {
  color: var(--muted);
  line-height: 1.65;
}

.legend {
  flex: 0 0 auto;
  display: flex;
  gap: 15px;
  padding: 10px 13px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--canvas);
  font-size: 12px;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--optional);
}

.dot.required {
  background: var(--required);
}

.dot.conditional {
  background: var(--conditional);
}

.progress-card {
  position: sticky;
  z-index: 15;
  top: 8px;
  margin: 16px 0;
  padding: 18px 22px 16px;
  backdrop-filter: blur(12px);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e9e6;
}

#progress-bar {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #4b9d86);
  transition: width 180ms ease;
}

.step-dots {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.step-dot {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-dot.active {
  color: var(--brand);
  font-weight: 800;
}

.step-dot.done::before,
.step-dot.active::before {
  content: "";
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--brand);
  vertical-align: 1px;
}

.form-card {
  padding: 28px;
}

.continuous-form {
  display: block;
}

.form-section {
  padding: 30px 0 10px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 92px;
}

.form-section:last-child {
  border-bottom: 0;
}

.form-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.form-section-heading h3,
.form-section-heading p {
  margin: 0;
}

.form-section-heading h3 {
  margin: 4px 0 6px;
  font-size: 21px;
}

.form-section-heading > div > p:last-child {
  color: var(--muted);
  line-height: 1.55;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 4px 0 6px;
  font-size: 25px;
}

.section-status {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 800;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 22px;
  padding: 26px 0 8px;
}

.field {
  min-width: 0;
}

.field.wide {
  grid-column: 1 / -1;
}

.field-label {
  min-height: 24px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.requirement {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--optional);
  background: #eef1f0;
  font-size: 10px;
  font-weight: 800;
}

.requirement.required {
  color: var(--required);
  background: #fff0f0;
}

.requirement.conditional {
  color: var(--conditional);
  background: #edf5fb;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd7d2;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input,
select {
  height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 94px;
  padding: 12px 13px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #98a8a2;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--required);
  background: #fffafa;
}

.field-help,
.field-error {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.55;
}

.field-help {
  color: var(--muted);
}

.field-error {
  color: var(--required);
  font-weight: 700;
}

.autocomplete {
  position: relative;
}

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 16px 40px rgba(24, 49, 44, 0.16);
}

.suggestion {
  width: 100%;
  padding: 10px 11px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.suggestion:hover,
.suggestion:focus {
  background: var(--brand-soft);
}

.suggestion code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.form-error {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid #f0b8b8;
  border-radius: 10px;
  color: #9f2020;
  background: var(--danger-soft);
  font-size: 13px;
  font-weight: 700;
}

.consent-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #cfe0d9;
  border-radius: 14px;
  background: #f7faf8;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.55;
}

.consent-check input {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  margin-top: 1px;
  accent-color: var(--brand);
}

.consent-panel p {
  margin: 9px 0 0 29px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-actions {
  margin-top: 26px;
  padding-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.button {
  min-width: 116px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button.primary {
  color: white;
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(23, 107, 91, 0.17);
}

.button.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: white;
}

.draft-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.honeypot {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
}

.state-card {
  max-width: 610px;
  margin: 10vh auto 0;
  padding: 46px 34px;
  text-align: center;
}

.state-card h2 {
  margin: 14px 0 8px;
  font-size: 26px;
}

.state-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.loader {
  width: 34px;
  height: 34px;
  display: inline-block;
  border: 3px solid #dbe5e1;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.state-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--required);
  background: var(--danger-soft);
  font-size: 26px;
  font-weight: 900;
}

.state-icon.success {
  color: var(--brand);
  background: var(--brand-soft);
}

.receipt {
  margin: 25px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
}

.receipt div {
  padding: 14px;
  border-radius: 12px;
  background: var(--canvas);
}

.receipt dt {
  color: var(--muted);
  font-size: 11px;
}

.receipt dd {
  margin: 5px 0 0;
  font-size: 16px;
  font-weight: 850;
}

footer {
  padding: 0 16px 28px;
  color: #7b8a85;
  font-size: 11px;
  text-align: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.admin-card {
  padding: 26px;
}

.admin-card h2,
.admin-card p {
  margin-top: 0;
}

.admin-stat {
  margin: 22px 0;
  padding: 20px;
  border-radius: 15px;
  background: var(--brand-soft);
}

.admin-stat strong {
  display: block;
  color: var(--brand-dark);
  font-size: 38px;
}

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

.qr-card {
  text-align: center;
}

.qr-card img {
  width: min(100%, 310px);
  height: auto;
  margin: 10px auto 14px;
  display: block;
  image-rendering: pixelated;
}

.form-url {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

@media (max-width: 760px) {
  .site-header {
    min-height: 82px;
  }

  .site-header h1 {
    font-size: 20px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .secure-chip {
    display: none;
  }

  .page-shell {
    width: min(100% - 20px, 1120px);
  }

  .intro-card {
    padding: 21px 18px;
    display: block;
    border-radius: 17px;
  }

  .legend {
    width: max-content;
    max-width: 100%;
    margin-top: 16px;
    gap: 10px;
    white-space: normal;
  }

  .progress-card {
    padding: 16px;
    border-radius: 17px;
  }

  .step-dots {
    display: none;
  }

  .form-card {
    padding: 20px 16px;
    border-radius: 17px;
  }

  .section-heading {
    display: block;
  }

  .form-section-heading {
    display: flex;
  }

  .section-heading h2 {
    font-size: 22px;
  }

  .section-status {
    width: max-content;
    margin-top: 12px;
    display: block;
  }

  .fields-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    padding-top: 22px;
  }

  .field.wide {
    grid-column: auto;
  }

  input,
  select {
    height: 48px;
    font-size: 16px;
  }

  textarea {
    font-size: 16px;
  }

  .form-actions {
    position: sticky;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 24px -16px -8px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 26px rgba(24, 49, 44, 0.08);
  }

  .button {
    flex: 1;
  }

  .receipt,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .state-card {
    margin-top: 7vh;
    padding: 38px 22px;
  }
}

@media print {
  body {
    background: white;
  }

  .site-header,
  footer,
  .admin-grid > :first-child,
  .admin-actions {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  .admin-grid {
    display: block;
  }

  .qr-card {
    border: 0;
    box-shadow: none;
  }
}
