:root {
  --doc-bg: #eef4f7;
  --doc-ink: #16242b;
  --doc-accent: #14958f;
  --doc-line: #bed5dd;
}

body.form-document-page {
  margin: 0;
  background: var(--doc-bg);
  color: var(--doc-ink);
  font-family: Arial, Helvetica, sans-serif;
}

.form-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--doc-line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(18, 48, 62, 0.1);
}

.form-toolbar h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.form-toolbar p {
  margin: 0.2rem 0 0;
  color: #58707a;
  font-size: 0.78rem;
}

.form-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.doc-btn {
  min-height: 2.25rem;
  border: 1px solid var(--doc-line);
  border-radius: 0.45rem;
  background: #fff;
  color: #1e3943;
  cursor: pointer;
  font-weight: 700;
  padding: 0.46rem 0.7rem;
}

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

.form-document {
  width: min(100%, 920px);
  margin: 1rem auto 2rem;
}

.form-page {
  position: relative;
  width: 100%;
  aspect-ratio: 1224 / 1584;
  margin: 0 auto 1rem;
  background: #fff;
  box-shadow: 0 12px 36px rgba(15, 44, 58, 0.16);
}

.form-page img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.doc-field {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 0.14rem;
  background: transparent;
  color: #111;
  font: 500 1.05vw/1.2 Arial, Helvetica, sans-serif;
  min-font-size: 9px;
  padding: 0.15% 0.35%;
  outline: none;
}

.doc-field:hover {
  border-color: rgba(20, 149, 143, 0.28);
  background: rgba(255, 255, 255, 0.28);
}

.doc-field:focus {
  border-color: #0f7678;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 2px rgba(20, 149, 143, 0.16);
}

.doc-field.has-value:not(:focus) {
  border-color: transparent;
  background: transparent;
}

textarea.doc-field {
  resize: none;
}

/* Proper checkbox that sits exactly on (and covers) the PDF's drawn box.
   Size/position come from the field's x/y/w/h (the box glyph's bounding box). */
.doc-check {
  position: absolute;
  z-index: 3;
  box-sizing: border-box;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #555;
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  outline: none;
}

.doc-check:hover,
.doc-check:focus-visible {
  border-color: #0f7678;
  box-shadow: 0 0 0 2px rgba(20, 149, 143, 0.18);
}

.doc-check:checked {
  background-color: #0f7678;
  border-color: #0f7678;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.6 4 7.4-8.6' fill='none' stroke='%23fff' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.doc-field::placeholder {
  color: transparent;
}

.professional-missing {
  max-width: 760px;
  margin: 4rem auto;
  padding: 1.2rem;
  border: 1px solid var(--doc-line);
  border-radius: 0.55rem;
  background: #fff;
  line-height: 1.55;
  box-shadow: 0 12px 36px rgba(15, 44, 58, 0.1);
}

@media (min-width: 920px) {
  .doc-field {
    font-size: 9.8px;
  }
}

@media print {
  @page {
    size: letter;
    margin: 0;
  }

  html,
  body.form-document-page {
    width: 8.5in;
    margin: 0;
    background: #fff;
  }

  .form-toolbar,
  .professional-missing {
    display: none !important;
  }

  .form-document {
    width: 8.5in;
    margin: 0;
  }

  .form-page {
    width: 8.5in;
    height: 11in;
    margin: 0;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }

  .form-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .doc-field {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .doc-check {
    border-color: #555;
    background-color: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .doc-check:checked {
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.6 4 7.4-8.6' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 100% 100%;
  }
}
