/* ==========================================================================
   وثيقة التقرير الرسمي — عرض الشاشة والطباعة (v2.12)
   الورقة بيضاء دائماً (حتى في الوضع الداكن) لأنها وثيقة تُطبع.
   ========================================================================== */
#printableReportDocument {
  --rp-ink: #0f172a; --rp-mute: #64748b; --rp-line: #cbd5e1; --rp-brand: #0b4f7a; --rp-soft: #f1f5f9;
  background: #fff; color: var(--rp-ink); border: 1px solid var(--rp-line); border-top: 4px solid var(--rp-brand);
  border-radius: 14px; padding: 2rem 2.25rem; line-height: 1.6;
}
#printableReportDocument * { color: inherit; }

/* الترويسة بصيغة الكتاب الرسمي: العربية يميناً، الإنكليزية يساراً، الشعار في الوسط */
.rpt-head { display: grid; grid-template-columns: minmax(0, 1fr) 118px minmax(0, 1fr); align-items: center; gap: .9rem; padding-bottom: .9rem; border-bottom: 3px double var(--rp-brand); }
.rpt-ar, .rpt-en { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.rpt-ar { text-align: right; direction: rtl; align-items: flex-start; }
.rpt-en { text-align: left; direction: ltr; align-items: flex-start; font-family: "Segoe UI", Arial, Helvetica, sans-serif; }
.rpt-country { font-size: .92rem; font-weight: 800; letter-spacing: .01em; padding-bottom: .3rem; margin-bottom: .1rem; border-bottom: 1.5px solid var(--rp-brand); }
.rpt-org { font-size: 1.02rem; font-weight: 800; color: var(--rp-brand) !important; line-height: 1.45; text-wrap: balance; }
.rpt-en .rpt-org { font-size: .95rem; }
.rpt-sub { font-size: .8rem; color: var(--rp-mute) !important; line-height: 1.5; text-wrap: balance; }
.rpt-name { font-size: .88rem; font-weight: 700; color: var(--rp-ink) !important; line-height: 1.5; text-wrap: balance; }
.rpt-name:empty { display: none; }
.rpt-head-c { text-align: center; }
.rpt-head-c img { max-height: 96px; width: auto; max-width: 118px; object-fit: contain; }
.rpt-refline { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .1rem 0; font-size: .85rem; color: var(--rp-mute) !important; }
.rpt-refline b { color: var(--rp-ink) !important; font-weight: 700; direction: ltr; unicode-bidi: isolate; }

/* العنوان */
.rpt-titlebar { text-align: center; padding: 1.1rem 0 .8rem; }
.rpt-kicker { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em; color: var(--rp-brand) !important; border: 1px solid var(--rp-brand); border-radius: 999px; padding: .1rem .8rem; margin-bottom: .45rem; }
.rpt-titlebar h2 { font-size: 1.35rem; font-weight: 800; margin: 0 0 .25rem; line-height: 1.4; }
.rpt-meta { font-size: .82rem; color: var(--rp-mute) !important; }
.rpt-meta bdi { unicode-bidi: isolate; }

/* مؤشرات */
.rpt-stats { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: .25rem 0 1rem; }
.rpt-stat { min-width: 105px; text-align: center; padding: .4rem .9rem; background: var(--rp-soft); border: 1px solid var(--rp-line); border-radius: 10px; }
.rpt-stat b { display: block; font-size: 1.15rem; font-weight: 800; color: var(--rp-brand) !important; line-height: 1.2; }
.rpt-stat span { font-size: .72rem; color: var(--rp-mute) !important; }
.rpt-months { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; font-size: .75rem; color: var(--rp-mute) !important; }
.rpt-months span { background: #fff; border: 1px solid var(--rp-line); border-radius: 6px; padding: .05rem .5rem; }
.rpt-months b { color: var(--rp-ink) !important; }

/* الجدول */
.rpt-table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.rpt-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: .88rem; }
.rpt-table col.c-n { width: 4%; } .rpt-table col.c-dt { width: 18%; } .rpt-table col.c-ti { width: 30%; } .rpt-table col.c-gu { width: 26%; } .rpt-table col.c-lo { width: 23%; }
.rpt-table th { background: var(--rp-brand); color: #fff !important; font-weight: 700; font-size: .82rem; padding: .55rem .6rem; border: 1px solid var(--rp-brand); text-align: center; }
.rpt-table td { padding: .5rem .6rem; border: 1px solid var(--rp-line); vertical-align: middle; text-align: right; overflow-wrap: anywhere; }
.rpt-table td.c-center { text-align: center; }
.rpt-table tbody tr:nth-child(even) td { background: #f8fafc; }
.rpt-t { font-weight: 700; }
.rpt-st { font-style: normal; font-weight: 600; color: #b91c1c !important; font-size: .78rem; }
.rpt-note { font-size: .76rem; color: var(--rp-mute) !important; margin-top: .1rem; line-height: 1.5; }
.rpt-time { font-size: .78rem; color: var(--rp-mute) !important; }
.rpt-empty { text-align: center !important; padding: 1.6rem 1rem !important; color: var(--rp-mute) !important; font-weight: 600; }
.rpt-empty i { margin-inline-end: .35rem; }

/* التوقيعات */
.rpt-sign { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 1rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1.5px solid var(--rp-line); text-align: center; break-inside: avoid; page-break-inside: avoid; }
.rpt-sign-role { font-weight: 800; font-size: .92rem; }
.rpt-sign-note { font-size: .8rem; color: var(--rp-mute) !important; }
.rpt-sign-name { color: var(--rp-brand) !important; font-weight: 700; font-size: .9rem; }
.rpt-sign-line { margin: 2.2rem auto 0; width: 70%; border-top: 1px solid #475569; }
.rpt-foot-note { margin-top: 1rem; text-align: center; font-size: .7rem; color: var(--rp-mute) !important; }

[data-bs-theme="dark"] #printableReportDocument { background: #fff; color: var(--rp-ink); }

@media screen and (max-width: 575.98px) {
  #printableReportDocument { padding: 1.1rem 1rem; }
  .rpt-head { grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); gap: .5rem; }
  .rpt-country { font-size: .74rem; } .rpt-org, .rpt-en .rpt-org { font-size: .74rem; } .rpt-sub { font-size: .64rem; } .rpt-name { font-size: .7rem; }
  .rpt-head-c img { max-height: 52px; max-width: 64px; }
  .rpt-sign { grid-template-columns: 1fr; }
  .rpt-titlebar h2 { font-size: 1.1rem; }
}

/* ===================== الطباعة =====================
   الطباعة تتم على نسخة معزولة (#printRoot) تُنشأ لحظة الطباعة، فتتوزع الصفحات
   طبيعياً دون اقتصاص، ويتكرر رأس الجدول في كل صفحة. */
@page report { size: A4 landscape; margin: 0; }
@media print {
  body.printing-report-only { background: #fff !important; height: auto !important; overflow: visible !important; }
  html:has(body.printing-report-only) { height: auto !important; }
  body.printing-report-only > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block !important; page: report; width: 100%; margin: 0; padding: 0; }
  #printRoot #printableReportDocument { border: 0 !important; border-radius: 0 !important; padding: 0 !important; box-shadow: none !important; font-size: 10pt; line-height: 1.5; }
  #printRoot .rpt-head { padding-bottom: 6px; grid-template-columns: minmax(0, 1fr) 32mm minmax(0, 1fr) !important; gap: 5mm; }
  #printRoot .rpt-country { font-size: 11pt; } #printRoot .rpt-org { font-size: 12.5pt; } #printRoot .rpt-en .rpt-org { font-size: 11pt; }
  #printRoot .rpt-sub { font-size: 9pt; } #printRoot .rpt-name { font-size: 10pt; }
  #printRoot .rpt-head-c img { max-height: 26mm; max-width: 32mm; }
  #printRoot .rpt-refline { font-size: 9.5pt; padding-top: 6px; }
  #printRoot .rpt-titlebar { padding: 10px 0 6px; } #printRoot .rpt-titlebar h2 { font-size: 15pt; } #printRoot .rpt-meta { font-size: 9pt; } #printRoot .rpt-kicker { font-size: 8pt; }
  #printRoot .rpt-stat { min-width: 26mm; padding: 4px 10px; } #printRoot .rpt-stat b { font-size: 12pt; } #printRoot .rpt-stat span { font-size: 8pt; }
  #printRoot .rpt-months { font-size: 8pt; }
  #printRoot .rpt-table-wrap { overflow: visible !important; }
  #printRoot .rpt-table { min-width: 0; table-layout: fixed; font-size: 9.5pt; }
  #printRoot .rpt-table th { font-size: 9pt; padding: 5px 6px; }
  #printRoot .rpt-table td { padding: 5px 7px; }
  #printRoot .rpt-note { font-size: 8pt; } #printRoot .rpt-time { font-size: 8.5pt; }
  #printRoot .rpt-table thead { display: table-header-group; }
  #printRoot .rpt-table tr { break-inside: avoid; page-break-inside: avoid; }
  #printRoot .rpt-sign { margin-top: 14px; }
  #printRoot .rpt-sign-line { margin-top: 12mm; }
  #printRoot .rpt-foot-note { font-size: 8pt; }
  #printRoot * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.rpt-day td { background: #eef2f7 !important; font-weight: 700; font-size: .85rem; padding: .3rem .6rem !important; color: #1f2d3d !important; }
.rpt-cancelled td { color: #6b7280 !important; text-decoration: line-through; }
.rpt-cancelled td .rpt-st { text-decoration: none; display: inline-block; }
.rpt-audit { margin-top: .8rem; text-align: center; font-size: .72rem; color: #374151 !important; border-top: 1px dashed #9ca3af; padding-top: .4rem; }
@media print {
  #printRoot .rpt-day td { background: #eef2f7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 9pt; }
  #printRoot .rpt-day { break-after: avoid; }
  #printRoot .rpt-audit { font-size: 8pt; }
}
.rpt-time { white-space: nowrap; }

/* خط الكشوف: Cairo — واضح وأكبر حجماً */
.official-report-card, #printRoot #printableReportDocument { font-family: "Cairo", "Tajawal", "Segoe UI", Tahoma, sans-serif !important; }
.official-report-card .rpt-en, #printRoot .rpt-en { font-family: "Segoe UI", Arial, sans-serif !important; }
.rpt-table { font-size: 1rem; } .rpt-table th { font-size: .95rem; }
.rpt-t { font-weight: 600; } .rpt-note { font-size: .85rem; } .rpt-time { font-size: .88rem; }
.rpt-titlebar h2 { font-size: 1.55rem; } .rpt-org { font-size: 1.12rem; } .rpt-name { font-size: .98rem; } .rpt-sub { font-size: .88rem; }
.rpt-meta { font-size: .92rem; } .rpt-stat span { font-size: .82rem; } .rpt-stat b { font-size: 1.3rem; }
.rpt-day td { font-size: .95rem; } .rpt-audit { font-size: .8rem; } .rpt-foot-note { font-size: .8rem; }
@media print {
  #printRoot .rpt-table { font-size: 10.5pt; } #printRoot .rpt-table th { font-size: 10pt; }
  #printRoot .rpt-note { font-size: 9pt; } #printRoot .rpt-time { font-size: 9.5pt; }
  #printRoot .rpt-titlebar h2 { font-size: 17pt; } #printRoot .rpt-org { font-size: 13.5pt; } #printRoot .rpt-name { font-size: 11pt; } #printRoot .rpt-sub { font-size: 10pt; }
  #printRoot .rpt-meta { font-size: 10pt; } #printRoot .rpt-stat span { font-size: 9pt; } #printRoot .rpt-stat b { font-size: 13.5pt; }
  #printRoot .rpt-day td { font-size: 10pt; } #printRoot .rpt-audit { font-size: 8.5pt; } #printRoot .rpt-foot-note { font-size: 8.5pt; }
  #printRoot .rpt-sign-role { font-size: 11pt; } #printRoot .rpt-sign-note, #printRoot .rpt-sign-name { font-size: 10pt; }
}

/* الطباعة: الهوامش مضمّنة في المحتوى فلا تتأثر بإعداد «الهوامش» في المتصفح */
@media screen { .rpt-pfoot { display: none; } }
@media print {
  #printRoot .prt-wrap { width: 100%; border-collapse: collapse; table-layout: fixed; }
  #printRoot .prt-wrap > thead > tr > td, #printRoot .prt-wrap > tfoot > tr > td { padding: 0; border: 0; }
  #printRoot .prt-sp-t { height: 9mm; } #printRoot .prt-sp-b { height: 17mm; }
  #printRoot .prt-body { padding: 0 12mm !important; border: 0; vertical-align: top; }
  #printRoot .rpt-pfoot { position: fixed; left: 12mm; right: 12mm; bottom: 5mm; text-align: center; font-size: 8pt; color: #374151; line-height: 1.5; border-top: 1px solid #9ca3af; padding-top: 2mm; background: #fff; }
  #printRoot .rpt-pfoot div:last-child { color: #6b7280; font-size: 7.5pt; }
  #printRoot .rpt-sign { break-inside: avoid; page-break-inside: avoid; }
  #printRoot .rpt-table tr { break-inside: avoid; page-break-inside: avoid; }
  #printRoot .rpt-head-c img { max-height: 20mm !important; max-width: 26mm !important; }
  #printRoot .rpt-head { grid-template-columns: minmax(0, 1fr) 28mm minmax(0, 1fr) !important; }
  #printRoot .rpt-titlebar { padding: 6px 0 4px !important; }
}
