:root {
  color-scheme: light;
  --ink: #202020;
  --muted: #666666;
  --line: #d7d7d7;
  --paper: #ffffff;
  --field: #f7f7f7;
  --accent: #ed1c24;
  --accent-dark: #c9141b;
  --red: #ed1c24;
  --shell: #f1f1f1;
  --soft-accent: #fff0f1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--shell);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(380px, 540px) minmax(720px, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.editor {
  align-self: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 16px 42px rgba(32, 32, 32, 0.12);
}

.editor__header,
.section-title,
.template-top,
.logo-row,
.totals,
.notes-sales,
.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 25px;
}

h2 {
  font-size: 18px;
}

form {
  display: grid;
  gap: 15px;
  margin-top: 18px;
}

.grid {
  display: grid;
  gap: 12px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 12px 18px;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  padding: 9px 12px;
}

.product-editor {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-editor__head,
.product-row {
  display: grid;
  grid-template-columns: 100px minmax(180px, 1fr) 76px 106px 82px 42px;
  gap: 8px;
  align-items: center;
  min-width: 780px;
  padding: 10px;
}

.product-editor__head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: var(--soft-accent);
  border-bottom: 1px solid var(--line);
}

.product-row + .product-row {
  border-top: 1px solid var(--line);
}

.remove-row {
  width: 34px;
  height: 34px;
  border: 0;
  background: #fff0ef;
  color: var(--red);
}

.preview-wrap {
  overflow: auto;
  display: grid;
  place-items: start center;
}

.quote-page {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  background: var(--paper);
  padding: 22mm 15mm 14mm;
  box-shadow: 0 18px 56px rgba(32, 32, 32, 0.18);
}

.quote-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-top: 12mm solid var(--accent);
  border-bottom: 8mm solid var(--accent);
}

.logo-row {
  position: relative;
  justify-content: center;
  margin-bottom: 1em;
  z-index: 1;
}

.brand-mark {
  width: 210px;
  max-height: 90px;
  object-fit: contain;
}

.template-top {
  position: relative;
  align-items: flex-start;
  margin-bottom: 22px;
  z-index: 1;
}

.form-title {
  margin-right: auto;
}

.form-title strong {
  display: block;
  font-size: 39px;
  line-height: 1;
  letter-spacing: 0;
}

.form-title span {
  display: block;
  margin-top: 5px;
  font-size: 28px;
}

.quote-number-box {
  display: grid;
  grid-template-columns: 112px 78px 88px 72px 72px;
  gap: 0;
  margin-top: 8px;
  border: 1px solid var(--line);
}

.quote-number-box div {
  display: grid;
  gap: 7px;
  padding: 8px 10px;
  min-height: 58px;
}

.quote-number-box div + div {
  border-left: 1px solid var(--line);
}

.quote-number-box span,
.payment-box span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.quote-number-box strong,
.payment-box strong {
  font-size: 14px;
}

.customer-block {
  display: grid;
  grid-template-columns: 1fr 105px;
  gap: 16px;
  margin: 8px 0 24px;
}

.customer-lines {
  display: grid;
  gap: 6px;
  max-width: 520px;
}

.customer-lines div {
  display: grid;
  grid-template-columns: 108px 14px minmax(0, 1fr);
  gap: 5px;
  min-height: 22px;
  align-items: baseline;
}

.customer-lines span {
  font-size: 13px;
}

.customer-lines strong {
  font-size: 15px;
  font-weight: 700;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.email {
  color: var(--accent-dark);
}

.payment-box {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 0;
  min-height: 62px;
}

.payment-box span {
  display: block;
  background: var(--accent);
  color: #fff;
  padding: 8px 10px;
}

.payment-box strong {
  display: block;
  padding: 9px 10px;
}

.salutation {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.intro {
  margin: 0 0 28px;
  font-size: 13px;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.quote-table th,
.quote-table td {
  padding: 8px 7px;
  border: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.quote-table th {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  text-align: left;
}

.quote-table th:nth-child(1),
.quote-table td:nth-child(1) {
  width: 96px;
}

.quote-table th:nth-child(3),
.quote-table td:nth-child(3),
.quote-table th:nth-child(5),
.quote-table td:nth-child(5) {
  width: 94px;
  text-align: right;
}

.quote-table th:nth-child(4),
.quote-table td:nth-child(4) {
  width: 70px;
  text-align: center;
}

.totals {
  align-items: flex-start;
  margin-top: 26px;
}

.amount-in-words {
  width: 48%;
  min-height: 32px;
  font-size: 17px;
  font-weight: 700;
}

.total-box {
  width: 340px;
  display: grid;
  gap: 6px;
}

.total-box div {
  display: grid;
  grid-template-columns: 1fr 108px;
  align-items: center;
  gap: 8px;
}

.total-box span {
  font-size: 13px;
}

.total-box strong {
  text-align: right;
  font-size: 16px;
}

.try-total {
  color: var(--muted);
}

.notes-sales {
  align-items: flex-start;
  margin-top: 28px;
}

.notes {
  flex: 1;
}

.notes h3,
.sales h3 {
  margin-bottom: 9px;
  font-size: 16px;
}

.notes ul {
  margin: 0;
  padding-left: 18px;
}

.notes li {
  margin-bottom: 7px;
  font-size: 13px;
}

.sales {
  width: 250px;
}

.sales p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.quote-footer {
  position: absolute;
  left: 15mm;
  right: 15mm;
  bottom: 9mm;
  color: #fff;
  font-size: 9px;
  z-index: 1;
}

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

  .preview-wrap {
    place-items: start;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 12px;
  }

  .editor {
    padding: 16px;
  }

  .editor__header,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }

  .quote-page {
    min-width: 794px;
  }
}

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

@media print {
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .editor {
    display: none;
  }

  .app {
    display: block;
    padding: 0;
    min-height: 0;
  }

  .preview-wrap {
    display: block;
    overflow: visible;
  }

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