/* =============================================================================
   ترويسة التطبيق وقائمة الحساب — تصميم المالك المعتمد (2026-12-01)
   -----------------------------------------------------------------------------
   الترميز: Shared/MainLayout.razor (أصناف hx-*) وShared/Header/OrgSwitchList.razor.
   يُحمَّل آخر ملف في _Host.cshtml: قواعد الجوال القديمة على .header و.user-menu-button
   كثيرة وبعضها !important، فالقواعد هنا بنوعية .header.hx-header (0,2,0) فما فوق، و!important
   حيث تنازع قاعدة !important قديمة فقط.

   - سطح المكتب (≥1024px): صفّ واحد 64px — ☰، بحث يتّسع عند التركيز، «إنشاء»؛ ثم «التواصل»،
     الإشعارات، «المزيد»، اسم المنشأة ▾، المستخدم.
   - اللوحي (768–1023px): الصفّ نفسه بلا تسميات.
   - الجوال (≤767px): ☰، الشعار، اسم المنشأة، البحث، الإشعارات، الصورة + شريط سفلي بخمسة.
   الألوان توكنات فقط، والحواف من --radius-system (ShapeContractTests).
   ============================================================================= */

/* ---------- الصفّ ---------- */
.header.hx-header {
    height: 64px;
    min-height: 64px;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    flex-wrap: nowrap !important;
    row-gap: 0;
    background: var(--background-primary);
    box-shadow: none;
    border-bottom: 1px solid var(--border-color);
}

/* أي قائمة مفتوحة (أو نافذة مساعدة الصفحة المرسومة داخل «المزيد») ترفع الترويسة فوق محتوى
   الصفحة — امتداد لإصلاح 16acf28 (crm-styles.css) إلى طبقات الترويسة الجديدة. */
.header.hx-header:has(.hx-pop.is-open, .user-dropdown-menu, .notification-dropdown, .global-search-preview, .page-help-drawer, .presence-overlay) {
    z-index: var(--z-fixed, 1030) !important;
}

.header.hx-header .hx-start {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1 1 auto;
    min-width: 0;
}

.header.hx-header .hx-end {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex: 0 0 auto !important;
    min-width: 0;
    flex-wrap: nowrap !important;
}

.hx-mobile-only { display: none; }

/* ---------- أزرار أيقونية ---------- */
.header.hx-header .hx-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-secondary);
    box-shadow: none;
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.22, 0.61, 0.36, 1), color 150ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.header.hx-header .hx-icon-btn:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
    transform: none;
}

.header.hx-header .hx-icon-btn.is-active,
.header.hx-header .hx-icon-btn[aria-expanded="true"] {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.header.hx-header .hx-icon-btn .material-icons,
.header.hx-header .hx-icon-btn .sx-icon {
    font-size: 22px;
    color: inherit;
}

.header.hx-header .notification-bell {
    margin-inline-start: 0;
}

/* شارة العدد: بلون العلامة (لا إشارة «عاجل» في النظام تبرّر الأحمر)، وحدّها «99». */
.hx-badge {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 var(--space-1);
    border: 2px solid var(--background-primary);
    border-radius: var(--radius-full);
    background: var(--primary-color);
    color: var(--background-primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    pointer-events: none;
}

.hx-badge.is-hot { background: var(--error-color); }

.hx-dot {
    position: absolute;
    top: 9px;
    inset-inline-end: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 2px var(--background-primary);
    pointer-events: none;
}

/* ---------- البحث ---------- */
@media (min-width: 768px) {
    .header.hx-header .hx-search {
        width: 260px !important;
        max-width: none !important;
        min-width: 0 !important;
        flex: 0 1 auto;
        height: 44px;
        min-height: 44px;
        padding: 0 var(--space-3);
        background: var(--background-secondary);
        box-shadow: none;
        transition: width 200ms cubic-bezier(0.22, 0.61, 0.36, 1), background-color 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
    }

    .header.hx-header .hx-search:focus-within {
        width: min(440px, 36vw) !important;
        background: var(--background-primary);
        border-color: var(--primary-color);
    }

    .header.hx-header .hx-search .form-control {
        font-size: var(--font-size-base);
    }

    /* المعاينة تمتدّ نحو داخل الصفحة لا نحو حافتها */
    .header.hx-header .hx-search .global-search-preview {
        inset-inline-start: 0;
        inset-inline-end: auto;
    }
}

.hx-kbd {
    flex: none;
    font-family: inherit;
    font-size: var(--font-size-xs);
    line-height: 1.6;
    padding: 0 var(--space-1);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--background-primary);
    color: var(--text-muted);
    direction: ltr;
    white-space: nowrap;
}

.hx-search:focus-within .hx-kbd { display: none; }

/* ---------- «إنشاء» ---------- */
.hx-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.header.hx-header .hx-create-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    flex: none;
    width: auto;
    height: 44px;
    padding: 0 var(--space-4) 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--primary-color);
    color: var(--background-primary);
    font-size: var(--font-size-sm);
    font-weight: 700;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.header.hx-header .hx-create-btn:hover { background: var(--primary-dark); }

.header.hx-header .hx-create-btn .material-icons,
.header.hx-header .hx-create-btn .sx-icon {
    font-size: 20px;
    color: inherit;
}

/* ---------- القوائم المنسدلة ---------- */
.hx-pop {
    position: absolute;
    top: calc(100% + var(--space-2));
    inset-inline-end: 0;
    z-index: var(--z-dropdown, 1000);
    width: 300px;
    max-width: min(380px, calc(100vw - 2 * var(--space-4)));
    max-height: calc(100vh - 64px - var(--space-6));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-2);
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    color: var(--text-primary);
    text-align: start;
}

/* «إنشاء» في جهة البداية: تمتدّ قائمتها نحو الداخل */
.hx-create-pop {
    inset-inline-start: 0;
    inset-inline-end: auto;
    width: 280px;
}

.hx-org-pop { width: 360px; }

/* «المزيد» تُرسم دائماً وتُخفى بالرؤية: نافذة مساعدة الصفحة تعيش داخلها وتبقى ظاهرة.
   بلا transform ولا opacity على القائمة حتى لا تُحبس النافذة الثابتة داخلها. */
.hx-more-pop:not(.is-open) {
    visibility: hidden;
    pointer-events: none;
}

.hx-more-pop .page-help-overlay,
.hx-more-pop .page-help-drawer {
    visibility: visible;
    pointer-events: auto;
}

.hx-pop-title {
    padding: var(--space-1) var(--space-3) var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-muted);
}

.hx-pop-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hx-pop-list > li { list-style: none; }

.header.hx-header .hx-pop-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3);
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    line-height: 1.4;
    text-align: start;
    text-decoration: none;
    box-shadow: none;
    cursor: pointer;
}

.header.hx-header .hx-pop-row:hover,
.header.hx-header .hx-pop-row:focus-visible {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.header.hx-header .hx-pop-row[disabled] { opacity: 0.6; cursor: wait; }

.header.hx-header .hx-pop-row .material-icons,
.header.hx-header .hx-pop-row .sx-icon {
    flex: none;
    font-size: 20px;
    color: var(--text-secondary);
}

.hx-row-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hx-count {
    flex: none;
    margin-inline-start: auto;
    min-width: 24px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-full);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
    font-size: var(--font-size-xs);
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.hx-pop-empty {
    display: block;
    padding: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.hx-divider {
    height: 1px;
    margin: var(--space-2);
    background: var(--border-color);
}

.header.hx-header .hx-call-dot {
    position: static;
    flex: none;
    margin-inline-start: auto;
}

.header.hx-header .hx-status-row { cursor: default; color: var(--text-secondary); }
.header.hx-header .hx-status-row:hover { background: transparent; }

.hx-status-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

/* مساعدة الصفحة واللغة: مكوّنان بزرّيهما الخاصّين، يُعرضان صفّين كبقية القائمة. */
.hx-pop-item,
.hx-pop-item .language-switcher { width: 100%; }

.header.hx-header .hx-more-pop .hx-pop-item > .page-help-btn,
.header.hx-header .hx-more-pop .hx-lang-item .language-icon-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: var(--space-3) !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 44px !important;
    padding: var(--space-2) var(--space-3) !important;
    border: 0 !important;
    border-radius: var(--radius-lg) !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
    font-size: var(--font-size-sm) !important;
    font-weight: 500 !important;
    text-align: start;
    transform: none !important;
}

.header.hx-header .hx-more-pop .hx-pop-item > .page-help-btn:hover,
.header.hx-header .hx-more-pop .hx-lang-item .language-icon-btn:hover {
    background: var(--background-secondary) !important;
}

.header.hx-header .hx-more-pop .page-help-btn .tool-label {
    display: inline !important;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.header.hx-header .hx-more-pop .page-help-btn .material-icons,
.header.hx-header .hx-more-pop .page-help-btn .sx-icon,
.header.hx-header .hx-more-pop .language-icon-btn .material-icons,
.header.hx-header .hx-more-pop .language-icon-btn .sx-icon {
    font-size: 20px !important;
    color: var(--text-secondary) !important;
}

/* ---------- مبدّل المنشأة ---------- */
.header.hx-header .hx-org-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex: none;
    width: auto;
    max-width: 240px;
    height: 44px;
    padding: 0 var(--space-2) 0 var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--background-primary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.header.hx-header .hx-org-btn:hover,
.header.hx-header .hx-org-btn[aria-expanded="true"] {
    border-color: var(--primary-color);
}

.header.hx-header .hx-org-btn .material-icons {
    flex: none;
    font-size: 18px;
    color: var(--text-muted);
}

.hx-org-btn-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- المستخدم ---------- */
.header.hx-header .hx-user-wrap { z-index: auto; }

.header.hx-header .hx-user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 240px;
    min-height: 44px;
    padding: 3px var(--space-2);
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    box-shadow: none;
    text-align: start;
    cursor: pointer;
}

.header.hx-header .hx-user-chip:hover { background: var(--background-secondary); border: 0; box-shadow: none; }

.header.hx-header .hx-user-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
}

.header.hx-header .hx-user-text .user-name {
    max-width: 150px;
    font-size: var(--font-size-sm);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
}

.header.hx-header .hx-user-text .user-role {
    font-size: var(--font-size-xs);
    line-height: 1.3;
    color: var(--text-muted);
}

.header.hx-header .hx-caret {
    flex: none;
    font-size: 18px !important;
    color: var(--text-muted);
    transition: transform 150ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.header.hx-header .hx-caret.is-open,
.header.hx-header [aria-expanded="true"] > .hx-caret { transform: rotate(180deg); }

.hx-avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--background-primary);
    font-size: var(--font-size-sm);
    font-weight: 700;
    line-height: 1;
}

.hx-avatar--lg {
    width: 46px;
    height: 46px;
    font-size: 18px;
}

/* نقطة الاتصال: خضراء = الاتصال اللحظي قائم؛ حلقة رمادية = منقطع (يُعاد الاتصال). */
.hx-presence-dot {
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--background-primary);
    background: var(--success-color);
}

.hx-presence-dot.is-offline {
    background: var(--background-primary);
    box-shadow: inset 0 0 0 2px var(--text-muted);
}

/* ---------- قائمة الحساب ---------- */
.header.hx-header .user-menu-container .user-dropdown-menu.hx-account {
    left: auto;
    right: auto;
    inset-inline-end: 0;
    width: 360px;
    min-width: 0;
    max-width: min(380px, calc(100vw - 2 * var(--space-4)));
    padding: var(--space-2);
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    text-align: start;
}

.hx-acc-id {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    margin-bottom: var(--space-1);
    border-radius: var(--radius-lg);
    background: var(--background-secondary);
}

.hx-acc-id .hx-presence-dot { border-color: var(--background-secondary); }

.hx-acc-id-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.hx-acc-name,
.hx-acc-mail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hx-acc-name {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
}

.hx-acc-role {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--primary-color);
}

.hx-acc-mail {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: left;
}

html[dir="rtl"] .hx-acc-mail { text-align: right; }

.hx-sec-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3) var(--space-1);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--text-muted);
}

.hx-sec-link {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.hx-sec-link:hover { text-decoration: underline; }

.header.hx-header .hx-logout,
.header.hx-header .hx-logout .material-icons {
    color: var(--error-color);
}

.header.hx-header .hx-logout:hover {
    background: rgba(var(--error-rgb), 0.08);
    color: var(--error-color);
}

/* رصيد الاشتراكات داخل القائمتين */
.hx-pop .organization-credit-hint,
.hx-account .organization-credit-hint {
    margin: var(--space-1) var(--space-2);
}

/* ---------- «منشآتي» (OrgSwitchList) ---------- */
.hx-orgs { display: grid; gap: 2px; }

.hx-org-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 44px;
    margin: var(--space-1) var(--space-2) var(--space-2);
    padding: 0 var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--background-secondary);
    color: var(--text-muted);
    cursor: text;
}

.hx-org-search:focus-within {
    border-color: var(--primary-color);
    background: var(--background-primary);
}

.hx-org-search .material-icons { font-size: 18px; }

/* !important: قواعد الجوال العامة تفرض على كل input ارتفاعاً وحشوة وإطاراً */
.hx-orgs .hx-org-search input {
    position: static !important;
    flex: 1 1 auto;
    width: auto !important;
    min-width: 0;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: none;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-base) !important;
}

.hx-org-list { display: grid; gap: 2px; }

/* المسار الواحد min-content افتراضياً فيتسع لاسم المنشأة الطويل ويدفع القائمة خارج الشاشة
   (لقطة التجربة: الشارة وعلامة ✓ و«عرض الكل» مقصوصة يساراً). نحصره بعرض القائمة ليعمل الاختصار بالنقاط. */
.hx-orgs,
.hx-org-list {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    max-width: 100%;
}

.hx-orgs .hx-org {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.hx-pop,
.header .user-menu-container .user-dropdown-menu { overflow-x: hidden; }

.hx-orgs .hx-org > .hx-chip,
.hx-orgs .hx-org > .hx-org-check { flex: none; }

.hx-orgs .hx-org {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    height: auto;
    min-height: 52px;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-primary);
    text-align: start;
    font-weight: 400;
    box-shadow: none;
    cursor: pointer;
}

.hx-orgs .hx-org:hover,
.hx-orgs .hx-org:focus-visible { background: var(--background-secondary); }

.hx-orgs .hx-org.is-current,
.hx-orgs .hx-org.is-current:hover { background: rgba(var(--primary-rgb), 0.08); }

.hx-org-tile {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-secondary);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 800;
}

.hx-org.is-current .hx-org-tile {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--background-primary);
}

.hx-org-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.hx-org-name,
.hx-org-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hx-org-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.35;
}

.hx-org.is-current .hx-org-name { color: var(--primary-color); }

.hx-org.is-unnamed .hx-org-name {
    color: var(--text-muted);
    font-style: italic;
}

.hx-org-sub {
    font-size: var(--font-size-xs);
    line-height: 1.35;
    color: var(--text-muted);
}

.hx-org-sub:empty { display: none; }

.hx-org-check {
    flex: none;
    font-size: 20px;
    color: var(--primary-color);
}

.hx-org-empty {
    padding: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-align: center;
}

.hx-chip {
    flex: none;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.hx-chip.is-expired {
    background: rgba(var(--error-rgb), 0.1);
    color: var(--error-color);
}

.hx-chip.is-trial,
.hx-chip.is-paused {
    background: rgba(var(--warning-rgb), 0.14);
    color: var(--warning-color);
}

.hx-expired-count { margin-inline-start: auto; }

/* ---------- الشريط الجانبي: الشعار بحجمه السابق مع اسم المنصة (طلب المالك 2026-12-01) ---------- */
.brand-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding-top: var(--space-3);
    margin-bottom: var(--space-4);
    text-align: center;
}

.brand-logo--sidebar {
    display: block;
    width: auto;
    height: auto;
    max-width: 140px;
    margin: 0 auto;
    object-fit: contain;
}

.brand-sidebar__name {
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    color: inherit;
}

/* ---------- الشريط السفلي (مخفيّ فوق الجوال) ---------- */
.hx-tabbar { display: none; }

/* =============================================================================
   اللوحي (768–1023px): الصفّ نفسه، بلا تسميات
   ============================================================================= */
@media (max-width: 1023px) {
    .header.hx-header .hx-create-btn { padding: 0; width: 44px; justify-content: center; }
    .header.hx-header .hx-create-btn .hx-label,
    .header.hx-header .hx-org-btn-name,
    .header.hx-header .hx-user-text,
    .hx-kbd { display: none !important; }
    .header.hx-header .hx-org-btn { padding: 0 var(--space-2); }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .header.hx-header {
        height: 64px !important;
        padding: 0 var(--space-3) !important;
        gap: var(--space-2) !important;
    }
    .header.hx-header .hx-start { flex: 1 1 auto !important; min-width: 0 !important; }
    .header.hx-header .hx-search { width: 200px !important; }
    .header.hx-header .hx-search:focus-within { width: min(320px, 40vw) !important; }
    .header.hx-header .hx-user-chip { padding: 3px; }
}

/* =============================================================================
   الجوال (≤767px)
   ============================================================================= */
@media (max-width: 767px) {
    :root:has(.hx-tabbar) {
        --hx-tabbar-space: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .header.hx-header {
        --m-header-h: 56px;
        height: calc(56px + env(safe-area-inset-top, 0px)) !important;
        min-height: 0 !important;
        padding: env(safe-area-inset-top, 0px) max(var(--space-2), env(safe-area-inset-right, 0px)) 0 max(var(--space-2), env(safe-area-inset-left, 0px)) !important;
        gap: var(--space-1) !important;
    }

    .header.hx-header .hx-start {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        gap: var(--space-1) !important;
    }

    .header.hx-header .hx-end { gap: 0 !important; }

    .hx-mobile-only { display: inline-flex; }

    .hx-mobile-brand {
        flex: none;
        align-items: center;
    }

    .header.hx-header .brand-header { display: inline-flex; align-items: center; }

    .header.hx-header .hx-mobile-brand .brand-logo--header {
        display: block;
        width: auto !important;
        height: auto !important;
        max-width: 64px !important;
        max-height: 30px !important;
        object-fit: contain;
    }

    .hx-mobile-org {
        display: block;
        flex: 0 1 auto;
        min-width: 0;
        max-width: 34vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: var(--font-size-sm);
        font-weight: 700;
        color: var(--text-secondary);
    }

    /* البحث أيقونة في آخر المجموعة؛ التركيز يبسطه شريطاً (MainLayout.razor.css). */
    .header.hx-header .hx-search {
        margin-inline-start: auto;
        border-color: transparent;
        background: transparent;
        box-shadow: none;
    }

    .header.hx-header .hx-search:focus-within {
        border-color: var(--primary-color);
        background: var(--background-primary);
    }

    /* ما انتقل إلى الشريط السفلي أو إلى قائمة الحساب */
    .header.hx-header .hx-create-btn,
    .header.hx-header .hx-comms-btn,
    .header.hx-header .hx-more-btn,
    .header.hx-header .hx-org-wrap,
    .header.hx-header .hx-user-chip .hx-caret {
        display: none !important;
    }

    .header.hx-header .hx-user-chip {
        padding: 0 !important;
        min-width: 44px;
        justify-content: center;
    }

    .header.hx-header .hx-user-chip .hx-avatar { width: 34px; height: 34px; }

    /* القوائم أوراق سفلية فوق الشريط السفلي */
    .header.hx-header .hx-pop.hx-sheet,
    .header.hx-header .user-menu-container .user-dropdown-menu.hx-account {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: var(--hx-tabbar-space, 0px) !important;
        width: 100% !important;
        max-width: none !important;
        max-height: min(72dvh, calc(100dvh - var(--hx-tabbar-space, 0px) - 56px - env(safe-area-inset-top, 0px))) !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        border-bottom: 0 !important;
        padding: var(--space-2) max(var(--space-2), env(safe-area-inset-right, 0px)) calc(var(--space-2) + env(safe-area-inset-bottom, 0px)) max(var(--space-2), env(safe-area-inset-left, 0px)) !important;
        box-shadow: 0 -10px 30px rgba(var(--primary-rgb), 0.12) !important;
        z-index: var(--z-popover, 1060);
    }

    /* «المزيد» على الجوال شبكة أيقونات بثلاثة أعمدة كما في النموذج */
    .header.hx-header .hx-more-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--space-2);
    }

    .header.hx-header .hx-more-list .hx-pop-row,
    .header.hx-header .hx-more-pop .hx-pop-item > .page-help-btn,
    .header.hx-header .hx-more-pop .hx-lang-item .language-icon-btn {
        flex-direction: column !important;
        justify-content: center !important;
        gap: var(--space-1) !important;
        min-height: 72px !important;
        padding: var(--space-2) var(--space-1) !important;
        background: var(--background-secondary) !important;
        font-size: var(--font-size-xs) !important;
        text-align: center !important;
    }

    .header.hx-header .hx-more-list .hx-row-label,
    .header.hx-header .hx-more-pop .page-help-btn .tool-label {
        flex: 0 0 auto;
        font-size: var(--font-size-xs) !important;
        line-height: 1.3;
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .header.hx-header .hx-more-list .hx-count {
        margin-inline-start: 0;
    }

    .header.hx-header .hx-more-list .hx-status-row { grid-column: 1 / -1; flex-direction: row !important; min-height: 44px !important; }

    /* ---------- الشريط السفلي ---------- */
    .hx-tabbar {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 990; /* تحت درج الشريط الجانبي (1001) وخلفيته (999) */
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        align-items: stretch;
        height: var(--hx-tabbar-space, 64px);
        padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
        background: var(--background-primary);
        border-top: 1px solid var(--border-color);
    }

    .hx-tabbar .hx-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        width: auto;
        height: auto;
        min-width: 0;
        min-height: 56px;
        padding: 0 var(--space-1);
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--text-muted);
        font-size: var(--font-size-xs);
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

    .hx-tabbar .hx-tab.is-active { color: var(--primary-color); }

    .hx-tabbar .hx-tab .material-icons { font-size: 24px; }

    .hx-tab-icon {
        position: relative;
        display: inline-flex;
    }

    .hx-tab-icon .hx-badge {
        top: -6px;
        inset-inline-end: -12px;
    }

    .hx-tab-icon .hx-dot { top: 0; inset-inline-end: -2px; }

    .hx-tab-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hx-fab {
        display: inline-grid;
        place-items: center;
        width: 48px;
        height: 48px;
        margin-top: calc(-1 * var(--space-4));
        border-radius: var(--radius-xl);
        background: var(--primary-color);
        color: var(--background-primary);
        box-shadow: 0 6px 14px rgba(var(--primary-rgb), 0.35);
    }

    .hx-fab .material-icons { color: inherit; }

    /* المحتوى والأزرار العائمة فوق الشريط */
    .main-content:has(.hx-tabbar) .content {
        padding-bottom: calc(var(--hx-tabbar-space, 64px) + var(--space-4)) !important;
    }

    .main-content:has(.hx-tabbar) .support-fab-wrapper {
        bottom: calc(var(--hx-tabbar-space, 64px) + var(--space-3)) !important;
    }
}

/* =============================================================================
   الحركة المخفّفة
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
    .header.hx-header .hx-icon-btn,
    .header.hx-header .hx-search,
    .header.hx-header .hx-create-btn,
    .header.hx-header .hx-caret,
    .header.hx-header .hx-pop-row,
    .hx-orgs .hx-org,
    .hx-tabbar .hx-tab {
        transition: none !important;
        animation: none !important;
    }

    .header.hx-header .user-dropdown-menu.hx-account { animation: none !important; }
}
