/* ============================================================
   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: #2b2d42; margin-bottom: 4px;
}
.login-sub {
    font-size: 13px; color: #4b5563;
    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;
    --bg-header: #3d5a80;
    /* ترويسة الديسكتوب بيضاء (مختلفة عن ترويسة الجوال الملوّنة) — صارت متغيّراً ليتبع الطابع الداكن */
    --bg-header-desktop: #ffffff;
    --bg-nav: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-input: #ffffff;
    --bg-hover: #f0f0eb;
    /* متغيّرات كانت مستعملة بقيم احتياطية داخلية (var(--card-bg,#fff) في كل النوافذ…) */
    --card-bg: #ffffff;
    --bg-muted: #f1f3f5;
    --bg: #fafafa;
    --skeleton: #e9ecef;
    --border: #dee2e6;
    --color-surface: #ffffff;

    /* 🎨 لون الهوية **للنص والإطار** — يختلف عن لون الخلفية في الطابع الداكن */
    --color-primary-text: #3d5a80;
    /* ألوان دلالية للنص فوق البطاقات — تُفتَّح في الطابع الداكن */
    --info-text: #1565c0;
    --danger-text: #c62828;
    --success-text: #2e7d32;
    --warn-text: #856404;

    /* 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;
    /* كانت مستعملة في app.css بلا تعريف ⇒ تسقط للقيمة الافتراضية للمتصفح */
    --font-size-icon: 28px;
    --font-size-label: 12px;

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

/* ============================================================
   🎨 الطابع (Theme) — فاتح / داكن / تلقائي
   يُطبَّق بـ`<html data-theme="dark">` من `Utils.applyTheme` فقط.
   الفكرة: كل الأسطح مبنية من متغيّرات CSS ⇒ إعادة تعريف المتغيّرات = طابع كامل.
   و`color-scheme: only light/dark` (يُضبط من JS) يمنع المتصفحات من قلب الألوان تلقائياً
   في الوضع الداكن على الأجهزة اللوحية/الجوال.
   ملاحظة: `app/templates/kiosk.html` قالب مستقل لا يحمّل هذا الملف ⇒ غير متأثّر.
   ============================================================ */
html[data-theme="dark"] {
    --bg-body: #0f1420;
    --bg-card: #182031;
    --card-bg: #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;
    --color-surface: #182031;

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

    --border-color: #2a3446;
    --border: #2a3446;

    --color-primary-text: #9ec1ee;
    --info-text: #90caf9;
    --danger-text: #ef9a9a;
    --success-text: #a5d6a7;
    --warn-text: #f0c974;

    /* تينتات الحالات: داكنة بنفس هوية اللون */
    --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);
}

/* 🟦 نصوص/أزرار بلون الهوية الغامق ⇒ لا تُقرأ على أسطح داكنة */
html[data-theme="dark"] .nav-item.active,
html[data-theme="dark"] .text-primary,
html[data-theme="dark"] .tab-btn.active,
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"] .btn-outline,
html[data-theme="dark"] .tab-btn.active { border-color: var(--color-primary-text); }
/* شريحة الاسم: بلا خلفية سطرية ⇒ لون نصّ فاتح؛ ومع خلفية لوحة فاتحة ⇒ يبقى داكناً */
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"] [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; }
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; }

/* 🗓️ تقويم «حضوري» في الوضع الداكن (شكوى المالك: «اللون الأخضر للنص لم يظهر»):
   الخلايا كانت تبقى **فاتحة** وألوان الحالة داكنة (#15803d على #182031 = لا تناقض لوني)
   ⇒ خلفيات ليلية مخصّصة لكل حالة، ونصّ الحالة نفسه يصير أفتح من JS (`ST_DARK`). */
html[data-theme="dark"] .p-cal { background: #0f1420; }
html[data-theme="dark"] .p-cal-w { background: #131a29; color: #94a3b8; }
html[data-theme="dark"] .p-cal-w.wknd { color: #f87171; }
html[data-theme="dark"] .p-cal-d { background: #182031; }
html[data-theme="dark"] .p-cal-d:hover { background: #223049; }
html[data-theme="dark"] .p-cal-d.out { background: #141b28; }
html[data-theme="dark"] .p-cal-d.out .p-cal-num { color: #4b5563; }
html[data-theme="dark"] .p-cal-d.wknd { background: #161d2c; }
html[data-theme="dark"] .p-cal-d.today { background: #1c2b46; }
html[data-theme="dark"] .p-cal-d.st-leave { background: #15253c; }
html[data-theme="dark"] .p-cal-d.st-absent { background: #2c1519; }
html[data-theme="dark"] .p-cal-d.st-missing_punch { background: #2c2413; }
html[data-theme="dark"] .p-cal-d.st-holiday { background: #221b3a; }
html[data-theme="dark"] .p-cal-d.st-holiday_worked { background: #122a24; }
html[data-theme="dark"] .p-cal-num { color: #cbd5e1; }
/* «ورقة» بيضاء (معاينة طباعة على الشاشة) تبقى بنصّها الداكن */
html[data-theme="dark"] [style*="background:#fff"] { color: #2b2d42; }
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*="color:#1a1a2e"],
html[data-theme="dark"] [style*="color: #1a1a2e"],
html[data-theme="dark"] [style*="color:#2b2d42"],
html[data-theme="dark"] [style*="color: #2b2d42"],
html[data-theme="dark"] [style*="color:#222"] { color: var(--text-primary) !important; }
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color:#666"] { color: var(--text-muted) !important; }
/* عنصر «غير مقروء» بخلفية زرقاء فاتحة سطرية ⇒ تُعتَّم */
html[data-theme="dark"] [style*="background:#f0f7ff"] { background: rgba(33,150,243,0.12) !important; }

/* ── نصوص ملوّنة مثبّتة داخل الكود (شاشات) — تُفتَّح في الداكن وإلا اختفت ──
   الاستثناء `:not([style*="background:#d|e|f"])`: عنصر يحمل خلفية **فاتحة صلبة** بنفسه
   (شريحة `background:#fee2e2;color:#b91c1c`) يبقى بنصّه الداكن لأن خلفيته فاتحة.
   أما الخلفيات الشفافة الداكنة (`background:#b91c1c1a`) أو الداكنة الصلبة (`#0f766e`)
   فتبقى في القائمة ⇒ نصّها يُفتَّح.
   ⚠️ ملاحظة أولوية: القواعد كلها ملفوفة بـ`:where()` **لتكون أولويتها دنيا**، كي تتقدّم عليها
   قاعدة «الجزر الفاتحة» أدناه — وهي التي تعالج حالة الخلفية الفاتحة على **الأب** والنصّ الداكن
   على **الابن** (وهي التي أظهرت شكوى «الإشعارات بلون أصفر غير مقروء»). */
html[data-theme="dark"] :where(
[style*="color:#b91c1c"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color: #b91c1c"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#c62828"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#b71c1c"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#991b1b"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#d32f2f"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #fca5a5 !important; }
html[data-theme="dark"] :where(
[style*="color:#b45309"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#92400e"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#b26a00"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#e65100"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #fcd34d !important; }
html[data-theme="dark"] :where(
[style*="color:#2e7d32"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#15803d"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#166534"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#33691e"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#065f46"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #86efac !important; }
html[data-theme="dark"] :where(
[style*="color:#1e40af"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#1d4ed8"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#1565c0"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#0d47a1"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #93c5fd !important; }
html[data-theme="dark"] :where(
[style*="color:#0f766e"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #5eead4 !important; }
html[data-theme="dark"] :where(
[style*="color:#7b1fa2"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color:#6d28d9"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: #d8b4fe !important; }
/* لون الهوية كبديل مضمَّن `var(--color-primary,#1565c0)` — النمط القديم لم يلتقطه */
html[data-theme="dark"] :where(
[style*="color:var(--color-primary,"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"]),
[style*="color: var(--color-primary,"]:not([style*="background:#d"]):not([style*="background:#e"]):not([style*="background:#f"])
) { color: var(--color-primary-text) !important; }
/* بطاقات الشبكة ذات التدرّجات الباستيل (مثبّتة في الكود) تبقى فاتحة ⇒ نصّها داكن */
html[data-theme="dark"] .quick-action-btn[style*="linear-gradient"] { color: #26323d; }
html[data-theme="dark"] .quick-action-btn[style*="linear-gradient"] .quick-action-label,
html[data-theme="dark"] .quick-action-btn[style*="linear-gradient"] span:not([style*="color:"]) {
    color: #26323d !important;
}
/* ── أولوية «الجزر الفاتحة» على قاعدة تفتيح النصوص ──
   المشكلة التي أُغلقت (شكوى: «الإشعارات في اللوحة الرئيسية بلون أصفر غير مقروء في الداكن»):
   خلفية الجزيرة الفاتحة تكون على **الأب** (`<div style="background:#fef3c7">`) بينما النصّ الداكن
   (`color:#92400e`) على **ابنٍ** فيه ⇒ قاعدة التفتيح (تشترط ألا يكون العنصر نفسه بلون فاتح)
   كانت تفتّح النصّ فيصير عنبرياً فاتحاً على أصفر فاتح (تباين 1.29 ✗).
   الحلّ: أي نصّ ملوّن داخل جزيرة فاتحة يَرِث لون الجزيرة (داكناً) — لأن خلفيته فاتحة فعلاً.
   (المحدّدان يجعلان الأولوية أعلى من قواعد التفتيح أحادية المحدِّد، و`:not([style*="background:"])`
   يترك الشرائح التي تحمل خلفيتها الخاصة — مثل `color:#fef3c7;background:#3b2f0f` — بلا مساس.) */
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:"]) {
    color: inherit !important;
}

/* أسطح كانت ألوانها مثبّتة داخل CSS */
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,
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); }

/* الطباعة تبقى فاتحة دائماً (ورق أبيض) — قواعد `@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%;
    /* ⚠️ ممنوع `font-variant-emoji: emoji` هنا: الأرقام 0-9 لها وجه إيموجي (لوحة مفاتيح)
       فصار كل رقم يُرسم مربّعاً أزرق بداخله الرقم ⇒ تواريخ وساعات وأرقام في مربّعات.
       العرض الإيموجي يُطلب للعناصر المخصّصة للأيقونات وحدها (القاعدة أدناه). */
}

/* 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);
}

/* 🍎 الوضع المستقل على آيفون/الآيباد: شريط الحالة **يطفو فوق الصفحة** (black-translucent
   في`spa_index.html`) ⇒ بلا هذه الإزاحة تختفي أزرار الترويسة (الجرس/اللغة/الحساب) تحته.
   `env(safe-area-inset-top)` = 0 على أندرويد/الكمبيوتر فلا يتغيّر شيء هناك. */
@media (display-mode: standalone) {
    #app-header {
        height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
    }
    .toast-container, .app-toast { margin-top: env(safe-area-inset-top, 0px); }
}

#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 — تلطيف خفيف فقط (كان 13/9px فيصعب قراءته) */
.header-clock-compact #header-time {
    font-size: 19px !important;
}
.header-clock-compact #header-date {
    font-size: 12px !important;
}

/* الموبايل: تكبير الساعة والتاريخ (يوجد فسحة — يُقاس بـ clamp حتى لا يقتطع النص) */
@media (max-width: 640px) {
    #header-clock {
        min-width: 100px;
    }
    #header-time {
        font-size: clamp(20px, 5.8vw, 26px) !important;
        letter-spacing: 0.5px;
        font-weight: 800;
    }
    #header-date {
        font-size: clamp(11.5px, 3.3vw, 14px) !important;
        opacity: 0.95;
    }
    /* العنوان يفسح للوقت (يُقتطع بنقاط عند الحاجة بدل دفعه) */
    #header-title {
        font-size: 16px;
        min-width: 0;
    }
    .header-title-compact {
        font-size: 15px !important;
        max-width: 108px;
    }
    .header-clock-compact #header-time {
        font-size: clamp(19px, 5.4vw, 24px) !important;
    }
    .header-clock-compact #header-date {
        font-size: clamp(11px, 3.1vw, 13px) !important;
    }
}

/* الموبايل الضيّق: **العنوان أهم من الساعة** — الموظف يجب أن يعرف في أي شاشة/بطاقة هو،
   وكان قِصَر العنوان (108px) يقطع «ملف الموظف» ويُخفي اسم القسم المعروض. */
@media (max-width: 480px) {
    .header-title-compact {
        max-width: none !important;
        flex: 1 1 auto;
        min-width: 0;
    }
    .header-clock-compact {
        min-width: 0;
        flex-shrink: 1;
    }
    .header-clock-compact #header-time {
        font-size: 17px !important;
        letter-spacing: 0;
    }
    .header-clock-compact #header-date {
        font-size: 10.5px !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;
}

/* ── شاشات الموظف: بطاقات كالبرنامج الرئيسي (بطاقتان في السطر على الموبايل) ──
   كانت الشاشات تستعمل شبكة بعرض 250-300px للبطاقة ⇒ عمود واحد على الجوال،
   أو جداول بتمرير أفقي (شكوى المستخدم: «لماذا لا تكون كبطاقات… كل بطاقتان على سطر؟»). */
.p-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
@media (min-width: 768px) {
    .p-cards { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
}
.p-cards > * { min-width: 0; }          /* يمنع انسحاق/تمدّد الخلية في الشبكة */
/* شبكة بطاقات التنقّل في «بوابتي» — بطاقتان في السطر على الموبايل (كنمط شاشات النظام) */
.p-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
@media (min-width: 768px) {
    .p-nav { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
.p-nav > .quick-action-btn { min-height: 96px; }
.p-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--card-bg, #fff);
    min-width: 0;
}
.p-card-t {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 12.5px;
    margin-bottom: 6px;
    min-width: 0;
    flex-wrap: wrap;                  /* التاريخ + الشارة يلتفّان في البطاقة نصف العرض */
}
.p-card-t > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.p-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    padding: 2px 0;
    min-width: 0;
}
.p-row > span:first-child { color: var(--text-muted); min-width: 0; }
.p-row > b, .p-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.p-muted { font-size: 11.5px; color: var(--text-muted); line-height: 1.7; }
.p-badge {
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 11.5px;
    white-space: nowrap;
    max-width: 100%;                  /* لا يفيض في بطاقة نصف العرض */
    overflow: hidden;
    text-overflow: ellipsis;
}
.p-big { font-size: 18px; font-weight: 800; }

/* ══════════════════════════════════════════════════════════════
   نظام عرض شاشات الموظف (v2.6) — لكل **نوع معلومات** شكله المناسب:
   قسم/عنوان · بطاقة تعريف · مربّع رقم · صف كامل للطلبات · تقويم للشهر ·
   خط زمني للبصمات · شرائح فلترة · شرائط أرصدة. كلها بمساحات مريحة.
   ══════════════════════════════════════════════════════════════ */
.p-sec { margin-bottom: 18px; }
.p-sec-h {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 10px; font-size: 14.5px; font-weight: 800;
}
.p-sec-h .hint { margin-inline-start: auto; font-size: 11.5px; font-weight: 600;
                 color: var(--text-muted); }
.p-hero {
    border: 1px solid var(--border-color); border-radius: 18px; padding: 16px;
    background: var(--card-bg, #fff);
}
.p-avatar {
    width: 60px; height: 60px; border-radius: 50%; background: #0f766e1a;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    line-height: 1; flex-shrink: 0; overflow: hidden;
}
.p-name { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden;
          text-overflow: ellipsis; }   /* سطر واحد دائمًا: الاسم الطويل يُقطع بنقاط لا يلتفّ */
.p-sub { font-size: 12px; color: var(--text-muted); }
.p-inline-pill { border-radius: 999px; padding: 2px 9px; font-size: 11.5px; }
/* مربّعات الأرقام: رقم كبير + تسمية صغيرة (واضح لا مضغوط) */
.p-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 768px) {
    .p-tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
.p-tile {
    border: 1px solid var(--border-color); border-radius: 14px; padding: 12px 14px;
    background: var(--card-bg, #fff); min-width: 0;
    /* ⬛ توسيط الرقم وعنوانه داخل البلاطة: كانا ملتصقين بالحافة (بداية السطر في RTL)
       فتظهر الأرقام مبعثرة في صفّ من البلاطات (طلب المالك: «النص توسيط في المربع»). */
    text-align: center;
}
.p-tile-v { font-size: 23px; font-weight: 800; line-height: 1.15;
            font-variant-numeric: tabular-nums; }
.p-tile-l { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
/* الصفوف والبطاقات الكاملة العرض (الطلبات/الكشوف) */
.p-list { display: flex; flex-direction: column; gap: 10px; }
.p-item {
    border: 1px solid var(--border-color); border-radius: 14px; padding: 13px 14px;
    background: var(--card-bg, #fff);
}
.p-item-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-item-t { font-size: 14px; font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.p-pill { border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700;
          white-space: nowrap; }
.p-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px;
          color: var(--text-muted); margin-top: 7px; }
/* جدول حقول (تسمية | قيمة) — لملف الموظف والعقد: قراءة سطراً سطراً بلا التفاف نصّ متجاور */
.p-table-w { border: 1px solid var(--border-color); border-radius: 12px;
             overflow: hidden; background: var(--card-bg, #fff); }
.p-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.p-table th, .p-table td { padding: 8px 11px; text-align: start; vertical-align: top;
                           border-bottom: 1px solid var(--border-color); }
.p-table th { font-size: 11.5px; font-weight: 600; color: var(--text-muted);
              background: var(--bg-hover, #f7f9fb); width: 42%; }
.p-table td { font-weight: 700; overflow-wrap: anywhere; }
.p-table tr:last-child th, .p-table tr:last-child td { border-bottom: none; }
@media (max-width: 380px) {
    .p-table th, .p-table td { padding: 7px 8px; font-size: 12.5px; }
}
.p-meta b { color: var(--text-primary, #212529); font-variant-numeric: tabular-nums; }
.p-bar { height: 7px; border-radius: 99px; background: var(--bg-hover, #eef1f4);
         overflow: hidden; margin-top: 7px; }
.p-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--color-primary); }
/* ── أدوات الشاشة: صف أزرار متناسق + شريط الشهر + شريط البصمة الثابت ── */
.p-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.p-toolbar > .btn { flex: 1 1 0; min-width: 132px; justify-content: center; }
.p-month-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-hover, #f4f6f8);
    border: 1px solid var(--border-color); border-radius: 12px; padding: 6px;
}
.p-arrow {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
    border: 1px solid var(--border-color); background: var(--card-bg, #fff);
    color: var(--text-secondary); font-size: 20px; line-height: 1; cursor: pointer;
}
.p-arrow:active { background: var(--bg-hover, #eef1f4); }
.p-month-title {
    flex: 1; min-width: 0; border: none; background: transparent; cursor: pointer;
    font-size: 15px; font-weight: 800; color: var(--text-primary); font-family: inherit;
    padding: 6px 4px; text-align: center;
}
.p-month-title .caret { font-size: 11px; color: var(--text-muted); }
.p-month-bar > .p-chip { flex-shrink: 0; }
/* (أُزيلت أنماط شريط البصمة الثابت: زر البصمة انتقل إلى «بوابتي» وحدها —
   `p-punch-btn` ما زال مستخدَماً في بطاقة البصمة هناك) */
.p-punch-btn {
    width: 100%; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; padding: 9px 14px; border: none;
    border-radius: 12px; background: var(--primary, #2563eb); color: #fff;
    font-family: inherit; line-height: 1.2; cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
}
.p-punch-btn .l1 { font-size: 16.5px; font-weight: 800; }
.p-punch-btn .l2 { font-size: 11.5px; font-weight: 600; opacity: .85; }
.p-punch-btn .l2:empty { display: none; }
.p-punch-btn:active { transform: translateY(1px); }

/* تقويم الحضور — بنفس لغة تقويم البرنامج المرجعي:
   شبكة متّصلة بفواصل رقيقة (لا مربّعات منفصلة حول كل رقم)، ورقم اليوم صغير عادي،
   وخلفية الخلية تدلّ على الحالة، والكبسولات داخل الخلية للتفاصيل. */
.p-cal-w {
    text-align: center; font-size: 11px; font-weight: 800; letter-spacing: .3px;
    color: var(--text-muted); background: var(--bg-hover, #f4f6f8);
    border-bottom: 1px solid var(--border-color); padding: 9px 4px;
}
.p-cal-w.wknd { color: #b91c1c; }
.p-cal {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid var(--border-color);
    border-inline-start: 1px solid var(--border-color);
    border-radius: 12px; overflow: hidden; background: var(--card-bg, #fff);
}
.p-cal-d {
    min-height: 76px; padding: 6px; cursor: pointer; position: relative;
    border-bottom: 1px solid var(--border-color);
    border-inline-end: 1px solid var(--border-color);
    display: flex; flex-direction: column; gap: 3px; min-width: 0;
    transition: background .12s;
}
.p-cal-d:hover { background: var(--bg-hover, #f7f9fb); }
.p-cal-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 27px; height: 27px; border-radius: 50%;
    font-size: 12px; font-weight: 600; color: #4b5563;
}
.p-cal-d.today .p-cal-num { background: var(--color-primary); color: #fff; font-weight: 900; }
.p-cal-chip {
    border-radius: 6px; padding: 2px 6px; font-size: 10.5px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.p-cal-d.out { background: #f6f5ee; }
.p-cal-d.out .p-cal-num { color: #c9c4b4; }
.p-cal-d.wknd { background: #f8f6ee; }
.p-cal-d.today { background: #eaf2ff; }
.p-cal-d.sel { box-shadow: inset 0 0 0 2.5px var(--color-primary); }
.p-cal-d.st-leave { background: #eff6ff; }
.p-cal-d.st-absent { background: #fef2f2; }
.p-cal-d.st-missing_punch { background: #fffbeb; }
.p-cal-d.st-holiday { background: #f5f3ff; }
.p-cal-d.st-holiday_worked { background: #ecfdf5; }
@media (max-width: 430px) {
    /* خلايا مربّعة تقريباً (لا مستطيلات) واستغلال كامل عرض الشاشة */
    .p-cal-d { min-height: 0; aspect-ratio: 1 / 1; padding: 3px 2px; justify-content: center;
               align-items: center; gap: 2px; }
    .p-cal-num { width: 25px; height: 25px; font-size: 12.5px; }
    .p-cal-chip { font-size: 9.5px; padding: 1px 4px; }
    /* أزمنة الدخول/الخروج طويلة للخلية المربّعة ⇒ تُعرض في بطاقة اليوم تحتها */
    .p-cal-chip.times { display: none; }
    .p-cal-w { font-size: 10px; padding: 7px 2px; }
}
@media (min-width: 431px) {
    .p-cal-d { justify-content: center; align-items: center; }
    .p-cal-chip { max-width: 92%; }
}
.p-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px;
            font-size: 11.5px; color: var(--text-muted); }
.p-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px;
              margin-inline-end: 4px; vertical-align: -1px; }
/* فلتر نوع اليوم: الأيام غير المطابقة تُبهت (تبقى في مكانها فلا يضيع سياق التقويم) */
.p-cal-d.dim { opacity: .32; }
/* خط زمني للبصمات */
.p-tl-row { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0;
            border-bottom: 1px dashed var(--border-color); }
.p-tl-row:last-child { border-bottom: none; }
.p-tl-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.p-tl-t { font-size: 13.5px; font-weight: 700; }
.p-tl-s { font-size: 11.5px; color: var(--text-muted); }
/* شرائح الفلترة */
.p-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.p-chip {
    border: 1px solid var(--border-color); background: var(--card-bg, #fff);
    border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 700;
    cursor: pointer; color: var(--text-secondary);
}
.p-chip.on { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ── التبويبات (تُشارك فيها الإشعارات وملف الموظف وغيره) ──
   كانت في صفّ `display:flex; overflow-x:auto` بلا `flex-shrink:0` ⇒ تضغط الأزرار إلى 35px
   فيُقطع نصّها و**تتراكب** على الجوال (شكوى المستخدم). القاعدة: زر التبويب لا ينضغط
   (`flex:0 0 auto`) والصفّ **يلتفّ** فلا يبقى تبويب مخفيّاً في تمرير أفقي، ولا يُسحق نصّ. */
.p-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.p-tab {
    flex: 0 0 auto; white-space: nowrap; cursor: pointer; font-family: inherit;
    border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
    border: 1px solid var(--border-color); background: transparent;
    color: var(--text-secondary);
}
.p-tab.on { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.p-tab .n { border-radius: 9px; padding: 0 6px; font-size: 10.5px; margin-inline-start: 5px;
            background: var(--bg-hover, #eef1f4); color: var(--text-secondary); }
.p-tab.on .n { background: rgba(255, 255, 255, .28); color: #fff; }
@media (max-width: 420px) { .p-tab { padding: 5px 10px; font-size: 12px; } }
.p-empty { text-align: center; padding: 26px 14px; color: var(--text-muted); font-size: 13px; }

/* ============================================================
   Bottom Navigation (Mobile)
   ============================================================ */
/* ── الأيقونات إيموجي ملوّنة دائمًا ──
   على أندرويد/WebView وبعض التوزيعات تُطابق خطوط النص (Changa/Cairo/Segoe UI/Arial)
   رموزًا يُفترض أنها إيموجي فتُرسم **أشكالًا رمادية مسطّحة**. الحل: خطوط الإيموجي
   **أوّلًا** للعناصر المخصّصة للأيقونة + طلب العرض الإيموجي **هنا فقط** (لا على الصفحة
   كلها، وإلا صارت الأرقام مربّعات لوحة مفاتيح). */
.nav-icon, .empty-state-icon, .quick-action-icon, .lp-hero-icon, [data-emoji] {
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
                 'Twemoji Mozilla', 'EmojiOne Color', 'Android Emoji', 'Segoe UI Symbol', sans-serif;
    font-variant-emoji: emoji;
    font-style: normal;
    font-weight: 400;
    line-height: 1;
}

#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;
    /* ⚠️ stretch لا center: مع center كان العنصر الأطول من الشريط (تسمية من سطرين)
       يُوسّط فيخرج من الأعلى وتُقصّ أيقونته (شكوى المستخدم: «الأيقونات مقصوصة من الأعلى»). */
    align-items: stretch;
    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: 2px;
    padding: 7px 4px;
    color: var(--text-muted);
    height: var(--nav-height);        /* ارتفاع ثابت داخل الشريط فلا خروج ولا قصّ */
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    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: 30px;                  /* إيموجي أكبر وأوضح (طلب المستخدم) */
    line-height: 1;                   /* كان normal ⇒ يُقصّ أعلى الإيموجي */
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-label {
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.25;
    max-width: 100%;                 /* سطر واحد دائمًا: الطول الزائد يُقطع بنقاط */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.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;
    }
}

/* ============================================================
   بوابة الموظف: أزرار عائمة (الرئيسية + تسجيل الدخول/الخروج)
   قرار المستخدم: حذف الشريط السفلي من البوابة ⇒ التنقّل ببطاقات ملوّنة
   وأزرار عائمة ثابتة ترافق الموظف في كل شاشات بوابته.
   ⚠️ الأزرار تُضاف إلى `body` (لا داخل `#app` الذي شبكته Grid ⇒ خليّة صغيرة)
   ============================================================ */
#portal-fab {
    position: fixed;
    inset-inline-end: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
    z-index: 640;
    font-family: var(--font-family);
}
#portal-fab button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: none;
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15,23,42,.28);
    transition: transform var(--transition), filter var(--transition);
}
#portal-fab button:active { transform: scale(0.96); }
#portal-fab .pfab-punch { background: var(--color-primary); }
#portal-fab .pfab-home { background: #0f172a; }
#portal-fab .pfab-ico { font-size: 17px; line-height: 1; }
/* الأزرار العائمة تعلو آخر المحتوى ⇒ حشوة سفلية تمنع حجب أي بطاقة */
body.portal-fab-on #app-main { padding-bottom: 96px; }

/* ============================================================
   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;
}

.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); }
}

/* الموبايل (≤420px): 3 أعمدة مرنة بحد أدنى صغير حتى لا تنسحق البطاقات */
@media (max-width: 420px) {
    /* 3 بطاقات في الصف على الجوال: المتاح ≈264px بعد هوامش الصفحة والبطاقة
       (3×78 + فاصلان 6px = 246 ⇒ تتسع بلا انسحاق) */
    .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .quick-action-btn { padding: 10px 4px; min-height: 78px; }
    .quick-action-btn .quick-action-icon { font-size: 20px; }
    .quick-action-btn .quick-action-label { font-size: 10.5px; line-height: 1.2; }
    /* وصف البطاقة كان 7.5px (غير مقروء) — يُقرأ بلا تكبير الشاشة */
    .quick-action-btn span[style*="10px"] { font-size: 9px !important; }
}
/* التابلت: أعمدة تلقائية بدل رقم ثابت فيمتد الشكل الطبيعي */
@media (min-width: 600px) and (max-width: 768px) {
    .quick-actions { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}
@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;
}
.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;
}


/* ============================================================
   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-block` مستثنى لأنه مقصود بعرض كامل. */
.btn:not(.btn-block) {
    flex-shrink: 0;
}
.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);
}




/* ============================================================
   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%, #e9ecef 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: var(--bg-card);
    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, #portal-fab, .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;
    }
}

/* ============================================================
   جداول البنود — أكبر على سطح المكتب
   ============================================================ */
@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;
    }
}


/* ============================================================
   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;
    }
}



/* ============================================================
   الشريط الجانبي المطوي (الشاشات الكبيرة) — 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-hint { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; line-height: 1.4; }


/* ═══════════════════════════════════════════════════════════════
   (حُذفت أنماط «وضع تطبيق الشاشة» وغطاء البدء — HR بلا تطبيق شاشة منفصل)
   ═══════════════════════════════════════════════════════════════ */


/* ════════════════════════════════════════════════════════════════════════
   WP7 — تجربة الاستخدام · الاتجاه · صلاحية الوصول · الموبايل
   (طبقة واحدة موثّقة: الجداول · حلقة التركيز · تقليل الحركة · أهداف اللمس)
   ════════════════════════════════════════════════════════════════════════ */

/* ── 1) الجداول: شكل موحّد بدل 75 جدولاً بأنماط سطرية ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-card);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
    background: var(--bg-card);
}
.data-table caption {
    caption-side: top;
    text-align: start;
    padding: 8px 10px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}
.data-table th,
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: start;
    vertical-align: middle;
}
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-hover);
    font-weight: 700;
    white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td[data-numeric], .data-table .num { text-align: end; font-variant-numeric: tabular-nums; }

/* ── 2) حلقة تركيز مرئية لكل عنصر تفاعلي (كانت غائبة) ── */
:where(.btn, .nav-item, a, button, [role="button"], .tab, .chip,
       input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 0 0 4px rgba(61, 90, 128, 0.18);
}
/* الحقول: نحفظ إزالة الحلقة الافتراضية لكن نعوّضها بحلقة واضحة عند التنقل بالمفاتيح */
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}
/* تجاوز شريط التنقل السفلي: حلقة داخلية لئلا تُقص عند حدود الشاشة */
#bottom-nav :focus-visible { outline-offset: -3px; }

/* ── 3) تقليل الحركة (احترام إعداد النظام) ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .page-enter, .skeleton, .ptr-spinner { animation: none !important; }
}

/* ── 4) النوافذ المنبثقة: شكل موحّد (تُستخدم مع Utils.openModal) ── */
.hr-modal-overlay { overscroll-behavior: contain; }
.hr-modal-card { max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); }

/* ── 5) الموبايل: أهداف لمس ≥44px وكثافة جدول أقل ── */
@media (max-width: 1023px), (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; padding: 8px 14px; }
    .btn-xs { min-height: 34px; padding: 6px 10px; font-size: 12px; }
    .icon-btn, .header-icon-btn, #user-menu-btn, #sidebar-toggle, #header-back {
        min-width: 44px; min-height: 44px;
    }
    .data-table th, .data-table td { padding: 10px; }
    .data-table { font-size: 13px; }
    /* صفوف الإجراءات في الجداول: مسافة تمنع الضغط الخاطئ */
    .data-table td .btn + .btn { margin-inline-start: 6px; }
}

/* ── 6) الشاشات الضيقة جداً: بطاقات بدل جداول عريضة (تُفعَّل بالصنف) ── */
@media (max-width: 640px) {
    .table-wrap { border-radius: var(--border-radius-sm); }
    .data-table.stacked thead { display: none; }
    .data-table.stacked tr {
        display: block;
        border-bottom: 1px solid var(--border-color);
        padding: 6px 0;
    }
    .data-table.stacked td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        border: none;
        padding: 5px 12px;
    }
    .data-table.stacked td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
    }
}

/* ══════════════════════════════════════════════════════════════
   بطاقات «إجراءات سريعة» القابلة للترتيب (الرئيسية)
   — مفتوحة الترتيب = مؤشر قبضة + رفع البطاقة + نسخة تتبع المؤشر (ghost)
   ══════════════════════════════════════════════════════════════ */
.quick-action-btn {
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
    position: relative; overflow: hidden;
    min-width: 0;                    /* يمنع انسحاق/تمدّد الخلية في الشبكة على الموبايل */
}
.quick-action-btn .quick-action-label,
.quick-action-btn > span { word-break: break-word; }

/* ── إحصاءات الرئيسية: صفّان على الموبايل (لا سطر لكل إحصائية) ── */
.home-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.home-stats > div { padding: 12px; }
.home-stats > div > div:nth-child(1) { font-size: 18px; }     /* الأيقونة */
.home-stats > div > div:nth-child(2) { font-size: 11.5px; }   /* التسمية */
.home-stats > div > div:nth-child(3) { font-size: 20px; }     /* الرقم */
@media (min-width: 560px) {
    .home-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .home-stats > div { padding: 14px; }
    .home-stats > div > div:nth-child(1) { font-size: 20px; }
    .home-stats > div > div:nth-child(2) { font-size: 12px; }
    .home-stats > div > div:nth-child(3) { font-size: 22px; }
}
.quick-action-btn .quick-action-label { line-height: 1.25; }
.quick-action-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.quick-action-btn.qa-lifted { opacity: .35; transform: scale(.97); }
.qa-grid-unlocked .quick-action-btn { cursor: grab; }
.qa-grid-unlocked .quick-action-btn:active { cursor: grabbing; }
.qa-grid-unlocked .quick-action-btn::after {
    content: '⠿'; position: absolute; inset-inline-start: 6px; top: 4px;
    font-size: 12px; color: rgba(0,0,0,.28); pointer-events: none;
}
.qa-ghost {
    position: fixed; z-index: 10050; pointer-events: none; opacity: .95;
    border-radius: var(--border-radius-md); box-shadow: 0 10px 26px rgba(0,0,0,.22);
    transform: rotate(-1.2deg) scale(1.03);
}
@media (prefers-reduced-motion: reduce) {
    .quick-action-btn:hover { transform: none; }
    .qa-ghost { transform: none; }
}
