/* ==========================================================================
   Tax documents (js/core/taxdoc.js): bilingual A4 print formats for the tax
   invoice, advance invoice, credit note, proforma and payment claim.
   Fixed print colours (paper is always white): navy #172e38, teal #19868b,
   red #e1273d. The document is laid out left-to-right in both languages,
   Arabic text runs right-to-left inside it, as on UAE bilingual invoices.
   ========================================================================== */
.a4.a4-doc { padding: 12mm 13mm 10mm; }
.td { position: relative; display: flex; flex-direction: column; gap: 9px; min-height: calc(297mm - 22mm); font-size: 10.5px; color: #13232b; line-height: 1.4; }
.td [lang="ar"] { font-family: "IBM Plex Sans Arabic", var(--font); }
.td .muted { color: #6f818a; }
.td-bi { display: inline-flex; flex-direction: column; line-height: 1.25; }
.td-bi [lang="ar"] { font-size: .95em; }

/* Head: logos, bilingual title */
.td-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-bottom: 9px; border-bottom: 3px solid #19868b; }
.td-head img { height: 42px; width: auto; }
.td-head img:last-child { justify-self: end; }
.td-title { display: grid; justify-items: center; text-align: center; gap: 1px; }
.td-title b { font-size: 19px; color: #172e38; letter-spacing: .02em; }
.td-title b[lang="en"] { text-transform: uppercase; letter-spacing: .12em; font-size: 16px; }
.td-title span { margin-top: 3px; padding: 2px 10px; border-radius: 999px; background: #e7f3f3; color: #146b6f; font-size: 9.5px; font-weight: 700; }
.td-info .td-title span, .td-credit .td-title span { background: #fdecee; color: #b81d31; }

/* Parties */
.td-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.td-party { border: 1px solid #d6e1e5; border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.td-party h5 { margin: 0 0 4px; font-size: 9.5px; color: #19868b; text-transform: uppercase; letter-spacing: .06em; }
.td-party h5 .td-bi { flex-direction: row; gap: 6px; }
.td-party > b { font-size: 11.5px; color: #172e38; }
.td-party p { margin: 3px 0 0; color: #3d525c; font-size: 10px; }
.td-trn { margin-top: auto; padding-top: 6px; display: flex; align-items: baseline; gap: 8px; border-top: 1px dashed #d6e1e5; }
.td-trn small { color: #6f818a; font-size: 9px; }
.td-trn b { font-size: 11px; letter-spacing: .03em; }

/* Meta strip and project */
.td-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0; border: 1px solid #d6e1e5; border-radius: 6px; overflow: hidden; }
.td-meta .td-kv + .td-kv { border-inline-start: 1px solid #d6e1e5; }
.td-kv { padding: 5px 8px; min-width: 0; }
.td-kv small { display: flex; flex-direction: column; color: #6f818a; font-size: 8.5px; line-height: 1.25; }
.td-kv small span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: match-parent; }
.td-proj .td-kv small { flex-direction: row; gap: 6px; }
.td-kv b { font-size: 10.5px; overflow-wrap: anywhere; }
.td-kv.strong { background: #172e38; color: #fff; }
.td-kv.strong small { color: #a9c6cc; }
.td-proj { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; }
.td-proj .td-kv { background: #f4f8f9; border-radius: 6px; }

/* Lines */
.td-lines { width: 100%; border-collapse: collapse; font-size: 10px; }
.td-lines th { background: #172e38; color: #fff; font-weight: 600; padding: 5px 6px; text-align: start; vertical-align: bottom; }
.td-lines th span { display: block; text-align: match-parent; }
.td-lines .td-ar, .td-line { text-align: match-parent; }
.td-line { display: block; }
.td-lines th span[lang="ar"] { font-weight: 500; color: #bcd6db; font-size: 9px; }
.td-lines th.n, .td-lines td.n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.td-lines th:first-child, .td-lines td:first-child { width: 22px; text-align: center; }
.td-lines td { padding: 6px; border-bottom: 1px solid #e3eaed; vertical-align: top; }
.td-lines tbody tr:nth-child(even) td { background: #f8fbfb; }
.td-lines td b { color: #172e38; font-weight: 600; }
.td-lines .td-ar { display: block; color: #3d525c; }
.td-lines td small { display: block; color: #6f818a; font-size: 9px; margin-top: 1px; }

/* Words, bank, totals */
.td-sum { display: grid; grid-template-columns: minmax(0, 1fr) 76mm; gap: 12px; align-items: start; }
.td-side { display: grid; gap: 8px; }
.td-words, .td-bank, .td-note { border-inline-start: 3px solid #19868b; background: #f4f8f9; padding: 6px 9px; border-radius: 0 4px 4px 0; }
.td-note { border-color: #e1273d; background: #fdf3f4; }
.td-words small, .td-bank small, .td-note small { display: block; color: #6f818a; font-size: 8.5px; margin-bottom: 2px; }
.td-words p, .td-bank p, .td-note p { margin: 0; font-size: 10px; }
.td-words p + p { margin-top: 2px; }
.td-totals { border: 1px solid #d6e1e5; border-radius: 6px; overflow: hidden; }
.td-tr { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 9px; }
.td-tr + .td-tr { border-top: 1px solid #e3eaed; }
.td-tr b { font-size: 11px; font-variant-numeric: tabular-nums; }
.td-tr.grand { background: #19868b; color: #fff; }
.td-tr.grand b { font-size: 14px; }
.td-credit .td-tr.grand { background: #172e38; }
.td-info .td-tr.grand { background: #172e38; }
.td-tr.due b { color: #e1273d; }

.td-notes { margin: 0; padding-inline-start: 16px; color: #3d525c; font-size: 9.5px; display: grid; gap: 3px; }

/* Signatures and footer */
.td-sign { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding-top: 14px; }
.td-sign > div { display: grid; gap: 3px; font-size: 9.5px; color: #3d525c; }
.td-sign i { display: block; height: 34px; border-bottom: 1px solid #8fa3ab; }
.td-sign small { color: #6f818a; font-size: 9px; }
.td-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; border-top: 1px solid #c9d5da; padding-top: 5px; font-size: 8.5px; color: #6f818a; }

/* Status watermark (draft, paid, cancelled, expired) */
.td-mark { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; pointer-events: none; transform: rotate(-24deg); opacity: .09; color: #172e38; font-weight: 800; line-height: 1; }
.td-mark span:first-child { font-size: 96px; letter-spacing: .1em; }
.td-mark span:last-child { font-size: 64px; }

@media print {
  .a4.a4-doc { padding: 0; }
  .td { min-height: 0; }
  .td-lines th, .td-kv.strong, .td-tr.grand { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4; margin: 12mm; }
}

/* Print formats gallery (revenue/print-formats) */
.pfg-tabs { overflow-x: auto; max-width: 100%; }
.pfg-tabs .seg { flex: none; }
@media (max-width: 760px) { .pfg-tabs + .xw-toolbar .field { min-width: 0 !important; flex: 1 1 100%; } }
