:root {
  --paper: #fffdf9;
  --background: #f1ede7;
  --text: #182026;
  --muted: #5c646b;
  --line: #d9d1c7;
  --line-strong: #c8bbac;
  --accent: #8a6a43;
  --accent-dark: #23323a;
  --success: #1f6a41;
  --error: #9b2f2f;
  --shadow: 0 18px 50px rgba(33, 38, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.55)),
    linear-gradient(135deg, #ebe5dc 0%, #f7f4ef 45%, #ece7df 100%);
}

.page {
  max-width: 980px;
  margin: 28px auto 42px;
  padding: 28px 34px 38px;
  background: var(--paper);
  border: 1px solid rgba(201, 191, 178, 0.75);
  box-shadow: var(--shadow);
}

.page-header {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  align-items: center;
  gap: 24px;
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.page-header::after {
  content: "";
  display: block;
  width: 180px;
}

.company-logo {
  width: 170px;
  height: auto;
}

.title-block {
  text-align: center;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.74rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0 0 14px;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  text-align: center;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--accent-dark);
}

h2 {
  margin-top: 0;
  font-size: 0.88rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h3 {
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

p {
  margin: 0 0 14px;
  line-height: 1.65;
}

.section-card {
  margin-top: 30px;
  padding: 24px 26px 26px;
  border: 1px solid rgba(201, 191, 178, 0.82);
  border-top-width: 4px;
  border-radius: 18px;
  background: var(--section-bg, linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 246, 241, 0.98)));
  box-shadow: 0 12px 32px rgba(33, 38, 42, 0.05);
}

.creditor-section {
  --section-accent: var(--accent);
  --section-bg: linear-gradient(180deg, rgba(255, 253, 250, 0.98), rgba(250, 246, 241, 0.98));
  border-top-color: var(--section-accent);
}

.intro-section {
  --section-accent: var(--accent-dark);
  --section-bg: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(245, 247, 249, 0.98));
  border-top-color: var(--section-accent);
}

.form-section {
  --section-accent: #5e7078;
  --section-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 249, 251, 0.98));
  border-top-color: var(--section-accent);
}

.legal-section {
  --section-accent: #a25f3f;
  --section-bg: linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(251, 248, 244, 0.98));
  border-top-color: var(--section-accent);
}

.section-card h2,
.section-card h3 {
  margin-top: 0;
}

.creditor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-top: 16px;
}

.creditor-grid p {
  margin: 0;
}

.creditor-grid strong {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--accent-dark);
}

.section-lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.02rem;
}

form {
  margin-top: 10px;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  margin-top: 18px;
}

.field {
  display: block;
  margin-bottom: 0;
}

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

label span,
legend {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--accent-dark);
}

input[type="text"],
input[type="date"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fffefc;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input[type="text"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(138, 106, 67, 0.14);
  transform: translateY(-1px);
}

input[readonly],
input[disabled] {
  color: var(--muted);
  background: #f6f3ee;
}

fieldset {
  border: 0;
  padding: 0;
}

.inline-option {
  display: inline-flex;
  align-items: center;
  margin-right: 24px;
  gap: 8px;
  color: var(--text);
}

.inline-option span {
  margin: 0;
  font-weight: 500;
}

input[type="radio"] {
  accent-color: var(--accent-dark);
}

.signature-label {
  margin-bottom: 0;
}

#signature-pad {
  width: 100%;
  height: 220px;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #fffefe, #f7f3ed);
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 4px;
}

button {
  border: 1px solid var(--accent-dark);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  padding: 11px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

#submit-button {
  background: var(--accent-dark);
  color: #ffffff;
  border-color: var(--accent-dark);
  min-width: 320px;
  min-height: 58px;
  font-size: 1.08rem;
  box-shadow: 0 14px 30px rgba(35, 50, 58, 0.18);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.submit-line {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.submit-centered {
  text-align: center;
}

.legal-section {
  margin-top: 32px;
}

.legal-panel {
  margin-top: 16px;
  padding: 22px 24px;
  border: 1px solid rgba(217, 209, 199, 0.85);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.legal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(217, 209, 199, 0.8);
}

.legal-item:first-of-type {
  padding-top: 0;
}

.legal-item:last-of-type {
  border-bottom: 0;
  padding-bottom: 18px;
}

.legal-copy {
  min-width: 0;
}

.legal-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--accent-dark);
}

.legal-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.more-info-button {
  padding: 9px 14px;
  min-width: 96px;
  font-size: 0.95rem;
}

.legal-consents {
  padding-top: 18px;
  border-top: 1px solid rgba(217, 209, 199, 0.8);
}

.consent-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--text);
}

.consent-line input {
  margin-top: 4px;
  accent-color: var(--accent-dark);
}

.consent-line span {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.feedback {
  margin-top: 18px;
  padding: 8px 0 0;
  font-weight: 500;
}

.feedback.success {
  color: var(--success);
}

.feedback.error {
  color: var(--error);
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(24, 32, 38, 0.58);
  z-index: 1000;
}

.legal-modal {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #fffdf9;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
  padding: 24px 26px 22px;
}

.legal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.legal-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent-dark);
}

.modal-close-button {
  min-width: auto;
}

.legal-modal-body {
  padding-top: 16px;
}

.legal-modal-body p {
  color: var(--text);
}

.modal-bullets {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.modal-bullets li {
  margin-bottom: 8px;
  line-height: 1.55;
}

.site-footer {
  padding: 0 18px 28px;
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  .page-header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .page-header::after {
    display: none;
  }

  .page {
    margin: 0;
    padding: 22px 18px 32px;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .section-card {
    padding: 20px 18px 22px;
    margin-top: 22px;
  }

  .company-logo {
    width: 150px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .creditor-grid,
  .fields-grid {
    grid-template-columns: 1fr;
  }

  .signature-actions {
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
  }

  .legal-item,
  .legal-modal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #submit-button {
    width: 100%;
    min-width: 0;
  }
}
