/* =============================================================================
 * print.css — the printed report.
 *
 * Loaded with media="print", so nothing here can affect the screen. The goal is
 * a document that looks like it came out of an accounts department: a
 * letterhead, a ruled title block, boxed tables with repeating headers, a
 * basis of preparation, a signature block, and a footer that repeats on every
 * page.
 * ========================================================================== */

@page {
  size: A4 portrait;
  /* One-page fit starts with the margins: 46 mm of white edge on the old sheet
   * was a third of the printable height before a single row was drawn. */
  margin: 10mm 8mm 12mm;
  @bottom-center {
    content: "Page " counter(page) " of " counter(pages);
    font: 7pt "Tajawal", "Segoe UI", sans-serif;
    color: #444;
  }
}

/* The app is hidden entirely; only #print-doc is on the page. */
.nav, .topbar, .page-actions, .filters, .table-bar, .icon-btn,
#modals, #toasts, .tabs, .no-print, .card-actions, .balance-bar,
.sr-list, .loader, .empty-box, .row-acts, .toast {
  display: none !important;
}

html, body {
  background: #fff !important;
  color: #000 !important;
  font-size: 8pt;
  line-height: 1.2;
  margin: 0; padding: 0;
}

/* The live app must not take up a single millimetre of the sheet. */
#app, .shell, .main, #view { display: none !important; }

#print-doc { display: block !important; }

/* ------------------------------------------------------- document layout */

.pr-doc {
  font-family: "Tajawal", "Cairo", "Segoe UI", system-ui, sans-serif;
  color: #000;
  font-size: 8pt;
  line-height: 1.2;
}

.pr-doc, .pr-doc * { box-sizing: border-box; }

.pr-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6mm;
  padding-block-end: 1.5mm;
}
.pr-head-l { min-width: 0; }
.print-logo { max-inline-size: 95px; max-block-size: 28px; margin-block-end: 1mm; }
.pr-co  { font-size: 12pt; font-weight: 800; letter-spacing: -.01em; line-height: 1.05; }
.pr-pr  { font-size: 8.5pt; font-weight: 700; color: #333; margin-block-start: .5mm; }
.pr-se  { font-size: 7pt; color: #555; margin-block-start: .8mm; display: flex; gap: 4mm; flex-wrap: wrap; }
.pr-head-r { text-align: end; white-space: nowrap; }
.pr-doc-t { }
.pr-head-r .pr-doc { font-size: 7pt; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #555; }
.pr-ref { font-size: 7.5pt; font-weight: 700; font-variant-numeric: tabular-nums; margin-block-start: .5mm; }

.pr-rule { height: 0; border-block-start: 1.8pt solid #000; margin-block-end: 2mm; }

.pr-title-block { margin-block-end: 2mm; }
.pr-title { font-size: 11pt; font-weight: 800; margin: 0; line-height: 1.15; }
.pr-sub   { font-size: 8pt; color: #333; margin-block-start: .8mm; }
.pr-stamp {
  display: flex; flex-wrap: wrap; gap: 1mm 5mm;
  font-size: 7pt; color: #444; margin-block-start: 1.5mm;
  padding-block-start: 1mm; border-block-start: .5pt solid #bbb;
}

/* -------------------------------------------------------------- meta grid */

.pr-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(40mm, 1fr));
  gap: .6mm 4mm;
  padding: 1.2mm 2mm;
  border: .6pt solid #999;
  background: #f7f7f7;
  margin-block-end: 2.5mm;
  break-inside: avoid;
}
.pr-meta-item { display: flex; flex-direction: column; }
.pr-meta-k { font-size: 7pt; text-transform: uppercase; letter-spacing: .04em; color: #555; }
.pr-meta-v { font-size: 8pt; font-weight: 700; }
.pr-meta-warn {
  background: #fff2cc !important;
  border-inline-start: 2pt solid #9a6700;
  padding-inline: 1mm;
}
.pr-meta-warn .pr-meta-v { color: #7a1f00; }

/* --------------------------------------------------------------- summary */

.pr-sec { margin-block-end: 3.2mm; break-inside: auto; }
.pr-sec-page { break-before: page; }
.pr-sec-h {
  font-size: 8.7pt; font-weight: 800; margin: 0 0 1.2mm;
  padding-block-end: .7mm; border-block-end: .8pt solid #000;
  break-after: avoid;
}
.pr-note { font-size: 7.2pt; color: #444; margin: 0 0 1.2mm; }
.pr-text { font-size: 8pt; margin: 0 0 1mm; }

.pr-sum { border: .6pt solid #bbb; border-block-start: .9pt solid #000; }
.pr-sum-row {
  display: flex; align-items: baseline; gap: 2mm;
  padding: .6mm 1.8mm;
  border-block-end: .4pt solid #ddd;
  break-inside: avoid;
}
.pr-sum-row:last-child { border-block-end: 0; }
.pr-sum-k { flex: 1 1 auto; font-size: 7.5pt; color: #333; }
.pr-sum-v { font-size: 8pt; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-sum-s { font-size: 6.5pt; color: #777; min-width: 18mm; text-align: end; }

/* ---------------------------------------------------------------- tables */

.pr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7.6pt;
  /* One grid for every table: widths are declared on <col> by the report, so
   * the same money column starts at the same x-position from page to page. */
  table-layout: fixed;
  break-inside: avoid;
}
.pr-table th, .pr-table td {
  border-block-end: .35pt solid #c8c8c8;
  border-inline: 0;
  padding: .75mm 1mm;
  text-align: start;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.15;
}
.pr-table thead { display: table-header-group; }   /* repeats on every page */
.pr-table tfoot { display: table-footer-group; }
.pr-table th {
  background: #ededed !important;
  font-weight: 800;
  font-size: 7.1pt;
  text-transform: uppercase;
  letter-spacing: .02em;
  border-block-end: .9pt solid #000;
}
.pr-table tbody tr.odd { background: #fafafa; }
.pr-table tbody tr { break-inside: avoid; }
.pr-table td.ta-end, .pr-table th.ta-end {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pr-table td.ta-center, .pr-table th.ta-center { text-align: center; }
.pr-table td.num, .pr-table th.num { font-variant-numeric: tabular-nums; }
.pr-table tfoot td {
  background: #ededed !important;
  font-weight: 800;
  border-block-start: .9pt solid #000;
  border-block-end: .9pt solid #000;
  font-variant-numeric: tabular-nums;
}
.pr-table .pr-empty { text-align: center; color: #666; font-style: italic; padding: 2mm; }

/* A status pill or a bar has no meaning on paper — flatten it to plain text
   inside a report, but keep the emphasis. */
.pr-doc .pill, .pr-doc .tag, .pr-doc .bar, .pr-doc .minibar {
  border: .4pt solid #999 !important;
  background: none !important;
  color: #000 !important;
  box-shadow: none !important;
  padding: 0 1mm;
  font-size: 7.5pt;
  border-radius: 0;
}
.pr-doc .bar-fill { background: #999 !important; }
.pr-doc .bar { display: none; }          /* a progress bar is decoration */
.pr-doc .badge { border: .4pt solid #999; background: none; color: #000; }

/* ------------------------------------------------- basis and signatures */

.pr-basis { break-inside: avoid; }
.pr-notes { margin: 0; padding-inline-start: 4mm; }
.pr-notes li { font-size: 7.3pt; color: #333; margin-block-end: .7mm; }

.pr-sign {
  display: flex; justify-content: space-between; gap: 6mm;
  margin-block-start: 6mm;
  break-inside: avoid;
}
.pr-sign-cell {
  flex: 1 1 0; width: 33.33%; text-align: center;
  display: flex; flex-direction: column; align-items: stretch;
}
.pr-sign-role { font-size: 7.5pt; font-weight: 700; margin-block-end: 1mm; }
.pr-sign-line { border-block-start: .6pt solid #000; height: 7mm; }
.pr-sign-name {
  font-size: 11pt; font-weight: 700; font-style: italic;
  min-height: 4mm; margin-block-start: 1mm;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pr-sign-name-empty { visibility: hidden; }
.pr-sign-date { font-size: 7pt; color: #444; white-space: nowrap; }

.pr-foot-note {
  margin-block-start: 3mm; padding-block-start: 1mm;
  border-block-start: .5pt solid #ccc;
  font-size: 6.5pt; color: #666; font-style: italic;
}

/* ---------------------------------------------------- running footer ----
   position:fixed repeats on every printed page in Chrome, Edge, Firefox and
   Safari, which is the only reliable way to get a running footer out of a
   browser without a PDF library. */

.pr-runfoot {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  display: flex;
  justify-content: space-between;
  gap: 6mm;
  padding-block-start: 1.5mm;
  border-block-start: .6pt solid #000;
  font-size: 7pt;
  color: #444;
}
.pr-runfoot-c { font-weight: 700; color: #000; }

/* ------------------------------- content carried over from the live screen */

.pr-body { margin-block-start: 2mm; }
.pr-body .card {
  border: .5pt solid #bbb !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  margin-block-end: 2mm;
  break-inside: auto;
}
.pr-body .card-head { background: #ededed !important; padding: .8mm 1.2mm; border-block-end: .5pt solid #bbb; }
.pr-body .card-head h3 { font-size: 8pt; margin: 0; }
.pr-body .card-body { padding: 1.2mm; }
.pr-body .kpis { grid-template-columns: repeat(4, 1fr) !important; gap: 1mm !important; }
.pr-body .kpi { border: .5pt solid #bbb !important; box-shadow: none !important; border-radius: 0 !important; padding: 1mm; break-inside: avoid; }
.pr-body .kpi-value { font-size: 9pt !important; }
.pr-body .kpi-clickable { cursor: default; }
.pr-body .kpi-clickable[aria-pressed="true"] { background: #f0f0f0 !important; }
.pr-body .summary-scope { font-size: 7pt; color: #444; }
.pr-body .table-scroll { max-height: none !important; overflow: visible !important; }
.pr-body table.data { font-size: 7.2pt; width: 100%; }
.pr-body table.data th, .pr-body table.data td { padding: .5mm .8mm; white-space: normal; line-height: 1.12; }
.pr-body table.data th { background: #e8e8e8 !important; color: #000 !important; position: static; border-block-end: .8pt solid #000; }
.pr-body table.data tfoot td { position: static; background: #e8e8e8 !important; font-weight: 800; }
.pr-body table.data thead { display: table-header-group; }
.pr-body table.data tfoot { display: table-footer-group; }
.pr-body table.data tbody tr { break-inside: avoid; }
.pr-body .chart-box { height: 38mm; break-inside: avoid; }
.pr-pie { break-inside: avoid; }
.pr-body .notice { border: .5pt solid #999; background: none !important; color: #000 !important; font-size: 7pt; }
.pr-body .statlist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1mm; }
.pr-body .stat { border: .4pt solid #bbb; padding: .8mm; }
.pr-body .stat .k { font-size: 6pt; text-transform: uppercase; color: #666; }
.pr-body .stat .v { font-size: 7.5pt; font-weight: 700; }
.pr-body .stat .d { font-size: 6pt; color: #777; }
.pr-body .tabs { display: none !important; }
.pr-body .grid-2, .pr-body .grid-2-1, .pr-body .grid-3 { display: block !important; }
.pr-body .rem-pos, .pr-body .pc-low { color: #000 !important; font-weight: 700; }
.pr-body .rem-zero, .pr-body .pc-ok { color: #444 !important; }
.pr-body .muted { color: #666 !important; }
.pr-body a { color: #000 !important; text-decoration: none !important; }
.pr-body a[href]::after { content: "" !important; }

/* ------------------------------------------------------------ RTL report */

.pr-doc[dir="rtl"] { text-align: right; }
.pr-doc[dir="rtl"] .pr-head { flex-direction: row; }
.pr-doc[dir="rtl"] .pr-head-r { text-align: start; }
.pr-doc[dir="rtl"] .pr-sum-v, .pr-doc[dir="rtl"] .pr-sum-s { text-align: start; }
.pr-doc[dir="rtl"] .pr-sign-line { border-block-start: .6pt solid #000; }

/* A4 is narrower than a wide table of money columns, so let a long report
   breathe rather than clipping it. Landscape is opt-in per report. */
@media print {
  .pr-doc.landscape { width: 100%; }
}
