/* ============================================================
   RTL fix: numeric inputs always type/display left-to-right
   (prevents digits being reversed while typing in Arabic UI)
   ============================================================ */
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"] {
    direction: ltr;
}

/* ============================================================
   Auth / Login Screen
   ============================================================ */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-layout {
    width: 100%;
}

.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    max-width: 440px;
    margin: 0 auto;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.login-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo-circle {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, #3d5a80, #2c4a6e);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(61,90,128,0.3);
}

.login-title {
    font-size: 22px; font-weight: 800;
    color: var(--text-primary); margin-bottom: 4px;
}
.login-sub {
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 28px;
}
.login-form { text-align: right; }
[dir="ltr"] .login-form { text-align: left; }

.login-input {
    width: 100%; padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-input);
    font-size: 15px;
    font-family: 'Cairo', 'Segoe UI', Arial, sans-serif;
    direction: ltr; text-align: left;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.login-input:focus {
    outline: none;
    border-color: #3d5a80;
    box-shadow: 0 0 0 3px rgba(61,90,128,0.10);
}

.login-error {
    color: #e63946; text-align: center;
    font-size: 13px; margin: 8px 0; display: none;
}

.login-btn {
    width: 100%; padding: 14px;
    margin-top: 8px;
    background: #3d5a80; color: #fff;
    border: none; border-radius: 12px;
    font-size: 16px; font-weight: 700;
    font-family: 'Cairo', 'Segoe UI', Arial, sans-serif;
    cursor: pointer;
}
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.6; }

.login-footer {
    text-align: center; font-size: 11px;
    color: #999; margin-top: 20px; opacity: 0.6;
}

@media (min-width: 500px) {
    .login-card { padding: 40px 36px 32px; }
    .login-title { font-size: 24px; }
}
/* ============================================================
   CSS Variables
   ============================================================ */
:root {
    /* Primary Colors */
    --color-primary: #3d5a80;
    --color-primary-dark: #2c4a6e;
    --color-primary-light: #e8eef5;
    --color-secondary: #5c7a9e;
    --color-accent: #e09f3e;

    /* Status Colors */
    --color-success: #2a9d8f;
    --color-success-bg: #d4edda;
    --color-warning: #e09f3e;
    --color-warning-bg: #fff3cd;
    --color-danger: #e63946;
    --color-danger-bg: #f8d7da;
    --color-info: #457b9d;
    --color-info-bg: #cff4fc;

    /* Backgrounds */
    --bg-body: #f5f5f0;
    --bg-card: #ffffff;
    /* 🎨 نصوص الألواح القديمة (لوحة الموظفين): على سطح فاتح تبقى داكنة، وعلى سطح الطابع
       العام تُفتَّح في الداكن — متغيّرات بديلة عن قاعدة تفتيح عامة أفسدت عناوين البطاقات. */
    --on-light-brand: #4a148c;
    --on-light-brand-sub: #7b1fa2;
    --on-surface-brand: #4a148c;
    --on-surface-brand-sub: #7b1fa2;
    --bg-header: #3d5a80;
    /* ترويسة الديسكتوب بيضاء (مختلفة عن ترويسة الجوال الملوّنة) — صارت متغيّراً ليتبع الطابع الداكن */
    --bg-header-desktop: #ffffff;
    --bg-nav: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-input: #ffffff;
    --bg-hover: #f0f0eb;
    /* متغيّرات كانت مستعملة بقيَم احتياطية داخلية (var(--bg-muted, #f1f3f5) و var(--bg, #fafafa)) — صارت معرّفة */
    --bg-muted: #f1f3f5;
    --bg: #fafafa;
    --skeleton: #e9ecef;

    /* 🎨 لون الهوية **للنص والإطار** — يختلف عن لون الخلفية في الطابع الداكن
       (خلفية الزر تبقى `--color-primary` بخط أبيض، أما النص/الرابط فيحتاج درجة أفتح ليُقرأ) */
    --color-primary-text: #3d5a80;
    /* ألوان دلالية للنص فوق البطاقات — تُفتَّح في الطابع الداكن */
    --info-text: #1565c0;
    --danger-text: #c62828;
    --success-text: #2e7d32;
    --warn-text: #856404;
    /* سطح عام كانت تستخدمه شاشات بقيَم احتياطية (var(--color-surface, #fff)) */
    --color-surface: #ffffff;

    /* Text Colors */
    --text-primary: #2b2d42;
    --text-secondary: #374151;
    --text-muted: #4b5563;
    --text-inverse: #ffffff;
    --text-link: #3d5a80;
    --text-header: #ffffff;

    /* Borders */
    --border-color: #dee2e6;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: 'Changa', 'Cairo', 'Segoe UI', Arial, sans-serif;
    --font-size-xs: 14px;
    --font-size-sm: 15px;
    --font-size-md: 17px;
    --font-size-lg: 22px;
    --font-size-xl: 18px;
    --font-size-2xl: 24px;
    --font-size-3xl: 30px;

    /* Layout */
    --header-height: 56px;
    --nav-height: 64px;
    /* ارتفاع شريط تنبيه فترة السماح — يضبطه app.js عند ظهور الشريط لئلا يُقصّ أسفل شاشات الكاشير/الطاولات */
    --grace-banner-h: 0px;
    --sidebar-width: 260px;
    --app-max-width: 1024px;
    --transition: 0.2s ease;
}

/* ============================================================
   🎨 الطابع (Theme) — فاتح / داكن / تلقائي
   يُطبَّق بـ`<html data-theme="dark">` من `Utils.applyTheme` فقط
   (وليس على تطبيق شاشة القاعات /hs/ — له طابعه الخاص `hs_theme`)

   الفكرة: كل الأسطح تقريباً تُبنى من متغيّرات CSS أعلاه ⇒ إعادة تعريف
   المتغيّرات تكفي لطابع داكن كامل. وهذا أيضاً العِلاج العملي لمشكلة
   «يظهر القالب أسود» على بعض التابلتات: صار للصفحة `color-scheme` صريح
   (يُضبط من JS) فتتوقف المتصفحات عن قلب الألوان تلقائياً.
   ============================================================ */
html[data-theme="dark"] {
    /* 🎨 نصوص الألواح القديمة: على سطح فاتح تبقى داكنة (البطاقة فاتحة في الطابعين)،
       وعلى سطح الطابع العام تُفتَّح. (بديل عن قاعدة تفتيح عامة أفسدت عناوين البطاقات.) */
    --on-light-brand: #4a148c;
    --on-light-brand-sub: #7b1fa2;
    --on-surface-brand: #d8b4fe;
    --on-surface-brand-sub: #c9a7f5;
    --bg-body: #0f1420;
    --bg-card: #182031;
    --bg-header: #131a29;
    --bg-header-desktop: #131a29;
    --bg-nav: #182031;
    --bg-sidebar: #0b101b;
    --bg-input: #131a29;
    --bg-hover: #1f2a3d;
    --bg-muted: #1f2a3d;
    --bg: #131a29;
    --skeleton: #1f2a3d;

    --text-primary: #e7ebf3;
    --text-secondary: #c6ceda;
    --text-muted: #9aa5b6;
    --text-inverse: #0f1420;
    --text-link: #93b7e6;
    --text-header: #e7ebf3;

    --border-color: #2a3446;

    /* نص الهوية والدلالية: الدرجة الغامقة الأصلية لا تُقرأ على الأسطح الداكنة */
    --color-primary-text: #9ec1ee;
    --info-text: #90caf9;
    --danger-text: #ef9a9a;
    --success-text: #a5d6a7;
    --warn-text: #f0c974;
    --color-surface: #182031;

    /* تينتات الحالات: داكنة بنفس هوية اللون */
    --color-success-bg: #12291f;
    --color-warning-bg: #30260f;
    --color-danger-bg: #351a20;
    --color-info-bg: #12262f;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.45);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
}

/* ── أسطح كانت ألوانها مثبّتة داخل CSS (لا تتبع المتغيّرات) ── */

/* 🟦 نصوص/أزرار كانت بلون الهوية الغامق (أزرار، روابط، أيقونات، تبويبات، أنماط سطرية)
   ⇒ لا تُقرأ على الأسطح الداكنة، فصارت تستخدم `--color-primary-text` */
html[data-theme="dark"] .nav-item.active,
html[data-theme="dark"] .text-primary,
html[data-theme="dark"] .tab-btn.active,
html[data-theme="dark"] .pos-pay-stat.pos-pay-stat-change b,
html[data-theme="dark"] .pay-confirm-payable,
html[data-theme="dark"] .pay-confirm-change > span:last-child,
/* الأزرار الشفّافة فقط — أمّا التي لها خلفية سطرية (مثل زر عنبري) فتبقى بنصّها */
html[data-theme="dark"] .btn-outline:not([style*="background:#"]):not([style*="background:var"]),
html[data-theme="dark"] .btn-ghost:not([style*="background:#"]):not([style*="background:var"]),
html[data-theme="dark"] [style*="color:var(--color-primary)"]:not([style*="background:#"]):not([style*="background:var"]),
html[data-theme="dark"] [style*="color: var(--color-primary)"]:not([style*="background:#"]):not([style*="background:var"]) { color: var(--color-primary-text) !important; }
/* تبويبات تُلوّن نصّها بلون الهوية (معرّفة داخل ملفات الشاشات) */
html[data-theme="dark"] .inv-tab.active { color: var(--color-primary-text); border-bottom-color: var(--color-primary-text); }
/* عنصر «غير مقروء» في الإشعارات: خلفية زرقاء فاتحة سطرية ⇒ تُعتَّم ليبقى نصّها مقروءاً */
html[data-theme="dark"] [style*="background:#f0f7ff"] { background: rgba(33,150,243,0.12) !important; }
/* شريحة الاسم: بلا خلفية سطرية ⇒ لون نصّ فاتح؛ ومع خلفية لوحة ألوان **فاتحة** ⇒ يبقى داكناً */
html[data-theme="dark"] .list-item-avatar:not([style*="background"]) { color: var(--color-primary-text); }
html[data-theme="dark"] .list-item-avatar[style*="background"] { color: #2b2d42 !important; }
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] .tab-btn.active { border-color: var(--color-primary-text); }
html[data-theme="dark"] .pay-confirm-discount-title { color: var(--info-text); }

/* مؤشّر السحب للتحديث: كان لوحاً أبيض بنصّ فاتح ⇒ 2.5:1 */
html[data-theme="dark"] .ptr-indicator { background: rgba(24,32,49,0.92); border-bottom-color: var(--border-color); }

/* 🟨 بطاقات خلفيتها **فاتحة** (تدرّجات سطرية في الشاشة الرئيسية) ⇒ يبقى نصّها داكناً
   في الوضعين (وإلا صار نصّاً فاتحاً على خلفية فاتحة = غير مقروء) */
html[data-theme="dark"] .quick-action-btn[style*="linear-gradient"],
html[data-theme="dark"] .quick-action-btn[style*="linear-gradient"] .quick-action-label { color: #2b2d42 !important; }
html[data-theme="dark"] [style*="background:#e"]:not([style*="color:"]):not([style*="background:#f0f7ff"]),
html[data-theme="dark"] [style*="background:#f"]:not([style*="color:"]):not([style*="background:#f0f7ff"]) { color: #2b2d42 !important; }
/* الأصناف التي تُحدّد لونها في CSS داخل «جزيرة فاتحة» تحتاج تثبيتاً صريحاً
   (الشرائح والشارات لها خلفياتها الخاصّة فتبقى بألوان الطابع) */
html[data-theme="dark"] [style*="background:#e"] .list-item-title,
html[data-theme="dark"] [style*="background:#e"] .list-item-subtitle,
html[data-theme="dark"] [style*="background:#e"] .list-item-amount,
html[data-theme="dark"] [style*="background:#f"] .list-item-title,
html[data-theme="dark"] [style*="background:#f"] .list-item-subtitle,
html[data-theme="dark"] [style*="background:#f"] .list-item-amount { color: #2b2d42 !important; }
/* صفوف الحالة في قوائم (منتهية/ملغاة) — خلفيتها فاتحة ⇒ النصّ فقط يصير داكناً */
html[data-theme="dark"] [style*="background:#f0faf0"] .list-item-title,
html[data-theme="dark"] [style*="background:#f0faf0"] .list-item-subtitle,
html[data-theme="dark"] [style*="background:#f0faf0"] .list-item-amount,
html[data-theme="dark"] [style*="background:#fff0f0"] .list-item-title,
html[data-theme="dark"] [style*="background:#fff0f0"] .list-item-subtitle,
html[data-theme="dark"] [style*="background:#fff0f0"] .list-item-amount,
/* نصوص داخل الصفّ لها لونها السطري الخاصّ (شارة الحالة مستثناة — لها خلفيتها) */
html[data-theme="dark"] [style*="background:#f0faf0"] span:not(.badge),
html[data-theme="dark"] [style*="background:#fff0f0"] span:not(.badge) { color: #2b2d42 !important; }
/* شرائح أيقونات خلفيتها تدرّج فاتح داخل بطاقة (الشاشة الرئيسية) */
html[data-theme="dark"] .hmb-ic { color: #2b2d42; }
html[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%);
}
html[data-theme="dark"] .badge-success { color: #7fd6a8; }
html[data-theme="dark"] .badge-warning { color: #f0c974; }
html[data-theme="dark"] .badge-danger  { color: #ff9aa2; }
html[data-theme="dark"] .badge-info    { color: #8ed2e8; }
html[data-theme="dark"] .print-table th { background: var(--bg-muted); }
html[data-theme="dark"] .print-table tfoot td { background: var(--bg-muted); }
html[data-theme="dark"] .print-table tr:nth-child(even) td { background: var(--bg); }

/* أسطح الكاشير/الدفع ذات خلفيات فاتحة محدّدة (عنبر/وردي/أزرق فاتح) */
html[data-theme="dark"] .pos-cart-pane .pos-cart-card { background: #2a2413; }
html[data-theme="dark"] .pos-cart-pane .pos-cart-card .card-header { background: #33290f; }
html[data-theme="dark"] .pay-confirm-discount { background: #152233; }
html[data-theme="dark"] .pay-confirm-warn { background: #33161c; }
html[data-theme="dark"] .pay-confirm-notes { background: #2a2413; }
html[data-theme="dark"] .po-btn-alert { background: #33161c !important; }

/* ── شبكة أمان: نصوص مثبّتة اللون داخل أنماط سطرية في شاشات قديمة ──
   (أزرق داكن/رمادي غامق تصير غير مقروءة على خلفية داكنة)
   ⚠️ كل القواعد ملفوفة بـ`:where()` **لتكون أولويتها دنيا**، كي تتقدّم عليها قاعدة
   «الجزر الفاتحة» أدناه (نصٌّ ملوّن داخل خلفية فاتحة يَرِث لون الجزيرة). */
html[data-theme="dark"] :where(
[style*="color:#1a1a2e"], [style*="color: #1a1a2e"], [style*="color:#2b2d42"],
[style*="color: #2b2d42"], [style*="color:#222"]
) { color: var(--text-primary) !important; }
html[data-theme="dark"] :where(
[style*="color:#475569"], [style*="color: #475569"], [style*="color:#64748b"],
[style*="color:#555"], [style*="color:#666"]
) { color: var(--text-muted) !important; }
/* ألوان دلالية مثبّتة على **أسطح داكنة** تختفي في الطابع الداكن.
   ⚠️ لُغِيت قاعدة تفتيح البنفسجي هنا لصالح **متغيّرات عند المصدر**: العنصر الذي يقف على سطح
   عام (يتغيّر مع الطابع) يستعمل `--on-surface-*`، والذي يقف على بطاقة فاتحة (تبقى فاتحة
   في الطابعين) يستعمل `--on-light-*`. السبب: قاعدة تفتيح عامة لا تستطيع تمييز السياقين،
   وكانت تُفسد عناوين البطاقات الباستيل (المقيس: 1.55 و2.24). */
/* ...إلا داخل «ورقة» بيضاء (معاينة طباعة على الشاشة): يبقى نصها داكناً ليُقرأ */
html[data-theme="dark"] [style*="background:#fff"] [style*="color:#1a1a2e"],
html[data-theme="dark"] [style*="background:#fff"] [style*="color:#475569"],
html[data-theme="dark"] [style*="background:#fff"] [style*="color:#666"] { color: #2b2d42 !important; }
html[data-theme="dark"] [style*="background:#fff"] { color: #2b2d42; }
/* 🔴 القاعدة الحاكمة للجزر الفاتحة (خلفية فاتحة على **الأب** ونصّ ملوّن على **الابن**،
   مثال: `<div style="background:#e8f5e9"><div style="color:#2e7d32">`). بلا هذه القاعدة
   يُفتَّح النصّ فيصير فاتحاً على فاتح — عيب مقيس بتباين 1.29 في تدبير HR وبنفس البنية هنا.
   ⚠️ لا تُوسَّع لتشمل التدرّجات: التدرّجات الشبه شفافة (`linear-gradient(135deg,#d1fae555,transparent)`)
   تبدو «فاتحة» بالاسم لكن خلفيتها الفعلية **داكنة** فوق طابع داكن ⇒ أُضيفت فتُنشئ عيباً جديداً
   (حدث فعلاً في تدبير HR على شاشة الاشتراك) ⇒ التدرّجات تُعالَج عند المصدر لا بقاعدة عامة. */
html[data-theme="dark"] [style*="background:#d"] [style*="color:#"]:not([style*="background:"]),
html[data-theme="dark"] [style*="background:#e"] [style*="color:#"]:not([style*="background:"]),
html[data-theme="dark"] [style*="background:#f"] [style*="color:#"]:not([style*="background:"]),
html[data-theme="dark"] [style*="background:#fff"] [style*="color:#"]:not([style*="background:"]) {
    color: inherit !important;
}

/* الطباعة تبقى فاتحة دائماً (ورق أبيض) — قواعد `@media print` أدناه تتكفّل بذلك */

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
    font-family: var(--font-family);
    -webkit-text-size-adjust: 100%;
}

/* Override direction when lang/dir is set to LTR */
html[dir="ltr"] {
    direction: ltr;
}

/* ── RTL/LTR Direction-Aware Styles ── */
/* Elements that need to flip between RTL and LTR */
[dir="rtl"] .flip-start { text-align: right; }
[dir="ltr"] .flip-start { text-align: left; }
[dir="rtl"] .flip-end { text-align: left; }
[dir="ltr"] .flip-end { text-align: right; }

/* Margin/padding logical directions */
[dir="rtl"] .ml-auto { margin-right: auto; }
[dir="ltr"] .ml-auto { margin-left: auto; }
[dir="rtl"] .mr-auto { margin-left: auto; }
[dir="ltr"] .mr-auto { margin-right: auto; }

/* Header back button arrow direction */
[dir="ltr"] #header-back svg {
    transform: scaleX(-1);
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

button {
    font-family: var(--font-family);
    cursor: pointer;
}

/* ============================================================
   App Shell Layout
   ============================================================ */
#app {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--grace-banner-h, 0px));
    min-height: calc(100dvh - var(--grace-banner-h, 0px));
}

#app-header {
    position: sticky;
    top: 0;
    z-index: 400;
    background: var(--bg-header);
    color: var(--text-header);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-family);
}

#app-header .header-left,
#app-header .header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#header-back {
    background: none;
    border: none;
    color: var(--text-header);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
}

#header-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Live Clock in Header */
#header-clock {
    flex-shrink: 0;
    text-align: center;
    min-width: 80px;
}

#header-time {
    display: block;
    font-size: 22px !important;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 1px;
}

#header-date {
    display: block;
    font-size: 13px !important;
    opacity: 0.85;
}

/* Compact title on sub-screens (prevent crowding with clock) */
.header-title-compact {
    font-size: 14px !important;
    max-width: 120px;
}

/* Compact clock on mobile sub-screens */
.header-clock-compact #header-time {
    font-size: 13px !important;
}
.header-clock-compact #header-date {
    font-size: 9px !important;
}

@media (max-width: 480px) {
    #header-clock {
        min-width: 70px;
    }
    #header-time {
        font-size: 18px !important;
    }
    #header-date {
        font-size: 12px !important;
    }
}

#app-main {
    flex: 1;
    padding: var(--space-md);
    padding-bottom: calc(var(--nav-height) + var(--space-md) + env(safe-area-inset-bottom));
    max-width: var(--app-max-width);
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Sidebar - hidden on mobile, visible on desktop */
#sidebar {
    display: none;
}

/* ============================================================
   Bottom Navigation (Mobile)
   ============================================================ */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-nav);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 500;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    font-family: var(--font-family);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 6px;
    color: var(--text-muted);
    min-height: var(--nav-height);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition);
    font-family: var(--font-family);
}
.nav-item.active {
    color: var(--color-primary);
}

.nav-icon {
    font-size: 24px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-label {
    font-size: 11px;
    font-weight: 600;
}

.nav-add {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
}
.nav-add:hover {
    transform: scale(1.08);
    background: var(--color-primary-dark);
}

/* ============================================================
   Mobile Scroll Fix — prevent body double-scroll on small screens
   ============================================================ */
@media (max-width: 1023px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }
    #app {
        height: calc(100vh - var(--grace-banner-h, 0px));
        height: calc(100dvh - var(--grace-banner-h, 0px));
        overflow: hidden;
    }
    /* Login/landing page needs full scroll on mobile */
    body.login-page,
    body.login-page #app {
        overflow: auto;
        height: auto;
    }
    body.login-page #app-main {
        overflow: visible;
    }
}

/* ============================================================
   Desktop Layout (≥1024px)
   ============================================================ */
@media (min-width: 1024px) {
    #app {
        display: grid;
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-rows: var(--header-height) 1fr;
        grid-template-areas:
            "sidebar header"
            "sidebar main";
        height: calc(100vh - var(--grace-banner-h, 0px));
        height: calc(100dvh - var(--grace-banner-h, 0px));
    }

    /* RTL: sidebar on the right, content on the left */
    [dir="rtl"] #app {
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-areas:
            "sidebar header"
            "sidebar main";
    }
    /* LTR: sidebar on the left, content on the right (default grid is already LTR) */

    #app-header {
        grid-area: header;
        background: var(--bg-header-desktop);
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-color);
        box-shadow: none;
    }
    #header-back { color: var(--text-muted); }
    #header-title { color: var(--text-primary); }

    #sidebar {
        grid-area: sidebar;
        background: var(--bg-sidebar);
        color: rgba(255,255,255,0.75);
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
        padding: var(--space-md) 0;
        font-family: var(--font-family);
    }
    
    #sidebar a, #sidebar span, #sidebar nav, #sidebar div {
        font-family: inherit;
    }

    #bottom-nav {
        display: none;
    }

    #app-main {
        grid-area: main;
        padding: var(--space-lg);
        padding-bottom: var(--space-lg);
        max-width: none;
    }
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

/* 🖱️ بطاقة تحتوي قائمة منسدلة (بحث عميل/مورد/موظف) — تسمح بظهور النتائج كاملة دون قص */
.card.card-dropdown-open {
    overflow: visible;
}

/* 📌 بطاقة تحتوي شريط إجراءات **لاصقاً** (sticky): `overflow:hidden` على البطاقة يجعلها هي
   حاوية التمرير فلا يلتصق الشريط إطلاقاً (ظهر عملياً: شريط «إضافة أصناف/نسبة» بقي يتحرك). */
.card.card-sticky-bar {
    overflow: visible;
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-lg);
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.stat-grid-3 {
    grid-template-columns: repeat(2, 1fr);
}

.stat-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 769px) {
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .stat-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .stat-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    .stat-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 14px 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    border-right: 4px solid var(--color-primary);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card.success { border-color: var(--color-success); }
.stat-card.warning { border-color: var(--color-warning); }
.stat-card.danger  { border-color: var(--color-danger); }
.stat-card.info    { border-color: var(--color-info); }

.stat-icon {
    font-size: 26px;
    margin-bottom: var(--space-xs);
}
.stat-value {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}
.stat-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   Welcome Card (Dashboard)
   ============================================================ */
.welcome-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: #fff;
    border-radius: var(--border-radius-lg);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.welcome-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: var(--font-size-lg);
    flex-shrink: 0;
    z-index: 1;
}
.welcome-greeting {
    font-size: var(--font-size-lg);
    font-weight: 700;
}
.welcome-role {
    font-size: var(--font-size-sm);
    opacity: 0.85;
    margin-top: 2px;
}

.welcome-stats {
    display: flex;
    gap: 8px;
    z-index: 1;
    flex-wrap: wrap;
}
.welcome-stat {
    flex: 1;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(255,255,255,0.12);
    border-radius: var(--border-radius-md);
    padding: 10px 8px;
    backdrop-filter: blur(4px);
}
.welcome-stat:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}
.welcome-stat-icon { font-size: 22px; }
.welcome-stat-value {
    font-size: var(--font-size-lg);
    font-weight: 800;
    direction: ltr;
    white-space: nowrap;
}
.welcome-stat-label {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 600;
}

@media (max-width: 480px) {
    .welcome-card { padding: var(--space-sm) var(--space-md); flex-direction: column; align-items: flex-start; }
    .welcome-avatar { display: none; }
    .welcome-stats { width: 100%; gap: 6px; }
    .welcome-stat { padding: 12px 8px; min-width: 65px; }
    .welcome-stat-value { font-size: 18px !important; }
    .welcome-stat-icon { font-size: 22px; }
    .welcome-stat-label { font-size: 13px !important; }
    .welcome-stat-label { font-size: 9px; }
}

@media (min-width: 769px) {
    .welcome-stats { width: auto; margin-right: auto; }
    .welcome-stat { min-width: 90px; padding: 12px 14px; }
    .welcome-card { padding: var(--space-lg) var(--space-xl); }
}

/* ============================================================
   Quick Actions
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: var(--space-lg);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
    text-align: center;
    min-height: 80px;
}
.quick-action-btn:active { transform: scale(0.97); }
.quick-action-icon { font-size: var(--font-size-icon); line-height: 1; }
.quick-action-label { font-size: var(--font-size-label); font-weight: 600; color: var(--text-secondary); }

@media (min-width: 500px) {
    .quick-actions { grid-template-columns: repeat(5, 1fr); gap: 10px; }
    .quick-action-btn { padding: 18px 12px; min-height: 90px; }
    .quick-action-icon { font-size: calc(var(--font-size-icon) + 4px); }
    .quick-action-label { font-size: calc(var(--font-size-label) + 1px); }
}

@media (min-width: 769px) {
    .quick-actions { grid-template-columns: repeat(5, 1fr); gap: 12px; }
    .quick-action-btn { padding: 18px 14px; min-height: 100px; }
    .quick-action-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
    .quick-action-icon { font-size: calc(var(--font-size-icon) + 8px); }
    .quick-action-label { font-size: calc(var(--font-size-label) + 2px); }
}

/* ============================================================
   List Items
   ============================================================ */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    transition: background var(--transition);
}
.list-item:hover { background: var(--bg-hover); }
.list-item:first-child {
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
}
.list-item:last-child {
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
    border-bottom: none;
}

.list-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-md);
    background: var(--color-primary-light);
    color: var(--color-primary);
    flex-shrink: 0;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}
.list-item-title {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.list-item-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.list-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.list-item-amount {
    font-weight: 700;
    font-size: var(--font-size-md);
    direction: ltr;
}

/* ═══════════ 🧷 إجراءات داخل بطاقة قائمة (وكلاء · شرائح · أقسام القائمة...) ═══════════
   عمود أزرار على الشاشات الواسعة، وصف يلتفّ **تحت** النصّ على الجوال.
   ⚠️ السبب المرجعي لعطل «النص يلتفّ حرفاً حرفاً»: عمود أزرار بعرضه الكامل (`flex-shrink:0`)
      يأكل عرض البطاقة، ونصّ البطاقة `flex:1;min-width:0` ينسحق إلى عرض حرف فينكسر كل كلمة
      حرفاً حرفاً. العلاج: النصّ يأخذ سطراً كاملاً والأزرار تنزل تحته. */
.row-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}
/* كتلة نصّ داخل بطاقة (صورة/أيقونة + نصّ + إجراءات) — لا تنسحق لعلّ عرض حرف */
.item-main { flex: 1; min-width: 0; }

/* ═══════════ 💰 مبالغ داخل بطاقة (شريحة الأسعار) — مقروءة على الجوال ═══════════
   ⚠️ بلاغ المالك (2026-09-21): كانت التجزئة وسعر الشريحة **11.5px** وشارة الخصم **10px**
      ⇒ «بدي عدسة مكبّرة لأشوفه». الأرقام قرار مالي ⇒ لا تنزل عن 12px، والأرقام الكبيرة 19px. */
.pg-prices { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.pg-p { display: flex; flex-direction: column; gap: 1px; }
.pg-lbl { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.pg-ret { font-size: 15px; font-weight: 700; color: var(--text-muted); text-decoration: line-through;
    direction: ltr; unicode-bidi: isolate; }
.pg-whl { font-size: 19px; font-weight: 800; color: var(--color-primary);
    direction: ltr; unicode-bidi: isolate; }
.pg-off { font-size: 14px; font-weight: 800; color: #2e7d32; background: #e8f5e9;
    border-radius: 999px; padding: 3px 11px; align-self: center; direction: ltr; unicode-bidi: isolate; }
.pg-off.eq { color: #e65100; background: #fff3e0; }
.pg-off.up { color: #c62828; background: #fdecea; }
.pg-minq { font-size: 13px; font-weight: 700; color: var(--text-muted); align-self: center; }
.pg-meta { font-size: 12px; color: var(--text-muted); line-height: 1.7; }
@media (max-width: 640px) {
    .pg-prices { gap: 12px 16px; }
    .pg-whl { font-size: 20px; }
}
/* صفّ بطاقة مرن (يقبل الالتفاف على الجوال) — يُستعمل مع `.item-main` و`.row-actions` */
.row-card { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
@media (max-width: 640px) {
    .list-item { flex-wrap: wrap; align-items: flex-start; }
    .list-item-avatar { order: 1; }
    .list-item > .list-item-content { order: 2; flex: 1 1 calc(100% - 60px); min-width: 170px; }
    .item-main { flex: 1 1 calc(100% - 60px); min-width: 170px; }
    .row-actions { order: 3; flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .row-actions .btn { width: auto; flex: 1 1 auto; min-width: 0; }
}
.list-item-date {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Payment list items - allow text wrapping on mobile */
.payment-item .list-item-subtitle {
    white-space: normal !important;
    overflow-wrap: break-word;
    overflow: visible !important;
    text-overflow: clip !important;
}
.payment-item .list-item-content {
    overflow: visible;
}
.payment-item .payment-delete-btn {
    padding: 8px 10px;
    font-size: 16px;
    flex-shrink: 0;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Workshop list items — allow title wrapping on mobile */
.workshop-list-item .list-item-title,
.workshop-list-item .list-item-subtitle {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.workshop-list-item .list-item-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}
.workshop-list-item .list-item-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    font-size: 11px;
}
@media(max-width:600px) {
    .workshop-list-item {
        padding: 10px 8px;
        gap: 8px;
    }
    .workshop-list-item .list-item-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .workshop-list-item .list-item-meta {
        min-width: 70px;
    }
    .workshop-list-item .list-item-amount {
        font-size: 13px;
    }
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: var(--space-md);
}
.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}
.form-help {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-family: var(--font-family);
    direction: rtl;
    text-align: right;
    transition: border-color var(--transition), box-shadow var(--transition);
}
/* Form inputs follow page direction */
[dir="ltr"] .form-input, [dir="ltr"] .form-select, [dir="ltr"] .form-textarea {
    direction: ltr;
    text-align: left;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(61,90,128,0.12);
}
.form-textarea {
    min-height: 100px;
    resize: vertical;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}
@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 8px 18px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font-family);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-success {
    background: #16a34a;
    color: #fff;
    border: none;
    font-weight: 800;
}
.btn-success:hover { background: #128a3e; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--color-primary);
    color: var(--color-primary);
}
.btn-outline:hover {
    background: var(--color-primary-light);
}
.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover {
    opacity: 0.9;
}
.btn-sm {
    padding: 5px 12px;
    font-size: var(--font-size-xs);
}
.btn-xs {
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 4px;
}
.btn-lg {
    padding: 12px 28px;
    font-size: var(--font-size-lg);
}
.btn-block {
    width: 100%;
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
}
.btn-ghost:hover {
    background: var(--bg-hover);
}

/* ============================================================
   Restaurant Floor — شريط الأدوات والفلاتر على الموبايل
   ============================================================ */
.rest-actions-row {
    flex: 1 1 auto;
    justify-content: flex-end;
}
.rest-actions-row .btn-sm {
    border-radius: 999px;
    padding: 6px 14px;
    height: 34px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card, #fff);
    color: var(--text-secondary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.rest-actions-row .btn-sm:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
#rest-status-legend .rest-status-chip,
.rest-chips-row button {
    border-radius: 999px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* ── المخزون على الشاشات الصغيرة: أزرار الصف تلتف لسطر مستقل بدل تفتيت اسم الفئة حرفاً حرفاً ── */
.inv-actions { display:flex; gap:4px; flex-wrap:wrap; }
@media (max-width: 640px) {
    .ct-row, .cat-row { flex-wrap: wrap !important; }
    .ct-row > div:last-child, .cat-row > div:last-child { flex-basis: 100% !important; justify-content: flex-end; flex-wrap: wrap; margin-top: 2px; }
    #ut-list > div { flex-wrap: wrap !important; }
    /* بطاقات الأصناف: اسم الصنف يأخذ السطر الأول كاملاً وتنزل خانة الكمية تحته */
    .inv-mobile .inv-card > div:first-child { flex-wrap: wrap !important; }
    .inv-mobile .inv-name-col { flex-basis: auto !important; }
}

@media (max-width: 640px) {
    .rest-floor-head {
        flex-direction: column;
        align-items: stretch !important;
    }
    /* الجرس ظاهر في الهيدر العلوي — لا داعي لتكراره في شريط الأدوات على الموبايل */
    #rest-notif-btn {
        display: none !important;
    }
    /* شبكة أزرار متساوية تلتف لصفوف — كلها مرئية بدون أي تمرير أفقي */
    .rest-actions-row {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px !important;
        flex-wrap: wrap !important;
        overflow: visible !important;
        width: 100% !important;
        justify-content: stretch !important;
        padding-bottom: 2px;
    }
    .rest-actions-row .btn-sm {
        width: 100%;
        height: auto;
        min-height: 36px;
        padding: 6px 4px;
        font-size: 11px;
        border-radius: 10px;
        white-space: normal;
        line-height: 1.25;
    }
    /* الشرائح تلتف طبيعياً لصفوف — مرئية كلها بدون تمرير */
    #rest-status-legend,
    .rest-chips-row {
        flex-wrap: wrap !important;
        overflow: visible !important;
    }
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: #856404; }
.badge-danger  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg); color: #055160; }

/* ============================================================
   Search Bar
   ============================================================ */
.search-bar {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.search-bar .form-input {
    flex: 1;
    min-width: 180px;
    background: var(--bg-card);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--space-sm);
}
.pagination-btn {
    padding: 6px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-card);
    font-size: var(--font-size-sm);
    cursor: pointer;
    font-family: var(--font-family);
    color: var(--text-secondary);
    transition: all var(--transition);
}
.pagination-btn:hover {
    background: var(--bg-hover);
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    padding: 0 var(--space-sm);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-md);
    text-align: center;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.7;
}
.empty-state h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}
.empty-state p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    max-width: 300px;
}

/* ============================================================
   Skeleton Loading
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover,#f0f0f0) 25%, var(--skeleton) 50%, var(--bg-hover,#f0f0f0) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================================
   Toast Animations
   ============================================================ */
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* ============================================================
   Page Transitions
   ============================================================ */
.page-enter {
    animation: fadeSlideUp 0.25s ease;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Bottom Sheet Animation
   ============================================================ */
@keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideDownSheet {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

/* ============================================================
   Pull-to-Refresh Indicator
   ============================================================ */
.ptr-indicator {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    gap: 8px;
    z-index: 110;
    pointer-events: none;
    transition: top 0.3s ease;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.ptr-spinner {
    display: block;
    border-style: solid;
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
}
.ptr-indicator .ptr-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
}

.ptr-indicator.ptr-refreshing .ptr-spinner {
    animation: ptr-spin 0.6s linear infinite;
}

@keyframes ptr-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   FAB (Floating Action Button)
   ============================================================ */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

@media (min-width: 1024px) {
    .fab {
        bottom: 24px;
        left: 24px;
    }
}

/* ============================================================
   Landing Page — شاشة تسجيل الدخول
   ============================================================ */
.login-form-side {
    flex: 0 0 440px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    background: #fff;
    z-index: 1;
    box-shadow: 2px 0 20px rgba(0,0,0,0.06);
}
.login-landing {
    flex: 1;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    overflow-y: auto;
    padding: 40px 32px 20px;
    display: flex;
    flex-direction: column;
}
.landing-header {
    text-align: center;
    margin-bottom: 20px;
}
.landing-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.landing-stat {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px 20px;
    text-align: center;
    min-width: 100px;
    flex: 1;
    max-width: 160px;
}
.landing-stat-num {
    display: block;
    font-size: 22px;
    font-weight: 900;
    color: #e2b04a;
    margin-bottom: 2px;
}
.landing-stat-label {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}
.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    flex: 1;
}
.landing-feature-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}
.landing-feature-card:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.landing-feature-card.expanded {
    background: rgba(255,255,255,0.12);
    border-color: rgba(226,176,74,0.4);
}
.landing-feature-card.expanded .lfc-detail {
    max-height: 200px;
    opacity: 1;
    margin-top: 10px;
}
.lfc-icon { font-size: 28px; display: inline-block; vertical-align: middle; }
.lfc-title { display: inline-block; font-size: 14px; font-weight: 700; color: #fff; margin-right: 8px; vertical-align: middle; }
.lfc-arrow { display: inline-block; font-size: 10px; color: rgba(255,255,255,0.4); vertical-align: middle; margin-right: auto; float: left; transition: transform 0.3s; }
.landing-feature-card.expanded .lfc-arrow { transform: rotate(180deg); }
.lfc-detail {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    line-height: 1.7;
}
.landing-footer {
    text-align: center;
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    padding-top: 20px;
    margin-top: auto;
}

@media (max-width: 900px) {
    .login-layout {
        flex-direction: column;
    }
    .login-form-side {
        flex: 0 0 auto;
        padding: 32px 20px;
        box-shadow: none;
    }
    .login-landing {
        padding: 24px 16px 20px;
    }
    .landing-features {
        grid-template-columns: 1fr;
    }
    .landing-stats {
        gap: 8px;
    }
    .landing-stat {
        min-width: 70px;
        padding: 10px 12px;
    }
    .landing-stat-num { font-size: 18px; }
}

@media (min-width: 500px) {
    .login-card { padding: 40px 36px 32px; }
    .login-title { font-size: 24px; }
}

   Action Bar (Search + Filters)
   ============================================================ */
.action-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--color-primary); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }

.font-bold { font-weight: 700; }
.font-sm { font-size: var(--font-size-sm); }
.font-xs { font-size: var(--font-size-xs); }
.font-lg { font-size: var(--font-size-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.w-full { width: 100%; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* ============================================================
   RTL Overflow Fixes
   ============================================================ */
* {
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    body { background: #fff; color: #000; overflow: visible !important; height: auto !important; min-height: auto !important; }
    #app { display: block !important; min-height: auto !important; height: auto !important; overflow: visible !important; }
    #app-header, #bottom-nav, #sidebar, .no-print { display: none !important; }
    #app-main { padding: 0; max-width: none; margin: 0; overflow: visible !important; height: auto !important; flex: none !important; }
    .internal-notice { display: none !important; }
    .print-table { width: 100%; border-collapse: collapse; }
    .print-table th, .print-table td { border: 1px solid #ccc; padding: 4px 5px; text-align: right; }
    .print-table td[style*="direction:ltr"] { white-space: nowrap !important; }
    .print-table thead { display: table-header-group; }
    .print-table tr { page-break-inside: avoid; }
}
@page { margin: 10mm; }

/* ============================================================
   Watermark — علامة مائية
   ============================================================ */
.wm-watermark {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 999; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.wm-watermark span {
    font-weight: 900; white-space: nowrap;
    max-width: 80%; overflow: hidden; text-overflow: ellipsis; letter-spacing: 12px;
}
@media print {
    .wm-watermark {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}


/* ============================================================
   Print Table Styles
   ============================================================ */
.print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-table th, .print-table td { border: 1px solid #ddd; padding: 5px 8px; text-align: right; }
.print-table th { background: #f0f0f0; font-weight: 700; white-space: nowrap; }
.print-table tr:nth-child(even) td { background: #fafafa; }
.print-table tfoot td { background: #f0f0f0; }

/* Tab buttons */
.tab-btn { border-radius:6px 6px 0 0; border:1px solid var(--border-color); border-bottom:none; background:var(--bg-hover); color:var(--text-muted); padding:6px 14px; }
.tab-btn.active { background:var(--bg-card); color:var(--color-primary); font-weight:700; border-color:var(--color-primary); }

/* ============================================================
   Employees List — Grid Cards on Desktop
   ============================================================ */
@media (min-width: 1024px) {
    /* Convert the list container to a grid */
    #employees-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 14px;
    }
    /* Card style for each employee */
    #employees-list .list-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
        padding: 24px 20px;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        transition: transform 0.2s, box-shadow 0.2s;
    }
    #employees-list .list-item:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        background: var(--bg-card);
    }
    #employees-list .list-item:first-child,
    #employees-list .list-item:last-child {
        border-radius: 14px;
    }
    /* Larger avatar */
    #employees-list .list-item-avatar {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    #employees-list .list-item-avatar img {
        width: 100px;
        height: 100px;
    }
    /* Content centered */
    #employees-list .list-item-content {
        flex: none;
        width: 100%;
    }
    #employees-list .list-item-title {
        font-size: 20px;
        white-space: normal;
        word-break: break-word;
        line-height: 1.3;
        margin-bottom: 6px;
    }
    #employees-list .list-item-subtitle {
        font-size: 15px;
        white-space: normal;
        word-break: break-word;
        line-height: 1.6;
    }
    /* Meta (status badge) centered */
    #employees-list .list-item-meta {
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }
    #employees-list .list-item-meta .badge {
        font-size: 14px;
        padding: 6px 16px;
    }
    /* Hide divider line on cards */
    #employees-list .list-item {
        border-bottom: 1px solid var(--border-color);
    }
}

@media (min-width: 1400px) {
    #employees-list {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 18px;
    }
    #employees-list .list-item-avatar {
        width: 120px;
        height: 120px;
        font-size: 48px;
    }
    #employees-list .list-item-avatar img {
        width: 120px;
        height: 120px;
    }
    #employees-list .list-item {
        padding: 28px 24px;
    }
    #employees-list .list-item-title {
        font-size: 22px;
    }
    #employees-list .list-item-subtitle {
        font-size: 16px;
    }
}

/* ============================================================
   Workshop Items Table — Larger on Desktop
   ============================================================ */
@media (min-width: 1024px) {
    /* Items table font & spacing */
    .wd-item-desc,
    .wd-item-qty,
    .wd-item-price,
    .wd-item-cost,
    .wd-item-discount {
        font-size: 14px !important;
        padding: 8px 4px !important;
    }
    .wd-item-total {
        font-size: 14px !important;
        white-space: nowrap !important;
    }
    .wd-item-del {
        font-size: 14px !important;
        padding: 4px 6px !important;
    }
    .wd-quick-add {
        font-size: 12px !important;
        padding: 3px 8px !important;
    }
    /* Header cells */
    .wd-items-table thead th {
        font-size: 13px !important;
        padding: 8px 4px !important;
    }
    /* Totals row */
    #wd-items-total {
        font-size: 15px !important;
        white-space: nowrap !important;
    }
    #wd-net-total {
        font-size: 16px !important;
        white-space: nowrap !important;
    }
    #wd-discount {
        font-size: 14px !important;
        padding: 5px 3px !important;
    }
    /* Tfoot labels */
    .wd-items-table tfoot td {
        font-size: 13px !important;
    }
}

@media (min-width: 1400px) {
    .wd-item-desc,
    .wd-item-qty,
    .wd-item-price,
    .wd-item-cost,
    .wd-item-discount {
        font-size: 15px !important;
        padding: 10px 6px !important;
    }
    .wd-item-total {
        font-size: 15px !important;
        white-space: nowrap !important;
    }
    .wd-items-table thead th {
        font-size: 14px !important;
        padding: 10px 6px !important;
    }
    #wd-items-total {
        font-size: 16px !important;
        white-space: nowrap !important;
    }
    #wd-net-total {
        font-size: 18px !important;
        white-space: nowrap !important;
    }
    #wd-discount {
        font-size: 15px !important;
        padding: 6px 4px !important;
    }
}

/* ============================================================
   Workshop Payments Table — Responsive layout
   ============================================================ */
/* Mobile base: compact with horizontal scroll */
.wd-payments-table {
    font-size: 12px !important;
}
.wd-payments-table th {
    font-size: 11px !important;
    padding: 6px 5px !important;
    white-space: nowrap;
}
.wd-payments-table td {
    font-size: 12px !important;
    padding: 6px 5px !important;
}
/* Notes column always wraps */
.wd-payments-table td.wd-notes-cell {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    min-width: 80px;
}
/* Actions column — buttons wrap naturally */
.wd-payments-table .wd-actions-cell {
    white-space: normal;
}
.wd-payments-table .wd-action-btn {
    margin: 1px !important;
}
/* Scroll hint for mobile */
.wd-payments-wrapper {
    position: relative;
}
.wd-payments-wrapper::after {
    content: '← اسحب للمزيد →';
    display: block;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted, #999);
    padding: 4px 0 0;
    opacity: 0.7;
}

@media (min-width: 1024px) {
    /* Hide scroll hint on desktop */
    .wd-payments-wrapper::after { display: none; }
    .wd-payments-table {
        font-size: 14px !important;
    }
    .wd-payments-table th {
        font-size: 13px !important;
        padding: 8px 4px !important;
    }
    .wd-payments-table td {
        font-size: 13px !important;
        padding: 6px 4px !important;
    }
    /* ✅ السماح للنص في عمود الملاحظات بالالتفاف — الأعمدة الأخرى تبقى nowrap */
    .wd-payments-table td:not(.wd-notes-cell):not(.wd-actions-cell) {
        white-space: nowrap !important;
    }
    .wd-payments-table td.wd-notes-cell {
        white-space: normal !important;
        word-break: break-word !important;
    }
    .wd-payments-table .btn-xs {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
    /* إجراءات — أزرار تلف داخل العمود */
    .wd-payments-table .wd-actions-cell {
        white-space: normal !important;
    }
    .wd-payments-table .wd-action-btn {
        margin: 1px !important;
    }
}

@media (min-width: 1400px) {
    .wd-payments-table {
        font-size: 15px !important;
    }
    .wd-payments-table th {
        font-size: 14px !important;
        padding: 10px 6px !important;
    }
    .wd-payments-table td {
        font-size: 14px !important;
        padding: 8px 6px !important;
    }
    .wd-payments-table td:not(.wd-notes-cell):not(.wd-actions-cell) {
        white-space: nowrap !important;
    }
    .wd-payments-table td.wd-notes-cell {
        white-space: normal !important;
        word-break: break-word !important;
    }
    .wd-payments-table .wd-actions-cell {
        white-space: normal !important;
    }
    .wd-payments-table .wd-action-btn {
        margin: 1px !important;
    }
}

/* ============================================================
   Print Tables & Reports — Larger on Desktop Screen
   ============================================================ */
@media screen and (min-width: 1024px) {
    .print-table { font-size: 14px !important; }
    .print-table th { font-size: 13px !important; padding: 10px 8px !important; }
    .print-table td { font-size: 14px !important; padding: 10px 8px !important; }
    /* Prevent currency wrapping in all tables */
    td[style*="direction:ltr"], th[style*="direction:ltr"] { white-space: nowrap !important; }
    #rp-content h3 { font-size: 16px !important; }
    #rp-org-name { font-size: 22px !important; }
    #rp-org-addr { font-size: 13px !important; }
    #rp-meta { font-size: 13px !important; }
}
@media screen and (min-width: 1400px) {
    .print-table { font-size: 15px !important; }
    .print-table th { font-size: 14px !important; padding: 12px 10px !important; }
    .print-table td { font-size: 15px !important; padding: 12px 10px !important; }
    td[style*="direction:ltr"], th[style*="direction:ltr"] { white-space: nowrap !important; }
    #rp-content h3 { font-size: 18px !important; }
}

/* ============================================================
   "Where Are They Now" Modal — Full-Screen on Desktop
   ============================================================ */
@media (min-width: 1024px) {
    .wz-modal-content {
        max-width: 92vw !important;
        width: 88% !important;
        max-height: 94vh !important;
        padding: 28px 32px !important;
    }
}
@media (min-width: 1400px) {
    .wz-modal-content {
        max-width: 1300px !important;
        width: 85% !important;
        padding: 32px 40px !important;
    }
}

/* ============================================================
   Custody List — Larger Avatars on Desktop
   ============================================================ */
@media (min-width: 1024px) {
    #custody-list .list-item img {
        width: 72px !important;
        height: 72px !important;
    }
    #custody-list .list-item span[style*="width:40px"] {
        width: 72px !important;
        height: 72px !important;
        font-size: 28px !important;
        line-height: 72px !important;
    }
    #custody-list .list-item {
        padding: 14px 16px !important;
    }
    #custody-list .list-item [style*="font-size:14px"] {
        font-size: 17px !important;
    }
    #custody-list .list-item [style*="font-size:11px"] {
        font-size: 13px !important;
    }
    #custody-list .list-item [style*="font-size:10px"] {
        font-size: 12px !important;
    }
}
@media (min-width: 1400px) {
    #custody-list .list-item img {
        width: 88px !important;
        height: 88px !important;
    }
    #custody-list .list-item span[style*="width:40px"] {
        width: 88px !important;
        height: 88px !important;
        font-size: 34px !important;
        line-height: 88px !important;
    }
}

/* ============================================================
   POS Pro Layout — الكاشير + محرر طلبية الطاولات (16.121.0)
   ألواح ثابتة تملأ الشاشة على الشاشات الكبيرة (نمط كاشير التابلت)
   وتتحول لتخطيط مكدس مع شريط دفع لاصق على الموبايل.
   RTL: الفئات يمين، الأصناف وسط، السلة يسار.
   ============================================================ */
.pos-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px;
}
.pos-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.pos-topbar h2 { margin: 0; font-size: 18px; }
#pos-shift-bar { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
/* منع التفاف أحرف عنوان الجلسة وزر الإغلاق نهائياً في كل المقاسات */
#pos-shift-bar b, #pos-shift-bar .btn { white-space: nowrap; }

.pos-panes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
}
.pos-panes .card { margin-bottom: 0; }

/* لوح الفئات */
.pos-cats-pane { width: 100%; }
.pos-cats-card {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: hidden;
}
.pos-cat-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    flex-shrink: 0;
}

/* لوح المنتجات */
.pos-products-pane { flex: 2; min-width: 270px; display: flex; flex-direction: column; }
.pos-products-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pos-products-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
}

/* لوح السلة + شريط الدفع */
.pos-cart-pane { flex: 1; min-width: 270px; display: flex; flex-direction: column; }
.pos-cart-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: visible; }
/* السلة بخلفية فاتحة مميزة عن باقي الشاشة (16.132.0) */
.pos-cart-pane .pos-cart-card {
    background: #fff8e1;
    border: 1px solid #ffe082;
}
.pos-cart-pane .pos-cart-card .card-header {
    background: #ffecb3;
    border-bottom-color: #ffe082;
}
.pos-cart-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
}
/* ══════════════════════════════════════════════════════════════════════════
   ⚖️ تبويب وحدات القياس (التسميات) — تصميم مرتّب متجاوب (طلب المالك 2026-09-26)
   المبدأ: **قسطان واضحان** — ① وحداتك المُدارة (بطاقات) ② الوحدات المتعارف عليها
   (أكورديون بالأنواع). العرض يتكيّف بالشبكة (`auto-fill/minmax`) بلا فرع شاشة:
   الموبايل عمود واحد · التابلت عمودان · الشاشة الكبيرة 3 أعمدة، وأهداف اللمس ≥40px.
   ══════════════════════════════════════════════════════════════════════════ */
.ut-head {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--bg-card);
    margin-bottom: 14px;
}
.ut-head-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ut-head-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.ut-count {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 2px 9px;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--text-muted);
    white-space: nowrap;
}
.ut-count.is-on { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.ut-hint { font-size: 11.5px; color: #1565c0; background: #e3f2fd; border: 1px solid #90caf9; border-radius: 10px; padding: 8px 10px; margin: 8px 0 10px; line-height: 1.8; }
.ut-addrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ut-addrow .form-input { flex: 1 1 140px; min-width: 0; }
.ut-addrow #ut-symbol { flex: 0 0 110px; }
.ut-addrow .btn { flex-shrink: 0; min-height: 40px; }

/* 🌱 بداية سريعة بالوحدات الشائعة — سطر مستقلّ تحت الإضافة اليدوية */
.ut-preset-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 10px; padding: 10px 12px;
    border: 1px dashed var(--border-color); border-radius: 12px;
    background: rgba(21, 101, 192, 0.045);
}
.ut-preset-row .btn { flex-shrink: 0; min-height: 40px; }
.ut-preset-hint { flex: 1 1 200px; min-width: 0; font-size: 11.5px; line-height: 1.6; color: var(--text-muted); }

.ut-sec { margin-bottom: 16px; }
.ut-sec-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 2px 10px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 10px;
}
.ut-sec-title { font-size: 13.5px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.ut-search { flex: 1 1 160px; min-width: 0; font-size: 12.5px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); }
.ut-sec-head .btn { flex-shrink: 0; min-height: 38px; }

/* ① بطاقات وحداتك: شبكة تتكيّف (1 → 2 → 3 أعمدة) */
.ut-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ut-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 11px 12px;
    background: var(--bg-card);
    display: flex; flex-direction: column; gap: 9px;
    min-width: 0;
}
.ut-card.is-off { background: var(--bg-hover); opacity: 0.85; }
.ut-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ut-card-name { font-size: 15px; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ut-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.ut-tag { border-radius: 9px; padding: 2px 8px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.ut-tag.kind { background: #f3e5f5; color: #6a1b9a; border: 1px solid #ce93d8; }
.ut-tag.used { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.ut-tag.off { background: #eeeeee; color: #616161; border: 1px solid #e0e0e0; }
.ut-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.ut-card-actions .btn { flex: 1 1 auto; min-height: 40px; }

/* ② الوحدات المتعارف عليها: أكورديون بالأنواع */
.ut-known-wrap { border: 1px solid var(--border-color); border-radius: 14px; padding: 12px 14px; background: var(--bg-hover); }
.ut-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; align-items: start; }
.ut-kind { border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card); overflow: hidden; }
.ut-kind-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    width: 100%; min-height: 48px; padding: 8px 12px;
    background: none; border: none; cursor: pointer; text-align: start;
    font-family: inherit; color: inherit;
}
.ut-kind-label { font-size: 13px; font-weight: 800; flex: 1 1 auto; min-width: 0; }
.ut-kind-caret { font-size: 12px; color: var(--text-muted); transition: transform 0.15s ease; }
.ut-kind.is-open .ut-kind-caret { transform: rotate(90deg); }
.ut-kind-add { font-size: 11.5px; color: #1565c0; font-weight: 700; white-space: nowrap; }
.ut-kind-body { display: none; padding: 4px 12px 12px; flex-wrap: wrap; gap: 7px; }
.ut-kind.is-open .ut-kind-body { display: flex; }
.ut-chip {
    min-height: 38px;
    padding: 7px 13px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 12.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
}
.ut-chip:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.ut-chip.is-on { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; cursor: default; font-weight: 600; }
.ut-chip .ut-ratio { font-size: 10px; color: var(--text-muted); font-weight: 500; }

@media (max-width: 600px) {
    .ut-addrow #ut-symbol { flex: 1 1 100px; }
    .ut-addrow .btn { flex: 1 1 100%; }
    .ut-cards { grid-template-columns: 1fr; }
    .ut-kinds { grid-template-columns: 1fr; }
    .ut-card-actions .btn { flex: 1 1 100%; }
    .ut-search { flex: 1 1 100%; }
}

/* ══════════════════════════════════════════════════════════════════════════
   🧾 سطر السلة: ثلاثة أسطر واضحة (طلب المالك 2026-09-26)
     ① الاسم في سطر لوحده ② أدوات (تعديل السعر/ملاحظة/حذف) ③ الكمية والمبلغ البارز
   والتصميم واحد على الموبايل والتابلت والشاشات الكبيرة (عرض عمود السلة ضيّق
   فيتكدّس رأسياً دائماً) — والأحجام تتغيّر بـ clamp بلا فرع شاشة.
   ══════════════════════════════════════════════════════════════════════════ */
.pos-line {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
}
.pos-line-name {
    font-size: clamp(13.5px, 1.05vw + 11px, 16px);
    font-weight: 800;
    line-height: 1.5;
    word-break: break-word;
    min-width: 0;
}
.pos-line-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    border-radius: 8px;
    padding: 1px 6px;
    white-space: nowrap;
}
.pos-line-note {
    font-size: 11px;
    color: #c62828;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.35;
    word-break: break-word;
}
/* ② أدوات السطر: مخفية افتراضياً وتُفتح لسطر واحد عند الحاجة (هدف لمس 44px) */
.pos-line-tools { display: none; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pos-line.is-open .pos-line-tools { display: flex; }
.pos-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px dashed var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    flex: 1 1 auto;
    white-space: nowrap;
}
.pos-tool-btn .pos-tool-txt { font-size: 11.5px; font-weight: 700; }
.pos-tool-btn.is-on { background: #ffe082; border-style: solid; }
.pos-tool-btn.pos-price-btn { border-color: #ffb74d; color: #e65100; }
.pos-tool-btn.pos-price-btn.is-on { background: #fff3e0; }
.pos-tool-btn.pos-del-btn { border-color: var(--color-danger); color: var(--color-danger); font-size: 16px; }
/* ═══ سطر السلة المكدّس (صيغة 16.132.0) ═══
   ① الاسم + المبلغ الإجمالي في سطر واحد ② الكمية + سعر الوحدة
   ③ أدوات السطر (سعر/ملاحظة/حذف) تُفتح عند الحاجة فقط — فالسطر الافتراضي 56px
   بدل 130–170px، فيظهر 8–10 أسطر بدل 3–4 (المعيار: أسطر 56–72px). */
.pos-line {
    display: block;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.pos-line.is-open { background: #fffdf5; }
.pos-cart-count:empty { display: none; }
.pos-cart-count {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    border-radius: 10px;
    padding: 0 7px;
    font-size: 11.5px;
    font-weight: 900;
    vertical-align: middle;
    direction: ltr;
}
.pos-line-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}
.pos-line-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.pos-line-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: clamp(13px, 0.9vw + 10px, 15px);
    font-weight: 800;
    line-height: 1.25;
    /* سطران كحد أقصى: الاسم الطويل يظهر كاملاً بدل «...» — والسطر القصير يبقى 76px */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.pos-line-name .pos-line-badge { font-weight: 800; }
.pos-line-note {
    font-size: 11px;
    color: #c62828;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.35;
    word-break: break-word;
}
.pos-line-total {
    flex: 0 0 auto;
    font-size: clamp(16px, 1.05vw + 12px, 20px);
    font-weight: 900;
    color: var(--color-primary);
    direction: ltr;
    line-height: 1.1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* زرّ «أدوات السطر» — يفتح تعديل السعر/ملاحظة/حذف لهذا السطر فقط */
.pos-line-more {
    flex: 0 0 auto;
    margin-inline-start: auto;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}
.pos-line-more:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pos-line.is-open .pos-line-more { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
/* سعر الوحدة: معلومة مساندة — تُخفى على العروض الضيقة لتوفير مساحة الاسم */
.pos-unit-money { flex: 0 0 auto; font-size: 11.5px; color: var(--text-muted); direction: ltr; white-space: nowrap; }
@media (max-width: 1439px) { .pos-line-foot .pos-unit-money { display: none; } }
.pos-tool-btn .pos-tool-txt { font-size: 11.5px; font-weight: 700; }
.pos-qty-group { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.pos-qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    flex-shrink: 0;
}
.pos-qty-btn:active { background: var(--color-primary); color: #fff; }
/* فأرة (سطح مكتب): أزرار أدق ⇒ سطر 72px بدل 84px · لمس (تابلت): 44px كما هي */
@media (pointer: fine) {
    .pos-qty-btn { width: 36px; height: 36px; font-size: 18px; border-radius: 10px; }
    .pos-line-more { width: 32px; height: 32px; font-size: 15px; }
}
.pos-qty-val {
    min-width: 34px;
    text-align: center;
    font-weight: 900;
    font-size: 19px;
    direction: ltr;
}
/* ④ وحدة السطر: قائمة كاملة العرض + بيان المعامل */
.pos-line-unit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pos-line-unit .pos-unit-sel {
    font-size: 13.5px;
    padding: 7px 8px;
    border-radius: 10px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}
.pos-line-factor { font-size: 11px; color: #1565c0; white-space: nowrap; }
html[data-theme="dark"] .pos-line-total { color: #ffd54f; }
html[data-theme="dark"] .pos-tool-btn { background: #33290f; color: #f0e6c8; }
html[data-theme="dark"] .pos-tool-btn.pos-del-btn { color: #ff8a80; border-color: #ff8a80; }
.pos-pay-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    padding: 12px;
    background: var(--bg-card);
    z-index: 20;
}
.pos-pay-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 800;
}

/* ── شريط الدفع الأفقي بعرض الشاشة: عميل | طريقة | مدفوع | إجمالي | باقي | دفع (16.124.0) ── */
.pos-pay-bar {
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    z-index: 25;
}
.pos-pay-customer { flex: 1 1 200px; min-width: 170px; max-width: 280px; }
.pos-pay-field { flex: 0 0 auto; min-width: 110px; }
.pos-pay-field.pos-pay-notes { flex: 1 1 150px; min-width: 120px; max-width: 300px; }
.pos-pay-customer .form-label,
.pos-pay-field .form-label { font-size: 11px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-pay-customer .form-input,
.pos-pay-field .form-input,
.pos-pay-field .form-select { padding: 7px 10px; font-size: 14px; }
.pos-pay-totals {
    display: flex;
    gap: 16px;
    align-items: stretch;
    flex: 0 0 auto;
    padding: 0 4px;
    margin-inline-start: auto;
}
.pos-pay-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 90px;
    text-align: center;
}
.pos-pay-stat span { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.pos-pay-stat b { font-size: 30px; font-weight: 900; line-height: 1.1; color: var(--text-primary); }
.pos-pay-stat.pos-pay-stat-change b { font-size: 28px; color: var(--color-primary); }
.pos-pay-stat.pos-pay-stat-change {
    background: var(--bg-hover, #f0f0eb);
    border-radius: 12px;
    padding: 2px 14px;
}
.pos-pay-bar .pos-pay-btn {
    width: auto;
    padding: 10px 26px;
    font-size: 15px;
    font-weight: 800;
    flex: 0 0 auto;
}
.pos-discount-box input:disabled {
    opacity: 0.45;
    background: var(--bg-muted, #f1f3f5);
    cursor: not-allowed;
}
.pos-pay-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 10px;
}
.pos-pay-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.pos-pay-actions .btn { flex: 1; }
.pos-pay-secondary {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.pos-pay-secondary .btn { flex: 1; min-width: 88px; padding: 6px 8px; font-size: 11px; }

/* شبكة المنتجات — بلاطات أكبر على الشاشات الكبيرة */
.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
/* صورة المنتج مربّعة (مطابقة لمصدر 512×512) = احتواء كامل للصورة بدون قصّ وبدون فراغات */
.pos-pimg {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: cover;
}
/* لمسة تابلت سلسة: أزرار المنتجات/الفئات لا تلتقط التمرير ولا تؤخر النقر */
.pos-product-btn,
.pos-cat-chip,
.pos-fav-chip,
.rest-cat-chip,
.pos-qty-btn,
.pos-del-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
/* منع سحب الصورة/القائمة الطويلة على iOS من اعتراض حركة التمرير بالإصبع */
.pos-product-btn img,
.pos-cat-chip img,
.rest-cat-chip img,
.pos-pimg {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

/* ── الموبايل (<768): مكدس + شريط الدفع لاصق أسفل الشاشة ── */
@media (max-width: 767px) {
    .pos-cart-body { max-height: 34vh; }
    .pos-pay-footer {
        position: sticky;
        bottom: 0;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.10);
    }
    .pos-pay-bar {
        position: sticky;
        bottom: 0;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.10);
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
    .pos-pay-bar .pos-pay-btn { width: 100%; }
    .pos-pay-customer { flex-basis: 100%; min-width: 0; }
    .pos-pay-totals { width: 100%; justify-content: space-between; }

    /* شريط الجلسة داخل الترويسة: سطر واحد مضغوط على الهاتف */
    #pos-shift-bar { flex-basis: 100%; }
    .pos-shift-hint { display: none; }
    #pos-shift-bar > div { flex-wrap: nowrap !important; overflow: hidden; }
    #pos-shift-bar span[style*="flex:1"] {
        min-width: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ── ترويسة الكاشير: على التابلت (768-1023) شريط الجلسة يأخذ سطراً كاملاً والأزرار سطراً ثانياً — بلا التفاف أحرف ── */
@media (min-width: 768px) and (max-width: 1023px) {
    .pos-layout-cashier .pos-topbar {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 10px;
    }
    .pos-layout-cashier .pos-topbar-main { flex: 1 1 100%; min-width: 0; }
    .pos-layout-cashier .pos-topbar h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex-shrink: 0; }
    .pos-layout-cashier .pos-topbar-actions { flex: 1 1 100%; justify-content: flex-start; gap: 6px; }
    .pos-layout-cashier .pos-topbar-actions .btn { padding: 4px 10px; font-size: 12px; }
    #pos-fs-btn { min-width: 30px; }
}
@media (min-width: 1024px) and (max-width: 1199px) {
    .pos-layout-cashier .pos-topbar {
        display: grid;
        flex-wrap: nowrap;
        grid-template-columns: minmax(0, 1fr) 320px;
        grid-template-areas: "top cart";
        align-items: center;
    }
    .pos-layout-cashier .pos-topbar-main { grid-area: top; }
    .pos-layout-cashier .pos-topbar h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .pos-layout-cashier .pos-topbar-actions { grid-area: cart; justify-content: flex-end; gap: 4px; }
    .pos-layout-cashier .pos-topbar-actions .btn { padding: 3px 7px; font-size: 11.5px; }
    #pos-fs-btn { min-width: 30px; }
}

/* ── تابلت وشاشات كبيرة (≥768): فئات عمودية إجبارية + شريط دفع أفقي بلا التفاف ── */
@media (min-width: 768px) {
    /* الفئات عمودية (يمين الشاشة) — إجباري على التابلت والشاشات الكبيرة */
    .pos-cats-pane .pos-cat-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        overflow-x: hidden;
        overflow-y: auto;
        gap: 6px;
        padding: 6px;
        height: 100%;
    }
    .pos-cats-pane .pos-cat-bar > span { display: none; } /* فاصل │ */
    .pos-cats-pane .pos-cat-bar .pos-cat-chip,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center;
        gap: 4px !important;
        padding: 8px 2px !important;
        border-radius: 12px !important;
        white-space: normal !important;
        width: 100%;
        font-size: 14px !important;
        flex-shrink: 0;
    }
    .pos-cats-pane .pos-cat-bar .pos-cat-chip img,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip img,
    .pos-cats-pane .pos-cat-bar .pos-cat-chip > span:first-child,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip > span:first-child {
        width: 56px !important;
        height: 56px !important;
        font-size: 22px !important;
    }
    .pos-cats-pane .pos-fav-chip > span:last-child { display: none; } /* سعر المفضلة */

    /* شريط الدفع: سطر أفقي واحد — ممنوع الالتفاف إطلاقاً */
    .pos-pay-bar { flex-wrap: nowrap !important; }
    .pos-pay-customer { flex: 1 1 auto; min-width: 110px; max-width: 200px; }
    .pos-pay-field { flex: 0 1 auto; min-width: 0; }
    .pos-pay-field.pos-pay-notes { max-width: 200px; }
    .pos-pay-field .form-select { max-width: 96px; }
    .pos-pay-field .form-input { max-width: 76px; }
    .pos-pay-field.pos-pay-notes .form-input { max-width: none; width: 100%; }
    .pos-pay-totals { flex: 0 0 auto; gap: 16px; }
    .pos-pay-stat { min-width: 96px; }
    .pos-pay-bar .pos-pay-btn { flex: 0 0 auto; white-space: nowrap; }
}

/* ── شاشات عريضة (≥1200): حقل العميل والملاحظة يمتصان الفائض بتوازن نسبي (بدون حقل عملاق) ── */
@media (min-width: 1200px) {
    .pos-pay-customer { max-width: min(24vw, 460px); }
    .pos-pay-field.pos-pay-notes { max-width: min(26vw, 480px); }
}

/* ── شاشة الكاشير بملء الصفحة (بدون هيدر ولا هوامش) — التابلت والشاشات الكبيرة ── */
@media (min-width: 768px) {
    /* قفل الجسم ضد الارتداد/التمرير المزدوج على iPad والتابلت أثناء الكاشير */
    body.pos-fullscreen {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }
    /* في ملء شاشة المتصفح الفعلي: منع تمرير الجذر حتى لا يقاوم تمرير المناطق الداخلية */
    html:fullscreen,
    html:-webkit-full-screen {
        overflow: hidden;
    }
    body.pos-fullscreen #app-header { display: none; }
    body.pos-fullscreen #bottom-nav { display: none; }
    body.pos-fullscreen #app { grid-template-rows: 0 1fr; }
    body.pos-fullscreen #app-main { padding: 8px; overflow: hidden; }
    body.pos-fullscreen .pos-layout { height: calc(100vh - var(--grace-banner-h, 0px) - 16px); height: calc(100dvh - var(--grace-banner-h, 0px) - 16px); }
}

/* ── الديسكتوب/الشاشات الكبيرة (≥1024): الكاشير يملأ الشاشة بالكامل — إخفاء الشريط الجانبي ── */
@media (min-width: 1024px) {
    body.pos-fullscreen #sidebar { display: none !important; }
    body.pos-fullscreen #app {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        grid-template-areas: "main";
    }
}

/* ── كثافة مضغوطة للتابلت والشاشات القصيرة: عناصر أصغر = منتجات أكثر (16.123.0) ── */
@media (min-width: 768px) and (max-width: 1199px),
       (min-width: 1200px) and (max-height: 820px) {
    .pos-layout { gap: 6px; padding: 2px; }
    .pos-panes { gap: 8px; }
    .pos-topbar { gap: 6px; }
    .pos-topbar h2 { font-size: 15px; }
    .pos-topbar .btn { padding: 3px 10px; font-size: 12px; }

    /* رؤوس بطاقات مضغوطة */
    .pos-products-card .card-header,
    .pos-cart-card .card-header { padding: 6px 10px; }
    .pos-products-card .card-title,
    .pos-cart-card .card-title { font-size: 15px; }
    .pos-products-card .form-input { padding: 6px 10px; font-size: 14px; }
    .pos-products-body,
    .pos-cart-body { padding: 8px; }

    /* شريط الفئات العمودي: مقاسات الصور/النصوص تُضبط في كتلة (min-width:768px) أعلاه — مكبّرة */

    /* بلاطات منتجات أدق */
    .pos-product-btn { padding: 6px 6px 8px !important; gap: 4px !important; }

    /* شريط دفع مضغوط */
    .pos-pay-footer { padding: 8px 10px; }
    .pos-pay-footer .form-group { margin-bottom: 4px !important; }
    .pos-pay-footer .form-label { font-size: 12px; margin-bottom: 2px; }
    .pos-pay-footer .form-input,
    .pos-pay-footer .form-select { padding: 6px 10px; font-size: 14px; }
    .pos-pay-btn { padding: 10px; font-size: 14px; }
    .pos-pay-total { font-size: 14px; margin-bottom: 6px; }
    .pos-pay-actions { margin-top: 6px; }
    .pos-pay-secondary { margin-top: 4px; }

    /* شريط الدفع الأفقي مضغوط */
    .pos-pay-bar { padding: 6px 8px; gap: 6px 10px; }
    .pos-pay-bar .form-label { font-size: 10px; margin-bottom: 2px; }
    .pos-pay-bar .form-input,
    .pos-pay-bar .form-select { padding: 6px 8px; font-size: 13px; }
    .pos-pay-stat b { font-size: 26px; }
    .pos-pay-stat.pos-pay-stat-change b { font-size: 24px; }
    .pos-pay-bar .pos-pay-btn { padding: 8px 18px; font-size: 14px; }
}

/* ── تابلت أفقي قصير جداً (≤700px ارتفاع): إخفاء العنوان ليتسع شريط الجلسة ── */
@media (min-width: 900px) and (max-height: 700px) {
    .pos-topbar h2 { display: none; }

    /* بلاطات أدق + إخفاء سطر المخزون = صفوف منتجات أكثر */
    .pos-layout .pos-products-card .card-header { padding: 5px 8px; }
    .pos-layout .pos-products-body { padding: 6px; }
    .pos-layout .pos-grid { gap: 6px; }
    .pos-layout .pos-product-btn > div:nth-of-type(3) { display: none; }
}

/* ── تابليت (768–1023): 3 ألواح + فئات عمودية إجبارية ── */
@media (min-width: 768px) and (max-width: 1023px) {
    .pos-layout {
        height: calc(100vh - var(--header-height) - var(--nav-height) - var(--grace-banner-h, 0px) - 32px);
        height: calc(100dvh - var(--header-height) - var(--nav-height) - var(--grace-banner-h, 0px) - 32px);
        min-height: 0;
    }
    .pos-panes {
        flex: 1;
        min-height: 0;
        flex-wrap: nowrap;
        display: grid;
        grid-template-columns: 100px minmax(0, 1fr) clamp(280px, 34vw, 340px);
        grid-template-areas: "cats products cart";
    }
    .pos-cats-pane { grid-area: cats; width: auto; min-height: 0; min-width: 0; }
    .pos-cats-pane .pos-cats-card { height: 100%; }
    .pos-products-pane { grid-area: products; min-width: 0; min-height: 0; }
    .pos-cart-pane { grid-area: cart; min-width: 0; min-height: 0; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }

    /* شريط الدفع مضغوط ليتسع سطراً واحداً بلا التفاف */
    .pos-pay-customer { min-width: 90px; max-width: 150px; }
    .pos-pay-field.pos-pay-notes { max-width: 150px; }
    .pos-pay-field .form-select { max-width: 88px; }
    .pos-pay-field .form-input { max-width: 64px; }
    .pos-pay-field.pos-pay-notes .form-input { max-width: none; width: 100%; }
    .pos-pay-totals { gap: 10px; }
    .pos-pay-stat { min-width: 80px; }
    .pos-pay-bar .pos-pay-btn { padding: 8px 12px; }
}

/* ── لابتوب/تابليت عريض (1024–1199): 3 ألواح + فئات عمودية إجبارية ── */
@media (min-width: 1024px) and (max-width: 1199px) {
    .pos-layout {
        height: calc(100vh - var(--header-height) - var(--grace-banner-h, 0px) - 48px);
        height: calc(100dvh - var(--header-height) - var(--grace-banner-h, 0px) - 48px);
        min-height: 0;
    }
    .pos-panes {
        flex: 1;
        min-height: 0;
        flex-wrap: nowrap;
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr) clamp(300px, 30vw, 360px);
        grid-template-areas: "cats products cart";
    }
    .pos-cats-pane { grid-area: cats; width: auto; min-height: 0; min-width: 0; }
    .pos-cats-pane .pos-cats-card { height: 100%; }
    .pos-products-pane { grid-area: products; min-width: 0; min-height: 0; }
    .pos-cart-pane { grid-area: cart; min-width: 0; min-height: 0; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
}

/* ── الشاشات الكبيرة (≥1200): 3 ألواح تملأ الشاشة — نمط كاشير التابلت ── */
@media (min-width: 1200px) {
    .pos-layout {
        height: calc(100vh - var(--header-height) - var(--grace-banner-h, 0px) - 48px);
        height: calc(100dvh - var(--header-height) - var(--grace-banner-h, 0px) - 48px);
        min-height: 540px;
    }
    .pos-panes {
        flex: 1;
        min-height: 0;
        flex-wrap: nowrap;
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr) clamp(340px, 26vw, 420px);
        grid-template-areas: "cats products cart";
        gap: 10px;
    }
    .pos-cats-pane { grid-area: cats; width: auto; min-height: 0; }
    .pos-cats-pane .pos-cats-card { height: 100%; }
    .pos-products-pane { grid-area: products; min-width: 0; min-height: 0; }
    .pos-cart-pane { grid-area: cart; min-width: 0; min-height: 0; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }

    /* الفئات عمودية (يمين الشاشة) بأيقونات كبيرة */
    .pos-cats-pane .pos-cat-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        overflow-x: hidden;
        overflow-y: auto;
        gap: 8px;
        padding: 8px;
        height: 100%;
    }
    .pos-cats-pane .pos-cat-bar > span { display: none; } /* فاصل │ */
    .pos-cats-pane .pos-cat-bar .pos-cat-chip,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center;
        gap: 6px !important;
        padding: 10px 4px !important;
        border-radius: 14px !important;
        white-space: normal !important;
        width: 100%;
        font-size: 15px !important;
        flex-shrink: 0;
    }
    .pos-cats-pane .pos-cat-bar .pos-cat-chip img,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip img {
        width: 72px !important;
        height: 72px !important;
    }
    .pos-cats-pane .pos-cat-bar .pos-cat-chip > span:first-child,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip > span:first-child {
        width: 72px !important;
        height: 72px !important;
        font-size: 30px !important;
    }
    .pos-cats-pane .pos-fav-chip > span:last-child { display: none; } /* سعر المفضلة */
}

/* ── شاشات عريضة لكن قصيرة (تابلت لاندسكيب 800px ارتفاع): ألواح أدق ── */
@media (min-width: 1200px) and (max-height: 820px) {
    .pos-panes {
        grid-template-columns: 108px minmax(0, 1fr) clamp(320px, 25vw, 380px);
    }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    /* شريط الفئات العمودي أدق */
    .pos-cats-pane .pos-cat-bar .pos-cat-chip,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip {
        padding: 6px 2px !important;
        gap: 4px !important;
        font-size: 13px !important;
    }
    .pos-cats-pane .pos-cat-bar .pos-cat-chip img,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip img,
    .pos-cats-pane .pos-cat-bar .pos-cat-chip > span:first-child,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip > span:first-child {
        width: 60px !important;
        height: 60px !important;
    }
    .pos-cats-pane .pos-cat-bar .pos-cat-chip > span:first-child,
    .pos-cats-pane .pos-cat-bar .rest-cat-chip > span:first-child { font-size: 20px !important; }
}

/* ============================================================
   الشريط الجانبي المطوي (الشاشات الكبيرة) — 16.121.0
   مطوي افتراضياً ليتسع المحتوى (منتجات أكثر)، يُفتح مؤقتاً كدرج
   ============================================================ */
#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-header);
}
#sidebar-backdrop {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + var(--grace-banner-h, 0px));
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 950;
}
@media (min-width: 1024px) {
    #sidebar-toggle {
        display: inline-flex;
        align-items: center;
        color: var(--text-primary);
    }
    /* مطوي: عمود الشريط = 0، والشريط نفسه يتحول درج منزلق فوق المحتوى */
    #app.sidebar-collapsed { grid-template-columns: 0 1fr; }
    #app.sidebar-collapsed #sidebar {
        position: fixed;
        top: calc(var(--header-height) + var(--grace-banner-h, 0px));
        inset-inline-start: 0;
        width: var(--sidebar-width);
        height: calc(100vh - var(--header-height) - var(--grace-banner-h, 0px));
        z-index: 960;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    html[dir="rtl"] #app.sidebar-collapsed #sidebar { transform: translateX(100%); }
    #app.sidebar-collapsed.sidebar-open #sidebar { transform: translateX(0); }
    html[dir="rtl"] #app.sidebar-collapsed.sidebar-open #sidebar { transform: translateX(0); }
    #app.sidebar-collapsed.sidebar-open #sidebar-backdrop { display: block; }
    /* أيقونة الإغلاق عند فتح الدرج */
    #sidebar-toggle .ic-close { display: none; }
    #app.sidebar-collapsed.sidebar-open #sidebar-toggle .ic-menu { display: none; }
    #app.sidebar-collapsed.sidebar-open #sidebar-toggle .ic-close { display: block; }
}

/* ============================================================
   نافذة «إتمام البيع» (كاشير + طاولات) — بلا شريط تمرير عمودي:
   كل المحتوى يظهر محتوياً في كل الشاشات (كبيرة/تابلت/صغيرة)
   ============================================================ */
.pay-confirm-box {
    display: flex;
    flex-direction: column;
    width: min(460px, 100%);
    max-height: calc(100dvh - 20px);
    overflow: hidden;
    border-radius: 18px;
    padding: 14px 16px;
    background: var(--bg-card, #fff);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}
.pay-confirm-title { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.pay-confirm-items {
    border: 1px solid var(--border-color, #eee);
    border-radius: 10px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: var(--bg, #fafafa);
    max-height: 96px;
    overflow: hidden;
    flex-shrink: 0;
}
.pay-confirm-gross {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}
/* 💵 مبلغ «الإجمالي قبل الخصم» كان بخطّ التسمية نفسه (12px على الشاشات القصيرة) فيكاد لا يُقرأ
   بجانب «المستحق» الكبير — صار رقماً بارزاً مستقلاً بحجمه. */
.pay-confirm-gross-value {
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
    direction: ltr;
    white-space: nowrap;
}
.pay-confirm-discount {
    background: #f3f8ff;
    border: 1px solid #bbdefb;
    border-radius: 12px;
    padding: 8px 10px;
    margin-bottom: 6px;
}
.pay-confirm-discount-title { font-size: 12px; font-weight: 800; color: var(--info-text); margin-bottom: 6px; }
.pay-confirm-payable {
    text-align: center;
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 6px;
    color: var(--color-primary);
}
.pay-confirm-box .form-group { margin-bottom: 6px; }
.pay-confirm-warn {
    font-size: 11px; font-weight: 700; color: #c62828;
    background: #ffebee; border: 1px solid #ef9a9a;
    border-radius: 8px; padding: 6px 8px; margin-bottom: 6px;
}
.pay-confirm-notes {
    font-size: 11px; color: #795548; background: #fff8e1;
    border: 1px solid #ffe082; border-radius: 8px;
    padding: 5px 8px; margin-bottom: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pay-confirm-hint { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.4; }
.pay-confirm-change {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    margin: 6px 0 8px;
    padding: 10px 12px;
    background: var(--bg, #fafafa);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
}
.pay-confirm-change > span:first-child { font-size: 14px; color: var(--text-muted); }
.pay-confirm-change > span:last-child { font-size: 24px; font-weight: 900; color: var(--color-primary); direction: ltr; }
.pay-confirm-actions { display: flex; gap: 10px; }
.pay-confirm-actions .btn { flex: 1; padding: 12px 16px; font-size: 15px; font-weight: 800; }

/* شاشات قصيرة (ارتفاع ≤ 700px): ضغط إضافي تلقائي — يبقى بلا تمرير */
@media (max-height: 700px) {
    .pay-confirm-box { padding: 10px 12px; max-height: calc(100dvh - 8px); border-radius: 14px; }
    .pay-confirm-title { font-size: 15px; margin-bottom: 4px; }
    .pay-confirm-items { max-height: 58px; padding: 4px 8px; margin-bottom: 4px; }
    .pay-confirm-gross { font-size: 12px; }
    .pay-confirm-gross-value { font-size: 18px; }
    .pay-confirm-discount { padding: 6px 8px; margin-bottom: 4px; }
    .pay-confirm-discount-title { font-size: 10px; margin-bottom: 3px; }
    .pay-confirm-payable { font-size: 18px; margin-bottom: 4px; }
    .pay-confirm-box .form-group { margin-bottom: 4px; }
    .pay-confirm-box .form-label { font-size: 10px; margin-bottom: 1px; }
    .pay-confirm-box .form-input, .pay-confirm-box .form-select { padding: 5px 8px; font-size: 13px; }
    .pay-confirm-change { padding: 8px 10px; margin: 4px 0 6px; }
    .pay-confirm-change > span:last-child { font-size: 20px; }
    .pay-confirm-actions .btn { padding: 10px 14px; font-size: 14px; }
}

/* شاشات قصيرة جداً (ارتفاع ≤ 560px — وضع أفقي): إخفاء ما هو متاح في الكاشير خلف النافذة */
@media (max-height: 560px) {
    .pay-confirm-gross { display: none; }
    .pay-confirm-discount { display: none; }
    .pay-confirm-box .form-group { margin-bottom: 3px; }
    .pay-confirm-change { margin: 3px 0 5px; }
}

/* 🛵 نبض زر طلبات التوصيل عند وصول طلب جديد (حركة + توهج أحمر) */
@keyframes po-pulse {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.55); }
    55%  { transform: scale(1.07); box-shadow: 0 0 0 10px rgba(198, 40, 40, 0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}
.po-btn-alert {
    animation: po-pulse 1.1s ease-out 3;
    border-color: #c62828 !important;
    color: #c62828 !important;
    background: #ffebee !important;
    font-weight: 800 !important;
}

/* ⏳ عناصر بانتظار إرسالها للمطبخ (طلبات الزبائن) — نبض دائم يلفت الموظف */
.pulse-attn {
    animation: po-pulse 1.2s ease-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   🖥️ وضع تطبيق شاشة القاعات (body.screen-app)
   القالب (/hs/) يضيف الصنف من الخادم قبل أي سكربت ⇒ الشل مخفي من الإطار
   الأول، ويعيد التطبيق تأكيده (حراسة ثانية في renderScreen).
   ═══════════════════════════════════════════════════════════════ */
body.screen-app { background: #0b1220 !important; }
body.screen-app #app-header,
body.screen-app #sidebar,
body.screen-app #bottom-nav,
body.screen-app #sidebar-backdrop { display: none !important; }

/* غطاء بدء شاشة القاعات — أبيض مطابق لشاشة البداية الأصلية، يُزال بعد أول رسم للوحة */
#hs-boot {
    position: fixed; inset: 0; z-index: 99999; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 14px;
    background: #ffffff; color: #1f2937; transition: opacity .25s ease;
}
#hs-boot.hs-boot-out { opacity: 0; pointer-events: none; }
#hs-boot img { max-width: 110px; max-height: 110px; border-radius: 14px; }
#hs-boot .hs-boot-sp {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(31,41,55,.18); border-top-color: #2563eb;
    animation: hsBootSpin .9s linear infinite;
}
#hs-boot .hs-boot-t { font-size: 15px; font-weight: 700; color: #1f2937; }
@keyframes hsBootSpin { to { transform: rotate(360deg); } }

/* ═══════════ 🧭 ترويسة شاشة: العنوان سطره وحده · والأزرار بجانب بعضها أفقياً ═══════════
   ⚠️ بلاغ المالك (2026-09-21): العنوان كان يلتفّ لأنه يتقاسم السطر مع زرّين على الجوال،
      والمطلوب: **العنوان سطر مستقل بلا التفاف** والزرّان **بجانب بعضهما أفقياً**.
   `text-overflow:ellipsis` يضمن سطراً واحداً حتى في أضيق شاشة (بلا كسر حرف). */
.page-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.page-head .ph-title {
    margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.page-head .ph-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: stretch; }
.page-head .ph-actions .btn {
    flex: 1 1 0; min-width: 0; width: auto; height: 38px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    /* حدود شفّافة موحّدة: الزرّ المحدَّد (outline) كان أوسع بـ2px من الأساسي */
    border: 1px solid transparent;
}
.page-head .ph-actions .status-badge { flex: 0 0 auto; }
@media (max-width: 640px) {
    .page-head .ph-title { font-size: 16px; }
    .page-head .ph-actions { gap: 8px; }
}
