/* ==========================================
   1. تهيئة عامة وألوان النظام (ERP Identity)
   ========================================== */
:root {
    /* FutureSystems brand palette, sampled from the logo (wine/burgundy "V") */
    --primary-blue: #8a2452;       /* اللون الأساسي لهوية FutureSystems (خمري/عنابي) */
    --primary-blue-dark: #6b1c40;  /* درجة أغمق للتفاعل (hover) والتدرجات */
    --primary-blue-light: #c05f8a; /* درجة فاتحة للتمييز والتدرجات */
    --accent-orange: #f59e0b;      /* لون مساعد للتنبيهات والتمييز */
    --body-bg: #f8fafc;            /* خلفية هادئة للصفحة والمحتوى */
    --white: #ffffff;
    --border-color: #f1f5f9;       /* حدود ناعمة ومطابقة للصورة */
    --text-dark: #334155;          /* لون النصوص الأساسي */
    --text-muted: #94a3b8;         /* لون النصوص الثانوية الباهتة */
    --active-bg: #fbeef3;          /* خلفية العنصر النشط (وردي فاتح متناسق مع الهوية) */
    --active-icon-color: #8a2452;  /* لون أيقونة العنصر النشط */
    --transition: all 0.25s ease-in-out;
}

/* تصفير الهوامش لضبط دقة الأبعاد */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--body-bg);
    color: var(--text-dark);
    overflow: hidden; /* لمنع ظهور شريط تمرير لكامل الصفحة والحفاظ على ثبات اللوحة */
}

/* التخطيط الهيكلي للوحة التحكم بالكامل (Grid Layout)
   تم ضبط الأعمدة ليكون شريط الجانب (100px) على اليمين والمحتوى (1fr) على اليسار */
.dashboard-layout {
    display: grid;
    grid-template-rows: 70px 1fr;
    grid-template-columns: 100px 1fr; 
    grid-template-areas: 
        "header header"
        "sidebar main";
    height: 100vh;
    width: 100vw;
}

/* ==========================================
   2. تنسيق شريط التنقل العلوي (TOP NAVBAR)
   ========================================== */
.top-navbar {
    grid-area: header;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
}

/* أقصى اليمين: الشعار وزر التحكم الهاتفي */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-toggle-btn {
    display: none; /* مخفي في الشاشات الكبيرة ويظهر فقط في الموبايل */
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-dark);
    cursor: pointer;
}

/* بناء اللوجو مطور ومقارب للصورة */
.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 20px;
}

.logo-icon .blue-dot {
    width: 18px;
    height: 18px;
    background-color: var(--primary-blue);
    border-radius: 50% 50% 0 50%;
}

.logo-icon .orange-dot {
    width: 12px;
    height: 12px;
    background-color: var(--accent-orange);
    border-radius: 50% 0 50% 50%;
    margin-right: auto;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
}

/* وسط الهيدر: شريط البحث الأنيق الدائري */
.navbar-center {
    flex: 1;
    max-width: 500px;
    margin: 0 30px;
    min-width: 0; /* بدون هذا لا يمكن لعنصر الفليكس أن ينكمش تحت حجم محتواه، فيتعطل تقصير النص بثلاث نقاط */
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 45px; /* مساحة لجهة اليسار للأيقونة */
    border: 1px solid #e2e8f0;
    border-radius: 30px; /* حواف دائرية بالكامل مثل الصورة */
    background-color: #fafafa;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    text-align: right;
}

.search-box input:focus {
    border-color: var(--primary-blue);
    background-color: var(--white);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 16px;
}

.navbar-org-name {
    width: 100%;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* يسار الهيدر: الأيقونات والبروفايل */
.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-dark);
    cursor: pointer;
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.nav-icon-btn:hover {
    background-color: var(--border-color);
}

/* شارة عدد الإشعارات الحمراء */
.notification-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: #ef4444; /* أحمر ناصع */
    color: var(--white);
    font-size: 10px;
    font-weight: bold;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* قائمة المستخدم والبروفايل */
.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    padding: 5px 10px;
    border-radius: 30px;
    transition: var(--transition);
}

.user-profile-menu:hover {
    background-color: var(--border-color);
}

.user-profile-menu .username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.user-profile-menu .avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

/* تصميم كارد القائمة المنسدلة للبروفايل
   left:0 يفترض أن الصورة الرمزية (المُحرِّك) تقع أقصى يسار الهيدر - وهذا صحيح
   فقط بالعربية (RTL)، حيث ينعكس ترتيب flex فتصبح الصورة الرمزية على اليسار.
   بالإنجليزية (LTR) الصورة الرمزية أقصى اليمين، فكانت هذه القائمة (200px) تمتد
   يميناً خارج الهيدر بالكامل - وبما أن visibility: hidden لا تمنع العنصر من
   المساهمة في عرض التخطيط، كانت الصفحة كلها (وليس فقط القائمة) تُحسب أعرض من
   الشاشة على الموبايل حتى قبل فتح القائمة فعلياً. تم تثبيت الاتجاه الصحيح تحت
   بدل الاعتماد على left:0 افتراضياً فقط. */
.dropdown-card {
    position: absolute;
    top: 50px;
    left: 0;
    width: 200px;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease-in-out;
    z-index: 500;
}

/* كلاس يتم تفعيله بواسطة الجافاسكريبت */
.dropdown-card.show-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* بالإنجليزية الصورة الرمزية أقصى يمين الهيدر - تمتد القائمة يساراً بدل يميناً
   حتى تبقى ضمن حدود الهيدر نفسه بدل الخروج من الشاشة (انظر التعليق أعلاه) */
.dashboard-layout[dir="ltr"] .dropdown-card {
    left: auto;
    right: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 14px;
    color: #475569;
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: #f8fafc;
}

.dropdown-item i {
    font-size: 16px;
    color: #64748b;
    width: 20px;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

/* تنسيق خيار الخروج بلون أحمر لطيف كما في الصورة */
.logout-item span {
    color: #f87171;
}

.logout-item i {
    color: #f87171 !important;
}

/* ==========================================
   3. تصميم الشـريط الجانبي الأيمن (SIDEBAR)
   ========================================== */
.sidebar-aside {
    grid-area: sidebar;
    background-color: var(--white);
    border-left: 1px solid var(--border-color); /* خط التقسيم على اليسار لأن السايدبار على اليمين */
    overflow-y: auto; /* لتمكين التمرير الداخلي */
    padding: 15px 0;
}

/* تخصيص السكرول بار ليبدو رفيعاً جداً وهادئاً */
.sidebar-aside::-webkit-scrollbar {
    width: 4px;
}

.sidebar-aside::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-aside::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* مخفي في سطح المكتب (الرف الأيقوني ضيق جداً 100px)، ويظهر فقط في القائمة
   المنزلقة على الموبايل - انظر @media (max-width: 991px) لتنسيقه الفعلي */
.sidebar-org-name {
    display: none;
}

/* هيكلة العنصر الواحد داخل القائمة */
.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 85px; /* تم تصغير العرض الإجمالي ليناسب الحجم الجديد */
    text-decoration: none;
    gap: 6px;
    transition: var(--transition);
}

/* المربع الحاوي للأيقونة (تم تعديل المقاسات لتصبح أصغر وأدق) */
.item-icon-box {
    width: 48px;        /* تم تصغيرها من 65px إلى 48px */
    height: 48px;       /* تم تصغيرها من 65px إلى 48px */
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 10px; /* تدوير زوايا أنعم ومناسب للحجم الصغير */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.item-icon-box i {
    font-size: 16px;    /* تم تصغير الأيقونة لتتناسق مع المربع الجديد */
    color: #64748b; 
    transition: var(--transition);
}

.item-label {
    font-size: 10px;    /* خط هادئ وصغير لمنع التداخل */
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    line-height: 1.3;
}

/* عند تمرير الماوس فوق العنصر */
.sidebar-item:hover .item-icon-box {
    background-color: var(--active-bg);
    border-color: var(--primary-blue-light);
}

.sidebar-item:hover .item-icon-box i {
    color: var(--active-icon-color);
}

/* حالة العنصر النشط (Active Item) */
.sidebar-item.active .item-icon-box {
    background-color: var(--active-bg);
    border-color: transparent;
}

.sidebar-item.active .item-icon-box i {
    color: var(--active-icon-color);
}

.sidebar-item.active .item-label {
    color: var(--primary-blue);
    font-weight: 700;
}

/* ==========================================
   4. مساحة المحتـوى على اليسار (MAIN AREA)
   ========================================== */
.main-page-content {
    grid-area: main;
    padding: 30px;
    overflow-y: auto;
    background-color: var(--body-bg);
}

/* الكارد الترحيبي */
.page-placeholder-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 12px;
    text-align: center;
}

.page-placeholder-card h2 {
    color: var(--primary-blue);
    margin-bottom: 10px;
}

.page-placeholder-card p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ==========================================
   5. تجاوب التصميم مع جميع الشاشات (RESPONSIVE)
   ========================================== */

/* للأجهزة اللوحية والمحمولة الشائعة */
@media (max-width: 991px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    /* بدون min-width: 0 هنا يفرض هيدر الصفحة (الشعار + اسم المنشأة + الأيقونات)
       عرض التخطيط بالكامل ليتسع لمحتواه الطبيعي (والذي يتجاوز عرض الهاتف)، بدل
       الانضغاط ضمن خلية الشبكة المخصصة له - وهي نفس مشكلة "grid blowout"
       المعروفة، حيث لا تنكمش عناصر الشبكة تحت حجم محتواها الأدنى افتراضياً */
    .top-navbar {
        min-width: 0;
    }

    /* تصغير هوية العلامة التجارية على الموبايل (الأيقونة فقط + اسم مختصر) حتى
       تبقى مساحة كافية لأيقونات التحكم على اليمين بدون ازدحام */
    .brand-sub {
        display: none;
    }

    .brand-title {
        font-size: 14px;
    }

    .navbar-right,
    .navbar-left {
        min-width: 0;
    }

    /* اسم المنشأة انتقل إلى أعلى القائمة الجانبية المنزلقة على الموبايل (انظر
       .sidebar-org-name) بدل منتصف الهيدر العلوي الضيق جداً لعرضه هنا بوضوح */
    .navbar-center {
        display: none;
    }

    /* إظهار زر فتح القائمة الجانبية في الموبايل */
    .mobile-toggle-btn {
        display: block;
    }

    /* تحويل شريط الجانب إلى قائمة منزلقة، من جهة البداية حسب اتجاه اللغة
       (يمين للعربية RTL، يسار للإنجليزية LTR) - أوسع من الرف الجانبي الأيقوني
       الضيق (100px) في سطح المكتب حتى يتسع بشكل مقروء لاسم المنشأة أعلى القائمة */
    .sidebar-aside {
        position: fixed;
        top: 70px;
        height: calc(100vh - 70px);
        width: 220px;
        z-index: 99;
        transition: var(--transition);
    }

    /* العربية (RTL): القائمة تنزلق من اليمين */
    .dashboard-layout[dir="rtl"] .sidebar-aside {
        right: -240px; /* مخفي خارج الشاشة يميناً */
        left: auto;
        box-shadow: -5px 0 15px rgba(0,0,0,0.05);
    }

    .dashboard-layout[dir="rtl"] .sidebar-aside.open {
        right: 0;
    }

    /* الإنجليزية (LTR): القائمة تنزلق من اليسار */
    .dashboard-layout[dir="ltr"] .sidebar-aside {
        left: -240px; /* مخفي خارج الشاشة يساراً */
        right: auto;
        box-shadow: 5px 0 15px rgba(0,0,0,0.05);
    }

    .dashboard-layout[dir="ltr"] .sidebar-aside.open {
        left: 0;
    }

    /* اسم المنشأة أعلى القائمة الجانبية المنزلقة، قبل قائمة الأيقونات - بدل
       عرضه في منتصف الهيدر العلوي حيث لا تتسع له المساحة على الموبايل */
    .sidebar-org-name {
        display: block;
        padding: 4px 16px 16px;
        margin-bottom: 10px;
        border-bottom: 1px solid var(--border-color);
        font-size: 14px;
        font-weight: 700;
        color: var(--primary-blue);
        text-align: center;
        word-wrap: break-word;
    }

    /* الخلفية المعتمة لإغلاق القائمة بالضغط الخارجي */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 70px);
        background-color: rgba(0,0,0,0.15);
        z-index: 98;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* للهواتف الذكية الصغيرة */
@media (max-width: 550px) {
    /* تصغير اللوجو والبحث لتفادي الازدحام */
    .navbar-center {
        margin: 0 10px;
    }

    .search-box input {
        padding: 8px 10px 8px 30px;
        font-size: 12px;
    }

    .search-icon {
        left: 10px;
        font-size: 14px;
    }

    .username {
        display: none; /* إخفاء اسم المستخدم في شاشات الموبايل الضيقة جداً */
    }
}




/* ==========================================
   6. رأس الصفحة الداخلي (Sub-Header Styling)
   ========================================== */
.content-sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 5px;
}

/* عنوان الصفحة (المالية) */
.page-module-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-blue); /* اللون الأزرق الغامق المعتمد */
}

/* حاوية الأزرار الثلاثة */
.sub-header-actions {
    display: flex;
    gap: 12px; /* مسافة متناسقة بين الأزرار */
}

/* تنسيق الزر الأبيض المشترك (مطابق للصورة بدقة) */
.sub-action-btn {
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 8px; /* حواف دائرية ناعمة */
    color: var(--primary-blue);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px; /* مسافة بين الأيقونة والنص */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03); /* ظل ناعم جداً تحت الزر */
    transition: var(--transition);
}

/* تأثير التمرير (Hover) فوق الأزرار */
.sub-action-btn:hover {
    background-color: var(--active-bg); /* خلفية سماوية خفيفة عند الوقوف بالماوس */
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* حجم أيقونات الأزرار الداخلي */
.sub-action-btn i {
    font-size: 14px;
    color: var(--primary-blue);
}

/* ==========================================
   تجاوب رأس الصفحة مع الأجهزة الصغيرة (Mobile)
   ========================================== */
@media (max-width: 576px) {
    .content-sub-header {
        flex-direction: column; /* ترتيب رأسي بدلاً من أفقي لعدم حدوث تداخل */
        align-items: flex-start;
        gap: 15px;
    }
    
    .sub-header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap; /* السماح بنزول الأزرار للسطر التالي إذا كانت الشاشة ضيقة جداً */
    }
    
    .sub-action-btn {
        flex: 1; /* جعل الأزرار تتوزع بالتساوي على الموبايل */
        justify-content: center;
        padding: 10px 15px;
    }
}



/* ==========================================
   7. شريط الإجراءات المفضلة (Favorite Actions Bar)
   ========================================== */
.fav-actions-bar {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.01);
}

.fav-right-side {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap; /* تفعيل اللف التلقائي للأزرار على الشاشات الصغيرة */
}

/* عنوان القسم مع النجمة الذهبية */
.fav-title-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.fav-title-label .star-icon {
    color: #f59e0b; /* اللون الذهبي للنجمة */
}

.fav-buttons-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* التنسيق الأساسي للأزرار داخل شريط الإجراءات */
.fav-btn {
    background-color: var(--white);
    border: 1px solid #cbd5e1;
    color: var(--primary-blue);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.fav-btn:hover {
    background-color: #f8fafc;
    border-color: 94a3b8;
}

/* تنسيق زر "التخصيص" (بحدود زرقاء داكنة) */
.btn-outline-blue {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-outline-blue:hover {
    background-color: var(--active-bg);
    border-color: var(--primary-blue);
}

/* تنسيق زر "المزيد" الأزرق الغامق */
.btn-dark-blue {
    background-color: var(--primary-blue);
    color: var(--white);
    border-color: var(--primary-blue);
}

.btn-dark-blue:hover {
    background-color: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

.chevron-icon {
    font-size: 10px;
}

/* ==========================================
   8. قائمة "المزيد" المنسدلة عند التمرير (Hover Dropdown)
   ========================================== */
.more-dropdown-container {
    position: relative;
}

/* محتوى القائمة المنسدلة */
.more-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0; /* محاذاة لليمين لأن النظام عربي */
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    width: 200px;
    padding: 8px 0;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 200;
}

/* تفعيل الظهور عند التمرير بالماوس فوق الأب */
.more-dropdown-container:hover .more-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* عناصر القائمة المنسدلة */
.dropdown-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    text-decoration: none;
    transition: var(--transition);
    text-align: right;
}

.dropdown-menu-item:hover {
    background-color: #f8fafc;
    color: var(--primary-blue);
}

.dropdown-menu-item i {
    font-size: 14px;
    color: var(--primary-blue);
    width: 16px;
    text-align: center;
}

/* ==========================================
   9. تصميم النافذة المنبثقة للتخصيص (Customization Modal)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4); /* تعتيم خلفية الصفحة */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

/* تنشيط الظهور التدريجي */
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background-color: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    /* margin-top, NOT transform, drives the slide-in - a `transform` (any value, including
       translateY(0)) makes this box a CSS containing block for `position:fixed` descendants,
       which silently breaks SearchableSelect's dropdown (it computes real viewport coordinates
       via JS and expects `position:fixed` to honor them) - the dropdown ends up positioned
       relative to THIS box instead of the viewport, then gets clipped by the `overflow:hidden`
       below. Found and fixed in ERP first (a modal with a SearchableSelect near the bottom of a
       tall form) - same trap here since this app shares the identical .modal-box/SearchableSelect
       mechanism. */
    margin-top: -20px;
    transition: var(--transition);
    overflow: hidden;
}

.modal-overlay.active .modal-box {
    margin-top: 0;
}

/* رأس النافذة المنبثقة */
.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-blue);
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-modal-btn:hover {
    color: #ef4444;
}

/* وسط النافذة: الخيارات مع Checkboxes */
.modal-body {
    padding: 20px;
    background-color: #f8fafc;
}

.checkbox-list {
    background-color: var(--white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
}

.checkbox-item:last-child {
    border-bottom: none;
}

.checkbox-item:hover {
    background-color: #f8fafc;
}

/* إخفاء الـ Checkbox الافتراضي وتنسيق بديل احترافي ومطابق تماماً */
.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

.checkbox-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

/* تذييل النافذة المنبثقة */
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end; /* محاذاة جهة اليمين/البداية */
    gap: 12px;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

/* زر الحفظ الأزرق الممتلئ */
.btn-save {
    background-color: var(--primary-blue);
    color: var(--white);
    border: none;
}

.btn-save:hover {
    background-color: var(--primary-blue-dark);
}

/* زر الإلغاء ذو الحدود الرمادية الهادئة */
.btn-cancel {
    background-color: var(--white);
    border: 1px solid #cbd5e1;
    color: var(--text-muted);
}

.btn-cancel:hover {
    background-color: #f1f5f9;
    color: var(--text-dark);
}

/* زر التأكيد الأحمر (حذف/إلغاء) داخل نافذة التأكيد العامة */
.modal-btn.btn-danger {
    background-color: #9c1f3f;
    color: var(--white);
    border: none;
}

.modal-btn.btn-danger:hover {
    background-color: #7a1830;
}

.modal-btn i,
.close-modal-btn i {
    margin-inline-end: 6px;
}

/* نافذة التأكيد العامة (حذف/إلغاء) */
.confirm-dialog-box {
    max-width: 420px;
}

.confirm-dialog-icon {
    color: #9c1f3f;
}

.confirm-dialog-message {
    margin: 0;
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
}

/* نافذة تقرير العميل المنبثقة (تفتح من أيقونة العين في بطاقة الموعد) - أوسع من نوافذ
   التأكيد/الحجز العادية لأنها تحتضن جداول تقرير كاملة، مع تمرير رأسي داخلي بدل تمدد
   النافذة خارج الشاشة عند وجود عدد كبير من الفواتير/المواعيد */
.report-modal-box {
    max-width: 900px;
}

.report-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.report-modal-body .table-card {
    margin-bottom: 16px;
}

.report-modal-body .table-card:last-child {
    margin-bottom: 0;
}

/* نافذة "تسعير حزمة" - إضافة عدة أصناف بسعر إجمالي متفق عليه بدل السعر الفردي لكل صنف
   (Sales Invoice, زر "تسعير حزمة" أعلى قسم الأصناف) */
.bundle-modal-box {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* يمنع تمدد النافذة خارج الشاشة على الأجهزة القصيرة عند إضافة عدة أصناف - يبقي رأس/تذييل
   النافذة (وزر "إضافة للفاتورة") ظاهرين دائماً، مع تمرير داخلي للمحتوى فقط */
.bundle-modal-box .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.bundle-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0 0 16px;
    line-height: 1.6;
}

.bundle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.bundle-row .searchable-select {
    flex: 1 1 auto;
    min-width: 0;
}

.bundle-qty {
    width: 90px;
    flex-shrink: 0;
}

.bundle-orig-price {
    width: 90px;
    flex-shrink: 0;
    text-align: end;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.bundle-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

/* ==========================================
   تجاوب شريط الإجراءات والنافذة مع الشاشات الصغيرة
   ========================================== */
@media (max-width: 768px) {
    .fav-actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .fav-right-side {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .fav-buttons-group {
        width: 100%;
    }

    .fav-btn {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }

    .more-dropdown-container {
        width: 100%;
    }

    .more-dropdown-container .fav-btn {
        width: 100%;
    }

    .fav-left-side .fav-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-box {
        width: 90%;
        margin: 0 auto;
    }
}


/* ==========================================
   10. نظام التبويبات والجداول (ERP Tabs & Tables Styling)
   ========================================== */

/* حاوية شريط التبويبات */
.tabs-navigation-bar {
    display: flex;
    gap: 25px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 25px;
    padding-right: 10px;
}

/* أزرار التبويبات الفردية */
.tab-link-btn {
    background: none;
    border: none;
    padding: 12px 5px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.tab-link-btn:hover {
    color: var(--primary-blue);
}

/* حالة التبويب النشط (المطابق للصورة بالخط التحتي الأزرق الداكن) */
.tab-link-btn.active {
    color: var(--primary-blue);
    font-weight: 700;
}

.tab-link-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px; /* ينطبق تماماً فوق خط الـ Border الخاص بالحاوية الأب */
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-blue);
    border-radius: 3px;
}

/* ألواح التبويبات (مخفية افتراضياً وتظهر عند إضافة active) */
.tab-content-panel {
    display: none;
}

.tab-content-panel.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

/* ==========================================
   11. كروت البيانات والجداول الافتراضية
   ========================================== */
.table-card, .form-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.01);
    margin-bottom: 25px;
    overflow: hidden;
}

/* الهيدر الأزرق الموحد للجداول والفورم */
.table-card-header {
    background-color: var(--primary-blue);
    color: var(--white);
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
}

/* حاوية الجدول المرنة لمنع تمدد الشاشة على الجوال */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
}

.erp-custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
}

.erp-custom-table th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.erp-custom-table td {
    padding: 15px;
    font-size: 13px;
    color: var(--text-dark);
    border-bottom: 1px solid #f1f5f9;
}

.erp-custom-table tbody tr:hover {
    background-color: #f8fafc;
}

/* الروابط والنصوص المميزة بداخل الجدول */
.table-link-id {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 700;
}

.table-link-id:hover {
    text-decoration: underline;
}

.text-bold {
    font-weight: 700;
}

.text-blue {
    color: #2563eb;
}

/* وسم الحالة الخضراء (نشط) */
.status-badge-green {
    background-color: #f0fdf4;
    color: #16a34a;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 11px;
}

/* نصوص LTR (الأرقام والإنجليزية كالهواتف) */
.ltr-text {
    direction: ltr;
    unicode-bidi: embed;
}

/* أزرار العمليات داخل الجدول */
.table-action-btn-red,
.table-action-btn-gold,
.table-action-btn-blue,
.table-action-btn-green,
.table-action-btn-purple {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 7px 12px;
    color: var(--white);
    transition: var(--transition);
}

/* لوحة ألوان متدرجة من اللون الأساسي لهوية FutureSystems (خمري/عنابي) بدل الألوان
   المتفرقة السابقة (أزرق/برتقالي/أحمر فاقع) - حتى تبقى أزرار الجدول متناسقة مع الهوية */
.table-action-btn-blue { background-color: var(--primary-blue-light); } /* تحرير: أفتح درجة */
.table-action-btn-blue:hover { background-color: #a8446f; }

.table-action-btn-gold { background-color: var(--primary-blue); } /* متابعة: الدرجة الأساسية */
.table-action-btn-gold:hover { background-color: var(--primary-blue-dark); }

.table-action-btn-red { background-color: #9c1f3f; } /* حذف: أغمق درجة مع ميل أوضح للأحمر للتحذير */
.table-action-btn-red:hover { background-color: #7a1830; }

.table-action-btn-green { background-color: #4d8a63; } /* تأكيد: أخضر مكتوم متناسق مع الهوية */
.table-action-btn-green:hover { background-color: #3c6d4e; }

.table-action-btn-purple { background-color: #6d4d8a; } /* فاتورة جديدة: بنفسجي مكتوم متناسق مع الهوية */
.table-action-btn-purple:hover { background-color: #573c6d; }

.table-action-btn-red:disabled,
.table-action-btn-gold:disabled,
.table-action-btn-blue:disabled,
.table-action-btn-green:disabled,
.table-action-btn-purple:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}


/* ==========================================
   12. تصميم استمارات الإدخال (Forms Styling)
   ========================================== */
.erp-grid-form {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* توزيع حقول الإدخال في صف واحد أفقي - col-3 بمعنى بوتستراب (4 حقول متساوية بالصف) */
.form-inputs-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.form-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-input-group label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
}

.form-input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: var(--white);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.form-input-group input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 5px rgba(138, 36, 82, 0.15);
}

/* الحاوية الأساسية للأزرار والموجهة لليسار تماماً */
.form-actions-left {
    display: flex;
    justify-content: flex-start; /* تحول تلقائياً لليسار في بيئة RTL المعتمدة */
    gap: 12px;
    margin-right: auto; /* دفع الكتلة بالكامل لأقصى اليسار في تصميم RTL */
}

/* أزرار الفورم */
.erp-form-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    color: var(--white);
    transition: var(--transition);
    /* Clear default for every bare .erp-form-btn (no variant class): a solid brand fill, never an unstyled/faded button. */
    background-color: var(--primary-blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.erp-form-btn:not(.btn-dark-blue):not(.btn-coral):not(.btn-green):not(.btn-blue):not(.btn-outline):not(.btn-outline-danger):hover {
    background-color: var(--primary-blue-dark);
}
.erp-form-btn:disabled { opacity: .55; cursor: not-allowed; }

.erp-form-btn.btn-dark-blue {
    background-color: var(--primary-blue);
}
.erp-form-btn.btn-dark-blue:hover {
    background-color: var(--primary-blue-dark);
}

.erp-form-btn.btn-coral {
    background-color: var(--primary-blue); /* الحفظ: اللون الأساسي لهوية الشركة بدل المرجان الغريب عن الهوية */
}
.erp-form-btn.btn-coral:hover {
    background-color: var(--primary-blue-dark);
}

.erp-form-btn.btn-green {
    background-color: #4d8a63; /* تأكيد: أخضر مكتوم متناسق مع الهوية، بدل الأخضر الفاقع */
}
.erp-form-btn.btn-green:hover {
    background-color: #3c6d4e;
}

.erp-form-btn.btn-blue {
    background-color: #2563eb;
}
.erp-form-btn.btn-blue:hover {
    background-color: #1d4ed8;
}

/* زر ثانوي بحدود رمادية (إلغاء/رجوع) */
.erp-form-btn.btn-outline {
    background-color: var(--white);
    border: 1px solid #cbd5e1;
    color: var(--text-muted);
}
.erp-form-btn.btn-outline:hover {
    background-color: #f1f5f9;
    color: var(--text-dark);
}

/* زر ثانوي بحدود حمراء لإجراءات الإلغاء الفعلية (مثل إلغاء الفاتورة) - يميزه عن أزرار
   التنقل البسيطة (رجوع/تراجع) التي تستخدم .btn-outline العادي */
.erp-form-btn.btn-outline-danger {
    background-color: var(--white);
    border: 1px solid #9c1f3f;
    color: #9c1f3f;
}
.erp-form-btn.btn-outline-danger:hover {
    background-color: #9c1f3f;
    color: var(--white);
}

.erp-form-btn:disabled,
.modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 16px;
}

.pagination-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* تباعد الأيقونات داخل الأزرار */
.erp-form-btn i,
.modal-btn i,
.login-submit-btn i,
.table-action-btn-red i,
.table-action-btn-gold i,
.table-action-btn-blue i,
.table-action-btn-green i,
.table-action-btn-purple i {
    margin-inline-end: 6px;
}


/* ==========================================
   التجاوب مع شاشات الموبايل
   ========================================== */
@media (max-width: 768px) {
    .tabs-navigation-bar {
        overflow-x: auto; /* تمكين التمرير الأفقي للتبويبات على الموبايل لعدم تداخلها */
        white-space: nowrap;
        gap: 15px;
    }
    
    .form-inputs-row {
        grid-template-columns: 1fr; /* جعل حقول الإدخال تحت بعضها على الهواتف */
        gap: 15px;
    }
    
    .form-actions-left {
        width: 100%;
        margin-right: 0;
        justify-content: space-between; /* تمدد متوازن للأزرار على الموبايل */
    }
    
    .erp-form-btn {
        flex: 1;
        text-align: center;
    }
}




/* ==========================================
   13. تنسيق الهيدر الداخلي والتبويبات الفرعية (Inner Pages Styling)
   ========================================== */

/* كارد هيدر الصفحات الفرعية */
.inner-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

/* زر العودة مع اسم القسم والسهم الموجه */
.back-navigation-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: 700;
    transition: var(--transition);
}

.back-navigation-link i {
    font-size: 18px;
    color: var(--text-muted);
    transition: var(--transition);
}

/* حركة بسيطة واحترافية للسهم عند تمرير الماوس */
.back-navigation-link:hover i {
    transform: translateX(4px); /* دفع السهم لليمين لإيحاء العودة للخلف */
    color: var(--primary-blue);
}

.back-navigation-link:hover span {
    color: var(--primary-blue);
}

/* أزرار الإجراءات جهة اليسار للهيدر الداخلي */
.inner-header-actions {
    display: flex;
    gap: 12px;
}

/* حاوية التبويبات الداخلية المطابقة للصورة الجديدة */
.inner-tabs-container {
    display: flex;
    gap: 20px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 25px;
    padding-right: 5px;
}

/* أزرار التبويبات الفرعية (عنوان الاجراء) */
.inner-tab-link {
    background: none;
    border: none;
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.inner-tab-link:hover {
    color: var(--primary-blue);
}

/* الحالة النشطة للتبويب الفرعي بالخط التحتي المتناسق */
.inner-tab-link.active {
    color: var(--primary-blue);
    font-weight: 700;
}

.inner-tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px; /* لتنطبق مباشرة فوق خط حاوية الأب */
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-blue);
    border-radius: 3px;
}

/* ألواح محتويات التبويبات الفرعية */
.inner-tab-panel {
    display: none;
}

.inner-tab-panel.active {
    display: block;
    animation: fadeInInner 0.25s ease-in-out;
}

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

/* ==========================================
   التجاوب للهواتف والشاشات الصغيرة
   ========================================== */
@media (max-width: 768px) {
    .inner-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .inner-header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .inner-header-actions .sub-action-btn {
        flex: 1;
        justify-content: center;
    }

    .inner-tabs-container {
        overflow-x: auto; /* تفعيل التمرير الأفقي للأزرار لتجنب حدوث أي أخطاء أو تداخل في الموبايل */
        white-space: nowrap;
        gap: 10px;
    }
}

/* ==========================================
   14. أيقونات SVG داخل الشريط الجانبي وشريط التنقل العلوي
   (المشروع لا يحتوي على مكتبة أيقونات خطية، لذا تُستخدم SVG مضمّنة
   بلون currentColor لتتوافق تلقائياً مع حالات hover/active الحالية)
   ========================================== */
.item-icon-box svg {
    width: 18px;
    height: 18px;
    color: #64748b;
    transition: var(--transition);
}

.sidebar-item:hover .item-icon-box svg,
.sidebar-item.active .item-icon-box svg {
    color: var(--active-icon-color);
}

.nav-icon-btn svg {
    width: 18px;
    height: 18px;
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: #64748b;
}

.logout-item svg {
    color: #f87171 !important;
}

.sidebar-brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(138, 36, 82, 0.25);
}

/* زر تبديل اللغة داخل شريط التنقل العلوي */
.lang-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}

.lang-toggle-btn:hover {
    background-color: var(--active-bg);
    border-color: var(--primary-blue-light);
    color: var(--primary-blue);
}

.lang-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* شارة الأحرف الأولى كبديل لصورة أفاتار غير متوفرة */
.avatar-initials {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-light));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* ==========================================
   15. صفحة تسجيل الدخول (Login Page)
   ========================================== */
.login-page {
    min-height: 100vh;
    width: 100%;
    display: flex;
    background-color: var(--white);
    overflow: hidden;
}

.login-visual-pane {
    flex: 1 1 45%;
    max-width: 560px;
    background: radial-gradient(circle at 20% 20%, var(--primary-blue-light) 0%, transparent 45%),
                linear-gradient(150deg, var(--primary-blue-dark) 0%, var(--primary-blue) 60%, var(--primary-blue-light) 130%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 48px 40px;
    text-align: center;
    gap: 32px;
}

.login-logo-badge {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    padding: 12px;
}

.login-logo-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-brand-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.login-brand-tagline {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    max-width: 360px;
    line-height: 1.7;
}

.login-module-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 420px;
}

.login-module-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 14px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(2px);
    transition: var(--transition);
}

.login-module-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.login-module-card svg {
    width: 22px;
    height: 22px;
}

.login-module-card span {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}

.login-form-pane {
    flex: 1 1 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
}

.login-lang-switch {
    position: absolute;
    top: 28px;
    inset-inline-end: 32px;
}

.login-form-card {
    width: 100%;
    max-width: 400px;
}

.login-form-header {
    margin-bottom: 32px;
}

.login-form-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.login-form-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.login-input-group {
    margin-bottom: 20px;
}

.login-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrapper svg {
    position: absolute;
    inset-inline-start: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.login-input-wrapper input {
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background-color: #fafafa;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

[dir="rtl"] .login-input-wrapper svg {
    inset-inline-start: auto;
    inset-inline-end: 16px;
}

[dir="rtl"] .login-input-wrapper input {
    padding: 13px 44px 13px 16px;
}

.login-input-wrapper input:focus {
    border-color: var(--primary-blue);
    background-color: var(--white);
    box-shadow: 0 0 0 3px rgba(138, 36, 82, 0.1);
}

.login-input-wrapper .toggle-visibility-btn {
    position: absolute;
    inset-inline-end: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
}

[dir="rtl"] .login-input-wrapper .toggle-visibility-btn {
    inset-inline-end: auto;
    inset-inline-start: 14px;
}

.login-remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.login-remember-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
}

.login-remember-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-blue);
    cursor: pointer;
}

.login-submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-blue-dark));
    color: var(--white);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 20px rgba(138, 36, 82, 0.25);
}

.login-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(138, 36, 82, 0.32);
}

.login-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
}

.login-alert.success {
    background-color: #f0fdf4;
    color: #16a34a;
}

.login-alert.error {
    background-color: #fef2f2;
    color: #dc2626;
}

.login-footer-note {
    margin-top: 28px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================
   16. Customer Session Appointments calendar (حجز المواعيد)
   Ported from the legacy screen's own <style> block, re-themed onto
   the shared design tokens above instead of hardcoded colors.
   ========================================== */
.calendar-table {
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 4px;
}

.calendar-table th {
    white-space: nowrap;
    background-color: var(--primary-blue);
    color: #fff;
    font-size: 0.85rem;
    padding: 8px 6px;
}

.calendar-table .time-header {
    background-color: #f1f5f9;
    font-weight: 700;
    color: var(--text-dark);
    width: 78px;
    white-space: nowrap;
    font-size: 0.8rem;
}

.calendar-table td {
    vertical-align: middle !important;
    padding: 4px 6px !important;
}

.slot-available {
    background-color: var(--white);
    text-align: center;
}

.slot-booked {
    background-color: #fdecec !important;
    border: 1px solid #f3b6b6 !important;
    border-radius: 6px;
    padding: 6px 6px !important;
}

.slot-attend {
    background-color: #eafaf0 !important;
    border: 1px solid #9ee6b8 !important;
    border-radius: 6px;
    padding: 6px 6px !important;
}

.slot-notattend {
    background-color: #fff3e6 !important;
    border: 1px solid #f6c78f !important;
    border-radius: 6px;
    padding: 6px 6px !important;
}

.appointment-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: center;
}

.patient-name {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.82rem;
    line-height: 1.2;
}

.patient-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* أيقونة صغيرة داخل بطاقة الموعد (عين تقرير العميل) - لا تأخذ نفس تنسيق أزرار
   حضور/لم يحضر/إلغاء الملونة، فقط أيقونة رمادية خفيفة بجانب اسم العميل */
.card-icon-btn {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.72rem;
    line-height: 1;
    padding: 2px 3px;
    border-radius: 3px;
    transition: var(--transition);
}

.card-icon-btn:hover {
    color: var(--primary-blue);
    background-color: var(--border-color);
}

.appointment-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.service-name {
    display: inline-block;
    background-color: var(--primary-blue);
    color: #fff;
    font-size: 0.68rem;
    line-height: 1.3;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.mobile-number {
    display: inline-block;
    background-color: #64748b;
    color: #fff;
    font-size: 0.68rem;
    line-height: 1.3;
    padding: 1px 8px;
    border-radius: 10px;
}

/* شارات تنبيه بطاقة الموعد: المبلغ المتبقي على العميل وعدد الجلسات المتبقية لهذه الخدمة */
.appointment-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.alert-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    line-height: 1.3;
    padding: 1px 7px;
    border-radius: 10px;
    color: #fff;
    white-space: nowrap;
}

.alert-badge.alert-balance { background-color: #b45309; }
.alert-badge.alert-info { background-color: #0d9488; }
.alert-badge.alert-danger { background-color: #9c1f3f; }

.appointment-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
    justify-content: center;
    margin-top: 2px;
}

.appointment-actions button {
    font-size: 0.65rem;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    border: none;
    color: #fff;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.appointment-actions .table-action-btn-blue { background-color: #16a34a; }
.appointment-actions .table-action-btn-blue:hover { background-color: #15803d; }
.appointment-actions .table-action-btn-blue.active { outline: 2px solid #14532d; }

.appointment-actions .table-action-btn-gold { background-color: #f59e0b; }
.appointment-actions .table-action-btn-gold:hover { background-color: #d97706; }
.appointment-actions .table-action-btn-gold.active { outline: 2px solid #92400e; }

.appointment-actions .table-action-btn-red { background-color: #dc2626; }
.appointment-actions .table-action-btn-red:hover { background-color: #b91c1c; }

.appointment-actions button i {
    margin-inline-end: 3px;
    font-size: 0.7em;
}

.btn-book-appointment {
    font-size: 0.78rem;
    padding: 8px 14px;
    white-space: nowrap;
    background-color: transparent;
    border: 1.5px solid #0d9488;
    color: #0d9488;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-book-appointment:hover {
    background-color: #0d9488;
    color: #fff;
}

.btn-book-appointment i {
    margin-inline-end: 4px;
}

/* ==========================================
   17. Global toasts & loading overlay
   Mounted once in App.razor (outside the router, so they cover every
   layout including the login screen) and driven by ToastBus/LoadingBus,
   which BaseViewModel.ShowMessage/ShowProgress broadcast into. Replaces
   the old per-page alert/spinner blocks that could go stale across
   navigation, since Blazor WASM ViewModels live for the whole app session.
   ========================================== */
.toast-stack {
    position: fixed;
    top: 20px;
    inset-inline-end: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    animation: toast-slide-in 0.25s ease-out;
}

.toast-success {
    background-color: #16a34a;
}

.toast-error {
    background-color: #dc2626;
}

.toast-close {
    background: none;
    border: none;
    color: #fff;
    opacity: 0.8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.customer-combobox,
.searchable-select {
    position: relative;
}

.autocomplete-clear {
    color: var(--text-muted);
    font-style: italic;
}

.autocomplete-empty {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: default;
}

.autocomplete-dropdown {
    /* Position (top/left/width) is set inline per-instance via JS (SearchableSelect.razor),
       using `position: fixed` at the input's actual screen coordinates - a dropdown positioned
       relative to its input gets clipped whenever the input sits inside a scrollable container
       (e.g. the Sales Invoice items table), no matter its z-index. This class only carries the
       visual styling, plus a position:absolute fallback for the rare case the JS positioning
       call fails (see the catch block in SearchableSelect.razor). */
    position: absolute;
    z-index: 2000;
    max-height: 220px;
    overflow-y: auto;
    background-color: var(--white);
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.autocomplete-item {
    padding: 8px 12px;
    font-size: 0.88rem;
    cursor: pointer;
}

.autocomplete-item:hover {
    background-color: #f5f5f7;
}

/* ==========================================================================
   Global loading indicator (LoadingOverlay.razor) - modern branded spinner
   ========================================================================== */
.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: rgba(248, 250, 252, 0.72);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    animation: app-fade-in 0.2s ease;
}

/* Full-screen boot loader (index.html, before Blazor starts) */
.app-boot {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--body-bg);
}

.app-loader { position: relative; width: 84px; height: 84px; }

/* Gradient arc that spins, cut into a ring via a radial mask */
.app-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 90deg, var(--primary-blue), var(--primary-blue-light) 55%, rgba(0, 0, 0, 0) 92%);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
            mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
    animation: app-spin 0.9s linear infinite;
}

.app-loader-logo {
    position: absolute;
    inset: 20px;
    width: 44px;
    height: 44px;
    object-fit: contain;
    animation: app-pulse 1.5s ease-in-out infinite;
}

.app-loader-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .3px;
    color: var(--primary-blue);
}

@keyframes app-spin { to { transform: rotate(360deg); } }
@keyframes app-pulse { 0%, 100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.09); opacity: 1; } }
@keyframes app-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   Modern content skeleton (SkeletonLoader.razor) - shimmering placeholders
   for a screen's own loading state.
   ========================================================================== */
.skeleton-wrap { width: 100%; }

.sk {
    position: relative;
    overflow: hidden;
    background: #e6ebf1;
    border-radius: 8px;
}
.sk::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85) 50%, transparent);
    animation: sk-shimmer 1.35s ease-in-out infinite;
}
[dir="rtl"] .sk::after { transform: translateX(100%); animation-name: sk-shimmer-rtl; }
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
@keyframes sk-shimmer-rtl { 100% { transform: translateX(-100%); } }

.sk-line { height: 13px; }
.sk-dot { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; }
.sk-avatar { width: 54px; height: 54px; border-radius: 14px; flex: 0 0 auto; }
.sk-input { height: 40px; border-radius: 10px; }

/* cards */
.sk-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.sk-card {
    display: flex; gap: 16px; padding: 20px;
    background: var(--white); border: 1px solid var(--border-color); border-radius: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.sk-card-body { flex: 1; display: flex; flex-direction: column; gap: 11px; padding-top: 4px; }

/* table */
.sk-table {
    background: var(--white); border: 1px solid var(--border-color);
    border-radius: 14px; overflow: hidden;
}
.sk-table-head, .sk-table-row {
    display: flex; gap: 18px; padding: 15px 18px; align-items: center;
}
.sk-table-head { background: var(--body-bg); }
.sk-table-row { border-top: 1px solid var(--border-color); }
.sk-table-head > .sk, .sk-table-row > .sk { flex: 1 1 0; min-width: 0; }

/* list */
.sk-list { display: flex; flex-direction: column; gap: 15px; }
.sk-list-row { display: flex; align-items: center; gap: 14px; }

/* form */
.sk-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.sk-field { display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 768px) {
    .sk-form { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .login-visual-pane {
        display: none;
    }

    .login-form-pane {
        flex: 1 1 100%;
    }
}

/* ==========================================
   21. لوحة التحكم الرئيسية (Home Dashboard)
   ========================================== */
.dashboard-cards-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dash-card {
    flex: 1 1 220px;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.dash-card-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 12px;
    background-color: var(--active-bg);
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.dash-card-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-blue);
    line-height: 1.2;
}

.dash-card-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.dash-chart-wrapper {
    padding: 20px;
    overflow-x: auto;
}

.dash-chart-svg {
    width: 100%;
    max-width: 720px;
    /* Fixed height (not auto): with few bars the viewBox is nearly square, so height:auto
       stretched the chart very tall when it filled the card width. The SVG uses
       preserveAspectRatio="meet", so a fixed height just letterboxes it to a compact,
       consistent size regardless of how many bars there are. */
    height: 240px;
    display: block;
    margin: 0 auto;
}

/* دونات نسبة الحالات (تقرير المواعيد) */
.donut-chart-wrapper {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.donut-chart-svg {
    width: 220px;
    height: 220px;
    flex-shrink: 0;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 180px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dark);
}

.donut-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.donut-legend-label {
    font-weight: 600;
}

.donut-legend-value {
    margin-inline-start: auto;
    color: var(--text-muted);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .dashboard-cards-row {
        flex-direction: column;
    }
}

/* شبكة رسوم لوحة التحكم البيانية - عمودان بالصف بدل التكديس الرأسي الكامل */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.dashboard-charts-grid .table-card {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* شارات الحالة الصغيرة (حالة المواعيد وغيرها) */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
}

.status-badge.status-green { background-color: #4d8a63; }
.status-badge.status-gold { background-color: #f59e0b; }
.status-badge.status-red { background-color: #9c1f3f; }
.status-badge.status-gray { background-color: #94a3b8; }


/* ==========================================
   16. تصميم فاتورة المبيعات بطراز نقاط البيع (POS)
   عمودان: سلة أصناف/بيانات على اليسار + لوحة ملخص والدفع الثابتة (sticky) على اليمين،
   بنفس ألوان وهوية FutureSystems الحالية بدل الجداول التقليدية.
   ========================================== */
.pos-invoice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pos-invoice-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
}

.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    align-items: start;
    gap: 20px;
}

.pos-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.pos-summary {
    position: sticky;
    top: 20px;
}

/* صف حقول مرن يتقلص تلقائياً حسب المساحة بدل تثبيت 4 أعمدة دائماً */
.pos-fields-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    padding: 20px;
}

.pos-fields-row + .pos-fields-row {
    padding-top: 0;
}

/* سلة الأصناف */
.pos-cart-list {
    display: flex;
    flex-direction: column;
}

.pos-cart-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.pos-cart-item:last-child {
    border-bottom: none;
}

.pos-cart-item-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.pos-cart-item-top .searchable-select {
    flex: 1 1 220px;
    min-width: 0;
}

.pos-cart-item-total {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-blue);
    white-space: nowrap;
}

.pos-cart-item-remove {
    border: none;
    background: none;
    color: #9c1f3f;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.pos-cart-item-remove:hover {
    background-color: #fef2f2;
}

.pos-cart-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
}

.pos-cart-item-details .form-input-group label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

/* عداد الكمية على طراز نقاط البيع (+ / -) بدل حقل رقمي عادي فقط */
.pos-qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    height: 42px;
}

.pos-qty-stepper button {
    width: 34px;
    height: 100%;
    flex-shrink: 0;
    border: none;
    background-color: #f8fafc;
    color: var(--primary-blue);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.pos-qty-stepper button:hover {
    background-color: var(--border-color);
}

.pos-qty-stepper button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.pos-qty-stepper input {
    flex: 1;
    min-width: 0;
    border: none;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    width: 100%;
    outline: none;
    background: transparent;
    color: var(--text-dark);
}

.pos-empty-cart {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.pos-empty-cart i {
    font-size: 28px;
    display: block;
    margin-bottom: 10px;
    opacity: .5;
}

.pos-add-item-btn {
    width: 100%;
    padding: 14px;
    border: 2px dashed #cbd5e1;
    background-color: #fafbfc;
    color: var(--primary-blue);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.pos-add-item-btn:hover {
    background-color: var(--border-color);
    border-color: var(--primary-blue-light);
}

/* لوحة الملخص والدفع الثابتة */
.pos-summary-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .03);
    overflow: hidden;
}

.pos-summary-rows {
    padding: 16px 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pos-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.pos-summary-row span:last-child {
    color: var(--text-dark);
    font-weight: 600;
}

.pos-summary-row span:last-child.negative {
    color: #9c1f3f;
}

/* الإجمالي الكبير المميز أسفل الفاتورة - أبرز عنصر باللوحة، بمثابة "الشاشة" في نقاط البيع */
.pos-summary-total {
    margin: 16px 20px;
    padding: 16px;
    background-color: #fdf2f6;
    border-radius: 8px;
    text-align: center;
}

.pos-summary-total .label {
    font-size: 12px;
    color: var(--primary-blue-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.pos-summary-total .value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-blue);
    margin-top: 4px;
}

.pos-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 20px;
}

.pos-payments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
}

.pos-payment-row {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pos-payment-row:first-of-type {
    border-top: none;
}

.pos-payment-row-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pos-payment-row-line .searchable-select,
.pos-payment-row-line input {
    flex: 1;
    min-width: 0;
}

.pos-add-payment-btn {
    margin: 4px 20px 12px;
    padding: 10px;
    border: 1px dashed #cbd5e1;
    background-color: #fafbfc;
    color: var(--primary-blue);
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    width: calc(100% - 40px);
    transition: var(--transition);
}

.pos-add-payment-btn:hover {
    background-color: var(--border-color);
}

.pos-paid-remaining {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pos-actions {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pos-btn-save {
    width: 100%;
    padding: 15px;
    font-size: 15px;
    border-radius: 8px;
}

.pos-actions-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pos-actions-secondary .erp-form-btn {
    flex: 1;
    min-width: 80px;
    padding: 9px 10px;
    font-size: 12px;
    text-align: center;
}

@media (max-width: 992px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }

    .pos-summary {
        position: static;
    }
}

/* بطاقات الفاتورة (POS) على الموبايل - بدون هذا كانت شبكة الحقول ذات العمودين
   (بحد أدنى 170px/110px للعمود) تتجاوز عرض الشاشات الضيقة بدل الانضغاط لعمود
   واحد، وبما أن body تستخدم overflow: hidden لمنع تمرير الصفحة بالكامل، كانت
   الحقول التي تتجاوز الحافة (مركز البيع، العميل، مدير المبيعات...) تختفي تماماً
   ولا يمكن الوصول إليها إطلاقاً على الهاتف - وليست مجرد مشكلة شكلية */
@media (max-width: 768px) {
    .pos-fields-row {
        grid-template-columns: 1fr;
    }

    .pos-cart-item-details {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .pos-cart-item-details {
        grid-template-columns: 1fr;
    }

    .main-page-content {
        padding: 16px;
    }
}

/* ==========================================================================
   Responsive modals (all pages) - later rules intentionally override the base .modal-* block.
   - The box never taller than the viewport: header/footer stay put, only the body scrolls.
   - Form rows inside a modal reflow by available width (auto-fit) instead of the page-wide fixed
     4-column grid, which squeezed every field into a ~90px sliver in a 500px dialog.
   - Phones get a full-width bottom sheet with wrapping, evenly-sized footer buttons.
   ========================================================================== */
.modal-overlay {
    inset: 0;
    width: auto;
    height: auto;
    padding: 16px;
    box-sizing: border-box;
}

.modal-box {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
}

.modal-box > .modal-header,
.modal-box > .modal-footer { flex-shrink: 0; }

.modal-box > .modal-body,
.modal-box > .modal-box-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    max-height: none;              /* the box's own max-height governs now (overrides .modal-box-lg's 65vh) */
    overscroll-behavior: contain;
}

.modal-box .modal-header { padding: 16px 20px; }
.modal-box .modal-header h3 { margin: 0; overflow-wrap: anywhere; }

/* forms inside a modal: no double padding, fields wrap by width */
.modal-box .erp-grid-form { padding: 0; gap: 16px; }
.modal-box .form-inputs-row { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.modal-box .form-inputs-row.cols-12 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.modal-box .form-inputs-row.cols-12 > * { grid-column: auto; }
.modal-box .form-input-group { min-width: 0; }
.modal-box .form-input-group input,
.modal-box .form-input-group select,
.modal-box .form-input-group textarea,
.modal-box .searchable-select { width: 100%; max-width: 100%; box-sizing: border-box; }
.modal-box .table-responsive-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.modal-footer { flex-wrap: wrap; }

@media (max-width: 576px) {
    .modal-overlay { padding: 0; align-items: flex-end; }

    .modal-box {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 18px 18px 0 0;
        max-height: 92vh;
        max-height: 92dvh;
    }

    .modal-box .modal-header { padding: 14px 16px; }
    .modal-box .modal-header h3 { font-size: 16px; }
    .modal-box .modal-body { padding: 16px; }
    .modal-box .form-inputs-row { grid-template-columns: 1fr; }

    .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
    .modal-footer .modal-btn { flex: 1 1 calc(50% - 8px); min-width: 0; padding: 11px 10px; text-align: center; white-space: nowrap; }
    /* Delete gets its own full-width row above Cancel/Save so the destructive action is never a stray thumb-tap */
    .modal-footer .modal-btn.btn-danger { flex: 1 1 100%; order: -1; }
}

@media (max-height: 520px) and (orientation: landscape) {
    .modal-overlay { padding: 8px; }
    .modal-box { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
}

/* ===== Search / filter forms on ONE row (class "search-row" on the .erp-grid-form, or - automatically - any form
   whose .form-actions-left holds the magnifier Search button, so existing markup needs no edit) =====
   The fields and the action button(s) share a single wrapping flex line instead of the button
   dropping to its own row underneath - display:contents on the inner .form-inputs-row lets its
   fields flow into the same line as the button. Wraps naturally when there are many filters. */
.erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: 16px 20px;
}
.erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) > .form-inputs-row { display: contents; }
.erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) .form-input-group { flex: 1 1 140px; min-width: 130px; max-width: 300px; }
.erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) > .form-actions-left {
    flex: 0 0 auto;
    margin: 0 !important;
    padding: 0 !important;
    align-self: flex-end;
}
.erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) .erp-form-btn { min-height: 44px; white-space: nowrap; }

@media (max-width: 576px) {
    .erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) .form-input-group { flex-basis: 100%; max-width: none; }
    .erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) > .form-actions-left { flex: 1 1 100%; }
    .erp-grid-form:is(.search-row, :has(> .form-actions-left .fa-magnifying-glass)) > .form-actions-left .erp-form-btn { width: 100%; justify-content: center; }
}

/* Transparent click-anywhere-to-close backdrop for any open dropdown/popover (user menu,
   Favorites "More" menu, ...) - sits between the page chrome (z-index 100) and the popover
   itself (z-index 500+) so a click anywhere outside the popover closes it, with no JS needed.
   Only visible (and only intercepts clicks) while .active is toggled on. */
.click-away-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: transparent;
}

.click-away-backdrop.active {
    display: block;
}

/* Superadmin organization picker - matches the login inputs above */
.login-org-select {
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background-color: #fafafa;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: var(--transition);
}

[dir="rtl"] .login-org-select {
    padding: 13px 44px 13px 16px;
}

.login-org-select:focus {
    border-color: var(--primary-blue);
    background-color: var(--white);
    box-shadow: 0 0 0 3px rgba(138, 36, 82, 0.1);
}

/* ==========================================
   Superadmin organization switcher (navbar center)
   ========================================== */
.org-switcher {
    position: relative;
    display: inline-block;
}

.org-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 340px;
    background: var(--active-bg);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 7px 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-blue);
    cursor: pointer;
    transition: var(--transition);
}

.org-switcher-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-switcher-btn i {
    font-size: 11px;
    opacity: 0.8;
}

.org-switcher-btn:hover {
    border-color: var(--primary-blue);
    background: var(--white);
}

.org-switcher-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: 320px;
    max-width: 88vw;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    z-index: 500;
    transition: var(--transition);
}

.org-switcher-menu.show-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.org-switcher-head {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 8px 12px 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
}

.org-switcher-list {
    max-height: 340px;
    overflow-y: auto;
}

.org-switcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 9px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.org-switcher-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-switcher-icon {
    color: var(--text-muted);
    font-size: 13px;
}

.org-switcher-item:hover {
    background: var(--active-bg);
    color: var(--primary-blue);
}

.org-switcher-item:hover .org-switcher-icon {
    color: var(--primary-blue);
}

.org-switcher-item.active {
    background: var(--active-bg);
    color: var(--primary-blue);
}

.org-switcher-item.active .org-switcher-icon {
    color: var(--primary-blue);
}

.org-switcher-check {
    color: var(--primary-blue);
    font-size: 12px;
}

/* Mobile: the navbar-center slot is hidden (org name lives in the slide-in menu) - but the superadmin's
   organization switcher must stay reachable, so show it there as a compact building button whose menu
   drops down full-width under the header. */
@media (max-width: 991px) {
    .navbar-center:has(.org-switcher) { display: flex; margin: 0; min-width: 0; }
    .org-switcher-btn { padding: 8px 10px; max-width: 46px; }
    .org-switcher-btn span, .org-switcher-btn i.fa-chevron-down { display: none; }
    .org-switcher-menu {
        position: fixed; top: 64px; left: 12px; right: 12px; width: auto; max-width: none;
        transform: translateY(-8px);
    }
    .org-switcher-menu.show-dropdown { transform: translateY(0); }
}
.org-switcher-building { font-size: 13px; }
@media (min-width: 992px) { .org-switcher-building { display: none; } }

/* ==========================================
   CRM Settings hub - modern icon-card grid (ported from ERP's General Settings / SettingsGrid,
   re-tinted with the CRM wine/burgundy palette). The per-group accent is passed inline as --gs-accent.
   ========================================== */
.gs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
    gap: 16px;
}

.gs-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: var(--transition);
}

.gs-card::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--gs-accent, var(--primary-blue));
    opacity: 0;
    transition: var(--transition);
}

.gs-card:hover {
    transform: translateY(-4px);
    border-color: var(--gs-accent, var(--primary-blue));
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.11);
}

.gs-card:hover::before { opacity: 1; }

.gs-card-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: var(--gs-accent, var(--primary-blue));
    background: color-mix(in srgb, var(--gs-accent, var(--primary-blue)) 12%, #fff);
    transition: var(--transition);
}

.gs-card:hover .gs-card-icon {
    background: var(--gs-accent, var(--primary-blue));
    color: #fff;
    transform: scale(1.06);
}

.gs-card-body { flex: 1; min-width: 0; }

.gs-card-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 4px;
}

.gs-card-arrow {
    flex-shrink: 0;
    align-self: center;
    color: var(--text-muted);
    font-size: 14px;
    transition: var(--transition);
}

.gs-card:hover .gs-card-arrow {
    color: var(--gs-accent, var(--primary-blue));
    transform: translateX(3px);
}

[dir="rtl"] .gs-card:hover .gs-card-arrow { transform: translateX(-3px); }

@media (max-width: 576px) {
    .gs-grid { grid-template-columns: 1fr; }
}

.settings-group { margin-bottom: 26px; }

.settings-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
}

.settings-group-bar {
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: var(--gs-accent, var(--primary-blue));
}

.settings-group-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--gs-accent, var(--primary-blue));
    background: color-mix(in srgb, var(--gs-accent, var(--primary-blue)) 12%, #fff);
    padding: 2px 9px;
    border-radius: 20px;
}

/* ==========================================
   Settings trees (Departments / Centers) - hand-rolled expand/collapse tree, same classes as ERP's
   Chart of Accounts tree.
   ========================================== */
.act-tree-panel { max-height: 70vh; overflow-y: auto; padding: 8px 12px; }
.act-tree-node { font-size: 13.5px; }
.act-tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 6px;
    cursor: default;
}
.act-tree-row:hover { background-color: color-mix(in srgb, var(--active-bg) 55%, #fff); }
.act-tree-row.active { background-color: var(--active-bg); }
.act-tree-toggle {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.act-tree-toggle:disabled { visibility: hidden; }
.act-tree-code { font-family: monospace; color: var(--text-muted); flex-shrink: 0; }
.act-tree-name { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-tree-add-btn {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--primary-blue);
    opacity: 0.6;
    cursor: pointer;
}
.act-tree-add-btn:hover { opacity: 1; }
.act-tree-children {
    padding-inline-start: 20px;
    border-inline-start: 1px dashed var(--border-color);
    margin-inline-start: 9px;
}

/* Light search/filter toolbar sitting below a .table-card-header (ERP convention). */
.erp-search-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
}
.erp-search-toolbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.erp-search-box { position: relative; display: flex; align-items: center; flex: 1; min-width: 180px; max-width: 320px; }
.erp-search-box .form-control { width: 100%; padding-inline-end: 36px; }
.erp-search-icon { position: absolute; inset-inline-end: 12px; color: var(--text-muted); font-size: 13px; pointer-events: none; }
@media (max-width: 576px) { .erp-search-box { max-width: none; width: 100%; } }

/* Two-column "pick a record, then edit its rows" layout used by the Services / Employee link screens. */
.settings-split {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px) { .settings-split { grid-template-columns: 1fr; } }
.settings-pick-list { max-height: 420px; overflow-y: auto; }
.settings-pick-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    text-align: start;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}
.settings-pick-row:hover { background: color-mix(in srgb, var(--active-bg) 55%, #fff); }
.settings-pick-row.selected { background: var(--active-bg); color: var(--primary-blue); font-weight: 700; }
.settings-pick-sub { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.settings-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); }
.settings-inline-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--body-bg);
}
.settings-inline-add > .form-input-group { flex: 1; min-width: 180px; }
.settings-selected-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--active-bg);
    color: var(--primary-blue);
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}
.settings-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border-color); }
.settings-image-preview { max-width: 100%; max-height: 60vh; border-radius: 10px; display: block; margin: 0 auto; }

/* Action buttons inside a .table-card-header: one compact row (wraps on narrow screens) instead of stacked full-width
   buttons - .sub-action-btn is display:flex, so bare buttons in a span each take their own line. */
.card-header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.card-header-actions .sub-action-btn { flex: 0 0 auto; padding: 7px 14px; font-size: 13px; }
.table-card-header.with-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 10px 20px; }
.settings-alert { margin: 12px 16px 0; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }

/* Appointments calendar (by center): the optional specialist line on a booked card. */
.appointment-specialist { font-size: 12px; color: #64748b; margin: 2px 0 4px; }
.appointment-specialist i { margin-inline-end: 4px; }

/* Appointments calendar: an extra side-by-side lane (overlapping bookings) has no bookable slots of its own. */
.slot-none { background: transparent; }

/* ---- Time row highlight (click a time on the left) ------------------------------------------------------------
   A day can carry many center columns plus long spanning appointment cards, so following one time across the whole
   table is hard. Clicking a time selects its row: the row gets a soft brand band across every column, and the
   appointments that START at that time (the cells actually rendered in that row, including ones that span further
   down) get a ring so they are unmistakable. Booked cells keep their own status colour because their own rules use
   !important - the band shows through the ring/edges instead of replacing the status colour. */
.calendar-table tbody tr.time-row-active > td {
    background-color: var(--active-bg);
    box-shadow: inset 0 1.5px 0 #e2b9ca, inset 0 -1.5px 0 #e2b9ca;
}

.calendar-table tbody tr.time-row-active > td.time-header { background-color: #f6dfe9; }

.calendar-table tbody tr.time-row-active > td.slot-booked,
.calendar-table tbody tr.time-row-active > td.slot-attend,
.calendar-table tbody tr.time-row-active > td.slot-notattend {
    outline: 2px solid var(--primary-blue-light);
    outline-offset: -2px;
}

/* The time cell itself is the click target - a plain-looking text button until hovered/pressed. */
.calendar-table .time-row-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 4px;
    border: none;
    background: transparent;
    padding: 3px 4px;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.calendar-table .time-row-btn:hover { background-color: #f6dfe9; color: var(--primary-blue); }
.calendar-table .time-row-btn:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 1px; }
.calendar-table .time-row-btn.active {
    background-color: var(--primary-blue);
    color: #fff;
    box-shadow: 0 2px 6px rgba(138, 36, 82, 0.28);
}

/* Which time is highlighted, shown in the card header (falls back to a one-line hint when nothing is selected). */
.table-card-header .time-row-hint { font-size: 12px; font-weight: 500; opacity: 0.8; }
.time-row-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding-block: 2px;
    padding-inline: 10px 2px;
    font-size: 12px;
    font-weight: 600;
}
.time-row-chip-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-blue);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}
.time-row-chip-clear:hover { background: #fff; }

/* ---- Appointment working hours (Settings > Appointment Working Hours, and the calendar's own hours line) ---- */
/* The day's window shown under the calendar toolbar; derived from Settings, so it says when it is only the default. */
.appt-hours-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-dark);
}
.appt-hours-line > i { color: var(--primary-blue); }
.appt-hours-line.closed { color: #b45309; font-weight: 600; }
.appt-hours-line.closed > i { color: #b45309; }
.appt-hours-note { color: var(--text-muted); font-size: 0.78rem; }

/* Dual-format time display: 12-hour on top, 24-hour below in smaller gray font */
.working-hours-time {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}
.working-hours-24 {
    font-size: 0.75em;
    color: #94a3b8;
    font-weight: 400;
    display: block;
}

/* Time display in calendar grid: 12-hour and 24-hour format stacked */
.time-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.time-24h {
    font-size: 0.75em;
    color: #94a3b8;
    font-weight: 400;
    display: block;
}

/* Settings screen: what the screen means (two short paragraphs above the table). */
.appt-hours-help {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--body-bg);
    font-size: 13px;
    color: var(--text-dark);
    display: grid;
    gap: 6px;
}
.appt-hours-help p { margin: 0; line-height: 1.6; }
.appt-hours-nextday { color: var(--primary-blue); font-weight: 600; font-size: 0.78rem; margin-inline-start: 4px; }

/* ==========================================
   Appointments calendar - compact toolbar, center chips and the phone layout
   ========================================== */
.appt-toolbar {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.appt-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.appt-title-icon {
    flex: 0 0 auto;
    height: 38px;
    width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary-blue);
    background: transparent;
    color: var(--primary-blue);
    border-radius: 8px;
    font-weight: 600;
}

.appt-page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-blue);
    margin-inline-start: 12px;
}

.appt-toolbar-spacer { flex: 1 1 auto; }

.appt-hours-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-dark);
    margin-inline-start: 12px;
    white-space: nowrap;
}
.appt-hours-inline > i { color: var(--primary-blue); }

.appt-date-input { flex: 1 1 auto; min-width: 0; max-width: 220px; }

.appt-nav-btn, .appt-today-btn {
    flex: 0 0 auto;
    height: 38px;
    border: 1px solid var(--primary-blue);
    background: transparent;
    color: var(--primary-blue);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}
.appt-nav-btn { width: 38px; }
.appt-today-btn { padding: 0 14px; }
.appt-nav-btn:hover, .appt-today-btn:hover { background: var(--primary-blue); color: #fff; }

/* One chip per center; scrolls sideways instead of wrapping onto many lines on a phone. */
.center-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: thin;
}
.center-chip {
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: var(--text-dark);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}
.center-chip.active { background: var(--primary-blue); border-color: var(--primary-blue); color: #fff; font-weight: 600; }

@media (max-width: 768px) {
    .appt-date-input { max-width: none; }

    /* The schedule scrolls sideways inside its card (never the whole page); the time column stays in view. */
    .calendar-table { table-layout: auto; border-spacing: 0 3px; }
    .calendar-table th { min-width: 150px; font-size: 0.78rem; }
    .calendar-table td { min-width: 150px; padding: 3px 4px !important; }
    .calendar-table .time-header {
        min-width: 58px; width: 58px; font-size: 0.7rem; padding: 4px 3px !important;
        position: sticky; inset-inline-start: 0; z-index: 2; box-shadow: 0 0 0 1px var(--border-color);
    }
    .calendar-table th.time-header { z-index: 3; }
    /* The sticky time cell is only 58px wide there, so the highlight button loses its horizontal padding. */
    .calendar-table .time-row-btn { padding: 3px 0; }

    .appointment-card { gap: 4px; }
    .patient-name { font-size: 0.78rem; }
    /* Bigger touch targets, and the action buttons may wrap instead of overflowing the narrow cell. */
    .appointment-actions { flex-wrap: wrap; gap: 4px; }
    .appointment-actions button { padding: 7px 8px; font-size: 0.7rem; flex: 1 1 auto; }
    .btn-book-appointment { width: 100%; padding: 10px 6px; font-size: 0.8rem; }

}
.appt-date-input { min-width: 150px; }
@media (max-width: 768px) {
    .appt-date-row { gap: 6px; }
    .appt-nav-btn { width: 34px; }
    .appt-today-btn { padding: 0 10px; }
    .appt-date-input { padding-inline: 8px; font-size: 0.85rem; }
    .appt-title-icon { width: 34px; height: 34px; }
    .appt-page-title { font-size: 16px; margin-inline-start: 8px; }
    .appt-hours-inline { font-size: 0.75rem; margin-inline-start: 8px; }
}


/* Arabic (RTL): letter-spacing breaks the joining of Arabic letters, so it is disabled everywhere in RTL. */
:is([dir="rtl"], [dir="rtl"] *),
:is([dir="rtl"], [dir="rtl"] *)::before,
:is([dir="rtl"], [dir="rtl"] *)::after {
    letter-spacing: 0 !important;
}

/* ---- Scan ID (optional) on File Customer ---- */
.id-scan-body { padding: 14px 16px 16px; }
.id-scan-hint { margin: 0 0 12px; color: #666; font-size: 13px; }
.id-scan-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.id-slot { border: 1px dashed #cdbfc6; border-radius: 10px; padding: 10px; background: #fcfafb; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.id-slot.has-picture { border-style: solid; border-color: #e3d6dc; background: #fff; }
.id-slot-title { font-weight: 600; font-size: 13px; color: var(--primary-blue); }
.id-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.id-slot-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; border-radius: 8px;
    background: #f5eef1; color: var(--primary-blue); cursor: pointer; font-size: 13px; text-align: center; padding: 8px; }
.id-slot-empty i { font-size: 26px; }
.id-slot-empty.disabled, .id-small-btn.disabled { opacity: .5; pointer-events: none; }
.id-thumb { width: 100%; max-height: 190px; object-fit: contain; border-radius: 8px; background: #f3f3f3; cursor: zoom-in; }
.id-slot-state { font-size: 12px; }
.id-slot-state.pending { color: #b26a00; }
.id-slot-state.stored { color: #1a7f4b; }
.id-slot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.id-small-btn { padding: 4px 10px; font-size: 12px; cursor: pointer; }
.id-small-btn.id-danger { color: #b3261e; border-color: #e5b9b5; }
.id-scan-progress { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #555; }
.id-scan-bar { height: 6px; border-radius: 3px; background: #eadde3; overflow: hidden; }
.id-scan-bar-fill { height: 100%; background: var(--primary-blue); transition: width .3s ease; }
.id-scan-result { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.id-scan-result.ok { background: #eaf6ef; border: 1px solid #bfe1cc; }
.id-scan-result.warn { background: #fff6e5; border: 1px solid #f0d9a6; }
.id-scan-review { color: #666; font-size: 12px; }
.id-scan-keep { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; cursor: pointer; }
.id-viewer { max-width: 760px; width: 94vw; }
.id-viewer-body { text-align: center; max-height: 70vh; overflow: auto; }
.id-viewer-body img { max-width: 100%; height: auto; border-radius: 6px; }
@media (max-width: 576px) {
    .id-scan-slots { grid-template-columns: 1fr; }
    .id-slot-empty { min-height: 96px; }
}

/* Global Back button (Shared/BackButton.razor) - above every page except home */
.page-back-row { padding: 10px 24px 0; }
.page-back-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border: 1px solid #cbd5e1; border-radius: 8px; background: var(--white, #fff); color: var(--primary-blue); font-size: 13px; font-weight: 700; cursor: pointer; transition: var(--transition); }
.page-back-btn:hover { background: var(--primary-blue); color: var(--white, #fff); border-color: var(--primary-blue); }
[dir="rtl"] .page-back-btn i { transform: scaleX(-1); }
@media (max-width: 768px) { .page-back-row { padding: 8px 12px 0; } }

/* ===== Grid action buttons = compact colour-coded icon buttons (tooltip comes from action-icons.js) ===== */
[data-ai] {
    --odb: #186493;
    font-size: 0 !important; gap: 0 !important;
    width: 34px; height: 34px; padding: 0 !important; margin-inline: 2px;
    border-radius: 10px; border: 1px solid color-mix(in srgb, var(--odb) 28%, transparent) !important;
    background: color-mix(in srgb, var(--odb) 10%, #fff) !important; color: var(--odb) !important;
    text-decoration: none; vertical-align: middle;
}
[data-ai] i, [data-ai] i[class*="fa-"] { font-size: 14px !important; margin: 0 !important; }
[data-ai]:hover:not(:disabled) {
    background: var(--odb) !important; color: #fff !important; transform: translateY(-1px);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--odb) 35%, transparent);
}
[data-ai]:focus-visible { outline: 2px solid var(--odb); outline-offset: 2px; }
[data-ai="edit"] { --odb: #15803d; }
[data-ai="view"] { --odb: #186493; }
[data-ai="print"] { --odb: #475569; }
[data-ai="warn"] { --odb: #b45309; }
[data-ai="ok"] { --odb: #15803d; }
[data-ai="danger"] { --odb: #b91c1c; }

/* ---- Appointments page: Refresh / Quick Add Customer / WhatsApp reminder, and the WhatsApp Templates settings screen ---- */
.appt-today-btn:disabled { opacity: .6; cursor: default; }
.appt-today-btn i { margin-inline-end: 4px; }
.appt-add-customer-btn { background: var(--primary-blue); color: #fff; }
.appt-add-customer-btn:hover { background: var(--primary-blue-dark, var(--primary-blue)); filter: brightness(.92); }
@media (max-width: 640px) {
    .appt-btn-text { display: none; }
    .appt-today-btn i { margin-inline-end: 0; }
}

.appt-customer-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.appt-inline-link {
    border: none; background: none; padding: 0; cursor: pointer;
    color: var(--primary-blue); font-weight: 600; font-size: 0.82rem; text-decoration: none;
}
.appt-inline-link:hover { text-decoration: underline; }

.appt-mobile-row { display: flex; gap: 8px; }
.appt-mobile-row .appt-code-select { flex: 0 0 120px; }
.appt-mobile-row input { flex: 1 1 auto; min-width: 0; }
.appt-quick-hint { font-size: 0.8rem; color: var(--text-muted); margin: 4px 0 8px; }
.appt-quick-error {
    margin-top: 8px; padding: 8px 12px; border-radius: 8px;
    background: #fdecea; color: #b3261e; font-size: 0.85rem; font-weight: 600;
}

/* WhatsApp: green icon on the appointment card, green send button in the reminder dialog */
.card-icon-btn.wa-btn { color: #1fa855; font-size: 0.9rem; }
.card-icon-btn.wa-btn:hover { color: #fff; background-color: #25d366; }
.wa-title-icon { color: #25d366; margin-inline-end: 6px; }
a.modal-btn.wa-send-btn, button.modal-btn.wa-send-btn {
    background: #25d366; color: #fff; border: none; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
a.modal-btn.wa-send-btn:hover { background: #1fa855; color: #fff; }
button.modal-btn.wa-send-btn:disabled { opacity: .5; cursor: default; }

/* Templates screen */
.wa-tpl-snippet { max-width: 420px; color: var(--text-muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-tpl-body { font-family: inherit; line-height: 1.6; min-height: 160px; }
.wa-tpl-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.wa-tpl-token {
    border: 1px solid var(--border-color); background: var(--bg-light, #f7f7f9); color: var(--primary-blue);
    border-radius: 6px; padding: 3px 8px; font-size: 0.78rem; font-family: monospace; cursor: pointer;
}
.wa-tpl-token:hover { background: var(--primary-blue); color: #fff; }
.wa-tpl-preview {
    white-space: pre-wrap; line-height: 1.7; padding: 12px 14px; border-radius: 10px;
    background: #e7f8ec; border: 1px solid #c4ebd0; max-height: 260px; overflow: auto; font-size: 0.88rem;
}
.wa-tpl-flags { display: flex; flex-direction: column; gap: 6px; }
.wa-tpl-flags label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
