:root {
  --page-bg: #f3f4f6;
  --text-main: #1f2937;
  --text-muted: #64748b;
  --text-label: #475569;
  --heading-color: #334155;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-modal: 0 10px 40px rgba(0,0,0,0.25);
  --th-color: #64748b;
  --scrollbar-track: #f1f5f9;
  --hover-bg: #f0f9ff;
  --tab-bg: #f8fafc;
  --tab-border: #e5e7eb;
  --tab-color: #334155;
  --subtle-bg: #f8fafc;
  --zebra-bg: #edf1f6; /* الصف الرمادي في الجداول المخططة (v205) */
  /* القائمة الجانبية: في الفاتح كحلي، في الغامق نفس لون خلفية الصفحة */
  --sb-bg: #1e293b;
  --sb-text: #cbd5e1;
  --sb-text-strong: #ffffff;
  --sb-muted: #64748b;
  --sb-faint: #475569;
  --sb-hover: rgba(255,255,255,0.05);
  --sb-line: rgba(255,255,255,0.08);
  --sb-btn: rgba(255,255,255,0.1);
  --sb-btn-hover: rgba(255,255,255,0.2);
  --sb-thumb: rgba(255,255,255,0.25);
  --sb-accent: #60a5fa;
}
/* غامق: كحلي غامق مريح للعين، مش أسود خالص */
:root[data-theme="dark"] {
  --page-bg: #0b1222;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-label: #cbd5e1;
  --heading-color: #cbd5e1;
  --card-bg: #121b32;
  --border-color: #26335a;
  --input-bg: #0e172c;
  --input-border: #35416b;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-modal: 0 10px 40px rgba(0,0,0,0.65);
  --th-color: #94a3b8;
  --scrollbar-track: #17213d;
  --hover-bg: #17213d;
  --tab-bg: #17213d;
  --tab-border: #2c3a63;
  --tab-color: #cbd5e1;
  --subtle-bg: #1a2744;
  --zebra-bg: #1b2846;
  --sb-bg: var(--page-bg);
  --sb-text: #cbd5e1;
  --sb-text-strong: #ffffff;
  --sb-muted: #64748b;
  --sb-faint: #475569;
  --sb-hover: rgba(255,255,255,0.05);
  --sb-line: rgba(255,255,255,0.08);
  --sb-btn: rgba(255,255,255,0.1);
  --sb-btn-hover: rgba(255,255,255,0.2);
  --sb-thumb: rgba(255,255,255,0.25);
  --sb-accent: #60a5fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* v221: Almarai افتراضي - v289: المدير بيغيّره من الإعدادات (--app-font من applyUiFont في app.js) */
  font-family: var(--app-font, "Almarai"), "Almarai", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-synthesis: none;
  background: var(--page-bg);
  color: var(--text-main);
  direction: rtl;
  transition: background-color .15s ease, color .15s ease;
}

* { font-family: inherit; }

.topbar {
  background: #1e293b;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.topbar .user-info {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* المحتوى بياخد عرض الشاشة كله (طلب صاحب المشروع): لما تصغّر الشاشة بـ Ctrl + عجلة الماوس
   الجداول بتبان أكتر بدل ما تفضل محبوسة في عرض ثابت في النص */
.container {
  max-width: none;
  margin: 20px 0;
  padding: 0 20px 0 84px; /* الشمال أوسع شوية: مكان زرار + الأخضر العايم عشان ميغطيش على حاجة */
}
.in-frame .container { padding: 0 12px; margin: 12px 0; } /* جوه شاشة الفواتير الموحدة: مفيش زرار عايم */

.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.card h2 {
  margin-top: 0;
  font-size: 17px;
  color: var(--heading-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

th {
  color: var(--th-color);
  font-weight: 600;
  white-space: nowrap;
}

#products-header-row th,
#si-header-row th { font-size: 11px; color: var(--text-main); }

#products-table,
#customers-table,
#drawer-stmt-table,
#sales-inv-table {
  table-layout: fixed;
  width: 100%; /* لازم عرض محدد عشان المتصفح يحترم عرض كل عمود (شوف .fixed-table) */
}
#products-table td,
#customers-table td,
#drawer-stmt-table td,
#sales-inv-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* عمود الإجراءات (عرض/تعديل/دفع...) يفضل مثبّت ظاهر على الشمال حتى لو الجدول اتسحب أفقيًا.
   قاعدة ثابتة: أي جدول فيه عمود إجراءات بنحط على خلاياه class="sticky-col" */
.table-scroll-wrap td.sticky-col,
.table-scroll-wrap th.sticky-col {
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 5;
  box-shadow: 6px 0 10px -4px rgba(0,0,0,0.22); /* v522: ضل واضح بطول عمود الأزرار */
}
.table-scroll-wrap tr:hover td.sticky-col { background: var(--hover-bg); }
/* عنوان عمود الأزرار فوق الخلايا وهي بتتحرك (ركن الجدول) */
.table-scroll-wrap thead th.sticky-col { z-index: 6; }
/* الأزرار نفسها لازقة في أقصى الشمال جوه عمودها (مش على يمينه وسايبة فراغ يغطي الأعمدة) */
.table-scroll-wrap td.sticky-col > div { justify-content: flex-end; }
/* v433: أي محتوى تاني في عمود الأزرار (span/زرار/لينك) لازق في أقصى الشمال برضه - مفيش فراغ بينه وبين آخر الجدول */
.table-scroll-wrap td.sticky-col { text-align: left; }

/* شريط "الإجمالي" تحت جدول المنتجات: عنصر عادي (مش جوه الجدول) عشان يفضل
   ثابت تحت مهما عملت سكرول - أكتر ثباتًا من التثبيت جوه خلايا جدول */
#products-totals-bar,
#sales-inv-totals-bar {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  border-top: 2px solid var(--border-color);
  padding: 6px 14px;
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  z-index: 10;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
}
#products-totals-text,
#sales-inv-totals-text {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
#products-totals-bar > *,
#sales-inv-totals-bar > * { flex-shrink: 0; }
#products-totals-text > *,
#sales-inv-totals-text > * { flex-shrink: 0; }
#products-totals-text:empty,
#sales-inv-totals-text:empty { display: none; }

/* فلتر الفروع المميز - بيبان بوضوح فوق أي شاشة فيها بضاعة/أرقام مرتبطة بفرع */
#branch-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.branch-tab {
  flex: 1;
  min-width: 130px;
  padding: 10px 14px;
  border: 2px solid var(--tab-border);
  border-radius: 10px;
  background: var(--tab-bg);
  color: var(--tab-color);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  transition: all .12s;
}
.branch-tab:hover { border-color: #93c5fd; }
.branch-tab.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.date-preset-tab {
  padding: 7px 12px;
  border: 2px solid var(--tab-border);
  border-radius: 8px;
  background: var(--tab-bg);
  color: var(--tab-color);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .12s;
}
.date-preset-tab:hover { border-color: #93c5fd; }
.date-preset-tab.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

#pe-totals-bar {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  border-top: 2px solid var(--border-color);
  padding: 6px 14px;
  z-index: 10;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
}

/* الجدول بقى صندوق مقفول بارتفاع معين وله سكرول بتاعه (يمين شمال وفوق تحت)،
   عشان تقدر توصله وتتحكم فيه بإيدك من غير ما تنزل في الصفحة كلها */
.table-scroll-wrap {
  overflow: auto;
  max-height: 62vh;
  scrollbar-width: auto;
}
.table-scroll-wrap::-webkit-scrollbar {
  width: 13px;
  height: 13px;
}
.table-scroll-wrap::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 8px;
}
.table-scroll-wrap::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 8px;
  border: 2px solid var(--scrollbar-track);
}
.table-scroll-wrap::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* عنوان الجدول يفضل ظاهر فوق حتى وإنت نازل في الصفوف جوه الصندوق */
.table-scroll-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 4;
}

/* صف الإجمالي (tfoot) ثابت تحت الجدول وإنت نازل - مش لازم تنزل لآخر القايمة عشان تشوف الإجمالي (v251) */
.table-scroll-wrap tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  z-index: 4;
  box-shadow: 0 -2px 0 var(--border-color);
}
.table-scroll-wrap tfoot td.sticky-col { z-index: 6; }

/* 💰 مربع المبلغ في خطوة الدفع (فاتورة البيع/الشراء/الكاشير السريع) - مميز وكبير (v259) */
.pay-line .pay-amount { font-size: 24px; font-weight: 800; padding: 10px 14px; min-height: 54px; border: 2px solid #2563eb; border-radius: 12px;
  background: color-mix(in srgb, #2563eb 7%, var(--card-bg)); color: #1d4ed8; }
:root[data-theme="dark"] .pay-line .pay-amount { color: #93c5fd; }
.pay-line .pay-amount:focus { box-shadow: 0 0 0 4px rgba(37,99,235,.25); outline: none; }
.pay-line .pay-method { font-size: 16px; font-weight: 800; min-height: 54px; border-radius: 12px; }
.pay-line label { font-size: 13px; font-weight: 800; }

/* ✂️ علامة شيل الخلفية على صورة العرض الجاهز (v276) */
.pk-bg-badge { position:absolute; top:6px; right:6px; width:24px; height:24px; border-radius:50%; background:#7c3aed; color:#fff; font-size:12px; display:flex; align-items:center; justify-content:center; box-shadow:0 2px 6px rgba(0,0,0,.25); }
.pk-bg-badge.err { background:#dc2626; }

/* ⚙️ ترتيب القايمة (v274) */
.sidebar-link.sb-user-hidden { display: none !important; }
.sb-arrange { width: 100%; margin: 6px 0 4px; padding: 7px 10px; border-radius: 10px; border: 1px dashed rgba(255,255,255,.25); background: rgba(255,255,255,.06);
  color: var(--sb-text, #cbd5e1); font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sb-arrange:hover { background: rgba(255,255,255,.14); }
.sidebar.collapsed .sb-arrange .sidebar-link-text { display: none; }
.sb-arr-box { max-width: 560px; width: 96%; text-align: right; max-height: 90vh; display: flex; flex-direction: column; }
.sb-arr-list { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.sb-arr-group { border: 1px solid var(--border-color); border-radius: 12px; padding: 6px 8px; background: var(--subtle-bg); }
.sb-arr-ghead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 2px 6px; font-size: 14px; }
.sb-arr-link { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; background: var(--card-bg); margin-bottom: 4px; font-size: 13.5px; font-weight: 700; }
.sb-arr-link.off { opacity: .45; }
.sb-arr-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-arr-btns { display: inline-flex; gap: 4px; flex-shrink: 0; }
.sb-arr-btns button { width: 30px; height: 28px; padding: 0; border-radius: 7px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); cursor: pointer; font-size: 12px; }
.sb-arr-btns button:disabled { opacity: .3; cursor: default; }

/* 🔎 زرار «اعرف الصنف بالكاميرا» جنب البحث الأساسي (v271) */
#rail-scan-btn { width:30px; height:30px; border-radius:50%; border:none; padding:0; cursor:pointer; color:#fff; display:flex; align-items:center; justify-content:center; flex-shrink:0;
  background:linear-gradient(135deg, #4f46e5, #2563eb); box-shadow:0 3px 10px rgba(79,70,229,.35); }
#rail-scan-btn svg { width:17px; height:17px; }
@media (min-width: 901px) {
  #user-chip #rail-scan-btn { width:40px; height:40px; border-radius:12px; }
  #user-chip #rail-scan-btn svg { width:21px; height:21px; }
  #user-chip #rail-scan-btn:hover { transform:scale(1.06); }
}

/* 📷 زرار سكان الكاميرا (v270) */
.cam-btn { display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; width:44px; min-height:40px; padding:0; margin:0;
  border:none; border-radius:10px; cursor:pointer; color:#fff; background:linear-gradient(135deg, #4f46e5, #2563eb); box-shadow:0 3px 10px rgba(79,70,229,.3); }
.cam-btn:hover { filter:brightness(1.08); transform:translateY(-1px); }

/* خانة الخزنة لسه متختارتش (v254) */
select.need-choice { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.25) !important; }

.table-scroll-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.table-scroll-nav button {
  background: var(--subtle-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: #334155;
}
.table-scroll-nav button:hover { background: var(--hover-bg); }

tr:hover td { background: var(--hover-bg); }

.btn {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: #1d4ed8; }

.btn.secondary {
  background: var(--subtle-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn.secondary:hover { background: var(--hover-bg); }

.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }

.btn.small { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
  background: var(--input-bg);
  color: var(--text-main);
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-label);
  margin-bottom: 4px;
  margin-top: 10px;
}

form .row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
form .row > div { flex: 1; min-width: 140px; }

.error-box {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

.success-box {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.login-box h1 {
  text-align: center;
  color: #1e293b;
  margin-bottom: 24px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.receipt { background: #dcfce7; color: #166534; }
.badge.payment { background: #fee2e2; color: #991b1b; }

.muted { color: var(--text-muted); font-size: 13px; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

/* v475/v476: «رجوع لكل العملاء/الموردين» مربع أزرق كامل والكتابة بالأبيض */
.back-link { display: inline-flex; width: fit-content; align-self: flex-start; align-items: center; gap: 6px; margin-bottom: 12px; padding: 8px 16px; border: 2px solid #2563eb; border-radius: 10px; background: #2563eb; color: #fff; font-weight: 800; font-size: 15px; text-decoration: none; transition: background .15s; }
.back-link:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

.sort-arrow { font-size: 10px; color: #2563eb; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}

.stat-card {
  background: var(--subtle-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.stat-card .stat-label {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
}

.stat-card.highlight {
  background: #1e293b;
  border-color: #1e293b;
}
.stat-card.highlight .stat-label { color: #cbd5e1; }
.stat-card.highlight .stat-value { color: #fff; font-size: 26px; }

/* هيكل الصفحة الجديد: قائمة جانبية ثابتة على اليمين + محتوى الصفحة.
   الشاشة كلها بارتفاع الشاشة بالظبط (مش أكتر)، والقائمة الجانبية ثابتة
   مكانها تمامًا، وبس الجزء الأبيض (main-content) هو اللي بيتحرك (سكرول)
   لوحده لما المحتوى يطول - القائمة الجانبية متتحركش معاه خالص. */
html, body { height: 100%; }
.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sb-bg);
  color: var(--sb-text-strong);
  border-left: 1px solid var(--sb-line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: width .15s ease;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .sidebar-footer > div:first-child {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#sidebar-collapse-btn {
  background: var(--sb-btn);
  border: none;
  color: var(--sb-text-strong);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
#sidebar-collapse-btn:hover { background: var(--sb-btn-hover); }

/* الموبايل: مفيش عمود على الشمال، فالخروج بيفضل جوه القائمة */
.rail-role, #rail-logout-btn { display: none; }
.sidebar-version {
  margin-top: 8px;
  text-align: center;
  font-size: 10px;
  color: var(--sb-faint);
}

.main-content {
  height: 100vh;
  overflow-y: auto;
}
.main-content::-webkit-scrollbar { width: 12px; }
.main-content::-webkit-scrollbar-track { background: var(--scrollbar-track); }
.main-content::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 8px;
  border: 2px solid var(--scrollbar-track);
}
.main-content::-webkit-scrollbar-thumb:hover { background: #64748b; }

.sidebar-header {
  padding: 18px 16px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--sb-line);
  background: linear-gradient(180deg, rgba(96,165,250,.10), transparent);
}
.sidebar-header-text { display: flex; align-items: center; gap: 10px; }
/* اللوجو والاسم = زرار يرجّعك لنظرة عامة */
.sb-home { text-decoration: none; color: inherit; cursor: pointer; border-radius: 12px; padding: 2px 4px; margin: -2px -4px; transition: background .15s ease; }
.sb-home:hover { background: var(--sb-hover); }
.sb-home:hover .sb-logo { transform: scale(1.06); }
.sb-logo { transition: transform .15s ease; }
.sb-logo {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff; font-size: 20px; font-weight: 900;
  box-shadow: 0 4px 14px rgba(59,130,246,.45);
}
.sb-brand { color: var(--sb-text-strong); }
.sb-brand b { color: var(--sb-accent); font-weight: 800; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
  /* بنقلب الاتجاه هنا بس عشان السكرول باين ينتقل لأقصى يمين القائمة
     (بعيد عن المحتوى الأبيض)، وبعدين برجع الاتجاه لعناصر القائمة نفسها
     تحت عشان الكلام يفضل مقروء صح من اليمين للشمال */
  direction: ltr;
}
.sidebar-nav > * {
  direction: rtl;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--sb-btn-hover); }

/* عنوان المجموعة: مقفول = باهت والسهم للشمال، مفتوح = أزرق مميز وشريط على اليمين والسهم لتحت */
.sidebar-group-label {
  margin: 6px 10px 2px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--sb-text);
  border-right: 3px solid transparent;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.sidebar-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.sg-icon {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; background: var(--sb-btn);
  filter: grayscale(.6); opacity: .8;
  transition: background .18s ease, filter .18s ease, opacity .18s ease;
}
.sg-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-group-arrow {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--sb-text); background: var(--sb-btn);
  transform: rotate(90deg);
  transition: transform .22s ease, background .18s ease, color .18s ease;
}
.sidebar-group-toggle:hover { background: var(--sb-hover); color: var(--sb-text-strong); }
.sidebar-group-toggle:hover .sg-icon { filter: none; opacity: 1; }
.sidebar-group-toggle.open {
  background: rgba(96,165,250,.14);
  color: var(--sb-accent);
  border-right-color: var(--sb-accent);
}
.sidebar-group-toggle.open .sg-icon { background: rgba(96,165,250,.22); filter: none; opacity: 1; }
.sidebar-group-toggle.open .sidebar-group-arrow {
  transform: rotate(0deg);
  background: var(--sb-accent);
  color: #0f172a;
  box-shadow: 0 0 0 3px rgba(96,165,250,.18);
}
/* الفتح والقفل بحركة ناعمة */
.sidebar-group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s ease;
}
.sidebar-group-body.open { grid-template-rows: 1fr; }
.sidebar-group-inner { min-height: 0; overflow: hidden; }
.sidebar-group-body.open .sidebar-group-inner {
  margin: 2px 22px 6px 10px;
  padding: 3px 0;
  border-right: 2px solid rgba(96,165,250,.25);
}
.sidebar-group-inner .sidebar-link { margin: 1px 6px 1px 0; padding: 8px 12px; font-size: 13.5px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, transform .15s ease;
}
.sidebar-link-text { overflow: hidden; text-overflow: ellipsis; }
.sidebar-link-text.sb-small-text { font-size: 12.5px; letter-spacing: -.2px; } /* v473: «المستندات المحذوفة» تظهر كاملة */
.sidebar-icon { flex-shrink: 0; font-size: 16px; width: 20px; text-align: center; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px 6px; margin: 1px 6px; }
.sidebar.collapsed .sidebar-group-body.open .sidebar-group-inner { margin: 0; padding: 0; border: none; }
.sidebar.collapsed .sidebar-group-inner .sidebar-link { margin: 1px 6px; padding: 10px 6px; }
.sidebar.collapsed .sidebar-header { padding: 18px 8px; justify-content: center; }
.sidebar.collapsed .sidebar-link-text,
.sidebar.collapsed .sidebar-group-label,
.sidebar.collapsed .badge-soon {
  display: none;
}
.sidebar-link:hover { background: var(--sb-hover); color: var(--sb-text-strong); transform: translateX(-2px); }
.sidebar-link.active {
  background: linear-gradient(270deg, #2563eb, #4f46e5);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.sidebar-link.active:hover { transform: none; }
.sidebar-link.disabled { color: var(--sb-faint); }
.sidebar-link.disabled:hover { background: none; color: var(--sb-faint); }

.badge-soon {
  font-size: 10px;
  background: #334155;
  color: #94a3b8;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 6px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sb-line);
  font-size: 13px;
}
.sidebar-footer .btn.secondary { background: var(--sb-btn); color: var(--sb-text-strong); border: 1px solid var(--sb-line); }
.sidebar-footer .btn.secondary:hover { background: rgba(239,68,68,.22); border-color: rgba(239,68,68,.5); }
.sb-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; min-width: 0; }
.sb-user:empty { display: none; }
.sb-user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0ea5e9, #6366f1); color: #fff; font-weight: 800; font-size: 15px;
}
.sb-user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sb-user-info b { color: var(--sb-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info small { color: var(--sb-muted); font-size: 11px; }

.main-content {
  flex: 1;
  min-width: 0;
}

.page-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
}
.page-header h1 { margin: 0; font-size: 19px; color: #1e293b; }

/* نافذة منبثقة (Modal) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 4px 8px;
}
.modal-close:hover { color: #1e293b; }

/* لموديل طويل محتاج زرار الحفظ يفضل ظاهر طول الوقت من غير ما تنزل لآخر الفورم */
.modal-box-scroll {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.modal-box-scroll .modal-header {
  padding: 22px 24px 0;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.modal-box-scroll .modal-scroll-body {
  overflow-y: auto;
  padding: 0 24px 20px;
  flex: 1;
  min-height: 0;
}
.modal-box-scroll .modal-sticky-footer {
  flex-shrink: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
  border-radius: 0 0 12px 12px;
}

.subnav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subnav-label {
  color: #94a3b8;
  font-size: 13px;
  margin-left: 10px;
}

.subnav-link {
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 6px;
}

.subnav-link:hover { background: var(--hover-bg); }

.subnav-link.active {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 600;
}


/* ===== جداول الأعمدة الجديدة (نفس معاملة المنتجات): عرض ثابت، سطر واحد، وشريط إجماليات ثابت تحت =====
   الاستخدام: <table class="fixed-table"> جوه .table-scroll-wrap، و<div class="totals-bar"> بعده */
/* لازم الجدول يبقى ليه عرض محدد (100%) عشان المتصفح يحترم أرقام لوحة "الأعمدة"
   (width:auto كانت بتخلّيه يتجاهلها خالص). لو مجموع الأعمدة أصغر من المساحة، الزيادة
   بتتوزع عليهم بنفس النسبة (الجدول يملا مكانه)، ولو أكبر الجدول بيتحرك يمين وشمال */
.fixed-table { table-layout: fixed; width: 100%; }
.fixed-table th { position: relative; font-size: 11px; color: #000; }
.fixed-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.totals-bar {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  border-top: 2px solid var(--border-color);
  padding: 6px 14px;
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  z-index: 10;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
}
.totals-bar > * { flex-shrink: 0; }
.totals-bar .totals-text { display: flex; gap: 14px; flex-wrap: nowrap; white-space: nowrap; }
.totals-bar .totals-text > * { flex-shrink: 0; }
.totals-bar .totals-text:empty { display: none; }


/* ===== الشريط العلوي (بحث عام في البرنامج) + زرار فاتورة بيع جديدة العايم ===== */
#user-chip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 6px;
  /* شكل زجاجي (زي الآيفون): شفاف مع تغبيش اللي وراه */
  background: rgba(255,255,255,0.55);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: 999px;
  padding: 5px 6px;
  box-shadow: 0 8px 30px rgba(15,23,42,0.16), inset 0 1px 0 rgba(255,255,255,0.7);
}
:root[data-theme="dark"] #user-chip {
  background: rgba(30,41,70,0.45);
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 8px 30px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
}
#user-chip #notif-btn, #user-chip #theme-toggle-btn { background: rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.5); }
:root[data-theme="dark"] #user-chip #notif-btn,
:root[data-theme="dark"] #user-chip #theme-toggle-btn { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.14); }
.notif-wrap { position: relative; }
#notif-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--page-bg);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  position: relative;
}
#notif-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
#notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15,23,42,0.2);
  z-index: 200;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--hover-bg); }
.notif-ico { font-size: 16px; flex-shrink: 0; }
.notif-t { font-weight: 700; font-size: 13px; color: var(--text-main); }
.notif-s { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 13px; }

#theme-toggle-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--page-bg);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.chip-avatar, .chip-avatar-placeholder {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.chip-avatar-placeholder {
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
}

.gs-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  transition: width .22s ease;
}
.gs-wrap:hover,
.gs-wrap:focus-within { width: 210px; }
#global-search-input {
  width: 100%;
  height: 26px;
  padding: 6px 30px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  margin: 0;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity .15s ease .05s;
}
.gs-wrap:hover #global-search-input,
.gs-wrap:focus-within #global-search-input { opacity: 1; }
#global-search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.gs-icon {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .7;
  font-size: 12px;
  z-index: 2;
}

#global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15,23,42,0.2);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
}
.gs-group { padding: 6px 0; border-bottom: 1px solid var(--border-color); }
.gs-group:last-child { border-bottom: none; }
.gs-group-title { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 4px 16px; }
.gs-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.gs-item.active, .gs-item:hover { background: var(--hover-bg); }
.gs-item .gs-ico { width: 22px; text-align: center; flex-shrink: 0; }
.gs-item .gs-t { font-weight: 600; font-size: 14px; color: var(--text-main); }
.gs-item .gs-s { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.gs-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.gs-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 999px;
  background: var(--card-bg);
  white-space: nowrap;
}
.gs-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.gs-hint {
  position: absolute; left: 30px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--text-muted); pointer-events: none;
  opacity: 0; transition: opacity .15s ease .05s; white-space: nowrap;
}
.gs-wrap:hover .gs-hint,
.gs-wrap:focus-within .gs-hint { opacity: 1; }

#new-invoice-fab {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
  display: flex;
  align-items: center;
  direction: ltr;
  height: 50px;
  min-width: 50px;
  border-radius: 25px;
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(22,163,74,0.45);
  overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}
#new-invoice-fab:hover { box-shadow: 0 8px 24px rgba(22,163,74,0.6); transform: translateY(-50%) scale(1.03); }
#new-invoice-fab .fab-plus { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; flex-shrink: 0; line-height: 1; }
#new-invoice-fab .fab-label {
  direction: rtl;
  max-width: 0;
  opacity: 0;
  white-space: nowrap;
  font-weight: 700;
  font-size: 14px;
  transition: max-width .25s ease, opacity .2s ease, padding .25s ease;
}
#new-invoice-fab:hover .fab-label, #new-invoice-fab:focus-visible .fab-label { max-width: 240px; opacity: 1; padding: 0 18px 0 0; }
#new-invoice-fab kbd { background: rgba(255,255,255,0.25); border-radius: 5px; padding: 1px 6px; font-size: 11px; margin-right: 6px; font-family: inherit; }


/* ===== إشعار مركزي واضح (تم حفظ الفاتورة وأمثاله) ===== */
.center-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%) scale(.92);
  background: #16a34a;
  color: #fff;
  padding: 34px 56px;
  border-radius: 20px;
  font-size: 26px;
  font-weight: 800;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  z-index: 5000; /* v480: كانت 900 = بتظهر ورا أي نافذة مفتوحة (1000) فالرسالة مكانتش بتبان */
  opacity: 0;
  pointer-events: none;
  text-align: center;
  max-width: 90vw;
  transition: opacity .2s ease, transform .2s ease;
}
.center-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.center-toast.is-error { background: #dc2626; }
.center-toast.is-warning { background: #ea580c; }

/* ===== تحذير حذف كبير (الموافقة الأولى قبل نافذة سبب الحذف) ===== */
#big-delete-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 4000; /* v318: فوق أي نافذة (كان بيطلع تحت نافذة التحويل بين الخزن) */
  align-items: center;
  justify-content: center;
}
#big-delete-overlay.open { display: flex; }
.big-delete-box {
  background: #dc2626;
  color: #fff;
  border-radius: 18px;
  padding: 36px 40px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.big-delete-icon { font-size: 48px; margin-bottom: 10px; }
.big-delete-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.big-delete-sub { font-size: 13.5px; opacity: 0.92; margin-bottom: 22px; }
.big-delete-actions { display: flex; gap: 12px; justify-content: center; }
.big-delete-actions .btn.secondary { background: #fff; color: #991b1b; border: none; }
.big-delete-actions .btn.danger { background: #7f1d1d; }

/* الشهر الحالي هو أكتر فترة بتتستخدم في فلتر الوقت، فبيتميّز بلون وعلامة واضحة */
.date-filter-opt-starred { background: #fef3c7; color: #92400e; font-weight: 700; }
.date-filter-opt-starred:hover { background: #fde68a !important; }

/* ===== مربع بحث العملاء ===== */
.cp-wrap { position: relative; flex: 1; min-width: 0; }
.cp-input { width: 100%; padding-left: 30px !important; }
.cp-clear { position: absolute; left: 6px; top: 7px; display: none; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.cp-list { position: absolute; top: calc(100% + 4px); right: 0; left: 0; max-height: 320px; overflow-y: auto; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,0.22); z-index: 120; }
.cp-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.cp-item:last-child { border-bottom: none; }
.cp-item.active, .cp-item:hover { background: var(--hover-bg); }
.cp-item-main { min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; color: var(--text-main); }
.cp-item-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-phone { font-size: 11.5px; color: var(--text-muted); direction: ltr; text-align: right; }
.cp-item-side { display: flex; gap: 5px; flex-shrink: 0; }
.cp-pill { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.cp-branch { background: #e0e7ff; color: #3730a3; }
.cp-sc { background: #fef3c7; color: #92400e; margin-inline-start: 6px; } /* v482: كود/اختصار العميل */
/* 🎨 v484: تلوين الكلمات في الإعدادات = كروت صغيرة جنب بعض بتتسحب */
.wc-addbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wc-addbar #wc-new-word { flex: 0 1 300px; }
.wc-swatch { width: 38px; height: 34px; padding: 2px; margin: 0; cursor: pointer; border-radius: 8px; flex-shrink: 0; }
.wc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 8px; }
.wc-row { --wc: #2563eb; display: flex; align-items: center; gap: 6px; padding: 5px 6px; border: 1px solid var(--border-color); border-inline-start: 4px solid var(--wc); border-radius: 10px; background: var(--card-bg); cursor: grab; }
.wc-row:hover { border-color: var(--wc); }
.wc-row.wc-dragging { opacity: .4; }
.wc-row .wc-handle { color: var(--text-muted); font-size: 12px; letter-spacing: -2px; user-select: none; }
.wc-row .wc-word { flex: 1; min-width: 0; margin: 0; padding: 4px 6px; height: 30px; border: 1px solid transparent; background: transparent; font-weight: 800; font-size: 15px; cursor: text; }
.wc-row .wc-word:focus { border-color: var(--border-color); background: var(--subtle-bg); }
.wc-row .wc-swatch { width: 30px; height: 28px; }
.wc-row .wc-del { border: none; background: transparent; color: #dc2626; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 6px; flex-shrink: 0; }
.wc-row .wc-del:hover { background: #fee2e2; }
:root[data-theme="dark"] .wc-row .wc-del:hover { background: rgba(220,38,38,.2); }
:root[data-theme="dark"] .cp-sc { background: rgba(245,158,11,.2); color: #fcd34d; }
.cp-alayh { background: #fee2e2; color: #b91c1c; }
.cp-lahu { background: #dcfce7; color: #166534; }
.cp-zero { background: var(--subtle-bg); color: var(--text-muted); }
.cp-hint { padding: 10px 12px; font-size: 12.5px; color: var(--text-muted); text-align: center; }
/* نسخة التجربة (اللاب توب): شريط أحمر صغير ثابت فوق في النص - مش بيمنع الضغط على اللي تحته */
#dev-banner { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 99999; pointer-events: none;
  background: #dc2626; color: #fff; font-size: 12.5px; font-weight: 800; padding: 4px 16px; border-radius: 0 0 12px 12px;
  box-shadow: 0 3px 10px rgba(220,38,38,.35); white-space: nowrap; max-width: 96vw; overflow: hidden; text-overflow: ellipsis; }
#dev-banner a { color: #fff; text-decoration: underline; pointer-events: auto; }
@media (max-width: 900px) { #dev-banner { top: auto; bottom: 0; border-radius: 12px 12px 0 0; font-size: 11.5px; } }
/* زرار "عميل/مورد جديد" جوه قايمة البحث - بيبقى بارز (أخضر) لو مفيش نتايج */
.cp-add-new { display: block; width: calc(100% - 12px); margin: 6px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 700; text-align: center; border: 1px dashed var(--border-color); background: var(--subtle-bg); color: var(--text-main); }
.cp-add-new:hover { border-color: #16a34a; color: #15803d; }
.cp-add-new.strong { border: none; background: #16a34a; color: #fff; font-size: 14.5px; padding: 11px 12px; }
.cp-add-new.strong:hover { background: #15803d; color: #fff; }
.cp-selected-meta { display: flex; gap: 5px; margin-top: 5px; min-height: 0; }
.cp-selected-meta:empty { display: none; }
.cp-cls-company { background: #ccfbf1; color: #0f766e; }
.cp-cls-tech { background: #f3e8ff; color: #7e22ce; }
.cp-cls-default { background: var(--subtle-bg); color: var(--text-muted); }

/* ===== أسماء العملاء/الموردين (روابط) جوه الجداول =====
   بدل لون المتصفح الافتراضي (أزرق/موف) اللي مش باين في الوضع الغامق */
td a:not(.btn), td a:not(.btn):visited { color: #1d4ed8; font-weight: 700; text-decoration: none; }
td a:not(.btn):hover { text-decoration: underline; }
:root[data-theme="dark"] td a:not(.btn),
:root[data-theme="dark"] td a:not(.btn):visited { color: #7dd3fc; }

/* ===== الوضع الغامق: أشرطة السكرول وعناصر المتصفح تبقى غامقة ===== */
:root[data-theme="dark"] { color-scheme: dark; }
/* القوايم المنسدلة (select): الاختيارات نفسها غامقة، من غير الجزء الأبيض اللي كان بيظهر */
:root[data-theme="dark"] select { color-scheme: dark; background-color: var(--input-bg); color: var(--text-main); }
:root[data-theme="dark"] select option,
:root[data-theme="dark"] select optgroup { background-color: #0e172c; color: #e2e8f0; }
:root[data-theme="dark"] select option:checked { background-color: #1d4ed8; color: #fff; }
:root[data-theme="dark"] ::-webkit-scrollbar { width: 12px; height: 12px; }
:root[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #35416b; border-radius: 8px; border: 2px solid var(--scrollbar-track); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4b5b8f; }
:root[data-theme="dark"] ::-webkit-scrollbar-corner { background: var(--scrollbar-track); }

/* مبالغ داخل/خارج - أخضر/أحمر واضحين في الوضعين */
.amt-in { color: #166534; font-weight: 700; }
.amt-out { color: #b91c1c; font-weight: 700; }
:root[data-theme="dark"] .amt-in { color: #4ade80; }
:root[data-theme="dark"] .amt-out { color: #f87171; }
:root[data-theme="dark"] input[type="file"]::file-selector-button { background: var(--subtle-bg); color: var(--text-main); border: 1px solid var(--input-border); border-radius: 6px; padding: 4px 10px; cursor: pointer; }

/* الوضع الغامق: الأخضر/الأحمر الغامق المكتوب جوه الصفحات (له/عليه، داخل/خارج)
   بيتفتّح تلقائي عشان يبان على الخلفية الكحلي */
:root[data-theme="dark"] [style*="color:#166534"]:not([style*="background"]) { color: #4ade80 !important; }
:root[data-theme="dark"] [style*="color:#b91c1c"]:not([style*="background"]) { color: #f87171 !important; }

/* ===== لوحة الأعمدة المشتركة (createSmartTable في app.js) ===== */
.smart-cols-panel { position: absolute; left: 0; top: calc(100% + 6px); background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); color: var(--text-main); padding: 10px 14px; z-index: 50; min-width: 280px; max-height: 420px; overflow-y: auto; }
.smart-cols-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border-color); }
.smart-cols-row:last-child { border-bottom: none; }
.smart-cols-row button { width: 22px; height: 22px; padding: 0; font-size: 11px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--subtle-bg); color: var(--text-main); cursor: pointer; }
.smart-cols-row button:disabled { opacity: .35; cursor: default; }
.smart-cols-row label { display: flex; align-items: center; gap: 6px; font-weight: 700; flex: 1; margin: 0; font-size: 13px; white-space: nowrap; }
.smart-cols-row input[type="number"] { width: 56px; padding: 3px 5px; font-size: 12px; }

/* ===== مربع «شير» (صورة / PDF / إكسيل / واتساب) ===== */
.share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.share-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px; border: 2px solid var(--border-color); border-radius: 14px; background: var(--card-bg); color: var(--text-main); cursor: pointer; font-family: inherit; font-size: 15px; transition: border-color .15s ease, background .15s ease; }
.share-tile:hover:not(:disabled) { border-color: #2563eb; background: var(--hover-bg); }
.share-tile:disabled { opacity: .55; cursor: not-allowed; }
.share-ico { font-size: 34px; line-height: 1; }
.share-tile small { font-size: 12px; color: var(--text-muted); }
.share-soon { background: #fef3c7; color: #92400e !important; padding: 1px 10px; border-radius: 99px; font-weight: 700; }

/* الصنف المعلّم بالكيبورد (↑ ↓) في قوايم اختيار الأصناف - Enter بيضيفه */
/* السطر كله أزرق غامق والكلام أبيض عريض عشان يبان من أول نظرة (فاتح وغامق) */
@media (min-width: 901px) {
  tr.kb-active td { background: #2563eb !important; color: #fff !important; font-weight: 700; }
  tr.kb-active td * { color: #fff !important; }
  tr.kb-active td:first-child { box-shadow: inset -5px 0 0 #f59e0b; }
  .kb-active:not(tr) { background: #2563eb !important; color: #fff !important; font-weight: 700; box-shadow: inset -5px 0 0 #f59e0b; }
  .kb-active:not(tr) * { color: #fff !important; }
}
/* 📱 v539: الموبايل - الصنف المعلّم مربع برتقاني منوّر حواليه كله (التلوين الأزرق كان بيطلع على الكلام بس زي التحديد) */
@media (max-width: 900px) {
  tr.kb-active, .kb-active:not(tr) { outline: 2px solid #f97316; outline-offset: -2px; border-radius: 10px; box-shadow: 0 0 0 3px rgba(249,115,22,.25), 0 0 16px rgba(249,115,22,.55) !important; }
}

/* خلية التاريخ والوقت في الجداول: خط أصغر شوية (بيتحط تلقائي من app.js) */
td.dt { font-size: 12px; color: var(--text-muted); letter-spacing: .2px; }

/* أزرار نهاية الفاتورة: حفظ وطباعة / حفظ وشير */
.save-actions { display: flex; gap: 10px; flex-wrap: wrap; }
/* 💾 v467 (طلب صاحب المشروع - الشغل دايمًا بـ «حفظ» بس): «حفظ» أخضر كبير ومميز، و«حفظ وطباعة» رصاصي */
.btn.save-only, .df-actions .btn.save-only, .save-actions .btn.save-only { background: #16a34a; font-size: 19px; font-weight: 800; padding: 12px 44px; border-radius: 10px; box-shadow: 0 0 0 3px #bbf7d0; }
.btn.save-only:hover:not(:disabled) { background: #15803d; }
.btn.save-print { background: #64748b; }
.btn.save-print:hover:not(:disabled) { background: #475569; }
:root[data-theme="dark"] .btn.save-only { box-shadow: 0 0 0 3px #14532d; }
@media (max-width: 900px) { .btn.save-only, .df-actions .btn.save-only, .save-actions .btn.save-only { padding: 10px 12px; } }
.btn.save-share { background: #2563eb; }

/* =====================================================================
   الموبايل والتابلت (أقل من 900px)
   القائمة الجانبية = درج بيتفتح بزرار ☰ من شريط فوق، والمحتوى بياخد الشاشة كلها
   ===================================================================== */
#mobile-topbar, #sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* الصفحة كلها بتعمل سكرول عادي (مش جزء جوه جزء) */
  html, body { height: auto; }
  .app-shell { display: block; height: auto; }
  .main-content { height: auto; overflow: visible; }
  body.has-mobile-shell .main-content { padding-top: 56px; }

  /* الشريط اللي فوق */
  #mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; right: 0; left: 0; height: 52px; z-index: 80;
    padding: 0 10px; background: var(--sb-bg); color: var(--sb-text-strong);
    border-bottom: 1px solid var(--sb-line); box-shadow: 0 2px 8px rgba(0,0,0,.15);
  }
  :root[data-theme="dark"] #mobile-topbar { background: #121b32; }
  #mobile-menu-btn {
    width: 40px; height: 40px; border: none; border-radius: 10px; font-size: 22px; line-height: 1;
    background: var(--sb-btn); color: var(--sb-text-strong); cursor: pointer;
  }
  .mobile-topbar-title { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
  .mobile-topbar-title span { color: var(--sb-accent); }

  /* القائمة الجانبية كدرج من اليمين */
  .sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; width: 280px; max-width: 85vw; height: 100%;
    z-index: 200; transform: translateX(105%); transition: transform .22s ease;
    background: #1e293b; box-shadow: none;
  }
  :root[data-theme="dark"] .sidebar { background: #121b32; }
  body.sidebar-open .sidebar { transform: none; box-shadow: -8px 0 30px rgba(0,0,0,.35); }
  body.sidebar-open { overflow: hidden; }
  #sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; }
  body.sidebar-open #sidebar-backdrop { display: block; }
  #sidebar-collapse-btn { display: none; }
  .sidebar-header { padding: 16px 18px; }
  .sidebar-link, .sidebar-group-inner .sidebar-link { padding: 11px 12px; font-size: 15px; }
  .sidebar-group-label { font-size: 14px; padding: 11px 10px; }

  /* شريحة البحث/الإشعارات: جوه الشريط اللي فوق على الشمال */
  #user-chip { top: 8px; left: 8px; z-index: 90; box-shadow: none; }
  .gs-wrap:hover, .gs-wrap:focus-within { width: 170px; }

  /* زرار + الأخضر: تحت على الشمال بدل نص الشاشة */
  #new-invoice-fab { top: auto; bottom: 16px; left: 16px; transform: none; }
  #new-invoice-fab:hover { transform: none; }

  /* المسافات والخطوط */
  .container { margin: 10px auto; padding: 0 8px; }
  .card { padding: 14px 12px; margin-bottom: 12px; border-radius: 10px; }
  h2 { font-size: 18px; }
  .page-header { padding: 12px 14px; }
  .page-header h1 { font-size: 17px; }

  /* خانات الإدخال: كبيرة وسهلة باللمس، و16px عشان الآيفون ميعملش زووم */
  input, select, textarea { font-size: 16px; max-width: 100%; }
  .btn { padding: 10px 14px; }
  form .row > div { min-width: 100%; }

  /* الجداول: تتحرك يمين وشمال جوه مكانها بدل ما توسّع الصفحة */
  .table-scroll-wrap { max-height: none; -webkit-overflow-scrolling: touch; }
  :not(.table-scroll-wrap) > table:not(.fixed-table):not(.items) { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .totals-bar { flex-wrap: wrap; }
  .totals-bar .totals-text { flex-wrap: wrap; white-space: normal; gap: 6px 12px; }

  /* تابات الفروع وفترات الوقت أصغر شوية */
  .branch-tab { min-width: 0; flex: 1 1 45%; padding: 9px 8px; font-size: 13px; }

  /* النوافذ: بتاخد الشاشة كلها */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal-box { max-width: 100% !important; width: 100%; max-height: 100%; height: 100%; border-radius: 0; padding: 16px 14px; }
  .share-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .center-toast { font-size: 19px; padding: 22px 26px; max-width: 88vw; }
  .big-delete-box { padding: 26px 20px; }

  /* لوحة الأعمدة: متخرجش برة الشاشة */
  .smart-cols-panel { min-width: 260px; max-width: calc(100vw - 24px); }

  /* سطور الأصناف في فواتير البيع/الشراء: اسم الصنف سطر لوحده والأرقام تحته */
  .inv-items-head { display: none !important; }
  .inv-item-row, .show-profit .inv-item-row {
    grid-template-columns: 1fr 1fr 1fr auto !important;
    padding: 8px 0; border-bottom: 1px solid var(--border-color);
  }
  .inv-item-row > div:first-child:not(.item-no) { grid-column: 1 / -1; font-weight: 700; } /* فاتورة الشراء */
  .inv-item-row .item-no { display: none; }
  .inv-item-row .item-name { grid-column: 1 / -1; font-weight: 700; }
  .inv-item-row .item-name::before { content: attr(data-no) ". "; color: var(--text-muted); }
  .pay-type-row { gap: 6px; }
  .pay-type-btn { font-size: 14px; padding: 12px 4px; }
  .pay-line, .pay-line.single { grid-template-columns: 1fr 1fr !important; }
  /* v491: على الموبايل كارت المبلغ مش ثابت فوق (كان بيغطي زراير نقدي/آجل/متعدد) وأصغر */
  .pay-sticky { position: static !important; top: auto; gap: 8px; padding: 10px 12px !important; }
  .pay-sticky > div:has(> #pay-h-total) { min-width: 0 !important; padding: 6px 14px !important; }
}

/* ===== الموبايل: زراير عمود الإجراءات أيقونات صغيرة من غير كلام =====
   كل زرار بيتعرف من وظيفته (onclick/href) وبياخد أيقونته، والكلام بيستخبى */
@media (max-width: 900px) {
  .table-scroll-wrap td.sticky-col { padding: 4px; }
  .table-scroll-wrap td.sticky-col > div { gap: 4px !important; }
  .table-scroll-wrap td.sticky-col :is(
    [onclick^="openInvoice"], [onclick^="openPurchase"], [onclick^="openReturnDetail"], [onclick^="openTransferDetail"],
    [onclick^="openDeleted"], [onclick^="openEdit("], a[href^="customer.html"], a[href^="supplier.html"], a[href^="drawer-statement.html"],
    a[href*="edit="], [onclick^="openEditUser"], [onclick^="openEditItem"], [onclick^="openEditProduct"], [onclick^="editTx"],
    [onclick^="openDelete"], [onclick^="deleteQuote"], [onclick^="deleteItem"], [onclick^="deleteProduct"],
    [onclick^="openDuplicateProduct"], [onclick^="openPriceEdit"], [onclick^="openPayModal"], [onclick^="toggleActive"]
  ) {
    font-size: 0 !important; width: 30px; height: 30px; padding: 0 !important; border-radius: 8px !important;
    display: inline-flex !important; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: none !important;
  }
  .table-scroll-wrap td.sticky-col :is([onclick^="openInvoice"], [onclick^="openPurchase"], [onclick^="openReturnDetail"], [onclick^="openTransferDetail"], [onclick^="openDeleted"], [onclick^="openEdit("], a[href^="customer.html"], a[href^="supplier.html"])::before { content: "👁"; font-size: 15px; }
  .table-scroll-wrap td.sticky-col a[href^="drawer-statement.html"]::before { content: "📒"; font-size: 15px; }
  .table-scroll-wrap td.sticky-col :is(a[href*="edit="], [onclick^="openEditUser"], [onclick^="openEditItem"], [onclick^="openEditProduct"], [onclick^="editTx"])::before { content: "✎"; font-size: 16px; font-weight: 700; }
  .table-scroll-wrap td.sticky-col :is([onclick^="openDelete"], [onclick^="deleteQuote"], [onclick^="deleteItem"], [onclick^="deleteProduct"])::before { content: "🗑"; font-size: 14px; }
  .table-scroll-wrap td.sticky-col [onclick^="openDuplicateProduct"]::before { content: "⧉"; font-size: 16px; }
  .table-scroll-wrap td.sticky-col [onclick^="openPriceEdit"]::before { content: "💲"; font-size: 14px; }
  .table-scroll-wrap td.sticky-col [onclick^="openPayModal"]::before { content: "💸"; font-size: 15px; }
  .table-scroll-wrap td.sticky-col [onclick^="toggleActive"]::before { content: "⏻"; font-size: 15px; }
  .table-scroll-wrap td.sticky-col .muted { font-size: 10px !important; }

  /* عرض عمود الأزرار على قد الأيقونات (بيغطي على العرض المكتوب في الكود) */
  .table-scroll-wrap th.sticky-col { width: 108px !important; }                      /* 3 زراير */
  #po-table th.sticky-col { width: 142px !important; }                                 /* 4 زراير */
  :is(#suppliers-table, #usr-table, #ql-table, #items-table) th.sticky-col { width: 76px !important; }  /* زرارين */
  :is(#customers-table, #drawer-table, #dl-table, #ed-table) th.sticky-col { width: 44px !important; }  /* زرار واحد */
  #tx-table th.sticky-col { width: 60px !important; }
}

/* ===== الموبايل: كروت بدل الجداول (createMobileList / createSmartTable) - الكمبيوتر مبيتأثرش ===== */
.m-list, .m-only { display: none; }
@media (max-width: 900px) {
  .m-has-list, .m-hide { display: none !important; }
  .m-only { display: block; }
  .m-list { display: flex; flex-direction: column; gap: 8px; }
  .m-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px; padding: 11px 13px;
    box-shadow: var(--shadow-card); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .m-card:active { background: var(--hover-bg); }
  .m-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .m-card-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 800; color: var(--heading-color); line-height: 1.5; word-break: break-word; }
  .m-card-main { flex: 1; min-width: 0; }
  .m-card-main .m-card-sub { margin-top: 1px; }
  .m-avatar { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; color: var(--av); background: color-mix(in srgb, var(--av) 14%, transparent); }
  .m-contact { display: flex; gap: 8px; margin-top: 9px; }
  .m-contact a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 10px; font-size: 13.5px; font-weight: 700; text-decoration: none;
    background: var(--subtle-bg); border: 1px solid var(--border-color); color: var(--text-main); direction: ltr; }
  .m-contact a.wa { flex: 0 0 auto; padding: 8px 14px; direction: rtl; background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.3); color: #15803d; }
  :root[data-theme="dark"] .m-contact a.wa { color: #4ade80; }
  /* كارت رأس الشاشة (العميل / المورد): الاسم والرصيد كبار والأزرار شبكة */
  .m-hero > div:first-child > div:first-child { width: 100%; }
  .m-hero h2 { font-size: 21px; margin-bottom: 4px; }
  .m-hero #customer-balance-line, .m-hero #supplier-balance-line { font-size: 20px !important; padding: 10px 12px; border-radius: 12px; background: var(--subtle-bg); }
  .m-btn-grid { display: grid !important; grid-template-columns: repeat(3, 1fr); width: 100%; gap: 6px !important; }
  .m-btn-grid .btn { padding: 10px 4px; font-size: 12.5px; white-space: normal; line-height: 1.35; }
  /* عنوان الشاشة في الشريط اللي فوق بدل سطر العنوان الكبير */
  body.mt-has-title .page-header { display: none; }
  .mobile-topbar-page { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
  .mobile-topbar-logo { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; font-weight: 900; font-size: 15px; flex-shrink: 0; }
  /* ===== كارت الصنف (المنتجات): الأسعار التلاتة + كمية كل فرع ===== */
  .m-thumb { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border-color); }
  .m-product .m-avatar { width: 46px; height: 46px; }
  .m-chev { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: var(--subtle-bg); color: var(--text-muted); font-size: 12px; }
  .m-product.open { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15), var(--shadow-card); }
  .m-product.open .m-chev { background: #2563eb; color: #fff; }
  .m-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
  .m-price { border-radius: 11px; padding: 6px 8px; text-align: center; border: 1px solid transparent; }
  .m-price small { display: block; font-size: 11.5px; font-weight: 700; opacity: .85; }
  .m-price b { display: block; font-size: 17px; font-weight: 900; white-space: nowrap; }
  .m-price.sale { background: rgba(37,99,235,.10); color: #1d4ed8; border-color: rgba(37,99,235,.25); }
  .m-price.tech { background: rgba(234,88,12,.10); color: #c2410c; border-color: rgba(234,88,12,.25); }
  .m-price.comp { background: rgba(124,58,237,.10); color: #6d28d9; border-color: rgba(124,58,237,.25); }
  :root[data-theme="dark"] .m-price.sale { color: #93c5fd; }
  :root[data-theme="dark"] .m-price.tech { color: #fdba74; }
  :root[data-theme="dark"] .m-price.comp { color: #c4b5fd; }
  .m-stocks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .m-stock { font-size: 12.5px; padding: 4px 10px; border-radius: 99px; background: rgba(22,163,74,.10); color: #166534; font-weight: 600; white-space: nowrap; }
  .m-stock b { font-weight: 900; font-size: 13.5px; }
  .m-stock.low { background: rgba(217,119,6,.15); color: #b45309; }
  .m-stock.zero { background: rgba(220,38,38,.10); color: #b91c1c; }
  .m-stock.total { background: var(--subtle-bg); color: var(--text-main); }
  .m-stock.svc { background: rgba(79,70,229,.12); color: #4338ca; }
  .m-stock.sel { outline: 2px solid currentColor; }
  :root[data-theme="dark"] .m-stock { color: #4ade80; }
  :root[data-theme="dark"] .m-stock.low { color: #fbbf24; }
  :root[data-theme="dark"] .m-stock.zero { color: #f87171; }
  :root[data-theme="dark"] .m-stock.total { color: var(--text-main); }
  :root[data-theme="dark"] .m-stock.svc { color: #a5b4fc; }
  .m-details { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); cursor: default; }
  .m-unit { margin-bottom: 10px; }
  .m-unit-name { font-size: 13.5px; font-weight: 800; color: var(--text-main); }
  .m-unit .m-prices { margin-top: 4px; }
  .m-unit .m-price b { font-size: 15px; }
  /* البحث يفضل ظاهر فوق وإنت بتعمل سكرول */
  .m-search-row { position: sticky; top: 52px; z-index: 30; background: var(--card-bg); padding: 8px 0; margin: -4px 0 6px !important; gap: 6px !important; }
  .m-search-row input { flex: 1 1 100% !important; min-width: 0 !important; font-size: 16px; padding: 12px 14px; border-radius: 12px; margin: 0; }
  .m-search-row .btn { flex: 1 1 40%; padding: 8px 10px !important; font-size: 12.5px; }
  /* ===== اختيار الأصناف في الفاتورة (بيع/شراء): ملء الشاشة على الموبايل ===== */
  #picker-close-m { display: none; }
  .picker-search-row { flex-wrap: wrap; gap: 6px !important; }
  #picker-search { flex: 1 1 100% !important; font-size: 16px; padding: 13px 14px; border-radius: 12px; }
  .picker-search-row .btn { flex: 1 1 auto; }
  .picker-wrap.open { position: fixed !important; inset: 0; z-index: 400; margin: 0 !important; background: var(--card-bg);
    display: flex; flex-direction: column; padding: 10px 10px 0; }
  body:has(.picker-wrap.open) { overflow: hidden; }
  .picker-wrap.open .picker-search-row { flex-wrap: wrap; gap: 6px !important; }
  .picker-wrap.open #picker-search { flex: 1 1 100% !important; font-size: 16px; padding: 13px 14px; border-radius: 12px; }
  .picker-wrap.open .picker-search-row .btn { flex: 1 1 auto; padding: 9px 8px; font-size: 13px; }
  .picker-wrap.open #picker-close-m { display: inline-flex; justify-content: center; }
  .picker-wrap:not(.open) #picker-filters-btn-m { display: none; }
  .picker-wrap.open .picker-dropdown { position: static !important; display: flex !important; flex-direction: column; flex: 1; min-height: 0;
    margin-top: 8px; padding: 0; border: none; box-shadow: none; background: transparent; }
  .picker-wrap.open .picker-dropdown .table-scroll-wrap { max-height: none !important; flex: 1; overflow-y: auto; border: none; }
  .picker-wrap.open #picker-table, .picker-wrap.open #picker-table tbody { display: block; width: 100%; }
  .picker-wrap.open #picker-table thead { display: none; }
  .picker-wrap.open #picker-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; padding: 11px 6px;
    border-bottom: 1px solid var(--border-color); }
  .picker-wrap.open #picker-table tr:active { background: var(--hover-bg); }
  .picker-wrap.open #picker-table td { display: inline; padding: 0 !important; border: none !important; white-space: nowrap; font-size: 13px; color: var(--text-muted); }
  .picker-wrap.open #picker-table td[data-label]:not([data-label=""])::before { content: attr(data-label) ": "; font-size: 11.5px; }
  .picker-wrap.open #picker-table td[data-k="name"] { flex: 1 1 100%; white-space: normal; font-size: 15px; font-weight: 800; color: var(--heading-color); }
  .picker-wrap.open #picker-table td[data-k="name"]::before, .picker-wrap.open #picker-table td[data-k="id"] { display: none; }
  .picker-wrap.open #picker-table td:is([data-k="sale_price"], [data-k="technician_price"], [data-k="company_price"]) { color: #2563eb; font-weight: 800; font-size: 14px; }
  .picker-wrap.open #picker-table td[data-k="quantity"] { color: #16a34a; font-weight: 800; }
  /* رقم كبير مميز (إجمالي الخزنة...) */
  .m-big-total { border-radius: 16px; padding: 16px 18px; margin-bottom: 10px; color: #fff;
    background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 60%, #7c3aed 100%); box-shadow: 0 8px 22px rgba(79,70,229,.3); }
  .m-big-total small { display: block; font-size: 13px; font-weight: 700; opacity: .9; }
  .m-big-total b { display: block; font-size: 30px; font-weight: 900; letter-spacing: .5px; margin: 2px 0; }
  .m-big-total span { font-size: 12px; opacity: .85; }
  /* الأرقام بالسالب: علامة - على الشمال صح (مش بعد الرقم) */
  .m-big-total b, .m-summary b, .m-tx-amount > span { unicode-bidi: plaintext; text-align: right; }
  .m-big-total b, .m-summary b { direction: ltr; text-align: right; }
  /* سطر حركة (كشف حساب / خزنة): أيقونة + البيان + المبلغ والرصيد بعده */
  .m-tx { display: flex; align-items: center; gap: 10px; }
  .m-tx-main { flex: 1; min-width: 0; }
  .m-tx-main .m-card-title { font-size: 14px; }
  .m-tx-icon { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; }
  .m-tx-icon.alayh { background: rgba(220,38,38,.12); color: #dc2626; }
  .m-tx-icon.lahu { background: rgba(22,163,74,.13); color: #16a34a; }
  .m-tx-side { flex-shrink: 0; text-align: left; }
  .m-tx-amount { font-size: 15.5px; font-weight: 800; white-space: nowrap; text-align: left; }
  .m-tx-amount small { font-size: 11.5px; font-weight: 700; }
  .m-tx-amount.alayh { color: #dc2626; }
  .m-tx-amount.lahu { color: #16a34a; }
  .m-tx-bal { font-size: 12px; white-space: nowrap; margin-top: 2px; }
  .m-tx-bal span { font-weight: 700 !important; }
  .m-card-amount { flex-shrink: 0; font-size: 15px; font-weight: 800; white-space: nowrap; }
  .m-card-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 12.5px; color: var(--text-muted); }
  .m-card-sub > span:not(:last-child)::after { content: "•"; margin-right: 10px; opacity: .6; }
  .m-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-color); }
  .m-card-grid > div { min-width: 0; display: flex; flex-direction: column; }
  .m-card-grid small { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
  .m-card-grid span { font-size: 14px; font-weight: 700; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; }
  .m-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; justify-content: flex-end; }
  .m-card-actions > div { display: flex !important; flex-wrap: wrap; gap: 6px !important; }
  .m-card-actions .btn, .m-card-actions button { padding: 7px 12px; font-size: 13px; }
  .m-sortbar { display: flex; align-items: center; gap: 6px; }
  .m-count { flex: 1; font-size: 13px; font-weight: 700; color: var(--text-muted); }
  .m-sortbar select { width: auto; max-width: 55%; margin: 0; padding: 7px 10px; font-size: 14px; }
  .m-sort-dir { width: 38px; height: 38px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--subtle-bg); color: var(--text-main); font-size: 13px; }
  .m-empty { text-align: center; padding: 24px; color: var(--text-muted); }
  .m-more { width: 100%; }
  .m-pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13.5px; font-weight: 800; white-space: nowrap; }
  .m-pill.alayh { background: rgba(220,38,38,.12); color: #b91c1c; }
  .m-pill.lahu { background: rgba(22,163,74,.13); color: #166534; }
  .m-pill.zero { background: var(--subtle-bg); color: var(--text-muted); }
  :root[data-theme="dark"] .m-pill.alayh { color: #f87171; }
  :root[data-theme="dark"] .m-pill.lahu { color: #4ade80; }
  /* كروت ملخص فوق القايمة (إجماليات) */
  .m-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; margin-bottom: 10px; }
  .m-summary > div { background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 8px 10px; }
  .m-summary small { display: block; font-size: 11.5px; color: var(--text-muted); font-weight: 700; }
  .m-summary b { font-size: 16px; white-space: nowrap; }
  /* شرايح اختيار سريعة (ترتيب / فلتر) بتتحرك يمين وشمال */
  .m-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
  .m-chips button { flex-shrink: 0; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--border-color); background: var(--subtle-bg);
    color: var(--text-main); font-family: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; }
  .m-chips button.active { background: #2563eb; border-color: #2563eb; color: #fff; }
  /* تابات الفروع (الشركة / بورسعيد / المطرية): سطر واحد بيتحرك يمين وشمال */
  #branch-filter-bar { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  #branch-filter-bar .branch-tab { flex: 0 0 auto; white-space: nowrap; padding: 8px 14px; border-radius: 99px; margin: 0; }
  .m-scroll-row { flex-wrap: nowrap !important; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .m-scroll-row > * { flex-shrink: 0; white-space: nowrap; }
  /* زرار الفلاتر: الفلاتر مقفولة لحد ما تدوس عليه */
  .m-filter-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .m-filters:not(.open) { display: none !important; }
}

/* موبايل صغير جدًا */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .share-tile { padding: 14px 6px; }
}


/* ===== عمود الأيقونات على الشمال (الكمبيوتر بس) =====
   فاتورة جديدة + بحث + إشعارات + الوضع الغامق + صورتك، فوق بعض في عمود ثابت بلون القائمة،
   والمحتوى بيبدأ بعده فمبيغطيش على أي قايمة أو جدول. اللي بيفتح (بحث/إشعارات) بيطلع على يمينه. */
@media (min-width: 901px) {
  #user-chip {
    top: 0; left: 0; bottom: 0;
    width: 60px;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-radius: 0;
    background: var(--sb-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: none;
    border-right: 1px solid var(--sb-line);
    box-shadow: 2px 0 12px rgba(15,23,42,0.12);
  }
  :root[data-theme="dark"] #user-chip { background: var(--sb-bg); border-color: var(--sb-line); box-shadow: 2px 0 12px rgba(0,0,0,0.35); }
  .container { padding-left: 80px; }
  .rail-spacer { flex: 1; }

  /* تحت الصورة: الوظيفة بخط صغير + أيقونة الخروج. ومربع الاسم والخروج اللي تحت القائمة بيستخبى */
  #user-chip .rail-role {
    display: block; margin-top: -6px; max-width: 56px; font-size: 10px; font-weight: 700; color: var(--sb-muted);
    text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #user-chip #rail-logout-btn {
    display: inline-flex; width: 36px; height: 36px; border-radius: 10px; font-size: 16px; cursor: pointer;
    align-items: center; justify-content: center; color: #fff;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.10);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
  }
  #user-chip #rail-logout-btn:hover { background: rgba(239,68,68,.30); border-color: rgba(239,68,68,.6); transform: scale(1.06); }
  .sidebar-footer .sb-user, .sidebar-footer .sb-logout { display: none !important; }
  .sidebar-footer { padding: 8px 14px; }
  .sidebar-version { margin-top: 0; }

  /* كل الأيقونات نفس المقاس */
  #user-chip #notif-btn, #user-chip #theme-toggle-btn, #user-chip .gs-wrap,
  #user-chip .chip-avatar, #user-chip .chip-avatar-placeholder {
    width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
  }
  #user-chip #notif-btn, #user-chip #theme-toggle-btn, #user-chip .chip-avatar-placeholder {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: #fff;
    transition: background .15s ease, transform .15s ease;
  }
  #user-chip #notif-btn:hover, #user-chip #theme-toggle-btn:hover { background: rgba(255,255,255,0.18); transform: scale(1.06); }
  #user-chip .chip-avatar { border: 2px solid rgba(255,255,255,0.35); border-radius: 50%; }
  #user-chip .chip-avatar-placeholder { border-radius: 50%; }
  #user-chip #notif-badge { top: -5px; left: auto; right: -5px; min-width: 18px; height: 18px; font-size: 11px; }

  /* زرار فاتورة البيع الجديدة: مربع أخضر فوق، والاسم بيطلع على يمينه لما تقف عليه */
  #user-chip #new-invoice-fab {
    position: relative; left: auto; top: auto; transform: none;
    width: 44px; min-width: 44px; height: 44px; border-radius: 14px; overflow: visible; margin-bottom: 4px;
  }
  #user-chip #new-invoice-fab:hover { transform: scale(1.06); }
  #user-chip #new-invoice-fab .fab-plus { width: 44px; height: 44px; font-size: 26px; }
  #user-chip #new-invoice-fab .fab-label {
    position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
    max-width: none; padding: 7px 12px; border-radius: 9px; background: #15803d; box-shadow: 0 6px 18px rgba(0,0,0,.2);
    pointer-events: none;
  }
  #user-chip #new-invoice-fab:hover .fab-label { opacity: 1; padding: 7px 12px; }

  /* البحث: الأيقونة في العمود، والخانة بتفتح على يمينها */
  #user-chip .gs-wrap { position: relative; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); cursor: text; transition: background .15s ease; }
  #user-chip .gs-wrap:hover, #user-chip .gs-wrap:focus-within { width: 40px; background: rgba(255,255,255,0.18); }
  #user-chip .gs-icon { right: 50%; transform: translate(50%, -50%); font-size: 17px; opacity: .95; }
  #user-chip #global-search-input {
    position: absolute; left: calc(100% + 12px); top: 0; height: 40px; width: 0; padding: 0;
    border-radius: 12px; opacity: 0; pointer-events: none;
    transition: width .2s ease, opacity .15s ease, padding .2s ease;
    box-shadow: 0 10px 28px rgba(15,23,42,0.22);
  }
  #user-chip .gs-wrap:focus-within #global-search-input { width: 340px; padding: 6px 12px; opacity: 1; pointer-events: auto; }
  #user-chip .gs-wrap:hover #global-search-input { opacity: 0; }
  #user-chip .gs-wrap:focus-within:hover #global-search-input { opacity: 1; }
  #user-chip .gs-hint { display: none; }
  #user-chip #global-search-results { left: calc(100% + 12px); top: 48px; width: 340px; }
  #user-chip #notif-panel { left: calc(100% + 12px); top: 0; }
}


/* ===== نافذة المستند فوق التقارير (openDocPopup) ===== */
.doc-popup-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.doc-popup { position: relative; width: min(1100px, 100%); height: min(92vh, 100%); background: var(--card-bg); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden; }
.doc-popup iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--card-bg); }
.doc-popup-close { position: absolute; top: 10px; left: 10px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); font-size: 18px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.doc-popup-close:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
@media (max-width: 900px) { .doc-popup-overlay { padding: 0; } .doc-popup { width: 100%; height: 100%; border-radius: 0; } }
/* جوه النافذة: القايمة مستخبية والمستند واخد المساحة كلها */
.doc-embed .app-shell { display: none !important; }
.doc-embed body { background: var(--card-bg); }
.doc-embed .modal-overlay { background: transparent; padding: 0; align-items: stretch; }
.doc-embed .modal-box { max-width: 100% !important; width: 100%; max-height: 100%; height: 100%; border-radius: 0; box-shadow: none; padding-top: 18px; }
.doc-embed .modal-box .modal-close { display: none; }


/* ===== نافذة سؤال في نص الشاشة (showChoiceDialog) ===== */
.choice-overlay { position: fixed; inset: 0; z-index: 5000; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; animation: choice-fade .15s ease; }
.choice-overlay.closing { opacity: 0; transition: opacity .12s ease; }
.choice-box {
  width: min(560px, 100%); background: var(--card-bg); color: var(--text-main); border-radius: 20px; padding: 26px 26px 20px; text-align: center;
  border-top: 6px solid #f59e0b; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: choice-pop .18s ease;
}
.choice-sticker { position: relative; width: 92px; height: 92px; margin: -64px auto 10px; border-radius: 50%; background: linear-gradient(135deg, #fde68a, #f59e0b); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px rgba(245,158,11,.45); border: 5px solid var(--card-bg); }
.choice-sticker-main { font-size: 46px; line-height: 1; animation: choice-wiggle 1.6s ease-in-out infinite; }
.choice-sticker-badge { position: absolute; bottom: -2px; left: -4px; width: 36px; height: 36px; border-radius: 50%; background: #dc2626; color: #fff; font-size: 20px; display: flex; align-items: center; justify-content: center; border: 3px solid var(--card-bg); font-weight: 800; }
.choice-title { font-size: 21px; font-weight: 800; color: var(--heading-color); margin-bottom: 6px; }
.choice-msg { font-size: 14.5px; color: var(--text-muted); line-height: 1.8; margin-bottom: 4px; }
.choice-actions { display: flex; gap: 12px; margin-top: 18px; }
.choice-col { flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 5px; min-width: 0; }
.choice-btn { display: flex; align-items: center; justify-content: center; gap: 7px; height: 48px; border-radius: 12px; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer; border: 2px solid transparent; transition: transform .1s ease, filter .1s ease; white-space: nowrap; }
.choice-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.choice-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.choice-btn.primary { background: #16a34a; color: #fff; }
.choice-btn.danger { background: transparent; color: #dc2626; border-color: #dc2626; }
.choice-btn.danger:hover { background: #dc2626; color: #fff; }
.choice-btn.neutral { background: var(--subtle-bg); color: var(--text-main); border-color: var(--border-color); }
.choice-keys { font-size: 11.5px; color: var(--text-muted); letter-spacing: .5px; }
@keyframes choice-fade { from { opacity: 0; } }
@keyframes choice-pop { from { transform: scale(.92); opacity: 0; } }
@keyframes choice-wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-10deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
@media (max-width: 600px) { .choice-actions { flex-direction: column; } }


/* ===== المرتجع: آجل (على الحساب) / نقدي / مقسوم ===== */
.settle-type-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.settle-type-btn { border: 2px solid var(--border-color); background: var(--card-bg); border-radius: 12px; padding: 12px 8px; font-size: 16px; font-weight: 800; cursor: pointer; font-family: inherit; color: var(--text-main); }
.settle-type-btn small { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-top: 2px; }
.settle-type-btn.active { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
:root[data-theme="dark"] .settle-type-btn.active { background: rgba(37,99,235,0.2); color: #93c5fd; }
.settle-type-btn:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.settle-summary { padding: 10px 14px; border-radius: 10px; background: var(--subtle-bg); border: 1px solid var(--border-color); font-size: 14px; font-weight: 700; margin-bottom: 6px; }
@media (max-width: 900px) { .settle-type-row { gap: 6px; } .settle-type-btn { font-size: 14px; padding: 10px 4px; } }


/* ===== العروض الجاهزة: مربعات بصورة واسم وسعر ===== */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.pkg-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 0 12px; border: 2px solid var(--border-color); border-radius: 16px; background: var(--card-bg); color: var(--text-main); cursor: pointer; font-family: inherit; overflow: hidden; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; text-align: center; }
.pkg-tile:hover { transform: translateY(-3px); border-color: #2563eb; box-shadow: 0 10px 24px rgba(37,99,235,.18); }
.pkg-img { width: 100%; height: 130px; display: flex; align-items: center; justify-content: center; font-size: 54px; background: var(--subtle-bg); border-bottom: 1px solid var(--border-color); }
.pkg-img img { width: 100%; height: 100%; object-fit: contain; padding: 6px; box-sizing: border-box; } /* v278: الصورة كلها جوه المربع من غير قص */
.pkg-name { font-size: 16px; font-weight: 800; padding: 6px 10px 0; color: var(--heading-color); }
.pkg-price { font-size: 22px; font-weight: 800; color: #16a34a; }
.pkg-price small { font-size: 13px; }
.pkg-old { font-size: 12.5px; color: var(--text-muted); text-decoration: line-through; margin-top: -4px; }
.pkg-count { font-size: 12px; color: var(--text-muted); }


/* سطر الصنف اللي لسه متضاف بالسكان: بينوّر أخضر ثانية */
@keyframes scan-flash { 0% { background: rgba(22,163,74,.45); box-shadow: inset 4px 0 0 #16a34a; } 100% { background: transparent; box-shadow: inset 4px 0 0 transparent; } }
.scan-flash, .scan-flash > * { animation: scan-flash 1.5s ease-out; }

/* ===== أقسام بتتفتح وتتقفل (الإعدادات / الصلاحيات) - بنفس روح القائمة الجانبية ===== */
.cs-card { border: 1px solid var(--border-color); border-radius: 14px; background: var(--card-bg); margin-bottom: 10px;
  box-shadow: var(--shadow-card); overflow: hidden; }
.cs-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none;
  border-right: 4px solid transparent; transition: background .15s ease, border-color .15s ease; }
.cs-head:hover { background: var(--hover-bg); }
.cs-icon { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--subtle-bg); }
.cs-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; color: var(--heading-color); }
.cs-sub { font-size: 12px; font-weight: normal; color: var(--text-muted); margin-right: 6px; }
.cs-arrow { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; background: var(--subtle-bg); color: var(--text-muted); transform: rotate(90deg); transition: transform .2s ease, background .15s ease, color .15s ease; }
.cs-card.open > .cs-head { border-right-color: #2563eb; background: rgba(37,99,235,.06); }
.cs-card.open > .cs-head .cs-title { color: #2563eb; }
:root[data-theme="dark"] .cs-card.open > .cs-head .cs-title { color: #60a5fa; }
.cs-card.open > .cs-head .cs-arrow { transform: rotate(0deg); background: #2563eb; color: #fff; }
.cs-body { padding: 4px 16px 16px; }
.cs-card:not(.open) > .cs-body { display: none; }
.cs-card .cs-card { box-shadow: none; margin-bottom: 8px; }
.cs-card .cs-card > .cs-head { padding: 9px 12px; }
.cs-card .cs-card .cs-title { font-size: 14px; }
.cs-card .cs-card .cs-icon { width: 28px; height: 28px; font-size: 15px; }
.pg-count { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; background: rgba(22,163,74,.12); color: #16a34a; }
.pg-count.none { background: var(--subtle-bg); color: var(--text-muted); }
.pg-diff-count { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; background: rgba(217,119,6,.16); color: #b45309; }
:root[data-theme="dark"] .pg-diff-count { color: #fbbf24; }
table.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.perm-table th { text-align: right; color: var(--text-muted); font-size: 12px; font-weight: 700; padding: 6px 8px; }
table.perm-table th.perm-action-col, table.perm-table td.perm-action-col { text-align: center; width: 70px; }
table.perm-table td { padding: 8px; border-top: 1px solid var(--border-color); }
table.perm-table td.perm-module-name { font-weight: 600; color: var(--text-main); }
table.perm-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
table.perm-table td.perm-diff { background: rgba(217,119,6,.16); box-shadow: inset 0 0 0 2px #d97706; border-radius: 6px; }

/* ===== نقاط الولاء ===== */
.loyalty-switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 800; font-size: 15px; cursor: pointer; }
.loyalty-switch input { width: 22px; height: 22px; margin: 0; accent-color: #16a34a; cursor: pointer; }
/* ===== نقاط الولاء في فاتورة البيع ===== */
.loyalty-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin-top: 10px;
  padding: 8px 12px; border-radius: 10px; border: 1.5px dashed #d97706; background: rgba(217,119,6,.08); color: var(--text-main); font-size: 14px; }
:root[data-theme="dark"] .loyalty-box { background: rgba(217,119,6,.16); }
.cp-pill.cp-points { background: rgba(217,119,6,.15); color: #b45309; }
:root[data-theme="dark"] .cp-pill.cp-points { color: #fbbf24; }

/* ===== اختيار الوحدة جوه سطر الصنف (لفة 100 / متر) ===== */
.unit-select { width: auto; margin: 0; padding: 3px 6px; font-size: 12.5px; font-weight: 800; border-radius: 8px;
  border: 1.5px solid #0891b2; background: rgba(8,145,178,.08); color: var(--text-main); cursor: pointer; }
:root[data-theme="dark"] .unit-select { background: rgba(8,145,178,.18); }

/* ===== محرر وحدات الصنف (شاشة المنتجات) ===== */
.unit-row { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; padding: 8px; margin-bottom: 6px;
  border: 1px solid var(--border-color); border-radius: 10px; background: var(--subtle-bg); }
.unit-cell { flex: 1 1 130px; min-width: 0; }
.unit-cell.sm { flex: 1 1 90px; }
.unit-cell label { font-size: 12px; margin: 0 0 2px; }
.unit-cell input { margin: 0; }
.unit-row .unit-del { flex: 0 0 auto; height: 34px; }

/* ===== نافذة موافقة المدير (كود سري) ===== */
.approval-form { margin-top: 6px; }
.approval-pin {
  display: block; width: 220px; max-width: 100%; margin: 6px auto 4px; text-align: center;
  font-size: 26px; font-weight: 800; letter-spacing: 10px; padding: 10px 12px;
  -webkit-text-security: disc; border: 2px solid #2563eb; border-radius: 12px;
  background: var(--input-bg, var(--card-bg)); color: var(--text-main);
}
.approval-err { min-height: 18px; color: #dc2626; font-weight: 700; font-size: 13px; text-align: center; margin-bottom: 6px; }

/* ===== نافذة اختيار الوحدة قبل إضافة الصنف (v200 - askUnitFirst) ===== */
.unit-pick-overlay { z-index: 6000; }
.unit-pick-box { width: min(640px, 100%); background: var(--card-bg); color: var(--text-main); border-radius: 20px; padding: 22px 22px 16px;
  text-align: center; border-top: 6px solid #2563eb; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: choice-pop .18s ease; }
.unit-pick-title { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.unit-pick-name { font-size: 20px; font-weight: 800; margin: 4px 0 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.unit-pick-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 118px; padding: 20px 14px 12px; border-radius: 16px; border: 2px solid var(--border-color); background: var(--subtle-bg);
  color: var(--text-main); cursor: pointer; font-family: inherit; transition: border-color .12s ease, transform .12s ease, background .12s ease; }
.unit-pick-btn:hover, .unit-pick-btn.active, .unit-pick-btn:focus-visible { border-color: #2563eb; background: rgba(37,99,235,.10); transform: translateY(-2px); outline: none; }
.unit-pick-key { position: absolute; top: 6px; right: 7px; width: 17px; height: 17px; border-radius: 50%; background: #2563eb; color: #fff;
  font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.unit-pick-unit { font-size: 20px; font-weight: 800; }
.unit-pick-factor { font-size: 12px; color: var(--text-muted); }
.unit-pick-price { font-size: 15px; font-weight: 800; color: #16a34a; }
.unit-pick-hint { margin-top: 14px; font-size: 12px; color: var(--text-muted); }

/* ===== عرض الأعمدة بالسحب (v203 - setupColumnResize في app.js) ===== */
th.col-resize-hot { cursor: col-resize !important; box-shadow: inset 3px 0 0 #2563eb; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }
/* العرض بقى بالسحب من حافة العنوان (v208)، فأرقام العرض في كل لوحات الأعمدة اتشالت */
[id$="columns-panel"] input[type="number"], .smart-cols-panel input[type="number"] { display: none !important; }

/* ===== صفوف مخططة (أبيض / رمادي فاتح) عشان العين تمشي مع الصف (v205 - تجربة على المنتجات) ===== */
#products-table tbody tr:nth-child(even) td { background: var(--zebra-bg); }
#products-table tbody tr:hover td { background: var(--hover-bg); }

/* اسم العمود في سطر واحد عشان يتقاس ويصغر لوحده لو العمود ضيق (fitHeaderText - v206) */
th.th-fit { white-space: nowrap; overflow: hidden; }

/* نقل العمود بالسحب (v207) */
.col-move-ghost { position: fixed; z-index: 7000; pointer-events: none; padding: 6px 12px; border-radius: 8px; background: #2563eb; color: #fff;
  font-size: 12px; font-weight: 800; box-shadow: 0 8px 20px rgba(0,0,0,.25); white-space: nowrap; opacity: .95; }
.col-move-line { position: fixed; z-index: 6999; pointer-events: none; width: 3px; background: #2563eb; border-radius: 2px; display: none;
  box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
th.col-moving { opacity: .45; }
body.col-dragging, body.col-dragging * { cursor: grabbing !important; user-select: none !important; }

/* استيكر لكل خزنة في نظرة عامة على الخزنة (v209) - اللون والأيقونة من mMethodIcon/mMethodColor */
.drawer-sticker { width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 23px; background: color-mix(in srgb, var(--st) 16%, transparent); border: 2px solid color-mix(in srgb, var(--st) 45%, transparent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--st) 25%, transparent); }
/* زرار مسح الفلتر ✕ جنب القوايم: دايرة صغيرة هادية بدل المربع الأحمر الكبير (v209) */
.btn.danger[id^="clear-filter-"] { width: 24px; height: 24px; min-width: 24px; padding: 0; border-radius: 50%; align-self: center; flex-shrink: 0;
  font-size: 11px; line-height: 1; border: none; background: rgba(220,38,38,.12); color: #dc2626; box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; }
.btn.danger[id^="clear-filter-"]:hover { background: #dc2626; color: #fff; }
:root[data-theme="dark"] .btn.danger[id^="clear-filter-"] { background: rgba(248,113,113,.15); color: #f87171; }
:root[data-theme="dark"] .btn.danger[id^="clear-filter-"]:hover { background: #dc2626; color: #fff; }
.perm-hidden { display: none !important; }

/* عمود الأزرار اللي اتشالت كل زراريه بالصلاحية بيختفي كله (v214 - hideEmptyActionColumns) */
table.actions-empty th.sticky-col, table.actions-empty td.sticky-col { display: none; }
/* جدول المنتجات: الأرقام والكلام بخط أتقل وأوضح (v214 - طلب صاحب المشروع) */
/* v216: خط ويندوز (Segoe UI) للجدول - حاد على أي شاشة (الـ Cairo الصغير التقيل كان بيطلع متقطع على شاشة 27 بوصة)،
   ومن غير تتقيل صناعي (font-synthesis) عشان الحروف متتبوّظش */
#products-table td { font-weight: 700; font-size: 13.5px; color: var(--text-main); }
#products-table th { font-weight: 800; font-size: 12.5px; color: var(--text-main); }

/* ===== v221: خط Almarai في البرنامج كله - الجداول والأزرار والخانات بالتقيل (صاحب المشروع لقى الخط الرفيع بيتعب العين) ===== */
td { font-weight: 700; }
th { font-weight: 800; }
.btn, button, input, select, textarea, label, .sidebar-link, .branch-tab, .date-preset-tab, .step-tab { font-weight: 700; }
input::placeholder, textarea::placeholder { font-weight: 400; }

/* عدد العملاء بكل تصنيف في قائمة العملاء (v238) - الضغط على المربع بيفلتر الجدول */
.cls-stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:10px; margin-bottom:14px; }
.cls-stat { display:flex; align-items:center; gap:12px; padding:12px 14px; border-radius:14px; border:1px solid var(--border-color); background:var(--card-bg);
  cursor:pointer; text-align:right; font-family:inherit; color:var(--text-main); border-right:5px solid var(--cl); transition:transform .12s ease, box-shadow .12s ease; }
.cls-stat:hover { transform:translateY(-2px); box-shadow:0 6px 16px rgba(0,0,0,.08); }
.cls-stat.active { background:color-mix(in srgb, var(--cl) 12%, var(--card-bg)); box-shadow:0 0 0 2px var(--cl) inset; }
.cls-stat-icon { width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:21px; background:color-mix(in srgb, var(--cl) 15%, transparent); flex-shrink:0; }
.cls-stat-num { font-size:22px; font-weight:800; line-height:1.1; color:var(--cl); }
.cls-stat-label { font-size:12.5px; font-weight:700; color:var(--text-muted); }
/* v252: مربعين الفلوس (عليهم/ليهم) - شكل مختلف: ملوّنين بالكامل */
.cls-money { display:flex; align-items:center; gap:12px; padding:12px 14px; border-radius:14px; border:none; cursor:pointer; text-align:right; font-family:inherit;
  color:#fff; background:linear-gradient(135deg, var(--mc1), var(--mc2)); box-shadow:0 6px 16px color-mix(in srgb, var(--mc1) 30%, transparent); transition:transform .12s ease; }
.cls-money:hover { transform:translateY(-2px); }
.cls-money-icon { width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:21px; background:rgba(255,255,255,.2); flex-shrink:0; }
.cls-money-num { font-size:22px; font-weight:800; line-height:1.1; }
.cls-money-label { font-size:12.5px; font-weight:700; opacity:.9; }
@media (min-width: 901px) {
  .cls-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cls-stat, .cls-money { padding:9px 12px; gap:10px; }
  .cls-stat-icon, .cls-money-icon { width:36px; height:36px; font-size:18px; }
  .cls-stat-num, .cls-money-num { font-size:19px; }
}
@media screen and (min-width: 901px) {
  /* الصفحة على قد الشاشة (v252): سكرول واحد بس جوه الجدول، والجدول بياخد الباقي من الطول (بيتظبط لوحده مع الزوم) */
  .fit-page .main-content { display:flex; flex-direction:column; overflow:hidden; }
  .fit-page .page-header { display:none; }
  .fit-page .container { flex:1; min-height:0; display:flex; flex-direction:column; margin:12px 0; }
  .fit-page .fit-card { flex:1; min-height:0; display:flex; flex-direction:column; margin-bottom:0; padding:14px 18px; }
  .fit-page .fit-card .table-scroll-wrap { flex:1; min-height:120px; max-height:none; }
  /* v268: أي شاشة فيها body.fit-page (من غير fit-card يدوي) - fitMainTable في app.js بيعلّم الطريق من الـ container لحد الجدول الأساسي.
     لو المساحة مش كفاية (فورم كبير فوق) الصفحة بتعمل سكرول عادي بدل ما حاجة تتقص */
  .fit-page.fit-auto .main-content { overflow-y:auto; }
  .fit-page .fit-chain { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; margin-bottom:0; }
  /* v405: أي حاجة فوق/تحت الجدول متتكبسش (كارت «الطابعة ومقاس الملصق» في طباعة الباركود كان بقى خط رفيع) */
  .fit-page .container > :not(.fit-chain):not(.fit-card):not([data-fit-manual]):not(script):not(style) { flex-shrink:0; }
  .fit-page .fit-chain > .table-scroll-wrap.fit-main { flex:1 1 auto; min-height:240px; max-height:none; }
  /* لو اللي فوق الجدول كبير ومفيش مكان: سكرول واحد للصفحة كلها والجداول بطولها (من غير سكرول جوه بعض) */
  .fit-page.fit-flow .container { flex:none; }
  .fit-page.fit-flow .fit-chain { display:block; flex:none; }
  .fit-page.fit-flow .container .table-scroll-wrap { max-height:none; flex:none; }
}

/* ▦ المنتجات - عرض المربعات (v280) */
.pg-switch { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.pg-switch button { border: none; background: var(--card-bg); color: var(--text-muted); font: inherit; font-weight: 700; font-size: 13px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.pg-switch button.active { background: #2563eb; color: #fff; }
.pg-grid { display: none; }
body.pg-mode #products-table { display: none; }
body.pg-mode .pg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--pg-size, 190px), 1fr)); gap: 12px; padding: 4px 2px 12px; }
body.pg-mode #products-totals-bar #scroll-table-right, body.pg-mode #products-totals-bar #scroll-table-left { display: none; }
.pg-tile { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; cursor: default; transition: box-shadow .15s, border-color .15s; content-visibility: auto; contain-intrinsic-size: 190px 300px; }
.pg-tile:hover { border-color: #93c5fd; box-shadow: 0 4px 14px rgba(37,99,235,.15); }
.pg-img { position: relative; aspect-ratio: 1 / 1; background: var(--subtle-bg); display: flex; align-items: center; justify-content: center; }
.pg-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; box-sizing: border-box; }
.pg-noimg { font-size: 46px; opacity: .35; }
.pg-bg { position: absolute; top: 6px; left: 6px; color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; display: flex; align-items: center; justify-content: center; z-index: 3; }
.pg-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; z-index: 4; }
.pg-tile:hover .pg-tools { opacity: 1; }
.pg-tools button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 0; }
.pg-tools button:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.pg-qtys { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; z-index: 2; }
.pg-q { background: rgba(15, 23, 42, .55); color: #fff; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pg-q b { font-weight: 800; }
.pg-q.low { background: rgba(234, 88, 12, .75); }
.pg-q.out { background: rgba(220, 38, 38, .75); }
.pg-q.svc { background: rgba(79, 70, 229, .7); }
.pg-name { font-weight: 800; font-size: 13.5px; color: var(--text-main); padding: 8px 10px 0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.pg-cat { font-size: 11.5px; color: var(--text-muted); padding: 2px 10px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-prices { display: flex; gap: 4px; padding: 8px 10px 10px; margin-top: auto; }
.pg-pr { flex: 1; text-align: center; border-radius: 7px; padding: 4px 2px; font-size: 12.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-pr.sale { background: rgba(37, 99, 235, .12); color: #2563eb; }
.pg-pr.tech { background: rgba(234, 88, 12, .12); color: #ea580c; }
.pg-pr.comp { background: rgba(124, 58, 237, .12); color: #7c3aed; }
.pg-sentinel { grid-column: 1 / -1; height: 1px; }
@media (max-width: 900px) {
  body.pg-mode #products-table-scroll.m-has-list { display: block !important; }
  body.pg-mode .m-list { display: none !important; }
  body.pg-mode .pg-grid { grid-template-columns: repeat(auto-fill, minmax(calc(var(--pg-size, 190px) * .75), 1fr)); gap: 8px; }
  .pg-tools { opacity: 1; }
  .pg-switch button { padding: 7px 9px; }
}
.pg-size { display: none; align-items: center; gap: 4px; border: 1px solid var(--border-color); border-radius: 8px; padding: 0 6px; background: var(--card-bg); flex-shrink: 0; }
body.pg-mode .pg-size { display: inline-flex; }
.pg-size button { border: none; background: none; color: var(--text-main); font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; width: 24px; height: 30px; padding: 0; }
.pg-size input[type=range] { width: 110px; accent-color: #2563eb; padding: 0; border: none; background: none; }
body.pg-small .pg-name { font-size: 12px; padding: 6px 7px 0; }
body.pg-small .pg-cat { font-size: 10.5px; padding: 1px 7px 0; }
body.pg-small .pg-prices { padding: 6px 6px 7px; gap: 3px; }
body.pg-small .pg-pr { font-size: 10.5px; padding: 3px 1px; }
body.pg-small .pg-q { font-size: 10px; padding: 1px 6px; }
@media (max-width: 900px) { .pg-size input[type=range] { width: 70px; } }

/* 👁 عرض أصناف الفاتورة في بحث المرتجع (v285) */
.ret-peek-btn { border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); border-radius: 8px; padding: 4px 10px; font: inherit; font-weight: 700; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.ret-peek-btn:hover, .ret-peek-btn.on { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.ret-peek-panel { background: var(--subtle-bg); border-bottom: 1px solid var(--border-color); padding: 6px 12px 8px; }
.ret-peek-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ret-peek-table th { font-size: 11.5px; color: var(--text-muted); font-weight: 700; text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border-color); }
.ret-peek-table td { padding: 5px 6px; border-bottom: 1px solid var(--border-color); white-space: nowrap; font-weight: 700; color: var(--text-main); }
.ret-peek-table td:first-child { white-space: normal; }
.ret-peek-table tr.done td { color: var(--text-muted); text-decoration: line-through; }

/* 🔤 اختيار خط البرنامج (v289) */
.font-options { display: flex; flex-direction: column; gap: 8px; }
.font-opt { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 2px solid var(--border-color); border-radius: 12px; cursor: pointer; background: var(--card-bg); color: var(--text-main); }
.font-opt:hover { background: var(--hover-bg); }
.font-opt.on { border-color: #2563eb; background: rgba(37, 99, 235, .07); }
.font-opt input { width: 18px; height: 18px; flex-shrink: 0; accent-color: #2563eb; }
.font-opt-body { flex: 1; min-width: 0; }
.font-opt-name { font-weight: 800; font-size: 15px; }
.font-opt-name small { font-weight: 400; font-size: 12px; color: var(--text-muted); margin-inline-start: 6px; }
.font-opt-sample { font-size: 13.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-opt-cur { flex-shrink: 0; font-size: 11.5px; font-weight: 700; color: #16a34a; background: rgba(22, 163, 74, .12); border-radius: 6px; padding: 2px 8px; }

/* 🎨 POP أخضر و ZX أحمر في البرنامج كله (v291) */
.pop-word { color: #16a34a; }
.pops-word { color: #dc2626; }
:root[data-theme="dark"] .pop-word { color: #4ade80; }
:root[data-theme="dark"] .pops-word { color: #f87171; }

/* 🗄️ اختيار الخزنة بالشعارات (v291) */
.method-logo { display: inline-flex; flex-shrink: 0; vertical-align: middle; }
.method-logo svg { width: 100%; height: 100%; display: block; }
select.dsel-hidden { display: none !important; }
.dsel-btn { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; padding: 6px 12px; border: 1px solid var(--input-border, var(--border-color)); border-radius: 8px;
  background: var(--input-bg, var(--card-bg)); color: var(--text-main); font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; text-align: right; }
.dsel-btn:hover { border-color: #2563eb; }
.dsel-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.dsel-btn:disabled { opacity: .6; cursor: not-allowed; }
.dsel-btn.need-choice { border: 2px solid #dc2626; background: rgba(220, 38, 38, .06); }
.dsel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsel-ph { flex: 1; color: var(--text-muted); font-weight: 700; }
.dsel-arrow { color: var(--text-muted); font-size: 12px; }
.dsel-list { position: fixed; z-index: 100000; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.22); padding: 6px; max-height: 60vh; overflow-y: auto; }
.dsel-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-weight: 800; font-size: 16px; color: var(--text-main); }
.dsel-item:hover, .dsel-item.kb { background: var(--hover-bg); }
.dsel-item.on { background: rgba(37, 99, 235, .1); color: #2563eb; }
.dsel-item.ph { color: var(--text-muted); font-weight: 700; font-size: 14px; }
@media (max-width: 900px) {
  .dsel-btn { min-height: 48px; font-size: 16px; }
  .dsel-item { padding: 12px 10px; font-size: 17px; }
}

.drawer-sticker.logo { background: none !important; box-shadow: none !important; border: none !important; }

/* 📌 شريط آخر الفاتورة ثابت تحت (v292): سطر الخانات (إضافة/سبب/خصم/ملاحظات) + سطر الإجمالي وPOP والتالي.
   الأصناف الكتير بتعمل سكرول عادي والشريط فاضل ظاهر. */
.doc-footer { position: sticky; bottom: 0; z-index: 30; margin: 14px -20px -20px; padding: 10px 20px 12px; background: var(--card-bg);
  border-top: 2px solid var(--border-color); box-shadow: 0 -8px 18px rgba(15, 23, 42, .08); border-radius: 0 0 12px 12px; }
.df-row1 { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.df-row1 .df-f { flex: 1 1 160px; min-width: 0; }
.df-row1 .df-num { flex: 0 0 130px; }
.df-row1 .df-num:has(.disc-wrap) { flex: 0 0 210px; } /* الخصم بالمبلغ أو % (v303) */
.df-row1 .df-wide { flex: 1.6 1 200px; }
.df-f label { display: block; font-size: 12px; margin: 0 0 3px; color: var(--text-muted); font-weight: 700; }
.df-f input { margin: 0; height: 38px; }
.df-row2 { display: flex; align-items: center; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.df-total { font-size: 20px; font-weight: 800; color: var(--text-main); white-space: nowrap; }
.df-total span { margin-inline-start: 6px; color: #2563eb; }
.df-row2 .profit-total-line { margin: 0 !important; font-size: 14.5px; font-weight: 700; gap: 6px; align-items: center; }
.df-row2 .df-warn { margin: 0 !important; padding: 5px 10px !important; font-size: 13px; }
.df-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.df-actions .btn { min-height: 42px; padding-inline: 22px; font-size: 15px; }
@media (max-width: 900px) {
  .doc-footer { display: contents; } /* على الموبايل: سطر الإجمالي بس اللي ثابت تحت (sticky لازم يبقى ابن الصفحة مش الشريط) */
  .df-row1 { margin-top: 14px; }
  .df-row1 .df-f, .df-row1 .df-num, .df-row1 .df-num:has(.disc-wrap) { flex: 1 1 45%; }
  .df-row1 .df-wide { flex-basis: 100%; }
  .df-row2 { position: sticky; bottom: 0; z-index: 30; background: var(--card-bg); padding: 8px 0; border-top: 2px solid var(--border-color); }
  .df-actions { width: 100%; }
  .df-actions .btn { flex: 1; }
}

/* 📍 اختيار الفرع بمربعات (v292 → v315 شكل أشيك): مجموعة زراير في شريط واحد، نقطة بلون الفرع، والمختار متلوّن بتدرّج */
.bsel { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 13px; }
.bsel > .bsel-tile { min-width: 0; }
.bsel-tile { flex: 1 1 auto; min-width: 0; min-height: 38px; padding: 6px 16px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-main);
  font: inherit; font-size: 14.5px; font-weight: 800; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, color .15s, box-shadow .15s, transform .08s; }
.bsel-tile::before { content: ''; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--bc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bc) 22%, transparent); }
.bsel-tile:hover { background: color-mix(in srgb, var(--bc) 11%, var(--card-bg)); border-color: color-mix(in srgb, var(--bc) 30%, transparent); }
.bsel-tile:active { transform: scale(.97); }
.bsel-tile.on { background: linear-gradient(135deg, var(--bc), color-mix(in srgb, var(--bc) 72%, #000)); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--bc) 38%, transparent), inset 0 1px 0 rgba(255,255,255,.18); }
.bsel-tile.on::before { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.bsel-tile:disabled { opacity: .55; cursor: not-allowed; }
.bsel.need-choice { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
@media (max-width: 900px) { .bsel-tile { min-height: 48px; font-size: 16px; } }

/* شعار بنك صورة (v297) */
.method-logo.img img { width: 100%; height: 100%; display: block; object-fit: contain; background: #fff; border: 1px solid #e2e8f0; border-radius: 25%; padding: 2px; box-sizing: border-box; }
/* 🔁 التحويل بين الخزن (v297) */
.xfer-side { border: 2px solid var(--border-color); border-radius: 12px; padding: 10px 12px; background: var(--subtle-bg); }
.xfer-side.from { border-color: rgba(220, 38, 38, .35); }
.xfer-side.to { border-color: rgba(22, 163, 74, .4); }
.xfer-side h4 { margin: 0 0 8px; font-size: 14px; }
.xfer-arrow { text-align: center; font-size: 22px; margin: 6px 0; color: var(--text-muted); }
.xfer-bal { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; font-weight: 700; }
.xfer-list { margin-top: 12px; max-height: 220px; overflow-y: auto; border-top: 1px solid var(--border-color); }
.xfer-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.xfer-row .amt { font-weight: 800; margin-inline-start: auto; white-space: nowrap; }
.drw-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; }
.drw-row .drw-name { flex: 1; min-width: 160px; margin: 0; font-weight: 800; }
.drw-row.reserve { background: rgba(124, 58, 237, .06); border-radius: 10px; padding: 8px; }
.drw-row.drw-hidden { opacity: .6; } /* v374 */
.drw-row .drw-br { font-weight: 700; }
.drw-vis { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }

/* 💳 تنسيق خطوة الدفع (v299 - كل شاشات الدفع: فاتورة البيع/الشراء/الكاشير السريع + المرتجعات) */
/* مبلغ الفاتورة في مربع مميز */
.pay-sticky > div:has(> #pay-h-total) { border: 2px solid #2563eb; background: color-mix(in srgb, #2563eb 8%, var(--card-bg)); border-radius: 14px; padding: 10px 22px; text-align: center; min-width: 190px; }
.pay-sticky > div:has(> #pay-h-total) .lbl { color: #2563eb; font-weight: 800; font-size: 13px; }
.pay-sticky #pay-h-total { font-size: 30px; color: #1d4ed8; letter-spacing: .3px; }
:root[data-theme="dark"] .pay-sticky #pay-h-total, :root[data-theme="dark"] .pay-sticky > div:has(> #pay-h-total) .lbl { color: #93c5fd; }
#sr-total, #pr-total { display: inline-block; border: 2px solid #2563eb; background: color-mix(in srgb, #2563eb 8%, var(--card-bg)); color: #1d4ed8; border-radius: 12px; padding: 4px 18px; font-size: 24px; font-weight: 800; }
:root[data-theme="dark"] #sr-total, :root[data-theme="dark"] #pr-total { color: #93c5fd; }
/* آجل / نقدي / متعدد: أكبر */
.pay-type-row { gap: 14px !important; margin-bottom: 18px !important; }
.pay-type-btn, .settle-type-btn { padding: 22px 10px !important; font-size: 20px !important; border-radius: 16px !important; transition: transform .12s, box-shadow .12s, border-color .12s; }
.pay-type-btn small, .settle-type-btn small { font-size: 13.5px !important; margin-top: 6px !important; }
.pay-type-btn:not(:disabled):hover, .settle-type-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37, 99, 235, .15); border-color: #93c5fd; }
.pay-type-btn.active, .settle-type-btn.active { box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
/* اختيار الخزنة بنفس مقاس مربع المبلغ */
.pay-line .pay-amount { min-height: 64px; font-size: 26px; }
.pay-line .dsel-btn, .sr-split-row .dsel-btn, .pr-split-row .dsel-btn { min-height: 64px; font-size: 19px; border: 2px solid var(--border-color); border-radius: 12px; padding: 8px 14px; }
.pay-line .dsel-btn .method-logo, .sr-split-row .dsel-btn .method-logo, .pr-split-row .dsel-btn .method-logo { width: 38px !important; height: 38px !important; }
.pay-line .dsel-btn.need-choice { border: 2px solid #dc2626; }
@media (max-width: 900px) {
  .pay-type-btn, .settle-type-btn { padding: 14px 4px !important; font-size: 16px !important; }
  .pay-type-btn small, .settle-type-btn small { font-size: 11.5px !important; }
  .pay-sticky #pay-h-total { font-size: 24px; }
}

/* 🧾 شاشات المستندات (v303) */
.disc-wrap { display: flex; align-items: stretch; gap: 4px; }
.disc-wrap > input { flex: 1; min-width: 0; }
.disc-wrap .disc-pct { display: none; max-width: 72px; }
.disc-wrap.is-pct .disc-pct { display: block; border: 2px solid #7c3aed; }
.disc-wrap.is-pct > input:not(.disc-pct) { background: var(--subtle-bg); color: var(--text-muted); }
.disc-mode { flex-shrink: 0; width: 36px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--card-bg); color: var(--text-main); font: inherit; font-weight: 800; cursor: pointer; }
.disc-wrap.is-pct .disc-mode { background: #7c3aed; border-color: #7c3aed; color: #fff; }
/* السطر اللي واقف عليه متميز كله */
.doc-row:hover, .doc-row:focus-within { background: rgba(37, 99, 235, .07); border-color: #93c5fd; }
:root[data-theme="dark"] .doc-row:hover, :root[data-theme="dark"] .doc-row:focus-within { background: rgba(59, 130, 246, .12); border-color: #3b82f6; }
.doc-row:focus-within .item-no, .doc-row:hover .item-no { color: #2563eb; }
.doc-row .item-no { cursor: grab; user-select: none; touch-action: none; border-radius: 6px; }
.doc-row .item-no:hover { background: var(--hover-bg); }
.doc-row .item-no::before { content: '⋮⋮'; font-size: 10px; opacity: .45; margin-inline-end: 2px; letter-spacing: -2px; }
/* v481: نفس علامة الإيد (السحب) على رقم الصنف في تحويل البضاعة وعرض السعر */
.st-item-no, .qt-item-no { cursor: grab; user-select: none; touch-action: none; }
.st-item-no:active, .qt-item-no:active, .doc-row .item-no:active { cursor: grabbing; }
.st-item-no::before, .qt-item-no::before { content: '⋮⋮'; font-size: 10px; opacity: .45; margin-inline-end: 2px; letter-spacing: -2px; }
.st-item-row:hover .st-item-no { background: rgba(37,99,235,.24); }
.row-dragging { opacity: .45; }
.row-drop-line { position: fixed; height: 3px; background: #2563eb; border-radius: 3px; z-index: 9999; pointer-events: none; box-shadow: 0 0 0 2px rgba(37, 99, 235, .2); }
/* ترتيب بالعنوان */
[data-sort] { cursor: pointer; user-select: none; }
[data-sort]:hover { color: #2563eb; }
.sorted-desc::after { content: ' ▼'; font-size: 9px; }
.sorted-asc::after { content: ' ▲'; font-size: 9px; }
/* زرار ✕ أصغر */
.remove-item-btn { width: 24px !important; height: 24px !important; min-height: 0 !important; padding: 0 !important; font-size: 11px !important; border-radius: 6px !important; line-height: 1; justify-self: center; }
/* نافذة تعديل الصنف من جوه المستند */
.prod-popup-ov { position: fixed; inset: 0; z-index: 99990; background: rgba(15, 23, 42, .45); display: flex; }
.prod-popup-ov iframe { flex: 1; border: 0; background: transparent; }

/* v304: قايمة بحث العملاء أعرض من الخانة (لما الخانة اتصغرت الأسامي اتقصت) - بتفتح لناحية الشمال */
.cp-list { left: auto !important; width: max(100%, 560px); max-width: calc(100vw - 120px); }
@media (max-width: 900px) { .cp-list { width: 100%; max-width: none; left: 0 !important; } }

/* v310: رقم الصنف (شريحة رمادي قبل الاسم) + رقم الترتيب عمود أزرق طولي مميز */
.pid-chip { display:inline-flex; align-items:center; flex-shrink:0; font-size:11.5px; font-weight:800; color:var(--text-muted); background:var(--subtle-bg); border:1px solid var(--border-color); border-radius:6px; padding:0 6px; line-height:20px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.pid-chip::before { content:'رقم'; font-size:9.5px; font-weight:700; opacity:.75; margin-inline-end:3px; }
.doc-row .item-no, .qt-item-no, .st-item-no { align-self:stretch; display:flex; align-items:center; justify-content:center; background:rgba(37,99,235,.13); color:#1d4ed8 !important; border-radius:8px; font-weight:800; min-height:30px; }
.doc-row:hover .item-no, .doc-row:focus-within .item-no, .qt-item-card:hover .qt-item-no { background:rgba(37,99,235,.24); }
:root[data-theme="dark"] .doc-row .item-no, :root[data-theme="dark"] .qt-item-no, :root[data-theme="dark"] .st-item-no { background:rgba(96,165,250,.18); color:#93c5fd !important; }

/* 👤 خانة العميل (v315): «العميل» في مربع أزرق غامق لازق في الخانة - نفس اللون = العميل في أي شاشة */
.cust-box { display: flex; align-items: flex-start; min-width: 0; flex: 1; }
.cust-box > .cust-tag { flex-shrink: 0; height: 42px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; background: #1e3a8a; color: #fff; font-weight: 800; font-size: 14px; border-radius: 0 10px 10px 0; white-space: nowrap; }
.cust-box > div { flex: 1; min-width: 0; }
.cust-box .cp-input { height: 42px; margin: 0; border: 2px solid #1e3a8a !important; border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; font-weight: 800; }
.cust-box .cp-input:focus { box-shadow: 0 0 0 3px rgba(30,58,138,.22); }
:root[data-theme="dark"] .cust-box > .cust-tag { background: #1e40af; }
:root[data-theme="dark"] .cust-box .cp-input { border-color: #1e40af !important; }

/* v317: بيانات العميل المختار جنب الخانة الزرقا - أكبر وأوضح */
.cust-box { align-items: center; }
.cust-box > div:not(.cust-meta) { min-width: 200px; }
.cust-box > .cust-meta { flex: 0 0 auto; margin: 0; margin-inline-start: 8px; gap: 6px; align-items: center; }
.cust-box > .cust-meta .cp-pill { font-size: 13px; padding: 5px 12px; border-radius: 9px; line-height: 1.2; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }

/* v318: نافذة سبب الحذف فوق أي نافذة مفتوحة */
#shared-delete-reason-modal { z-index: 4100; }

.cust-box { flex-wrap: wrap; row-gap: 6px; } /* v319 */

/* 📄 v319: قوايم المستندات بالشكل الجديد (فواتير الشراء السابقة، عروض الأسعار السابقة...) - setupDocListDetail */
.dl-filters-card { padding: 10px 14px !important; }
.dl-frow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dl-frow + .dl-frow { margin-top: 8px; }
.dl-fright { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; flex-wrap: wrap; }
.dl-chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.dl-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main);
  border-radius: 999px; padding: 3px 11px 3px 9px; font-family: inherit; font-size: 12.5px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.dl-chip:hover { border-color: #2563eb; }
.dl-chip.active { background: #1e3a8a; border-color: #1e3a8a; color: #fff; }
.dl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dl-sep { width: 1px; align-self: stretch; background: var(--border-color); margin: 0 4px; }
table.dl-list thead th { background: #1e3a8a !important; color: #fff !important; font-weight: 800; border-color: #1e3a8a !important; }
table.dl-list thead th .sort-arrow, table.dl-list thead th .st-arrow { color: #fde68a; }
table.dl-list tbody td { padding-top: 4px; padding-bottom: 4px; }
table.dl-list .btn.small { padding: 3px 9px; font-size: 12px; }
table.dl-list tbody tr[data-id] { cursor: pointer; }
table.dl-list tbody tr[data-id]:hover td { background: color-mix(in srgb, #2563eb 16%, var(--card-bg)) !important; } /* v572: لون صلب (الشفاف كان بيبيّن الخانات اللي ورا عمود الأزرار الثابت فتبان منطقة غامقة) */
/* v569 (تصميم 1): الصف المختار أزرق فاتح بنفس عيلة العنوان + خط أزرق على الطرف - بيتشاف من غير ما يزعّق */
table.dl-list tbody tr.dl-sel td, #sales-inv-table tbody tr.si-sel td { background: #dbeafe !important; color: #0c447c !important; font-weight: 800; }
/* v570: إطار برتقاني مضيء رفيع حوالين الصف المختار (بدل الخط الأزرق على الطرف) */
table.dl-list tbody tr.dl-sel td, #sales-inv-table tbody tr.si-sel td { box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316; }
table.dl-list tbody tr.dl-sel td:first-child, #sales-inv-table tbody tr.si-sel td:first-child { box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316, inset -2px 0 0 #f97316; border-start-start-radius: 8px; border-end-start-radius: 8px; }
table.dl-list tbody tr.dl-sel td:last-child, #sales-inv-table tbody tr.si-sel td:last-child { box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316, inset 2px 0 0 #f97316; border-start-end-radius: 8px; border-end-end-radius: 8px; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel td, [data-theme="dark"] #sales-inv-table tbody tr.si-sel td { background: #17325c !important; color: #dbeafe !important; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel td, [data-theme="dark"] #sales-inv-table tbody tr.si-sel td { box-shadow: inset 0 2px 0 #fb923c, inset 0 -2px 0 #fb923c; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel td:first-child, [data-theme="dark"] #sales-inv-table tbody tr.si-sel td:first-child { box-shadow: inset 0 2px 0 #fb923c, inset 0 -2px 0 #fb923c, inset -2px 0 0 #fb923c; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel td:last-child, [data-theme="dark"] #sales-inv-table tbody tr.si-sel td:last-child { box-shadow: inset 0 2px 0 #fb923c, inset 0 -2px 0 #fb923c, inset 2px 0 0 #fb923c; }
.dl-split { height: 12px; cursor: row-resize; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; flex-shrink: 0; }
.dl-split::before { content: ''; width: 70px; height: 4px; border-radius: 4px; background: var(--border-color); transition: background .15s, width .15s; }
.dl-split:hover::before, .dl-split.drag::before { background: #2563eb; width: 120px; }
.dl-detail { flex-shrink: 0; height: var(--dl-h, 230px); display: flex; flex-direction: column; border: 2px solid #1e3a8a; border-radius: 12px; overflow: hidden; background: var(--card-bg); }
.dl-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 12px; background: rgba(30,58,138,.08); border-bottom: 1px solid var(--border-color); font-size: 13px; }
.dl-head .dl-no { font-weight: 800; color: #1e3a8a; font-size: 15px; }
:root[data-theme="dark"] .dl-head .dl-no { color: #93c5fd; }
.dl-head .dl-tools { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; position: relative; }
.dl-body { flex: 1; min-height: 0; overflow: auto; }
.dl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dl-table th { position: sticky; top: 0; background: var(--subtle-bg); font-weight: 800; padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--border-color); white-space: nowrap; z-index: 1; }
.dl-table td { padding: 4px 8px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.dl-table tbody tr:hover td { background: var(--hover-bg); }
.dl-cols-panel { position: absolute; left: 0; top: calc(100% + 6px); background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.2); padding: 8px 12px; z-index: 60; min-width: 190px; }
.dl-cols-panel label { display: flex; gap: 6px; align-items: center; margin: 4px 0; font-weight: 700; font-size: 13px; }
.dl-empty { padding: 20px; text-align: center; color: var(--text-muted); }
@media (max-width: 900px) { .dl-split, .dl-detail { display: none !important; } }

/* v324: قوايم المستندات */
.fit-page.has-dl-detail .fit-chain > .table-scroll-wrap.fit-main { min-height: 140px; }
.dl-chip.dl-logo, .si-chip.si-logo { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 50%; }
.dl-chip.dl-logo .method-logo, .si-chip.si-logo .method-logo { border-radius: 50%; overflow: hidden; }
.dl-chip.dl-logo.active, .si-chip.si-logo.active { background: var(--card-bg); border: 3px solid #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.22); } /* v569: أزرق بدل البرتقاني */
table.dl-list .btn.small, #sales-inv-table .btn.small { padding: 2px 7px; font-size: 11.5px; }

/* v327: قوايم المستندات - الشاشة الكاملة + إخفاء مربع الأصناف (setupDocListDetail) */
body.dl-detail-off .dl-split, body.dl-detail-off .dl-detail { display: none !important; }
.dl-detail-toggle.off { background: #2563eb !important; color: #fff !important; border-color: #2563eb !important; }
.dl-focus-info { display: none; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.dl-focus-info b { color: var(--text-main); }
.dl-focus-exit { border: none; background: #2563eb; color: #fff; border-radius: 999px; padding: 6px 14px; font-family: inherit; font-weight: 800; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.dl-focus-exit:hover { background: #c2410c; }
@media (min-width: 901px) {
  body.dl-focus .dl-filters-card { display: none !important; }
  body.dl-focus .dl-focus-info { display: flex; }
}

/* ⚠️ v331: الخانة الإجباري الناقصة (أحمر بيلمع) والخطوة الجاية (أزرق) - zoomGoToMissing */
@keyframes zoomMissingPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } 30%, 70% { box-shadow: 0 0 0 5px rgba(220,38,38,.45); } }
@keyframes zoomNextPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); } 30%, 70% { box-shadow: 0 0 0 5px rgba(37,99,235,.4); } }
.zoom-missing-ring { animation: zoomMissingPulse 1.2s ease 2; border-radius: 12px; outline: 2px solid #dc2626; outline-offset: 2px; }
.zoom-next-ring { animation: zoomNextPulse 1.2s ease 2; border-radius: 12px; outline: 2px solid #2563eb; outline-offset: 2px; }

/* v332: زرار الحفظ لما فيه حاجة ناقصة في الدفع - باهت بس بيتداس (بيوديك على الناقص) */
.btn.pay-problem { opacity: .55; }

/* ✏️ v337: تعديل العميل/المورد كنافذة فوق الفاتورة (customer.html / supplier.html ?editpopup=1) */
body.party-popup-mode { background: transparent !important; overflow: hidden; }
body.party-popup-mode > :not(.party-popup-card):not(script):not(.modal-overlay):not(#big-delete-overlay):not(.center-toast) { display: none !important; }
body.party-popup-mode .party-popup-card { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; margin: 0; z-index: 10; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
body.party-popup-mode .party-popup-x { position: static; margin-inline-start: auto; }

/* 📅 v343: رأس الإشعارات + «قراءة الكل» */
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border-color); font-weight: 800; font-size: 13px; color: var(--text-muted); position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
.notif-readall { border: 1px solid #16a34a; background: transparent; color: #16a34a; border-radius: 999px; padding: 3px 12px; font-family: inherit; font-weight: 800; font-size: 12px; cursor: pointer; }
.notif-readall:hover { background: #16a34a; color: #fff; }

/* 🚨 v345: إشعار المراجعة الليلية (غلط في الحسابات) */
.notif-item.notif-danger { background: rgba(220, 38, 38, .12); border-right: 4px solid #dc2626; }
.notif-item.notif-danger .notif-t { color: #dc2626; font-weight: 800; }

/* ===================== 📱 v347: مراجعة الموبايل ===================== */
@media (max-width: 900px) {
  /* الآيفون بيعمل زوم لوحده لما تدوس على خانة خطها أصغر من 16 - الخانات كلها 16 على الموبايل */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
  /* أزرار عمود الأيقونات أكبر عشان الصباع */
  #user-chip button, #user-chip .chip-btn, #notif-btn, #theme-toggle-btn { min-width: 34px; min-height: 34px; }
  /* الجداول العريضة = كروت (zoomMobileStack في app.js) */
  table.m-stack, table.m-stack tbody, table.m-stack tfoot { display: block; width: 100% !important; min-width: 0 !important; table-layout: auto !important; }
  table.m-stack thead, table.m-stack colgroup { display: none !important; }
  .table-scroll-wrap:has(> table.m-stack), .fit-main:has(> table.m-stack) { overflow: visible !important; max-height: none !important; height: auto !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
  table.m-stack tbody tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px; background: var(--card-bg) !important; border: 1px solid var(--border-color); border-radius: 14px; padding: 10px 12px; margin: 0 0 8px; position: relative; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
  table.m-stack tbody tr.si-sel, table.m-stack tbody tr.dl-sel { border: 2px solid #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,.18); background: color-mix(in srgb, #2563eb 8%, var(--card-bg)) !important; color: var(--text-main) !important; }
  html body table.m-stack:is(#sales-inv-table, .m-stack) tbody tr.si-sel td, html body table.m-stack tbody tr.dl-sel td { color: inherit !important; background: transparent !important; }
  html body table.m-stack:is(#sales-inv-table, .m-stack) tbody tr.si-sel a, html body table.m-stack tbody tr.dl-sel a:not(.btn) { color: #2563eb !important; }
  table.m-stack td { display: flex; flex-direction: column; gap: 1px; border: 0 !important; padding: 0 !important; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; max-width: 100% !important; width: auto !important; min-width: 0; background: transparent !important; position: static !important; font-size: 13px; line-height: 1.35; height: auto !important; }
  table.m-stack td::before { content: attr(data-m-label); font-size: 10.5px; color: var(--text-muted); font-weight: 700; }
  table.m-stack td.m-title { order: -3; flex: 1 1 auto; font-size: 15.5px; font-weight: 800; }
  table.m-stack td.m-title::before { display: none; }
  table.m-stack td.m-big { order: -2; flex: 0 0 auto; margin-inline-start: auto; font-size: 17px; font-weight: 800; text-align: left; align-items: flex-end; }
  table.m-stack td.m-big::before { text-align: left; }
  table.m-stack td.m-hide { display: none !important; }
  /* سطر جديد بعد العنوان والمبلغ (الباقي تحت) */
  table.m-stack tbody tr::after { content: ""; order: -1; flex-basis: 100%; height: 0; }
  table.m-stack td.m-actions { order: 99; flex: 1 1 100%; flex-direction: row; justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 6px !important; border-top: 1px dashed var(--border-color) !important; }
  table.m-stack td.m-actions::before { display: none; }
  table.m-stack td.m-actions > div { flex-wrap: wrap; justify-content: flex-end; }
  table.m-stack td.m-actions button, table.m-stack td.m-actions .btn { min-height: 36px; min-width: 40px; }
  table.m-stack td.m-msg { flex: 1 1 100%; text-align: center; }
  table.m-stack td.m-msg::before { display: none; }
  table.m-stack tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 14px; background: var(--subtle-bg) !important; border-radius: 14px; padding: 10px 12px; position: static !important; }
  table.m-stack tfoot td { display: block; border: 0 !important; padding: 0 !important; background: transparent !important; position: static !important; }
  table.m-stack tfoot td:empty { display: none; }
}

/* 📱 v347: بحث الأصناف في فاتورة البيع/الشراء على الموبايل - الخانة كانت متزنوقة جنب الكاميرا (cam-wrap واخد flex من الخانة) */
@media (max-width: 900px) {
  .picker-search-row > .cam-wrap { flex: 1 1 100% !important; min-width: 0 !important; order: -1; }
  .picker-search-row > .cam-wrap > input { flex: 1 1 auto !important; min-width: 0 !important; height: 50px; font-size: 16px !important; padding: 0 14px; border-radius: 12px; }
  .picker-search-row > .cam-wrap > .cam-btn { width: 50px; min-height: 50px; border-radius: 12px; }
  /* خانة العميل الزرقا: العلامة صغيرة والخانة جنبها في نفس السطر، وبيانات العميل تحتهم */
  .cust-box { flex-wrap: wrap; }
  .cust-box > .cust-tag { height: 46px; padding: 0 10px; font-size: 13px; }
  .cust-box > div:not(.cust-meta) { flex: 1 1 0% !important; min-width: 0 !important; }
  .cust-box .cp-input { height: 46px; font-size: 16px !important; }
  .cust-box > .cust-meta { flex: 1 1 100% !important; margin: 4px 0 0 !important; flex-wrap: wrap; }
  .inv-cust-row { flex-wrap: wrap; gap: 6px; }
  .inv-cust-row > .cust-box { flex: 1 1 100%; }
}

/* 📱 v347: أزرار أكبر للصباع على الموبايل (مراجعة كل الشاشات) */
@media (max-width: 900px) {
  .btn.small, button.btn.small, a.btn.small { min-height: 36px; }
  #new-invoice-fab .fab-label { display: none !important; }
  /* فلاتر القوايم (طرق الدفع / الحالات / الفروع) */
  .si-filters-card button, .dl-filters-card button, .si-chip, .bsel-tile { min-height: 34px; }
  /* نظرة عامة */
  .ov-hide-btn { min-width: 36px; min-height: 32px; font-size: 16px !important; }
  .ov-kpis-wrap > .ov-hide-btn { position: static !important; display: block; margin: 0 0 4px auto; }
  .ov-hidden-bar button { min-height: 32px; }
  .ov-target-hide { min-width: 36px; min-height: 32px; }
  .ov-dr-tabs button { min-height: 32px; padding: 4px 12px !important; font-size: 13px !important; }
  .ov-kpi-sub a { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 6px; }
}

/* 📱 v347: أسهم تحريك الجداول ملهاش لازمة على الموبايل (الجداول بقت كروت)، وشريط تعديل الأسعار الجماعي مش ثابت فوق الكروت */
@media (max-width: 900px) {
  [id$="-scroll-right"], [id$="-scroll-left"], [id$="-scroll-up"], [id$="-scroll-down"], [id^="scroll-pe-"], [id^="scroll-table-"], .pe-arrow-btn { display: none !important; }
  #pe-totals-bar { position: static !important; box-shadow: none; padding: 10px 4px; }
  #pe-totals-bar .pe-bar-row { gap: 10px; }
  #pe-totals-bar .pe-sep { display: none; }
}

/* 📱 v347: اسم الشاشة في الشريط اللي فوق كان بيستخبى ورا شريحة الأيقونات */
@media (max-width: 900px) {
  #user-chip { gap: 3px; padding: 3px 4px; top: 7px; }
  body.mt-has-title .mobile-topbar-logo { display: none; }
  .mobile-topbar-page { max-width: calc(100vw - 245px); font-size: 15px; }
}

/* 📱 v347: سطور الأصناف في البيع/الشراء: رقم الترتيب الأزرق كان واخد سطر لوحده، وخانات الكمية والسعر من غير اسم */
@media (max-width: 900px) {
  .inv-item-row .item-no { display: none !important; }
  .inv-items-head { display: grid !important; grid-template-columns: 1fr 1fr 1fr auto !important; gap: 8px; font-size: 11.5px !important; font-weight: 800; margin: 0 0 2px !important; padding: 0 !important; position: sticky; top: 52px; z-index: 6; background: var(--card-bg); }
  .inv-items-head > div:first-child, .inv-items-head > [data-sort="name"] { display: none !important; }
  .inv-items-head > div:last-child { width: 36px; }
  .inv-item-row input { height: 42px; }
  .remove-item-btn { width: 36px !important; height: 36px !important; font-size: 14px !important; border-radius: 9px !important; }
}

/* 📱 v348: عرض السعر على الموبايل - البحث عرض كامل، وشريط الترتيب والأزرار في سطور مرتبة */
@media (max-width: 900px) {
  #qt-picker-wrap > div:first-child { flex-wrap: wrap; }
  #qt-picker-wrap > div:first-child > .cam-wrap { flex: 1 1 100% !important; min-width: 0 !important; }
  #qt-picker-wrap > div:first-child > .cam-wrap > input { height: 50px; border-radius: 12px; font-size: 16px !important; }
  #qt-picker-wrap > div:first-child > .cam-wrap > .cam-btn { width: 50px; min-height: 50px; border-radius: 12px; }
  #qt-picker-wrap > div:first-child > .btn { flex: 1 1 auto; }
  .card > div:has(> #qt-sortbar) { flex-wrap: wrap; gap: 8px; }
  .card > div:has(> #qt-sortbar) > h3 { flex: 1 1 100%; }
  #qt-sortbar { margin: 0 !important; flex: 1 1 100%; flex-direction: row; }
  #qt-sortbar [data-sort] { padding: 6px 12px; }
  .qt-top-row { flex-wrap: wrap; gap: 8px; }
  .qt-top-row .qt-cust { flex: 1 1 100%; }
  /* رأس الكمية/السعر في البيع/الشراء يستخبى لما مفيش أصناف */
  .inv-items-head:not(:has(+ * .inv-item-row)) { display: none !important; }
}

/* 📱 v348: زرار ＋ الأخضر كان بيغطي زراير الحفظ في شاشات المستندات وآخر كارت في القوايم */
@media (max-width: 900px) {
  body:has(.doc-footer) #new-invoice-fab, body:has(#qt-picker-wrap) #new-invoice-fab, body:has(.pos-wrap) #new-invoice-fab { display: none !important; }
  .main-content { padding-bottom: 84px; }
}

/* 📱 v348: تابات الفروع (الشركة / بورسعيد / المطرية) كانت بتتقص على الموبايل - بقت 3 جنب بعض كلها باينة */
@media (max-width: 900px) {
  #branch-filter-bar, :not(#branch-filter-bar):has(> .branch-tab + .branch-tab) { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); overflow: visible !important; gap: 6px; flex: 1 1 100% !important; width: 100%; max-width: 100%; }
  #branch-filter-bar .branch-tab, :has(> .branch-tab + .branch-tab) > .branch-tab { white-space: normal !important; padding: 8px 6px !important; font-size: 12.5px; line-height: 1.25; text-align: center; min-height: 40px; }
}

/* 🗄️ v349: الخزن مربعات (data-dsel-tiles) */
.dtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dtile { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--border-color); background: var(--card-bg); color: var(--text-main); font-family: inherit; font-size: 14.5px; font-weight: 800; cursor: pointer; text-align: start; transition: transform .1s, border-color .12s, background .12s, box-shadow .12s; }
.dtile span { min-width: 0; overflow: hidden; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dtile:hover { border-color: color-mix(in srgb, var(--dc) 55%, transparent); background: color-mix(in srgb, var(--dc) 7%, var(--card-bg)); }
.dtile:active { transform: scale(.97); }
.dtile.on { border-color: var(--dc); background: color-mix(in srgb, var(--dc) 14%, var(--card-bg)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dc) 22%, transparent); }
.dtile.on::after { content: "✓"; margin-inline-start: auto; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--dc); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.dtiles.need-choice { outline: 2px dashed #dc2626; outline-offset: 4px; border-radius: 12px; }
@media (max-width: 900px) { .dtiles { grid-template-columns: 1fr 1fr; } .dtile { min-height: 50px; font-size: 13.5px; } }

/* 🗄️ v353: مربعات الخزن جوه سطر الدفع (البيع/الشراء/المرتجعات): المربعات سطر كامل والمبلغ تحتها */
.pay-line:has(.dtiles) { grid-template-columns: minmax(0, 1fr) auto auto !important; align-items: end; }
.pay-line:has(.dtiles) > div:first-child { grid-column: 1 / -1; }
.pay-line:has(.dtiles) .dtile { min-height: 58px; font-size: 15px; }
.sr-split-row:has(.dtiles), .pr-split-row:has(.dtiles) { flex-wrap: wrap; }
.sr-split-row .dtiles, .pr-split-row .dtiles { flex: 1 1 100%; }

/* 🎨 v355: أيقونات القائمة - مربع بلون القسم وأيقونة خطوط بيضا (الشكل رقم 1) */
.sb-sq { width: 30px !important; height: 30px !important; border-radius: 9px; flex-shrink: 0; display: inline-flex !important; align-items: center; justify-content: center; background: var(--gc) !important; color: #fff !important; filter: none !important; opacity: 1 !important; box-shadow: 0 2px 6px color-mix(in srgb, var(--gc) 35%, transparent); }
.sb-sq svg { width: 18px; height: 18px; }
.sidebar-group-toggle { font-size: 13.5px; }
.sidebar-group-toggle:hover .sb-sq { transform: scale(1.06); }
.sb-sq { transition: transform .15s ease; }
.sidebar-group-toggle.open { background: color-mix(in srgb, var(--gc, #60a5fa) 16%, transparent) !important; border-right-color: var(--gc, #60a5fa) !important; color: var(--sb-text-strong) !important; }
.sidebar-group-toggle.open .sidebar-group-arrow { background: var(--gc, var(--sb-accent)) !important; color: #fff !important; box-shadow: none !important; }
.sidebar-group-body.open .sidebar-group-inner { border-right-color: color-mix(in srgb, var(--gc, #60a5fa) 40%, transparent) !important; }

/* v356: الخزنة المختارة في فلتر طرق الدفع بتكبر جنب الدايرة (أوضح إنها المختارة) */
.dl-chip.dl-logo, .si-chip.si-logo { transition: transform .15s ease, width .15s ease, height .15s ease; }
/* v357: المختارة بتبقى مستطيل فيه الشعار كبير واسم الخزنة (بدل الدايرة) */
.dl-chip.dl-logo.active, .si-chip.si-logo.active { width: auto; height: 46px; margin: 0 4px; padding: 0 14px 0 6px; gap: 8px; border-radius: 12px; }
.dl-chip.dl-logo.active::after, .si-chip.si-logo.active::after { content: attr(title); font-weight: 800; font-size: 14px; color: var(--text-main); white-space: nowrap; }
.dl-chip.dl-logo.active .method-logo, .si-chip.si-logo.active .method-logo { width: 34px !important; height: 34px !important; border-radius: 9px !important; }
.dl-chip.dl-logo.active .method-logo svg, .si-chip.si-logo.active .method-logo svg, .dl-chip.dl-logo.active .method-logo img, .si-chip.si-logo.active .method-logo img { width: 100%; height: 100%; }

/* ✨ v358: كروت الخزن في شاشة الخزنة - إطار بلون الخزنة، بتنوّر وتعلى لما تقف عليها، والضغط = كشف حسابها */
.stat-card.dr-go { position: relative; cursor: pointer; border: 2px solid color-mix(in srgb, var(--dc) 55%, transparent) !important; background: color-mix(in srgb, var(--dc) 7%, var(--card-bg)); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; outline: none; }
.stat-card.dr-go:hover, .stat-card.dr-go:focus-visible { transform: translateY(-4px); border-color: var(--dc) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--dc) 25%, transparent), 0 10px 28px color-mix(in srgb, var(--dc) 40%, transparent); }
.stat-card.dr-go .drawer-sticker { transition: transform .2s ease; }
.stat-card.dr-go:hover .drawer-sticker { transform: scale(1.12) rotate(-4deg); }
.stat-card.dr-go .stat-label { font-weight: 800; }
.dr-go-hint { font-size: 12px; font-weight: 800; color: var(--dc); opacity: 0; transform: translateY(4px); transition: opacity .16s ease, transform .16s ease; margin-top: 4px; }
.stat-card.dr-go:hover .dr-go-hint, .stat-card.dr-go:focus-visible .dr-go-hint { opacity: 1; transform: none; }
/* v400: كل فرع لوحده + حركة الفترة تحت الرصيد */
.dr-branches { display:flex; flex-direction:column; gap:2px; margin-top:6px; font-size:12.5px; font-weight:700; color:var(--text-muted); }
.dr-period { margin-top:6px; font-size:12px; font-weight:700; color:var(--text-muted); }
.dr-period.up b { color:#16a34a; }
.dr-period.down b { color:#dc2626; }
.stat-card.highlight.dr-go { background: color-mix(in srgb, #f59e0b 10%, #1e293b); }
@media (prefers-reduced-motion: reduce) { .stat-card.dr-go, .stat-card.dr-go .drawer-sticker { transition: none; } .stat-card.dr-go:hover { transform: none; } }

/* 🗄️ v359: اسم الخزنة في الجداول بالشعار جنبه */
.dcell { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; vertical-align: middle; }
.dcell > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcell .method-logo { flex-shrink: 0; }

/* v380/v382: قايمة العملاء - العميل الحالي: إطار برتقاني منوّر بينبض ومن جوه شفاف (زي زرار منوّر بيتحرك) */
#customers-body tr.cust-cur > td { background-image: linear-gradient(rgba(234, 88, 12, .07), rgba(234, 88, 12, .07)) !important; }
#customers-body tr.cust-cur { outline: 2px solid #ea580c; outline-offset: -2px; animation: zoomCurGlow 1.4s ease-in-out infinite; }
@keyframes zoomCurGlow { 0%, 100% { outline-color: #ea580c; } 50% { outline-color: rgba(234, 88, 12, .35); } }
@media (prefers-reduced-motion: reduce) { #customers-body tr.cust-cur { animation: none; } }

/* v381: نافذة «دفع للمورد» - المبلغ أول سطر كبير، والخزن مربعات في صندوق مميز */
.spay-form label { font-weight: 800; }
.spay-amount { margin-bottom: 12px; }
.spay-amount .cam-wrap, .spay-amount > div { width: 100%; }
.spay-amount input { font-size: 26px; font-weight: 800; height: 58px; text-align: center; direction: ltr; border: 2px solid #16a34a; border-radius: 12px; }
.spay-amount input:focus { box-shadow: 0 0 0 4px rgba(22, 163, 74, .18); }
.spay-box { background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 14px; padding: 10px 12px 12px; margin-bottom: 12px; }
.spay-box > label { display: block; margin-bottom: 8px; }
.spay-box .dtiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.spay-line { margin-bottom: 10px; }
.spay-line input { width: 100%; }
.spay-submit { width: 100%; font-size: 17px; padding: 12px; }
@media (max-width: 900px) { .spay-box .dtiles { grid-template-columns: 1fr 1fr; } }

/* v383: رصيد المورد في نافذة الدفع - أكبر والمبلغ في مربع بلون */
.spay-bal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; font-size: 16px; font-weight: 800; color: var(--text-main); }
.spay-bal-amt { font-size: 22px; padding: 4px 14px; border-radius: 10px; border: 2px solid; direction: ltr; }
.spay-bal-amt.alayh { color: #dc2626; border-color: #dc2626; background: rgba(220, 38, 38, .08); }
.spay-bal-amt.lahu { color: #16a34a; border-color: #16a34a; background: rgba(22, 163, 74, .08); }
.spay-bal-amt.zero { color: var(--text-muted); border-color: var(--border-color); }
.spay-bal-tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; color: #fff; }
.spay-bal-tag.alayh { background: #dc2626; } .spay-bal-tag.lahu { background: #16a34a; }
/* v383: رسالة «تم» كبيرة في نص الشاشة - بتتقفل بدوسة في أي حتة */
.zdone-ov { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 4300; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.zdone-box { background: var(--card-bg); color: var(--text-main); border-radius: 22px; padding: 26px 44px; text-align: center; min-width: 340px; max-width: 92vw; box-shadow: 0 24px 70px rgba(0, 0, 0, .4); border-top: 8px solid #16a34a; animation: zdonePop .18s ease-out; }
.zdone-icon { font-size: 44px; line-height: 1; }
.zdone-title { font-size: 28px; font-weight: 800; color: #16a34a; margin: 6px 0; }
.zdone-sub { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.zdone-bal { font-size: 20px; font-weight: 800; margin: 10px 0 4px; }
.zdone-bal b { display: inline-block; padding: 2px 12px; border-radius: 10px; border: 2px solid; direction: ltr; }
.zdone-bal b.alayh { color: #dc2626; border-color: #dc2626; } .zdone-bal b.lahu { color: #16a34a; border-color: #16a34a; } .zdone-bal b.zero { color: #16a34a; border: none; }
.zdone-hint { font-size: 13px; color: var(--text-muted); margin-top: 12px; }
@keyframes zdonePop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* v384: الموردين - مربعين ليهم/عليهم + إخفاء الأرقام */
.sup-money { display: flex; gap: 12px; align-items: stretch; margin-bottom: 12px; flex-wrap: wrap; }
.sup-money .cls-money { flex: 0 1 260px; min-width: 200px; }
.sup-money-eye { align-self: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--card-bg); font-size: 18px; cursor: pointer; }
.sup-money-eye:hover { border-color: #2563eb; }
.sup-money-off .cls-money-num { filter: blur(8px); user-select: none; }
@media (max-width: 900px) { .sup-money .cls-money { flex: 1 1 0; min-width: 0; } }

/* v385: الشريط - آلة حاسبة + علامة الجهاز الموثوق للمدير (أخضر/أحمر) */
#user-chip #rail-calc-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 19px; cursor: pointer; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: #fff; transition: background .15s ease, transform .15s ease; }
#user-chip #rail-calc-btn:hover { background: rgba(255,255,255,0.18); transform: scale(1.06); }
#user-chip #rail-trust-dot { width: 14px; height: 14px; border-radius: 50%; padding: 0; cursor: pointer; border: 2px solid rgba(255,255,255,.55); background: #dc2626; box-shadow: 0 0 8px rgba(220,38,38,.8); }
#user-chip #rail-trust-dot.ok { background: #16a34a; box-shadow: 0 0 8px rgba(22,163,74,.8); }
@media (max-width: 900px) { #user-chip #rail-calc-btn { display: none; } #user-chip #rail-trust-dot { width: 12px; height: 12px; } }
#zoom-calc { position: fixed; left: 76px; top: 70px; z-index: 4400; width: 270px; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.3); padding: 10px; direction: ltr; }
#zoom-calc .zc-head { display: flex; justify-content: space-between; align-items: center; direction: rtl; margin-bottom: 8px; }
#zoom-calc .zc-x { border: none; background: transparent; cursor: pointer; font-size: 16px; color: var(--text-muted); }
#zoom-calc .zc-screen { background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 10px; padding: 8px 10px; text-align: right; margin-bottom: 8px; min-height: 62px; }
#zoom-calc .zc-expr { font-size: 14px; color: var(--text-muted); min-height: 18px; word-break: break-all; }
#zoom-calc .zc-res { font-size: 26px; font-weight: 800; word-break: break-all; }
#zoom-calc .zc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#zoom-calc .zc-k { height: 44px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); font-size: 18px; font-weight: 800; cursor: pointer; font-family: inherit; }
#zoom-calc .zc-k:hover { background: var(--hover-bg); }
#zoom-calc .zc-k.op { color: #2563eb; }
#zoom-calc .zc-k.eq { background: #16a34a; border-color: #16a34a; color: #fff; }
#zoom-calc .zc-k.clr { color: #dc2626; }
#zoom-calc .zc-copy { width: 100%; margin-top: 8px; border: 1px dashed var(--border-color); background: transparent; color: var(--text-muted); border-radius: 10px; padding: 6px; cursor: pointer; font-family: inherit; font-weight: 700; direction: rtl; }

/* v387: زرار سعر الدولار + نافذته */
#user-chip #rail-usd-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; font-weight: 800; cursor: pointer; background: rgba(22,163,74,0.18); border: 1px solid rgba(74,222,128,0.45); color: #4ade80; font-family: inherit; transition: background .15s ease, transform .15s ease; }
#user-chip #rail-usd-btn:hover { background: rgba(22,163,74,0.32); transform: scale(1.06); }
#user-chip #rail-calc-btn { display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 900px) { #user-chip #rail-usd-btn { display: none; } }
#zoom-usd { position: fixed; left: 76px; top: 110px; z-index: 4400; width: 290px; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.3); padding: 12px; }
#zoom-usd .zc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#zoom-usd .zc-x { border: none; background: transparent; cursor: pointer; font-size: 16px; color: var(--text-muted); }
#zoom-usd .zu-rate { font-size: 24px; font-weight: 800; text-align: center; direction: ltr; padding: 10px; border-radius: 12px; background: rgba(22,163,74,.08); border: 2px solid #16a34a; }
#zoom-usd .zu-rate b { color: #16a34a; font-size: 30px; }
#zoom-usd .zu-time { font-size: 12px; color: var(--text-muted); text-align: center; margin: 6px 0 10px; }
#zoom-usd .zu-conv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#zoom-usd .zu-conv label { font-size: 12.5px; font-weight: 800; display: flex; flex-direction: column; gap: 4px; }
#zoom-usd .zu-conv input { margin: 0; font-size: 17px; font-weight: 800; text-align: center; direction: ltr; }
#zoom-usd .zu-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; text-align: center; }

/* v388: سطر سعر الدولار في دفع مورد دولار */
.zfx-row .zfx-lbl { display: block; font-weight: 800; margin-bottom: 6px; }
.zfx-row .zfx-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zfx-row .zfx-rate { width: 130px; margin: 0; font-size: 18px; font-weight: 800; text-align: center; direction: ltr; }
.zfx-row .zfx-eq { font-weight: 800; color: var(--text-muted); }
.zfx-row .zfx-usd { font-size: 20px; color: #16a34a; direction: ltr; padding: 2px 12px; border: 2px solid #16a34a; border-radius: 10px; background: rgba(22,163,74,.08); }
.zfx-row .zfx-today { border: 1px dashed var(--border-color); background: transparent; color: var(--text-muted); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 12px; }
.zfx-row .zfx-src { font-size: 11.5px; margin-top: 4px; }

/* v393: كارت التركيب في الإعدادات */
.inst-svcs { display: flex; gap: 14px; flex-wrap: wrap; }
.inst-br { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--border-color); }
.inst-br > b { min-width: 110px; }
.inst-dues { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--subtle-bg); border: 1px solid var(--border-color); }
.inst-due { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 4px 0; }

/* v394: زرار «مستحقات تركيب (للفني)» في المصروفات */
.ex-install-pick { display: block; width: 100%; margin: 4px 0 8px; padding: 10px 12px; border-radius: 12px; border: 2px dashed #ea580c; background: rgba(234,88,12,.08); color: #c2410c; font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; text-align: start; }
.ex-install-pick:hover { background: rgba(234,88,12,.16); }
.ex-install-pick.on { border-style: solid; background: #ea580c; color: #fff; }
.ex-install-pick.on::after { content: "  ✓ مختار"; }

/* 📅 v411: فلتر الوقت - «اليوم» و«الشهر» مربعات جنب القايمة */
.zdf-wrap { display: inline-flex; gap: 6px; align-items: stretch; flex-wrap: nowrap; }
.zdf-q { font: inherit; font-weight: 800; font-size: 13px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); cursor: pointer; white-space: nowrap; }
.zdf-q:hover { border-color: #93c5fd; background: var(--hover-bg); }
.zdf-q.on { background: #2563eb; border-color: #2563eb; color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,.3); }
.zdf-picked, .zdf-picked:hover { background: #ea580c !important; border-color: #ea580c !important; color: #fff !important; box-shadow: 0 3px 10px rgba(234,88,12,.3); } /* v534 */
.zdf-q[data-q="this_month"].on { background: #7c3aed; border-color: #7c3aed; box-shadow: 0 3px 10px rgba(124,58,237,.3); }

/* 🔎 v414: فلاتر التصنيف/البرند/... بخانة بحث وخط تقيل */
.zas-btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; font: inherit; font-weight: 800; font-size: 13px; text-align: right;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); cursor: pointer; }
.zas-btn:hover { border-color: #93c5fd; }
.zas-btn.on { border-color: #2563eb; background: rgba(37,99,235,.1); color: #1d4ed8; }
:root[data-theme="dark"] .zas-btn.on { color: #93c5fd; }
.zas-btn .zas-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zas-btn .zas-arrow { opacity: .6; flex-shrink: 0; }
/* 🧱 v469: نافذة الصنف عمودين (الكمبيوتر) - البيانات يمين والصورة + الخصائص في عمود ضيق شمال */
.modal-box.pf-wide { max-width: 1120px !important; }
.pf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.pf-side { background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 2px 14px 14px; position: sticky; top: 0; }
.pf-side h3 { margin-top: 12px !important; }
/* v470: عناوين أقسام نافذة الصنف كانت بلون ثابت باهت في الوضع الغامق */
.pf-layout h3 { color: var(--heading-color, var(--text-main)) !important; border-bottom-color: var(--border-color) !important; }
#p-nav-bottom { flex-shrink: 0; }
/* v471: اسم الصنف جنب عنوان نافذة الصنف */
#p-title-name { font-size: 20px; font-weight: 800; color: #2563eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
:root[data-theme="dark"] #p-title-name { color: #93c5fd; }
.pf-side .row { display: block; }
.pf-side .row > div { margin-bottom: 10px; }
.pf-side > div:has(> #p-image-preview) { flex-wrap: wrap; }
.pf-side #p-image-input { max-width: 100%; }
/* ✍️ v468: خانة خصائص الصنف بالكتابة (zoomComboSelect) */
.zcb { position: relative; }
.zcb .zcb-in { width: 100%; box-sizing: border-box; font-weight: 700; padding-left: 34px; }
.zcb.on .zcb-in { border-color: #2563eb; }
.zcb.is-new .zcb-in { border-color: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,.18); padding-left: 96px; }
.zcb .zcb-tag { display: none; position: absolute; left: 32px; top: 50%; transform: translateY(-50%); background: #16a34a; color: #fff; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; pointer-events: none; }
.zcb.is-new .zcb-tag { display: block; }
.zcb .zcb-x { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 4px; width: auto; }
.zcb:not(.on):not(.is-new) .zcb-x { display: none; }
.zcb .zcb-list { display: none; position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 3000; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); padding: 6px; max-height: 260px; overflow-y: auto; }
.zcb .zcb-opt { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zcb .zcb-opt:hover, .zcb .zcb-opt.hi { background: var(--hover-bg); }
.zcb .zcb-opt.sel { color: #2563eb; }
.zcb .zcb-opt.zcb-add { color: #16a34a; }
.zcb .zcb-empty { padding: 8px 10px; color: var(--text-muted); font-size: 13px; }
.zas-pop { position: fixed; z-index: 3000; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); padding: 8px; direction: rtl; }
.zas-pop .zas-q { width: 100%; box-sizing: border-box; font: inherit; font-weight: 700; padding: 8px 10px; border-radius: 8px; border: 2px solid #2563eb; margin-bottom: 6px; background: var(--card-bg); color: var(--text-main); }
.zas-pop .zas-list { max-height: 300px; overflow-y: auto; }
.zas-pop .zas-opt { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zas-pop .zas-opt:hover, .zas-pop .zas-opt.hi { background: var(--hover-bg); }
.zas-pop .zas-opt.sel { color: #2563eb; }
.zas-pop .zas-opt.zas-all { color: var(--text-muted); font-size: 12.5px; }
.zas-pop .zas-empty { padding: 8px 10px; color: var(--text-muted); font-size: 12.5px; }
@media (max-width: 900px) { .zas-btn { font-size: 15px; padding: 9px 10px; } .zas-pop .zas-q { font-size: 16px; } }

/* ⇄ v415: التنقل بين الأصناف في فورم التعديل */
.pnav { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.pnav-btn { font: inherit; font-weight: 800; font-size: 14px; padding: 8px 16px; border-radius: 10px; border: 2px solid #2563eb; background: #2563eb; color: #fff; cursor: pointer; white-space: nowrap; box-shadow: 0 3px 10px rgba(37,99,235,.3); }
.pnav-btn:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.pnav-btn:disabled { background: var(--subtle-bg); border-color: var(--border-color); color: var(--text-muted); box-shadow: none; cursor: default; }
.pnav-pos { font-weight: 800; font-size: 13px; color: var(--text-muted); min-width: 64px; text-align: center; }
@media (max-width: 900px) { .pnav-btn { padding: 8px 10px; font-size: 13px; } .pnav-pos { min-width: 0; } }

/* v419: الصف المختار بالأسهم/بكرة الماوس (scrollIntoView) ميستخباش تحت عنوان الجدول الثابت أو الإجمالي تحت - في كل الجداول */
tbody tr { scroll-margin-top: 52px; scroll-margin-bottom: 44px; }

/* ⚏ v420: لوحة حساب الأسعار في خطوة الأسعار بعد فاتورة الشراء */
.ps-calc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--subtle-bg); border: 1px solid var(--border-color); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.ps-calc label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin: 0; white-space: nowrap; }
.ps-calc select { width: auto; padding: 5px 8px; margin: 0; }
.ps-calc .ps-t input[type="number"] { width: 70px; padding: 4px 6px; margin: 0; }
.ps-calc .ps-sep { width: 1px; align-self: stretch; background: var(--border-color); }

/* v421: إجمالي المستند قبل الخصم جنب الإجمالي (بعد الخصم) - فاتورة البيع والشراء وعرض السعر */
.doc-footer .df-before { font-size: 14px; font-weight: 700; color: var(--text-muted); white-space: nowrap; padding: 4px 10px; border: 1px dashed var(--border-color); border-radius: 8px; }
.doc-footer .df-before b { color: var(--text-main); font-size: 16px; font-weight: 800; }

/* 💲 v422: علامة $ جنب إجمالي فاتورة البيع - الوقوف عليها = POP الفاتورة */
.inv-pop-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-inline-start: 8px;
  border-radius: 50%; background: #16a34a; color: #fff; font-size: 13px; font-weight: 800; cursor: help; vertical-align: middle; }
.inv-pop-tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); right: 50%; transform: translateX(50%); white-space: nowrap;
  background: #14532d; color: #fff; font-size: 14px; font-weight: 800; padding: 7px 12px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 50; }
.inv-pop-tip:hover::after, .inv-pop-tip:focus::after { opacity: 1; }

/* 0️⃣ v423: الصفر في خانات الأرقام باهت (زي المثال) - أول رقم بيتكتب بيمسحه */
input.zoom-zero { color: var(--text-muted) !important; -webkit-text-fill-color: var(--text-muted); opacity: .75; }
input.zoom-zero:focus { opacity: 1; }

/* 💲 v435: علامة $ (POP) - الضغط عليها بيثبّتها (الموبايل مفيهوش وقوف بالماوس)، وبالسالب حمرا */
.inv-pop-tip.show::after { opacity: 1; }
.inv-pop-tip.neg { background: #dc2626; }
@media (max-width: 900px) { .inv-pop-tip { width: 26px; height: 26px; font-size: 15px; } .inv-pop-tip::after { right: auto; left: 0; transform: none; } }

/* 📱 v435: الموبايل - شريحة الأيقونات فوق = صورتك بس (ونقطة حمرا لو فيه إشعارات)، والضغط عليها بيفتح كل الأزرار لتحت.
   علامة «الجهاز موثوق» اتشالت من الموبايل، والدولار والآلة الحاسبة ظاهرين جوه القايمة */
@media (max-width: 900px) {
  #user-chip:not(.m-open) > :not(#chip-avatar-wrap) { display: none !important; }
  #user-chip:not(.m-open) { padding: 2px; gap: 0; }
  #user-chip #chip-avatar-wrap { position: relative; cursor: pointer; display: inline-flex; }
  #user-chip.has-notif:not(.m-open) #chip-avatar-wrap::after { content: ""; position: absolute; top: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
  #user-chip #rail-trust-dot { display: none !important; }
  #user-chip.m-open {
    flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px;
    width: min(300px, calc(100vw - 16px)); padding: 12px; border-radius: 18px;
    background: var(--card-bg); border: 1px solid var(--border-color); box-shadow: 0 14px 40px rgba(0,0,0,.28);
    -webkit-backdrop-filter: none; backdrop-filter: none; z-index: 400;
  }
  #user-chip.m-open #chip-avatar-wrap { order: -2; }
  #user-chip.m-open .rail-role { order: -1; display: inline-block !important; flex: 1; font-weight: 800; color: var(--text-main); font-size: 15px; }
  #user-chip.m-open .rail-spacer { display: none !important; }
  #user-chip.m-open .gs-wrap { order: 0; width: 100% !important; flex-basis: 100%; }
  #user-chip.m-open .gs-wrap #global-search-input { opacity: 1 !important; pointer-events: auto !important; width: 100% !important; padding: 8px 34px 8px 10px; }
  #user-chip.m-open .gs-wrap .gs-hint { display: none; }
  #user-chip.m-open > button, #user-chip.m-open .notif-wrap > button { order: 1; width: 48px !important; height: 48px !important; border-radius: 14px !important; font-size: 21px; display: inline-flex !important; align-items: center; justify-content: center; }
  #user-chip.m-open #rail-usd-btn, #user-chip.m-open #rail-calc-btn { display: inline-flex !important; }
  #user-chip.m-open .notif-wrap { order: 1; }
  #user-chip.m-open #rail-logout-btn { order: 2; }
  .mobile-topbar-page { max-width: calc(100vw - 130px); }
}
@media (max-width: 900px) {
  #user-chip.m-open :is(#rail-calc-btn, #theme-toggle-btn, #notif-btn) { background: var(--subtle-bg) !important; border: 1px solid var(--border-color) !important; color: var(--text-main) !important; }
  #user-chip.m-open #rail-logout-btn { background: rgba(239,68,68,.12) !important; border: 1px solid rgba(239,68,68,.45) !important; }
  #user-chip.m-open #rail-usd-btn { background: rgba(22,163,74,.14) !important; border: 1px solid rgba(22,163,74,.5) !important; color: #16a34a !important; }
}
@media (max-width: 900px) {
  #user-chip.m-open #notif-panel, #user-chip.m-open #global-search-results { position: fixed; left: 8px; right: 8px; width: auto; top: 222px; max-height: calc(100vh - 240px); overflow-y: auto; }
}

/* 📱 v437 (طلب صاحب المشروع): القايمة عمود بالطول على الشمال، والبحث أيقونة - الضغط عليها بيفتح مستطيل بحث أعلى جنب العمود،
   والخلفية غامقة/مليانة مش شفافة (كانت قاعدة الوضع الغامق للشريحة بتغلب عليها) */
@media (max-width: 900px) {
  #user-chip.m-open, :root[data-theme="dark"] #user-chip.m-open {
    flex-direction: column !important; flex-wrap: nowrap !important; align-items: center !important; justify-content: flex-start !important;
    width: 70px !important; padding: 10px 0 !important; gap: 10px !important; border-radius: 20px !important;
    background: #ffffff !important; border: 1px solid #cbd5e1 !important; box-shadow: 0 16px 44px rgba(0,0,0,.35) !important;
    max-height: calc(100vh - 16px); overflow-y: auto;
  }
  :root[data-theme="dark"] #user-chip.m-open { background: #0b1222 !important; border-color: #334155 !important; box-shadow: 0 16px 44px rgba(0,0,0,.7) !important; }
  #user-chip.m-open .rail-role { display: none !important; }
  #user-chip.m-open #chip-avatar-wrap { order: -2; }
  /* البحث = أيقونة بنفس حجم الأزرار؛ الخانة نفسها شفافة فوقها عشان الضغطة تفتحها */
  #user-chip.m-open .gs-wrap { order: -1; width: 48px !important; height: 48px !important; flex-basis: auto !important; flex-shrink: 0; border-radius: 14px !important;
    background: var(--subtle-bg) !important; border: 1px solid var(--border-color) !important; position: relative; }
  #user-chip.m-open .gs-wrap .gs-icon { font-size: 20px; }
  #user-chip.m-open .gs-wrap #global-search-input { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; opacity: 0 !important; padding: 0 !important; }
  #user-chip.m-open .gs-wrap:focus-within #global-search-input {
    position: fixed !important; left: 88px !important; right: 8px !important; top: 10px !important; width: auto !important; height: 58px !important; inset: 10px 8px auto 88px !important;
    opacity: 1 !important; padding: 0 16px !important; font-size: 18px !important; font-weight: 700; border-radius: 14px !important;
    background: #ffffff !important; color: #0f172a !important; border: 2px solid #2563eb !important; box-shadow: 0 12px 34px rgba(0,0,0,.35) !important; z-index: 420;
  }
  :root[data-theme="dark"] #user-chip.m-open .gs-wrap:focus-within #global-search-input { background: #0b1222 !important; color: #f1f5f9 !important; }
  #user-chip.m-open #global-search-results { position: fixed !important; left: 88px !important; right: 8px !important; top: 76px !important; width: auto !important; max-height: calc(100vh - 90px); overflow-y: auto; z-index: 420; }
  #user-chip.m-open #notif-panel { position: fixed !important; left: 88px !important; right: 8px !important; top: 10px !important; width: auto !important; max-height: calc(100vh - 20px); overflow-y: auto; z-index: 420; }
  #user-chip.m-open > button, #user-chip.m-open .notif-wrap { flex-shrink: 0; }
}

/* 🖼️ v438: زرار الصور في قايمة اختيار الأصناف - أيقونة بس، وأخضر مزرق لما يبقى شغال */
.zpic-btn { display: inline-flex !important; align-items: center; justify-content: center; padding: 6px 10px !important; min-width: 42px; flex-shrink: 0; }
.zpic-btn.on { background: #0d9488 !important; border-color: #0d9488 !important; color: #fff !important; }
#picker-table td[data-k="image"] { padding: 3px 6px; }
.zp-img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: var(--subtle-bg); display: block; }
.zp-noimg { width: 44px; height: 44px; border-radius: 6px; background: var(--subtle-bg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
@media (max-width: 900px) { .picker-wrap.open #picker-table td[data-k="image"] { flex: 0 0 auto; } .picker-wrap.open #picker-table td[data-k="image"]::before { display: none; } }

/* 🎨 v439: الكلمات الملوّنة في أسامي الأصناف (اللون نفسه من الإعدادات) */

/* 🏷️ v448: اسم الأيقونة لما القائمة مقفولة */
.sb-tip { position: fixed; z-index: 3000; display: none; pointer-events: none; white-space: nowrap;
  background: #0f172a; color: #fff; font-size: 14px; font-weight: 800; padding: 7px 13px; border-radius: 9px;
  box-shadow: 0 8px 22px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12); }
.sb-tip::after { content: ""; position: absolute; top: 50%; transform: translateY(-50%); border: 6px solid transparent; left: -12px; border-right-color: #0f172a; }
.sb-tip.to-left::after { left: auto; right: -12px; border-right-color: transparent; border-left-color: #0f172a; }

/* 💵 v452: زرار تحديث سعر الدولار */
#zoom-usd .zu-refresh { display:block; width:100%; margin:8px 0 2px; padding:8px; border-radius:10px; border:1px solid #16a34a; background:#dcfce7; color:#166534; font-weight:800; font-family:inherit; cursor:pointer; }
#zoom-usd .zu-refresh:hover { background:#bbf7d0; }
#zoom-usd .zu-refresh:disabled { opacity:.6; cursor:wait; }
:root[data-theme="dark"] #zoom-usd .zu-refresh { background:rgba(22,163,74,.18); color:#86efac; border-color:rgba(74,222,128,.5); }

/* 🆕 v456: نافذة «تسجيل صنف جديد» عريضة ومترتبة */
.qp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 12px; }
.qp-grid label { margin-top: 6px; }
.qp-grid input, .qp-grid select, .qp-grid .zas-btn { margin-bottom: 0; }
.qp-span2 { grid-column: span 2; }
.qp-span4 { grid-column: 1 / -1; }
.qp-sec { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--border-color); font-weight: 800; color: var(--heading-color); }
.qp-attrs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .qp-grid, .qp-attrs { grid-template-columns: repeat(2, minmax(0, 1fr)); } .qp-span4, .qp-attrs .qp-span2 { grid-column: 1 / -1; } }

/* 📱 v493 (طلب صاحب المشروع): الموبايل - «حفظ وطباعة» مستخبي (مفيش طباعة من الموبايل)، وزراير الحفظ قصيرة في سطر واحد بدل المربعات الطويلة */
@media (max-width: 900px) {
  .btn.save-print { display: none !important; }
  .df-actions, .save-actions { display: flex !important; flex-wrap: nowrap !important; gap: 6px !important; width: 100%; }
  .df-actions .btn, .save-actions .btn { flex: 1 1 0; min-width: 0; min-height: 46px !important; padding: 8px 6px !important; font-size: 14px !important; line-height: 1.2; white-space: normal; }
  .df-actions .btn.save-only, .save-actions .btn.save-only { flex: 1.4 1 0; font-size: 17px !important; }
  .m-stock.m-zx { margin-inline-start: auto; color: #fff !important; background: #dc2626 !important; border-color: #dc2626 !important; font-weight: 800; } /* v507: ZX لوحده على الشمال بالأحمر الصريح */
  :root[data-theme="dark"] .m-stock.m-zx b { color: #fff; }
}

/* 🔍 v495: حجم البرنامج (zoom على الشاشة الأم) - الطول بالـ vh بيتعوّض عشان الشاشة توصل لتحت */
.tabs-main, .app-shell > .sidebar, .app-shell > .main-content { height: calc(100vh / var(--zoom-ui, 1)) !important; }

/* 🎨 v497: لوجو القايمة = أيقونة البرنامج الجديدة (Z الأزرق المنور) */
.sb-logo { background: #0b1220 url("icon-192.png?v=2") center / cover no-repeat !important; color: transparent !important; text-shadow: none !important; }

/* 👆 v502: سحب الكارت = زرار مسح (zoomSwipeDelete) - الزرار برّه الكارت على الشمال وبيظهر لما الكارت يتزق يمين */
.m-card[data-del] { position: relative; touch-action: pan-y; }
.zsw-act { position: absolute; top: 50%; left: -60px; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 14px; border: none; background: #ef4444; color: #fff; font-family: inherit; display: flex; align-items: center; justify-content: center; cursor: pointer; background: linear-gradient(160deg, #f87171, #dc2626); box-shadow: 0 4px 12px rgba(220,38,38,.35); }
.zsw-act span { font-size: 11px; }
.zsw-act.zsw-hide { background: linear-gradient(160deg, #94a3b8, #475569); box-shadow: 0 4px 12px rgba(71,85,105,.35); font-size: 20px; } /* v522 */

/* v507: كلمة ZX جوه المربع الأحمر بيضا (التلوين العام بيخليها حمرا) */
.m-stock.m-zx .pops-word { color: #fff !important; }

/* 🏠 v510: «ZOOM ERP» فوق في الموبايل = نظرة عامة */
.mobile-topbar-title, .mobile-topbar-logo, .mobile-topbar-page { cursor: pointer; }

/* 💰 v515: رصيد الخزنة تحت اسمها في المربع */
.dtile .dtile-txt { display: flex; flex-direction: column; gap: 1px; -webkit-line-clamp: unset; overflow: visible; }
.dtile .dtile-bal { font-size: 12px; font-weight: 800; color: var(--text-muted); direction: ltr; text-align: end; }
.dtile .dtile-bal.pos { color: #16a34a; }
.dtile .dtile-bal.neg { color: #dc2626; }

/* 🎨 v516: نافذة التحويل بين الخزن بالعرض */
.xfer-box { max-width: 980px !important; width: 96%; }
.xfer-grid { display: grid; grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); gap: 8px; align-items: stretch; }
.xfer-grid .xfer-arrow { display: flex; align-items: center; justify-content: center; margin: 0; }
.xfer-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; margin-top: 12px; }
.xfer-fields label { margin-top: 0; }
.xfer-date { display: flex; align-items: center; gap: 6px; }
.xfer-date label { margin: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.xfer-date input { margin: 0; font-size: 12px; padding: 4px 6px; width: auto; }
.xfer-go { width: 100%; background: #16a34a !important; font-size: 17px; font-weight: 800; padding: 14px; border-radius: 12px; }
#xfer-modal #xfer-amount + button { background: transparent !important; color: var(--text-muted) !important; border: 1.5px solid var(--border-color) !important; width: 52px; padding: 2px !important; font-size: 11px; line-height: 1.15; white-space: normal !important; }
@media (max-width: 900px) {
  .xfer-grid { grid-template-columns: 1fr; }
  .xfer-grid .xfer-arrow { transform: rotate(-90deg); }
  .xfer-fields { grid-template-columns: 1fr; }
}

/* ⚖️ v517: تسوية خزنة */
.adj-box { max-width: 820px !important; width: 96%; }
.adj-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.adj-tabs button, .adj-dir button { flex: 1; border: 2px solid var(--border-color); background: var(--card-bg); color: var(--text-main); border-radius: 10px; padding: 9px; font-family: inherit; font-weight: 800; cursor: pointer; }
.adj-tabs button.on { border-color: #0f766e; background: rgba(15,118,110,.1); color: #0f766e; }
.adj-dir { display: flex; gap: 8px; margin: 10px 0 2px; }
.adj-dir button.in.on { border-color: #16a34a; background: rgba(22,163,74,.12); color: #15803d; }
.adj-dir button.out.on { border-color: #dc2626; background: rgba(220,38,38,.1); color: #b91c1c; }
.adj-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--border-color); border-radius: 10px; }
.adj-table { width: 100%; border-collapse: collapse; }
.adj-table th { position: sticky; top: 0; background: var(--subtle-bg); font-size: 12.5px; padding: 6px 8px; text-align: start; }
.adj-table td { padding: 5px 8px; border-top: 1px solid var(--border-color); white-space: nowrap; }
.adj-table td .method-logo { vertical-align: middle; }
.adj-table .adj-exp { font-weight: 800; }
.adj-table .adj-in { width: 130px; margin: 0; padding: 6px 8px; font-weight: 800; }
.adj-d { font-weight: 800; }
.adj-d.pos, .adj-sum .pos { color: #16a34a; }
.adj-d.neg, .adj-sum .neg { color: #dc2626; }
.adj-d.ok { color: var(--text-muted); }
.adj-sum { margin-top: 6px; font-size: 13.5px; }
@media (max-width: 900px) { .adj-table .adj-in { width: 100px; } .adj-table td small { display: none; } }

/* v523: أزرار عمود الإجراءات أصغر في كل الجداول (الكمبيوتر) */
@media (min-width: 901px) {
  .table-scroll-wrap td.sticky-col .btn.small, .table-scroll-wrap td.sticky-col .btn { padding: 2px 7px; font-size: 11px; min-height: 0; line-height: 1.6; border-radius: 6px; }
  .table-scroll-wrap td.sticky-col > div { gap: 3px !important; }
}

/* v536: رقم التليفون في نافذة الشير */
.share-phone { display:flex; align-items:center; gap:10px; margin-top:10px; padding:8px 12px; border:1px dashed var(--border-color); border-radius:12px; background:var(--subtle-bg); }
.share-phone-lbl { color:var(--text-muted); font-weight:700; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.share-phone-num { font-size:18px; font-weight:800; letter-spacing:.5px; color:var(--text-main); flex:1; text-align:left; }

/* v541: مربع ZX لما تقف على صنف في الفاتورة */
.zct-tip { position:fixed; z-index:5000; pointer-events:none; background:var(--card-bg); color:var(--text-main); border:2px solid #dc2626; border-radius:12px; box-shadow:0 8px 24px rgba(0,0,0,.22); padding:8px 12px; min-width:170px; font-size:13px; opacity:0; transition:opacity .12s; }
.zct-tip.on { opacity:1; }
.zct-name { font-weight:800; margin-bottom:4px; max-width:260px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.zct-row { display:flex; justify-content:space-between; gap:14px; padding:2px 0; }
.zct-row span { color:var(--text-muted); font-weight:700; }
.zct-zx { color:#dc2626; font-size:15px; }
.zct-pos { color:#16a34a; } .zct-neg { color:#dc2626; }

/* 🤖 v544: اختصار الذكاء الاصطناعي في العمود */
#user-chip #rail-ai-btn { display: none; width: 40px; height: 40px; border-radius: 12px; font-size: 21px; cursor: pointer; background: rgba(124,58,237,0.28); border: 1px solid rgba(167,139,250,0.6); align-items: center; justify-content: center; transition: background .15s ease, transform .15s ease; }
#user-chip #rail-ai-btn.on { display: inline-flex; }
#user-chip #rail-ai-btn:hover { background: rgba(124,58,237,0.45); transform: scale(1.06); }
@media (max-width: 900px) {
  #user-chip #rail-ai-btn.on { display: none; }
  #user-chip.m-open #rail-ai-btn.on { display: inline-flex !important; background: rgba(124,58,237,.12) !important; border: 1px solid rgba(124,58,237,.5) !important; }
  #user-chip.m-open #rail-ai-btn:not(.on) { display: none !important; }
}

/* v562: «إضافة الرصيد» مربع فاضي بإطار بنفسجي (مش مليان) - في كل الشاشات */
.btn.zoom-fill-btn { white-space: nowrap; margin: 0; background: transparent !important; color: #7c3aed !important; border: 2px solid #7c3aed !important; box-shadow: none; }
.btn.zoom-fill-btn:hover { background: rgba(124, 58, 237, .08) !important; }
[data-theme="dark"] .btn.zoom-fill-btn { color: #c4b5fd !important; border-color: #a78bfa !important; }
@media (max-width: 900px) {
  /* v562: قايمة العملاء على الموبايل: الاسم سطر لوحده كامل والعلامات تحته (كان بيتقص «مد...») */
  .cp-item { flex-wrap: wrap; row-gap: 4px; }
  .cp-item-main { flex: 1 1 100%; }
  .cp-item-main b { white-space: normal; overflow: visible; text-overflow: clip; font-size: 15px; }
  .cp-item-side { flex-wrap: wrap; }
  /* مربعات ليهم/عليهم في الموردين بتترتب */
  #m-sup-summary [data-sup-sort] { cursor: pointer; }
  #m-sup-summary [data-sup-sort].active { outline: 2px solid var(--text-main); }
}
@media (max-width: 900px) {
  /* v562: قايمة العملاء جوه الخانة الزرقا بعرض الصندوق كله (مش عرض خانة الكتابة بس) */
  .cust-box { position: relative; }
  .cust-box > div > .cp-wrap, .cust-box .cp-wrap { position: static; }
  .cust-box .cp-list { left: 0 !important; right: 0 !important; width: auto !important; }
  .cp-item-side { max-width: 100%; }
}

/* v568: رقم حركة القبض/الصرف */
.zoom-txno { display:inline-block; font-size:11.5px; font-weight:800; padding:1px 7px; border-radius:6px; background:var(--subtle-bg); border:1px solid var(--border-color); color:var(--text-main); margin-inline-end:6px; white-space:nowrap; }

/* v569: أيقونات السطر (تعديل/حذف) في قوايم المستندات - رمادي هادي، التعديل أزرق في الصف المختار، والحذف أحمر لما تقف عليه بس */
.zrow-ico { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid var(--border-color); background: transparent; color: var(--text-muted); cursor: pointer; text-decoration: none; flex: 0 0 auto; font-family: inherit; }
.zrow-ico:hover { background: var(--hover-bg); color: var(--text-main); }
.zrow-ico.zrow-edit:hover { color: #2563eb; border-color: #2563eb; }
.zrow-ico.zrow-del:hover { color: #dc2626; border-color: #dc2626; background: rgba(220, 38, 38, .08); }
tr.dl-sel .zrow-ico.zrow-edit, tr.si-sel .zrow-ico.zrow-edit { color: #2563eb; border-color: #2563eb; background: #fff; }
[data-theme="dark"] tr.dl-sel .zrow-ico.zrow-edit, [data-theme="dark"] tr.si-sel .zrow-ico.zrow-edit { color: #93c5fd; border-color: #60a5fa; background: transparent; }
tr.dl-sel .zrow-ico.zrow-del, tr.si-sel .zrow-ico.zrow-del { color: #0c447c; border-color: rgba(12, 68, 124, .3); }
[data-theme="dark"] tr.dl-sel .zrow-ico.zrow-del, [data-theme="dark"] tr.si-sel .zrow-ico.zrow-del { color: #dbeafe; border-color: rgba(219, 234, 254, .3); }
@media (max-width: 900px) { .zrow-ico { width: 38px; height: 36px; } }

/* v569: شريط الإجماليات تحت الجداول بيلف سطرين بدل ما يبقاله سكرول لوحده
   (كان بيطلع شريط سكرول تاني تحت سكرول الجدول، وبيظهر ويختفي مع الزوم) */
#products-totals-bar, #sales-inv-totals-bar, .totals-bar, #pe-totals-bar { flex-wrap: wrap !important; overflow: visible !important; row-gap: 4px; }
#products-totals-text, #sales-inv-totals-text, .totals-bar .totals-text { flex-wrap: wrap !important; row-gap: 4px; }
/* v569: سكرول الجداول رفيع ومتظبط (شكل البرامج الاحترافية) - ظاهر دايمًا ومش بيغطي على حاجة */
.table-scroll-wrap { scrollbar-width: thin; scrollbar-color: #b6c2d2 transparent; }
.table-scroll-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll-wrap::-webkit-scrollbar-track { background: transparent; border-radius: 999px; }
.table-scroll-wrap::-webkit-scrollbar-thumb { background: #c3cdd9; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.table-scroll-wrap::-webkit-scrollbar-thumb:hover { background: #8a9bb3; background-clip: padding-box; }
.table-scroll-wrap::-webkit-scrollbar-corner { background: transparent; }
[data-theme="dark"] .table-scroll-wrap { scrollbar-color: #3b4a72 transparent; }
[data-theme="dark"] .table-scroll-wrap::-webkit-scrollbar-thumb { background: #3b4a72; background-clip: padding-box; }
[data-theme="dark"] .table-scroll-wrap::-webkit-scrollbar-thumb:hover { background: #5a6c9e; background-clip: padding-box; }
#products-totals-text, #sales-inv-totals-text, .totals-bar .totals-text { flex: 1 1 260px !important; min-width: 0; }
.zrow-ico.zrow-price:hover { color: #16a34a; border-color: #16a34a; } /* v570 */
/* v572: الصف المختار وإنت واقف عليه = نفس الأزرق الفاتح بدرجة أغمق شوية على كل الخانات (حتى عمود الأزرار) */
table.dl-list tbody tr.dl-sel[data-id]:hover td, #sales-inv-table tbody tr.si-sel:hover td { background: #cfe1fb !important; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel[data-id]:hover td, [data-theme="dark"] #sales-inv-table tbody tr.si-sel:hover td { background: #1c3b6b !important; }

/* v574: الصنف المختار في جدول المنتجات - نفس شكل الصف المختار في الفواتير السابقة */
#products-table tbody tr.p-sel td, #products-table tbody tr.p-sel:hover td { background: #dbeafe !important; color: #0c447c; box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316; }
#products-table tbody tr.p-sel td:first-child { box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316, inset -2px 0 0 #f97316; border-start-start-radius: 8px; border-end-start-radius: 8px; }
#products-table tbody tr.p-sel td:last-child { box-shadow: inset 0 2px 0 #f97316, inset 0 -2px 0 #f97316, inset 2px 0 0 #f97316; border-start-end-radius: 8px; border-end-end-radius: 8px; }
[data-theme="dark"] #products-table tbody tr.p-sel td, [data-theme="dark"] #products-table tbody tr.p-sel:hover td { background: #17325c !important; color: #dbeafe; }
#products-table tbody tr[data-pid] { cursor: pointer; }

/* v575: طرف الإطار البرتقاني عند عمود الأزرار الثابت مدوّر ونضيف (الخلية بلون الكارت والصف المختار مرسوم جواها) - كل القوايم والمنتجات */
table.dl-list tbody tr.dl-sel td.sticky-col, #sales-inv-table tbody tr.si-sel td.sticky-col, #products-table tbody tr.p-sel td.sticky-col { background: var(--card-bg) !important; box-shadow: none !important; border-radius: 0 !important; }
table.dl-list tbody tr.dl-sel td.sticky-col::before, #sales-inv-table tbody tr.si-sel td.sticky-col::before, #products-table tbody tr.p-sel td.sticky-col::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: #dbeafe; border: 2px solid #f97316; border-inline-start: 0; border-start-end-radius: 8px; border-end-end-radius: 8px;
}
table.dl-list tbody tr.dl-sel:hover td.sticky-col::before, #sales-inv-table tbody tr.si-sel:hover td.sticky-col::before { background: #cfe1fb; }
[data-theme="dark"] table.dl-list tbody tr.dl-sel td.sticky-col::before, [data-theme="dark"] #sales-inv-table tbody tr.si-sel td.sticky-col::before, [data-theme="dark"] #products-table tbody tr.p-sel td.sticky-col::before { background: #17325c; border-color: #fb923c; }
table.dl-list tbody tr.dl-sel td.sticky-col > *, #sales-inv-table tbody tr.si-sel td.sticky-col > *, #products-table tbody tr.p-sel td.sticky-col > * { position: relative; z-index: 1; }
.zrow-ico.zrow-copy:hover { color: #7c3aed; border-color: #7c3aed; }
#products-table tbody tr.p-sel .zrow-ico.zrow-edit { color: #2563eb; border-color: #2563eb; background: #fff; }
