/* ==========================================================================
   زاجل — طبقة الهوية البصرية
   ==========================================================================

   مصدرٌ واحد لألوان المنظومة. اللوحة مأخوذة حرفياً من حزمة الشعار
   (static/img/brand/BRAND.md): كحليٌّ للثقة والأرشيف الرسمي، وذهبيٌّ
   هادئ لكنةً وحيدة، وعاجيٌّ أرضاً دافئة.

   القاعدة التي تحكم هذا الملف: **لكنةٌ واحدة، ولونُ الحالة للحالة وحدها.**
   الذهبي يعني «هنا موضع نظرك»، ولا يُستعمل زينةً. والأخضر والكهرماني
   والأحمر تعني نجاحاً وتحذيراً وخطراً — لا تُستعمل لتمييز بطاقةٍ عن
   جارتها. ما كان قبل هذا الملف قوس قزح: كل بطاقة بلونٍ مختلف، فلا
   يدلّ لونٌ على شيء ولا تُقرأ أولويةٌ من الشاشة.
   ========================================================================== */

:root {
    /* ── اللوحة الأساس ───────────────────────────────────────────────── */
    --z-navy:        #12395B;   /* كحلي زاجل — الأساس */
    --z-navy-deep:   #0B2540;   /* أعمق — عمق التدرّج */
    --z-navy-lift:   #1B4C77;   /* أفتح — التحويم والروابط */
    --z-navy-tint:   #17456C;   /* طرف التدرّجات الكحلية */
    --z-gold:        #D4A93C;   /* ذهبي الختم — اللكنة الوحيدة */
    --z-gold-deep:   #A8811F;   /* ذهبيٌّ داكن — نصٌّ على أرضٍ فاتحة */
    --z-gold-lift:   #E0B850;   /* أفتح — تحويم الزر الذهبي */
    --z-gold-ink:    #3A2A05;   /* نصٌّ فوق الذهبي */
    --z-gold-wash:   #FBF3DE;   /* أرض اللكنة */
    --z-ivory:       #F5F7FA;   /* أرض الصفحة — باردة محايدة (D-064؛ الاسم باقٍ للتوافق) */
    --z-slate:       #5B6B7A;   /* رمادي النص المساند */
    --z-line:        #DDE3EA;   /* حدٌّ محايد بارد */

    /* ── المحايدات (منحازة دفئاً لتؤالف الكحلي — لا رماديّ ميّت) ────── */
    --z-ink:         #14202B;   /* النص الأساس */
    --z-ink-soft:    #46586A;   /* النص الثانوي */
    --z-ink-faint:   #6B7A88;   /* التسميات والوحدات — كان #8494A3 بتباين 3.1:1 دون AA */
    --z-surface:     #FFFFFF;   /* سطح البطاقات */
    --z-surface-alt: #F7F8FA;   /* سطحٌ بديل — الصفوف والترويسات */
    --z-hairline:    #E3E7EC;   /* خطٌّ شعري بين العناصر */
    --z-side:        #0F2B45;   /* الشريط الجانبي — كحليٌّ يمتدّ من الترويسة (D-064) */
    --z-ground:      var(--z-ivory); /* أرض الصفحة */

    /* ── ألوان الحالة — للحالة فقط، وبإشباعٍ مكبوح ─────────────────── */
    --z-ok:          #2E7D5B;
    --z-ok-wash:     #EAF5EF;
    --z-warn:        #B4791F;
    --z-warn-wash:   #FDF4E3;
    --z-risk:        #B4453C;
    --z-risk-wash:   #FBEDEB;

    /* ── الظلال: كحليةٌ لا سوداء — الظلّ الأسود يُوسِّخ العاجي ──────── */
    --z-shadow-sm:  0 1px 2px rgba(18, 57, 91, .06);
    --z-shadow:     0 2px 8px rgba(18, 57, 91, .07), 0 1px 2px rgba(18, 57, 91, .05);
    --z-shadow-lg:  0 12px 28px rgba(18, 57, 91, .12), 0 4px 8px rgba(18, 57, 91, .06);

    --z-radius:     14px;
    --z-radius-sm:  10px;

    /* ── سُلَّم الطبقات — بدل أرقام z-index المتناثرة في القوالب ────── */
    --z-layer-sticky:    30;    /* ترويسات لاصقة وأشرطة */
    --z-layer-dropdown:  40;    /* قوائم منسدلة */
    --z-layer-overlay:   50;    /* حُجُب وأدراج */
    --z-layer-modal:     100;   /* نوافذ منبثقة */
    --z-layer-toast:     110;   /* إشعارات منزلقة */
    --z-layer-watermark: 9999;  /* علامة المساءلة المائية — فوق الكل */
}

/* ==========================================================================
   ١ — الشريط العلوي والقائمة الجانبية
   ========================================================================== */

.z-topbar {
    background: linear-gradient(135deg, var(--z-navy-deep) 0%, var(--z-navy) 55%, var(--z-navy-tint) 100%);
}

/* الخيط الذهبي أسفل الشريط: الفاصل الوحيد الذي يحتاجه الشريط عن الصفحة،
   وهو نفسه الخيط الذي يفصل الاسم عن الختم في الشعار. */
.z-topbar::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent, var(--z-gold) 22%, var(--z-gold) 78%, transparent);
    opacity: .55;
    pointer-events: none;
}

/* حالة العنصر النشط في القائمة الجانبية.
   كل رابطٍ كان يحمل تدرّجاً مختلفاً inline (بنفسجي، زمردي، برتقالي،
   تركوازي…) — فكان الموضع النشط يتلوّن بحسب الصفحة لا بحسب كونه نشطاً.
   (محدِّد `a[style]` القديم حُذف: كان يلتقط زرّ «بريد جديد» فيمنحه حلقة
   النشاط الذهبية — فيدّعي عنصران النشاط في آن.) */
#appSidebar nav a.z-nav-active {
    background: rgba(212, 169, 60, .16) !important;
    color: #fff !important;
    box-shadow: inset 0 0 0 1px rgba(212, 169, 60, .28) !important;
}
#appSidebar nav a.z-nav-active::before {
    content: ''; position: absolute; inset-inline-start: -.25rem; top: .55rem; bottom: .55rem; width: 3px; border-radius: 2px;
    background: var(--z-gold);
}
/* شارة اسم المساعد في العنصر النشط — تُكتب بالخصائص المفردة لا بالاختصار.
   كان `background: …!important` يعيد `background-clip` (وهو من مكوّنات
   الاختصار) إلى `border-box` بأولوية !important، فيهزم `background-clip: text`
   التالية له في الكتلة نفسها لأنها غير مهمّة. فتُطلى الشارة كلها بالتدرّج
   الفاتح ويبقى نصّها `transparent` — أي «المساعد الذكي» أبيض على أبيض
   لا يُقرأ متى صار العنصر نشطاً (فحص العقود / إعادة الصياغة). */
#appSidebar nav a.z-nav-active .sidebar-assistant-badge {
    background-color: transparent !important;
    background-image: linear-gradient(90deg, var(--z-gold-wash), #fff, var(--z-gold-wash)) !important;
    background-size: 200% auto !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
}
/* حارس المتصفّحات التي لا تقصّ الخلفية على النص: النص ذهبيٌّ فاتح مقروء
   على الأرض الكحلية بدل أن يبقى شفافاً. */
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
    #appSidebar nav a.z-nav-active .sidebar-assistant-badge {
        background-image: none !important;
        color: var(--z-gold-wash) !important;
    }
}

/* مربّع أيقونة القائمة الجانبية في حالته الخاملة — واحدٌ للجميع:
   كانت تسعة ألوانٍ مختلفة (indigo/emerald/blue/amber/orange/teal/
   purple/sky/slate) فلا يدلّ لونٌ على شيء. التحويم ذهبيٌّ خافت. */
/* ==========================================================================
   ٠ — الطبقات (D-064): أرضٌ باردة محايدة ← شريطٌ كحلي يمتدّ من الترويسة ← بطاقات بيضاء
   البيج (D-063) قرأه المالك ورقاً قديماً؛ الهيبة تأتي من لونٍ واحد للأثاث
   (الترويسة والشريط) وأرضٍ لا تُرى بذاتها وأسطحٍ بيضاء حادّة، والذهبي لكنةٌ
   نادرة: العنصر النشط والدعوة وشارة «حيّ» لا غير. كل قواعد الشريط هنا
   بمحدِّد المُعرِّف لتغلب أصناف Tailwind الملوّنة في القالب بلا لمسها.
   ========================================================================== */
.z-ground { background: var(--z-ground); }
.z-sidebar { background: var(--z-side); border-color: rgba(255, 255, 255, .06); }
/* عرض الشريط من أول إطار (تدقيق «الظهور المجزّأ» 2026-09): كان العرض يأتي من
   ‎:class‎ في Alpine وحده فيُرسم الشريط بعرض محتواه (~193px) ثم يقفز عند
   DOMContentLoaded إلى w-52 أو إلى القضبان أو يُغلق على الجوال. الحالة تُبصم
   على <html> بسكربتٍ مبكر في رأس base.html (z-side-rail / z-side-closed)
   وAlpine يبقيها متزامنة. ‎:where()‎ يُبقي القاعدة الافتراضية بلا خصوصية
   فتغلبها أدوات Tailwind (w-52 / w-0 / w-[4.75rem]) التي يضيفها Alpine لاحقاً
   بالقيم نفسها؛ وقاعدتا الحالة (html.class + :where) تغلبانها لأنهما
   لاحقتان لـtailwind.css وبخصوصية (0,1,1). */
:where(#appSidebar) { width: 13rem; }
html.z-side-rail :where(#appSidebar) { width: 4.75rem; }
html.z-side-closed :where(#appSidebar) { width: 0; overflow: hidden; }
#appSidebar nav a { position: relative; color: rgba(255, 255, 255, .80); }
#appSidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#appSidebar nav > p { color: rgba(255, 255, 255, .42); letter-spacing: .04em; }
#appSidebar .nav-toggle { background: rgba(255, 255, 255, .05); color: rgba(255, 255, 255, .72); border-color: rgba(255, 255, 255, .14); }
#appSidebar .nav-toggle:hover { background: rgba(255, 255, 255, .11); color: #fff; border-color: rgba(255, 255, 255, .28); }
/* أزرار الإنشاء في أسفل الشريط: الدعوة الأولى ذهبية على الكحلي، والثانية زجاجية */
#appSidebar nav .pt-5 a.z-btn--navy { background: linear-gradient(135deg, var(--z-gold), var(--z-gold-lift)); color: var(--z-gold-ink); box-shadow: 0 8px 18px rgba(0, 0, 0, .28); }
#appSidebar nav .pt-5 a.z-btn--navy:hover { background: linear-gradient(135deg, var(--z-gold-lift), var(--z-gold)); color: var(--z-gold-ink); }
#appSidebar nav .pt-5 a:not(.z-btn--navy) { background: rgba(255, 255, 255, .08); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
#appSidebar nav .pt-5 a:not(.z-btn--navy):hover { background: rgba(255, 255, 255, .14); color: #fff; }

.z-nav-ico {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .85);
    transition: background-color .15s ease, color .15s ease;
}
#appSidebar nav a:hover .z-nav-ico { background: rgba(212, 169, 60, .22); color: var(--z-gold-lift); }
#appSidebar nav a.z-nav-active .z-nav-ico { background: var(--z-gold); color: var(--z-gold-ink); }

/* زرّ الدعوة الكحلي (بريد جديد) — صنفٌ بدل style المضمّن */
.z-btn--navy {
    background: linear-gradient(135deg, var(--z-navy), var(--z-navy-lift));
    color: #fff;
    box-shadow: var(--z-shadow);
}
.z-btn--navy:hover { background: linear-gradient(135deg, var(--z-navy-deep), var(--z-navy)); }

/* ==========================================================================
   ٢ — البطاقة: سطحٌ واحد لكل الصفحة الرئيسية
   ========================================================================== */

.z-card {
    background: var(--z-surface);
    border: 1px solid var(--z-hairline);
    border-radius: var(--z-radius);
    box-shadow: var(--z-shadow-sm);
}

.z-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .9rem 1.15rem;
    border-bottom: 1px solid var(--z-hairline);
    border-radius: var(--z-radius) var(--z-radius) 0 0;
}

.z-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--z-ink);
    letter-spacing: -.01em;
}

/* التسمية الفوقية: بديل العنوان الثانوي. سطرٌ واحد صغير مُفرَّق الحروف
   يحمل السياق، فيستغني العنوان عن جملةٍ شارحة تحته. */
.z-eyebrow {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .10em;
    color: var(--z-ink-faint);
    text-transform: uppercase;
}

/* ==========================================================================
   ٣ — الترويسة الرئيسية
   ========================================================================== */

.z-hero {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background:
        radial-gradient(120% 140% at 88% 8%, rgba(212, 169, 60, .16) 0%, transparent 46%),
        linear-gradient(118deg, var(--z-navy-deep) 0%, var(--z-navy) 52%, var(--z-navy-tint) 100%);
    box-shadow: var(--z-shadow-lg);
}

/* شبكةٌ كحلية خافتة: نسيجٌ يمنع التدرّج من أن يبدو مسطحاً، بلا صورة. */
.z-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(80% 100% at 70% 0%, #000 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(80% 100% at 70% 0%, #000 0%, transparent 72%);
    pointer-events: none;
}

.z-hero::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--z-gold) 0%, rgba(212, 169, 60, .12) 62%, transparent 100%);
}

/* الشعار علامةً مائية — يتنفّس ببطء، ويسكن تماماً عند طلب تقليل الحركة */
.z-hero-mark {
    position: absolute;
    /* الطرف المقابل للنص: في العربية يساراً وفي الإنكليزية يميناً.
       كان `inset-inline-start` فوقع الختم تحت التحية نفسها. */
    inset-inline-end: 3.5rem;
    top: 50%;
    /* يُقاس ليسع داخل ارتفاع الترويسة كاملاً: أكبر منه فيقصّه
       `overflow:hidden` فيبدو شظيةً لا ختماً. */
    width: 11rem;
    height: 7.5rem;
    transform: translateY(-50%);
    opacity: .10;
    pointer-events: none;
    user-select: none;
    animation: z-breathe 9s ease-in-out infinite;
}
@keyframes z-breathe {
    0%, 100% { opacity: .085; transform: translateY(-50%) scale(1); }
    50%      { opacity: .145; transform: translateY(-50%) scale(1.04); }
}

/* ==========================================================================
   ٤ — شريط الأرقام
   ==========================================================================
   أربعة أرقام في صفٍّ واحد يفصلها خيطٌ شعري — لا أربع بطاقاتٍ ذات ظلال
   وأيقوناتٍ متدرّجة. الرقم نفسه هو العنصر البصري؛ ما حوله يخدمه.
   ========================================================================== */

.z-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    background: var(--z-surface);
    border: 1px solid var(--z-hairline);
    border-radius: var(--z-radius);
    box-shadow: var(--z-shadow-sm);
    overflow: hidden;
}

.z-stat {
    position: relative;
    display: block;
    padding: 1.15rem 1.25rem 1.05rem;
    border-inline-start: 1px solid var(--z-hairline);
    transition: background-color .18s ease;
}
.z-stat:first-child { border-inline-start: 0; }
a.z-stat:hover { background: var(--z-surface-alt); }

.z-stat-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--z-ink-soft);
}

.z-stat-value {
    display: block;
    margin-top: .3rem;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--z-ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

/* الرقم الذي يستدعي فعلاً: ذهبيٌّ وبشريطٍ علوي. هذا هو كل ما يميّزه —
   ولذلك يُرى فوراً وسط جيرانه الساكنين. */
.z-stat--live .z-stat-value { color: var(--z-gold-deep); }
.z-stat--live::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    background: var(--z-gold);
}

.z-stat--zero .z-stat-value { color: var(--z-ink-faint); font-weight: 600; }

/* بلاطة مرشِّح مختارة (شريط الأرقام يعمل مرشِّحاً في القوائم):
   أرضية ذهبية مغسولة + الشريط العلوي نفسه — «أنت هنا» بلا لون جديد. */
.z-stat--active { background: var(--z-gold-wash); }
.z-stat--active::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    background: var(--z-gold);
}
.z-stat--active .z-stat-label { color: var(--z-navy); font-weight: 700; }

/* شريط تبويبات محتوى (segmented): حاويةٌ عاجية والتبويب النشط بطاقةٌ
   بيضاء بخيطٍ ذهبي سفلي — بديل خطوط border-b-2 المتفرقة الألوان. */
.z-tabbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--z-ivory);
    border: 1px solid var(--z-line);
    border-radius: 14px;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.z-tabbar::-webkit-scrollbar { display: none; }
.z-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--z-slate);
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.z-tab:hover { color: var(--z-navy); background: rgba(18, 57, 91, .05); }
.z-tab-on {
    background: #fff;
    color: var(--z-navy);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(16, 42, 67, .12), inset 0 -2px 0 var(--z-gold);
}
.z-tab-on:hover { background: #fff; }
.z-tab-count {
    font-size: 11px;
    line-height: 1.4;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(18, 57, 91, .08);
    color: var(--z-slate);
    font-weight: 700;
}
.z-tab-on .z-tab-count { background: var(--z-gold-wash); color: var(--z-gold-deep); }

/* ── مجموعة خيارات متراصة — بديل القائمة المنسدلة للحقل ذي الخيارات
      القليلة (التصنيف الأمني، الأولوية). المختار يمتلئ بلون دلالته:
      كحلي للعادي، وكهرمان للوسطى، وقرمزي للقصوى — لون الحالة للحالة. ── */
.z-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--z-surface-alt);
    border: 1px solid var(--z-hairline);
    border-radius: 12px;
}
.z-seg-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .5rem .4rem;
    border-radius: 9px !important; /* تغلب قاعدة أزرار النموذج العامة */
    font-size: .8rem;
    font-weight: 600;
    color: var(--z-ink-soft);
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.z-seg-opt:hover { background: #fff; color: var(--z-ink); }
.z-seg-opt svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.z-seg-opt:focus-visible { outline: 2px solid var(--z-gold); outline-offset: 1px; }
.z-seg-on--calm { background: var(--z-navy) !important; color: #fff !important; box-shadow: var(--z-shadow-sm); }
.z-seg-on--warn { background: var(--z-warn) !important; color: #fff !important; box-shadow: var(--z-shadow-sm); }
.z-seg-on--risk { background: var(--z-risk) !important; color: #fff !important; box-shadow: var(--z-shadow-sm); }

/* مربّع أيقونة محايد لصفوف القوائم — النوع ليس حالةً فلا يتلوّن بلونها */
.z-ico-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 57, 91, .07);
    color: var(--z-navy);
    border-radius: 10px;
}

/* ==========================================================================
   ٥ — صفوف العمل
   ========================================================================== */

.z-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1.15rem;
    border-top: 1px solid var(--z-hairline);
    transition: background-color .16s ease;
}
.z-row:first-child { border-top: 0; }
a.z-row:hover { background: var(--z-surface-alt); }

/* الشريط الجانبي للأولوية — ٣ بكسل تحمل الحالة كلها، بلا أيقونةٍ ملوّنة */
.z-row--risk { box-shadow: inset 3px 0 0 var(--z-risk); }
.z-row--warn { box-shadow: inset 3px 0 0 var(--z-warn); }
[dir="rtl"] .z-row--risk { box-shadow: inset -3px 0 0 var(--z-risk); }
[dir="rtl"] .z-row--warn { box-shadow: inset -3px 0 0 var(--z-warn); }

.z-serial {
    font-size: .8rem;
    font-weight: 700;
    color: var(--z-navy);
    font-variant-numeric: tabular-nums;
}
.z-subject {
    font-size: .8rem;
    color: var(--z-ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.z-tag {
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .5rem;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.z-tag--risk { color: var(--z-risk); background: var(--z-risk-wash); }
.z-tag--warn { color: var(--z-warn); background: var(--z-warn-wash); }
.z-tag--ok   { color: var(--z-ok);   background: var(--z-ok-wash); }
.z-tag--calm { color: var(--z-slate); background: var(--z-surface-alt); }

/* ==========================================================================
   ٦ — الأزرار
   ========================================================================== */

.z-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.1rem;
    border-radius: var(--z-radius-sm);
    font-size: .85rem;
    font-weight: 700;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.z-btn:hover { transform: translateY(-1px); }

.z-btn--gold {
    background: var(--z-gold);
    color: var(--z-gold-ink);
    box-shadow: 0 2px 10px rgba(212, 169, 60, .34);
}
.z-btn--gold:hover { background: var(--z-gold-lift); box-shadow: 0 5px 16px rgba(212, 169, 60, .42); }

.z-btn--ghost {
    background: rgba(255, 255, 255, .11);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .26);
}
.z-btn--ghost:hover { background: rgba(255, 255, 255, .19); }

.z-btn--quiet {
    background: var(--z-surface-alt);
    color: var(--z-navy);
    border: 1px solid var(--z-hairline);
}
.z-btn--quiet:hover { background: var(--z-gold-wash); border-color: var(--z-gold); }

/* مقاسٌ صغير — كان يُكتب مضمّناً (padding/font-size) لغيابه */
.z-btn--sm { padding: .4rem .8rem; font-size: .78rem; }

/* حجاب النوافذ المنبثقة — كان تسع صياغات (bg-black bg-opacity-50،
   bg-black/60، bg-gray-900/75…) بعضها يفتح سياق تكديسٍ مختلفاً */
.z-scrim { background: rgba(11, 37, 64, .55); }

/* شريط التبويب النشط — كان ثمانية ألوان عبر ١٦ قالباً */
.z-tab--active {
    border-bottom: 2px solid var(--z-gold) !important;
    color: var(--z-navy) !important;
    font-weight: 700;
}

/* رقمٌ مضغوط لبطاقات الشريط الضيقة */
.z-stat--compact .z-stat-value { font-size: 1.6rem; }

/* ==========================================================================
   ٧ — دخول الصفحة: تدرّجٌ من أول رسم، بلا JS
   ==========================================================================
   التأخير على العنصر لا على سكربتٍ يركض بعد التحميل: العنصر يبدأ
   شفافاً وينتهي ظاهراً، فإن عُطِّل JS أو تأخّر بقيت الصفحة صحيحة.
   ========================================================================== */

@keyframes z-rise {
    from { opacity: 0; transform: translateY(9px); }
    to   { opacity: 1; transform: none; }
}
.z-enter { animation: z-rise .5s cubic-bezier(.22, .8, .3, 1) backwards; }
.z-enter-1 { animation-delay: .04s; }
.z-enter-2 { animation-delay: .10s; }
.z-enter-3 { animation-delay: .16s; }
.z-enter-4 { animation-delay: .22s; }

@media (prefers-reduced-motion: reduce) {
    .z-enter, .z-hero-mark { animation: none !important; }
    .z-hero-mark { opacity: .12 !important; }
    .z-btn:hover { transform: none; }
}

/* ==========================================================================
   ٨ — الطباعة
   ========================================================================== */

@media print {
    .z-hero, .z-stats, .z-card { box-shadow: none !important; }
    .z-hero { background: var(--z-navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ==========================================================================
   ٩ — بطاقات الإشعارات المنزلقة
   ==========================================================================
   كانت هذه القواعد في وسم <style> داخل كتلة محتوى الصفحة الرئيسية —
   وسكربت الإشعارات في base يناديها، فلو فُتحت صفحةٌ أخرى لم تُعرَّف.
   موضعها الصحيح هنا: تُحمَّل مع كل صفحة كما يُحمَّل السكربت الذي يناديها.
   ========================================================================== */

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-120%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-120%); }
}
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.toast-card-in  { animation: toast-in .6s cubic-bezier(.22,.9,.3,1.15) forwards; }
.toast-card-out { animation: toast-out .5s cubic-bezier(.55,0,.55,.2) forwards; }
.toast-progress { animation: toast-progress linear forwards; transform-origin: right; }

/* في LTR تقف الحاوية على اليمين (end) فتنزلق البطاقات من اليمين */
@keyframes toast-in-ltr {
    from { opacity: 0; transform: translateX(120%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out-ltr {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(120%); }
}
[dir="ltr"] .toast-card-in  { animation-name: toast-in-ltr; }
[dir="ltr"] .toast-card-out { animation-name: toast-out-ltr; }
[dir="ltr"] .toast-progress { transform-origin: left; }

@media (prefers-reduced-motion: reduce) {
    .toast-card-in, .toast-card-out, .toast-progress {
        animation: none !important; opacity: 1 !important; transform: none !important;
    }
}

/* ==========================================================================
   ١٠ — الحقل القابل للبحث
   ==========================================================================
   يقابل ``common/partials/_searchable_select.html``. مظهره مطابقٌ لمظهر
   بقية حقول النماذج كي لا يبدو غريباً بينها — الفرق الوحيد أنه يقبل
   الكتابة.
   ========================================================================== */

.z-select-input {
    /* الحشوة منطقية: السهم وزر المسح على الطرف المنتهي في الاتجاهين */
    padding-block: .55rem;
    padding-inline-start: .75rem;
    padding-inline-end: 2.5rem;
    border-radius: var(--z-radius-sm);
    border: 1px solid var(--z-line);
    background: var(--z-surface);
    color: var(--z-ink);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.z-select-input::placeholder { color: var(--z-ink-faint); }
.z-select-input:focus {
    border-color: var(--z-navy);
    box-shadow: 0 0 0 3px rgba(18, 57, 91, .12);
}
/* حقلٌ فيه اختيار: خيطٌ ذهبيّ على الطرف المبتدئ — يُقرأ «هذا محدَّد»
   من طرف العين بلا قراءة النصّ. */
.z-select-input--set {
    box-shadow: inset 3px 0 0 var(--z-gold);
}
[dir="rtl"] .z-select-input--set {
    box-shadow: inset -3px 0 0 var(--z-gold);
}
.z-select-input--set:focus {
    box-shadow: inset 3px 0 0 var(--z-gold), 0 0 0 3px rgba(18, 57, 91, .12);
}
[dir="rtl"] .z-select-input--set:focus {
    box-shadow: inset -3px 0 0 var(--z-gold), 0 0 0 3px rgba(18, 57, 91, .12);
}

.z-select-menu {
    position: absolute;
    z-index: 40;
    inset-inline: 0;
    margin-top: .25rem;
    max-height: 17rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--z-surface);
    border: 1px solid var(--z-hairline);
    border-radius: var(--z-radius-sm);
    box-shadow: var(--z-shadow-lg);
    padding-block: .25rem;
}

.z-select-opt {
    display: block;
    width: 100%;
    text-align: start;
    padding: .5rem .75rem;
    font-size: .85rem;
    color: var(--z-ink-soft);
    cursor: pointer;
}
/* عنصرٌ واحد فقط «نشط» في كل لحظة — سواءٌ بلغه السهم أم الفأرة، فلا
   يظهر تظليلان يتنازعان دلالة «التالي عند Enter». */
.z-select-opt--active { background: var(--z-gold-wash); color: var(--z-ink); }
.z-select-opt--picked { color: var(--z-navy); font-weight: 700; }

.z-select-group {
    padding: .45rem .75rem .2rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--z-ink-faint);
    background: var(--z-surface-alt);
    position: sticky;
    top: 0;
}

/* تحويم بلا معالجٍ مضمَّن (D-067): كانت onmouseover/onmouseout تكتب style مباشرةً */
.z-hover-risk:hover { background: var(--z-risk-wash); }
.z-hover-gold:hover { background: var(--z-gold-wash); }

/* ==========================================================================
   الأفعال المشتركة — .z-act وقائمة «المزيد» (D-076، قاعدة الصفحة الثالثة)
   كانت العائلة منسوخةً تحت #docDetailRoot و#caseFileRoot فقط، فبقيت أزرار
   الأرشيف (ومفاتيح الاتحاد) نصّاً عارياً. هنا الأصل غير المقيّد؛ والنسختان
   المقيّدتان تبقيان مطابقتين له فلا يتغيّر شيء في صفحتي الكتاب والأضبارة.
   ========================================================================== */
.z-act {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .6rem 1rem; border-radius: .75rem; font-size: .875rem; font-weight: 600; line-height: 1.25rem;
    border: 1px solid transparent; white-space: nowrap; cursor: pointer; text-decoration: none; font-family: inherit;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.z-act:hover:not(:disabled) { transform: translateY(-1px); }
.z-act:focus-visible { outline: 2px solid var(--z-gold); outline-offset: 2px; }
.z-act:disabled { opacity: .55; cursor: not-allowed; }
.z-act--primary { background: var(--z-navy); color: #fff; box-shadow: var(--z-shadow-sm); }
.z-act--primary:hover:not(:disabled) { background: var(--z-navy-lift); color: #fff; box-shadow: var(--z-shadow); }
.z-act--gold { background: var(--z-gold); color: var(--z-gold-ink); box-shadow: var(--z-shadow-sm); }
.z-act--gold:hover:not(:disabled) { background: var(--z-gold-lift); box-shadow: 0 5px 16px rgba(212, 169, 60, .35); }
.z-act--quiet { background: #fff; color: var(--z-ink-soft); border-color: var(--z-line); }
.z-act--quiet:hover:not(:disabled) { background: var(--z-gold-wash); border-color: var(--z-gold); color: var(--z-ink); }
.z-act--warn { color: var(--z-warn); }
.z-act--danger { background: #fff; color: var(--z-risk); border-color: #EFC7C2; }
.z-act--danger:hover:not(:disabled) { background: var(--z-risk-wash); border-color: var(--z-risk); }
.z-act > svg { width: 1rem; height: 1rem; flex: none; }
.z-act > svg * { stroke-width: 1.8; }
.z-act__chev { width: .8rem !important; height: .8rem !important; opacity: .8; }
.z-act__count { display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; font-size: .68rem; font-weight: 700; line-height: 1; background: var(--z-navy); color: #fff; }
.z-act__count--calm { background: var(--z-surface-alt); color: var(--z-navy); border: 1px solid var(--z-hairline); }
.z-acts__main, .z-acts__end { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.z-acts__end { margin-inline-start: auto; }
.z-acts__sep { width: 1px; height: 1.5rem; background: var(--z-hairline); flex: none; }
/* قائمة منسدلة: زرٌّ هادئ يفتح لوحةً من أفعالٍ متراصّة */
.z-more { position: relative; }
.z-more__panel { position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); min-width: 17rem; max-width: min(92vw, 24rem); background: var(--z-surface); border: 1px solid var(--z-hairline); border-radius: var(--z-radius-sm); box-shadow: var(--z-shadow-lg); padding: .4rem; z-index: var(--z-layer-dropdown); display: flex; flex-direction: column; gap: .1rem; }
.z-more__panel form { display: block; width: 100%; }
.z-more__panel .z-act { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; box-shadow: none; padding: .55rem .7rem; border-radius: .5rem; font-weight: 600; }
.z-more__panel .z-act:hover:not(:disabled) { background: var(--z-surface-alt); transform: none; border-color: transparent; }
.z-more__panel .z-act--danger { color: var(--z-risk); }
.z-more__panel .z-act--danger:hover:not(:disabled) { background: var(--z-risk-wash); }
.z-more__panel .z-act--warn:hover:not(:disabled) { background: var(--z-warn-wash); }
.z-more__sep { height: 1px; background: var(--z-hairline); margin: .3rem .2rem; }
/* بندٌ بسطرين: الفعل ثم ما يعنيه (بطاقة A6 تُلصق على المجلد…) */
.z-more__item { white-space: normal; text-align: start; }
.z-more__item > svg { align-self: flex-start; margin-top: .15rem; }
.z-more__item-text { display: grid; gap: .1rem; min-width: 0; }
.z-more__item-text b { font-size: .86rem; font-weight: 700; color: var(--z-ink); display: flex; align-items: center; gap: .4rem; }
.z-more__item-text small { font-size: .74rem; color: var(--z-ink-faint); line-height: 1.35; }
@media (max-width: 639.98px) { .z-more__panel { inset-inline: 0; min-width: 0; } }
@media (prefers-reduced-motion: reduce) { .z-act:hover { transform: none; } }

/* ==========================================================================
   صفوف المرفقات وأزرار الأيقونات — مشتركة بين الأضبارة والكتاب (D-080، قاعدة الصفحة الثالثة)
   كانت تحت #caseFileRoot فقط؛ الأصل غير المقيّد هنا والنسخة المقيّدة مطابقة.
   ========================================================================== */
.z-iconbtn { width: 1.9rem; height: 1.9rem; border-radius: .5rem; display: inline-grid; place-items: center; color: var(--z-ink-faint); background: transparent; border: 0; cursor: pointer; text-decoration: none; transition: background .12s ease, color .12s ease; }
.z-iconbtn svg { width: 1rem; height: 1rem; }
.z-iconbtn:hover { background: var(--z-surface-alt); color: var(--z-navy); }
.z-iconbtn:focus-visible { outline: 2px solid var(--z-gold); outline-offset: 1px; }
.z-iconbtn--risk:hover { background: var(--z-risk-wash); color: var(--z-risk); }
.z-iconbtn--warn:hover { background: var(--z-warn-wash); color: var(--z-warn); }
.z-att { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .7rem; padding: .6rem .4rem; border-bottom: 1px solid var(--z-hairline); border-radius: .5rem; }
.z-att:last-child { border-bottom: 0; }
.z-att:hover { background: var(--z-surface-alt); }
.z-att__ico { width: 2.2rem; height: 2.2rem; border-radius: .6rem; display: grid; place-items: center; background: rgba(18, 57, 91, .07); color: var(--z-navy); flex: none; position: relative; }
.z-att__ico svg { width: 1.05rem; height: 1.05rem; }
/* مصغرة الصورة تملأ مربع الأيقونة نفسه: الصف لا يتغير ارتفاعه حين تصل */
.z-att__thumb { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; background: var(--z-surface-alt); }
.z-att__ext { position: absolute; bottom: -.4rem; left: 50%; transform: translateX(-50%); font-size: .52rem; font-weight: 800; letter-spacing: .03em; padding: 0 .3rem; border-radius: .3rem; background: var(--z-navy); color: #fff; line-height: 1.5; direction: ltr; }
.z-att__label { font-size: .86rem; font-weight: 700; color: var(--z-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.z-att__meta { font-size: .72rem; color: var(--z-ink-faint); display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin-top: .15rem; }
.z-att__meta .z-tag { font-size: .64rem; padding: .1rem .45rem; }
.z-att__acts { display: flex; align-items: center; gap: .15rem; flex: none; }
.z-att__desc { grid-column: 2 / -1; font-size: .74rem; color: var(--z-ink-soft); margin: 0; }
.z-att__dist { display: inline-flex; align-items: center; gap: .25rem; font-size: .66rem; font-weight: 700; color: var(--z-navy); background: var(--z-surface-alt); border: 1px solid var(--z-hairline); border-radius: 999px; padding: .08rem .45rem; }
.z-att__dist svg { width: .7rem; height: .7rem; }
.z-att-empty { padding: 1.6rem 1rem; text-align: center; color: var(--z-ink-faint); font-size: .86rem; display: grid; justify-items: center; gap: .4rem; }
.z-att-empty svg { width: 2rem; height: 2rem; color: var(--z-line); }
.z-att-empty p { margin: 0; }
@media (max-width: 639.98px) {
    .z-att { grid-template-columns: minmax(0, 1fr) auto; }
    .z-att__ico { display: none; }
    .z-att__desc { grid-column: 1 / -1; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   النماذج والجداول والحالة الفارغة (D-082)
   كانت كل شاشة إدارية تكتب حقولها بـTailwind خام وأزرقَ غريبٍ عن الهوية،
   فاختلف الحقل الواحد من صفحة إلى أخرى. هذه هي الصيغة الواحدة:
   لا لونَ حرفياً، الرموز وحدها؛ والاتجاه منطقيٌّ فينقلب مع اللغة بلا نسخةٍ ثانية.
   ═══════════════════════════════════════════════════════════════════════════ */

.z-form { display: grid; gap: 1.15rem; }

.z-fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: .85rem; }
.z-fieldset__head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; padding-bottom: .55rem; border-bottom: 1px solid var(--z-hairline); }
.z-fieldset__title { font-size: .85rem; font-weight: 700; color: var(--z-ink); margin: 0; }
.z-fieldset__hint { font-size: .74rem; color: var(--z-ink-faint); margin: 0; }
.z-fieldset__grid { display: grid; gap: .9rem 1.1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }

.z-field { display: grid; gap: .35rem; min-width: 0; }
.z-field--wide { grid-column: 1 / -1; }
.z-field__label { font-size: .78rem; font-weight: 700; color: var(--z-ink-soft); }
.z-field__req { color: var(--z-gold-deep); font-weight: 700; margin-inline-start: .15rem; }
.z-field__hint { font-size: .72rem; color: var(--z-ink-faint); }
.z-field__err { font-size: .74rem; font-weight: 600; color: var(--z-risk); }

.z-input {
    width: 100%; font: inherit; font-size: .88rem; color: var(--z-ink);
    background: var(--z-surface); border: 1px solid var(--z-line);
    border-radius: var(--z-radius-sm); padding: .55rem .75rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.z-input::placeholder { color: var(--z-ink-faint); }
.z-input:focus { outline: 0; border-color: var(--z-navy); box-shadow: 0 0 0 3px rgba(18, 57, 91, .12); }
.z-input:disabled { background: var(--z-surface-alt); color: var(--z-ink-faint); cursor: not-allowed; }
.z-input--err { border-color: var(--z-risk); }
.z-input--err:focus { box-shadow: 0 0 0 3px rgba(180, 69, 60, .14); }
textarea.z-input { min-height: 4.5rem; resize: vertical; }
select.z-input { appearance: none; padding-inline-end: 2.1rem; background-image: linear-gradient(45deg, transparent 50%, var(--z-ink-faint) 50%), linear-gradient(135deg, var(--z-ink-faint) 50%, transparent 50%); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
select.z-input { background-position: calc(100% - 1.15rem) 1.1rem, calc(100% - .85rem) 1.1rem; }
[dir="rtl"] select.z-input { background-position: .85rem 1.1rem, 1.15rem 1.1rem; }

.z-check { display: inline-flex; align-items: flex-start; gap: .5rem; cursor: pointer; }
.z-check__box { width: 1rem; height: 1rem; margin-top: .12rem; flex: none; accent-color: var(--z-navy); cursor: pointer; }
.z-check__text { font-size: .82rem; font-weight: 600; color: var(--z-ink); }
.z-check__hint { display: block; font-size: .72rem; font-weight: 400; color: var(--z-ink-faint); margin-top: .1rem; }

/* بطاقةُ خيار: صندوقٌ كامل قابلٌ للنقر يحوي مربّع اختيار — للأعلام والصلاحيات */
.z-optcard { display: flex; align-items: flex-start; gap: .55rem; padding: .65rem .8rem; border: 1px solid var(--z-line); border-radius: var(--z-radius-sm); background: var(--z-surface); cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.z-optcard:hover { background: var(--z-surface-alt); }
.z-optcard:focus-within { border-color: var(--z-navy); box-shadow: 0 0 0 3px rgba(18, 57, 91, .10); }
.z-optcard--on { border-color: var(--z-gold); background: var(--z-gold-wash); }

/* شريط الحفظ: يبقى في المرأى مهما طال النموذج */
.z-formbar { position: sticky; bottom: 0; z-index: var(--z-layer-sticky); display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .75rem 1.15rem; background: var(--z-surface); border: 1px solid var(--z-line); border-radius: var(--z-radius); box-shadow: var(--z-shadow-lg); }
.z-formbar__end { margin-inline-start: auto; display: flex; gap: .6rem; flex-wrap: wrap; }

.z-table__wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.z-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.z-table thead th { text-align: start; font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--z-ink-faint); background: var(--z-surface-alt); padding: .6rem .9rem; border-bottom: 1px solid var(--z-hairline); white-space: nowrap; }
.z-table tbody td { padding: .7rem .9rem; border-top: 1px solid var(--z-hairline); color: var(--z-ink); vertical-align: middle; }
.z-table tbody tr:first-child td { border-top: 0; }
.z-table tbody tr:hover { background: var(--z-surface-alt); }
.z-table__num { font-variant-numeric: tabular-nums; }
.z-table__acts { display: flex; align-items: center; gap: .15rem; justify-content: flex-end; }

/* الحالة الفارغة — تعميمُ .z-att-empty ليخدم كل صفحة */
.z-empty { display: grid; gap: .45rem; justify-items: center; text-align: center; padding: 2.6rem 1.25rem; color: var(--z-ink-faint); }
.z-empty__icon { width: 2.75rem; height: 2.75rem; color: var(--z-line); }
.z-empty__title { font-size: .92rem; font-weight: 700; color: var(--z-ink-soft); margin: 0; }
.z-empty__hint { font-size: .8rem; margin: 0; max-width: 30rem; }

@media (max-width: 640px) {
    .z-fieldset__grid { grid-template-columns: 1fr; }
    .z-formbar { padding: .65rem .8rem; }
    .z-formbar__end { width: 100%; }
    .z-formbar__end > * { flex: 1; justify-content: center; }
}
