/* =========================
   Document Base
========================= */

body {
  margin: 0;
  padding: 0;
  background: #f5f5f3;
  color: #111;
  font-family: Georgia, serif;
  line-height: 1.8;
}

.document {
  max-width: 1000px;
  margin: 60px auto;
  padding: 60px;
  background: white;
}

/* =========================
   Header
========================= */

.document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 60px;
}

.document-logo {
  width: 207px;
  height: auto;
}

.document-header h1 {
  margin: 0;
  font-size: 40px;
  font-weight: normal;
}

.document-header p {
  margin-top: 10px;
  opacity: 0.7;
}

.document-intro {
  max-width: 760px;
  margin: 0 0 50px;
  font-size: 18px;
  line-height: 1.7;
}

/* =========================
   Sections
========================= */

.section {
  margin-bottom: 50px;
}

.section h2 {
  margin-bottom: 20px;
  font-size: 22px;
  font-weight: normal;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 10px;
}

.section p {
  margin-bottom: 18px;
}

/* =========================
   Two Columns
========================= */

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
}

/* =========================
   Tables
========================= */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  text-align: left;
}

th {
  width: 220px;
  font-weight: normal;
  opacity: 0.7;
}

/* =========================
   Signature Area
========================= */

.signature-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  margin-top: 80px;
}

.document-authorization {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 80px;
  margin-top: 80px;
}

.signature-block,
.date-block {
  text-align: center;
}

.document-date {
  min-height: 24px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.signature-line {
  border-bottom: 1px solid black;
  margin-bottom: 10px;
  height: 40px;
}

.document-authorization .signature-line {
  width: 230px;
  height: auto;
  margin: 0 auto 10px;
}

.signature-area p,
.document-authorization p {
  font-size: 14px;
  opacity: 0.7;
}

/* =========================
   Footer
========================= */

footer {
  margin-top: 80px;
  text-align: center;
  font-size: 14px;
  opacity: 0.6;
}

/* =========================
   Print Layout
========================= */

@media print {
  @page {
    size: Letter;
    margin: 0.5in;
  }

  html,
  body {
    margin: 0;
    padding: 0;
    width: auto;
    min-height: 0;
    background: white;
  }

  * {
    box-sizing: border-box;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .document {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
    page-break-after: auto;
    break-after: auto;
  }

  .document-header {
    margin-bottom: 0.32in;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .document-logo {
    width: 1.55in;
  }

  .document-header h1 {
    font-size: 28pt;
    line-height: 1.15;
  }

  .document-header p {
    margin: 0.06in 0 0;
  }

  .document-intro {
    max-width: 6.2in;
    margin: 0 0 0.28in;
    font-size: 12pt;
    line-height: 1.45;
  }

  .section {
    margin-bottom: 0.28in;
  }

  .section h2 {
    margin: 0 0 0.1in;
    padding-bottom: 0.06in;
    font-size: 16pt;
  }

  .section p {
    margin: 0 0 0.08in;
    line-height: 1.45;
    orphans: 3;
    widows: 3;
  }

  .two-columns {
    gap: 0.45in;
  }

  th,
  td {
    padding: 0.08in 0;
  }

  tr,
  .signature-area,
  .document-authorization,
  footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .signature-area {
    gap: 0.6in;
    margin-top: 0.42in;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .document-authorization {
    gap: 0.6in;
    margin-top: 0.34in;
  }

  .signature-area + .signature-area {
    margin-top: 0.24in;
    break-before: avoid-page;
    page-break-before: avoid;
  }

  .document-date {
    min-height: 0.22in;
    margin-bottom: 0.07in;
    font-size: 10.5pt;
  }

  .signature-line {
    height: 0.28in;
    margin-bottom: 0.08in;
  }

  .document-authorization .signature-line {
    width: 2.25in;
    height: auto;
    margin: 0 auto 0.08in;
  }

  footer {
    margin-top: 0.4in;
  }
}

/* =========================
   Responsive
========================= */

@media screen and (max-width: 768px) {

  .document {
    padding: 30px 20px;
    margin: 20px;
  }

  .document-header {
    flex-direction: column;
    gap: 30px;
    text-align: center;
  }

  .document-header h1 {
    font-size: 32px;
  }

  .two-columns,
  .signature-area,
  .document-authorization {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .document-authorization .signature-line {
    width: 100%;
  }

  th,
  td {
    display: block;
    width: 100%;
  }

  th {
    padding-bottom: 5px;
  }
}

/* =========================
   Draft Contract Preview
========================= */

.contract-preview-actions {
  display: flex;
  justify-content: space-between;
  max-width: 1000px;
  margin: 24px auto 0;
}

.contract-preview-actions a,
.contract-preview-actions button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.contract-preview-status {
  max-width: 1000px;
  margin: 24px auto;
}

.contract-draft-banner {
  margin-bottom: 36px;
  border: 2px solid #7a3028;
  padding: 14px;
  color: #7a3028;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-align: center;
}

.contract-meta {
  margin: 0;
  text-align: right;
}

.contract-meta dt {
  margin-top: 8px;
  opacity: 0.65;
}

.contract-meta dd {
  margin: 2px 0 0;
}

.contract-draft-terms {
  border-left: 3px solid #7a3028;
  padding-left: 18px;
}

@media print {
  .contract-preview-actions,
  .contract-preview-status {
    display: none !important;
  }

  .contract-draft-banner {
    break-inside: avoid;
  }
}
