:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --ink: #172033;
  --muted: #64708a;
  --line: #dfe4ef;
  --line-strong: #cbd3e2;
  --primary: #2a55e5;
  --primary-dark: #1f42ba;
  --primary-soft: #edf1ff;
  --success: #167558;
  --danger: #bf3344;
  --shadow: 0 18px 45px rgba(37, 52, 92, .09);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(203, 211, 226, .8);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .78rem; }

.topbar__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.save-state { margin-right: 6px; color: var(--muted); font-size: .84rem; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible, .nav-item:focus-visible, .dialog__close:focus-visible, .export-option:focus-visible {
  outline: 3px solid rgba(42, 85, 229, .23);
  outline-offset: 2px;
}
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover { background: var(--primary-dark); }
.button--secondary { background: var(--surface); border-color: var(--line-strong); }
.button--ghost { background: transparent; border-color: var(--line); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 920px);
  justify-content: center;
  gap: clamp(28px, 4vw, 64px);
  padding: 38px clamp(18px, 4vw, 54px) 72px;
}

.sidebar { position: sticky; top: 104px; align-self: start; max-height: calc(100vh - 126px); overflow: auto; padding-right: 8px; }
.progress-card, .sidebar__note {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.progress-card__row { display: flex; justify-content: space-between; gap: 12px; }
.progress-card__row span { color: var(--primary); font-weight: 800; }
.progress-track { height: 8px; margin: 12px 0 9px; overflow: hidden; border-radius: 99px; background: #e8ebf3; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s ease; }
.progress-card p, .sidebar__note p { margin: 0; color: var(--muted); font-size: .84rem; }
.section-nav { display: grid; gap: 4px; margin: 18px 0; }
.nav-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.75); color: var(--ink); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.nav-item.is-complete .nav-number { background: var(--success); color: #fff; }
.nav-number { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: #e7eaf2; font-size: .72rem; font-weight: 800; }

.main { min-width: 0; }
.mobile-section-picker { display: none; }
.intro { margin-bottom: 30px; }
.eyebrow { display: inline-block; color: var(--primary); font-size: .77rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
h1 { max-width: 720px; margin: 8px 0 12px; font-size: clamp(2.1rem, 5vw, 3.65rem); line-height: 1.02; letter-spacing: -.045em; }
.intro > p { max-width: 740px; margin: 0; color: var(--muted); font-size: 1.05rem; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 18px; color: var(--muted); font-size: .83rem; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.legend__required { background: var(--primary); }
.legend__optional { border: 1px solid var(--line-strong); background: #fff; }

.form-step { display: none; }
.form-step.is-active { display: block; animation: enter .25s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } }

.step-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.step-heading h2 { margin: 5px 0 0; font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.15; letter-spacing: -.025em; }
.step-heading p { max-width: 560px; margin: 8px 0 0; color: var(--muted); }
.step-badge { flex: 0 0 auto; padding: 7px 11px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-dark); font-size: .8rem; font-weight: 800; }

.panel {
  margin-bottom: 16px;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23,32,51,.02);
}
.panel__title { margin: 0 0 5px; font-size: 1.12rem; }
.panel__description { margin: 0 0 20px; color: var(--muted); font-size: .93rem; }
.panel__description:last-child { margin-bottom: 0; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.service-field-slot { grid-column: 1 / -1; min-width: 0; }
.price-editor { width: 100%; }
.field { min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label:not(.choice), .field-label { display: block; margin-bottom: 7px; font-weight: 700; }
.required-mark { color: var(--primary); }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .8rem; }

input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="date"], input[type="number"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(42,85,229,.12); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }

.choices { display: grid; gap: 9px; }
.choices--inline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  cursor: pointer;
}
.choice:hover { border-color: #aeb9d3; }
.choice:has(input:checked) { border-color: rgba(42,85,229,.55); background: var(--primary-soft); }
.choice:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.choice input { flex: 0 0 auto; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.choice span { min-width: 0; }
.choice small { display: block; margin-top: 2px; color: var(--muted); }

.conditional { display: none; margin-top: 16px; padding: 16px; border-left: 3px solid var(--primary); border-radius: 0 12px 12px 0; background: var(--primary-soft); }
.conditional.is-visible { display: block; }
.field-grid > .conditional { grid-column: 1 / -1; width: 100%; }
.conditional > .field, .conditional > .field-grid { width: 100%; }

.range-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(160px, 2fr) minmax(90px, 1fr); align-items: center; gap: 14px; margin: 14px 0; }
.range-row span:last-child { text-align: right; }
input[type="range"] { width: 100%; accent-color: var(--primary); }

.repeater { display: grid; gap: 14px; }
.repeater-item { position: relative; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.repeater-item__head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.repeater-item__head h3 { margin: 0; font-size: 1rem; }
.remove-item { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-weight: 700; }
.add-item { width: 100%; margin-top: 14px; border-style: dashed; background: transparent; color: var(--primary-dark); }

.status-table { width: 100%; border-collapse: collapse; }
.status-table th, .status-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.status-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.status-table select, .status-table input { min-height: 42px; }

.upload {
  display: block;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  text-align: center;
}
.upload input { max-width: 100%; margin-top: 8px; }

.info-box { padding: 15px 17px; border-radius: 12px; background: #f1f4fb; color: #4f5c75; font-size: .88rem; }
.info-box strong { color: var(--ink); }
.warning-banner { display: grid; gap: 4px; margin-top: 18px; padding: 14px 16px; border: 1px solid #f0b85a; border-radius: 12px; background: #fff8e8; color: #744700; }
.warning-banner[hidden] { display: none; }
.warning-banner span { font-size: .9rem; line-height: 1.45; }
.file-total-status { margin-top: 12px !important; font-size: .88rem !important; }
.choice--missing-file { outline: 2px solid #f0b85a; outline-offset: 2px; }
.honeypot { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; }

.form-footer {
  position: sticky;
  z-index: 10;
  bottom: 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.form-footer > :last-child { justify-self: end; }
.form-footer__center { display: grid; justify-items: center; gap: 3px; color: var(--muted); font-size: .84rem; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .78rem; }

.dialog { width: min(560px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 24px 80px rgba(20,31,57,.22); }
.dialog::backdrop { background: rgba(16,24,42,.55); backdrop-filter: blur(4px); }
.dialog__panel { position: relative; padding: 30px; }
.dialog__panel h2 { margin: 7px 0 8px; }
.dialog__panel p { margin: 0 0 20px; color: var(--muted); }
.dialog__close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--surface-soft); cursor: pointer; font-size: 1.4rem; }
.export-options { display: grid; gap: 10px; }
.export-option { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; text-align: left; cursor: pointer; }
.export-option:hover { border-color: var(--primary); background: var(--primary-soft); }
.export-option:disabled { cursor: wait; opacity: .62; }
.export-option strong, .export-option span { display: block; }
.export-option span { margin-top: 3px; color: var(--muted); font-size: .84rem; }
.dialog__panel .submit-status { min-height: 1.4em; margin: 14px 0 0; color: var(--ink); font-size: .9rem; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(390px, calc(100% - 44px)); padding: 13px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: none; }
.empty-note { color: var(--muted); font-style: italic; }
.choice-group.has-error { padding: 12px; border: 1px solid var(--danger); border-radius: 12px; }
.group-error { display: block; min-height: 1em; margin-top: 7px; color: var(--danger); font-size: .8rem; }
.sort-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.sort-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.sort-list li > span:first-of-type { flex: 1; }
.sort-list button { width: 34px; height: 34px; margin-left: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); cursor: pointer; }
.sort-list button:disabled { opacity: .35; cursor: default; }
.sort-list__fixed { color: var(--muted); background: var(--surface-soft) !important; }
.review-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.review-grid div { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.review-grid span, .review-grid strong { display: block; }
.review-grid span { margin-bottom: 5px; color: var(--muted); font-size: .78rem; }
.review-grid strong { overflow-wrap: anywhere; }
.review-section { margin-top: 22px; }
.review-section h4 { margin: 0 0 10px; }
.review-list { display: grid; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.review-list > div { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(0, 1.4fr); gap: 18px; padding: 11px 13px; border-bottom: 1px solid var(--line); background: #fff; }
.review-list > div:last-child { border-bottom: 0; }
.review-list dt { color: var(--muted); font-weight: 600; }
.review-list dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.review-list__missing dd { color: var(--danger); font-weight: 700; }
.loop-note, .required-note { margin: 0 0 12px; color: var(--muted); font-size: .84rem; }
.required-note { padding: 10px 12px; border-radius: 10px; background: #fff3d6; color: #744700; }
.field-grid > .required-note { grid-column: 1 / -1; }
.remove-item:disabled { color: var(--muted); cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
  .save-state { display: none; }
}

@media (max-width: 780px) {
  .topbar { position: static; }
  .brand small, #print-button { display: none; }
  .app-shell { display: block; padding-top: 24px; }
  .sidebar { position: static; max-height: none; padding: 0; }
  .section-nav, .sidebar__note { display: none; }
  .progress-card { margin-bottom: 24px; }
  .mobile-section-picker { position: sticky; z-index: 9; top: 8px; display: grid; gap: 5px; margin-bottom: 20px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
  .mobile-section-picker span { color: var(--muted); font-size: .78rem; font-weight: 700; }
  .mobile-section-picker select { min-height: 42px; }
  .field-grid, .field-grid--three, .choices--inline { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-list > div { grid-template-columns: 1fr; gap: 3px; }
  .field--full { grid-column: auto; }
  .status-table, .status-table tbody, .status-table tr, .status-table td { display: block; }
  .status-table thead { display: none; }
  .status-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .status-table td { padding: 5px 0; border: 0; }
  .status-table td:first-child { font-weight: 700; }
  .form-footer { grid-template-columns: 1fr 1fr; bottom: 8px; }
  .form-footer__center { grid-column: 1 / -1; grid-row: 1; }
  .form-footer > :first-child { grid-column: 1; grid-row: 2; }
  .form-footer > :last-child { grid-column: 2; grid-row: 2; }
}

@media (max-width: 480px) {
  .topbar { padding: 10px 14px; }
  .brand strong { font-size: .9rem; }
  .brand__mark { width: 38px; height: 38px; }
  .topbar__actions .button { min-height: 40px; padding: 8px 12px; font-size: .86rem; }
  .app-shell { padding-inline: 14px; }
  .panel { padding: 18px; border-radius: 16px; }
  .range-row { grid-template-columns: 1fr; gap: 3px; }
  .range-row span:last-child { text-align: left; }
  .step-heading { align-items: start; }
  .step-badge { display: none; }
  .review-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .sidebar, .intro, .form-footer, .remove-item, .add-item { display: none !important; }
  .app-shell { display: block; padding: 0; }
  .form-step { display: block !important; page-break-before: always; }
  .form-step:first-child { page-break-before: auto; }
  .panel { break-inside: avoid; box-shadow: none; }
  input, textarea, select { border-color: #999 !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
