/* Printable documents: tax invoice (A4) and shipping label (100 × 150 mm). */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px 16px 48px;
  background: #ece8e1;
  color: #161413;
  font-family: "Saudi Riyal", "Almarai", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

bdi {
  unicode-bidi: isolate;
}

.print-toolbar {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.print-toolbar button {
  min-height: 42px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: #161413;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- Invoice and credit note ---------- */

.doc {
  position: relative;
  width: min(210mm, 100%);
  min-height: 270mm;
  margin: 0 auto;
  padding: 14mm 14mm 10mm;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
  page: invoice;
}

.doc::before {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  content: "";
  background: linear-gradient(90deg, #8a6224, #d4a85f, #8a6224);
}

.doc-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  max-width: 420px;
  opacity: 0.05;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.doc-title {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.doc-stamp {
  margin-top: 10px;
  padding: 4px 14px;
  border: 3px solid #3d7650;
  border-radius: 8px;
  color: #3d7650;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  transform: rotate(-12deg);
  opacity: 0.75;
}

.doc-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #161413;
}

.doc-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.doc-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  padding: 8px;
  border-radius: 16px;
  background: #161413;
}

.doc-seller {
  display: grid;
  gap: 2px;
  font-size: 12.5px;
  color: #3a3632;
}

.doc-seller strong {
  color: #161413;
  font-size: 17px;
}

.doc-title {
  text-align: end;
}

.doc-title h1 {
  margin: 0;
  font-size: 26px;
  color: #161413;
}

.doc-title span {
  color: #8a6224;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.doc-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid #e7dfd3;
  border-radius: 10px;
  background: #e7dfd3;
}

.doc-meta div {
  padding: 10px 12px;
  background: #faf7f2;
}

.doc-meta dt {
  color: #6c635a;
  font-size: 10.5px;
}

.doc-meta dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.doc-parties {
  display: flex;
  gap: 16px;
}

.doc-parties > div {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid #e7dfd3;
  border-radius: 10px;
  font-size: 13px;
}

.doc-caption {
  color: #8a6224;
  font-size: 10.5px;
  font-weight: 800;
}

.doc-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.doc-lines th {
  padding: 8px 6px;
  background: #161413;
  color: #fff;
  font-size: 11.5px;
  text-align: start;
  vertical-align: bottom;
}

.doc-lines th:first-child {
  border-start-start-radius: 8px;
}

.doc-lines th:last-child {
  border-start-end-radius: 8px;
}

.doc-lines th small {
  font-weight: 400;
  opacity: 0.7;
}

.doc-lines td {
  padding: 9px 6px;
  border-bottom: 1px solid #ece6dc;
}

.doc-lines tbody tr:nth-child(even) td {
  background: #fcfaf6;
}

.doc-lines td:not(:nth-child(2)),
.doc-lines th:not(:nth-child(2)) {
  text-align: center;
  white-space: nowrap;
}

.doc-lines .discount td {
  color: #a3363b;
}

.doc-lines .muted {
  color: #6c635a;
}

.doc-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.doc-qr {
  width: 128px;
  margin: 0;
  text-align: center;
  font-size: 10px;
  color: #6c635a;
}

.doc-qr svg {
  width: 100%;
  height: auto;
}

.doc-totals {
  display: grid;
  gap: 6px;
  min-width: 340px;
  margin: 0 0 0 auto;
}

[dir="rtl"] .doc-totals {
  margin: 0 auto 0 0;
}

.doc-totals div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}

.doc-totals dd {
  margin: 0;
  font-weight: 800;
}

.doc-totals .grand {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #161413;
  color: #fff;
  font-size: 15px;
}

.doc-totals .grand small {
  color: #d4a85f;
}

.doc-notes {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-inline-start: 3px solid #a3363b;
  background: #fbf3f3;
  font-size: 12.5px;
}

.doc-notes a {
  color: #a3363b;
}

.doc-note {
  margin: 0;
  color: #6c635a;
  font-size: 11.5px;
}

.doc-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #e7dfd3;
  text-align: center;
  font-size: 11.5px;
  color: #6c635a;
}

.doc-foot p {
  margin: 2px 0;
}

.doc-thanks {
  color: #8a6224;
  font-weight: 800;
}

.doc.credit::before {
  background: linear-gradient(90deg, #7a2a30, #c46a70, #7a2a30);
}

/* ---------- Shipping label ---------- */

.label {
  display: grid;
  gap: 3mm;
  width: 100mm;
  min-height: 150mm;
  margin: 0 auto;
  padding: 5mm;
  background: #fff;
  border: 1px solid #161413;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  font-size: 10pt;
  page: label;
}

.label-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 2mm;
  border-bottom: 2px solid #000;
}

.label-head strong {
  font-size: 16pt;
}

.label-logo {
  width: 12mm;
  height: 12mm;
  object-fit: contain;
  padding: 1mm;
  border-radius: 2mm;
  background: #000;
}

.label-gift {
  padding: 1.5mm;
  border: 2px solid #000;
  text-align: center;
  font-weight: 800;
}

.gift-card {
  display: grid;
  justify-items: center;
  gap: 4mm;
  width: 100mm;
  margin: 16px auto 0;
  padding: 8mm;
  border: 1px solid #d4a85f;
  background: #fffaf2;
  text-align: center;
  font-size: 13pt;
  page: label;
  break-before: page;
}

.gift-card img {
  width: 18mm;
  height: 18mm;
  object-fit: contain;
  padding: 1.5mm;
  border-radius: 3mm;
  background: #161413;
}

.label-caption {
  display: block;
  color: #555;
  font-size: 8pt;
  font-weight: 700;
}

.label-to {
  display: grid;
  gap: 1mm;
  padding: 3mm;
  border: 2px solid #000;
  border-radius: 2mm;
}

.label-to p {
  margin: 0;
}

.label-name {
  font-size: 15pt;
}

.label-phone {
  font-size: 14pt;
  letter-spacing: 0.04em;
}

.label-city {
  font-weight: 800;
}

.label-middle {
  display: flex;
  gap: 3mm;
  align-items: stretch;
}

.label-payment {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2mm;
  border: 1px solid #000;
  border-radius: 2mm;
}

.label-payment.collect {
  background: #000;
  color: #fff;
}

.label-payment strong {
  font-size: 15pt;
}

.label-qr {
  width: 30mm;
  margin: 0;
  text-align: center;
  font-size: 7pt;
}

.label-qr svg {
  width: 100%;
  height: auto;
}

.label-from {
  display: grid;
  gap: 0.5mm;
  font-size: 9pt;
}

.label-carrier {
  padding: 1.5mm;
  border: 1px dashed #000;
  text-align: center;
  font-weight: 800;
}

.label-items {
  margin: 0;
  padding-inline-start: 5mm;
  color: #333;
  font-size: 8pt;
}

/* ---------- Tech pack and customer design sheet ---------- */

/* Tokens used by the shared drawing styles (designer.css). */
.techpack-page {
  --font-body: "Saudi Riyal", "Almarai", system-ui, sans-serif;
  --muted: #6c635a;
  --line: #e7dfd3;
  --surface: #ffffff;
  --surface-2: #f4efe6;
  --radius-sm: 8px;
}

.techpack {
  gap: 18px;
}

.techpack h2 {
  margin: 0 0 8px;
  font-size: 10.5pt;
  letter-spacing: 0.04em;
}

.tp-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 2px solid #161413;
}

.tp-head .doc-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.tp-kicker {
  display: block;
  color: #8a6224;
  font-size: 8pt;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.tp-title h1 {
  margin: 2px 0;
  font-size: 18pt;
}

.tp-title span[lang] {
  color: #6c635a;
}

.tp-meta {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px 16px;
  margin: 0;
  font-size: 8.5pt;
}

.tp-meta dt {
  color: #6c635a;
}

.tp-meta dd {
  margin: 0;
  font-weight: 800;
}

.tp-edit {
  color: #8a6224;
  font-weight: 800;
}

.tp-flats {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  align-items: start;
}

.sheet-flats {
  grid-template-columns: 1fr;
}

.tp-flat,
.tp-colour,
.tp-pom {
  padding: 8px;
  border: 1px solid #e7dfd3;
  border-radius: 8px;
}

.tp-side {
  display: grid;
  gap: 10px;
}

.tp-swatches {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 9pt;
}

.tp-swatches li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tp-swatches span {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 4px;
  border: 1px solid #d8d0c4;
}

.tp-swatches .thread[data-thread="gold"] { background: linear-gradient(135deg, #a87a36, #e5c88a, #a87a36); }
.tp-swatches .thread[data-thread="silver"] { background: linear-gradient(135deg, #9aa0a8, #e8eaee, #9aa0a8); }
.tp-swatches .thread[data-thread="black"] { background: #141414; }
.tp-swatches .thread[data-thread="ivory"] { background: #efe6d4; }
.tp-swatches .thread[data-thread="tonal"] { background: linear-gradient(135deg, #161413 50%, #e9e2d6 50%); }

.tp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.tp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8.5pt;
}

.tp-table th,
.tp-table td {
  padding: 5px 7px;
  border-bottom: 1px solid #ece6dc;
  text-align: start;
  vertical-align: top;
}

.tp-table tbody th {
  width: 38%;
  color: #6c635a;
  font-weight: 400;
}

.tp-table thead th {
  background: #161413;
  color: #fff;
  font-weight: 800;
}

.tp-total td,
.tp-total th {
  font-weight: 800 !important;
  color: #161413 !important;
  border-top: 1px solid #161413;
}

.tp-spec {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 16px;
  align-items: start;
}

.tp-grading td,
.tp-grading th {
  text-align: center;
}

.tp-grading td:nth-child(2),
.tp-grading th:nth-child(2) {
  text-align: start;
}

.tp-grading .base {
  background: #f4ead9;
  font-weight: 800;
}

.tp-grading thead .base {
  background: #8a6224;
}

.tp-grading .code {
  color: #b5452f;
  font-weight: 800;
}

.tp-hint {
  color: #6c635a;
  font-size: 8pt;
}

.tp-notes {
  margin: 0;
  padding-inline-start: 18px;
  font-size: 9pt;
  display: grid;
  gap: 4px;
}

.tp-fabric {
  font-size: 9pt;
}

.techpack p {
  font-size: 9pt;
}

.tp-pre {
  white-space: pre-line;
  font-size: 9pt;
}

.tp-signoff {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: auto;
  padding-top: 18px;
  font-size: 8.5pt;
}

.tp-signoff div {
  display: grid;
  gap: 6px;
}

.tp-line {
  height: 26px;
  border-bottom: 1px solid #161413;
}

.tp-signoff small {
  color: #6c635a;
}

.sheet-price {
  display: grid;
  gap: 2px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f4ead9;
}

.sheet-price strong {
  font-size: 16pt;
}

.techpack .dz-view {
  fill: #6c635a;
}

/* ---------- Printing ---------- */

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

@page label {
  size: 100mm 150mm;
  margin: 0;
}

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

  .print-toolbar {
    display: none;
  }

  .doc,
  .label,
  .gift-card {
    box-shadow: none;
    margin: 0;
  }

  .doc {
    min-height: 297mm;
  }

  .label {
    border: 0;
    width: 100mm;
    height: 150mm;
  }
}

@media (max-width: 640px) {
  .tp-head,
  .tp-flats,
  .tp-grid,
  .tp-spec,
  .tp-signoff {
    grid-template-columns: 1fr;
  }

  .doc {
    min-height: 0;
    padding: 24px 14px;
  }

  .doc-head,
  .doc-summary,
  .doc-parties {
    flex-direction: column;
  }

  .doc-title {
    text-align: start;
  }

  .doc-meta {
    grid-template-columns: 1fr 1fr;
  }

  .doc-totals {
    min-width: 0;
    width: 100%;
  }

  .doc-lines {
    font-size: 11px;
  }
}
