/* Petromix Middle East · Price Offer (A4 print template)

   The supplied price-offer.css, with three changes for living inside the app:
   · its `body` rules are gone — they would have restyled the whole app; the
     preview frame (.ov) does that job instead, only while an offer is open;
   · `Inter` is the app's self-hosted face (theme.css), so no Google Fonts;
   · a print block at the end prints the OFFER, not the app behind it;
   · its @page rules (A4, the address footer, page numbers) moved to offer.js
     as OFFER_PAGE_CSS, injected only while an offer is open — @page cannot be
     scoped by a selector, so here they gave Ctrl+P ANYWHERE in the app the
     offer's margins and footer. */

.po {
  --ink: #111214;
  --ink-2: #374151;
  --muted: #6B7280;
  --line: #E3E5E8;
  --line-strong: #C9CDD2;
  --band: #0B0B0C;
  --gold: #F9B21D;
  --tint: #F6F7F8;

  width: 210mm;
  margin: 0 auto;
  background: #FFFFFF;
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 8.3pt;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  text-align: left;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.po * { box-sizing: border-box; }
.po h1, .po h2, .po h3, .po p { margin: 0; }

/* ---------- Header band ---------- */
.po-band {
  background: var(--band);
  padding: 7mm 16mm 6mm;
  display: flex; align-items: center; justify-content: space-between; gap: 10mm;
}
.po-logo { height: 12mm; width: auto; display: block; }
.po-title { text-align: right; color: #FFFFFF; }
.po-title h1 { font-family: "Inter", sans-serif; font-size: 22pt; line-height: 1; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #FFFFFF; }
.po-title p { margin-top: 2mm; font-size: 8pt; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.po-rule { height: 1.4mm; background: var(--gold); }

.po-body { padding: 5mm 16mm 0; }

/* ---------- Meta strip ---------- */
.po-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 0.3mm solid var(--line-strong); border-radius: 1.5mm; overflow: hidden; }
.po-meta > div { padding: 2.6mm 3.4mm; border-right: 0.3mm solid var(--line); }
.po-meta > div:last-child { border-right: 0; }
.po-label { display: block; font-size: 6.6pt; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.8mm; }
.po-meta strong { font-size: 9.6pt; font-weight: 700; white-space: nowrap; }
.po-meta small { display: block; font-size: 7.4pt; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-meta .po-valid strong { color: #9A5B00; }

/* ---------- Parties ---------- */
.po-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8mm; margin-top: 4mm; }
.po-party { padding-top: 2.4mm; border-top: 0.6mm solid var(--ink); }
.po-party h2 { font-size: 11pt; font-weight: 700; margin-bottom: 1.6mm; color: var(--ink); }
.po-party dl { display: grid; grid-template-columns: 20mm 1fr; gap: 0.6mm 3mm; margin: 0; }
.po-party dt { color: var(--muted); font-weight: 500; }
.po-party dd { margin: 0; font-weight: 500; }

.po .po-intro { margin-top: 3.5mm; font-size: 9pt; color: var(--ink-2); }
.po-intro b { color: var(--ink); }

/* ---------- Items table ---------- */
.po-table { width: 100%; border-collapse: collapse; margin-top: 3mm; table-layout: fixed; }
.po-table thead { display: table-header-group; }
.po-table th {
  background: var(--band); color: #FFFFFF; text-align: left;
  font-size: 6.8pt; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1.8mm 2.2mm; line-height: 1.25; vertical-align: bottom;
}
.po-table th:first-child { border-top-left-radius: 1.2mm; }
.po-table th:last-child { border-top-right-radius: 1.2mm; }
.po-table td { padding: 1.2mm 2.2mm; border-bottom: 0.3mm solid var(--line); vertical-align: top; color: var(--ink); }
.po-table tbody tr:nth-child(even) td { background: var(--tint); }
.po-table tr { break-inside: avoid; }
.po-table .c-no { color: var(--muted); }
.po-table col.w-no { width: 8mm; } .po-table col.w-prod { width: 53mm; } .po-table col.w-eq { width: 41mm; }
.po-table col.w-pack { width: 24mm; } .po-table col.w-qty { width: 9mm; } .po-table col.w-money { width: 21.5mm; }
.po-table .c-prod b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-table .c-prod small { display: block; color: var(--muted); font-size: 7.2pt; }
.po-table .c-eq { color: var(--ink-2); }
.po-table .c-pack { white-space: nowrap; }
.po-table .num { text-align: right; white-space: nowrap; }
.po-table td.num.total { font-weight: 700; }

/* ---------- Totals ---------- */
.po-words { padding: 2.4mm 3.4mm; background: var(--tint); border-left: 1mm solid var(--gold); border-radius: 0 1.2mm 1.2mm 0; }
.po-words p { font-weight: 600; color: var(--ink); }
.po-totals { border: 0.3mm solid var(--line-strong); border-radius: 1.5mm; overflow: hidden; }
.po-totals div { display: flex; justify-content: space-between; gap: 4mm; padding: 1.7mm 3.4mm; border-bottom: 0.3mm solid var(--line); }
.po-totals div span:last-child { font-weight: 600; }
.po-totals .po-grand { background: var(--band); color: #FFFFFF; border-bottom: 0; padding: 3mm 3.4mm; align-items: baseline; }
.po-totals .po-grand span:first-child { white-space: nowrap; font-size: 7pt; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.po-totals .po-grand span:last-child { white-space: nowrap; font-size: 13pt; font-weight: 800; color: var(--gold); }

/* ---------- Terms ---------- */
.po-terms { break-inside: avoid; }
.po-section-title { font-size: 7pt; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; padding-bottom: 1.6mm; border-bottom: 0.6mm solid var(--ink); margin-bottom: 2.4mm; color: var(--ink); }
.po-terms ol { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.8mm; font-size: 7.8pt; counter-reset: t; }
.po-terms li { counter-increment: t; display: grid; grid-template-columns: 6mm 1fr; }
.po-terms li::before { content: counter(t, decimal-leading-zero); font-weight: 700; color: var(--muted); }
.po-terms li b { font-weight: 700; }

/* ---------- Bottom block ---------- */
.po-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 78mm; gap: 7mm; margin-top: 4mm; break-inside: avoid; }
.po-col { display: flex; flex-direction: column; gap: 3mm; min-width: 0; }
.po-sign-box { border: 0.3mm solid var(--line-strong); border-radius: 1.5mm; padding: 2.6mm 3.4mm 2mm; display: flex; flex-direction: column; }
.po-stamp { width: 46mm; height: auto; margin-top: 1mm; mix-blend-mode: multiply; }
.po-lines { display: flex; flex-direction: column; gap: 4.5mm; margin-top: 3mm; }
.po-lines div { display: grid; grid-template-columns: 30mm 1fr; align-items: end; gap: 2mm; color: var(--muted); }
.po-lines div span:last-child { border-bottom: 0.3mm solid var(--line-strong); height: 4mm; }
.po-lines--sig { margin-top: 5mm; }
.po-lines--sig div { grid-template-columns: auto 1fr; }
.po-accept { margin-top: 3.5mm; padding: 2.6mm 3.4mm 3.2mm; border: 0.3mm solid var(--line-strong); border-radius: 1.5mm; break-inside: avoid; }
.po-accept .po-lines { flex-direction: row; gap: 6mm; margin-top: 2mm; }
.po-accept .po-lines div { flex: 1; grid-template-columns: auto 1fr; }
.po-accept .po-lines div:nth-child(2) { flex: 1.4; }

/* ══ The preview, inside the app ═══════════════════════════════════════════
   A full-screen frame over the app: a toolbar, and the A4 page on a grey
   desk, scaled to fit a phone by JS (style.zoom). Only shown while an offer
   is open; the app is untouched otherwise. */
.ov {
  position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column;
  background: #E9EBEE;
}
.ov__bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: #0B0B0C; color: #FFFFFF; font-family: "Inter", system-ui, sans-serif;
}
.ov__t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ov__t b { font-size: 15px; }
.ov__t span { font-size: 12px; color: #A3ABB4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov__btn {
  height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid rgba(255,255,255,.22);
  background: transparent; color: #FFFFFF; font: 700 14px/1.2 "Inter", system-ui, sans-serif; cursor: pointer;
}
.ov__btn--go { background: #F9B21D; border-color: #F9B21D; color: #111214; }
.ov__btn:focus-visible { outline: 3px solid #F9B21D; outline-offset: 2px; }
.ov__desk { flex: 1; overflow: auto; padding: 20px 16px 40px; }
.ov__desk .po { box-shadow: 0 6px 30px rgba(0,0,0,.12); min-height: 297mm; }

/* ══ Printing: the offer and nothing else ══════════════════════════════════
   html.is-printing-offer is set while the offer preview is open (and only
   then): every rule it switches on is inside @media print. */
@media print {
  html.is-printing-offer body > *:not(#offerView) { display: none !important; }
  html.is-printing-offer, html.is-printing-offer body { background: #FFFFFF !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; height: auto !important; }
  html.is-printing-offer .ov { position: static; display: block; background: #FFFFFF; }
  html.is-printing-offer .ov__bar { display: none !important; }
  html.is-printing-offer .ov__desk { padding: 0; overflow: visible; }
  html.is-printing-offer .ov__desk .po { box-shadow: none; min-height: 0; zoom: 1 !important; }
}
