/* المطبوعات (R1، D-440، D-441): كل القواعد تحت .print كي لا تمس شاشات النظام (المعاينة في شاشة الإعدادات تستعملها أيضاً). */
.print-toolbar { display: flex; gap: 1rem; align-items: center; padding: .75rem 1rem; background: #f3f4f6; border-bottom: 1px solid #ddd; }
.print { --brand: #1f5a85; --logo-h: 70px; --ink: #111; --line: #c9ced6; color: var(--ink); background: #fff; font-family: "Segoe UI", Tahoma, Arial, sans-serif;
         -webkit-print-color-adjust: exact; print-color-adjust: exact; line-height: 1.45; }
.print.size-a4 { width: 186mm; margin: 1rem auto; padding: 8mm; box-shadow: 0 0 0 1px #e5e7eb; }
.print.size-80 { width: 72mm; margin: 1rem auto; padding: 2mm; box-shadow: 0 0 0 1px #e5e7eb; }
.print.fs-small { font-size: 11px; }
.print.fs-normal { font-size: 12.5px; }
.print.fs-large { font-size: 14px; }

/* الرأس */
.print .p-head { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; margin-bottom: 10px; }
.print .p-logo { height: var(--logo-h); max-width: 40%; object-fit: contain; }
.print .p-company { flex: 1; }
.print .p-name { font-size: 1.45em; font-weight: 700; }
.print .p-name-en { font-size: .95em; opacity: .8; }
.print .p-line { font-size: .9em; }
.print .p-doc { text-align: end; min-width: 30%; }
.print .p-title { font-size: 1.2em; font-weight: 700; color: var(--brand); }
.print.logo-start .p-logo { order: 0; }
.print.logo-end .p-logo { order: 2; }
.print.logo-end .p-doc { order: -1; text-align: start; }
.print.logo-center .p-head { flex-wrap: wrap; justify-content: center; text-align: center; }
.print.logo-center .p-logo { order: -2; flex-basis: 100%; max-width: none; }
.print.logo-center .p-company { order: -1; flex-basis: 100%; }
.print.logo-center .p-doc { flex-basis: 100%; text-align: center; }

/* القالب الكلاسيكي: خط سفلي بلون الشركة واسم في الوسط */
.print.tpl-classic .p-head { border-bottom: 2px solid var(--brand); }
.print.tpl-classic .p-company { text-align: center; }
.print.tpl-classic thead th { border-bottom: 2px solid var(--brand); }
/* الحديث: شريط ملوّن بالرأس وعناوين الجدول */
.print.tpl-modern .p-head { background: var(--brand); color: #fff; padding: 10px 12px; border-radius: 6px; }
.print.tpl-modern .p-head .p-title { color: #fff; }
.print.tpl-modern .p-logo { background: #fff; border-radius: 4px; padding: 3px; }
.print.tpl-modern thead th { background: var(--brand); color: #fff; }
/* المبسّط: بلا ألوان، خطوط رفيعة */
.print.tpl-simple .p-head { border-bottom: 1px solid var(--ink); }
.print.tpl-simple .p-title { color: var(--ink); }
.print.tpl-simple thead th { border-bottom: 1px solid var(--ink); }

/* علامة الحالة (مسودة، ملغاة...) */
.print .p-stamp { border: 2px dashed #b42318; color: #b42318; text-align: center; font-weight: 700; padding: 4px; margin-bottom: 8px; }

/* كتل المعلومات */
.print .p-info { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 16px; margin-bottom: 10px; }
.print .p-info div span { color: #555; }
.print.size-80 .p-info { grid-template-columns: 1fr; }

/* الجدول */
.print table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.print th, .print td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.print th { font-weight: 700; }
.print td.n, .print th.n { text-align: end; white-space: nowrap; direction: ltr; }
.print .p-totals { margin-inline-start: auto; width: 45%; }
.print .p-totals td { border: 0; padding: 2px 6px; }
.print .p-totals tr.grand td { font-weight: 700; font-size: 1.15em; border-top: 2px solid var(--brand); }
.print.tpl-simple .p-totals tr.grand td { border-top-color: var(--ink); }
.print .p-notes { margin: 6px 0; }
.print .p-sign { display: flex; justify-content: space-between; margin-top: 28px; }
.print .p-sign div { border-top: 1px solid var(--ink); padding-top: 4px; min-width: 35%; text-align: center; }
.print .p-foot { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--line); font-size: .85em; text-align: center; white-space: pre-line; }

/* الحراري 80 مم: رأس عمودي في الوسط، وجدول مختصر */
.print.size-80 .p-head { flex-direction: column; text-align: center; gap: 4px; background: none !important; color: var(--ink) !important; padding: 0 0 4px; border-radius: 0; border-bottom: 1px dashed var(--ink); }
.print.size-80 .p-head .p-title { color: var(--ink) !important; }
.print.size-80 .p-logo { order: 0 !important; height: calc(var(--logo-h) * .6); max-width: 60%; padding: 0; }
.print.size-80 .p-company, .print.size-80 .p-doc { order: 0 !important; text-align: center !important; flex-basis: auto; }
.print.size-80 thead th { background: none !important; color: var(--ink) !important; border-bottom: 1px dashed var(--ink); }
.print.size-80 th, .print.size-80 td { padding: 2px 1px; }
.print.size-80 .wide-only { display: none; }
.print.size-80 .p-totals { width: 100%; }
.print.size-80 .p-sign { display: none; }
.print .thermal-only { display: none; }
.print.size-80 .thermal-only { display: block; }
.print .p-line-sub { font-size: .85em; color: #444; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff !important; }
    .print.size-a4, .print.size-80 { margin: 0; box-shadow: none; padding: 0; width: auto; }
    .print tr, .print .p-totals { page-break-inside: avoid; }
}
/* R2: كشوف الحساب */
.print .p-statement td { font-size: .95em; }
.print .p-statement tr.p-opening td { font-weight: 700; background: #f5f6f8; }
.print td.nowrap { white-space: nowrap; }
.print thead { display: table-header-group; }   /* تكرار عناوين الجدول في كل صفحة */

/* D-462: عمودا رمز المادة ووصفها منفصلان */
.print td.pcode, .print th.pcode { white-space: nowrap; padding-inline-end: 1.2em; }
