/* ==========================================================
   فاتورة أونلاين — تصاميم الفاتورة (A4 + حراري)
   ========================================================== */
.inv {
  --i-p: #1f6fe0; --i-s: #2b2f36; --i-bg: #ffffff; --i-text: #1f2937; --i-muted: #6b7280; --i-title: #1f2937;
  --i-th-bg: #1f6fe0; --i-th-text: #ffffff; --i-td: #1f2937; --i-stripe: #f1f5fb; --i-border: #e5e7eb;
  --i-tot-bg: #1f6fe0; --i-tot-text: #ffffff; --i-pat: #94a3b8; --i-fs: 1; --i-logo: 84px; --i-rad: 10px;
  position: relative; overflow: hidden;
  width: 794px; min-height: 1123px;
  background: var(--i-bg); color: var(--i-text);
  font-family: 'Inter', 'Tajawal', sans-serif;
  font-size: calc(13px * var(--i-fs)); line-height: 1.55;
  text-align: start;
  -webkit-font-smoothing: antialiased;
}
.inv.l-ar { font-family: 'Tajawal', sans-serif; line-height: 1.6; }
.inv * { box-sizing: border-box; }
.inv .amt { unicode-bidi: isolate; white-space: nowrap; }
.inv .ltr { direction: ltr; unicode-bidi: isolate; }
.inv-deco { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.inv-deco svg { position: absolute; display: block; }
.inv-deco .waves { inset: 0; width: 100%; height: 100%; }
.inv-deco .corner-t { top: 0; right: 0; }
.inv-deco .corner-b { bottom: 0; left: 0; }
.inv[dir="rtl"] .inv-deco .corner-t { right: auto; left: 0; transform: scaleX(-1); }
.inv[dir="rtl"] .inv-deco .corner-b { left: auto; right: 0; transform: scaleX(-1); }
.inv-body { position: relative; z-index: 1; padding: 54px 56px 34px; min-height: 1123px; display: flex; flex-direction: column; }

/* ---- Header (split) ---- */
.inv-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; position: relative; }
.inv-brand { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1; }
.inv-logo { width: var(--i-logo); height: var(--i-logo); object-fit: contain; flex: none; }
.inv-shop { font-size: 1.9em; font-weight: 800; color: var(--i-title); line-height: 1.2; overflow-wrap: anywhere; }
.inv-tag { color: var(--i-muted); font-size: 1.05em; margin-top: 2px; overflow-wrap: anywhere; }
.inv-titlebox { text-align: end; flex: none; max-width: 46%; }
.inv-title { font-size: 2.15em; font-weight: 800; color: var(--i-p); line-height: 1.15; }
.inv-no { margin-top: 6px; font-weight: 700; color: var(--i-text); font-size: 1.05em; }
.inv-no span { color: var(--i-muted); font-weight: 500; }
.inv-contact { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 20px; padding: 10px 0; border-top: 1.5px solid var(--i-border); border-bottom: 1.5px solid var(--i-border); color: var(--i-text); font-size: .95em; }
.inv-contact div { display: inline-flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.inv-contact svg { width: 14px; height: 14px; stroke: var(--i-p); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- Section title ---- */
.sec { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12em; color: var(--i-title); margin: 0 0 12px; }
.sec::after { content: ''; flex: 1; height: 2px; background: var(--i-border); border-radius: 2px; }

/* ---- Parties ---- */
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; margin-top: 28px; }
.party-name { font-size: 1.22em; font-weight: 800; color: var(--i-text); margin-bottom: 4px; overflow-wrap: anywhere; }
.party-line { color: var(--i-muted); display: flex; gap: 8px; overflow-wrap: anywhere; }
.party-line b { color: var(--i-text); font-weight: 600; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--i-border); }
.meta-row:last-child { border-bottom: 0; }
.meta-row > span { color: var(--i-muted); }
.meta-row b { font-weight: 700; color: var(--i-text); text-align: end; overflow-wrap: anywhere; }
.st-pill { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .88em; font-weight: 800; color: #fff; }

/* ---- Table ---- */
.inv-items { margin-top: 28px; }
.inv-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.inv-table th { background: var(--i-th-bg); color: var(--i-th-text); font-weight: 700; padding: 11px 12px; text-align: center; font-size: .97em; }
.inv-table td { padding: 10px 12px; color: var(--i-td); border-bottom: 1px solid var(--i-border); text-align: center; vertical-align: top; }
.inv-table .c-desc { text-align: start; overflow-wrap: anywhere; }
.inv-table .c-idx { width: 44px; color: var(--i-muted); }
.inv-table th.c-idx { color: var(--i-th-text); }
.inv-table .c-qty { width: 72px; }
.inv-table .c-price { width: 128px; }
.inv-table .c-total { width: 140px; font-weight: 700; }
.inv.striped .inv-table tbody tr:nth-child(even) td { background: var(--i-stripe); }
.inv.rounded .inv-table th:first-child { border-start-start-radius: var(--i-rad); border-end-start-radius: var(--i-rad); }
.inv.rounded .inv-table th:last-child { border-start-end-radius: var(--i-rad); border-end-end-radius: var(--i-rad); }

/* ---- Summary ---- */
.inv-summary { display: grid; grid-template-columns: 1fr 300px; gap: 30px; margin-top: 24px; align-items: start; }
.inv-words { background: var(--i-stripe); border-inline-start: 4px solid var(--i-p); padding: 12px 14px; color: var(--i-text); margin-bottom: 14px; }
.inv.rounded .inv-words { border-radius: var(--i-rad); }
.inv-words small { display: block; color: var(--i-muted); font-size: .85em; margin-bottom: 2px; }
.inv-words div { font-weight: 700; overflow-wrap: anywhere; }
.inv-notes h5 { margin: 0 0 4px; font-size: 1em; color: var(--i-title); }
.inv-notes p { margin: 0; color: var(--i-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.tot-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; }
.tot-row > span { color: var(--i-muted); }
.tot-row b { font-weight: 700; }
.tot-row.grand { background: var(--i-tot-bg); color: var(--i-tot-text); margin-top: 6px; padding: 12px 14px; font-size: 1.22em; }
.tot-row.grand > span, .tot-row.grand b { color: var(--i-tot-text); font-weight: 800; }
.inv.rounded .tot-row.grand { border-radius: var(--i-rad); }
.tot-row.paid b { color: #12a150; }
.tot-row.rem b { color: #e03a3a; }
.tot-sep { height: 1px; background: var(--i-border); margin: 4px 14px; }

/* ---- Signature & stamp ---- */
.inv-sign { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-top: 34px; }
.status-stamp {
  display: inline-block; padding: 8px 22px; border: 4px double currentColor; border-radius: 12px;
  font-size: 1.9em; font-weight: 800; transform: rotate(-9deg); opacity: .88; white-space: nowrap; line-height: 1.25;
  box-shadow: inset 0 0 0 2px transparent; margin-inline-start: 16px;
}
.inv:not(.l-ar) .status-stamp { letter-spacing: .06em; }
.status-stamp.paid { color: #12a150; }
.status-stamp.unpaid { color: #e03a3a; }
.status-stamp.partial { color: #e8890c; }
.sign-box { width: 230px; text-align: center; margin-inline-start: auto; }
.sign-box img { max-width: 100%; max-height: 110px; object-fit: contain; display: block; margin: 0 auto 6px; }
.sign-box .line { border-top: 1.5px solid var(--i-text); padding-top: 6px; color: var(--i-muted); font-weight: 600; }
.sign-box .space { height: 70px; }

/* ---- Footer ---- */
.inv-foot { margin-top: auto; padding-top: 22px; }
.inv-foot-in { border-top: 1.5px solid var(--i-border); padding-top: 14px; text-align: center; }
.inv-thanks { font-weight: 800; color: var(--i-p); font-size: 1.15em; }
.inv-foot small { display: block; color: var(--i-muted); margin-top: 3px; overflow-wrap: anywhere; }

/* ==========================================================
   القوالب
   ========================================================== */
/* 1) عصري — Modern */
.tpl-modern .sec::before { content: ''; width: 14px; height: 22px; background: var(--i-p); transform: skewX(-22deg); border-radius: 2px; flex: none; box-shadow: 5px 0 0 -1px var(--i-s); }
.inv.tpl-modern[dir="rtl"] .sec::before { transform: skewX(22deg); box-shadow: -5px 0 0 -1px var(--i-s); }
.tpl-modern .inv-head::before { content: ''; position: absolute; left: -56px; right: -56px; top: 50%; height: 46px; transform: translateY(-50%); background: var(--i-stripe); z-index: -1; }
.tpl-modern .inv-shop { color: var(--i-s); }
.tpl-modern .inv-logo { background: var(--i-bg); padding: 4px; border: 3px solid var(--i-bg); box-shadow: 0 6px 18px -8px rgba(0,0,0,.35); }

/* 2) دائري — Arc */
.arc-head { display: grid; grid-template-columns: 1fr 190px 1fr; gap: 18px; align-items: center; }
.arc-start { min-width: 0; }
.arc-end { min-width: 0; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; font-size: .95em; }
.arc-end div { display: inline-flex; gap: 7px; align-items: center; overflow-wrap: anywhere; min-width: 0; }
.arc-end svg { width: 14px; height: 14px; stroke: var(--i-p); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.arc-ring { position: relative; width: 190px; height: 150px; }
.arc-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.arc-ring .arc-logo { position: absolute; left: 50%; top: 66px; transform: translate(-50%, -50%); width: 104px; height: 104px; border-radius: 50%; background: var(--i-bg); border: 4px solid var(--i-bg); box-shadow: 0 6px 18px -6px rgba(0,0,0,.3); overflow: hidden; display: grid; place-items: center; }
.arc-ring .arc-logo img { width: 86%; height: 86%; object-fit: contain; }
.arc-ring .arc-logo b { font-size: 40px; color: var(--i-p); font-weight: 800; }
.arc-title { text-align: center; margin-top: 6px; }
.arc-title .inv-title { font-size: 1.9em; }
.tpl-arc .inv-shop { font-size: 1.75em; }
.tpl-arc .inv-shop .first { color: var(--i-p); }
.tpl-arc .sec { justify-content: flex-start; }
.tpl-arc .sec::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--i-p); box-shadow: 0 0 0 4px color-mix(in srgb, var(--i-p) 20%, transparent); flex: none; }
.tpl-arc .inv-parties { margin-top: 22px; }

/* 3) كلاسيكي — Classic */
.tpl-classic .frame { position: absolute; inset: 18px; border: 2px solid var(--i-p); }
.tpl-classic .frame::after { content: ''; position: absolute; inset: 5px; border: 1px solid var(--i-p); opacity: .55; }
.tpl-classic .inv-body { padding: 58px 62px 40px; }
.center-head { text-align: center; }
.center-head .inv-logo { margin: 0 auto 10px; display: block; }
.center-head .inv-shop { font-size: 2em; }
.center-head .inv-contact { justify-content: center; border-top: 0; margin-top: 8px; padding-top: 0; }
.classic-titlebar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; padding: 12px 18px; background: var(--i-stripe); border-top: 2px solid var(--i-p); border-bottom: 2px solid var(--i-p); }
.classic-titlebar .inv-title { font-size: 1.7em; }
.tpl-classic .sec { border-bottom: 2px solid var(--i-p); padding-bottom: 6px; }
.tpl-classic .sec::after { display: none; }
.inv.tpl-classic:not(.l-ar) .sec { text-transform: uppercase; letter-spacing: .08em; font-size: 1em; }
.tpl-classic .inv-table th, .tpl-classic .inv-table td { border: 1px solid var(--i-border); }
.tpl-classic .inv-table td { border-top: 0; }
.tpl-classic .inv-table th + th, .tpl-classic .inv-table td + td { border-inline-start: 0; }

/* 4) بسيط — Minimal */
.tpl-minimal .inv-body { padding: 64px 64px 40px; }
.tpl-minimal .inv-title { font-weight: 300; font-size: 2.6em; color: var(--i-title); }
.inv.tpl-minimal:not(.l-ar) .inv-title { text-transform: uppercase; letter-spacing: .12em; }
.inv.tpl-minimal.l-ar .inv-title { font-weight: 500; }
.tpl-minimal .inv-contact { border-top: 0; border-bottom: 1px solid var(--i-border); padding-top: 0; }
.tpl-minimal .sec { font-size: .92em; color: var(--i-muted); font-weight: 700; }
.inv.tpl-minimal:not(.l-ar) .sec { text-transform: uppercase; letter-spacing: .14em; }
.tpl-minimal .sec::after { height: 1px; }
.tpl-minimal .inv-table th { background: transparent; color: var(--i-th-bg); border-bottom: 2px solid var(--i-th-bg); padding: 10px 8px; }
.tpl-minimal .inv-table td { padding: 12px 8px; }
.tpl-minimal .tot-row.grand { background: transparent; color: var(--i-tot-bg); border-top: 2px solid var(--i-tot-bg); border-radius: 0 !important; }
.tpl-minimal .tot-row.grand span, .tpl-minimal .tot-row.grand b { color: var(--i-tot-bg); }

/* 5) فاخر — Luxury */
.tpl-luxury .inv-head { margin: -54px -56px 0; padding: 46px 56px 38px; background: var(--i-s); border-bottom: 5px solid var(--i-p); }
.tpl-luxury .inv-shop { color: var(--i-th-text); }
.tpl-luxury .inv-tag { color: color-mix(in srgb, var(--i-th-text) 70%, transparent); }
.tpl-luxury .inv-no { color: var(--i-th-text); }
.tpl-luxury .inv-no span { color: color-mix(in srgb, var(--i-th-text) 65%, transparent); }
.tpl-luxury .inv-logo { background: #fff; border-radius: 50%; padding: 8px; }
.tpl-luxury .inv-contact { border-top: 0; border-bottom: 1px solid var(--i-p); }
.tpl-luxury .sec::before { content: ''; width: 9px; height: 9px; background: var(--i-p); transform: rotate(45deg); flex: none; }
.tpl-luxury .sec::after { height: 1px; background: var(--i-p); opacity: .6; }
.tpl-luxury .inv-table th { background: var(--i-th-bg); }
.inv.tpl-luxury:not(.l-ar) .inv-title { letter-spacing: .06em; text-transform: uppercase; }

/* 6) جريء — Bold */
.tpl-bold .inv-head { margin: -54px -56px 0; padding: 46px 56px 70px; background: var(--i-p); clip-path: polygon(0 0, 100% 0, 100% 72%, 0 100%); }
.inv.tpl-bold[dir="rtl"] .inv-head { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 72%); }
.tpl-bold .inv-shop, .tpl-bold .inv-title, .tpl-bold .inv-no { color: var(--i-th-text); }
.tpl-bold .inv-tag, .tpl-bold .inv-no span { color: color-mix(in srgb, var(--i-th-text) 75%, transparent); }
.tpl-bold .inv-title { font-size: 2.5em; }
.tpl-bold .inv-logo { background: #fff; border-radius: 16px; padding: 8px; }
.tpl-bold .inv-contact { border-top: 0; margin-top: 4px; }
.tpl-bold .sec { display: inline-flex; background: var(--i-s); color: #fff; padding: 4px 14px; border-radius: 8px; }
.tpl-bold .sec::after { display: none; }
.tpl-bold .tot-row.grand { font-size: 1.4em; }

/* ==========================================================
   الفاتورة الحرارية
   ========================================================== */
.inv.thermal { width: 302px; min-height: 0; padding: 18px 14px 22px; font-size: calc(12px * var(--i-fs)); line-height: 1.45; }
.inv.thermal.w58 { width: 219px; padding: 14px 10px 18px; font-size: calc(10.5px * var(--i-fs)); }
.t-center { text-align: center; }
.t-logo { width: calc(var(--i-logo) * .75); height: calc(var(--i-logo) * .75); object-fit: contain; display: block; margin: 0 auto 6px; }
.t-shop { font-size: 1.45em; font-weight: 800; color: var(--i-title); line-height: 1.25; overflow-wrap: anywhere; }
.t-muted { color: var(--i-muted); overflow-wrap: anywhere; }
.t-sep { border-top: 1.5px dashed var(--i-text); opacity: .45; margin: 10px 0; }
.t-title { display: block; background: var(--i-th-bg); color: var(--i-th-text); font-weight: 800; font-size: 1.15em; padding: 5px 8px; margin: 2px 0 8px; text-align: center; }
.inv.thermal.rounded .t-title { border-radius: 6px; }
.t-row { display: flex; justify-content: space-between; gap: 8px; padding: 1.5px 0; }
.t-row > span { color: var(--i-muted); }
.t-row b { font-weight: 700; text-align: end; overflow-wrap: anywhere; }
.t-item { padding: 5px 0; border-bottom: 1px dotted color-mix(in srgb, var(--i-text) 30%, transparent); }
.t-item:last-child { border-bottom: 0; }
.t-item-name { font-weight: 700; overflow-wrap: anywhere; }
.t-item-calc { display: flex; justify-content: space-between; gap: 8px; color: var(--i-muted); }
.t-item-calc b, .t-item-calc b .amt { color: var(--i-td); }
.t-grand { display: flex; justify-content: space-between; gap: 8px; background: var(--i-tot-bg); color: var(--i-tot-text); padding: 7px 8px; font-weight: 800; font-size: 1.25em; margin-top: 6px; }
.inv.thermal.rounded .t-grand { border-radius: 6px; }
.t-stamp { display: inline-block; border: 2.5px solid currentColor; padding: 4px 14px; font-weight: 800; font-size: 1.3em; transform: rotate(-4deg); margin: 8px 0 2px; border-radius: 6px; }
.t-stamp.paid { color: #12a150; } .t-stamp.unpaid { color: #e03a3a; } .t-stamp.partial { color: #e8890c; }
.t-words { font-weight: 600; overflow-wrap: anywhere; margin-top: 6px; }
.t-notes { white-space: pre-wrap; color: var(--i-muted); overflow-wrap: anywhere; }
.t-sign img { max-width: 60%; max-height: 70px; object-fit: contain; display: block; margin: 6px auto 0; }
.t-thanks { font-weight: 800; color: var(--i-p); margin-top: 4px; }
