:root {
  --ink: #17211b;
  --muted: #657168;
  --paper: #fbfaf4;
  --panel: #ffffff;
  --line: #ded8ca;
  --line-strong: #c4baa8;
  --green: #214f3b;
  --green-soft: #e7f0e9;
  --gold: #b9872c;
  --red: #9b3d34;
  --blue: #285a78;
  --shadow: 0 18px 50px rgba(49, 45, 35, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(33, 79, 59, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(33, 79, 59, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  min-height: 100vh;
}

.sidebar,
.summary-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px 22px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 244, 0.92);
}

.summary-panel {
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #fff;
  background: var(--green);
  border: 1px solid rgba(23, 33, 27, 0.2);
  border-radius: var(--radius);
  font-size: 24px;
  font-weight: 800;
  box-shadow: 6px 6px 0 rgba(185, 135, 44, 0.22);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.18;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 18px;
}

.progress-card,
.intro-panel,
.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress-card {
  padding: 16px;
  margin-bottom: 18px;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-copy strong {
  color: var(--ink);
}

.progress-track {
  height: 10px;
  margin-top: 13px;
  overflow: hidden;
  background: #eee8dc;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 180ms ease;
}

.progress-step-title {
  display: none;
  margin-top: 10px;
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.step-nav {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.step-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
}

.step-link span:first-child {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.step-link strong {
  overflow: hidden;
  color: inherit;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-link em {
  width: 8px;
  height: 8px;
  background: var(--line-strong);
  border-radius: 50%;
}

.step-link.complete em {
  background: var(--green);
}

.step-link.active {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(49, 45, 35, 0.08);
}

.topbar-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.main-panel {
  min-width: 0;
  padding: 30px clamp(18px, 4vw, 52px);
}

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

.intro-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #ffffff, #f8f2e7);
}

.intro-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(33, 79, 59, 0.18);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

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

.section-note {
  margin: 0 0 4px;
  color: var(--muted);
  line-height: 1.7;
}

.question-card {
  padding: 18px;
}

.question-label {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 800;
}

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

.help-text {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

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

.input,
.textarea,
.select {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fffdf9;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.static-field {
  min-height: 44px;
  padding: 11px 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(33, 79, 59, 0.2);
  border-radius: var(--radius);
  line-height: 1.55;
  font-weight: 800;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.7;
}

.input:focus,
.textarea:focus,
.select:focus {
  background: #fff;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 79, 59, 0.14);
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 11px;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.choice span {
  line-height: 1.35;
}

.range-wrap {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 12px;
  align-items: center;
}

.range-wrap input {
  width: 100%;
  accent-color: var(--green);
}

.range-value {
  padding: 6px 8px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 800;
}

.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px 0 4px;
  margin-top: 18px;
  background: linear-gradient(180deg, rgba(251, 250, 244, 0), var(--paper) 34%);
}

.form-footer .primary-btn {
  justify-self: end;
}

.form-footer.single-action {
  grid-template-columns: minmax(156px, 240px);
  justify-content: center;
}

.form-footer.single-action .primary-btn,
.form-footer.dual-action > button {
  width: 100%;
  justify-self: stretch;
}

.primary-btn,
.ghost-btn,
.text-btn,
.icon-btn {
  min-height: 42px;
  border-radius: var(--radius);
  font-weight: 800;
  white-space: nowrap;
}

.primary-btn {
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  box-shadow: 0 8px 22px rgba(33, 79, 59, 0.2);
}

.ghost-btn {
  padding: 0 13px;
  color: var(--ink);
  background: #fffdf9;
  border: 1px solid var(--line-strong);
}

.text-btn {
  padding: 0 10px;
  color: var(--blue);
  background: transparent;
  border: 1px solid transparent;
}

.icon-btn {
  width: 42px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 26px;
}

.file-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.summary-header {
  margin-bottom: 18px;
}

.summary-content {
  display: grid;
  gap: 12px;
}

.summary-block {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary-block h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.summary-block dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.summary-block div {
  display: grid;
  gap: 3px;
}

.summary-block dt {
  color: var(--muted);
  font-size: 12px;
}

.summary-block dd {
  margin: 0;
  line-height: 1.45;
}

.review-dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(23, 33, 27, 0.25);
}

.review-dialog::backdrop {
  background: rgba(23, 33, 27, 0.36);
}

.dialog-header,
.dialog-actions {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: #fffdf9;
}

.dialog-header {
  top: 0;
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  bottom: 0;
  border-top: 1px solid var(--line);
}

.review-content {
  padding: 22px;
  background: #fff;
}

.review-content h3 {
  margin: 26px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.review-content h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.review-content pre {
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  background: #f7f3ea;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.review-table th,
.review-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.review-table th {
  width: 28%;
  color: var(--muted);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.print-root {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 760px;
  padding: 0;
  background: #fff;
  color: #000;
}

.collection-sheet {
  padding: 34px 38px;
  color: #17211b;
  background: #fff;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.collection-header {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 2px solid #214f3b;
}

.collection-header p {
  margin: 0 0 6px;
  color: #b9872c;
  font-size: 12px;
  font-weight: 800;
}

.collection-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
}

.collection-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.collection-summary div {
  min-height: 56px;
  padding: 10px 12px;
  background: #f8f6ef;
  border: 1px solid #ded8ca;
  border-radius: 6px;
}

.collection-summary span {
  display: block;
  margin-bottom: 4px;
  color: #657168;
  font-size: 12px;
  font-weight: 700;
}

.collection-summary strong {
  display: block;
  color: #17211b;
  font-size: 15px;
  line-height: 1.45;
}

.collection-sheet h3 {
  margin: 22px 0 8px;
  padding: 0 0 6px;
  color: #17211b;
  border-bottom: 1px solid #c4baa8;
  font-size: 18px;
}

.collection-row-block:not(.collection-section-block) {
  padding-top: 0;
}

.collection-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 13px;
}

.collection-table th,
.collection-table td {
  padding: 8px 10px;
  border: 1px solid #ded8ca;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
}

.collection-table th {
  width: 30%;
  color: #4f5d54;
  background: #faf8f1;
  font-weight: 800;
}

.collection-table td {
  color: #17211b;
}

.pdf-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(251, 250, 244, 0.72);
  backdrop-filter: blur(8px);
}

.pdf-loading.active {
  display: grid;
}

.pdf-loading-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  width: min(360px, 100%);
  padding: 26px 22px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.pdf-loading-card strong {
  font-size: 20px;
}

.pdf-loading-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.pdf-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .summary-panel {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .progress-card {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 -2px 18px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
  }

  .progress-card.is-mobile-fixed {
    position: fixed;
    top: 5px;
    left: 18px;
    right: 18px;
    z-index: 60;
  }

  .progress-card.is-mobile-fixed .progress-step-title {
    display: block;
  }

  .progress-card.is-mobile-fixed::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: -5px;
    bottom: -12px;
    left: -18px;
    width: 100vw;
    background: rgba(251, 250, 244, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(49, 45, 35, 0.1);
    backdrop-filter: blur(10px);
  }

  .progress-card.is-mobile-fixed + .step-nav {
    margin-top: calc(var(--progress-fixed-height, 76px) + 23px);
  }

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

  .step-link {
    grid-template-columns: 26px max-content auto;
    min-width: 154px;
  }

  .main-panel {
    padding: 20px 16px 28px;
  }

  .topbar,
  .intro-panel {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 0 0 auto;
  }

  h2 {
    font-size: 24px;
  }

  .control-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

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

  .form-footer.single-action {
    grid-template-columns: minmax(156px, 44%);
  }

}

.print-root h3 {
  break-after: avoid;
  page-break-after: avoid;
}

.print-root tr,
.print-root .collection-summary div {
  break-inside: avoid;
  page-break-inside: avoid;
}
