:root {
  --ink: #1c2428;
  --muted: #5d6a70;
  --line: #cfd7dc;
  --panel: #f4f7f8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --paper: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #e8edf0;
  font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  min-height: 100vh;
}

.toolbar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.toolbar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.toolbar p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.form-grid {
  display: grid;
  gap: 18px;
}

fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  color: #354046;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  min-height: 38px;
  border: 1px solid #b9c4ca;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 8px 10px;
  background: #fff;
}

button {
  padding: 0 14px;
  border-color: transparent;
  background: #dce7ea;
  color: #172024;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.primary {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.status {
  min-height: 20px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--accent-dark);
}

.preview-wrap {
  display: grid;
  justify-content: center;
  gap: 24px;
  padding: 32px;
}

.page {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  padding: 12mm 18mm 18mm;
  background: var(--paper);
  box-shadow: 0 10px 34px rgba(18, 31, 38, 0.18);
  color: #111;
  font-family: "Times New Roman", Times, serif;
  font-size: 12.5pt;
  line-height: 1.25;
}

.page h2 {
  margin: 4mm 0 18px;
  text-align: center;
  font-size: 18pt;
  letter-spacing: 0;
}

.page-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 25mm;
}

.page-logo img {
  width: auto;
  height: 25mm;
  max-width: 52mm;
  object-fit: contain;
}

.page h3 {
  margin: 14px 0 8px;
  font-size: 13pt;
  text-align: center;
}

.date-line {
  text-align: center;
}

.company-block {
  margin-top: 30px;
}

.recipient-marker {
  margin-bottom: 14px;
}

.company-block p,
.signature-footer p,
.agreement p {
  margin: 3px 0;
}

.ref {
  margin-top: 24px;
  font-weight: 700;
}

table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border: 1px solid #111;
  padding: 8px;
  vertical-align: top;
}

th:first-child,
td:first-child {
  width: 75%;
}

th {
  text-align: left;
  font-weight: 700;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-box {
  display: grid;
  place-items: center;
  height: 228px;
  border: 1px dashed #777;
  color: #777;
  overflow: hidden;
  background: #fafafa;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11pt;
  padding: 4px;
}

.photo-box img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  display: block;
}

.signature-footer {
  position: absolute;
  right: 18mm;
  bottom: 5mm;
  left: 18mm;
  text-align: center;
}

.line {
  width: 260px;
  max-width: 100%;
  margin: 20px auto 6px;
  border-top: 1px solid #111;
}

.conditions {
  margin: 0;
  padding-left: 22px;
}

.conditions li {
  margin-bottom: 8px;
}

.uppercase-label {
  text-transform: uppercase;
}

.conditions .validity-line {
  margin-bottom: 92px;
}

.agreement {
  margin-top: 28px;
  text-align: center;
}

.agreement .agree-title {
  margin: 28px 0 0;
  font-weight: 700;
}

.client-signature .line {
  margin-top: 28px;
}

.conditions-page .signature-footer {
  position: static;
  margin-top: 18mm;
}

.conditions-page {
  font-size: 11.2pt;
  line-height: 1.14;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-wrap {
    overflow: auto;
    justify-content: start;
  }
}

@media print {
  body {
    background: #fff;
  }

  .toolbar {
    display: none;
  }

  .app-shell,
  .preview-wrap {
    display: block;
    padding: 0;
  }

  .page {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
    page-break-after: always;
  }

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

  @page {
    size: A4;
    margin: 0;
  }
}
