/* وثائق المالية (الفاتورة، فاتورة الدفعة المسبقة، الفاتورة التصحيحية، عرض السعر) بهوية المها v3 «الدفتر والنافذة».
   نسخة من نموذج الفاتورة المعتمد (AL_MAHA_Identity_v2/06_Office/Word/AM_Invoice_AR_Example.docx، 22/10/2026)
   بقياساته نفسها بالمليمتر: A4، الهوامش 14 / 24 / 29 / 20، عمود النص من 20 إلى 186 مم، الشعار الأفقي الملوّن 46 مم
   أعلى اليمين، الحافة الرأسية (خيط أحمر 0.3pt عند 192.8 مم + الشعار النصي عموديًا)، وشريط البيانات أسفل الصفحة عند 272 مم.
   الألوان والخطوط هنا وحدها (هوية المها، لا متغيرات المنصة)، والوثيقة لا تتبع الوضع الداكن: ورقة بيضاء دائمًا.
   كل شيء تحت .inv-doc فلا يمسّ أنماط المنصة. اللاتيني مسموح داخل .inv-doc وحده (قرار المالك 14/11/2026). */

@font-face { font-family: 'AM Cairo'; font-weight: 400; font-display: block; src: url(../fonts/am-cairo-400.woff2) format('woff2'); }
@font-face { font-family: 'AM Cairo'; font-weight: 500; font-display: block; src: url(../fonts/am-cairo-500.woff2) format('woff2'); }
@font-face { font-family: 'AM Cairo'; font-weight: 600; font-display: block; src: url(../fonts/am-cairo-600.woff2) format('woff2'); }
@font-face { font-family: 'AM Cairo'; font-weight: 700; font-display: block; src: url(../fonts/am-cairo-700.woff2) format('woff2'); }
@font-face { font-family: 'AM Cairo'; font-weight: 900; font-display: block; src: url(../fonts/am-cairo-900.woff2) format('woff2'); }
@font-face { font-family: 'AM Montserrat'; font-weight: 100 900; font-display: block; src: url(../fonts/am-montserrat-var.woff2) format('woff2'); }

.inv-doc {
  /* ألوان هوية المها v3 (amdocx.COL) */
  --inv-ink: #222222;
  --inv-muted: #554C47;
  --inv-rule: #DAD5D0;
  --inv-red: #EB070D;
  --inv-crimson: #B1091B;
  --inv-bordeaux: #8E1028;
  --inv-ivory: #F8F2EC;
  --inv-paper: #FFFFFF;
  --inv-shadow: rgba(30, 26, 24, .16);
  --inv-ar: 'AM Cairo', 'App Sans', sans-serif;
  --inv-lat: 'AM Montserrat', 'AM Cairo', sans-serif;
  --inv-hair: .3pt;
  page: inv;
  color: var(--inv-ink);
  font-family: var(--inv-ar);
  font-size: 10.5pt;
  line-height: 1.45;
  font-kerning: normal;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-scheme: light;
}
.inv-doc *, .inv-doc *::before, .inv-doc *::after { box-sizing: border-box; }
.inv-doc p { margin: 0; }
.inv-doc table { border-collapse: collapse; border-spacing: 0; }
.inv-doc td, .inv-doc th { padding: 0; vertical-align: top; text-align: start; font-weight: inherit; }
.inv-lat { font-family: var(--inv-lat); }
.inv-muted { color: var(--inv-muted); }

/* الورقة على الشاشة: صفحة A4 بظل خفيف؛ تطول إن طال المحتوى، والحافة والشريط يلحقان أسفلها */
.inv-sheet {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: var(--inv-paper);
  box-shadow: 0 2mm 8mm var(--inv-shadow);
  overflow: hidden;
}

/* أثاث الصفحة: الحافة الرأسية وشريط البيانات (يتكرر في كل صفحة عند الطباعة) */
.inv-furniture { position: absolute; inset: 0; pointer-events: none; }
.inv-spine-rule { position: absolute; left: 192.8mm; top: 104mm; bottom: 25mm; width: var(--inv-hair); background: var(--inv-red); }
.inv-spine {
  position: absolute; height: 4mm; line-height: 4mm; text-align: center; white-space: nowrap;
  color: var(--inv-muted); font-size: 9pt; font-weight: 600; transform: rotate(-90deg);
}
/* الصناديق الأصلية: x 196.2 مم بعرض 4 مم؛ العربي من 122 إلى 172 مم، والإنجليزي من 206 إلى 272 مم (من أسفل الصفحة: 125 و25 مم) */
.inv-spine-ar { width: 50mm; left: 173.2mm; bottom: 148mm; font-family: var(--inv-ar); direction: rtl; }
.inv-spine-en { width: 66mm; left: 165.2mm; bottom: 56mm; font-family: var(--inv-lat); letter-spacing: .54pt; direction: ltr; }

.inv-strip { position: absolute; left: 20mm; width: 166mm; bottom: 10.6mm; height: 14.4mm; font-size: 9pt; line-height: 12pt; }
.inv-strip::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: var(--inv-hair); background: var(--inv-red); }
.inv-strip-addr { position: absolute; right: 0; top: 1.4mm; width: 90mm; color: var(--inv-ink); text-align: right; direction: rtl; }
.inv-strip-contacts { position: absolute; left: 0; top: 1.4mm; width: 74mm; color: var(--inv-ink); text-align: left; direction: ltr; font-family: var(--inv-lat); }
.inv-strip-contacts b { color: var(--inv-bordeaux); font-weight: 600; margin-inline-end: 1.6mm; }
.inv-strip-contacts .inv-gap { display: inline-block; width: 5mm; }
.inv-strip-contacts .inv-web { font-weight: 600; }
/* السطر القانوني يلتف على سطرين إن طال (لا يُقصّ أبدًا: البيانات القانونية إلزامية) */
.inv-strip-legal { position: absolute; left: 0; right: 0; top: 10mm; color: var(--inv-muted); text-align: right; direction: rtl; white-space: pre-line; line-height: 10.5pt; }
/* سطر قانوني طويل (أكثر من 150 حرفًا أو بفواصل أسطر، والحد في «بيانات الشركة» 220 حرفًا وسطران): خط أصغر يبقى داخل الورقة */
.inv-doc .inv-strip-legal.inv-legal-long { font-size: 7.5pt; line-height: 9pt; }
/* اللاتيني الكبير العريض (حروف كبيرة) يأخذ أسطرًا أكثر: درجة أصغر وتباعد أضيق فيبقى في ثلاثة أسطر داخل الورقة */
.inv-doc.inv-en .inv-strip-legal.inv-legal-long { font-size: 7pt; line-height: 8.4pt; letter-spacing: -.1pt; }
.inv-en .inv-strip-addr { text-align: left; direction: ltr; font-family: var(--inv-lat); font-size: 8.5pt; }
.inv-en .inv-strip-legal { text-align: left; direction: ltr; font-family: var(--inv-lat); font-size: 8.5pt; }

/* تدفق المحتوى: جدول بفاصل علوي 14 مم وسفلي 29 مم يتكرران في كل صفحة مطبوعة */
.inv-flow { width: 100%; }
.inv-flow > thead > tr > td > div { height: 14mm; }
.inv-flow > tfoot > tr > td > div { height: 29mm; }
/* الهامشان صريحان (لا عرض ثابت): في اتجاه RTL يُهمَل margin-left حين تتعارض القيود فيلتصق المحتوى بالحافة اليمنى */
.inv-body { margin: 0 24mm 0 20mm; position: relative; }

/* 1. الشعار والعنوان: الشعار أعلى اليمين (16 مم من أعلى الورقة)، والعنوان مقابله في اللغتين */
.inv-head { position: relative; height: 21.5mm; }
.inv-logo { position: absolute; right: 0; top: 2mm; width: 46mm; height: auto; display: block; }
.inv-title { position: absolute; left: 0; top: -1.2mm; text-align: left; direction: rtl; }
.inv-title h1 { margin: 0; font-family: var(--inv-ar); font-weight: 900; font-size: 40pt; line-height: 47pt; color: var(--inv-ink); white-space: nowrap; }
.inv-title.inv-long h1 { font-size: 30pt; line-height: 40pt; }
.inv-kicker { font-family: var(--inv-lat); font-weight: 600; font-size: 9pt; line-height: 13pt; letter-spacing: 3pt; text-transform: uppercase; color: var(--inv-muted); direction: ltr; text-align: left; }
.inv-en .inv-title { direction: ltr; }
.inv-en .inv-kicker { font-family: var(--inv-ar); font-size: 10pt; letter-spacing: 0; text-transform: none; direction: rtl; text-align: left; }
.inv-en .inv-title h1 { font-family: var(--inv-lat); font-weight: 700; font-size: 34pt; line-height: 44pt; letter-spacing: -.3pt; }
.inv-en .inv-title.inv-long h1 { font-size: 28pt; line-height: 40pt; }

/* 2. البيانات | الجهة: 86 + 4 + 76 مم */
.inv-meta-row { display: flex; gap: 4mm; margin-top: 3.5mm; align-items: stretch; }
.inv-meta { width: 86mm; flex: none; }
.inv-meta table { width: 100%; }
.inv-meta td { height: 5mm; border-bottom: .5pt solid var(--inv-rule); vertical-align: middle; padding: .35mm 0; }
.inv-meta tr:first-child td { border-top: .25pt solid var(--inv-red); }
.inv-meta td:first-child { width: 28mm; color: var(--inv-muted); font-weight: 600; font-size: 9pt; line-height: 15pt; }
.inv-meta td:last-child { font-size: 10.5pt; line-height: 15pt; }
.inv-meta .inv-lat { font-weight: 600; font-size: 10pt; }
.inv-meta .inv-ref { font-weight: 400; font-size: 9.5pt; }
.inv-meta bdi.inv-lat { white-space: nowrap; } /* رقم مثل AM-Q-2026-001 لا ينكسر عند الشرطة */
.inv-client { width: 76mm; flex: none; background: var(--inv-ivory); padding: 3mm 4.5mm; }
.inv-label { color: var(--inv-muted); font-weight: 600; font-size: 9pt; line-height: 13pt; }
.inv-client .inv-label { margin-bottom: 1mm; }
.inv-client-name { font-weight: 700; font-size: 11.5pt; line-height: 17pt; margin-bottom: .35mm; }
.inv-client-line { font-size: 10pt; line-height: 15.5pt; }

/* عنوان المشروع (عرض السعر) */
.inv-subject { margin-top: 3.5mm; break-after: avoid; }
.inv-subject .inv-label { margin-bottom: .7mm; }
.inv-subject-text { font-weight: 700; font-size: 12.5pt; line-height: 19pt; margin-bottom: 2.8mm; }

/* 3. البنود: 10 + 84 + 20 + 26 + 26 مم، رأس بخيطين من الحبر بلا تعبئة */
.inv-items { width: 166mm; margin-top: 2.8mm; table-layout: fixed; }
.inv-items col.c-n { width: 10mm; } .inv-items col.c-d { width: 84mm; } .inv-items col.c-q { width: 20mm; }
.inv-items col.c-p { width: 26mm; } .inv-items col.c-t { width: 26mm; }
.inv-items th {
  border-top: 1pt solid var(--inv-ink); border-bottom: .5pt solid var(--inv-ink);
  vertical-align: bottom; padding: 1.5mm 1.8mm; font-weight: 700; font-size: 10pt; line-height: 14pt;
}
.inv-items td { padding: 1.3mm 1.8mm; border-bottom: .5pt solid var(--inv-rule); }
.inv-items tr { break-inside: avoid; }
.inv-items .a-c { text-align: center; }
.inv-items .a-e { text-align: end; }
.inv-items .a-s { text-align: start; }
.inv-no { font-family: var(--inv-lat); color: var(--inv-red); font-size: 10pt; line-height: 15pt; font-weight: 500; }
.inv-code { font-family: var(--inv-lat); color: var(--inv-muted); font-size: 8pt; line-height: 12pt; font-weight: 500; white-space: nowrap; }
.inv-items td:first-child { padding-inline: 1mm; }
.inv-doc .inv-num { white-space: nowrap; }
.inv-line-title { font-weight: 700; font-size: 11pt; line-height: 15pt; margin-bottom: .35mm; }
.inv-line-desc { color: var(--inv-muted); font-size: 9pt; line-height: 13pt; }
.inv-qty { font-size: 10.5pt; line-height: 15pt; }
.inv-money { font-size: 10.5pt; line-height: 15pt; white-space: nowrap; unicode-bidi: isolate; direction: ltr; display: inline-block; }
.inv-strong { font-weight: 600; }
.inv-items thead { display: table-header-group; }

/* 4. الملاحظات | المجاميع: 76 + 4 + 86 مم */
.inv-sum-row { display: flex; gap: 4mm; margin-top: 2.1mm; break-inside: avoid; }
.inv-notes { width: 76mm; flex: none; padding-inline-end: 2mm; }
.inv-notes > .inv-label { margin-bottom: 1.4mm; }
.inv-notes ul { list-style: none; margin: 0; padding: 0; }
.inv-notes li { position: relative; padding-inline-start: 4mm; font-size: 9.5pt; line-height: 13.5pt; margin-bottom: 1mm; }
.inv-notes li::before { content: '•'; position: absolute; inset-inline-start: 0; color: var(--inv-red); }
.inv-words-label { margin-top: 2.1mm; margin-bottom: .7mm; }
.inv-words { font-weight: 700; font-size: 10pt; line-height: 15pt; }
.inv-totals { width: 86mm; flex: none; }
.inv-totals table { width: 100%; }
.inv-totals td { height: 6.2mm; padding: 0 2.5mm; vertical-align: middle; border-bottom: .5pt solid var(--inv-rule); font-size: 10pt; line-height: 15pt; }
.inv-totals td:first-child { width: 50mm; }
.inv-totals td:last-child { text-align: end; }
.inv-totals .k-strong td { border-top: 1pt solid var(--inv-ink); font-weight: 700; }
.inv-totals .k-due td { height: 9.2mm; background: var(--inv-crimson); color: var(--inv-paper); border-bottom: 0; font-weight: 700; font-size: 11pt; }
.inv-totals .k-due .inv-money { font-size: 12pt; font-weight: 700; }
.inv-totals .k-neg .inv-money::before { content: '− '; }

/* 5. بيانات السداد | الاعتماد: 92 + 6 + 68 مم */
.inv-bank-row { display: flex; gap: 6mm; margin-top: 4.2mm; break-inside: avoid; }
.inv-bank { width: 92mm; flex: none; }
.inv-bank > .inv-label { margin-bottom: 1mm; }
.inv-bank table { width: 100%; }
.inv-bank td { height: 5mm; vertical-align: middle; border-bottom: .5pt solid var(--inv-rule); font-size: 10pt; line-height: 14pt; padding: .2mm 0; }
.inv-bank td:first-child { width: 20mm; color: var(--inv-muted); font-weight: 600; font-size: 9pt; }
.inv-bank td:first-child.inv-lat { font-weight: 500; }
.inv-bank .inv-lat { font-size: 9pt; }
.inv-bank .inv-acc { font-weight: 500; font-size: 9.5pt; }
.inv-approve { width: 68mm; flex: none; border-inline-start: .5pt solid var(--inv-rule); padding-inline-start: 6mm; }
.inv-approve-by { font-size: 9pt; line-height: 15pt; }
.inv-approve-by span { color: var(--inv-muted); font-weight: 600; }
.inv-approve-by strong { font-weight: 400; font-size: 10pt; }
.inv-sign-space { height: 10.6mm; position: relative; }
.inv-sign-space img { position: absolute; inset-inline-start: 0; bottom: .5mm; max-height: 16mm; max-width: 40mm; }
.inv-signer { border-top: .5pt solid var(--inv-muted); padding-top: 1.4mm; font-weight: 700; font-size: 11pt; line-height: 16pt; }
.inv-signer-title { color: var(--inv-muted); font-size: 9.5pt; line-height: 15pt; }

/* شروط عرض السعر وموافقة الجهة: 81 + 4 + 81 مم — كتلة واحدة لا تنقسم (تنتقل معًا إلى الصفحة التالية إن لم تتسع) */
.inv-quote-tail { break-inside: avoid; }
.inv-terms { margin-top: 5.6mm; break-inside: avoid; }
.inv-terms h2 { margin: 0 0 2.1mm; font-weight: 700; font-size: 16pt; line-height: 24pt; }
.inv-terms ol { list-style: none; margin: 0; padding: 0; }
.inv-terms li { position: relative; padding-inline-start: 9mm; font-size: 10.5pt; line-height: 16pt; margin-bottom: 1.4mm; }
.inv-terms li .inv-no { position: absolute; inset-inline-start: 0; top: 0; line-height: 16pt; }
.inv-accept-row { display: flex; gap: 4mm; margin-top: 5.6mm; break-inside: avoid; }
.inv-accept-row > div { width: 81mm; flex: none; }
.inv-accept-row .inv-approve { border: 0; padding: 0; }
.inv-client-accept { padding-inline-start: 8mm; }
.inv-client-accept .inv-label { margin-bottom: 1mm; }
.inv-fill { border-bottom: .5pt solid var(--inv-rule); padding-top: 1.8mm; color: var(--inv-muted); font-size: 9.5pt; line-height: 16pt; }
.inv-fill-sign { margin-top: 7.8mm; border-top: .5pt solid var(--inv-muted); padding-top: 1.4mm; color: var(--inv-muted); font-size: 9pt; line-height: 13pt; }

/* النسخة الإنجليزية: Montserrat أعرض من Cairo بالمقاس نفسه، فتصغر النصوص درجة لتبقى الوثيقة في صفحتها */
.inv-en { font-family: var(--inv-lat); font-size: 9.5pt; }
.inv-en .inv-label { font-size: 8.5pt; font-weight: 500; }
.inv-en .inv-meta td:first-child { font-size: 8.5pt; font-weight: 500; }
.inv-en .inv-meta td:last-child, .inv-en .inv-meta .inv-lat { font-size: 9.5pt; }
.inv-en .inv-client-name { font-size: 10.5pt; line-height: 15pt; font-weight: 600; }
.inv-en .inv-client-line { font-size: 9pt; line-height: 14pt; }
.inv-en .inv-subject-text { font-size: 11.5pt; font-weight: 600; }
.inv-en .inv-items th { font-size: 9pt; font-weight: 600; }
.inv-en .inv-line-title { font-size: 10pt; line-height: 14pt; font-weight: 600; }
.inv-en .inv-line-desc { font-size: 8.5pt; line-height: 12.5pt; }
.inv-en .inv-qty, .inv-en .inv-money { font-size: 9.5pt; }
.inv-en .inv-notes li { font-size: 9pt; line-height: 13pt; }
.inv-en .inv-words { font-size: 9.5pt; line-height: 14pt; font-weight: 600; }
.inv-en .inv-totals td { font-size: 9.5pt; }
.inv-en .inv-totals .k-due td { font-size: 10.5pt; font-weight: 600; }
.inv-en .inv-totals .k-due .inv-money { font-size: 11pt; }
.inv-en .inv-bank td { font-size: 9pt; }
.inv-en .inv-bank td:first-child { width: 25mm; font-size: 8.5pt; }
.inv-en .inv-approve-by { font-size: 8.5pt; }
.inv-en .inv-approve-by strong { font-size: 9pt; }
.inv-en .inv-signer { font-size: 10.5pt; font-weight: 600; }
.inv-en .inv-signer-title, .inv-en .inv-fill { font-size: 8.5pt; }
.inv-en .inv-terms h2 { font-size: 14pt; font-weight: 600; }
.inv-en .inv-terms li { font-size: 9.5pt; line-height: 14pt; }

/* التنبيهات داخل الوثيقة: المسودة وبيانات الشركة الناقصة */
.inv-draft {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-30deg);
  font-family: var(--inv-ar); font-weight: 900; font-size: 120pt; line-height: 1; color: var(--inv-rule);
  opacity: .4; white-space: nowrap; pointer-events: none; z-index: 0;
}
.inv-en .inv-draft { font-family: var(--inv-lat); font-size: 110pt; letter-spacing: 6pt; }
.inv-body > * { position: relative; z-index: 1; }
.inv-missing { color: var(--inv-muted); font-style: normal; }

/* الطباعة: صفحة مسماة بلا هوامش ولا مربعات هامش المتصفح؛ الأثاث ثابت فيتكرر في كل صفحة */
@page inv {
  size: A4;
  margin: 0;
  @top-left { content: ''; } @top-center { content: ''; } @top-right { content: ''; }
  @bottom-left { content: ''; } @bottom-center { content: ''; } @bottom-right { content: ''; }
}
@media print {
  .inv-sheet { box-shadow: none; margin: 0; min-height: 0; overflow: visible; }
  .inv-furniture { position: fixed; inset: auto; left: 0; top: 0; width: 210mm; height: 297mm; }
  .inv-draft { position: fixed; }
  .inv-sheet + .inv-sheet { break-before: page; }
}
