/* برگه رسمی، سربرگ و چاپ (A4) — سربرگ و پانویس یکسان همه اسناد و برگه‌های چاپی صندوق.
   سبک‌های عمومی سامانه در app.css است؛ این پرونده فقط سربرگ رسمی، برگه سند و قواعد چاپ را دارد. */

/* ---------- سربرگ رسمی (letterhead) ---------- */
/* «بسمه‌تعالی» با خط نستعلیق (Noto Nastaliq Urdu، پروانه OFL؛ فقط همین حروف) */
@font-face { font-family: "TamNastaliq"; src: url("../fonts/nastaliq-bism.ttf") format("truetype"); font-display: swap; }
.lh { display: flex; flex-direction: column; gap: 0; border-bottom: 3px double #1f5f8b; padding-bottom: 0;
  margin-bottom: 10px; color: #1c2430; }
.lh-bism { text-align: center; font-family: "TamNastaliq", "Vazirmatn", serif; font-size: 20px; line-height: 2; color: #0f3a57;
  margin-bottom: 14px; }
.lh-row { display: flex; align-items: center; gap: 14px; }
.lh-brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.lh-logo { height: 76px; width: auto; max-width: 130px; object-fit: contain; flex: none; }
.lh-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* نام صندوق: یک خط، کنار (چپِ) نشان و هم‌تراز با میانه آن */
.lh-brand { align-self: center; }
.lh-fund { font-size: 15px; line-height: 1.5; color: #0f3a57; white-space: nowrap; align-self: center; }
/* مشخصات ثبتی: ریزتر ولی خوانا، وسط‌چین و مماس با خط زیر سربرگ */
.lh-ids { list-style: none; margin: 8px 0 0; padding: 0 0 1px; display: flex; flex-wrap: wrap; justify-content: center; gap: 0 14px;
  font-size: 8.5px; line-height: 1.6; color: #566374; }
.lh-ids li span { color: #8a95a3; }
.lh-statement { margin-top: 14px; font-size: 10px; color: #566374; text-align: center; }
.lh-meta { display: grid; grid-template-columns: auto auto; gap: 1px 10px; margin: 0; font-size: 12.5px; flex: none; }
.lh-meta dt { color: #566374; }
.lh-meta dd { margin: 0; font-weight: 500; }
.lh-meta .lh-blank { color: #8a95a3; font-weight: 400; }
.lh-qr { flex: none; width: 84px; }
.lh-qr svg { display: block; width: 84px; height: 84px; }
.lh-title { text-align: center; font-size: 19px; margin: 10px 0 14px; color: #0f3a57; }
.lh-foot { border-top: 1px solid #c9d2dc; margin-top: 6px; padding-top: 6px; font-size: 11px; color: #566374;
  line-height: 1.8; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.lh-foot strong { color: #1c2430; font-weight: 500; }
.lh-print-only { display: none !important; }
@media (max-width: 600px) {
  .lh-row { flex-wrap: wrap; }
  .lh-fund { white-space: normal; }
  .lh-meta { flex-basis: 100%; }
}

/* ---------- برگه سند صادره ---------- */
.doc-frame { margin: 0 auto; max-width: 820px; }
.doc-print-frame { width: 100%; border-collapse: collapse; margin: 0; background: transparent; }
.doc-print-frame > thead > tr > td, .doc-print-frame > tfoot > tr > td, .doc-print-frame > tbody > tr > td { padding: 0; border: 0; }
.doc-runhead, .doc-runfoot { display: none; }
.doc-frame .doc-sheet { margin: 12px 0; }
.doc-frame .doc-sheet::before { display: none; }
.doc-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; font-size: 130px; font-weight: 700; color: rgba(192, 57, 43, .09); transform: rotate(-28deg);
  z-index: 0; user-select: none; }
.doc-sheet > * { position: relative; z-index: 1; }
.doc-sheet > .doc-watermark { position: absolute; z-index: 0; }
.doc-preview-note { text-align: center; color: #9a3412; background: #fff7ed; border: 1px dashed #f0b27a; border-radius: 4px;
  padding: 4px 10px; font-size: 13px; }
.doc-placeholder { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px;
  border: 1px dashed #b8c2cc; color: #8a95a3; font-size: 11px; text-align: center; }
.doc-qr svg { display: block; width: 96px; height: 96px; }

/* محل امضای طرفین */
.doc-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0 14px;
  break-inside: avoid; page-break-inside: avoid; }
.doc-party { border: 1px solid #d6dde5; border-radius: 4px; padding: 8px 12px; break-inside: avoid; }
.doc-party-title { font-size: 14px; margin: 0 0 6px; padding-bottom: 4px; border-bottom: 1px solid #e3e8ee; }
.doc-party-role { display: inline-block; background: #eaf2f8; color: #1f5f8b; border-radius: 3px; padding: 0 6px;
  font-size: 12px; margin-inline-end: 4px; }
.doc-party-note { font-size: 12px; color: #566374; margin: 0 0 6px; }
.doc-party-slots { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.doc-party .doc-sign { min-width: 170px; flex: 1 1 170px; border-top: 0; padding-top: 0; gap: 2px; }
.doc-sign-label { font-size: 12px; color: #566374; }
.doc-sign-line { display: block; height: 46px; border-bottom: 1px solid #8a95a3; margin: 2px 0 2px; }
.doc-sign-place { font-size: 11px; color: #8a95a3; }
.doc-party .doc-sign-blank { min-height: 0; border-bottom: 0; }
.doc-seal-box { flex: 0 0 auto !important; min-width: 0 !important; align-items: center; }
.doc-seal { width: 104px; height: 104px; object-fit: contain; display: block; margin: 2px 0; }
.doc-sign-done .doc-specimen { max-height: 58px; }

/* نوار چاپ و پیوند نسخه رسمی */
.official-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 auto 4px; max-width: 820px; }
.official-hint { flex-basis: 100%; margin: 0; font-size: 12px; }
.official-link { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.official-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 820px; margin: 0 auto 8px; }
.official-picker select { max-width: 360px; }

/* ردیف جمع گزارش‌ها (report_totals) */
tr.totals th, tr.subtotal th { font-weight: 600; white-space: nowrap; }
tr.subtotal th { background: #f7f9fb; border-top: 1px solid #d6dde5; font-weight: 500; }
tr.totals th { border-top: 2px solid #b8c2cc; }
.method-box { border-inline-start: 4px solid #1f5f8b; background: #f5f9fc; }
.method-box ol { padding-inline-start: 20px; line-height: 2; }
.method-box .formula { font-weight: 600; color: #0f3a57; }

/* ---------- چاپ (A4) ---------- */
@page { size: A4; margin: 11mm 10mm 13mm 10mm;
  @bottom-left { content: "صفحه " counter(page) " از " counter(pages); font-size: 9pt; color: #566374; } }
@media print {
  html, body { background: #fff !important; }
  body { font-size: 11.5pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, nav, .tabs, .footer, .no-print, .messages, details.page-help, .page-help, .official-bar, .official-link,
  .official-picker, .skip-link, .install-app { display: none !important; }
  main, .container { margin: 0 !important; padding: 0 !important; max-width: none !important; width: auto !important; }
  .card { box-shadow: none !important; border: 0 !important; padding: 0 !important; margin: 0 0 10px !important; }
  .lh-print-only { display: flex !important; }
  h1.lh-print-only { display: block !important; }
  .lh-foot.lh-print-only { display: grid !important; }
  .card { overflow: visible !important; }
  main table { display: table !important; width: 100% !important; min-width: 0 !important; max-width: none !important;
    table-layout: auto; font-size: 8pt; }
  main table .badge { padding: 0 4px; font-size: 7.5pt; }
  main form:not(.keep-print) { display: none !important; }
  main table th, main table td { padding: 3px 4px !important; white-space: normal !important; }
  table { page-break-inside: auto; }
  tr, td, th { page-break-inside: avoid; break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  a { color: inherit; text-decoration: none; }

  /* برگه سند: سربرگ و پانویس کوتاه در هر صفحه تکرار می‌شود (thead/tfoot جدول قاب) */
  .doc-frame { max-width: none; }
  .doc-frame .doc-sheet { border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; overflow: visible; }
  /* ویرایش ۵۰: عنوان تکراری بالای هر صفحه و نشانی تکراری پایین هر صفحه حذف شد؛ سربرگ کامل یک بار در آغاز و نشانی
     یک بار در پایان سند می‌آید و شماره صفحه از @page. سطر خالی سربرگ قاب فقط حامل واترمارک پیش‌نمایش است. */
  .doc-runhead { display: block; height: 0; margin: 0; padding: 0; border: 0; overflow: visible; }
  .doc-runhead > * { display: none !important; }
  .doc-runfoot { display: none !important; }
  .doc-body { font-size: 11.5pt; }
  .doc-body .doc-article { break-after: avoid; page-break-after: avoid; }
  .doc-foot { break-inside: avoid; page-break-inside: avoid; }
  /* واترمارک «نمونه / پیش‌نمایش» در هر صفحه: از سربرگ تکرارشونده جدول قاب آویخته می‌شود */
  .doc-sheet > .doc-watermark { display: none; }
  .doc-is-preview .doc-runhead { position: relative; overflow: visible; }
  .doc-is-preview .doc-runhead::after { content: attr(data-mark); position: absolute; top: 330px; left: 0; right: 0;
    text-align: center; font-size: 120px; font-weight: 700; color: rgba(192, 57, 43, .13); transform: rotate(-28deg);
    pointer-events: none; z-index: 5; }
  .doc-preview-note { border-style: solid; }
}

/* نشان استاندارد یکسان (ویرایش ۴۶): لوگوی کامل همراه نام صندوق؛ QR فقط در پایین برگه */
.lh-logo-full { height: 84px; width: auto; max-width: 260px; object-fit: contain; flex: none; }
/* پانویس: نشانی و تماس صندوق دقیقاً وسط، QR در کنار (ویرایش ۴۹) */
.lh-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; text-align: center; }
.lh-foot .lh-contact { grid-column: 2; text-align: center; }
.lh-foot .lh-qr { grid-column: 3; justify-self: end; margin-inline-start: 0; }
.lh-foot, .doc-foot { break-inside: avoid; page-break-inside: avoid; }
.doc-runhead img { height: 22px; }
.print-logo-full { height: 56px; width: auto; }
@media (max-width: 600px) { .lh-logo-full { height: 64px; } }

/* ---------- سربرگ رسمی استاندارد (ویرایش ۴۸) ----------
   ۱. «بسمه‌تعالی» با خط نستعلیق (تصویر برداری‌شده از قلم، تا در هر مرورگر، گوشی و چاپ یکسان باشد) بالای وسط؛
   ۲. سه ستون هم‌عرض: نشان صندوق (راست)، عنوان برگه دقیقاً وسط، شماره و تاریخ و پیوست (چپ)؛
   ۳. مشخصات ثبتی ریز زیر سربرگ و خط دوگانه جداکننده. */
.lh-bism { font-size: 0; line-height: 0; margin: 0 0 6px; text-align: center; }
.lh-bism img { height: 30px; width: auto; display: inline-block; }
.lh-row { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); align-items: center;
  gap: 12px; }
.lh-brand { justify-self: start; flex: none; }
.lh-brand .lh-logo-full { max-width: 100%; height: auto; max-height: 84px; }
.lh-center { justify-self: stretch; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lh-head-title { font-size: 19px; font-weight: 700; line-height: 1.6; color: #0f3a57; text-wrap: balance; }
.lh-meta { justify-self: end; grid-template-columns: auto auto; font-size: 12px; gap: 2px 8px; }
.lh-meta dt { white-space: nowrap; }
.lh-meta dd { white-space: normal; max-width: 15em; overflow-wrap: anywhere; }
.lh-head-sub { font-size: 12.5px; color: #3a4757; line-height: 1.6; text-wrap: balance; }
.lh-title { display: none; }
@media screen and (max-width: 600px) {
  /* گوشی: نشان، عنوان و مشخصات زیر هم و وسط‌چین */
  .lh-row { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 8px; }
  .lh-brand, .lh-meta { justify-self: center; }
  .lh-center { justify-self: stretch; width: 100%; }
  .lh-head-title { font-size: 17px; }
  .lh-meta { flex-basis: auto; }
  .lh-meta dd { max-width: 60vw; }
}
@media print {
  .lh-bism img { height: 26px; }
  .lh-head-title { font-size: 15pt; }
  .lh-head-sub { font-size: 10pt; }
  .lh-meta { font-size: 9.5pt; }
  .lh-print-only.lh { display: flex !important; }
  .lh-row { display: grid !important; }
  /* عنوان صفحه در سربرگ چاپی آمده است؛ عنوان تکراری بالای صفحه در چاپ پنهان می‌شود */
  body:has(.lh.lh-print-only .lh-head-title) main#main h1:not(.keep-print) { display: none !important; }
}
/* قاب برگه سند هم‌عرض صفحه می‌ماند (در گوشی بیرون نمی‌زند) */
.doc-print-frame { table-layout: fixed; }
main table.doc-print-frame { display: table !important; overflow: visible !important; max-width: 100%; }
