/* ================= SmartInvoice — العالم التحريري (Editorial) ================= */
:root {
  --paper: #FAF8F3;
  --surface: #FFFFFF;
  --surface-2: #F3F0E9;
  --ink: #211D18;
  --muted: #6E675C;
  --faint: #A29A8B;
  --line: #E4DFD4;
  --line-strong: #D5CEC0;
  --accent: #146B4F;
  --accent-soft: #E6EFEA;
  --accent-ink: #FFFFFF;
  --e: cubic-bezier(.16,1,.3,1);
  --display: "Tajawal", "Noto Sans Arabic", sans-serif;
  --body: "Noto Sans Arabic", "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  --paper: #16140F;
  --surface: #1D1A14;
  --surface-2: #23201A;
  --ink: #F0EBE0;
  --muted: #A69E90;
  --faint: #726B5D;
  --line: rgba(240,235,224,.10);
  --line-strong: rgba(240,235,224,.16);
  --accent: #35B085;
  --accent-soft: rgba(53,176,133,.12);
  --accent-ink: #16140F;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .35s var(--e), color .35s var(--e);
}
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@keyframes ed-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ============ صفحة الدخول (تحريرية — بلا زجاج ولا mesh) ============ */
.si-login-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--paper);
}
.si-login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 52px 44px;
  max-width: 440px; width: 100%;
  animation: ed-in .7s var(--e) both;
}
.si-login-logo {
  width: 60px; height: 60px; border-radius: 14px; margin: 0 0 26px;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
:root[data-theme="dark"] .si-login-logo { background: var(--accent); color: var(--accent-ink); }

/* ============ رأس الصفحة التحريري ============ */
.ed-head { animation: ed-in .6s var(--e) both; margin-bottom: 28px; }
.ed-kicker { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .02em; color: var(--accent); margin-bottom: 12px; }
.ed-h1 { font-family: var(--display); font-weight: 900; font-size: clamp(34px, 5.5vw, 62px); line-height: 1.02; letter-spacing: -.02em; margin: 0; }
.ed-lead { color: var(--muted); font-size: clamp(15px, 1.6vw, 18px); margin-top: 14px; max-width: 60ch; }
.ed-rule { border: none; border-top: 1px solid var(--line); margin: 0 0 34px; }

/* ============ شريط الأرقام (تحريري — خطوط شعرية لا بطاقات) ============ */
.ed-figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  background: var(--surface); margin-bottom: 48px;
  animation: ed-in .6s .05s var(--e) both;
}
.ed-fig { padding: 26px 28px; border-inline-start: 1px solid var(--line); }
.ed-fig:first-child { border-inline-start: none; }
.ed-fig-label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.ed-fig-num { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 3.6vw, 46px); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ed-fig-num.accent { color: var(--accent); }
@media (max-width: 520px) {
  .ed-fig { border-inline-start: none; border-top: 1px solid var(--line); }
  .ed-fig:first-child { border-top: none; }
}

/* ============ عناوين الأقسام ============ */
.ed-h2 { font-family: var(--display); font-weight: 800; font-size: clamp(21px, 2.4vw, 28px); letter-spacing: -.01em; margin: 0 0 20px; }

/* ============ الإجراءات (قائمة تحريرية لا بطاقات) ============ */
.ed-actions {
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface);
}
.ed-action {
  display: flex; align-items: center; gap: 18px; padding: 22px 26px;
  border-top: 1px solid var(--line); text-decoration: none; color: var(--ink);
  transition: background .25s var(--e);
}
.ed-action:first-child { border-top: none; }
.ed-action:hover { background: var(--surface-2); }
.ed-action .ed-ic { color: var(--accent); display: flex; flex: none; transition: transform .25s var(--e); }
.ed-action:hover .ed-ic { transform: translateX(-4px); }
.ed-action-body { flex: 1; transition: transform .25s var(--e); }
.ed-action:hover .ed-action-body { transform: translateX(-4px); }
.ed-action-title { font-family: var(--display); font-weight: 700; font-size: 17px; }
.ed-action-desc { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.ed-action .ed-arrow { color: var(--faint); transition: transform .25s var(--e), color .25s; }
.ed-action:hover .ed-arrow { color: var(--accent); transform: translateX(-6px); }

/* ============ تجاوزات MudBlazor — تحريرية ============ */
.mud-appbar { border-bottom: 1px solid var(--line); box-shadow: none !important; }
.mud-appbar.mud-elevation-1 { box-shadow: none !important; }
.mud-drawer { border-inline-start: 1px solid var(--line); box-shadow: none !important; }
.mud-card { border: 1px solid var(--line); border-radius: 16px !important; box-shadow: none !important; }
.mud-paper-outlined { border-color: var(--line) !important; }
.mud-table { border: 1px solid var(--line); border-radius: 14px; box-shadow: none !important; }
.mud-table-head th { font-family: var(--display); font-weight: 700; color: var(--muted); background: var(--surface-2); }
.mud-table-row:hover { background: var(--surface-2) !important; }
.mud-button-root { border-radius: 12px; font-family: var(--display); font-weight: 700; }
.mud-button-filled { box-shadow: none !important; }
.mud-nav-link { border-radius: 10px; margin: 2px 12px; transition: background .2s var(--e), color .2s; font-weight: 500; }
.mud-nav-link:hover { background: var(--surface-2); }
.mud-nav-link.active { background: var(--accent-soft); color: var(--accent) !important; font-weight: 700; }

/* ترويسة الدرج */
.si-drawer-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 16px; }
.si-drawer-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
:root[data-theme="dark"] .si-drawer-logo { background: var(--accent); color: var(--accent-ink); }

/* رأس الحوار: زر الإغلاق يميناً والعنوان في المنتصف.
   MudBlazor يضع الزر يميناً ويحاذي العنوان يميناً أيضاً فيركب أحدهما الآخر،
   وصنفه التصحيحي mud-dialog-rtl لا يُضاف لحوارات الصفحات المعرَّفة بـ
   @bind-Visible. التوسيط يحلّ التصادم ويبقى متوازناً: فراغ متساوٍ على
   الطرفين فلا ينزاح العنوان عن مركزه بسبب الزر. */
.mud-dialog .mud-dialog-title .mud-button-close {
  left: unset;
  right: 8px;
}
.mud-dialog .mud-dialog-title:has(.mud-button-close) {
  text-align: center;
  padding-inline-start: 64px;
  padding-inline-end: 64px;
}

/* ترتيب القائمة الجانبية */
.si-nav-tools { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0 12px 4px; }
.si-nav-sort-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin: 3px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 14px; cursor: grab; user-select: none;
}
.si-nav-sort-item:active { cursor: grabbing; }
.mud-drop-item-preview { opacity: .5; }

/* جدول جرد المرشنديزر — شبكة أكسل واضحة: أعمدة ثابتة العرض ومحاذاة موحّدة
   لكل عمود (الأرقام في المنتصف، الصنف يتصدّر) بدل عرض متغيّر حسب طول النص */
.si-merch-grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.si-merch-grid th, .si-merch-grid td {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  text-align: center; font-variant-numeric: tabular-nums;
}
.si-merch-grid thead th { font-weight: 700; color: var(--muted); background: var(--surface-2); }
.si-merch-grid tbody tr:hover { background: var(--surface-2); }

/* شريط التمرير */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 3px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

/* أدوات مساعدة موروثة */
.si-page-title { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.si-page-title h5, .si-page-title .mud-typo-h5 { margin: 0; }
.gap-2 { gap: 8px; }
.max-width-600px { max-width: 600px; }
.fill-height { height: 100%; }
.si-signature { font-size: 11px; color: var(--muted); text-align: center; margin-top: 16px; font-weight: 500; }
.si-signature strong { color: var(--accent); }
.mud-selected { background-color: var(--accent-soft) !important; }
.si-priced-row { background-color: var(--accent-soft) !important; }
.si-priced-row:hover { background-color: var(--accent-soft) !important; filter: brightness(.97); }

/* ============================================================
   الجوال — طبقة تجاوب واحدة تخدم كل الصفحات
   المشكلة كانت: الجداول تفيض أفقياً، أشرطة الأدوات لا تلتف،
   الحوارات أعرض من الشاشة، والحقول أصغر من هدف لمس مريح.
   ============================================================ */

/* لا تمرير أفقي للصفحة كلها مهما فاض جدول بداخلها */
html, body { max-width: 100%; overflow-x: hidden; }

/* تبويبات المرشنديزر: MudBlazor يفرض min-width:160px لكل تبويب بشكل inline،
   فثلاثة تبويبات = 480px، أعرض من أي شاشة جوال — يظهر تمرير أفقي بسهمين
   "<" ">" بدل عرضها كاملة دفعة واحدة. نُلغي الحد الأدنى ونوزّعها بالتساوي. */
.si-merch-tabs .mud-tabs-scroll-button { display: none !important; }
.si-merch-tabs .mud-tabs-tabbar-wrapper { display: flex; width: 100%; }
.si-merch-tabs .mud-tooltip-root.mud-tooltip-inline { flex: 1 1 0; min-width: 0; }
.si-merch-tabs .mud-tab {
  min-width: 0 !important;
  width: 100%;
  padding-inline: 6px !important;
}
@media (max-width: 480px) {
  .si-merch-tabs .mud-tab { font-size: 0.7rem; padding-inline: 2px !important; }
}

@media (max-width: 960px) {
  /* عناصر شريط علوي ثانوية تُخفى لتترك مساحة للمنطقة والحساب */
  .si-hide-mobile { display: none !important; }

  /* الجداول: تمرير أفقي داخل حدود البطاقة لا خارج الشاشة */
  .mud-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mud-table { border-radius: 12px; }
  /* الجداول التي لم تتحوّل لبطاقات تبقى تمرّر أفقياً */
  .mud-table:not(.si-cards) .mud-table-cell,
  .mud-table-head th { white-space: nowrap; padding: 8px 10px !important; }

  /* الشريط العلوي يبقى سطراً واحداً: هو أيضاً mud-toolbar، والالتفاف كان
     يحوّله إلى عمود يبتلع نصف الشاشة قبل أن يبدأ المحتوى */
  .mud-appbar .mud-toolbar {
    flex-wrap: nowrap !important;
    height: 56px !important;
    padding: 0 8px !important;
    gap: 0 !important;
  }
  .mud-appbar .mud-toolbar > * { flex: none !important; min-width: 0 !important; }

  /* ترتيب أولويات الشريط على الجوال: بلا التفاف، مجموع الأزرار يتجاوز عرض
     الشاشة فتُقصّ العناصر الأخيرة — ورمز الحساب آخرها، فيختفي تماماً.
     العلاج بثلاث خطوات: الحساب لا يتقلّص أبداً، وشارة المنطقة تتقلّص
     ضمن سقف عرض، والاسم التجاري يختفي تحت 600px (الدرج يحمله أصلاً). */
  .mud-appbar .mud-toolbar > .si-appbar-account { flex: none !important; }
  .mud-appbar .mud-toolbar > .si-region-pill {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: 34vw;
    overflow: hidden;
  }
  .si-region-pill .mud-button-root { min-width: 0; max-width: 100%; overflow: hidden; }
  .si-region-pill .mud-chip-content { overflow: hidden; white-space: nowrap; }

  /* أشرطة أدوات الصفحات تلتف بدل أن تتلاصق أو تُقصّ */
  .mud-main-content .mud-toolbar {
    height: auto !important; min-height: 0 !important;
    flex-wrap: wrap; gap: 8px; padding: 4px 0 !important;
  }
  .mud-main-content .mud-toolbar > * { margin-inline: 0 !important; }
  .mud-main-content .mud-toolbar .mud-button-root { flex: 1 1 auto; min-width: 44%; }
  /* حقل البحث في الشريط يأخذ سطراً كاملاً */
  .mud-main-content .mud-toolbar .mud-input-control { flex: 1 1 100%; max-width: 100% !important; }
  .mud-main-content .mud-spacer { display: none; }

  /* الحوارات لا تتجاوز الشاشة */
  .mud-dialog { max-width: calc(100vw - 24px) !important; margin: 12px !important; }
  .mud-dialog-content { max-height: 70vh; overflow-y: auto; }
  .mud-dialog-actions { flex-wrap: wrap; gap: 8px; }

  /* عنوان الصفحة يلتف بدل قصّ الشارة */
  .si-page-title { flex-wrap: wrap; row-gap: 6px; }

  /* هوامش أهدأ: المحتوى أهم من الفراغ على شاشة صغيرة */
  .mud-main-content .mud-container { padding-inline: 12px !important; }
  .mud-card .mud-card-content.pa-5 { padding: 16px !important; }

  /* أهداف لمس: 16px يمنع تكبير iOS التلقائي عند التركيز */
  .mud-input-root, .mud-input-slot input { font-size: 16px !important; }
  .mud-icon-button { padding: 8px; }

  /* رأس تحريري أصغر — 62px عنوان يبتلع نصف الشاشة */
  .ed-h1 { font-size: clamp(28px, 8vw, 38px); }
}

/* شاشة ضيقة جداً: الاسم التجاري يُخلي مكانه لاسم المنطقة وأزرار الشريط.
   الاسم موجود في ترويسة الدرج، فلا يضيع من الواجهة. */
@media (max-width: 600px) {
  .si-appbar-title { display: none !important; }
  .mud-appbar .mud-toolbar > .si-region-pill { max-width: 30vw; }

  /* الفراغ الذي أخلاه الاسم التجاري يذهب لأهداف اللمس لا للهواء:
     أيقونة 28px داخل مربع 48px — الحد الموصى به للمس، وكانت 24 داخل 36.
     شارة المنطقة وحدها هي التي تتقلّص عند الضيق، فالحساب يبقى ظاهراً. */
  .mud-appbar .mud-icon-button { padding: 10px; }
  .mud-appbar .mud-icon-button .mud-icon-root { font-size: 1.75rem; }

  /* الشارات كانت أصغر من أن تُقرأ بطرف العين: اسم المنطقة وعدّاد المتصلين */
  .mud-appbar .mud-chip { height: 32px; font-size: .85rem; }
  .mud-appbar .mud-chip .mud-icon-root { font-size: 1.2rem; }
  .mud-appbar .si-region-pill .mud-button-root { font-size: .85rem; }
  .mud-appbar .si-region-pill .mud-icon-root { font-size: 1.2rem; }

  /* الفاصل يستعيد تمدّده: بلا هذا تتكدّس الأيقونات في جهة ويبقى نصف
     الشريط حفرة فارغة، لأن قاعدة flex:none أعلاه تبتلع تمدّده أيضاً. */
  .mud-appbar .mud-toolbar > .mud-spacer { flex: 1 1 auto !important; }
}

/* سطر الفرق تحت كمية الصنف — «▲ +13000» أو «● جديد».
   صغير ومحاذٍ للرقم كي لا يزاحمه، وواضح بما يكفي ليُلتقط بطرف العين:
   كمية ضخمة تنزل لصنف واحد كانت تمرّ بلا انتباه لأن المخزون لم ينفد. */
.si-qty-delta {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
}
@media (max-width: 960px) {
  /* في بطاقة الجوال يلتصق الفرق بالرقم مباشرة */
  .si-cards .si-qty-delta { font-size: 12.5px; margin-top: 3px; }
}

/* ============================================================
   بطاقات الصنف على الجوال
   جدول بسبعة أعمدة لا يُصلَح بالتمرير الأفقي — يُستبدل. تحت 960px
   يصفّ MudBlazor الخلايا عمودياً (mud-sm-table) ويطبع اسم العمود في
   ::before، وهنا نحوّل الصف نفسه إلى شبكة عمودين: الاسم يتصدّر،
   والأرقام تتجاور في سطر واحد بدل سبعة أسطر label/value.
   ============================================================ */
@media (max-width: 959.98px) {
  .si-cards .mud-table-body { border-top: none; }

  .si-cards .mud-table-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    column-gap: 12px;
    padding: 12px 14px;
    margin: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }
  /* الخطوط الفاصلة بين الخلايا تُلغى — حدّ البطاقة يحمل الفصل وحده */
  .si-cards .mud-table-row .mud-table-cell,
  .si-cards .mud-table-row .mud-table-cell:last-child {
    grid-column: 1 / -1;
    border: none;
    padding: 4px 0 !important;
    min-height: 0;
  }
  .si-cards .mud-table-cell:before {
    color: var(--muted); font-size: 12.5px; font-weight: 500;
    padding: 0 !important;
  }
  /* التخطيط المخطط (Striped) يفقد معناه حين يصير كل صف بطاقة مستقلة —
     الحدّ يفصل، والتلوين المتناوب يوهم بأن نصف الأصناف مميّز */
  .si-cards .mud-table-row,
  .si-cards .mud-table-row:hover { background: var(--surface) !important; }

  /* خلية فيها حقل إدخال: التسمية فوقه لا بجانبه — بجانبه ينضغط
     «الاسم المعدل» إلى سطرين ويبقى للحقل أقلّ من نصف العرض */
  .si-cards .mud-table-cell:has(.mud-input-control) { display: block; }
  .si-cards .mud-table-cell:has(.mud-input-control):before {
    display: block; margin-bottom: 4px;
  }
  .si-cards .mud-table-cell:has(.mud-input-control) .mud-input-control { width: 100%; }

  /* خلية اسم الصنف في جرد المرشنديزر: تحمل أزرار "+" و"حذف" بجانب الاسم —
     بلا هذا كانت تسمية العمود (::before) تتراكب فوق الأزرار لأنها البقية
     الوحيدة التي لم تُحوَّل صراحة لعرض block مثل خلايا حقول الإدخال. */
  .si-cards .mud-table-row .si-item-cell { display: block; }
  .si-cards .mud-table-row .si-item-cell:before { display: block; margin-bottom: 4px; }

  /* البطاقة لا تُعشَّش داخل بطاقة: الحاوية تذوب والبطاقات تطفو على الورق */
  .mud-card:has(.si-cards) {
    border: none !important; background: transparent !important;
  }
  .si-cards.mud-table { border: none; background: transparent; }

  /* ترتيب القراءة داخل البطاقة يُفرض هنا لا بترتيب أعمدة الجدول:
     الاسم أولاً لأنه ما يبحث عنه المستخدم، ثم الأرقام، ثم الإجراء. */
  /* القاعدة العامة أولاً، ثم المسمّاة بخصوصية أعلى — بالتساوي كانت
     العامة (الأخيرة) تفوز فيسقط الترتيب كله */
  .si-cards .mud-table-cell { order: 6; }
  .si-cards .mud-table-row .si-c-img   { order: 0; }
  .si-cards .mud-table-row .si-c-name  { order: 1; }
  .si-cards .mud-table-row .si-c-code  { order: 2; }
  .si-cards .mud-table-row .si-c-qty   { order: 3; }
  .si-cards .mud-table-row .si-c-price { order: 4; }
  .si-cards .mud-table-row .si-c-act,
  .si-cards .mud-table-row .si-c-add,
  .si-cards .mud-table-row .si-c-del,
  .si-cards .mud-table-row .si-c-total { order: 9; }

  /* الاسم هو مرساة البطاقة: بلا تسمية، وبثقل يفصله عمّا تحته */
  .si-cards .mud-table-row .si-c-name {
    display: block;
    font-family: var(--display); font-weight: 700;
    font-size: 17px; line-height: 1.35; color: var(--ink);
    padding: 0 0 8px 0 !important;
  }
  .si-cards .si-c-name:before { content: none; }

  /* أرقام متجاورة في سطر واحد بدل سطرين */
  .si-cards .mud-table-row .si-c-code,
  .si-cards .mud-table-row .si-c-qty,
  .si-cards .mud-table-row .si-c-price { grid-column: auto; }
  .si-cards .si-c-code { font-family: ui-monospace, monospace; font-size: 12.5px; }
  .si-cards .si-c-qty, .si-cards .si-c-price { font-variant-numeric: tabular-nums; }

  /* الصورة تُصغَّر: مرجع بصري لا بطل البطاقة */
  .si-cards .si-c-img { justify-content: flex-start; }
  .si-cards .si-c-img:before { content: none; }

  /* الإجراءات في أسفل البطاقة — أقرب مكان للإبهام */
  .si-cards .si-c-act, .si-cards .si-c-del {
    padding-top: 8px !important;
    border-top: 1px solid var(--line) !important;
    margin-top: 4px;
  }
  .si-cards .si-c-del { justify-content: flex-end; }
  .si-cards .si-c-del:before { content: none; }
  .si-cards .mud-icon-button { min-width: 44px; min-height: 44px; }

  /* الحقول داخل البطاقة تأخذ عرضها الطبيعي لا عرضاً ثابتاً بالبكسل */
  .si-cards .mud-input-control { width: auto; min-width: 120px; }
  .si-cards .si-nav-alias { min-width: 0 !important; width: 100% !important; }

  /* ── اختيار الأصناف في الفاتورة ──
     المخزون والسعر في سطر، ثم الكمية وزر الإضافة في سطر الإجراء */
  .si-cards-pick .si-c-qty, .si-cards-pick .si-c-price { grid-column: auto; }
  .si-cards-pick .si-c-act { grid-column: 1; }
  .si-cards-pick .si-c-add {
    grid-column: 2;
    justify-content: flex-end;
    padding-top: 8px !important;
    border-top: 1px solid var(--line) !important;
    margin-top: 4px;
  }
  .si-cards-pick .si-c-add:before { content: none; }
  /* الإضافة هي الفعل الوحيد المقصود من هذه البطاقة — أيقونة 24px هدف لمس
     ضعيف، فتتحول إلى شريط بعرض العمود بارتفاع إبهام مريح */
  .si-cards-pick .si-c-add .mud-icon-button {
    width: 100%; height: 44px; border-radius: 12px;
    background: var(--accent) !important; color: var(--accent-ink) !important;
  }
  .si-cards-pick .si-c-add .mud-icon-button:active { filter: brightness(.92); }
  .si-cards-pick .si-qty-cell { width: 100% !important; min-width: 0 !important; }
  /* صنف له سعر عند هذا العميل: البطاقة كلها تتلوّن فيُرى الفرق فوراً */
  .si-cards .si-priced-row { border-color: var(--accent); }

  /* ── بنود الفاتورة ──
     الترقيم يسقط: ترتيب البطاقات نفسه يحمل المعلومة على شاشة ضيقة */
  .si-cards-line .si-c-num { display: none; }
  /* الكمية/المجاني/السعر: حقلان في السطر بدل ثلاثة أسطر */
  .si-cards-line .mud-table-cell { grid-column: auto; }
  .si-cards-line .si-c-name { grid-column: 1 / -1; }
  .si-cards-line .mud-table-cell:before { display: block; margin-bottom: 2px; }
  .si-cards-line .mud-table-cell { display: block; }
  .si-cards-line .mud-input-control { min-width: 0; width: 100%; }
  .si-cards-line .mud-input-control input { width: 100% !important; }
  .si-cards-line .si-c-total { display: flex; }
  .si-cards-line .si-c-total {
    grid-column: 1 / -1;
    font-weight: 800; font-size: 15px;
    border-top: 1px solid var(--line) !important;
    padding-top: 8px !important; margin-top: 4px;
  }
}

/* حقول الكمية/السعر ذات العرض الثابت (style مضمّن) تتقلص على الجوال */
@media (max-width: 600px) {
  .si-nav-qty, .si-nav-price, .si-qty-cell { width: 76px !important; min-width: 76px !important; }
  /* الاسم المعدل مفروض عليه min-width:260px مضمّناً — يفيض على شاشة 360px */
  .si-nav-alias { min-width: 150px !important; width: 150px !important; }
  .mud-table-cell .mud-input-control { min-width: 0 !important; }
  .mud-toolbar .mud-button-root { min-width: 100%; }
}

/* ===== جرس الإشعارات في الشريط العلوي =====
   لا فئة للمُفعِّل: MudBadge يلفّ MudMenu فيرسم الأخير زر الأيقونة بنفسه.
   (ActivatorContent لا يفتح القائمة إطلاقاً في هذه النسخة — مُختبَر.)

   القائمة تُضبط مرة واحدة، فتبقى ضيّقة ولا تلتهم شاشة الجوال كالبطاقة السابقة */
.si-bell-menu {
  padding: 12px 14px;
  min-width: 250px;
  max-width: 300px;
}
.si-bell-menu .mud-checkbox { margin-inline-start: -6px; }

/* ===== شريط السلة الثابت (الجوال فقط) =====
   على الحاسوب البنود ظاهرة في العمود المجاور، فلا داعي للشريط إطلاقاً.
   md في MudBlazor = 960px، فنُظهره تحتها فقط. */
.si-cart-bar { display: none; }
.si-cart-bar-spacer { display: none; }

@media (max-width: 959.98px) {
  .si-cart-bar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 12px;
    /* env(safe-area-inset-bottom): شريط الإيماءات السفلي في أندرويد/iOS يغطّي
       آخر 15-30px من الشاشة، فبلا هذا يُقصّ الزر والإجمالي على الأجهزة الحديثة */
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--mud-palette-surface, #fff);
    border-top: 1px solid var(--mud-palette-lines-default, rgba(0,0,0,.12));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
  }
  /* يمنع الشريط من تغطية آخر صف في الصفحة */
  .si-cart-bar-spacer { display: block; height: calc(68px + env(safe-area-inset-bottom, 0px)); }
}

.si-cart-bar-info { display: flex; align-items: center; gap: 6px; }
.si-cart-bar-count { font-weight: 800; font-size: 1.05rem; }
.si-cart-bar-label { opacity: .7; font-size: .85rem; }
.si-cart-bar-total {
  flex: 1;
  text-align: center;
  font-weight: 800;
  color: #10B981;
  font-size: 1.05rem;
  white-space: nowrap;
}

/* لا تُضِف scroll-behavior:smooth هنا. حاوية التمرير في هذا التخطيط هي <body>،
   وأي مسار نعومة عليها في كروم لا يفعل شيئاً بصمت — قيس تجريبياً: الإسناد
   المباشر لـ scrollTop يحرّك 300px بـ auto و**صفر** بـ smooth. القفز الفوري
   هو السلوك العامل، وهو مقبول تماماً على الجوال. */

/* مربّع اختيار الصف في وضع البطاقات: بلا هذا يسقط في وسط البطاقة (order العام 6)
   فيبدو تائهاً بين البيانات. مكانه الطبيعي أعلى البطاقة قبل اسم العميل. */
@media (max-width: 959.98px) {
  .si-cards .mud-table-row .mud-table-cell-checkbox { order: -1; grid-column: 1 / -1; }
  .si-cards .mud-table-row .mud-table-cell-checkbox:before { content: none; }
}


/* ================= صفحة الدخول — إيصال حبري بحافة مسنّنة (2026-10) ================= */
:root { --danger: #A3372A; --tooth: 14px; }
:root[data-theme="dark"] { --danger: #E58370; }

.lg { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 44%) 1fr; background: var(--paper); }
.lg-slip {
  position: relative; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 56px 64px;
  animation: lg-print .9s var(--e) both;
}
/* الحافة المسنّنة: مثلثات هندسية على الحافة الحرّة كإيصال مقطوع من الطابعة */
.lg-slip::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-end: calc(var(--tooth) * -1 + 1px);
  width: var(--tooth);
  background: conic-gradient(from 56.3deg at 0 50%, var(--ink) 0 67.4deg, transparent 0) 0 0 / var(--tooth) calc(var(--tooth) * 1.34) repeat-y;
}
:root[dir="ltr"] .lg-slip::after, [dir="ltr"] .lg-slip::after { transform: scaleX(-1); }
.lg-slip-in { width: 100%; max-width: 380px; }
.lg-mark { display: block; color: var(--paper); margin-bottom: 30px; }
.lg-word {
  font-family: var(--display); font-weight: 900; font-size: clamp(40px, 4.6vw, 64px);
  line-height: 1; letter-spacing: -.03em; direction: ltr; text-align: right;
}
.lg-lines { list-style: none; margin: 44px 0 0; padding: 0; font-size: 15px; }
.lg-lines li { display: flex; align-items: baseline; gap: 10px; padding: 11px 0; }
.lg-lines li span:first-child { font-family: var(--display); font-weight: 700; }
.lg-lines li span:last-child { opacity: .62; font-size: 13.5px; }
/* خط النقاط الموجِّه كسطر في إيصال */
.lg-lines i { flex: 1; border-bottom: 1.5px dotted color-mix(in srgb, var(--paper) 34%, transparent); transform: translateY(-4px); }
.lg-sign { margin-top: 48px; font-size: 12px; letter-spacing: .04em; opacity: .5; direction: ltr; text-align: right; }

.lg-form { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.lg-form-in { width: 100%; max-width: 400px; animation: ed-in .7s .25s var(--e) both; }
.lg-h1 { font-family: var(--display); font-weight: 900; font-size: 40px; line-height: 1.05; letter-spacing: -.02em; margin: 0; color: var(--ink); }
.lg-lead { color: var(--muted); margin: 10px 0 34px; font-size: 15px; }
.lg-form .mud-button-filled-primary { height: 52px; border-radius: 12px; font-family: var(--display); font-weight: 700; font-size: 16px; }

@keyframes lg-print { from { clip-path: inset(0 -40px 100% -40px); } to { clip-path: inset(0 -40px -40px -40px); } }

/* جوال: الإيصال شريط علوي، والأسنان على حافته السفلى */
@media (max-width: 820px) {
  .lg { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .lg-slip { padding: 34px 24px 30px; justify-content: flex-start; }
  .lg-slip::after {
    inset-inline: 0; inset-block-start: auto; inset-block-end: calc(var(--tooth) * -1 + 1px);
    width: auto; height: var(--tooth); transform: none;
    background: conic-gradient(from -33.7deg at 50% 100%, var(--ink) 0 67.4deg, transparent 0) 0 0 / calc(var(--tooth) * 1.34) var(--tooth) repeat-x;
  }
  .lg-slip-in { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; max-width: none; }
  .lg-mark { width: 28px; height: 34px; margin: 0; }
  .lg-word { font-size: 30px; }
  .lg-lines { display: none; }
  .lg-sign { margin: 0; flex-basis: 100%; }
  .lg-form { align-items: flex-start; padding: 40px 20px 32px; }
  .lg-h1 { font-size: 32px; }
}

/* ================= لوحة البداية — كشف الصباح: الانتباه أولاً ثم الإجراء (2026-10) ================= */
.hm-head { margin: 4px 0 30px; animation: ed-in .5s var(--e) both; }
.hm-date { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.hm-h1 {
  font-family: var(--display); font-weight: 900; font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.12; letter-spacing: -.02em; margin: 0; max-width: 22ch; text-wrap: balance;
}
.hm-n { font-variant-numeric: tabular-nums; color: var(--ink); border-bottom: 4px solid var(--ink); }
.hm-n.out { color: var(--danger); border-color: var(--danger); }
.hm-skel { height: 54px; max-width: 520px; border-radius: 10px; background: var(--surface-2); animation: hm-pulse 1.2s ease-in-out infinite alternate; }
@keyframes hm-pulse { from { opacity: .55; } to { opacity: 1; } }

/* الإجراءات: ثلاثة أزرار متساوية، الأول حبري ممتلئ لأنه الأكثر تكراراً */
.hm-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 44px; animation: ed-in .5s .06s var(--e) both; }
.hm-act {
  display: flex; align-items: center; gap: 14px; padding: 20px 22px; min-height: 84px;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  color: var(--ink); text-decoration: none;
  transition: background .2s var(--e), border-color .2s var(--e), transform .2s var(--e);
}
.hm-act .mud-icon-root { color: var(--accent); font-size: 28px; flex: none; }
.hm-act span { display: flex; flex-direction: column; min-width: 0; }
.hm-act b { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.2; }
.hm-act small { color: var(--muted); font-size: 13px; margin-top: 3px; }
.hm-act:hover { border-color: var(--ink); background: var(--surface-2); }
.hm-act:active { transform: translateY(1px); }
.hm-act.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.hm-act.primary .mud-icon-root, .hm-act.primary small { color: color-mix(in srgb, var(--paper) 72%, transparent); }
.hm-act.primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--accent)); }

/* دفترا المخزون: نفد ومنخفض جنباً إلى جنب، أسطر بخطوط شعرية لا بطاقات */
.hm-ledgers { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; animation: ed-in .5s .12s var(--e) both; }
.hm-h2 {
  display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding-bottom: 12px;
  border-bottom: 2px solid var(--ink); font-family: var(--display); font-weight: 800; font-size: 20px;
}
.hm-h2 em { font-style: normal; margin-inline-start: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }
.hm-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.hm-dot.out { background: var(--danger); }
.hm-dot.low { background: transparent; border: 2px solid var(--ink); }
.hm-rows { list-style: none; margin: 0; padding: 0; }
.hm-rows li { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.hm-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-name small { display: block; color: var(--faint); font-weight: 400; font-size: 11.5px; direction: ltr; text-align: start; }
.hm-gauge { flex: none; width: 72px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.hm-gauge i { display: block; height: 100%; background: var(--ink); border-radius: 2px; }
.hm-qty { flex: none; min-width: 3ch; text-align: end; font-family: var(--display); font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.hm-qty.out { color: var(--danger); }
.hm-empty { color: var(--muted); padding: 16px 0; margin: 0; }
.hm-more { display: inline-block; margin-top: 12px; color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none; }
.hm-more:hover { text-decoration: underline; text-underline-offset: 4px; }

.hm-today { margin: 44px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.hm-today b { color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .hm-actions { grid-template-columns: 1fr; gap: 10px; margin-bottom: 34px; }
  .hm-act { min-height: 72px; padding: 16px 18px; }
  .hm-ledgers { grid-template-columns: 1fr; gap: 34px; }
}
