:root {
  color-scheme: light;
  --green: #008638;
  --ink: #20252b;
  --muted: #626b72;
  --line: #aab2ad;
  --paper-width: 210mm;
  --paper-height: 297mm;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: #e9eeeb;
  color: var(--ink);
  font: 15px/1.42 Arial, sans-serif;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px max(20px, calc((100% - 920px) / 2));
  background: #fff;
  border-bottom: 1px solid #d6ddd9;
  box-shadow: 0 2px 10px rgb(24 40 30 / 6%);
}

.toolbar strong { color: var(--green); }

.toolbar-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.actions { display: flex; gap: 10px; }

.button {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary { background: #e5ebe7; color: var(--ink); }

.pages { padding-bottom: 30px; }

.paper {
  position: relative;
  width: min(var(--paper-width), calc(100% - 24px));
  min-height: var(--paper-height);
  margin: 18px auto;
  padding: 17mm 18mm 16mm;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 30px rgb(24 40 30 / 13%);
}

.document { position: relative; min-height: 260mm; padding-bottom: 10mm; }

.document-title {
  margin: 0;
  text-align: center;
  font-size: 24px;
  text-transform: uppercase;
}

.document-number { margin: 2px 0 20px; text-align: center; }

.page-heading {
  margin: 0 0 17px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  text-align: center;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h2 { margin: 20px 0 8px; font-size: 17px; }
h3 { margin: 15px 0 6px; font-size: 15px; }
p { margin: 6px 0; text-align: justify; }

.clause {
  display: grid;
  grid-template-columns: 31px 1fr;
  gap: 3px;
  margin: 5px 0;
}

.clause p { margin: 0; }

.field {
  display: inline-block;
  min-width: 150px;
  padding: 0 3px;
  border-bottom: 1px solid #555;
  font-weight: 700;
}

.field.long { min-width: 280px; }
.placeholder { color: var(--ink); font-weight: 700; }

.confirmed {
  margin: 11px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: #f0f8f3;
}

ul { margin: 7px 0 8px 20px; padding: 0; }
li { margin: 3px 0; }

table { width: 100%; margin: 10px 0; border-collapse: collapse; }
th, td { padding: 8px 9px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { width: 31%; background: #f1f4f2; }

.compact th, .compact td { padding: 6px 8px; }
.compact th { width: auto; }

.term-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.term-card div {
  padding: 9px 10px;
  border: 1px solid #cbd2ce;
  background: #fafbfa;
}

.term-card b { display: block; margin-bottom: 2px; color: #323b35; }

.signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 20px;
}

.signature { min-width: 0; min-height: 195px; border: 1px solid var(--line); padding: 13px; overflow-wrap: anywhere; }
.signature > b { display: block; margin-bottom: 10px; }
.signature-line { margin-top: 21px; border-bottom: 1px solid #555; height: 20px; }
.signature-hint { color: var(--muted); font-size: 11px; text-align: center; }

.page-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid #d7dcd9;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 700px) {
  body { font-size: 14px; }
  .toolbar { align-items: flex-start; padding: 11px 12px; }
  .toolbar > div:first-child { display: none; }
  .actions { width: 100%; }
  .button { flex: 1; padding: 10px 8px; text-align: center; }
  .paper { min-height: auto; padding: 28px 21px 45px; }
  .document { min-height: auto; }
  .meta, .signatures, .term-card { display: block; }
  .meta span { display: block; margin: 4px 0; }
  .signature, .term-card div { margin-top: 10px; }
  .field.long { min-width: 180px; }
  .page-footer { position: static; margin-top: 28px; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; font-size: 12px; line-height: 1.33; }
  .no-print { display: none !important; }
  .pages { padding: 0; }
  .paper {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    margin: 0;
    padding: 14mm 17mm 13mm;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }
  .paper:last-child { break-after: auto; page-break-after: auto; }
  .document { min-height: 270mm; }
  h2 { margin-top: 13px; }
  .clause { margin: 3px 0; }
  .confirmed { margin: 7px 0; padding: 7px 9px; }
  .page-footer { bottom: 0; }
  .paper:nth-child(5),
  .paper:nth-child(6) { font-size: 11px; line-height: 1.24; }
  .paper:nth-child(5) h2,
  .paper:nth-child(6) h2 { margin-top: 10px; font-size: 15px; }
  .paper:nth-child(5) .term-card,
  .paper:nth-child(6) .term-card,
  .paper:nth-child(5) .signatures,
  .paper:nth-child(6) .signatures { margin-top: 8px; }
}