* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #1b211e;
  --muted: #626b66;
  --line: #9aa49d;
  --soft-line: #dce3df;
  --paper: #fff;
  --wash: #eef2ef;
  --gold: #dca93b;
  --green: #0a6457;
  --green-strong: #073f38;
}

html {
  background: var(--wash);
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at top right, rgb(220 169 59 / 16%), transparent 30rem),
    linear-gradient(135deg, #f7faf8 0%, var(--wash) 100%);
  color: var(--ink);
  font-family: Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.real-invoice-pages {
  width: min(100% - 32px, 1430px);
  margin: 24px auto;
  direction: rtl;
}

.real-invoice-pages > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.real-invoice-pages h1,
.real-invoice-pages p {
  margin: 0;
}

.real-invoice-note {
  color: var(--muted);
  margin-bottom: 18px !important;
}

.real-invoice-page {
  background: #fff;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgb(34 39 35 / 12%);
  margin-bottom: 24px;
  overflow: hidden;
}

.real-invoice-label {
  align-items: center;
  background: #f0f5f2;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
}

.real-invoice-label a {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.real-invoice-page iframe {
  background: #fff;
  border: 0;
  display: block;
  height: 900px;
  width: 100%;
}

a,
button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgb(220 169 59 / 45%);
  outline-offset: 3px;
}

.print-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 20px auto;
  width: min(1430px, calc(100% - 40px));
}

.print-actions a,
.print-actions button {
  border-radius: 8px;
  font-weight: 700;
  min-height: 42px;
  padding: 10px 16px;
  text-decoration: none;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.print-actions a {
  background: #fff;
  border: 1px solid #bed1c8;
  color: var(--green);
}

.print-actions button {
  background: linear-gradient(180deg, var(--green), var(--green-strong));
  border: 0;
  box-shadow: 0 10px 24px rgb(10 100 87 / 18%);
  color: #fff;
  cursor: pointer;
}

.print-actions a:hover,
.print-actions button:hover {
  transform: translateY(-1px);
}

.invoice-sheet {
  background: var(--paper);
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgb(34 39 35 / 12%);
  margin: 0 auto 28px;
  min-height: 820px;
  padding: 48px 56px;
  width: min(1430px, calc(100% - 40px));
}

.invoice-head {
  align-items: center;
  direction: ltr;
  display: flex;
  justify-content: space-between;
}

.logo {
  align-items: center;
  direction: rtl;
  display: flex;
  gap: 14px;
}

.logo > span {
  align-items: center;
  background: linear-gradient(145deg, #f2c765, #c38c20);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-size: 28px;
  font-weight: 700;
  height: 74px;
  justify-content: center;
  width: 88px;
}

.logo strong {
  color: var(--green-strong);
  display: grid;
  font-size: 34px;
}

.logo small {
  color: var(--muted);
  direction: ltr;
  font-size: 22px;
  font-weight: 400;
}

.meta {
  direction: rtl;
  font-size: 19px;
  text-align: right;
}

.meta p {
  margin: 10px 0 0;
}

.divider {
  border-top: 3px solid var(--green);
  margin: 28px 0 34px;
}

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

.party,
.factor {
  border: 1.5px solid var(--line);
  border-radius: 8px;
}

.party {
  background: linear-gradient(180deg, #fff, #f9fbfa);
  min-height: 250px;
  padding: 22px 30px;
}

.party h2 {
  color: var(--green-strong);
  font-size: 20px;
  margin: 0 0 18px;
}

p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.9;
  margin: 8px 0;
}

p span {
  color: var(--muted);
}

p strong {
  overflow-wrap: anywhere;
}

.party-fields {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.party-fields p {
  background: #fff;
  border: 1px solid #eef2ef;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 10px 12px;
}

.factor {
  margin-top: 18px;
  min-height: 410px;
  overflow: hidden;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--soft-line);
  overflow-wrap: anywhere;
  padding: 14px 10px;
  text-align: center;
}

th:first-child,
td:first-child {
  text-align: right;
}

thead th,
.summary th,
.summary td {
  background: #f0f5f2;
  color: #30443c;
}

.signatures {
  background: #fbfdfb;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 220px;
}

.signatures strong {
  border-inline-start: 1px solid var(--soft-line);
  padding: 18px 28px;
}

.signatures strong:last-child {
  border-inline-start: 0;
}

.missing {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 40px auto;
  padding: 24px;
  width: min(720px, calc(100% - 40px));
}

@media (max-width: 920px) {
  .print-actions,
  .invoice-sheet {
    width: min(100% - 24px, 100%);
  }

  .invoice-sheet {
    min-height: auto;
    padding: 28px 18px;
  }

  .invoice-head {
    align-items: flex-start;
    direction: rtl;
    flex-direction: column;
    gap: 18px;
  }

  .party-grid,
  .party-fields,
  .signatures {
    grid-template-columns: 1fr;
  }

  .factor {
    overflow-x: auto;
  }

  table {
    min-width: 860px;
  }
}

@media print {
  @page {
    margin: 8mm;
    size: A4 landscape;
  }

  body {
    background: #fff;
  }

  .print-actions {
    display: none;
  }

  .real-invoice-pages {
    margin: 0;
    width: 100%;
  }

  .real-invoice-pages > header,
  .real-invoice-note,
  .real-invoice-label {
    display: none;
  }

  .real-invoice-page {
    break-after: page;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    overflow: hidden;
  }

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

  .real-invoice-page iframe {
    height: 190mm;
    width: 100%;
  }

  .invoice-sheet {
    break-after: page;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    min-height: auto;
    padding: 0;
    width: 100%;
  }

  .invoice-sheet:last-child {
    break-after: auto;
  }
}
