/* ===== مستند عرض السعر (معاينة + طباعة A4) ===== */
#o_print { position: fixed; inset: 0; z-index: 2000; background: #525659; overflow: auto; direction: ltr; }
.p_toolbar { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--o-border); padding: 8px 16px; display: flex; gap: 8px; align-items: center; direction: rtl; }
.p_tip { color: var(--o-muted); font-size: 12.5px; }
.p_doc { padding: 18px 10px 40px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.p_page {
  background: #fff; width: 210mm; max-width: 100%; min-height: 297mm; padding: 14mm 13mm; box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  color: #1f2937; font-size: 10.5pt; line-height: 1.45; display: flex; flex-direction: column; font-family: var(--o-font);
}
.p_items_page { min-height: 0; }
.p_head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; border-bottom: 2.5px solid var(--o-brand); padding-bottom: 9px; margin-bottom: 12px; }
.p_co { display: flex; flex-direction: column; font-size: 9pt; color: #4b5563; }
.p_co b { font-size: 11.5pt; color: #111827; }
.p_co.ar { direction: rtl; text-align: right; }
.p_title { text-align: center; font-size: 19pt; font-weight: 700; letter-spacing: .06em; color: var(--o-brand); line-height: 1.1; }
.p_title small { display: block; font-size: 11pt; letter-spacing: 0; font-weight: 600; }
.p_head.small .p_title { font-size: 13pt; }
.p_head.small .p_title small { font-size: 9pt; }
.p_logo { max-height: 62px; max-width: 170px; object-fit: contain; }
.p_h1 { text-align: center; font-size: 17pt; color: var(--o-brand); letter-spacing: .06em; margin: 0 0 10px; display: flex; justify-content: center; gap: 14px; }
.p_h1 span { letter-spacing: 0; }
.p_tri { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.p_tri th { font-weight: 500; color: #4b5563; padding: 3.5px 8px; width: 30%; white-space: nowrap; font-size: 9.5pt; }
.p_tri th.en { text-align: left; }
.p_tri th.ar { text-align: right; direction: rtl; }
.p_tri td.val { text-align: center; color: #111827; padding: 3.5px 8px; font-variant-numeric: tabular-nums; }
.p_tri tr { border-bottom: 1px solid #e5e7eb; }
.p_info { border: 1px solid #d1d5db; }
.p_info tr:last-child { border-bottom: 0; }
.p_info th { background: #f0f7f8; }
.p_intro { font-size: 8.8pt; color: #4b5563; margin-bottom: 8px; }
.p_intro p { margin: 0 0 4px; text-align: justify; }
.p_h3 { display: flex; justify-content: space-between; font-size: 11pt; color: #fff; background: var(--o-brand); padding: 4px 10px; margin: 4px 0 0; font-weight: 600; }
.p_sum { border: 1px solid #d1d5db; border-top: 0; }
.p_sum tr.strong th, .p_sum tr.strong td { font-weight: 700; color: #111827; background: #f0f7f8; }
.p_sum tr.grand th, .p_sum tr.grand td { font-weight: 700; color: #fff; background: var(--o-brand); font-size: 11.5pt; padding-block: 6px; }
.p_sum tr.grand { border-bottom: 0; }
.p_terms tr.sep th { color: var(--o-brand); font-weight: 700; padding-top: 8px; }
.p_terms tr.sep { border-bottom: 1.5px solid var(--o-brand); }
.p_notes { border: 1px solid #d1d5db; border-radius: 3px; padding: 7px 10px; font-size: 9pt; color: #374151; }
.p_notes h4 { display: flex; justify-content: space-between; font-size: 9.5pt; margin: 0 0 4px; color: var(--o-brand); }
.p_notes p { margin: 0 0 3px; }
.p_notes .extra { white-space: pre-wrap; border-top: 1px dashed #d1d5db; padding-top: 4px; margin-top: 4px; }
.p_sign { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: auto; padding-top: 22px; }
.p_sign > div { border-top: 1px solid #9ca3af; padding-top: 6px; display: flex; flex-direction: column; font-size: 9pt; color: #6b7280; min-height: 70px; }
.p_sign b { color: #111827; font-size: 10.5pt; }
.p_sign i { font-style: normal; }
.p_foot { text-align: center; font-size: 8.5pt; color: #6b7280; border-top: 1px solid #e5e7eb; padding-top: 6px; margin-top: 10px; white-space: pre-wrap; }
.p_mini { width: 100%; border-collapse: collapse; margin-bottom: 9px; border: 1px solid #d1d5db; }
.p_mini td { padding: 4px 8px; border-inline-end: 1px solid #e5e7eb; vertical-align: top; }
.p_mini span { display: block; font-size: 8pt; color: #6b7280; }
.p_mini b { font-size: 9.5pt; color: #111827; font-weight: 600; }
.p_items { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.p_items thead th { background: var(--o-brand); color: #fff; font-weight: 600; padding: 5px 6px; border: 1px solid var(--o-brand); font-size: 9pt; line-height: 1.25; }
.p_items thead th small { display: block; font-weight: 400; font-size: 8pt; opacity: .9; }
.p_items td { border: 1px solid #d1d5db; padding: 5px 7px; vertical-align: middle; }
.p_items .w_sr { width: 28px; }
.p_items .w_pic { width: 112px; }
.p_items .w_unit { width: 46px; }
.p_items .w_qty { width: 46px; }
.p_items .w_price { width: 82px; }
.p_items td.c { text-align: center; }
.p_items td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.p_items tbody tr { break-inside: avoid; page-break-inside: avoid; }
.p_pic img { max-width: 100px; max-height: 96px; object-fit: contain; display: block; margin: 0 auto; }
.p_desc b { color: #111827; }
.p_desc .d { color: #4b5563; font-size: 8.8pt; white-space: pre-wrap; margin-top: 2px; }
.p_desc em { color: #9a6700; font-size: 8.5pt; }
.p_code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 7.8pt; color: #6b7280; margin-inline-start: 7px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.p_kids { margin: 3px 0 0; padding: 0; list-style: none; font-size: 8.8pt; color: #374151; }
.p_kids li { padding: 1px 0; display: flex; gap: 4px; }
.p_kids li::before { content: '•'; color: var(--o-brand); }
.p_kids .q { color: #6b7280; white-space: nowrap; }
.p_kids .kp { margin-inline-start: auto; color: #6b7280; font-variant-numeric: tabular-nums; padding-inline-start: 10px; }
.p_section td { background: #e4f0f1; font-weight: 700; color: #111827; }
.p_note td { font-style: italic; color: #4b5563; white-space: pre-wrap; }
.p_optional td { color: #6b7280; }
.p_optional td.n:last-child { text-decoration: line-through; }
.p_items tfoot td { font-weight: 600; text-align: right; background: #f7fbfb; }
.p_items tfoot tr.acc td { background: var(--o-brand); color: #fff; border-color: var(--o-brand); font-size: 10.5pt; }

/* أمر العمل للمصنع (بدون أسعار) */
.p_wo { direction: rtl; }
.p_wo .p_co.ar { text-align: right; }
.p_wo .p_co.en { direction: ltr; text-align: left; }
.p_wo .p_title { letter-spacing: 0; }
.p_wo .p_title small { letter-spacing: .08em; }
.p_wo_grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #d1d5db; border-bottom: 0; border-inline-end: 0; margin-bottom: 10px; }
.p_wo_grid > div { padding: 5px 9px; border-inline-end: 1px solid #d1d5db; border-bottom: 1px solid #d1d5db; min-width: 0; }
.p_wo_grid span { display: block; font-size: 8pt; color: #6b7280; }
.p_wo_grid b { font-size: 10pt; color: #111827; font-weight: 600; unicode-bidi: plaintext; display: block; overflow-wrap: anywhere; }
.p_wo_grid .big { background: #f0f7f8; }
.p_wo_grid .big b { font-size: 13.5pt; color: var(--o-brand); font-weight: 700; }
.p_wo_note { border: 1px solid #d1d5db; border-inline-start: 4px solid var(--o-brand); border-radius: 3px; padding: 7px 10px; margin-bottom: 10px; font-size: 9.5pt; white-space: pre-wrap; }
.p_wo_items thead th { text-align: center; }
.p_wo_items .w_q { width: 58px; }
.p_wo_items .w_done { width: 34px; }
.p_wo_items .w_src { width: 74px; }
.p_wo_items .w_sup { width: 96px; }
.p_wo_group td { background: var(--o-brand) !important; color: #fff !important; font-size: 10.5pt; padding-block: 6px; }
.p_wo_group td span { float: inline-end; font-weight: 400; font-size: 9pt; opacity: .92; }
.p_desc .ctx { font-size: 8.3pt; color: var(--o-brand); margin-top: 1px; }
.p_wo_items td.p_src { font-size: 8.8pt; font-weight: 600; color: #374151; }
.p_wo_items .w_note { width: 120px; }
.p_wo_items td.q { text-align: center; font-weight: 700; font-size: 11.5pt; color: #111827; font-variant-numeric: tabular-nums; }
.p_wo_items tfoot td { text-align: start; }
.p_wo_items tfoot td.q { color: #fff; }
.p_box { display: inline-block; width: 13px; height: 13px; border: 1.3px solid #6b7280; border-radius: 2px; vertical-align: middle; }
.p_wo_bundle td { background: #f0f7f8; font-weight: 700; color: #111827; }
.p_wo_bundle td span { font-weight: 500; color: var(--o-brand); }
.p_wo_bundle .d { font-weight: 400; color: #4b5563; font-size: 8.8pt; }
.p_wo_kid .p_desc { padding-inline-start: 20px; }
.p_wo_kid .p_desc .d { color: #6b7280; }
.p_wo_foot { font-size: 8.5pt; color: #6b7280; margin: 8px 0 0; }
.p_wo_sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: auto; padding-top: 28px; }
.p_wo_sign > div { border-top: 1px solid #9ca3af; padding-top: 6px; display: flex; flex-direction: column; font-size: 9pt; color: #6b7280; min-height: 62px; }
.p_wo_sign b { color: #111827; font-size: 10.5pt; }
.p_wo_sign i { font-style: normal; font-size: 8.5pt; }

/* مستندات المشتريات: محضر مقارنة العروض وبيان تكلفة الوصول */
.p_cmp .w_num { width: 70px; }
.p_cmp .w_sup { width: 84px; }
.p_cmp .w_q { width: 54px; }
.p_cmp td.c { white-space: nowrap; }
.p_cmp tbody td:last-child, .p_cmp tfoot td.c { white-space: normal; }
.p_cmp thead th small { font-size: 7.5pt; }
.p_cmp td.n { text-align: center; }
.p_cmp td.pick { background: #e3f4e9; font-weight: 700; color: #111827; }
.p_cmp tfoot td { font-weight: 500; font-size: 9pt; }
.p_cmp tfoot td.c { text-align: center; }
.p_cmp tfoot td small { font-weight: 400; color: #6b7280; }
.p_cmp tfoot tr.acc td { font-weight: 700; }
.p_kv { width: 64%; margin-top: 10px; border-collapse: collapse; font-size: 9.5pt; }
.p_kv td { border: 1px solid #d1d5db; padding: 4px 8px; }
.p_kv td.n { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; width: 140px; }
.p_kv tr.sum td { background: #f0f7f8; font-weight: 600; }
.p_kv tr.grand td { background: var(--o-brand); color: #fff; font-weight: 700; border-color: var(--o-brand); }

@media print {
  @page { size: A4; margin: 11mm 11mm 12mm; }
  html, body { height: auto !important; background: #fff !important; }
  body.o_printing > *:not(#o_print) { display: none !important; }
  #o_print { position: static; background: #fff; overflow: visible; }
  .p_toolbar { display: none; }
  .p_doc { padding: 0; gap: 0; display: block; }
  .p_page { width: auto; min-height: 0; padding: 0; box-shadow: none; display: block; }
  .p_page:first-child { display: flex; min-height: 272mm; break-after: page; page-break-after: always; }
  .p_page.p_wo { display: block; min-height: 0; break-after: auto; page-break-after: auto; }
  .p_wo .p_wo_sign { break-inside: avoid; page-break-inside: avoid; }
  .p_items thead { display: table-header-group; }
  .p_items tfoot { display: table-row-group; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* تقارير (js/reports.js): ورقة A4 بجداول مبسّطة */
.p_rep_head { display: flex; align-items: baseline; gap: 12px; border-bottom: 2.5px solid var(--o-brand); padding-bottom: 8px; margin-bottom: 10px; }
.p_rep_head b { font-size: 10pt; color: #4b5563; }
.p_rep_head h2 { flex: 1; text-align: center; font-size: 14pt; margin: 0; color: #111827; }
.p_rep_head span { font-size: 9pt; color: #4b5563; }
.p_rep_sub { font-size: 9.5pt; color: #4b5563; margin: 0 0 8px; }
.p_rep_h { font-size: 11pt; margin: 14px 0 5px; color: #111827; }
.p_rep_table { width: 100%; border-collapse: collapse; font-size: 8.8pt; }
.p_rep_table th, .p_rep_table td { border: 1px solid #cbd0d6; padding: 3px 5px; text-align: start; vertical-align: middle; }
.p_rep_table th { background: #f1f3f5; font-weight: 600; }
.p_rep_table .o_rep_sum td { font-weight: 700; background: #f8f9fa; }
.p_rep_table .o_margin_bad { color: #b42318 !important; font-weight: 600; }
.p_rep .o_todo_empty { border: 0; font-size: 9pt; color: #6b7280; }
.p_rep_box { border: 1px solid #cbd0d6; border-radius: 3px; padding: 6px 8px; min-height: 34px; font-size: 9.5pt; margin: 0 0 6px; white-space: pre-wrap; }
.p_rep_box.tall { min-height: 150px; }
.p_rep .p_wo_grid { margin-bottom: 10px; }
.p_qc_pics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.p_qc_pics figure { margin: 0; break-inside: avoid; }
.p_qc_pics img { width: 100%; height: 150px; object-fit: cover; border: 1px solid #cbd0d6; border-radius: 3px; display: block; }
.p_qc_pics figcaption { font-size: 8pt; color: #4b5563; padding-top: 2px; }
