:root {
  --orange: #f26419;
  --orange-dark: #d94d00;
  --orange-soft: #fff0e4;
  --ink: #28313c;
  --muted: #68717d;
  --line: #dfd7cf;
  --paper: #fffaf4;
  --white: #fff;
  --green: #168c4e;
  --red: #b42318;
  --shadow: 0 20px 55px rgba(46, 35, 27, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 1000;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.topbar {
  border-top: 5px solid var(--orange);
  border-bottom: 1px solid #ecd9ca;
  background: rgba(255, 250, 244, .96);
}
.topbar__inner {
  width: min(calc(100% - 36px), 1320px);
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: #a93700; font-size: 21px; font-weight: 800; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.topbar__actions { display: flex; align-items: center; gap: 14px; }
.back-link { color: #5a626c; font-size: 14px; font-weight: 650; text-decoration: none; }
.back-link:hover { color: var(--orange-dark); }
.bot-link { padding: 10px 13px; color: #fff; background: #168c4e; border-radius: 10px; font-size: 13px; font-weight: 800; text-decoration: none; }
.bot-link:hover { background: #0e703d; }

main { width: min(calc(100% - 36px), 1320px); margin: 0 auto; }
.intro { padding: 46px 0 28px; }
.intro__copy { max-width: 830px; }
.eyebrow, .step-caption { margin: 0 0 5px; color: var(--orange-dark); font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
h1 { margin: 0 0 12px; font-size: clamp(36px, 6vw, 60px); line-height: 1.04; letter-spacing: -.045em; }
.lead { max-width: 800px; margin: 0; color: var(--muted); font-size: clamp(17px, 2vw, 20px); }
.blank-download-box {
  max-width: 800px;
  margin-top: 20px;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #fff;
  border: 1px solid #e4d8cd;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(46,35,27,.06);
}
.blank-download-box strong, .blank-download-box span { display: block; }
.blank-download-box strong { margin-bottom: 2px; font-size: 14px; }
.blank-download-box span { color: var(--muted); font-size: 12px; }
.blank-download-box button {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 10px 13px;
  color: var(--orange-dark);
  background: var(--orange-soft);
  border: 1px solid #efbd9d;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.blank-download-box button:hover { color: #fff; background: var(--orange-dark); border-color: var(--orange-dark); }
.blank-download-box button:focus-visible { outline: 3px solid rgba(242,100,25,.30); outline-offset: 2px; }
.blank-download-box button:disabled { opacity: .65; cursor: wait; }
.privacy-note, .official-note {
  max-width: 980px;
  margin-top: 20px;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 14px;
}
.privacy-note { color: #175b39; background: #eaf8f0; border: 1px solid #b9e2ca; }
.official-note { color: #5b4a2f; background: #fff7df; border: 1px solid #ead398; }
.official-note a { color: #8a420d; font-weight: 700; }

.workspace { padding: 4px 0 64px; display: grid; grid-template-columns: minmax(360px, 480px) minmax(650px, 1fr); gap: 28px; align-items: start; }
.form-card, .preview {
  background: var(--white);
  border: 1px solid #eadfd4;
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.form-card { padding: 24px; }
.form-card__heading, .preview__heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.form-card__heading { margin-bottom: 22px; }
.form-card h2, .preview h2 { margin: 0; font-size: 25px; line-height: 1.15; letter-spacing: -.025em; }
.text-button { padding: 6px; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.text-button:hover { color: var(--orange-dark); }

fieldset { min-width: 0; margin: 0; padding: 22px 0; border: 0; border-top: 1px solid #eee5dc; }
fieldset:first-of-type { padding-top: 0; border-top: 0; }
legend { width: 100%; margin: 0 0 16px; padding: 0; display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 16px; font-weight: 800; }
legend span { width: 28px; height: 28px; display: inline-grid; place-items: center; color: #fff; background: var(--orange-dark); border-radius: 50%; font-size: 13px; }
.field-grid { display: grid; gap: 12px; }
.field-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { margin: 0 0 14px; display: block; }
.field > span, .field > label > span { margin-bottom: 6px; display: block; color: #39424d; font-size: 13px; font-weight: 750; }
.field b { color: var(--orange-dark); }
.field small { margin-top: 5px; display: block; color: var(--muted); font-size: 12px; }
input[type="text"], input[type="date"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfc7bf;
  border-radius: 11px;
  outline: none;
}
textarea { min-height: 72px; resize: vertical; }
input:hover, textarea:hover { border-color: #a99d92; }
input:focus, textarea:focus { border-color: var(--orange-dark); box-shadow: 0 0 0 3px rgba(242, 100, 25, .16); }
input:user-invalid, textarea:user-invalid { border-color: var(--red); }
.segmented { min-height: 48px; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #f3eee9; border-radius: 11px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { height: 40px; display: grid; place-items: center; color: #59616b; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
.segmented input:checked + span { color: #fff; background: var(--orange-dark); box-shadow: 0 4px 12px rgba(169,55,0,.18); }
.segmented input:focus-visible + span { outline: 3px solid rgba(242, 100, 25, .25); }
.date-helper { display: flex; gap: 9px; padding: 12px; color: #414b56; background: #f5f7f8; border-radius: 11px; font-size: 13px; }
.date-helper strong { color: var(--orange-dark); }

.form-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-actions .secondary-button { grid-column: 1 / -1; }
.primary-button, .share-button, .secondary-button {
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { color: #fff; background: var(--orange-dark); border: 1px solid var(--orange-dark); box-shadow: 0 8px 20px rgba(217,77,0,.20); }
.primary-button:hover { background: #a93700; }
.share-button { color: #fff; background: #168c4e; border: 1px solid #168c4e; box-shadow: 0 8px 20px rgba(22,140,78,.16); }
.share-button:hover { background: #0e703d; }
.secondary-button { color: var(--ink); background: #fff; border: 1px solid #bfb7af; }
.secondary-button:hover { color: var(--orange-dark); border-color: var(--orange-dark); background: var(--orange-soft); }
.primary-button:focus-visible, .share-button:focus-visible, .secondary-button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(242,100,25,.30); outline-offset: 2px; }
.primary-button[disabled], .share-button[disabled], .secondary-button[disabled] { opacity: .65; cursor: wait; }
.action-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.form-error { margin-top: 12px; padding: 11px; color: var(--red); background: #fff1f0; border: 1px solid #ffc7c2; border-radius: 10px; font-size: 13px; font-weight: 700; }

.preview { position: sticky; top: 18px; padding: 20px; background: #f1ece7; overflow: hidden; }
.preview__heading { margin-bottom: 16px; }
.preview-badge { padding: 5px 9px; color: #625950; background: #fff; border: 1px solid #d7cec5; border-radius: 8px; font-size: 12px; font-weight: 800; }
.sheet-scroll { overflow: auto; border-radius: 6px; }
.paper {
  width: 720px;
  min-height: 1018px;
  margin: 0 auto;
  padding: 45px 42px 38px;
  color: #000;
  background: #fff;
  border: 1px solid #d0cbc5;
  box-shadow: 0 12px 30px rgba(20,18,16,.15);
  font-family: "Times New Roman", Times, serif;
}
.form-number { margin-bottom: 22px; text-align: right; font: 700 12px Arial, sans-serif; }
.paper h2 { margin: 0 0 4px; text-align: center; font: 700 18px/1.15 Arial, sans-serif; letter-spacing: .015em; }
.paper h3 { margin: 0 0 22px; text-align: center; font: 700 14px/1.2 Arial, sans-serif; }
.official-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.official-table th, .official-table td { height: 52px; padding: 7px 9px; border: 1px solid #000; vertical-align: middle; }
.official-table th { width: 43%; font: 400 11px/1.18 Arial, sans-serif; text-align: left; }
.official-table th small { font-size: 9px; }
.official-table td { overflow-wrap: anywhere; font: 700 13px/1.2 Arial, sans-serif; text-transform: uppercase; }
.official-table tr:nth-child(8) td { height: 62px; }
.official-table tr:nth-child(10) td, .official-table tr:nth-child(11) td { height: 66px; }
.value-separator { color: #777; }
.registration-line { margin-top: 17px; font: 12px Arial, sans-serif; }
.registration-line strong { margin-left: 8px; font-size: 13px; }
.signatures { margin-top: 75px; display: grid; grid-template-columns: 1fr 1fr; gap: 50px; text-align: center; }
.signatures span { display: block; border-top: 1px solid #000; }
.signatures p { margin: 5px 0 0; font: 10px/1.25 Arial, sans-serif; }
.signatures small { font-size: 8px; }

.footer { padding: 0 18px 44px; color: var(--muted); font-size: 13px; text-align: center; }
.footer p { margin: 4px 0; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .form-card { max-width: 760px; }
  .preview { position: static; }
}

@media (max-width: 620px) {
  .topbar__inner, main { width: min(calc(100% - 24px), 1320px); }
  .topbar__inner { min-height: 62px; }
  .brand { font-size: 19px; }
  .brand img { width: 34px; height: 34px; }
  .back-link { display: none; }
  .bot-link { padding: 9px 10px; font-size: 11px; }
  .intro { padding-top: 32px; }
  h1 { font-size: 38px; }
  .blank-download-box { align-items: stretch; flex-direction: column; gap: 10px; }
  .blank-download-box button { width: 100%; }
  .workspace { gap: 18px; padding-bottom: 36px; }
  .form-card, .preview { padding: 17px; border-radius: 16px; }
  .field-grid--two, .form-actions { grid-template-columns: 1fr; }
  .paper { margin: 0; }
  .preview::after { content: "Проведите по бланку в сторону, чтобы посмотреть полностью"; margin-top: 10px; display: block; color: var(--muted); font-size: 11px; text-align: center; }
}

@media print {
  @page { size: A4 portrait; margin: 9mm; }
  html, body { width: 210mm; min-height: 297mm; margin: 0; padding: 0; background: #fff; }
  .no-print { display: none !important; }
  main, .workspace, .preview, .sheet-scroll { width: auto; margin: 0; padding: 0; display: block; overflow: visible; background: #fff; border: 0; box-shadow: none; }
  .preview { position: static; }
  .paper {
    width: 192mm;
    min-height: 279mm;
    margin: 0;
    padding: 8mm 7mm 5mm;
    border: 0;
    box-shadow: none;
    break-inside: avoid;
  }
  .form-number { margin-bottom: 5mm; }
  .paper h3 { margin-bottom: 5mm; }
  .official-table th, .official-table td { height: 12.2mm; }
  .official-table tr:nth-child(8) td { height: 14mm; }
  .official-table tr:nth-child(10) td, .official-table tr:nth-child(11) td { height: 15mm; }
  .signatures { margin-top: 18mm; }
}
