/* Lumix — نظام المبيعات | ستايل واحد للنظام كله */

:root {
  /* ألوان — أزرق للبيانات وبرتقالي للتنبيهات، مفحوصة للتباين WCAG AA */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;          /* رمادي غامق للنص — أريح للعين من الأزرق بالساعات الطويلة */
  --text-2: #475569;
  --text-3: #8494a8;
  --primary: #1e40af;
  --primary-600: #2563eb;
  --primary-50: #eff6ff;
  --accent: #d97706;
  --accent-50: #fffbeb;
  --ok: #059669;
  --ok-50: #ecfdf5;
  --bad: #dc2626;
  --bad-50: #fef2f2;
  --border: #cbd5e1;
  --border-soft: #e2e8f0;

  --r: 8px;
  --r-lg: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .14);

  /* خطوط ويندوز المدمجة — دعم عربي ممتاز وتشتغل بلا إنترنت */
  --font: "Segoe UI", Tahoma, Arial, sans-serif;
  --font-num: "Segoe UI", Tahoma, sans-serif;

  --side-w: 216px;
  --top-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* الأرقام بعرض ثابت حتى الأعمدة تبقى مصطفة */
.num, td.num, input[type="number"], .money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 2px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #c3cedb; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #a6b4c4; }

/* ═══════════════ الهيكل ═══════════════ */
.app { display: flex; height: 100vh; }

.side {
  width: var(--side-w);
  flex: 0 0 auto;
  background: #101a33;
  color: #cdd7e6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.side > * { transition: opacity .15s ease; }
.app.collapsed .side {
  width: 0;
}
.app.collapsed .side > * {
  opacity: 0;
}

.brand {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  flex: 0 0 auto;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: contain; flex: 0 0 auto;
}
.brand-txt { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.brand b { color: #fff; font-size: 17px; letter-spacing: .3px; display: block; }
.brand small { color: #8b9ab3; font-size: 11px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.brand .dot.off { background: var(--bad); }

.nav { padding: 8px; overflow-y: auto; flex: 1 1 auto; }
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 2px;
  background: none;
  border: 0;
  border-radius: var(--r);
  color: #cdd7e6;
  font-size: 14.5px;
  text-align: right;
  transition: background .15s, color .15s, transform .15s ease;
}
.nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateY(-2px); }
.nav button.on { background: var(--primary-600); color: #fff; font-weight: 600; }
.nav button .ic { flex: 0 0 auto; opacity: .9; }
.nav button .badge {
  margin-inline-start: auto;
  background: linear-gradient(135deg, #fb923c, #dc2626);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  box-shadow: 0 1px 4px rgba(220, 38, 38, .5), 0 0 0 0 rgba(220, 38, 38, .55);
  animation: navBadgePulse 2s ease-out infinite;
}
/* حلقة نبض تتوسّع وتخفت — تلفت العين للتنبيه بلا حركة مزعجة دائمة */
@keyframes navBadgePulse {
  0%   { box-shadow: 0 1px 4px rgba(220, 38, 38, .5), 0 0 0 0 rgba(251, 146, 60, .6); }
  70%  { box-shadow: 0 1px 4px rgba(220, 38, 38, .5), 0 0 0 6px rgba(251, 146, 60, 0); }
  100% { box-shadow: 0 1px 4px rgba(220, 38, 38, .5), 0 0 0 0 rgba(251, 146, 60, 0); }
}
/* أقسام القائمة القابلة للفتح */
.navgrp { margin-bottom: 2px; }
.nav .grphd {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 0; background: none;
  color: #cdd7e6; font-size: 14.5px; text-align: right;
  border-radius: var(--r); transition: background .15s, transform .15s ease;
}
.nav .grphd:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateY(-2px); }
.nav .grphd.act { color: #fff; font-weight: 600; }
.nav .grphd .chev2 {
  margin-inline-start: auto; font-size: 11px; color: #7d8ca6;
  transition: transform .18s; flex: 0 0 auto;
}
.navgrp.open .grphd .chev2 { transform: rotate(180deg); }
.nav .grpitems { display: none; padding: 2px 0 4px; }
.navgrp.open .grpitems { display: block; }
.nav .grpitems button {
  padding: 7px 11px 7px 0;
  padding-inline-start: 26px;
  font-size: 13.5px;
  gap: 8px;
}
.nav .grpitems .dot2 {
  width: 5px; height: 5px; border-radius: 50%;
  background: #59688a; flex: 0 0 auto;
}
.nav .grpitems button.on .dot2 { background: #fff; }
.nav button.lone { margin-bottom: 4px; }

.nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 8px 6px; }
.nav .cap { font-size: 11px; color: #6b7a94; padding: 8px 11px 4px; letter-spacing: .4px; }

.side-foot { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.09); font-size: 11.5px; color: #6b7a94; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

.top {
  position: relative;
  height: var(--top-h);
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
.top h1 { font-size: 17px; margin: 0; font-weight: 600; }
.top .spacer { flex: 1 1 auto; }
.top .chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text-2);
}
.top .chip b { color: var(--text); }

/* ═══════════════ زر التحديث بالرأس ═══════════════ */
/* بنفسجي هادئ بالوضع العادي، ويصير برتقالي نابض لما يتوفر تحديث */
.btn-update {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid #c7b3ec;
  background: #f5f0ff;
  color: #5b3a9e;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  position: relative;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .07s;
}
.btn-update:hover { background: #ece1ff; border-color: #a98be0; }
.btn-update:active { transform: translateY(1px); }
.btn-update[disabled] { opacity: .6; cursor: not-allowed; }

/* ═══ عدّاد التنقّل بين الفواتير ═══ */
/* شكل عدّاد السجلات المعروف: أسهم على الطرفين ورقم الفاتورة بالوسط */
.pager { display: flex; align-items: stretch; gap: 0; }
.pager .pg {
  width: 26px; flex: 0 0 26px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.pager .pg:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-600); }
.pager .pg:active { transform: translateY(1px); }
.pager .pg:first-child { border-start-start-radius: var(--r); border-end-start-radius: var(--r); }
.pager .pg:last-child { border-start-end-radius: var(--r); border-end-end-radius: var(--r); }
.pager .inp {
  flex: 1 1 auto; min-width: 0; text-align: center; font-weight: 700;
  border-radius: 0; border-inline: 0; direction: ltr;
}

/* ═══ قائمة الأرباح والخسائر ═══ */
/* الترتيب المحاسبي يحتاج تدرّجاً بصرياً: عناوين أقسام ثم بنود ثم مجاميع */
table.pnl td { padding: 8px 14px; }
table.pnl tr.pnl-h td {
  background: var(--surface-2); font-weight: 700; font-size: 12.5px;
  color: var(--text-2); border-top: 1px solid var(--border);
}
table.pnl tr.pnl-r td:first-child { padding-inline-start: 26px; }
table.pnl tr.pnl-s td { font-weight: 700; border-top: 1px solid var(--border); }
table.pnl tr.pnl-g td { font-weight: 700; background: var(--primary-50); color: var(--primary); font-size: 14px; }
table.pnl tr.pnl-n td {
  font-weight: 800; font-size: 16px; background: var(--primary-600);
  color: #fff; border-top: 2px solid var(--primary-600);
}
table.pnl tr.pnl-n td.dim { color: #fff; opacity: .8; }
table.pnl tr.pnl-g td.dim { color: var(--primary); opacity: .85; }

/* ═══ جرس التنبيهات ═══ */
.bell-wrap { position: relative; }
.btn-bell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px; position: relative;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}

.btn-side {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px; flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s, transform .07s;
}
.btn-side:hover { background: var(--surface-2); border-color: var(--primary-600); color: var(--primary); }
.btn-side:active { transform: translateY(1px); }
.btn-side.on { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-side .ic { transition: transform .3s cubic-bezier(.4, 0, .2, 1); }
.btn-side.on .ic { transform: rotate(180deg); }

/* ═══ بحث الشريط العلوي — صندوق عادي بمنتصف الشريط، واقتراحاته تنسدل
   تحته مباشرة بنفس أسلوب أي بحث ثاني بالبرنامج (.ac-list)، بلا نافذة
   منبثقة. بين فراغين متساويين (spacer قبله وبعده) فيبقى بالنص دائماً
   ويتقلّص أول ما تضيق المساحة بدل ما يتراكب مع أزرار الشريط ═══ */
.top-search {
  flex: 1 1 320px; max-width: 380px; min-width: 130px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; min-height: 38px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.top-search:focus-within {
  background: var(--surface); border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.top-search .ic-wrap { flex: 0 0 auto; display: inline-flex; color: var(--text-3); }
.top-search input {
  flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 13.5px; color: var(--text);
}
.top-search input::placeholder { color: var(--text-3); }
@media (max-width: 820px) { .top-search { display: none; } }

/* صفوف اقتراحات البحث السريع بالشريط العلوي — أيقونة الشاشة + قسمها */
.cmdk-ic {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary);
}
.ac-list div.cur .cmdk-ic, .ac-list div:hover .cmdk-ic { background: var(--primary-600); color: #fff; }

.btn-bell:hover { background: var(--surface-2); border-color: var(--primary-600); color: var(--primary); }
.bell-wrap.urgent .btn-bell { border-color: var(--bad); color: var(--bad); background: var(--bad-50); }
.btn-bell .badge {
  position: absolute; inset-block-start: -4px; inset-inline-start: -4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}
.bell-wrap.urgent .btn-bell .badge { background: var(--bad); }

.bell-panel {
  position: absolute; inset-block-start: calc(100% + 8px); inset-inline-start: 0;
  min-width: 290px; z-index: 60; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.al-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); font-size: 13px; text-align: start;
}
.al-row:hover { background: var(--surface-2); }
.al-row .l { flex: 1; }
.al-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.al-row.bad { color: var(--bad); }
.al-row.warn { color: var(--accent); }
.al-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; }

/* يتوفر تحديث: برتقالي واضح مع نبض خفيف يجذب النظر بلا إزعاج */
.btn-update.has {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(217, 119, 6, .55);
  animation: updPulse 2.4s ease-out infinite;
}
.btn-update.has:hover { background: #b96405; border-color: #b96405; }
@keyframes updPulse {
  0%   { box-shadow: 0 0 0 0 rgba(217, 119, 6, .5); }
  60%  { box-shadow: 0 0 0 9px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

/* تحديث إجباري: أحمر */
.btn-update.must {
  background: var(--bad); border-color: var(--bad); color: #fff;
  animation: updPulse 1.5s ease-out infinite;
}
.btn-update.must:hover { background: #b3211d; border-color: #b3211d; }

/* جاهز للتطبيق: أخضر */
.btn-update.ready { background: var(--ok); border-color: var(--ok); color: #fff; animation: none; }
.btn-update.ready:hover { background: #04785b; border-color: #04785b; }

.btn-update.busy { animation: none; }
.btn-update.busy .ic-wrap { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-update .ic-wrap { display: inline-flex; }
.btn-update .pip {
  position: absolute; top: -3px; left: -3px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bad); border: 2px solid var(--surface);
}

/* شريط تقدم التنزيل داخل النافذة */
.prog { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.prog > i { display: block; height: 100%; width: 0; background: var(--primary-600); transition: width .2s; }

.notes { margin: 0; padding-inline-start: 20px; line-height: 1.9; }
.notes li { margin-bottom: 2px; }

code {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  direction: ltr;
  display: inline-block;
}

.pages { flex: 1 1 auto; overflow: auto; padding: 16px; }
.page { display: none; }
.page.on { display: block; }
.page.full { height: 100%; }

/* ═══════════════ عناصر عامة ═══════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card > .hd {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
}
.card > .hd .spacer { flex: 1 1 auto; }
.card > .bd { padding: 14px; }
.card > .bd.flush { padding: 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
/* حقل وجنبه زر: .inp عرضه 100% فيدفع الزر لسطر تحته — نخليه يتقلّص بدلها */
.row .inp.grow { flex-basis: 0; min-width: 0; }
.grow { flex: 1 1 auto; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.hidden { display: none !important; }
/* أي عنصر عليه خاصية hidden يختفي فعلاً. بدونها أي قاعدة display صريحة
   (مثل .pending { display:flex }) تغلب قاعدة المتصفح فيبقى العنصر ظاهراً —
   صار هذا مع الفاتورة العائمة فظلّت تظهر داخل شاشة الفاتورة نفسها. */
[hidden] { display: none !important; }

/* align-*: start مهمّان — بدونهما الشبكة تمدّد صفوفها لتملأ الارتفاع المتاح
   فتطلع البطاقات بطول الشاشة كلها */
.grid { display: grid; gap: 12px; align-items: start; align-content: start; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g5, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px)  { .g5, .g4, .g3, .g2 { grid-template-columns: 1fr; } }

/* أزرار — الحد الأدنى 40px ارتفاعاً حتى تنفع باللمس والاستخدام السريع */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #b3c1d2; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.p { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.p:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.a { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.a:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(1.07); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.bad:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: 52px; padding: 0 22px; font-size: 17px; font-weight: 600; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 32px; min-height: 32px; }

/* حقول */
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.f > label .req { color: var(--bad); }
.inp {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.inp:hover { border-color: #b3c1d2; }
.inp:focus { border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13); outline: none; }
.inp[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea.inp { min-height: 66px; resize: vertical; }
.inp.big { min-height: 50px; font-size: 18px; font-weight: 600; }

/* حقل التاريخ العربي — للقراءة فقط لأن الاختيار من التقويم، لكن يبقى بمظهر حقل عادي */
.inp.dt-in[readonly] {
  background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 600;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238494a8' stroke-width='1.9' stroke-linecap='round'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M8 3v4M16 3v4M3 10h18'/></svg>");
  background-repeat: no-repeat;
  background-position: left 9px center;
  padding-left: 30px;
}

/* ═══════════════ التقويم العربي ═══════════════ */
.dp {
  position: fixed; z-index: 950; width: 262px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop .12s ease-out; user-select: none;
}
.dp-hd { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.dp-nv, .dp-t, .dp-m, .dp-d, .dp-b {
  border: 1px solid transparent; background: none; border-radius: 7px;
  cursor: pointer; font-family: inherit; color: var(--text);
}
.dp-nv {
  width: 30px; height: 30px; font-size: 19px; line-height: 1;
  color: var(--text-2); flex: 0 0 auto;
}
.dp-nv:hover { background: var(--surface-2); color: var(--primary); }
.dp-t {
  flex: 1 1 auto; height: 34px; font-size: 15px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.dp-t small { font-size: 10.5px; font-weight: 600; color: var(--muted); }
.dp-t:hover { background: var(--primary-50); color: var(--primary); }
.dp-wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 3px; }
.dp-wk span { text-align: center; font-size: 10.5px; color: var(--text-3); font-weight: 600; }
.dp-dg { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-d {
  height: 31px; font-size: 13.5px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
}
.dp-d:hover { background: var(--primary-50); }
.dp-d.out { color: var(--text-3); opacity: .55; }
.dp-d.in { background: var(--primary-50); }
.dp-d.now { border-color: var(--primary-600); font-weight: 700; color: var(--primary); }
.dp-d.sel, .dp-m.sel { background: var(--primary-600); color: #fff; font-weight: 700; }
.dp-mg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.dp-m {
  height: 46px; padding: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.dp-m b { font-size: 15px; font-weight: 700; line-height: 1; }
.dp-m small { font-size: 9.5px; color: var(--muted); line-height: 1.1; }
.dp-m.sel small, .dp-m.sel b { color: inherit; }
.dp-m:hover { background: var(--primary-50); }
.dp-m.now { border-color: var(--primary-600); color: var(--primary); font-weight: 700; }
.dp-note { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 5px; }
.dp-ft {
  display: flex; align-items: center; gap: 6px;
  margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border-soft);
}
.dp-ft .spacer { flex: 1 1 auto; }
.dp-b { padding: 5px 11px; font-size: 12.5px; border-color: var(--border); }
.dp-b:hover { background: var(--surface-2); }
.dp-b.p { background: var(--primary-50); border-color: #bfdbfe; color: var(--primary); font-weight: 600; }
.hint { font-size: 11.5px; color: var(--text-3); }
.err { font-size: 12px; color: var(--bad); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary-600); cursor: pointer; }
/* قائمة مفاتيح رأسية — كل مفتاح بسطره، وصف نقر أوسع */
.switches .switch {
  display: flex; width: 100%;
  padding: 9px 10px; border-radius: 8px;
  border: 1px solid transparent;
}
.switches .switch:hover { background: var(--surface-2); border-color: var(--border-soft); }
.switches .switch + .switch { margin-top: 2px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--r); padding: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 6px; font-size: 13.5px; color: var(--text-2); min-height: 34px; }
.seg button.on { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.seg button:disabled { opacity: .5; cursor: not-allowed; }
/* الاسم العلمي بقائمة نتائج البحث — يميّزه عن الاسم التجاري */
.hit .nm .sci,
.ac-list .sci { color: var(--primary); font-weight: 600; margin-inline-start: 6px; }
.seg.block { display: flex; width: 100%; }
.seg.block button { flex: 1 1 auto; min-height: 38px; }
/* مفتاح نموذج الطباعة تحت زر «بيع وطباعة» — مختصر حتى ما يزاحم الأزرار */
.seg.fmt { margin-top: 6px; }
.seg.fmt button { min-height: 30px; padding: 4px 8px; font-size: 12.5px; }
/* المرتجع يأخذ اللون البرتقالي بكل مكان حتى ما يلتبس بالبيع */
#kindSeg button[data-k="return"].on { color: var(--accent); }
#paySeg button[data-p="card"].on { color: var(--primary); }
#paySeg button[data-p="credit"].on { color: var(--accent); }

/* جداول كثيفة للبيانات */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); }
table.tbl tbody tr:hover { background: var(--primary-50); }
table.tbl tbody tr.sel { background: var(--primary-50); }
table.tbl tbody tr.clk { cursor: pointer; }
/* السطر اللي انضاف هالتو — يلمع لحظة حتى تشوف إن الحركة تسجّلت */
table.tbl tbody tr.flash { animation: rowflash 2.2s ease-out; }
@keyframes rowflash {
  0%, 55% { background: #d1fae5; }
  100% { background: transparent; }
}
table.tbl td.num, table.tbl th.num { text-align: left; direction: ltr; }
table.tbl td.act { text-align: left; white-space: nowrap; width: 1%; }
table.tbl tr.tot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
table.tbl.zebra tbody tr:nth-child(even) { background: #fbfdff; }
table.tbl.zebra tbody tr:nth-child(even):hover { background: var(--primary-50); }
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.tag.ok { background: var(--ok-50); color: #04785b; }
.tag.warn { background: var(--accent-50); color: #a35c05; }
.tag.bad { background: var(--bad-50); color: #b91c1c; }
.tag.info { background: var(--primary-50); color: var(--primary); }

/* بطاقات أرقام — مدمجة بارتفاع ثابت لا يتمدد */
.kpi {
  /* عمود بسطر فرعي محجوز — فكل البطاقات بنفس الارتفاع سواء لها سطر فرعي أو لا،
     و align-self: stretch يمنع الشبكة (align-items: start) من تقصيرها */
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 9px 12px;
  box-shadow: var(--shadow);
  align-self: stretch;
  min-height: 68px;
  overflow: hidden;
}
.kpi .lb {
  font-size: 12px; color: var(--text-2);
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .lb svg { flex: 0 0 auto; }
.kpi .vl {
  font-size: 21px; font-weight: 700; margin-top: 1px; line-height: 1.2;
  letter-spacing: -.4px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* السطر الفرعي: يُحجز مكانه دائماً (min-height) فالبطاقة بلا سطر فرعي
   تبقى بنفس ارتفاع اللي عندها سطر — بلا تفاوت بالأبعاد */
.kpi .sb {
  font-size: 11.5px; color: var(--text-3); line-height: 1.35;
  min-height: 16px; margin-top: auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi.pos .vl { color: var(--ok); }
.kpi.neg .vl { color: var(--bad); }
.kpi.acc .vl { color: var(--accent); }
.kpi.pri .vl { color: var(--primary); }

/* ═══════════════ شريط الفواتير المفتوحة ═══════════════ */
.itabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.itabs .itab {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  padding: 4px 10px; min-height: 34px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.itabs .itab:hover { background: var(--surface); border-color: var(--primary-600); }
.itabs .itab.on {
  background: var(--surface); color: var(--primary);
  border-color: var(--primary-600); box-shadow: var(--shadow);
  font-weight: 600;
}
.itabs .itab.on.ret { color: var(--accent); border-color: var(--accent); }
/* تبويب تعديل فاتورة محفوظة — إطار متقطّع يميّزه عن فاتورة جديدة */
.itabs .itab.edit { border-style: dashed; border-color: var(--primary); }
.itabs .itab.on.edit { color: var(--primary); border-color: var(--primary); border-style: dashed; }
.itabs .itab .nm {
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13.5px;
}
.itabs .itab .mt2 {
  font-size: 11px; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
.itabs .itab.on .mt2 { background: var(--bg); }
.itabs .itab .cl {
  font-size: 13px; color: var(--text-3); line-height: 1;
  padding: 3px 5px; border-radius: 5px;
}
.itabs .itab .cl:hover { background: var(--bad); color: #fff; }

/* زر فتح فاتورة جديدة — آخر الشريط، أخضر يميّزه عن التبويبات */
.itabs .itab.new {
  background: var(--ok); color: #fff; border-color: var(--ok);
  font-weight: 600; gap: 5px;
}
.itabs .itab.new:hover { filter: brightness(1.07); border-color: var(--ok); }
.itabs .itab.new .nm { max-width: none; }

/* ═══════════════ الفاتورة العائمة ═══════════════ */
/* شريحة أسفل يسار الشاشة تبيّن فاتورة نصف مكتملة وترجّعك لها */
.pending {
  /* يسار الشاشة فعلياً: القائمة الجانبية على اليمين دائماً (الواجهة عربية)،
     فلو استخدمنا inset-inline-start تطلع الشريحة فوق القائمة */
  position: fixed; left: 18px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: flex-start;
  animation: pendIn .28s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pendIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.pending .pend-main {
  display: flex; align-items: center; gap: 11px;
  border: 0; cursor: pointer; text-align: start;
  padding: 11px 14px; border-radius: 14px;
  background: linear-gradient(150deg, #7c3aed, #5b21b6);
  color: #fff; box-shadow: 0 10px 28px rgba(124, 58, 237, .42);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1), box-shadow .2s;
}
.pending .pend-main.ret {
  background: linear-gradient(150deg, #f59e0b, #b45309);
  box-shadow: 0 10px 28px rgba(245, 158, 11, .42);
}
.pending .pend-main.pur {
  background: linear-gradient(150deg, #10b981, #047857);
  box-shadow: 0 10px 28px rgba(16, 185, 129, .42);
}
.pending .pend-main:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(124, 58, 237, .52); }
.pending .pend-main.ret:hover { box-shadow: 0 14px 34px rgba(245, 158, 11, .52); }
.pending .pend-main.pur:hover { box-shadow: 0 14px 34px rgba(16, 185, 129, .52); }
.pending .pend-ic {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .3);
}
.pending .pend-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pending .pend-txt b { font-size: 14px; font-weight: 700; }
.pending .pend-txt small {
  font-size: 11.5px; opacity: .9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}
@media (max-width: 700px) {
  .pending { left: 10px; bottom: 10px; }
}

/* ═══════════════ الواجهة الرئيسية ═══════════════ */
/* المربعات: تدرّج لوني + توهّج يزيد عند المرور */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}
/* عدد أعمدة ثابت يختاره المستخدم من الإعدادات — عرض المربع ثابت دائماً
   بغض النظر عن العدد؛ لو الصف ما يمتلئ يبقى الفراغ فاضياً بدل ما يكبّر
   المربعات لتعبئته (كانت تكبر أو تصغر حسب عدد الأعمدة المختار) */
.tiles[data-cols] { grid-template-columns: repeat(var(--tcols, 4), 210px); }
/* فاصل سطر: يأكل بقية الصف فاللي بعده يبدأ صفاً جديداً */
.tbreak { grid-column: 1 / -1; height: 0; margin: -6px 0; }
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
  .tiles > .tile { grid-column: auto !important; }
}
.tile {
  position: relative; overflow: hidden;
  border: 0; border-radius: 16px;
  padding: 16px 15px;
  min-height: 100px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  color: #fff; text-align: right;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.8,.3,1), box-shadow .2s, filter .2s;
}
/* اللمعة العلوية تعطي إحساس العمق */
.tile::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,.26), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.tile:hover { transform: translateY(-3px); filter: saturate(1.12); }
.tile:active { transform: translateY(0); }
.tile:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }

.tile-ic {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .28);
  margin-bottom: 8px;
}
.tile-lb { font-size: 17px; font-weight: 700; line-height: 1.25; }

/* التدرّجات — كل واحد له توهّج بلونه */
.g-violet  { background: linear-gradient(150deg, #7c3aed, #5b21b6); box-shadow: 0 8px 22px rgba(124,58,237,.36); }
.g-rose    { background: linear-gradient(150deg, #f43f5e, #be123c); box-shadow: 0 8px 22px rgba(244,63,94,.34); }
.g-navy    { background: linear-gradient(150deg, #1e40af, #172554); box-shadow: 0 8px 22px rgba(30,64,175,.36); }
.g-teal    { background: linear-gradient(150deg, #10b981, #047857); box-shadow: 0 8px 22px rgba(16,185,129,.34); }
.g-amber   { background: linear-gradient(150deg, #f59e0b, #b45309); box-shadow: 0 8px 22px rgba(245,158,11,.34); }
.g-cyan    { background: linear-gradient(150deg, #06b6d4, #0e7490); box-shadow: 0 8px 22px rgba(6,182,212,.34); }
.g-indigo  { background: linear-gradient(150deg, #4f46e5, #3730a3); box-shadow: 0 8px 22px rgba(79,70,229,.34); }
.g-slate   { background: linear-gradient(150deg, #475569, #1e293b); box-shadow: 0 8px 22px rgba(71,85,105,.32); }
.g-emerald { background: linear-gradient(150deg, #059669, #065f46); box-shadow: 0 8px 22px rgba(5,150,105,.32); }
.g-fuchsia { background: linear-gradient(150deg, #d946ef, #a21caf); box-shadow: 0 8px 22px rgba(217,70,239,.34); }
.g-sky     { background: linear-gradient(150deg, #0ea5e9, #0369a1); box-shadow: 0 8px 22px rgba(14,165,233,.34); }
.g-plum    { background: linear-gradient(150deg, #a855f7, #6b21a8); box-shadow: 0 8px 22px rgba(168,85,247,.34); }
.g-blue    { background: linear-gradient(150deg, #2563eb, #1e3a8a); box-shadow: 0 8px 22px rgba(37,99,235,.36); }
.g-stone   { background: linear-gradient(150deg, #78716c, #44403c); box-shadow: 0 8px 22px rgba(120,113,108,.32); }

.tile:hover.g-violet  { box-shadow: 0 12px 30px rgba(124,58,237,.5); }
.tile:hover.g-rose    { box-shadow: 0 12px 30px rgba(244,63,94,.48); }
.tile:hover.g-navy    { box-shadow: 0 12px 30px rgba(30,64,175,.5); }
.tile:hover.g-teal    { box-shadow: 0 12px 30px rgba(16,185,129,.48); }
.tile:hover.g-amber   { box-shadow: 0 12px 30px rgba(245,158,11,.48); }
.tile:hover.g-cyan    { box-shadow: 0 12px 30px rgba(6,182,212,.48); }
.tile:hover.g-indigo  { box-shadow: 0 12px 30px rgba(79,70,229,.48); }
.tile:hover.g-slate   { box-shadow: 0 12px 30px rgba(71,85,105,.46); }
.tile:hover.g-emerald { box-shadow: 0 12px 30px rgba(5,150,105,.46); }
.tile:hover.g-fuchsia { box-shadow: 0 12px 30px rgba(217,70,239,.48); }
.tile:hover.g-sky     { box-shadow: 0 12px 30px rgba(14,165,233,.48); }
.tile:hover.g-plum    { box-shadow: 0 12px 30px rgba(168,85,247,.48); }
.tile:hover.g-blue    { box-shadow: 0 12px 30px rgba(37,99,235,.5); }
.tile:hover.g-stone   { box-shadow: 0 12px 30px rgba(120,113,108,.46); }

/* ═══════════════ ساعة الرئيسية ═══════════════ */
/* تمتلئ بها المساحة الفارغة أسفل المربعات — أسفل يسار الشاشة */
.home { display: flex; flex-direction: column; min-height: calc(100vh - var(--top-h) - 32px); }
/* الساعة ومربع البصمة جنب بعض — أسفل يسار الشاشة (القائمة على اليمين) */
.hbot {
  margin-top: auto; align-self: flex-end;
  margin-bottom: var(--pend-space, 0px);
  display: flex; gap: 12px; align-items: stretch;
  transition: margin-bottom .2s ease;
}
.hclock {
  position: relative; overflow: hidden;
  width: 318px; padding: 16px 18px 14px;
  border-radius: 18px;
  background: linear-gradient(155deg, #16264a 0%, #101a33 55%, #0b1224 100%);
  box-shadow: 0 14px 34px rgba(8, 15, 35, .34), inset 0 1px 0 rgba(255, 255, 255, .07);
  color: #eaf1ff;
  direction: ltr;                            /* الأرقام والشعار يبدأون من اليسار */
  transition: margin-bottom .2s ease;
}
/* توهّج هادي يتنفّس خلف الأرقام — بدل الشريط المتحرك اللي كان يشتّت النظر */
.hc-glow {
  position: absolute; inset: -30% -10% auto -10%; height: 150%;
  pointer-events: none; border-radius: 50%;
  background: radial-gradient(60% 55% at 22% 40%, rgba(96, 165, 250, .3), transparent 70%);
  animation: hcBreathe 6s ease-in-out infinite;
}
@keyframes hcBreathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
.hc-top {
  display: flex; align-items: baseline; gap: 2px;
  direction: ltr; justify-content: flex-start;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
.hc-t {
  display: inline-block;
  font-size: 46px; font-weight: 800; line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 0 18px rgba(120, 170, 255, .45);
}
.hc-t.tick { animation: hcTick .5s ease-out; }
@keyframes hcTick {
  from { opacity: .25; transform: translateY(-8%); }
  to { opacity: 1; transform: none; }
}
.hc-c {
  font-size: 40px; font-weight: 700; line-height: 1; margin: 0 1px;
  color: #7dd3fc;
  animation: hcBlink 2s ease-in-out infinite;
}
@keyframes hcBlink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.hc-s.tick { animation: hcTick .5s ease-out; }
.hc-side { display: flex; align-items: center; gap: 6px; margin-left: 10px; align-self: flex-end; padding-bottom: 6px; }
.hc-s {
  font-size: 13px; font-weight: 700; padding: 2px 7px; border-radius: 7px;
  background: rgba(125, 211, 252, .16); color: #bae6fd;
  font-variant-numeric: tabular-nums;
}
.hc-ap { font-size: 12px; font-weight: 700; color: #93a7c9; }
.hc-date { direction: rtl; text-align: left; margin-top: 9px; font-size: 13px; color: #9fb3d4; }
.hc-brand {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.hc-brand img { width: 22px; height: 22px; border-radius: 6px; }
.hc-brand span { font-size: 16px; font-weight: 800; letter-spacing: .3px; }
.hc-brand small { font-size: 11.5px; color: #8fa3c4; }
@media (max-width: 860px) {
  .hbot { align-self: stretch; flex-wrap: wrap; padding-top: 0; }
  .hclock-wrap { flex: 1 1 240px; flex-direction: column; gap: 10px; }
  .hclock { width: auto; flex: 1 1 auto; }
  .hcalc { position: relative; bottom: auto; }
}

/* ═══════════════ زر الحاسبة فوق الساعة ═══════════════ */
/* مكانه محجوز بحشوة فوق الشريط السفلي — فما يغطّي المربعات مهما كثرت */
.hbot { padding-top: 56px; }
.hclock-wrap { position: relative; display: flex; }
.hcalc {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 10px);
  height: 46px; padding: 0 14px; overflow: hidden;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(125, 211, 252, .18); border-radius: 14px; cursor: pointer;
  color: #eaf1ff; text-align: right;
  background: linear-gradient(155deg, #1b2f5c 0%, #121d3a 60%, #0d1530 100%);
  box-shadow: 0 10px 24px rgba(8, 15, 35, .28), inset 0 1px 0 rgba(255, 255, 255, .07);
  transition: transform .18s cubic-bezier(.2, .8, .3, 1), box-shadow .2s, border-color .2s;
}
.hcalc:hover {
  transform: translateY(-2px); border-color: rgba(125, 211, 252, .4);
  box-shadow: 0 14px 30px rgba(8, 15, 35, .38), 0 0 0 3px rgba(96, 165, 250, .12);
}
.hcalc:active { transform: translateY(0) scale(.98); }
.hcalc b { font-size: 14.5px; font-weight: 800; }
.hcalc small { margin-inline-start: auto; font-size: 11.5px; color: #93a7c9; }
.hcalc-ic {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .45);
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.hcalc:hover .hcalc-ic { transform: rotate(-8deg) scale(1.08); }
/* لمعة تعبر الزر كل بضع ثوان — تلفت النظر بلا إزعاج */
.hcalc-shine {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .13) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: hcalcShine 5.5s ease-in-out infinite;
}
@keyframes hcalcShine { 0%, 62% { transform: translateX(-120%); } 82%, 100% { transform: translateX(120%); } }

/* ═══════════════ الحاسبة العائمة ═══════════════ */
.calc {
  position: fixed; z-index: 90; width: 318px;
  padding: 0 14px 14px; border-radius: 22px;
  color: #eaf1ff; outline: none;
  background:
    radial-gradient(120% 60% at 15% 0%, rgba(96, 165, 250, .16), transparent 60%),
    linear-gradient(160deg, #1a2c55 0%, #111c38 55%, #0b1226 100%);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 28px 70px rgba(5, 10, 25, .5), 0 4px 14px rgba(5, 10, 25, .3),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  transform-origin: 50% 80%;
  animation: calcIn .42s cubic-bezier(.2, .9, .25, 1.12);
  transition: border-color .2s, box-shadow .2s;
}
.calc:focus-within, .calc:focus {
  border-color: rgba(125, 211, 252, .32);
  box-shadow: 0 28px 70px rgba(5, 10, 25, .5), 0 0 0 4px rgba(96, 165, 250, .12),
    inset 0 1px 0 rgba(255, 255, 255, .08);
}
.calc.drag { transition: none; }
.calc.out { animation: calcOut .2s ease-in forwards; pointer-events: none; }
@keyframes calcIn {
  from { opacity: 0; transform: translateY(26px) scale(.86); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes calcOut { to { opacity: 0; transform: translateY(14px) scale(.9); filter: blur(4px); } }

.calc-hd {
  display: flex; align-items: center; gap: 8px;
  margin: 0 -14px; padding: 11px 14px 9px;
  cursor: grab; user-select: none; touch-action: none;
}
.calc.drag .calc-hd { cursor: grabbing; }
.calc-hd b { font-size: 14px; font-weight: 800; }
.calc-logo {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px;
  color: #fff; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}
.calc-kb { font-size: 11px; color: #7f93b8; }
.calc-x {
  margin-inline-start: auto; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 9px; cursor: pointer; color: #b8c6e0;
  background: rgba(255, 255, 255, .06);
  transition: background .15s, color .15s, transform .2s;
}
.calc-x:hover { background: rgba(244, 63, 94, .85); color: #fff; transform: rotate(90deg); }

.calc-scr {
  direction: ltr; text-align: right; cursor: copy;
  margin-bottom: 12px; padding: 12px 14px 10px; border-radius: 15px;
  background: rgba(3, 8, 20, .45);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .04);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  overflow: hidden;
}
.calc-top {
  min-height: 19px; font-size: 13.5px; color: #8fa3c4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calc-top.live { color: #7dd3fc; }
.calc-main {
  font-size: 38px; font-weight: 800; line-height: 1.2; letter-spacing: -.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 18px rgba(120, 170, 255, .35);
  transition: font-size .15s;
}
.calc-main.sm { font-size: 27px; }
.calc-main.xs { font-size: 20px; }
.calc-main.pop { animation: calcPop .35s cubic-bezier(.3, 1.5, .5, 1); }
.calc-main.err { color: #fda4af; direction: rtl; text-align: left; animation: calcShake .4s; }
@keyframes calcPop { from { transform: scale(.88); opacity: .4; } }
@keyframes calcShake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.calc-pad { direction: ltr; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ck {
  position: relative; overflow: hidden;
  height: 52px; border: 0; border-radius: 14px; cursor: pointer;
  display: grid; place-items: center;
  font: inherit; font-size: 20px; font-weight: 700; color: #eaf1ff;
  background: rgba(255, 255, 255, .065);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: background .15s, transform .12s cubic-bezier(.2, .8, .3, 1), box-shadow .15s;
}
.ck:hover { background: rgba(255, 255, 255, .12); }
.ck:active, .ck.hit { transform: scale(.92); background: rgba(255, 255, 255, .18); }
.ck[data-k="000"] { font-size: 16px; letter-spacing: .5px; }
.ck.fn { color: #c7d2fe; background: rgba(148, 163, 184, .14); font-size: 17px; }
.ck.fn:hover { background: rgba(148, 163, 184, .24); }
.ck.fn[data-k="ac"] { color: #fda4af; background: rgba(244, 63, 94, .14); }
.ck.fn[data-k="ac"]:hover { background: rgba(244, 63, 94, .24); }
.ck.op { color: #7dd3fc; background: rgba(56, 189, 248, .13); font-size: 23px; }
.ck.op:hover { background: rgba(56, 189, 248, .24); }
.ck.eq {
  color: #fff; font-size: 24px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  box-shadow: 0 8px 20px rgba(99, 102, 241, .45), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.ck.eq:hover { background: linear-gradient(135deg, #4f8ff7, #9a6cf7); }
.ck.eq:active, .ck.eq.hit { background: linear-gradient(135deg, #2f6fe0, #7c4fe0); }
/* تموّج خفيف من مكان الضغطة */
.ck::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .28) 0%, transparent 60%);
  opacity: 0; transform: scale(.3);
}
.ck:active::after, .ck.hit::after { animation: ckRipple .35s ease-out; }
@keyframes ckRipple { from { opacity: 1; transform: scale(.3); } to { opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) {
  .calc, .calc.out, .calc-main.pop, .hcalc-shine, .ck::after { animation: none !important; }
}

/* ═══════════════ مربع بصمة الحضور ومربع واتساب ═══════════════ */
.hbio, .hwa {
  position: relative; overflow: hidden;
  width: 168px; padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; cursor: pointer; text-align: center; color: #ecfdf5;
  border-radius: 18px;
  background: linear-gradient(155deg, #0f766e 0%, #115e59 55%, #0b3d3a 100%);
  box-shadow: 0 14px 34px rgba(13, 90, 84, .34), inset 0 1px 0 rgba(255, 255, 255, .09);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1), box-shadow .2s;
}
.hbio:hover, .hwa:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(13, 90, 84, .46); }
.hbio:active, .hwa:active { transform: translateY(0); }
.hbio b, .hwa b { font-size: 14.5px; font-weight: 800; margin-top: 4px; }
.hbio small, .hwa small { font-size: 11px; color: #a7f3d0; line-height: 1.5; }
/* واتساب بأخضره المعروف حتى يُعرف بلمحة */
.hwa {
  color: #f0fdf4;
  background: linear-gradient(155deg, #16a34a 0%, #15803d 55%, #0c3d21 100%);
  box-shadow: 0 14px 34px rgba(14, 100, 45, .34), inset 0 1px 0 rgba(255, 255, 255, .1);
}
.hwa:hover { box-shadow: 0 18px 40px rgba(14, 100, 45, .48); }
.hwa small { color: #bbf7d0; }
.hwa .bio-ic { color: #dcfce7; }
.hwa .bio-ring { border-color: rgba(187, 247, 208, .5); }
.hbio-go {
  margin-top: 7px; padding: 3px 9px; border-radius: 8px; font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
}
.hbio-go:hover { background: rgba(255, 255, 255, .3); }
.bio-ic { display: grid; place-items: center; color: #d1fae5; }
/* حلقة تنبض حول البصمة — تدلّ إنها زر حيّ */
.bio-ring {
  position: absolute; top: 50%; left: 50%; width: 108px; height: 108px;
  transform: translate(-50%, -50%); margin-top: -8px;
  border-radius: 50%; border: 1.5px solid rgba(167, 243, 208, .5);
  pointer-events: none; animation: bioPulse 2.8s ease-out infinite;
}
@keyframes bioPulse {
  0% { opacity: .55; transform: translate(-50%, -50%) scale(.72); }
  70% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; }
}

/* ═══════════════ شاشة الحضور ═══════════════ */
.att-top { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.att-top .grow { flex: 1 1 420px; }
.bio-pad {
  position: relative; overflow: hidden; flex: 0 0 auto;
  width: 268px; padding: 20px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; cursor: pointer; text-align: center; color: #ecfdf5;
  border-radius: var(--r-lg);
  background: linear-gradient(155deg, #0f766e 0%, #115e59 55%, #0b3d3a 100%);
  box-shadow: 0 12px 30px rgba(13, 90, 84, .32);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1), box-shadow .2s;
}
.bio-pad:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(13, 90, 84, .44); }
.bio-pad b { font-size: 16px; font-weight: 800; margin-top: 6px; }
.bio-pad small { font-size: 11.5px; color: #a7f3d0; line-height: 1.6; }
.bio-pad .bio-ring { width: 150px; height: 150px; margin-top: -14px; }
/* البطاقات بطول زر البصمة، والجداول بأعمدة ثابتة متوسّطة تحت عناوينها */
.att-top .bio-pad { width: 240px; padding: 16px; }
.att-top #kpis { align-content: stretch; align-items: stretch; }
.att-top .kpi { padding: 16px 18px; }
.att-top .kpi .vl { font-size: 30px; margin: 10px 0 6px; }
.att-day { min-height: 34px; height: 34px; width: 160px; }
.att-pair { align-items: stretch; }
/* جدول بأعمدة ثابتة: الأول (الاسم) ياخذ الباقي، والبقية متوسّطة تحت عناوينها */
table.tbl.att-tbl, table.tbl.fix-tbl { table-layout: fixed; }
table.tbl:is(.att-tbl, .fix-tbl) :is(th, td):not(:first-child) { text-align: center; }
table.tbl:is(.att-tbl, .fix-tbl) td.act { text-align: left; width: auto; }
table.tbl:is(.att-tbl, .fix-tbl) td:first-child { overflow-wrap: anywhere; }
.inp.sm-inp { width: 80px; height: 34px; min-height: 34px; text-align: center; }
.att-tbl .tnum { font-variant-numeric: tabular-nums; }
/* تقييم المخزون: خمس بطاقات بسطر، فلاتر مضغوطة، وبطاقات المجموعات تنضغط للفلترة */
.sv-kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.sv-filters { padding-bottom: 8px; }
.sv-filters .inp { height: 34px; min-height: 34px; width: auto; min-width: 150px; }
.sv-filters .sv-q { min-width: 220px; }
.sv-filters .sv-p { min-width: 0; width: 110px; }
.sv-filters select.inp { padding-top: 0; padding-bottom: 0; }
.sv-cats { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 0; }
.sv-cat { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 150px;
  padding: 8px 12px; border: 1px solid var(--border-soft); border-radius: var(--r); background: var(--surface-2); cursor: pointer; text-align: start; }
.sv-cat:hover { border-color: var(--primary); }
.sv-cat span { font-weight: 700; color: var(--primary); }
.sv-cat small { color: var(--text-3); font-size: 11.5px; }
.sv-pager { border-top: 1px solid var(--border-soft); padding-top: 8px; padding-bottom: 8px; }
/* اسم قابل للضغط يفتح تفاصيله (كشف سلف الموظف) */
.hr-link { cursor: pointer; color: var(--primary); }
.hr-link:hover { text-decoration: underline; }
/* إعدادات واتساب: كلها بسطر واحد، والرسالتان جنب بعض بنفس الارتفاع */
.wa-set { display: grid; grid-template-columns: auto 140px 200px minmax(240px, 1fr); gap: 12px 20px; align-items: end; }
.wa-set .switches { align-self: center; }
@media (max-width: 1100px) { .wa-set { grid-template-columns: 1fr 1fr; } }
.wa-tpl { height: 340px; line-height: 1.8; resize: vertical; }
.bio-modal { text-align: center; }
.bio-modal .bio-ic { color: var(--primary); margin-bottom: 6px; }
.inp.center { text-align: center; letter-spacing: 6px; text-indent: 6px; }
/* شريط عمليات المحدد: يبقى محجوزاً بالمكان فما يتزحلق الجدول */
.selbar.off { visibility: hidden; }

/* زر واتساب بالجداول */
.btn.wa { background: #16a34a; border-color: #15803d; color: #fff; font-weight: 600; }
.btn.wa:hover:not(:disabled) { background: #15803d; }
.btn.wa:disabled { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
.btn.hold { background: #f59e0b; border-color: #d97706; color: #1f1300; font-weight: 600; }
.btn.hold:hover:not(:disabled) { background: #d97706; color: #fff; }
.btn.hold .kb { background: rgba(0,0,0,.12); border-color: rgba(0,0,0,.15); color: inherit; }
#btnHeld .tag { background: #f59e0b; color: #1f1300; font-weight: 700; min-width: 22px; justify-content: center; }
td.bad-txt, .bad-txt { color: var(--bad); }
/* أرقام الهواتف داخل نص عربي: العنصر السطري يحتاج isolate وإلا انعكس ترتيب المجموعات */
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.tag.block-tag {
  display: block; white-space: normal; line-height: 1.7; padding: 9px 11px; text-align: start;
}

/* محرّر المربعات بالإعدادات */
.tlist { display: flex; flex-direction: column; gap: 6px; }
.trow {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border: 1px solid var(--border-soft);
  border-radius: var(--r); background: var(--surface);
}
.trow .spacer { flex: 1 1 auto; }
.trow.brk { background: var(--surface-2); border-style: dashed; }
.trow.brk .tnm { flex: 0 1 auto; overflow: hidden; white-space: nowrap; }
.trow .btn.sm { min-height: 30px; padding: 4px 8px; }
.trow .btn[disabled] { opacity: .3; pointer-events: none; }
.tsw {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 8px;
  display: grid; place-items: center; color: #fff;
}
.tnm { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.tnm small { font-size: 11.5px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw {
  width: 34px; height: 26px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; box-shadow: none !important;
}
.sw.on { border-color: var(--text); }
.icgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.icb {
  min-height: 38px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 7px; cursor: pointer; color: var(--text-2);
  display: grid; place-items: center;
}
.icb:hover { background: var(--surface-2); }
.icb.on { border-color: var(--primary-600); background: var(--primary-50); color: var(--primary); }

/* ═══════════════ شاشة فاتورة مبيع ═══════════════ */
/* الاسم pos-wrap لا pos — الأخير كان يتصادم مع بطاقة الأرقام ذات الحالة
   الموجبة (class="kpi pos") فتأخذ display:flex وارتفاع الشاشة كاملة */
.pos-wrap { display: flex; gap: 8px; height: calc(100vh - var(--top-h) - 32px); }
.pos-left { width: 300px; flex: 0 0 300px; display: flex; flex-direction: column; gap: 6px; }
/* لوحة الدفع مضغوطة: الإجمالي ثابت فوق الأزرار ويبقى ظاهراً دائماً */
.pos-left .pay-fields { padding: 10px 12px; }
.pos-left .pay-actions { flex: 0 0 auto; border-top: 1px solid var(--border-soft); padding: 8px 12px 10px; }
.pos-left .pay-actions .totals { border-top: 0; padding-top: 0; margin-bottom: 8px; }
.pos-left .pay-actions .totals .ln.big { font-size: 20px; padding-top: 4px; margin-top: 2px; }
.pos-left .btn.lg { min-height: 42px; padding: 0 12px; font-size: 15px; }
.pos-left #btnSave.btn.lg { min-height: 48px; font-size: 17px; }
.pos-left .mt { margin-top: 6px; }
.pos-left .btn.sm, .pos-left .row.tight .btn { min-height: 34px; padding: 0 8px; font-size: 13px; }
.pos-left .hint:empty, #recvOut:empty { display: none; }
.pos-right { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* ─────── لوحة البيع السريع — مربعات تضيف مادة بضغطة وحدة ─────── */
/* أول عنصر داخل pos-wrap (RTL) = أقصى اليمين، جنب قائمة المواد مباشرة */
.pos-tiles { width: 234px; flex: 0 0 234px; display: flex; flex-direction: column;
  overflow: hidden; }
.pos-tiles .hd { gap: 8px; }
.qtile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  padding: 10px; overflow-y: auto; align-content: start; }
.qtile {
  position: relative; overflow: hidden; border: 0; border-radius: 13px;
  min-height: 72px; padding: 9px 10px 8px; color: #fff; text-align: right;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 3px;
  cursor: pointer; touch-action: manipulation;
  transition: transform .12s cubic-bezier(.3,.8,.4,1), box-shadow .18s, filter .18s;
}
.qtile::before { content: ''; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,.24), rgba(255,255,255,0) 55%);
  pointer-events: none; }
.qtile:hover { transform: translateY(-2px); filter: saturate(1.1); }
.qtile:active { transform: scale(.95); }
.qtile:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.qtile .qn { font-size: 12.5px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qtile .qp { font-size: 11.5px; font-weight: 600; opacity: .92; }
/* نبضة تأكيد الإضافة — خضراء سريعة تختفي، تؤكد إن الضغطة سجّلت بلا ما تعطّل التتابع */
@keyframes qtileZap {
  0% { box-shadow: inset 0 0 0 3px rgba(255,255,255,.9), 0 8px 22px rgba(5,150,105,.4); }
  100% { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
}
.qtile.zap { animation: qtileZap .38s ease-out; }
/* وضع التعديل: زر حذف علوي + مربع «أضف مادة» متقطّع الحدود بآخر الشبكة */
.qtile-x { position: absolute; top: 4px; left: 4px; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(15,23,42,.55); color: #fff; display: grid; place-items: center;
  cursor: pointer; line-height: 1; }
.qtile-x:hover { background: var(--bad); }
.qtile-add { border: 2px dashed var(--border); border-radius: 13px; min-height: 72px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--text-3); background: var(--surface-2); cursor: pointer;
  font-size: 12px; font-weight: 600; transition: border-color .15s, color .15s; }
.qtile-add:hover { border-color: var(--primary-600); color: var(--primary-600); }
.qtile-empty { padding: 22px 14px; text-align: center; color: var(--text-3); }
.qtile-empty svg { opacity: .5; }
.qtile-empty .mt { font-size: 12.5px; margin-top: 8px; line-height: 1.6; }
@media (max-width: 1180px) { .pos-tiles { display: none; } }

/* قائمة المواد وخانة المسح بنفس البطاقة — كل بكسل يروح لجدول المواد */
.cart-card { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.scan-box { display: flex; gap: 8px; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft); }
.scan-box .inp { min-height: 38px; font-size: 15px; }
.scan-box .tag { min-width: 26px; justify-content: center; }
.hit-info { padding: 0 12px 4px; }
.hit-info:empty { display: none; }

/* رأس الفاتورة — سطران مضغوطان بلا عناوين */
.inv-head .bd { padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.ih-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ih-row > * { flex: 0 0 auto; }
.ih-row > .grow { flex: 1 1 0; }
.ih-row > #refNo { width: 110px; }
.ih-row > .igrp { margin-inline-start: auto; }
.inv-head .inp { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.inv-head select.inp { min-height: 30px; }
.inv-head .seg button { min-height: 28px; padding: 3px 14px; }
.inv-head .btn { min-height: 30px; padding: 4px 8px; }
.inv-head .pager { width: 160px; }
.inv-head #invDate { width: 132px; }
.igrp { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: var(--surface); }
.igrp .inp { border: 0; border-radius: 0; min-width: 0; }
.igrp select.inp { width: 72px; }
.igrp input.inp { width: 70px; }
.igrp > span { display: flex; align-items: center; padding: 0 7px; font-size: 11.5px;
  color: var(--text-3); background: var(--surface-2);
  border-inline: 1px solid var(--border-soft); }
/* فاتورة مرتجع: شريط برتقالي أعلى الرأس يميّزها بلمحة */
.pos-wrap.is-return .inv-head { border-top: 3px solid var(--accent); }
.pos-wrap.is-return .inv-head::before {
  content: 'فاتورة مرتجع'; display: block;
  background: var(--accent-50); color: #a35c05;
  font-size: 12px; font-weight: 700; padding: 5px 14px;
  border-bottom: 1px solid var(--border-soft);
}

/* بانر تعديل فاتورة محفوظة — يظهر أعلى شاشة البيع أثناء التعديل */
.edit-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary-50); color: var(--primary);
  border: 1px solid var(--primary-600); border-radius: 8px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 10px;
}
.edit-banner .dim { font-weight: 400; color: var(--text-2); }

/* أزرار البيع كبيرة وواضحة */
#btnSave, #btnSavePrint { min-height: 58px; font-size: 17px; }
#btnSave b { font-size: 20px; }

/* شارة الاختصار على الزر — مظللة وواضحة بلا ما تسحب النظر من النص */
kbd.kb {
  font-family: Consolas, monospace;
  font-size: 11.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .34);
  color: inherit; line-height: 1.5;
  margin-inline-start: 4px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .14);
}
.btn:not(.p):not(.ok):not(.a):not(.bad) kbd.kb {
  background: var(--surface-2); border-color: var(--border); color: var(--text-2);
}

/* وميض قصير يبيّن أن ضغطة F1/F2 وصلت فعلاً */
.btn.flash {
  animation: kbflash .26s ease;
}
@keyframes kbflash {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); }
  45% { transform: scale(.985); box-shadow: 0 0 0 6px rgba(255, 255, 255, .28); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* ترقيم صفوف مواد الفاتورة */
table.cart td.rowno {
  text-align: center; color: var(--text-3);
  font-size: 12px; font-weight: 700;
  background: var(--surface-2);
}

/* الفاتورة الملغاة بالقوائم */
table.tbl tr.voided td { opacity: .58; text-decoration: line-through; }
table.tbl tr.voided td:first-child, table.tbl tr.voided td.act { text-decoration: none; opacity: 1; }

/* نتائج البحث كقائمة منسدلة فوق المحتوى — المواد المضافة تبقى ظاهرة أسفل البحث */
.hitbox {
  position: absolute; z-index: 40; top: calc(100% + 4px); right: 0; left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  max-height: 320px; overflow: auto;
  animation: pop .12s ease-out;
}
.hit {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.hit:last-child { border-bottom: 0; }
.hit:hover, .hit.cur { background: var(--primary-50); }
.hit .nm { flex: 1 1 auto; min-width: 0; }
.hit .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit .nm small { color: var(--text-3); font-size: 11.5px; }
.hit .pr { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.hit .qt { font-size: 12px; min-width: 62px; text-align: left; }

.cart-wrap { flex: 1 1 auto; overflow: auto; min-height: 120px; }
table.cart { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.cart th { position: sticky; top: 0; background: var(--surface-2); font-size: 11.5px; color: var(--text-2); padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); }
table.cart td { padding: 5px 8px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
/* كل الأعمدة بعد اسم المادة: العنوان بالوسط فوق خانته، والخانة تملأ عرض عمودها */
table.cart { table-layout: fixed; }
.cart-card .cart-wrap { overflow-x: hidden; }
table.cart th:not(:nth-child(-n+2)) { text-align: center; }
table.cart td:not(:nth-child(-n+2)) { padding-inline: 4px; }
table.cart .ln-name { overflow-wrap: anywhere; line-height: 1.35; }
table.cart .cinfo { padding: 0 3px; font-size: 12.5px; }
table.cart .qty-in, table.cart .prc-in, table.cart .dsc-in { width: 100%; text-align: center; min-height: 34px; padding: 4px; }
table.cart .prc-in { direction: ltr; }
table.cart .ln-tot { font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
table.cart .x { border: 0; background: none; color: var(--bad); padding: 4px 6px; border-radius: 6px; line-height: 1; }
table.cart .x:hover { background: var(--bad-50); }

/* حقول الخصم والملاحظات وطريقة الدفع بيسار شاشة البيع — مضغوطة، لأن
   الإجمالي وزرّي البيع هي المهمّة هنا لا هذي الحقول الثانوية */
.pay-fields .f { gap: 3px; }
.pay-fields .f > label { font-size: 11.5px; }
.pay-fields .mt { margin-top: 8px; }
.pay-fields .inp { min-height: 34px; padding: 6px 9px; }
.pay-fields .seg.block button { min-height: 32px; }
.pay-fields .hint { font-size: 11.5px; }

.totals { border-top: 2px solid var(--border); padding-top: 10px; }
.totals .ln { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; font-size: 14px; }
.totals .ln.big { font-size: 22px; font-weight: 700; padding-top: 8px; margin-top: 4px; border-top: 1px dashed var(--border); }
.totals .ln.big .v { color: var(--primary); }
.totals .ln .v { font-variant-numeric: tabular-nums; direction: ltr; }
.totals .usd { font-size: 13px; color: var(--text-3); }

/* ═══════════════ نوافذ منبثقة ═══════════════ */
.ov {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } }
.modal.wide { max-width: 900px; }
.modal.xwide { max-width: 1180px; }
/* معاينة فاتورة A4 داخل النافذة — الورقة كاملة بخلفية رمادية مثل عارض PDF */
.a4-prev { background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--r); padding: 10px; height: min(66vh, 720px); }
.a4-prev iframe { width: 100%; height: 100%; border: 0; background: #fff;
  border-radius: 4px; box-shadow: var(--shadow); }
.modal .hd { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 10px; }
.modal .hd b { font-size: 16px; }
.modal .hd .spacer { flex: 1 1 auto; }
.modal .bd { padding: 16px; overflow: auto; flex: 1 1 auto; }
.modal .ft { padding: 12px 16px; border-top: 1px solid var(--border-soft); display: flex; gap: 8px; justify-content: flex-start; }
.modal .ft .spacer { flex: 1 1 auto; }

/* تنبيهات */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #101a33; color: #fff;
  padding: 11px 15px; border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 14px; max-width: 420px;
  display: flex; align-items: center; gap: 9px;
  animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(-16px); opacity: 0; } }
.toast.ok { background: #046c52; }
.toast.bad { background: #b3211d; }
.toast.warn { background: #9a5404; }

/* شريط تحميل رقيق فوق */
#load { position: fixed; top: 0; right: 0; left: 0; height: 3px; z-index: 400; background: transparent; overflow: hidden; }
#load.on::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--primary-600), transparent);
  animation: bar .9s linear infinite;
}
@keyframes bar { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* اقتراحات البحث — معلَّقة على body بموضع ثابت حتى لا تقصّها البطاقات */
.ac { position: relative; }
/* قائمة الاقتراحات: ظل خفيف محصور بحدود القائمة. الظل الكبير كان يمتدّ
   تحتها كبقعة داكنة تبيّن كأنها جزء من الشاشة، خصوصاً فوق المساحات الفارغة. */
.ac-list {
  position: fixed; z-index: 800;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .10), 0 0 0 1px rgba(15, 23, 42, .04);
  max-height: 260px; overflow: auto;
  animation: pop .12s ease-out;
}
.ac-list div { padding: 9px 11px; cursor: pointer; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.ac-list div + div { border-top: 1px solid var(--border-soft); }
.ac-list div:hover, .ac-list div.cur { background: var(--primary-50); }
.ac-list div .spacer { flex: 1 1 auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════ شاشة الدخول والقفل ═══════════════ */
.authwrap {
  --a-text: #eef2f9;
  --a-text-2: #a3b2cb;
  --a-text-3: #7486a6;
  --a-key: rgba(255, 255, 255, .075);
  --a-key-h: rgba(255, 255, 255, .13);
  --a-or: #f97316;
  --a-or-2: #e84a0a;
  --a-k: clamp(54px, 8.2vh, 74px);
  position: fixed; inset: 0; z-index: 900;
  display: flex; flex-direction: column; align-items: center;
  overflow: auto; overscroll-behavior: contain;
  padding: max(14px, 2.5vh) 16px 12px;
  color: var(--a-text);
  background:
    radial-gradient(60vmax 50vmax at 88% -10%, rgba(232, 74, 10, .26), transparent 60%),
    radial-gradient(55vmax 45vmax at -5% 110%, rgba(37, 99, 235, .24), transparent 62%),
    radial-gradient(40vmax 30vmax at 50% 50%, rgba(30, 47, 87, .55), transparent 70%),
    linear-gradient(160deg, #0a1229 0%, #111d3d 55%, #0a1229 100%);
  -webkit-tap-highlight-color: transparent;
}
.authwrap { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.authwrap.ok, .authwrap.leave { pointer-events: none; }
/* الواجهة خلف الشاشة ما توسّع الصفحة على الموبايل */
body:has(> .authwrap) .app { max-width: 100vw; overflow: hidden; }
.authwrap.leave { animation: authOut .38s ease forwards; }
.authwrap.leave .authbox { transform: scale(1.03); transition: transform .38s ease; }

.authstage { flex: 1 0 auto; width: 100%; display: flex; align-items: center; justify-content: center; }

/* لوحة زجاجية بلا حدود — تندمج مع الخلفية */
.authbox {
  width: min(100%, 392px);
  padding: clamp(18px, 3.2vh, 30px) clamp(18px, 4vw, 30px) clamp(18px, 3vh, 26px);
  border-radius: 30px;
  background: linear-gradient(165deg, rgba(255, 255, 255, .085), rgba(255, 255, 255, .03));
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(2, 6, 23, .42), inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: authIn .55s cubic-bezier(.2, .8, .2, 1) both;
}
.authbox > *, .sig { animation: authUp .5s cubic-bezier(.2, .8, .2, 1) both; }
.authbox > :nth-child(2) { animation-delay: .06s; }
.authbox > :nth-child(3) { animation-delay: .11s; }
.authbox > :nth-child(4) { animation-delay: .16s; }
.authbox > :nth-child(n+5) { animation-delay: .2s; }
.sig { animation-delay: .3s; }

@keyframes authIn { from { opacity: 0; transform: scale(.94); } }
@keyframes authUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes authOut { to { opacity: 0; } }

.authbrand { text-align: center; margin-bottom: clamp(10px, 2vh, 18px); }
.authlogo {
  display: block; width: clamp(80px, 12.5vh, 128px); height: auto; aspect-ratio: 1;
  margin: 0 auto 8px;
  border-radius: 24%;
  object-fit: contain;
  box-shadow: 0 14px 40px rgba(232, 74, 10, .38), 0 0 0 6px rgba(249, 115, 22, .07);
}
.authbrand .shoplogo {
  display: block; max-height: 40px; max-width: 60%;
  margin: 10px auto 4px; object-fit: contain;
}
.authsub { font-size: 15.5px; color: var(--a-text); margin-top: 2px; font-weight: 600; letter-spacing: .2px; opacity: .92; }

.authbox h2 { font-size: 16px; margin: 0 0 8px; font-weight: 600; text-align: center; color: var(--a-text); }
.pinlbl { font-size: 12.5px; color: var(--a-text-3); text-align: center; margin-top: 4px; }

/* حقل الرمز: نقاط تفاعلية، والحقل الحقيقي شفاف فوقها (type=text دائماً
   حتى لا يتدخّل مدير كلمات المرور بالمتصفح) */
.pinrow { position: relative; min-height: 52px; display: flex; align-items: center; justify-content: center; }
.pinrow::after {
  content: ''; position: absolute; bottom: 2px; left: 28%; right: 28%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(249, 115, 22, .75), transparent);
  opacity: 0; transition: opacity .25s;
}
.pinrow:focus-within::after { opacity: 1; }
.pinin {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; font-size: 16px;
  cursor: text; z-index: 1;
}
.pindots {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; direction: ltr; padding: 0 44px; min-height: 40px;
}
.pindots.many { gap: 8px; }
.pindots i {
  flex: none; width: 14px; height: 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .13);
  display: grid; place-items: center;
  font-style: normal; font-size: 0; color: #fff;
  transition: background .2s, box-shadow .2s, width .2s, height .2s;
}
.pindots.many i { width: 11px; height: 11px; }
.pindots i.on {
  background: linear-gradient(135deg, #fb923c, var(--a-or-2));
  box-shadow: 0 0 14px rgba(249, 115, 22, .55);
}
.pindots i.pop { animation: dotPop .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes dotPop { 0% { transform: scale(.35); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
/* إظهار الرمز: الخانات تتحوّل لكبسولات فيها الرقم */
.pinrow.show .pindots i.on {
  width: auto; min-width: 24px; height: 32px; padding: 0 6px; border-radius: 10px;
  font-size: 18px; font-weight: 700;
  font-family: Consolas, 'Courier New', ui-monospace, monospace;
}
.pinrow.show .pindots.many i.on { min-width: 18px; height: 28px; font-size: 15px; padding: 0 3px; }
.authwrap.bad .pindots i.on { background: #ef4444; box-shadow: 0 0 14px rgba(239, 68, 68, .6); }
.authwrap.ok .pindots i.on {
  background: #22c55e; box-shadow: 0 0 16px rgba(34, 197, 94, .6);
  animation: dotPop .3s cubic-bezier(.3, 1.6, .5, 1);
}

.pinrow .eye {
  position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 2px; z-index: 2;
  border: 0; background: none; color: var(--a-text-3);
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.pinrow .eye:hover { background: rgba(255, 255, 255, .08); color: var(--a-text); }

.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both !important; }
@keyframes shake {
  15%, 85% { transform: translateX(-3px); }
  30%, 70% { transform: translateX(7px); }
  45%, 55% { transform: translateX(-9px); }
  50% { transform: translateX(9px); }
}
.authwrap.bad .authbox { box-shadow: 0 30px 80px rgba(2, 6, 23, .42), 0 0 0 1px rgba(239, 68, 68, .25), 0 0 60px rgba(239, 68, 68, .18), inset 0 1px 0 rgba(255, 255, 255, .07); }

/* لوحة الأرقام: كبسولات دائرية شبه شفافة */
.pinpad {
  display: grid; grid-template-columns: repeat(3, var(--a-k)); justify-content: center;
  gap: clamp(9px, 1.5vh, 15px) clamp(16px, 5vw, 26px);
  margin-top: clamp(10px, 1.8vh, 16px);
}
.pinpad button {
  position: relative; overflow: hidden;
  width: var(--a-k); height: var(--a-k); border-radius: 50%;
  border: 0; background: var(--a-key); color: var(--a-text);
  font-size: calc(var(--a-k) * .37); font-weight: 500;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  display: grid; place-items: center;
  touch-action: manipulation; user-select: none;
  transition: background .15s, transform .12s cubic-bezier(.3, 1.4, .5, 1);
}
.pinpad button:hover { background: var(--a-key-h); }
.pinpad button:active { transform: scale(.9); background: rgba(249, 115, 22, .24); }
.pinpad button.alt { background: transparent; box-shadow: none; font-size: 14.5px; color: var(--a-text-2); }
.pinpad button.alt:hover { background: rgba(255, 255, 255, .06); color: var(--a-text); }
.pinpad button:focus-visible { outline: 2px solid rgba(249, 115, 22, .8); outline-offset: 2px; }
.rip {
  position: absolute; width: 100%; aspect-ratio: 1; margin: -50% 0 0 -50%;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 70%);
  transform: scale(0); animation: rip .5s ease-out forwards;
}
@keyframes rip { to { transform: scale(2.4); opacity: 0; } }

.autherr { min-height: 20px; margin-top: 10px; font-size: 13px; color: #fca5a5; text-align: center; line-height: 1.6; }

.authwrap .btn.p {
  margin-top: 6px; min-height: clamp(48px, 6.6vh, 56px);
  border: 0; border-radius: 18px; color: #fff; font-size: 17px; font-weight: 600;
  background: linear-gradient(135deg, var(--a-or) 0%, var(--a-or-2) 100%);
  box-shadow: 0 12px 30px rgba(232, 74, 10, .32), inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .12s, box-shadow .2s, filter .2s;
  touch-action: manipulation;
}
.authwrap .btn.p:hover { filter: brightness(1.07); box-shadow: 0 14px 36px rgba(232, 74, 10, .42), inset 0 1px 0 rgba(255, 255, 255, .22); }
.authwrap .btn.p:active { transform: scale(.98); }
.authwrap .btn.p:disabled { filter: saturate(.7); opacity: .8; cursor: default; }
.authwrap.ok .btn.p { background: linear-gradient(135deg, #22c55e, #16a34a); box-shadow: 0 12px 30px rgba(22, 163, 74, .3); }

/* شاشات قصيرة عريضة (كاشير باللمس): الشعار يسار والإدخال يمين */
@media (min-width: 760px) and (max-height: 640px) {
  .authwrap { --a-k: clamp(50px, 10.5vh, 66px); }
  .authbox {
    width: min(100%, 720px);
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 34px; align-items: center;
  }
  .authbox > * { grid-column: 2; }
  .authbox > .authbrand { grid-column: 1; grid-row: 1 / span 6; margin: 0; }
  .authlogo { width: clamp(96px, 26vh, 150px); }
}

/* النسخة التجريبية: دخول بضغطة */
.demo-quick { display: flex; gap: 10px; margin-top: 12px; }
.demo-quick button {
  flex: 1; min-height: 44px; border: 0; border-radius: 14px;
  background: rgba(255, 255, 255, .08); color: var(--a-text);
  font-size: 13.5px; font-weight: 600; touch-action: manipulation;
  transition: background .15s, transform .12s;
}
.demo-quick button b { font-family: Consolas, monospace; color: #fdba74; letter-spacing: 1px; margin-inline-start: 4px; }
.demo-quick button:hover { background: rgba(255, 255, 255, .14); }
.demo-quick button:active { transform: scale(.97); }

.authwrap:has(.demo-quick) { --a-k: clamp(48px, 6.8vh, 70px); }
.authwrap:has(.demo-quick) .authlogo { width: clamp(72px, 11vh, 120px); }
/* بالنسخة التجريبية رقم الإصدار يفسح مكانه للشارة */
html.demo .side-foot > #footVer { display: none; }

/* شارة النسخة التجريبية بأسفل القائمة الجانبية */
.demo-badge {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex: 1 1 auto; min-width: 0; padding: 5px 5px 5px 10px; border-radius: 12px;
  background: rgba(249, 115, 22, .12); color: #fed7aa; font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.demo-badge a {
  color: #fff; text-decoration: none; padding: 4px 11px; border-radius: 9px;
  background: linear-gradient(135deg, #f97316, #e84a0a);
}
.demo-badge a:hover { filter: brightness(1.08); }

/* ═══ توقيع Andalus Cloud أسفل الشاشة ═══ */
.sig { flex: none; margin-top: clamp(10px, 1.8vh, 22px); text-align: center; opacity: .62; transition: opacity .25s; }
.sig:hover { opacity: .95; }
.sig-line {
  height: 1px; margin: 0 auto 10px; width: 150px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
}
.sig-name {
  font-size: 15px; font-weight: 600; letter-spacing: 1px;
  color: var(--a-text); line-height: 1.2;
}
.sig-name span { color: #fb923c; font-weight: 700; }
.sig-tags {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 5px;
  font-size: 11.5px; color: var(--a-text-2);
}
.sig-tags i {
  width: 3px; height: 3px; border-radius: 50%;
  background: #fb923c; opacity: .7; flex: 0 0 auto;
}
.sig-tel {
  display: inline-block; margin-top: 7px;
  font-size: 12.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: .6px;
  color: var(--a-text-2);
  background: rgba(255, 255, 255, .05);
  border-radius: 999px;
  padding: 3px 12px;
}

/* عرض رموز الحسابات للمدير */
.pinval {
  font-family: Consolas, monospace;
  font-size: 15px; font-weight: 700; letter-spacing: 2px;
  color: var(--primary); direction: ltr; display: inline-block;
  background: var(--primary-50); border: 1px solid #cfe0fb;
  padding: 1px 8px; border-radius: 5px;
}
.pinval.hid { -webkit-text-security: disc; text-security: disc; letter-spacing: 3px; }
.curpin {
  font-family: Consolas, monospace;
  font-size: 22px; font-weight: 700; letter-spacing: 4px;
  color: var(--primary); direction: ltr; text-align: center;
  background: var(--primary-50); border: 1px solid #cfe0fb;
  padding: 8px; border-radius: var(--r);
}

/* بطاقة الحساب بالقائمة الجانبية + قائمة منسدلة */
.acct { position: relative; margin: 8px; }
.acct-btn {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border: 0;
  background: rgba(255, 255, 255, .07);
  border-radius: var(--r);
  font-size: 13px; color: #cdd7e6; text-align: right;
  transition: background .15s;
}
.acct-btn:hover { background: rgba(255, 255, 255, .12); }
.acct .av {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-600); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.acct .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .rl { font-size: 10.5px; color: #8b9ab3; }
.acct .chev { color: #8b9ab3; font-size: 11px; flex: 0 0 auto; }
.acct.dev .av { background: var(--accent); }

.acct-menu {
  position: absolute; z-index: 30; top: calc(100% + 4px); right: 0; left: 0;
  background: #1b2848;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
  padding: 5px;
  animation: pop .13s ease-out;
}
.acct-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border: 0; background: none;
  color: #cdd7e6; font-size: 13.5px; border-radius: 6px; text-align: right;
}
.acct-menu button small { margin-inline-start: auto; color: #7d8ca6; font-size: 10.5px; }
.acct-menu button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.acct-menu button.danger { color: #ff9a94; }
.acct-menu button.danger:hover { background: rgba(220, 38, 38, .22); color: #fff; }
.acct-menu .mdiv { height: 1px; background: rgba(255, 255, 255, .12); margin: 4px 2px; }

/* ═══════════════ الطباعة ═══════════════ */
@media print {
  body { overflow: visible; background: #fff; }
  .app, #toasts, #load, .ov { display: none !important; }
  #printArea { display: block !important; }
}
#printArea { display: none; }

/* ═══════════════ شاشة التفعيل ═══════════════ */
.actwrap {
  position: fixed; inset: 0; z-index: 950; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(160deg, #101a33 0%, #1e2f57 60%, #101a33 100%); overflow: auto;
}
.actbox {
  width: 100%; max-width: 460px; background: var(--surface);
  border-radius: 20px; padding: 26px; box-shadow: var(--shadow-lg);
}
.actlogo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 14px; }
.actlogo img { width: 40px; height: 40px; border-radius: 10px; }
.actlogo b { font-size: 20px; font-weight: 800; display: block; }
.actlogo span { font-size: 11.5px; color: var(--text-3); }
.actbox h2 { margin: 0; font-size: 20px; text-align: center; }
.actbox h2.bad { color: var(--bad); }
.actbox .sub { margin: 6px 0 0; text-align: center; color: var(--text-2); font-size: 13.5px; line-height: 1.8; }
.actbox .inp.code {
  text-align: center; letter-spacing: 2px; font-family: Consolas, monospace;
  font-size: 19px; font-weight: 700; direction: ltr;
}
.actfoot {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft);
  text-align: center; font-size: 12px; color: var(--text-2);
}
.actcontact {
  margin-top: 16px; padding: 14px; border-radius: 14px; text-align: center;
  background: var(--bad-50); border: 1px solid #fecaca;
}
.actcontact .t { font-size: 12px; color: var(--bad); font-weight: 600; }
.actcontact .n { font-size: 20px; font-weight: 800; margin-top: 4px; }
.actcontact .p { font-size: 22px; font-weight: 800; color: var(--primary); letter-spacing: 1px; margin: 2px 0 4px; }
.actcode.folded { margin-top: 14px; }
/* سطر السلة: وحدة البيع وخصم السطر */
.cart .ln-name { font-weight: 600; }
.cart .unit-in { width: 100%; min-height: 34px; padding: 4px 6px; font-size: 13px; }
.cart .unit-txt { font-size: 13px; color: var(--text-2); }
/* خانات المعلومات (المتوفر · الشراء · النفاذ) بنفس قياس حقول الإدخال */
.cart .cinfo { min-height: 34px; display: flex; align-items: center; justify-content: center;
  padding: 0 6px; border: 1px solid var(--border-soft); border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart .cinfo.out, .cart .cinfo.low, .cart .cinfo.exp-dead { color: var(--bad); border-color: var(--bad); font-weight: 600; }
.cart .cinfo.short, .cart .cinfo.exp-soon { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.cart .dsc-in { text-align: center; }
.cart .dsc-in:not([value="0"]) { border-color: var(--accent); }

/* ═══════════════ مصمم الملصق ═══════════════ */
/* الورقة بحجمها الحقيقي بالملم ومكبّرة، وفوقها مربعات شفافة للسحب */
.lb-stage {
  position: relative; margin: 0 auto;
  background: #fff; border: 1px solid var(--border);
  border-radius: 4px; box-shadow: var(--shadow);
  overflow: hidden; touch-action: none; user-select: none;
}
.lb-stage .lb-paper { position: absolute; inset: 0; transform-origin: top right; }
.lb-stage .lb { border: 0 !important; }
.lb-hit {
  position: absolute; cursor: move; border: 1px dashed transparent; border-radius: 2px;
}
.lb-hit:hover { border-color: var(--primary); background: rgba(37, 99, 235, .06); }
.lb-hit.on { border-color: var(--primary); background: rgba(37, 99, 235, .12); }
/* مقبض التكبير بالزاوية السفلى اليسرى — اتجاه التوسّع بشاشة عربية */
.lb-res {
  position: absolute; left: -6px; bottom: -6px;
  width: 13px; height: 13px; border-radius: 3px;
  background: var(--primary); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: nesw-resize;
}
.lb-res:hover { transform: scale(1.15); }

/* ═══════════════ مصمم الفاتورة الحرارية ═══════════════ */
/* قائمة مقاطع تُسحب للترتيب، وجنبها الورقة بحجمها الحقيقي بالملم */
.rc-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
@media (max-width: 900px) { .rc-wrap { grid-template-columns: 1fr; } }

.rc-list { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.rc-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer; background: var(--surface);
}
.rc-row:last-child { border-bottom: 0; }
.rc-row:hover { background: var(--surface-2); }
.rc-row.on { background: rgba(37, 99, 235, .1); box-shadow: inset 3px 0 0 var(--primary); }
.rc-row.off .rc-name { opacity: .45; text-decoration: line-through; }
.rc-row.drop { box-shadow: inset 0 -2px 0 var(--primary); }
.rc-grip { cursor: grab; color: var(--text-3); letter-spacing: -2px; }
.rc-row .rc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-row .rc-hint { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.rc-props {
  border: 1px solid var(--border); border-radius: 6px; padding: 11px;
  background: var(--surface-2); min-height: 60px;
}

/* الورقة: عرضها بالملم مثل الطابعة تماماً حتى تكون المعاينة صادقة */
.rc-prevwrap { display: flex; justify-content: center; }
#rcPrev { overflow: auto; max-height: 620px; }
.rc-paper {
  background: #fff; color: #000; box-shadow: var(--shadow);
  border: 1px solid var(--border); border-radius: 3px;
}

/* ═══════════════ زر الإغلاق بأسفل القائمة الجانبية ═══════════════ */
/* هنا مو بالشريط العلوي — الشريط مزدحم أصلاً وشرائحه تنطوي على سطرين */
.side-power {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 6px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04);
  color: #b8c4d8; font: inherit; font-size: 12.5px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.side-power .ic { transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.side-power:hover { background: rgba(244, 63, 94, .16); border-color: rgba(244, 63, 94, .45); color: #fecdd3; }
.side-power:hover .ic { transform: rotate(-20deg) scale(1.1); }
.side-power:active { transform: scale(.97); }
.side-power:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }

/* ═══════════════ نافذة «تسكّر البرنامج؟» ═══════════════ */
.quit-ov {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, .5), rgba(2, 6, 23, .82));
  backdrop-filter: blur(8px) saturate(1.15);
  animation: quitFade .28s ease-out;
}
.quit-ov.out { animation: quitFadeOut .22s ease-in forwards; }
.quit-ov.out .quit { animation: quitOut .22s ease-in forwards; }
@keyframes quitFade { from { opacity: 0; } }
@keyframes quitFadeOut { to { opacity: 0; } }

.quit {
  position: relative; overflow: hidden; outline: none;
  width: min(420px, 100%); padding: 30px 26px 18px;
  border-radius: 28px; text-align: center; color: #eaf1ff;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(244, 63, 94, .22), transparent 60%),
    linear-gradient(165deg, #1b2d57 0%, #111c39 55%, #0a1124 100%);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 40px 90px rgba(2, 6, 23, .6), inset 0 1px 0 rgba(255, 255, 255, .08);
  animation: quitIn .55s cubic-bezier(.2, .9, .25, 1.15);
}
@keyframes quitIn {
  from { opacity: 0; transform: translateY(34px) scale(.88); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes quitOut { to { opacity: 0; transform: translateY(16px) scale(.92); } }

/* الكرة: حلقة ألوان تدور، وتوهّج يتنفّس، وأيقونة الإطفاء بالوسط */
.quit-orb {
  position: relative; width: 104px; height: 104px; margin: 0 auto 16px;
  display: grid; place-items: center;
  animation: quitOrbIn .7s .08s cubic-bezier(.3, 1.6, .5, 1) backwards;
}
@keyframes quitOrbIn { from { transform: scale(.3) rotate(-120deg); opacity: 0; } }
.quit-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #a855f7, #3b82f6, #f43f5e);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  animation: quitSpin 5s linear infinite;
}
@keyframes quitSpin { to { transform: rotate(360deg); } }
.quit-glow {
  position: absolute; inset: 10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 63, 94, .55), transparent 70%);
  filter: blur(10px);
  animation: quitBreathe 2.6s ease-in-out infinite;
}
@keyframes quitBreathe { 0%, 100% { opacity: .45; transform: scale(.9); } 50% { opacity: .95; transform: scale(1.08); } }
.quit-ic {
  position: relative; width: 78px; height: 78px; border-radius: 50%;
  display: grid; place-items: center; color: #fecdd3;
  background: radial-gradient(circle at 35% 30%, #2a3f73, #0d1733 70%);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, .08), 0 8px 24px rgba(2, 6, 23, .5);
  transition: color .2s, transform .3s;
}
.quit:has(.quit-go:hover) .quit-ic, .quit:has(.quit-go:focus-visible) .quit-ic { color: #fff; transform: scale(1.06); }
.quit:has(.quit-go:hover) .quit-ring { animation-duration: 1.4s; }

/* المحتوى يطلع بالتتابع */
.quit h2, .quit-sub, .quit-day, .quit-note, .quit-btns, .quit-foot { animation: quitUp .5s cubic-bezier(.2, .9, .3, 1) backwards; }
.quit h2 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -.2px; animation-delay: .14s; }
.quit-sub { margin: 6px 0 0; font-size: 14px; color: #9fb3d4; animation-delay: .2s; }
.quit-day { animation-delay: .26s; }
.quit-note { animation-delay: .3s; }
.quit-btns { animation-delay: .34s; }
.quit-foot { animation-delay: .4s; }
@keyframes quitUp { from { opacity: 0; transform: translateY(12px); } }

.quit-day {
  margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.quit-day[hidden] { display: none; }
.quit-day-hd { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; color: #7f93b8; text-align: right; }
.quit-cell {
  padding: 10px 6px; border-radius: 14px;
  background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
.quit-cell small { display: block; font-size: 11px; color: #8fa3c4; }
.quit-cell b {
  display: block; margin-top: 3px; font-size: 17px; font-weight: 800; direction: ltr;
  font-variant-numeric: tabular-nums;
}
.quit-note {
  margin-top: 12px; padding: 9px 12px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12.5px; line-height: 1.6; color: #fde68a;
  background: rgba(245, 158, 11, .12); box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .22);
}
.quit-note[hidden] { display: none; }

.quit-btns { display: flex; gap: 10px; margin-top: 22px; }
.quit-go, .quit-stay {
  flex: 1; height: 50px; border-radius: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15.5px; font-weight: 800;
  transition: transform .15s cubic-bezier(.2, .8, .3, 1), box-shadow .2s, background .2s;
}
.quit-go {
  border: 0; color: #fff;
  background: linear-gradient(135deg, #f43f5e, #e11d48 55%, #be123c);
  box-shadow: 0 12px 28px rgba(225, 29, 72, .45), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.quit-go:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(225, 29, 72, .55), inset 0 1px 0 rgba(255, 255, 255, .22); }
.quit-go:active { transform: translateY(0) scale(.98); }
.quit-stay {
  color: #e2e8f0; background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14);
}
.quit-stay:hover { background: rgba(255, 255, 255, .13); }
.quit-go:focus-visible, .quit-stay:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 3px; }
.quit-foot { margin-top: 14px; font-size: 11.5px; line-height: 1.7; color: #7f93b8; }

/* الوداع: بعد «إغلاق» المحتوى يذوب ويطلع الشعار ومع السلامة وشريط يمتلي */
.quit-bye {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(165deg, #1b2d57, #0a1124);
}
.quit-bye img { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 10px 30px rgba(249, 115, 22, .35); animation: quitLogo .9s cubic-bezier(.3, 1.5, .5, 1); }
.quit-bye b { margin-top: 10px; font-size: 22px; font-weight: 800; animation: quitUp .45s .12s backwards; }
.quit-bye small { color: #9fb3d4; font-size: 13px; animation: quitUp .45s .2s backwards; }
.quit-bar { width: 150px; height: 4px; margin-top: 14px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .1); }
.quit-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #f43f5e, #f59e0b); }
.quit-ov.closing .quit-bye { display: flex; animation: quitFade .3s ease-out; }
.quit-ov.closing .quit-bar i { animation: quitFill .85s ease-in-out forwards; }
.quit-ov.closing { background: rgba(2, 6, 23, .9); transition: background .4s; }
@keyframes quitLogo { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }
@keyframes quitFill { to { width: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .quit-ov, .quit, .quit *, .quit-bye * { animation: none !important; }
  .quit-ov.closing .quit-bar i { width: 100%; }
}

/* ── قراءة فاتورة من صورة ── */
.ocr-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 240px; border: 2px dashed var(--border); border-radius: var(--r-lg); cursor: pointer;
  color: var(--primary); background: var(--surface-2); transition: border-color .15s, background .15s; }
.ocr-drop b { font-size: 16px; color: var(--text); }
.ocr-drop:hover, .ocr-drop.over { border-color: var(--primary); background: var(--primary-50); }
.ocr-busy { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 240px; }
.ocr-spin { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--border-soft);
  border-top-color: var(--primary); animation: spin .8s linear infinite; }
.ocr-split { display: flex; gap: 14px; align-items: stretch; }
.ocr-img { flex: 0 0 300px; max-height: 64vh; overflow: auto; border: 1px solid var(--border-soft);
  border-radius: var(--r); background: var(--surface-2); }
.ocr-img img { display: block; width: 100%; }
.ocr-img iframe { width: 100%; height: 64vh; border: 0; }
.ocr-main { flex: 1; min-width: 0; }
.ocr-sum { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: flex-end; font-size: 14px; }
@media (max-width: 1000px) { .ocr-img { display: none; } }

/* أسطر فاتورة الشراء — ١٥ عمود، فنضغط الحشو حتى تبقى المجاميع جنبها */
table.pur-lines th, table.pur-lines td { padding: 6px 4px; }
table.pur-lines th { white-space: nowrap; font-size: 12.5px; }
table.pur-lines .inp { padding-inline: 6px; }

/* مصاريف فاتورة الشراء + مجاميع أضيق */
.xp-row { gap: 6px; margin-bottom: 6px; align-items: center; }
.xp-total { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  border-radius: var(--r); background: var(--surface-2); font-size: 15px; }
.xp-total b { font-size: 18px; color: var(--primary); }
.pur-side .totals .ln.big .v { font-size: 22px; }
/* محاذاة الأعمدة: العنوان والقيمة بالوسط لكل الأعمدة الرقمية */
table.pur-lines th { text-align: center; }
table.pur-lines th:first-child { text-align: start; }
table.pur-lines td.num { text-align: center; }
table.pur-lines .inp.num { text-align: center; }
table.pur-lines th, table.pur-lines td { padding: 7px 6px; }
table.pur-lines td:not(:first-child) { text-align: center; }

/* عنصر بالشريط العلوي مخفي من الإعدادات */
.top .tb-off { display: none !important; }

/* ═══════════════ تسديد الفواتير ═══════════════ */
.stl { display: flex; flex-direction: column; gap: 14px; }
.stl-bar { display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: 10px 12px; box-shadow: var(--shadow); }
.stl-dir { flex: 0 0 auto; }
.stl-dir button { min-width: 104px; min-height: 40px; font-size: 14.5px; }
.stl-who { position: relative; flex: 1 1 auto; min-width: 0; }
.stl-who .inp { padding-inline-start: 40px; min-height: 42px; font-size: 15px; }
.stl-who-ic { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: flex; pointer-events: none; }
.stl-bar > .btn { min-height: 42px; }

/* شريط الأرقام: خلايا متساوية بفواصل — رقم واحد بس بلون أساسي */
.stl-sum { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.stl-cell { padding: 14px 18px; border-inline-start: 1px solid var(--border-soft); min-width: 0; }
.stl-cell:first-child { border-inline-start: 0; }
.stl-cell .lb { font-size: 12.5px; color: var(--text-3); font-weight: 600; letter-spacing: .2px; }
.stl-cell .vl { font-size: 21px; font-weight: 700; color: var(--text); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stl-cell .sb { font-size: 12.5px; color: var(--text-2); min-height: 18px; }
.stl-cell.main { background: var(--primary-50); box-shadow: inset 0 3px 0 var(--primary); }
.stl-cell.main .vl { color: var(--primary); font-size: 24px; }

.stl-main { display: flex; align-items: flex-start; gap: 14px; }
.stl-list { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.stl-pay { flex: 0 0 330px; width: 330px; }
.stl-hd { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); min-height: 56px; }
.stl-hd b { font-size: 15.5px; }
.stl-cnt:not(:empty) { background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 700;
  border-radius: 999px; padding: 1px 9px; }
.stl-flt { position: relative; display: flex; align-items: center; color: var(--text-3); }
.stl-flt svg { position: absolute; inset-inline-start: 10px; }
.stl-flt .inp { width: 200px; min-height: 34px; padding-inline-start: 32px; font-size: 13.5px; }

table.stl-tbl th { background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 700;
  padding: 10px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
table.stl-tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.stl-tbl tbody tr:hover td { background: #f8fbff; }
table.stl-tbl .n { text-align: center; font-variant-numeric: tabular-nums; }
table.stl-tbl th.n { text-align: center; }
table.stl-tbl td.muted { color: var(--text-3); }
table.stl-tbl td.due { font-weight: 700; color: var(--text); }
table.stl-tbl .sub { font-size: 12px; color: var(--text-3); }
table.stl-tbl .lnk { color: var(--primary); font-weight: 600; text-decoration: none; }
table.stl-tbl .lnk:hover { text-decoration: underline; }
table.stl-tbl td.acts { white-space: nowrap; text-align: end; width: 1%; }
table.stl-tbl td.acts .btn { min-height: 32px; padding: 4px 12px; }
table.stl-tbl tfoot td { background: var(--surface-2); font-weight: 700; padding: 12px 14px; border-top: 2px solid var(--border); }
table.stl-tbl tfoot td.due { color: var(--primary); font-size: 16px; }
.btn.stl-go { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.btn.stl-go:hover { background: var(--primary); color: #fff; }
.stl-age { font-size: 12.5px; color: var(--text-2); }
.stl-age.late { color: #a35c05; background: var(--accent-50); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.stl-other { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px;
  padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--r); color: var(--text-2); font-size: 13.5px; }

.stl-pay-bd { padding: 16px; }
.stl-amt { display: flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.stl-amt:focus-within { border-color: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-50); }
.stl-amt .inp { border: 0; border-radius: 0; box-shadow: none !important; }
.stl-amt #amt { flex: 1 1 auto; min-width: 0; font-size: 24px; font-weight: 700; min-height: 54px; }
.stl-amt #cur { flex: 0 0 70px; width: 70px; border-inline-start: 1px solid var(--border-soft);
  background: var(--surface-2); font-weight: 700; text-align: center; min-height: 54px; }
.stl-quick button { font-size: 13px; }
.stl-alloc { border: 1px solid var(--border-soft); border-radius: var(--r); overflow: hidden; }
.stl-alloc .r { display: flex; justify-content: space-between; padding: 7px 12px; font-size: 13.5px; }
.stl-alloc .r + .r { border-top: 1px solid var(--border-soft); }
.stl-alloc .r b { font-variant-numeric: tabular-nums; }
.stl-alloc .r.extra { background: var(--surface-2); color: var(--text-2); }
/* تسديد: أعمدة موسّطة وبلا تلوين عند المرور، والمدة المتأخرة لون نص بس */
table.stl-tbl .c, table.stl-tbl th.c { text-align: center; }
table.stl-tbl tbody tr:hover td { background: transparent; }
table.stl-tbl td.c { color: var(--text-2); font-variant-numeric: tabular-nums; }
table.stl-tbl td.c b { color: var(--text); font-weight: 700; }
table.stl-tbl td.late { color: var(--bad); font-weight: 600; }
/* فواتير البيع — نفس أسلوب التسديد */
table.inv-tbl td.ret { color: var(--accent); font-weight: 600; }
table.inv-tbl td.credit { color: var(--text); font-weight: 600; }
table.inv-tbl td.owe { color: var(--bad); font-weight: 600; }
table.inv-tbl tr.voided td { opacity: .5; text-decoration: line-through; }
table.inv-tbl tr.voided td.acts { opacity: 1; text-decoration: none; }
table.stl-tbl td.acts .icons { display: flex; gap: 2px; justify-content: flex-end; }
table.stl-tbl td.acts .slot { display: inline-flex; width: 34px; justify-content: center; }
table.stl-tbl td.acts .icons .btn { min-height: 32px; width: 32px; padding: 0; justify-content: center; color: var(--text-2); }
table.stl-tbl td.acts .icons .btn:hover { color: var(--primary); background: var(--primary-50); }
table.stl-tbl td.acts .icons .btn.del:hover { color: var(--bad); background: var(--bad-50); }
/* جدول طابعات ويندوز: الاسم ياخذ المساحة والباقي ما ينكسر */
table.prn-tbl td:first-child { min-width: 150px; }
table.prn-tbl th, table.prn-tbl td:last-child { white-space: nowrap; }
table.prn-tbl td:nth-child(2) { word-break: break-all; max-width: 140px; }
table.prn-tbl td:first-child { overflow-wrap: anywhere; }
/* الشريط العلوي بالشاشات المتوسطة (1366): ما ينكسر لسطرين */
.top h1 { white-space: nowrap; flex: 0 0 auto; }
.top-search { min-width: 110px; }
.top .chip, .top .btn-update { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 1440px) {
  .top .chip { padding-inline: 10px; font-size: 13px; }
  .top-search { flex-basis: 200px; }
}
/* مستويات الأسعار بفاتورة البيع: سطر واحد دائماً، تصغر بالشاشات المتوسطة */
#pmode button { white-space: nowrap; }
@media (max-width: 1440px) { #pmode button { padding-inline: 8px; font-size: 12.5px; } }
/* وحدة سطر الشراء ما تنضغط لحد ما تختفي */
table.pur-lines select[data-u] { min-width: 96px; }
/* ═══════════════ الوردية ═══════════════ */
.shf-open { max-width: 460px; margin: 40px auto 0; }
.shf-open-bd { padding: 18px; }
table.shf-tbl td { padding: 10px 16px; }
table.shf-tbl td.n { text-align: end; }
table.shf-tbl tfoot td { font-size: 15px; }
table.stl-tbl td.short, .shf-diff.short b { color: var(--bad); font-weight: 700; }
table.stl-tbl td.over, .shf-diff.over b { color: var(--accent); font-weight: 700; }
.shf-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.shf-note { display: flex; align-items: center; gap: 8px; }
.shf-note span { flex: 0 0 64px; font-weight: 700; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.shf-note .inp { min-height: 34px; text-align: center; min-width: 0; }
.shf-diff { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  border-radius: var(--r); background: var(--surface-2); font-weight: 600; }
.shf-diff:empty { display: none; }
.shf-diff b { font-size: 20px; font-variant-numeric: tabular-nums; }
.shf-diff.ok { background: var(--ok-50); color: #04785b; }
.shf-diff.short { background: var(--bad-50); }
.shf-diff.over { background: var(--accent-50); }
.shf .stl-amt .inp.num { flex: 1 1 auto; min-width: 0; font-size: 24px; font-weight: 700; min-height: 54px; }
.stl-cur { flex: 0 0 70px; display: flex; align-items: center; justify-content: center; font-weight: 700;
  background: var(--surface-2); border-inline-start: 1px solid var(--border-soft); color: var(--text-2); }

/* ═══════════════ الرواتب ═══════════════ */
.hr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.hr-tabs button { display: inline-flex; align-items: center; gap: 6px; }
.hr-tabs button .ic { opacity: .75; }
.hr-tabs button.on .ic { opacity: 1; }
.hr-month { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.hr-month .inp { min-height: 36px; width: 150px; }
.hr-kpis { margin-bottom: 0; }
.hr-kpi { animation: hrUp .45s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
.hr-kpi .vl { direction: ltr; text-align: right; }
.hr-in { animation: hrUp .4s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes hrUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hr-skel { display: grid; gap: 10px; margin-top: 12px; }
.hr-skel i { display: block; height: 44px; border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface-2) 25%, #e9eef5 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: hrShimmer 1.1s linear infinite; }
@keyframes hrShimmer { to { background-position: -200% 0; } }

.hr-empty { text-align: center; padding: 38px 20px; }
.hr-empty h3 { margin: 12px 0 6px; font-size: 18px; }
.hr-empty p { max-width: 560px; margin: 0 auto 18px; line-height: 1.8; }
.hr-empty-ic { width: 68px; height: 68px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary); }

/* شريط مراحل المسير */
.hr-status { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hr-steps { display: flex; align-items: center; gap: 0; }
.hr-step { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.hr-step b { font-size: 13.5px; }
.hr-step .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  border: 2px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 700;
  transition: background .3s, border-color .3s, color .3s; }
.hr-step.done { color: var(--text); }
.hr-step.done .dot { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.hr-step.cur .dot { box-shadow: 0 0 0 4px rgba(37, 99, 235, .16); }
.hr-line { width: 34px; height: 2px; background: var(--border); margin: 0 10px; flex: 0 0 auto; }
.hr-step.done + .hr-line { background: var(--primary-600); }
.hr-note { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px;
  border-top: 1px solid var(--border-soft); }
.hr-note.warn { background: var(--accent-50); color: #92400e; }
.hr-note.ok { background: var(--ok-50); color: #065f46; }
.hr-export { gap: 4px; }

table.tbl td.hr-neg, .hr-neg { color: #b91c1c; }
.hr-net { color: var(--primary); font-size: 14.5px; }
table.tbl tfoot td { position: sticky; bottom: 0; }

/* القسيمة */
.hr-slip-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); }
.hr-sec { border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: 12px 14px; }
.hr-sec h4 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.hr-sec.plus { border-top: 3px solid var(--ok); }
.hr-sec.minus { border-top: 3px solid var(--bad); }
.hr-calc { display: flex; align-items: center; background: var(--surface-2); color: var(--text-2); font-weight: 600; direction: ltr; }
.hr-formula { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap;
  padding: 10px; border-radius: var(--r-lg); background: var(--surface-2); }
.hr-formula > div { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border-soft); min-width: 92px; }
.hr-formula > div span { font-size: 11.5px; color: var(--text-3); }
.hr-formula > div b { font-size: 15px; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; transition: color .2s; }
.hr-formula > div.neg b { color: #b91c1c; }
.hr-formula > div.net { flex: 1 1 160px; background: var(--primary-600); border-color: var(--primary-600); }
.hr-formula > div.net span { color: rgba(255, 255, 255, .8); }
.hr-formula > div.net b { color: #fff; font-size: 19px; }
.hr-formula > div.net.bad { background: var(--bad); border-color: var(--bad); }
.hr-formula > i { align-self: center; font-style: normal; font-weight: 700; color: var(--text-3); }
.hr-pay-top { padding: 2px 0 14px; }
.hr-big { font-size: 32px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }

.hr-prog { height: 6px; margin-top: 4px; }
.hr-prog > i { background: var(--ok); transition: width .7s cubic-bezier(.2, .7, .2, 1); }

/* التقارير */
.hr-filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.hr-filters .f { min-width: 140px; }
.hr-filters .inp { min-height: 36px; }
.hr-filters .switch { min-height: 36px; }
.hr-quick { margin-inline-start: auto; }
.hr-blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.hr-block { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  animation: hrUp .4s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
.hr-block span { font-size: 12px; color: var(--text-2); }
.hr-block b { font-size: 17px; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.hr-block.b { background: var(--primary-50); border-color: #c7d7fb; }
.hr-block.b b { color: var(--primary); }
.hr-block.neg b { color: #b91c1c; }
.hr-block.net { background: var(--primary-600); border-color: var(--primary-600); }
.hr-block.net span { color: rgba(255, 255, 255, .85); }
.hr-block.net b { color: #fff; }
.hr-h { display: flex; align-items: center; gap: 6px; margin: 18px 0 8px; font-size: 14px; color: var(--text-2); }

.hr-dept { display: flex; flex-direction: column; gap: 10px; }
.hr-dept-row { display: grid; grid-template-columns: 190px 1fr 150px; align-items: center; gap: 14px;
  animation: hrUp .4s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
.hr-dept-row .nm { display: flex; flex-direction: column; min-width: 0; }
.hr-dept-row .bars { display: flex; flex-direction: column; gap: 4px; }
.hr-dept-row .bars i { display: block; height: 10px; border-radius: 999px; width: var(--w);
  transform-origin: right; animation: hrBar .8s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
.hr-dept-row .v { display: flex; flex-direction: column; text-align: left; direction: ltr; }
.hr-dept-row .v b { font-variant-numeric: tabular-nums; }
@keyframes hrBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.hr-dept .g, .hr-legend i.g { background: #c7d2e4; }
.hr-dept .n, .hr-legend i.n { background: var(--primary-600); }
.hr-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.hr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hr-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.hr-legend i.t { height: 3px; background: var(--accent); }

.hr-chart-wrap { padding: 4px 0; }
.hr-chart { width: 100%; height: 250px; display: block; }
.hr-chart .gl { stroke: var(--border-soft); stroke-dasharray: 3 4; }
.hr-chart .base { stroke: var(--border); }
.hr-chart .b { transform-box: fill-box; transform-origin: bottom; animation: hrGrow .7s cubic-bezier(.2, .7, .2, 1) both; }
.hr-chart g { --d: 0ms; }
.hr-chart g .b { animation-delay: var(--d); }
.hr-chart .g { fill: #c7d2e4; }
.hr-chart .n { fill: var(--primary-600); }
.hr-chart text { font-size: 11px; fill: var(--text-2); text-anchor: middle; font-family: var(--font); }
.hr-chart .vl { font-weight: 700; fill: var(--primary); }
.hr-chart .trend { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round;
  stroke-dasharray: 1600; stroke-dashoffset: 1600; animation: hrDraw 1.2s .3s ease-out forwards; }
@keyframes hrGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes hrDraw { to { stroke-dashoffset: 0; } }

/* التحقق من السند */
.hr-verify .row { flex-wrap: nowrap; }
.hr-verify-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--primary-50); color: var(--primary); }
.hr-vres { display: flex; gap: 14px; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-lg);
  animation: hrUp .35s cubic-bezier(.2, .7, .2, 1) both; }
.hr-vres.ok { background: var(--ok-50); border: 1px solid #a7f3d0; color: #065f46; }
.hr-vres.bad { background: var(--bad-50); border: 1px solid #fecaca; color: #991b1b; }
.hr-vres .ic { flex: 0 0 auto; }
.hr-vgrid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--text); }
.hr-vgrid span { color: var(--text-2); }
.hr-diff { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; color: var(--text-2); }
.hr-diff s { color: var(--text-3); }
.hr-day { padding: 6px 10px; border: 1px solid var(--border-soft); border-radius: var(--r); }

@media (max-width: 1100px) {
  .hr-dept-row { grid-template-columns: 140px 1fr 120px; }
  .hr-tabs button span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hr-kpi, .hr-in, .hr-block, .hr-dept-row, .hr-dept-row .bars i, .hr-chart .b, .hr-vres { animation: none; }
  .hr-chart .trend { animation: none; stroke-dashoffset: 0; }
  .hr-skel i { animation: none; }
}
