/* A4 quotation / invoice / receipt (Prasat CI, from the Quotations/ and Invoices/ templates of 8 Oct 2026).
   Everything is scoped to .a4 so the app's own styles never leak in. --navy and --sky can be changed per
   workspace (Documents → Settings); the other shades are mixed from them. */
.a4 {
  --navy: #102858; --sky: #1A89C5;
  --blue: color-mix(in srgb, var(--navy) 70%, var(--sky)); --blue2: color-mix(in srgb, var(--sky) 80%, var(--navy));
  --sky-l: color-mix(in srgb, var(--sky) 75%, #fff); --pale: color-mix(in srgb, var(--sky) 32%, #fff);
  --ink: #14223d; --muted: #5b6b86; --line: #d9e3ef; --tint: color-mix(in srgb, var(--sky) 6%, #fff);
  width: 210mm; height: 297mm; position: relative; overflow: hidden; display: flex; flex-direction: column;
  background: #fff; color: var(--ink); font: 9.6pt/1.45 "IBM Plex Sans", "Noto Sans Khmer", sans-serif; text-align: left;
  transform-origin: 0 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; letter-spacing: normal;
}
.a4 *, .a4 *::before, .a4 *::after { box-sizing: border-box; }
.a4 h1, .a4 h2, .a4 p, .a4 ul, .a4 dl, .a4 dd { margin: 0; padding: 0; }
.a4 img { display: block; max-width: none; }
.a4 .nb { white-space: nowrap; }

.a4-head { background: var(--navy); color: #fff; padding: 9mm 16mm 8mm; display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; position: relative; flex: none; }
.a4-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2mm; background: linear-gradient(90deg, var(--sky), var(--blue2) 55%, var(--blue)); }
.a4-brandblock { display: flex; align-items: center; gap: 4mm; min-width: 0; }
.a4-brandblock img { height: 14mm; width: auto; max-width: 48mm; object-fit: contain; }
.a4-brandblock b { display: block; font: 800 17pt/1 Montserrat, "Noto Sans Khmer", sans-serif; letter-spacing: .02em; }
.a4-brandblock b span { color: var(--sky-l); }
.a4-brandblock small { display: block; margin-top: 2mm; font: 500 7.5pt "IBM Plex Mono", monospace; letter-spacing: .18em; color: var(--pale); text-transform: uppercase; }
.a4-issuer b { display: block; font: 700 17pt/1.1 "Space Grotesk", "Noto Sans Khmer", sans-serif; letter-spacing: .01em; }
.a4-issuer div { margin-top: 1.6mm; font: 500 9pt "IBM Plex Mono", monospace; color: var(--pale); }
.a4-issuer div + div { margin-top: .6mm; }
.a4-doc { text-align: right; flex: none; }
.a4-doc h1 { font: 700 27pt/1 "Space Grotesk", sans-serif; letter-spacing: .08em; color: #fff; }
.a4-doc p { margin-top: 2.5mm; font-size: 9.5pt; color: var(--pale); max-width: 92mm; margin-left: auto; }
.a4-kind { display: inline-block; margin-top: 2.5mm; padding: .8mm 3mm; border: 1px solid var(--sky-l); border-radius: 1.2mm; font: 600 7.5pt "IBM Plex Mono", monospace; letter-spacing: .14em; text-transform: uppercase; color: #fff; }

.a4-main { padding: 8mm 16mm 6mm; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.a4-label { display: flex; align-items: center; gap: 2.5mm; margin: 0 0 3.5mm; padding-bottom: 2.2mm; border-bottom: 1px solid var(--line); font: 600 8pt "IBM Plex Mono", monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--blue2); }
.a4-plain .a4-label::before { content: ""; width: 2.2mm; height: 2.2mm; border-radius: .5mm; background: var(--sky); flex: none; }
.a4-tiers { display: inline-grid; justify-items: center; gap: .45mm; }
.a4-tiers i { display: block; height: .9mm; background: var(--sky); border-radius: .2mm; }
.a4-tiers i:nth-child(1) { width: 1.6mm; } .a4-tiers i:nth-child(2) { width: 2.5mm; background: var(--blue2); }
.a4-tiers i:nth-child(3) { width: 3.4mm; background: var(--blue); } .a4-tiers i:nth-child(4) { width: 4.3mm; background: var(--navy); }

.a4-meta { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12mm; margin-bottom: 6mm; }
.a4-who { font: 600 12pt "Space Grotesk", "Noto Sans Khmer", sans-serif; margin-bottom: 1.5mm; }
.a4 dl { display: grid; grid-template-columns: auto 1fr; gap: .6mm 4mm; }
.a4 dt { color: var(--muted); }
.a4 dd { font-weight: 600; overflow-wrap: anywhere; }
.a4-details dd { font-family: "IBM Plex Mono", monospace; }

.a4-items { width: 100%; border-collapse: collapse; font-size: inherit; }
.a4-items th { background: var(--navy); color: #fff; font: 600 8.5pt "IBM Plex Sans", sans-serif; letter-spacing: .06em; text-transform: uppercase; padding: 3.2mm 4mm; text-align: right; border: 0; vertical-align: middle; }
.a4-items th:first-child { text-align: left; border-radius: 2mm 0 0 0; } .a4-items th:last-child { border-radius: 0 2mm 0 0; }
.a4-items td { padding: 3.5mm 4mm; vertical-align: top; text-align: right; border: 0; border-bottom: 1px solid var(--line); font: 500 9.6pt/1.45 "IBM Plex Mono", monospace; color: var(--ink); white-space: nowrap; }
.a4-items td:first-child { text-align: left; font-family: "IBM Plex Sans", "Noto Sans Khmer", sans-serif; font-weight: 400; white-space: normal; }
.a4-items td.a4-empty { color: var(--muted); text-align: center; }
.a4-item { font: 600 12pt "Space Grotesk", "Noto Sans Khmer", sans-serif; margin-bottom: 2mm; }
.a4-scope { list-style: none; font-size: 9pt; color: var(--muted); }
.a4-scope li { position: relative; padding-left: 4.5mm; margin: .8mm 0; }
.a4-scope li::before { content: ""; position: absolute; left: 0; top: 1.9mm; width: 1.6mm; height: 1.6mm; border-radius: .4mm; background: var(--sky); }
.a4-scope b { color: var(--ink); font-weight: 600; }

.a4-totals { margin: 3mm 0 0 auto; width: 86mm; position: relative; }
.a4-totals div { display: flex; justify-content: space-between; gap: 4mm; padding: 1.2mm 4mm; color: var(--muted); }
.a4-totals div span:last-child { font-family: "IBM Plex Mono", monospace; color: var(--ink); white-space: nowrap; }
.a4-totals .project { margin-top: 1mm; border-top: 1px solid var(--line); padding-top: 2.2mm; color: var(--ink); font-weight: 600; }
.a4-totals .grand { margin-top: 2mm; padding: 3.2mm 4mm; border-radius: 2mm; background: var(--navy); color: #fff; align-items: baseline; }
.a4-totals .grand span:first-child { font: 600 11pt "Space Grotesk", sans-serif; color: var(--pale); }
.a4-totals .grand span:last-child { font: 700 17pt "Space Grotesk", sans-serif; color: #fff; }
.a4-totals .after { padding-top: 2mm; font-size: 8.8pt; }

.a4-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; margin-top: 6mm; }
.a4-plain .a4-boxes { grid-template-columns: 1.2fr 1fr; }
.a4-boxes.one { grid-template-columns: 1fr; }
.a4-box { padding: 4mm 6mm; background: var(--tint); border-radius: 2.5mm; border-left: 1.4mm solid var(--sky); }
.a4-box.pay { border-left-color: var(--navy); }
.a4-box .a4-label { border: 0; padding: 0; margin-bottom: 2.5mm; }
.a4-box ul { list-style: none; font-size: 9pt; }
.a4-box li { position: relative; padding-left: 4.5mm; margin: 1mm 0; }
.a4-box li::before { content: ""; position: absolute; left: 0; top: 2mm; width: 1.5mm; height: 1.5mm; border-radius: 50%; background: var(--blue2); }
.a4-box b { font-weight: 600; }
.a4-paygrid { display: flex; gap: 4mm; align-items: flex-start; }
.a4-paygrid ul { flex: 1; }
.a4-qr { flex: none; width: 29mm; text-align: center; }
.a4-qr img { width: 29mm; height: 29mm; object-fit: contain; padding: 1.5mm; background: #fff; border-radius: 1.5mm; border: 1px solid var(--line); }
.a4-qr span { display: block; margin-top: 1mm; font: 600 7pt "IBM Plex Mono", monospace; letter-spacing: .12em; color: var(--blue2); }

.a4-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16mm; margin-top: auto; padding-top: 8mm; }
.a4-sign div { border-top: 1px solid #9fb3cc; padding-top: 2.5mm; text-align: center; font-size: 9.5pt; color: var(--muted); }
.a4-sign small { display: block; margin-top: 1mm; font-size: 8pt; color: #8a99b2; min-height: 1.2em; }

.a4-foot { background: var(--navy); color: var(--pale); padding: 3mm 16mm; display: flex; justify-content: space-between; align-items: center; gap: 6mm; font-size: 8.5pt; flex: none; }
.a4-foot b { color: #fff; font: 600 9pt "Space Grotesk", sans-serif; letter-spacing: .02em; flex: none; }
.a4-contact { text-align: right; line-height: 1.6; }
.a4-contact span + span::before { content: "·"; margin: 0 2.5mm; color: var(--sky-l); }

.a4-stamp { position: absolute; pointer-events: none; font: 700 16pt "Space Grotesk", sans-serif; letter-spacing: .2em; }
.a4-stamp-draft, .a4-stamp-void { left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-28deg); font-size: 92pt; opacity: .07; color: var(--navy); }
.a4-stamp-void { opacity: .16; color: #b42335; }
/* Stamps sit in the empty space left of the totals. */
.a4-totals .a4-stamp-paid { display: block; right: calc(100% + 14mm); left: auto; top: 6mm; padding: 1.5mm 5mm; transform: rotate(-12deg); color: #157a46; border: 1mm solid currentColor; border-radius: 2mm; opacity: .6; font-size: 18pt; }

/* Screen: a page box that scales the sheet to fit (see fitA4 in doc-render.js). */
.a4-fit { position: relative; overflow: hidden; border-radius: 6px; box-shadow: 0 1px 3px rgba(16, 40, 88, .12), 0 8px 28px rgba(16, 40, 88, .14); background: #fff; }
.a4-fit .a4 { position: absolute; left: 0; top: 0; }
