/* ==========================================================================
   سِدرة · print primitives
   .sheet-a4  portrait A4 (12mm margins): extract certificate, official forms
   .slide     1280x720 page: visit decks, monthly reports (mirrors the NCVC PowerPoint template)
   Print views render at #/print/<module>/<...> inside .print-root (no app chrome).
   ========================================================================== */

@page { margin: 0; }
@page a4 { size: A4 portrait; margin: 12mm; }
@page slide { size: 1280px 720px; margin: 0; }

.sheet-a4, .slide {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color: var(--c-ink, #2B2B2B);
  font-family: var(--font, "IBM Plex Sans Arabic", "Geeza Pro", Tahoma, sans-serif);
}

/* ------------------------------------------------------------------ A4 sheet */
.sheet-a4 {
  page: a4;
  position: relative;
  width: 210mm;
  min-height: 297mm;
  padding: 12mm;
  background: #fff;
  font-size: 12px;
  line-height: 1.55;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .12);
  break-after: page;
  page-break-after: always;
}
.sheet-a4:last-child { break-after: auto; page-break-after: auto; }
.sheet-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 2px solid var(--c-green, #119853);
}
.sheet-header .sheet-logo, .sheet-logo { width: 190px; height: auto; }
.sheet-org { font-size: 11px; line-height: 1.6; color: #444; }
.sheet-org strong { display: block; font-size: 12.5px; color: var(--c-forest, #2C5F2D); }
.sheet-title { text-align: center; font-size: 17px; font-weight: 700; color: var(--c-forest, #2C5F2D); margin: 6px 0 2px; }
.sheet-subtitle { text-align: center; font-size: 12px; color: #555; margin-bottom: 8px; }
.sheet-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid #9A9A9A; margin: 8px 0; }
.sheet-meta > div { padding: 4px 8px; border-inline-start: 1px solid #C9C9C9; border-bottom: 1px solid #C9C9C9; min-width: 0; }
.sheet-meta dt, .sheet-meta .k { font-size: 10px; color: #666; margin: 0; }
.sheet-meta dd, .sheet-meta .v { margin: 0; font-weight: 700; font-size: 11.5px; }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin: 6px 0; }
.sheet-table th, .sheet-table td { border: 1px solid #8C8C8C; padding: 3px 5px; text-align: center; vertical-align: middle; }
.sheet-table th { background: #E6F0DC; font-weight: 700; color: #1E3F1F; }
.sheet-table td.t-start, .sheet-table th.t-start { text-align: start; }
.sheet-table td.num, .sheet-table td.t-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-table tr.is-total td { background: #F1F6EA; font-weight: 700; }
.sheet-table tr.is-grand td { background: #DDEBD0; font-weight: 700; font-size: 11.5px; }
.sheet-box { border: 1px solid #8C8C8C; padding: 6px 8px; margin: 6px 0; }
.sheet-note { font-size: 10.5px; color: #444; line-height: 1.7; }
.sheet-sign { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.sheet-sign.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet-sign.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sign-block { border: 1px solid #9A9A9A; padding: 6px 8px 8px; min-height: 92px; display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; break-inside: avoid; }
.sign-role { font-weight: 700; color: var(--c-forest, #2C5F2D); }
.sign-name { font-weight: 600; }
.sign-line { margin-top: auto; border-top: 1px dotted #777; padding-top: 3px; color: #666; font-size: 10px; }
.sheet-footer {
  position: absolute; inset-inline: 12mm; bottom: 6mm;
  display: flex; justify-content: space-between; font-size: 9.5px; color: #777;
}
.sheet-footer .ltr, .slide-footer, .slide-social { direction: ltr; unicode-bidi: isolate; }

/* ------------------------------------------------------------------ slides */
.slide {
  page: slide;
  position: relative;
  width: 1280px;
  height: 720px;
  overflow: hidden;
  background: #fff;
  font-size: 20px;
  line-height: 1.55;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .14);
  break-after: page;
  page-break-after: always;
  break-inside: avoid;
  flex: none;
}
.slide:last-child { break-after: auto; page-break-after: auto; }
.slide-cream { background: var(--c-cream, #FBFBF3); }
.slide-tint { background: var(--c-tint, #EAF3E4); }

/* header: title on the right, NCVC logo top-left (as in the template) */
.slide-header {
  position: absolute; top: 0; inset-inline: 0; height: 118px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 26px 56px 0;
}
.slide-header::after {
  content: ""; flex: none; width: 236px; height: 74px;
  background: url("/assets/ncvc-logo.png") no-repeat left center / contain;
}
.slide-header:has(.slide-logo)::after { display: none; }
.slide-logo { width: 236px; height: auto; flex: none; }

/* Operator logo (الجهة المشغلة: مؤسسة مصادر الإنشاء للمقاولات) on the side opposite the NCVC logo:
   far right of the slide header, far left of the A4 sheet header. The official «مستخلص وشهادة إنجاز»
   form has its own header and keeps the NCVC logo only. */
.slide-header { justify-content: flex-start; }
.slide-header::before {
  content: ""; flex: none; width: 78px; height: 64px;
  background: url("/assets/operator-logo.png") no-repeat right center / contain;
}
.slide-header::after, .slide-header .slide-logo { margin-inline-start: auto; }
.sheet-header .sheet-org { margin-inline-end: auto; }
.sheet-header::after {
  content: ""; flex: none; width: 64px; height: 52px;
  background: url("/assets/operator-logo.png") no-repeat left center / contain;
}
.slide-heading { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.slide-kicker { font-size: 16px; font-weight: 600; color: var(--c-green, #119853); }
.slide-title { font-size: 36px; font-weight: 700; color: var(--c-forest, #2C5F2D); line-height: 1.25; }
.slide-title::after { content: ""; display: block; width: 72px; height: 4px; border-radius: 2px; background: var(--c-primary, #76BC21); margin-top: 10px; }
.slide-title.no-rule::after { display: none; }

.slide-body {
  position: absolute; top: 136px; bottom: 76px; inset-inline: 56px;
  display: flex; flex-direction: column; gap: 18px; min-height: 0;
}
.slide-body.is-full { top: 40px; }

/* footer: '@ncvcksa | ncvc.gov.sa' bottom-left with the thin diagonal lines */
.slide-footer {
  position: absolute; bottom: 24px; left: 56px;
  font-size: 15px; font-weight: 700; color: var(--c-teal, #035859); letter-spacing: .2px;
}
.slide-footer:empty::before { content: "@ncvcksa | ncvc.gov.sa"; }
.slide::after {
  content: ""; position: absolute; left: 250px; bottom: -6px; width: 150px; height: 90px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='90' viewBox='0 0 150 90'%3E%3Cg stroke='%2376BC21' stroke-width='1.3' fill='none' stroke-linecap='round'%3E%3Cpath d='M4 88 L118 6'/%3E%3Cpath d='M44 88 L146 16' stroke-opacity='.55'/%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
}
.slide.no-motif::after, .slide-cover::after, .slide-end::after { display: none; }
.slide-num { position: absolute; bottom: 24px; right: 56px; font-size: 14px; color: #888; font-variant-numeric: tabular-nums; }
.slide-meta { position: absolute; bottom: 24px; right: 56px; font-size: 14px; color: #777; }

/* cover: the hero asset is the template cover (photo panel, logo and footer included) */
/* cover: the operator logo sits top-left, opposite the NCVC logo that is part of the template image */
.slide-cover {
  background:
    url("/assets/operator-logo.png") no-repeat left 56px top 14px / auto 72px,
    #fff url("/assets/hero-jazan.jpg") no-repeat center / cover;
}
.slide-cover-box {
  position: absolute; top: 212px; right: 80px; width: 600px;
  padding: 30px 34px 28px; border-radius: 22px;
  background: rgba(16, 70, 44, .74);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff;
}
.slide-cover-kicker { font-size: 18px; font-weight: 600; color: #CDEBAA; }
.slide-cover-title { font-size: 44px; font-weight: 700; line-height: 1.25; margin-top: 6px; }
.slide-cover-sub { font-size: 21px; margin-top: 10px; color: rgba(255, 255, 255, .92); line-height: 1.6; }
.slide-cover-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 18px; font-size: 17px; color: rgba(255, 255, 255, .9); }
.slide-cover-meta span { display: inline-flex; align-items: center; gap: 8px; }
.slide-cover-meta span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-primary, #76BC21); }

/* closing slide (template «شكرًا لكم») */
.slide-end { background: #fff url("/assets/hero-mountains.jpg") no-repeat center / cover; }

/* section divider: green */
.slide-section {
  background: linear-gradient(135deg, #119853 0%, #1E7A43 55%, #2C5F2D 100%);
  color: #fff;
}
.slide-section::before {
  content: ""; position: absolute; left: -40px; bottom: -40px; width: 520px; height: 380px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='380' viewBox='0 0 520 380'%3E%3Cg stroke='%23BAD9A1' stroke-width='1.6' fill='none' stroke-linecap='round'%3E%3Cpath d='M20 370 L430 10'/%3E%3Cpath d='M130 370 L510 40' stroke-opacity='.5'/%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
}
.slide-section::after { display: none; }
.slide-section .slide-footer { color: rgba(255, 255, 255, .9); }
.slide-section-inner { position: absolute; top: 50%; right: 96px; left: 360px; transform: translateY(-50%); display: flex; flex-direction: column; gap: 14px; }
.slide-section-num { font-size: 96px; font-weight: 700; line-height: 1; color: rgba(255, 255, 255, .28); font-variant-numeric: tabular-nums; }
.slide-section-title { font-size: 54px; font-weight: 700; line-height: 1.2; }
.slide-section-sub { font-size: 22px; color: rgba(255, 255, 255, .88); line-height: 1.6; }
.slide-section-emblem {
  position: absolute; top: 40px; left: 56px; width: 84px; height: 84px; border-radius: 50%;
  background: #fff url("/assets/ncvc-emblem.png") no-repeat center / 76%;
}

/* content helpers */
.slide-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; min-height: 0; flex: 1 1 auto; }
.slide-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; min-height: 0; }
.slide-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; min-height: 0; }
.slide-card { background: var(--c-cream, #FBFBF3); border: 1px solid #E4E6D8; border-radius: 16px; padding: 18px 22px; min-width: 0; }
.slide-card.is-tint { background: var(--c-tint, #EAF3E4); border-color: #D6E8C8; }
.slide-card-title { font-size: 20px; font-weight: 700; color: var(--c-forest, #2C5F2D); margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.slide-card-title::before { content: ""; width: 5px; height: 20px; border-radius: 3px; background: var(--c-primary, #76BC21); flex: none; }
.slide-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.slide-stat { background: #fff; border: 1px solid #E4E6D8; border-radius: 16px; padding: 16px 20px; border-top: 4px solid var(--c-green, #119853); }
.slide-stat-value { font-size: 40px; font-weight: 700; line-height: 1.15; color: var(--c-ink, #2B2B2B); font-variant-numeric: tabular-nums; }
.slide-stat-label { font-size: 16px; color: #666; margin-top: 4px; }
.slide-stat.is-teal { border-top-color: var(--c-teal, #035859); }
.slide-stat.is-gold { border-top-color: var(--c-gold, #9C7A32); }
.slide-stat.is-orange { border-top-color: var(--c-orange, #F15922); }
.slide-stat.is-primary { border-top-color: var(--c-primary, #76BC21); }
.slide-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 20px; }
.slide-list li { position: relative; padding-inline-start: 26px; line-height: 1.6; }
.slide-list li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .62em; width: 10px; height: 10px; border-radius: 3px; background: var(--c-primary, #76BC21); transform: rotate(45deg); }
.slide-list.is-numbered { counter-reset: sl; }
.slide-list.is-numbered li { padding-inline-start: 44px; }
.slide-list.is-numbered li::before {
  counter-increment: sl; content: counter(sl); transform: none; top: .15em; width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-green, #119853); color: #fff; font-size: 16px; font-weight: 700; display: grid; place-items: center;
}
.slide-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 17px; border: 1px solid #DCE3D2; border-radius: 14px; overflow: hidden; }
.slide-table th { background: var(--c-green, #119853); color: #fff; font-weight: 600; padding: 10px 14px; text-align: start; }
.slide-table td { padding: 9px 14px; border-top: 1px solid #E6EADF; font-variant-numeric: tabular-nums; }
.slide-table tr:nth-child(even) td { background: #F7F9F2; }
.slide-table td.t-num, .slide-table th.t-num { text-align: center; }
.slide-photos { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); flex: 1 1 auto; min-height: 0; }
.slide-photos.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.slide-photos.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.slide-photo { position: relative; margin: 0; border-radius: 16px; overflow: hidden; background: #EEE; min-height: 0; }
.slide-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-photo figcaption { position: absolute; inset-inline: 0; bottom: 0; padding: 22px 14px 10px; color: #fff; font-size: 15px; background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent); }
.slide-photo .photo-kind { font-size: 14px; top: 10px; inset-inline-start: 10px; }
.slide-text { font-size: 20px; line-height: 1.75; color: #3A3A3A; }
.slide-lead { font-size: 23px; line-height: 1.7; color: #333; }
.slide-note { font-size: 15px; color: #666; }
.slide-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; border-radius: 999px; background: var(--c-tint, #EAF3E4); color: var(--c-forest, #2C5F2D); font-size: 15px; font-weight: 600; }
.slide-timeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; position: relative; }
.slide-timeline::before { content: ""; position: absolute; top: 22px; inset-inline: 30px; height: 3px; background: var(--c-mint, #BAD9A1); }
.slide-step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.slide-step-dot { width: 46px; height: 46px; border-radius: 50%; background: var(--c-green, #119853); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 18px; box-shadow: 0 0 0 6px #fff; z-index: 1; }
.slide-step-title { font-size: 19px; font-weight: 700; color: var(--c-forest, #2C5F2D); }
.slide-step-text { font-size: 16px; color: #555; line-height: 1.6; }

/* ------------------------------------------------------------------ screen preview of print pages */
@media screen {
  .print-root .slide { zoom: var(--slide-zoom, 1); }
  .print-root .sheet-a4 { zoom: var(--sheet-zoom, 1); }
}

/* ------------------------------------------------------------------ print */
@media print {
  html, body { background: #fff !important; }
  body { margin: 0; }
  .sidebar, .topbar, .bottom-nav, .sb-backdrop, .toast-stack, .print-fab, .no-print, .overlay, .lightbox { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  .print-root { padding: 0 !important; gap: 0 !important; display: block !important; }
  .print-root .slide, .print-root .sheet-a4 { zoom: 1 !important; }
  .slide { box-shadow: none; margin: 0; }
  .sheet-a4 { box-shadow: none; width: auto; min-height: 0; padding: 0 1px; margin: 0; } /* 1px keeps edge borders inside the printable area */
  .sheet-footer { position: static; margin-top: 10px; }
  .card { box-shadow: none; break-inside: avoid; }
  .table thead th { position: static; }
  a { color: inherit; text-decoration: none; }
  .chart-tip { display: none !important; }
}
