/* ============================================================================
   نظام الاتصالات الإدارية — أنماط الواجهة المشتركة (مستخرجة من التصاميم المعتمدة)
   هوية: Sky #0EA5E9 · Tajawal · بطاقات 16px · شارات 6px. آمنة للاتجاهين RTL/LTR.
   ========================================================================== */

* { font-family: 'Tajawal', sans-serif; }
body { background: #F1F5F9; color: #1E293B; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

/* ── الشريط الجانبي ── */
.sidebar { background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%); border-inline-end: 1px solid #E2E8F0; }
.nav-item { transition: all .2s ease; position: relative; }
.nav-item:hover:not(.active) { background: #F0F9FF; color: #0369A1; }
.nav-item.active { background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; box-shadow: 0 4px 12px rgba(14,165,233,.3); }
.nav-item.active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 50%; transform: translateY(-50%); width: 4px; height: 24px; background: #0369A1; border-radius: 4px 0 0 4px; }
.nav-disabled { opacity: .55; cursor: not-allowed; }

/* بادج رقمي «الجديد» على روابط الشريط الجانبي */
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 4px; background: #E0F2FE; color: #0369A1;
    font-size: 9px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-badge { background: #fff; color: #0369A1; }
/* في الوضع المطويّ: بادج زاوية صغير فوق الأيقونة بدل الحبّة الجانبية */
.sidebar-collapsed #appSidebar .nav-badge {
    position: absolute; top: 4px; inset-inline-end: 8px; margin: 0;
    min-width: 14px; height: 14px; padding: 0 3px; font-size: 8px;
    border: 1.5px solid #fff;
}

/* ===== اختصارات شخصية فوق بطاقة المستخدم (البريد · المحادثة · التقويم) ===== */
.sidebar-quick { display: flex; align-items: stretch; gap: .5rem; }
.sidebar-quick-btn {
    position: relative; flex: 1 1 0;
    display: flex; align-items: center; justify-content: center;
    height: 40px; border-radius: .75rem;
    background: #fff; border: 1px solid #E2E8F0; color: #64748B;
    font-size: 15px; text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
a.sidebar-quick-btn:hover { background: #F1F5F9; color: #0369A1; border-color: #BAE6FD; }
.sidebar-quick-btn.active { background: #E0F2FE; color: #0369A1; border-color: #7DD3FC; }
.sidebar-quick-btn.is-soon { opacity: .5; cursor: default; }
.sidebar-quick-badge {
    position: absolute; top: -5px; inset-inline-end: -5px;
    min-width: 16px; height: 16px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9999px; background: #EF4444; color: #fff;
    font-size: 9px; font-weight: 700; line-height: 1; border: 1.5px solid #fff;
    font-variant-numeric: tabular-nums;
}
.sidebar-quick-badge.hidden { display: none; }
/* في الوضع المطويّ: عمودياً لتفادي التزاحم داخل 76px */
.sidebar-collapsed #appSidebar .sidebar-quick { flex-direction: column; }

/* ===== الشريط الجانبي القابل للطيّ ===== */
#appSidebar, #appContent { transition: width .2s ease, margin .2s ease; }
.sidebar-collapsed #appSidebar { width: 76px !important; }
.sidebar-collapsed #appContent { margin-inline-start: 76px !important; }
.sidebar-collapsed #appSidebar .nav-label,
.sidebar-collapsed #appSidebar .sidebar-text,
.sidebar-collapsed #appSidebar nav > p { display: none; }
.sidebar-collapsed #appSidebar nav .nav-item { justify-content: center; gap: 0; padding-inline: 0; }
.sidebar-collapsed #appSidebar .nav-item.active::before { inset-inline-start: -4px; }
.sidebar-collapsed #appSidebar .sidebar-usercard { padding: .5rem; }
.sidebar-collapsed #appSidebar .sidebar-usercard > div { justify-content: center; gap: 0; }

/* ===== مجموعات السايدبار القابلة للطيّ (أكورديون) ===== */
.nav-group { margin-top: .375rem; }
.nav-group-header {
    width: 100%; display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem; margin-bottom: .125rem;
    background: transparent; border: 0; cursor: pointer;
    border-radius: .75rem; transition: background .15s ease;
}
.nav-group-header:hover { background: #F1F5F9; }
.nav-group-header:focus-visible { outline: 2px solid #0EA5E9; outline-offset: 2px; }
.nav-group-title {
    flex: 1; text-align: start;
    font-size: .875rem; font-weight: 700; color: #94A3B8;
    letter-spacing: normal; line-height: 1.4;
}
.nav-group-chevron { font-size: 10px; color: #CBD5E1; transition: transform .2s ease; }
.nav-group.open > .nav-group-header .nav-group-chevron { transform: rotate(180deg); color: #94A3B8; }
.nav-group.open > .nav-group-header .nav-group-title { color: #64748B; }
.nav-group-body {
    display: flex; flex-direction: column; gap: .25rem;
    overflow: hidden; max-height: 0; opacity: 0;
    transition: max-height .25s ease, opacity .2s ease;
}
.nav-group.open > .nav-group-body { max-height: 640px; opacity: 1; }

/* في الوضع المطويّ (أيقونات فقط): أظهِر كل الروابط وأخفِ رؤوس المجموعات */
.sidebar-collapsed #appSidebar .nav-group-header { display: none; }
.sidebar-collapsed #appSidebar .nav-group-body { max-height: none !important; opacity: 1 !important; overflow: visible; }

/* ===== حقل تصفية القائمة الجانبية ===== */
.sidebar-search-box {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem;
    background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: .75rem;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.sidebar-search-box:focus-within {
    background: #fff; border-color: #38BDF8;
    box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}
.sidebar-search-icon { flex-shrink: 0; color: #94A3B8; font-size: .8rem; transition: color .18s ease; }
.sidebar-search-box:focus-within .sidebar-search-icon { color: #0EA5E9; }
.sidebar-search-input {
    flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
    font-size: .8125rem; font-weight: 500; color: #1E293B;
}
.sidebar-search-input::placeholder { color: #94A3B8; font-weight: 500; }
.sidebar-search-clear {
    flex-shrink: 0; display: none;
    width: 1.25rem; height: 1.25rem; padding: 0; border: 0; border-radius: 50%;
    align-items: center; justify-content: center;
    background: #E2E8F0; color: #64748B; cursor: pointer; font-size: .7rem;
    transition: background .15s ease, color .15s ease;
}
.sidebar-search-clear:hover { background: #CBD5E1; color: #0F172A; }
.sidebar-search-box.has-value .sidebar-search-clear { display: inline-flex; }
/* يختفي الحقل تماماً في الوضع المطويّ */
.sidebar-collapsed #appSidebar .sidebar-search { display: none; }

/* رسالة عدم وجود نتائج */
.sidebar-no-results {
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    padding: 2rem 1rem; text-align: center;
    color: #94A3B8; font-size: .8125rem; font-weight: 600;
}
.sidebar-no-results[hidden] { display: none; }
.sidebar-no-results i { font-size: 1.5rem; color: #CBD5E1; }

/* تمييز التطابق داخل الرابط */
.nav-label mark { background: #FDE68A; color: inherit; padding: 0 1px; border-radius: 3px; }
.nav-item.active .nav-label mark { background: rgba(255,255,255,.35); color: #fff; }

/* إخفاء العناصر غير المطابقة أثناء التصفية */
#appSidebar .nav-hidden { display: none !important; }

/* ── البطاقات ── */
.card { background: #fff; border: 1px solid #E2E8F0; border-radius: 16px; box-shadow: 0 1px 3px rgba(15,23,42,.04); transition: all .25s ease; }
.card:hover { box-shadow: 0 8px 24px rgba(15,23,42,.06); }
.kpi-card { position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: -50%; inset-inline-end: -30%; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, currentColor 0%, transparent 70%); opacity: .08; }
.icon-circle { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.pattern-bg { background-image: radial-gradient(circle at 100% 0%, rgba(14,165,233,.04) 0%, transparent 40%), radial-gradient(circle at 0% 100%, rgba(5,150,105,.03) 0%, transparent 40%); }

/* ── الشارات ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-sky { background: #E0F2FE; color: #0C4A6E; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }
.badge-slate { background: #F1F5F9; color: #334155; }
.badge-emerald { background: #D1FAE5; color: #065F46; }
.badge-amber { background: #FEF3C7; color: #92400E; }

/* ── ملاحظة داخلية (طلبات الجهات الخارجية C18 — لا تظهر للمستفيد) ── */
.internal-note { background: #FFFBEB; border: 1px dashed #FCD34D; }

/* ── أزرار التقسيم (Segmented) + تبويبات ── */
.seg-btn { padding: 8px 16px; font-size: 13px; font-weight: 600; color: #64748B; border-radius: 8px; transition: all .2s; cursor: pointer; border: none; background: transparent; }
.seg-btn.active { background: #fff; color: #0369A1; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── بطاقات مراحل سير العمل (C19 — مشترك منطقي للاتجاهين) ── */
.stage-card { border: 1.5px solid #E2E8F0; border-radius: 14px; padding: 16px; background: #fff; position: relative; }
.stage-arrow { display: flex; align-items: center; justify-content: center; color: #94A3B8; }
/* السهم ينقلب تلقائياً مع الاتجاه (يشير لليسار في RTL، لليمين في LTR). */
[dir="ltr"] .stage-arrow .fa-arrow-left::before { content: "\f061"; }

/* ── خريطة الخطوات (x-workflow-map) — الترتيب من الانتقالات، والحالة من سجلّ السير ── */
.wf-map { display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.wf-map-card { flex: 0 0 auto; padding: 12px 14px; }
.wf-map-card.is-done { border-color: #A7F3D0; background: #F0FDF4; }
.wf-map-card.is-active { border-color: #38BDF8; box-shadow: 0 4px 12px rgba(14,165,233,.18); }
.wf-map-card.is-wait { border-style: dashed; }
.wf-map-card.is-skipped { border-style: dashed; background: #F8FAFC; opacity: .75; }
.wf-map-card.is-orphan { border-color: #FCD34D; border-style: dashed; background: #FFFBEB; }
.wf-map-seq { position: absolute; top: -9px; inset-inline-end: 10px; background: #fff; border: 1.5px solid #E2E8F0;
    color: #64748B; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.wf-map-card.is-active .wf-map-seq { border-color: #38BDF8; color: #0369A1; }
.wf-map-card.is-done .wf-map-seq { border-color: #A7F3D0; color: #047857; }
.wf-map-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700;
    border-radius: 7px; padding: 2px 6px; margin-top: 4px; max-width: 100%; }
.wf-map-tag i { font-size: 9px; }
.wf-map-tag.t-start { background: #E0F2FE; color: #075985; margin-top: 0; }
.wf-map-tag.t-back { background: #FEF3C7; color: #92400E; }
.wf-map-tag.t-jump { background: #E0F2FE; color: #075985; }
.wf-map-tag.t-split { background: #EDE9FE; color: #5B21B6; }
.wf-map-tag.t-missing { background: #FEE2E2; color: #991B1B; }
/* الرابط بين صندوقين: سهمٌ حين يوجد انتقالٌ مباشر، وخطٌّ منقّط حين لا يوجد (فرعان متوازيان مثلاً). */
.wf-map-link { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; min-width: 42px; color: #94A3B8; align-self: center; }
.wf-map-link .wf-map-link-label { font-size: 9px; font-weight: 700; max-width: 76px; text-align: center;
    line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wf-map-link.is-done { color: #059669; }
.wf-map-link.is-none { color: #CBD5E1; }
[dir="ltr"] .wf-map-link .fa-arrow-left::before { content: "\f061"; }
/* ── عارض مخطط السير للقراءة فقط (x-workflow-diagram) — كل المحدِّدات منطَّقة بـ.wfv-root ──
   الأنماط تُحاكي لوحة المصمّم (design.blade.php) عمداً كي يبدو الرسم نفسَه، وتضيف تلوين التقدّم. */
.wfv-root { position: relative; }
.wfv-wrap { border: 1.5px solid #E2E8F0; border-radius: 16px; overflow: auto; position: relative; height: 460px;
    background: radial-gradient(circle, #e2e8f0 1px, transparent 1px) 0 0 / 22px 22px, #f8fafc; cursor: grab; }
.wfv-wrap.is-panning { cursor: grabbing; }
.wfv-canvas { position: relative; min-width: 100%; min-height: 100%; transition: transform .12s ease; }
.wfv-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* طبقة وسوم الأزرار وحدها فوق العقد (الخطوط تبقى تحتها) */
.wfv-svg-top { z-index: 3; }
.wfv-root .wf-node { position: absolute; width: 180px; min-height: 76px; background: #fff; border: 1.5px solid #E2E8F0;
    border-radius: 14px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05); user-select: none; cursor: default; }
.wfv-root .wf-node-h { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #0f172a; font-size: 13px; }
.wfv-root .wf-node-h i { color: #0EA5E9; }
.wfv-root .wf-node-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wfv-root .wf-node-meta { font-size: 11px; color: #64748b; margin-top: 4px; }
.wfv-root .wf-start-badge { position: absolute; top: -9px; inset-inline-start: 10px; background: #0EA5E9; color: #fff;
    font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 8px; }
.wfv-root .wf-elabel { background: #fff; border: 1.5px solid #0EA5E9; border-radius: 8px; font-size: 11px; font-weight: 700;
    color: #0f172a; text-align: center; padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wfv-root .wfv-elabel.is-done { background: #ECFDF5; color: #065F46; }
/* حالة الخطوة في هذه المعاملة */
.wfv-node.wfv-done { border-color: #6EE7B7; background: #F0FDF4; }
.wfv-node.wfv-active { border-color: #0EA5E9; box-shadow: 0 0 0 4px rgba(14,165,233,.18); }
.wfv-node.wfv-wait { border-style: dashed; }
.wfv-node.wfv-skipped { border-style: dashed; background: #F8FAFC; opacity: .7; }
.wfv-state { position: absolute; bottom: -9px; inset-inline-end: 10px; font-size: 10px; font-weight: 700;
    padding: 1px 7px; border-radius: 8px; border: 1px solid #E2E8F0; background: #fff; color: #64748B; }
.wfv-state-done { border-color: #6EE7B7; color: #047857; }
.wfv-state-active { border-color: #0EA5E9; background: #0EA5E9; color: #fff; }
.wfv-state-skipped { color: #94A3B8; }
.wfv-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.wfv-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #334155;
    background: #fff; border: 1.5px solid #E2E8F0; border-radius: 10px; padding: 6px 12px; cursor: pointer; }
.wfv-btn:hover { border-color: #0EA5E9; color: #0369A1; }
.wf-map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 11px; color: #64748B; }
.wf-map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.wf-map-legend i { font-size: 8px; }
.tab-btn { padding: 10px 18px; font-size: 13px; font-weight: 700; color: #64748B; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; transition: all .2s; background: transparent; border-top: 0; border-inline: 0; }
.tab-btn.active { color: #0369A1; border-bottom-color: #0EA5E9; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.seg-pane { display: none; }
.seg-pane.active { display: block; }

/* ── مفتاح تبديل (Switch) — آمن للاتجاهين ── */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #CBD5E1; border-radius: 20px; transition: .3s; }
.slider::before { content: ''; position: absolute; height: 16px; width: 16px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.switch input:checked + .slider { background: #10B981; }
.switch input:checked + .slider::before { inset-inline-start: 19px; }
.switch input:disabled + .slider { cursor: default; opacity: .85; }

/* ── حركات ── */
@keyframes pulse-red { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); } }
.pulse-red { animation: pulse-red 1.5s infinite; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fade-up .5s ease-out both; }

/* ── البحث + الجداول ── */
.search-bar { background: #F8FAFC; border: 1.5px solid #E2E8F0; transition: all .2s ease; }
.search-bar:focus-within { background: #fff; border-color: #38BDF8; box-shadow: 0 0 0 4px rgba(14,165,233,.1); }
.table-row { transition: all .15s ease; cursor: pointer; }
.table-row:hover { background: #F0F9FF; }

/* ── قائمة نتائج البحث العام (الشريط العلوي) ── */
/* تمتدّ بعرض حقل البحث نفسه (start:0/end:0) لأنها تابعةٌ له لا لزرٍّ في الطرف، فلا تحتاج مرساة hdr-menu. */
.gs-menu { position: absolute; top: calc(100% + 8px); inset-inline-start: 0; inset-inline-end: 0; background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; box-shadow: 0 20px 50px rgba(15,23,42,.16); z-index: 70; display: none; overflow: hidden; max-height: 70vh; overflow-y: auto; }
.gs-menu.show { display: block; animation: hdr-pop .18s ease-out; }
.gs-item { display: block; padding: 10px 14px; border-bottom: 1px solid #F1F5F9; cursor: pointer; transition: background .15s; text-align: start; width: 100%; }
.gs-item:last-child { border-bottom: 0; }
.gs-item:hover, .gs-item.active { background: #F0F9FF; }
.gs-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.gs-num { font-family: ui-monospace, monospace; font-size: 11px; color: #64748B; direction: ltr; }
.gs-subject { font-size: 13px; font-weight: 700; color: #0F172A; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-meta { font-size: 11px; color: #64748B; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.gs-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: #F8FAFC; border-top: 1px solid #E2E8F0; font-size: 12px; font-weight: 700; color: #0369A1; cursor: pointer; width: 100%; }
.gs-foot:hover, .gs-foot.active { background: #E0F2FE; }
.gs-state { padding: 18px 14px; text-align: center; font-size: 12px; color: #64748B; }

/* ── الحقول (نماذج) ── */
.fld-label { font-size: 13px; font-weight: 700; color: #334155; margin-bottom: 6px; display: block; }
.fld { background: #F8FAFC; border: 1.5px solid #E2E8F0; border-radius: 12px; padding: 10px 14px; font-size: 14px; width: 100%; }
.fld:focus { background: #fff; border-color: #38BDF8; outline: none; box-shadow: 0 0 0 4px rgba(14,165,233,.1); }

/* ── قوائم الشريط العلوي ── */
.hdr-rel { position: relative; }
.hdr-btn { height: 40px; border-radius: 12px; display: flex; align-items: center; gap: 8px; padding: 0 10px; color: #475569; transition: all .2s; cursor: pointer; }
.hdr-btn:hover { background: #F1F5F9; }
/* المرساة: أزرارُ الشريط العلوي تقع دائماً في طرف الترويسة المنطقيّ (inline-end) — يسارُ الشاشة في RTL
   ويمينُها في LTR. فتُثبَّت القائمة من inline-end لتنفتح نحو داخل الصفحة لا نحو حافّتها فتُقتطَع. */
.hdr-menu { position: absolute; top: calc(100% + 8px); inset-inline-start: auto; inset-inline-end: 0; max-width: calc(100vw - 2rem); background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; box-shadow: 0 20px 50px rgba(15,23,42,.16); z-index: 70; display: none; overflow: hidden; }
.hdr-menu.show { display: block; animation: hdr-pop .18s ease-out; }
@keyframes hdr-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 11px 16px; font-size: 13px; font-weight: 600; color: #334155; cursor: pointer; transition: all .15s; }
.menu-item:hover { background: #F0F9FF; color: #0369A1; }
.menu-item i { width: 18px; text-align: center; color: #94A3B8; }
.menu-item:hover i { color: #0EA5E9; }
.menu-item.danger { color: #DC2626; }
.menu-item.danger:hover { background: #FEF2F2; color: #B91C1C; }
.menu-item.danger i { color: #F87171; }
.notif-row { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid #F1F5F9; cursor: pointer; }
.notif-row:hover { background: #F8FAFC; }
.notif-ic { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lang-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; font-size: 13px; font-weight: 600; color: #334155; cursor: pointer; }
.lang-opt:hover { background: #F0F9FF; }

/* ── مودال موحّد ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); z-index: 95; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 18px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(15,23,42,.25); }
.modal-box-lg { width: min(880px, 100%); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid #E2E8F0; display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid #E2E8F0; display: flex; justify-content: flex-end; gap: 8px; }

/* ── أزرار ── */
.btn-primary { background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%); box-shadow: 0 4px 14px rgba(14,165,233,.35); color: #fff; transition: all .25s ease; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(14,165,233,.45); }
.btn-ghost { background: #fff; border: 1px solid #E2E8F0; color: #475569; font-weight: 600; border-radius: 10px; transition: all .2s; }
.btn-ghost:hover { border-color: #7DD3FC; background: #F0F9FF; color: #0369A1; }
.btn-ghost:disabled, .btn-ghost.nav-disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost:disabled:hover, .btn-ghost.nav-disabled:hover { border-color: #E2E8F0; background: #fff; color: #475569; }

/* ── تبويبات عمودية للإعدادات (C17) — آمنة للاتجاهين ── */
.settings-tab { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; color: #475569; cursor: pointer; transition: all .2s ease; width: 100%; text-align: start; background: transparent; border: 0; }
.settings-tab:hover:not(.active) { background: #F0F9FF; color: #0369A1; }
.settings-tab.active { background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; box-shadow: 0 4px 12px rgba(14,165,233,.3); }
.settings-tab i { width: 18px; text-align: center; }
.settings-tab .tab-soon { margin-inline-start: auto; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
/* لوحات تبويب صفحة «حسابي» (نمط مشترك منطقي — نظير settings-pane). */
.acc-pane { display: none; }
.acc-pane.active { display: block; }

/* ── حقول النماذج (نمط C17) ── */
.form-input { width: 100%; background: #F8FAFC; border: 1.5px solid #E2E8F0; border-radius: 10px; padding: 9px 12px; font-size: 13px; color: #1E293B; transition: all .2s; }
.form-input:focus { outline: none; background: #fff; border-color: #38BDF8; box-shadow: 0 0 0 4px rgba(14,165,233,.1); }
.form-input:disabled { opacity: .6; cursor: not-allowed; }
.form-label { display: block; font-size: 12.5px; font-weight: 700; color: #334155; margin-bottom: 6px; }
.form-hint { font-size: 11px; color: #94A3B8; margin-top: 5px; }

/* ── حقلٌ بلاحقةٍ ثابتة (مثل: النطاق الفرعي + .domain) ──
   اللاحقة جزءٌ من صندوق الحقل بصرياً لا نصٌّ يطفو بجانبه، فيُقرأ الحقل وحدةً واحدة. */
.input-group { display: flex; align-items: stretch; direction: ltr; }
.input-group > .form-input { border-start-end-radius: 0; border-end-end-radius: 0; border-inline-end: none; }
.input-group > .form-input:focus { position: relative; z-index: 1; border-inline-end: none; }
.input-group > .input-suffix {
    display: flex; align-items: center; white-space: nowrap;
    background: #F1F5F9; border: 1.5px solid #E2E8F0; border-inline-start: none;
    border-start-end-radius: 10px; border-end-end-radius: 10px;
    padding: 0 12px; font-size: 12px; color: #64748B; direction: ltr;
}

/* ── منطقة رفع (شعار الجهة) ── */
.upload-zone { border: 2px dashed #CBD5E1; border-radius: 14px; background: #F8FAFC; transition: all .2s; cursor: pointer; }
.upload-zone:hover { border-color: #7DD3FC; background: #F0F9FF; }
.upload-zone.nav-disabled { cursor: not-allowed; }
.upload-zone.nav-disabled:hover { border-color: #CBD5E1; background: #F8FAFC; }
/* §4.6 حالة السحب فوق المنطقة (dropzone.js) */
.upload-zone.dragover { border-color: #0EA5E9; background: #E0F2FE; box-shadow: 0 0 0 4px rgba(14,165,233,.12); }

/* ── شجرة الهيكل التنظيمي (C07) ── */
.tree-node { border: 1.5px solid #E2E8F0; border-radius: 12px; padding: 10px 14px; background: #fff; transition: all .2s; }
.tree-node:hover { border-color: #7DD3FC; background: #F0F9FF; }
.tree-children { padding-inline-start: 24px; border-inline-start: 2px dashed #E2E8F0; margin-inline-start: 18px; }

/* ── رقائق الفلاتر (Filter chips) ── */
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: #fff; border: 1.5px solid #E2E8F0; border-radius: 20px; font-size: 12px; font-weight: 600; color: #334155; cursor: pointer; transition: all .2s ease; }
.filter-chip:hover { border-color: #7DD3FC; background: #F0F9FF; }
.filter-chip.active { background: #0EA5E9; color: #fff; border-color: #0EA5E9; }

/* ── بطاقة تقرير جاهز (Report tile) — C10، آمنة للاتجاهين ── */
.report-tile { border: 1px solid #E2E8F0; border-radius: 12px; padding: 16px; cursor: pointer; transition: all .2s ease; }
.report-tile:hover { border-color: #7DD3FC; background: #F0F9FF; transform: translateY(-2px); }

/* ── قائمة منسدلة لإجراءات الصف (Row actions dropdown) — آمنة للاتجاهين ── */
.dropdown-menu { position: absolute; top: 100%; inset-inline-end: 0; margin-top: 6px; background: #fff; border: 1px solid #E2E8F0; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.1); min-width: 190px; z-index: 30; display: none; overflow: hidden; }
.dropdown-menu.show { display: block; animation: hdr-pop .18s ease-out; }
.dropdown-item { padding: 10px 14px; font-size: 13px; color: #334155; cursor: pointer; display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 0; text-align: start; }
.dropdown-item:hover { background: #F0F9FF; color: #0369A1; }
.dropdown-item.danger { color: #DC2626; }
.dropdown-item.danger:hover { background: #FEF2F2; color: #B91C1C; }

/* ── درج المعاينة السريعة (Quick View) ── */
.sv-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 90; display: none; }
.sv-overlay.show { display: block; }
.sv-drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: -520px; width: min(480px, 95vw); background: #fff; display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(15,23,42,.18); z-index: 91; transition: inset-inline-end .3s cubic-bezier(.4,0,.2,1); }
.sv-drawer.show { inset-inline-end: 0; }
.sv-head { padding: 18px 22px; border-bottom: 1px solid #E2E8F0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sv-body { flex: 1; overflow-y: auto; padding: 20px 22px; font-size: 14px; }
.sv-foot { padding: 14px 22px; border-top: 1px solid #E2E8F0; display: flex; gap: 8px; }

/* ── معاينة المستند الحقيقي داخل درج المعاينة السريعة: iframe بصفحة المستند مُصغَّرٌ بنسبة A4 ── */
.sv-mini { display: block; text-decoration: none; cursor: pointer; }
.sv-doc-shell { position: relative; border: 1px solid #E2E8F0; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 20px rgba(15,23,42,.06); background: #fff; aspect-ratio: 210 / 297; transition: all .2s ease; }
.sv-mini:hover .sv-doc-shell { border-color: #7DD3FC; box-shadow: 0 12px 28px rgba(14,165,233,.14); transform: translateY(-2px); }
/* الإطار بعرض ورقة A4 (794px) ثابتٍ ثم يُصغَّر عبر transform في JS ليملأ عرض الغلاف؛ الزائد يُقصّ. */
.sv-doc-frame { position: absolute; top: 0; left: 0; width: 794px; height: 1123px; border: 0; background: #fff; transform-origin: top left; pointer-events: none; }
/* قناعٌ شفّاف يبتلع النقر فيُفعّل رابط المعاينة بدل التقاط الـiframe له. */
.sv-doc-mask { position: absolute; inset: 0; z-index: 1; }
.sv-mini-cta { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; font-size: 12px; font-weight: 700; color: #0369A1; }
[dir="ltr"] .sv-mini-cta .fa-arrow-left::before { content: "\f061"; }

/* ── علامة الحقل الإلزامي + أزرار تبديل العرض + بطاقة الشبكة (الوارد C03) ── */
.req { color: #EF4444; }
.view-btn { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: all .2s; cursor: pointer; }
.view-btn.active { background: #0EA5E9; color: #fff; }
.view-btn:not(.active) { color: #94A3B8; background: #fff; border: 1px solid #E2E8F0; }
.doc-card { transition: all .25s ease; cursor: pointer; }
.doc-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,23,42,.08); border-color: #7DD3FC; }

/* ── معالج التسجيل (C05): مؤشّر الخطوات + بطاقات النوع — آمن للاتجاهين ── */
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; position: relative; }
.step-circle { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; border: 2px solid #E2E8F0; background: #fff; color: #94A3B8; z-index: 2; transition: all .3s; }
.step.active .step-circle { background: linear-gradient(135deg, #0EA5E9, #0284C7); border-color: #0EA5E9; color: #fff; box-shadow: 0 4px 12px rgba(14,165,233,.3); }
.step.done .step-circle { background: #10B981; border-color: #10B981; color: #fff; }
.step-label { font-size: 12px; font-weight: 600; color: #94A3B8; }
.step.active .step-label, .step.done .step-label { color: #0F172A; }
.step-line { position: absolute; top: 22px; inset-inline-end: 50%; inset-inline-start: -50%; height: 2px; background: #E2E8F0; z-index: 1; }
.step.done .step-line { background: #10B981; }
.step-pane { display: none; }
.step-pane.active { display: block; }
/* حالة الخطأ قبل الانتقال (wizard-validate.js): الحقل الناقص يُلوَّن، ودائرةُ خطوته تحمر في
   المؤشّر — كي يُرى موضعُ النقص من الشريط العلوي بلا فتح كل خطوة. الترتيب مقصود: يلي
   .step.active/.done ليغلبهما بالتساوي في الأولوية. */
.fld-error { border-color: #EF4444; background: #FEF2F2; }
.fld-error:focus { border-color: #EF4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, .12); }
.step.invalid .step-circle { background: #FEF2F2; border-color: #EF4444; color: #DC2626; box-shadow: none; }
.step.active.invalid .step-circle { background: linear-gradient(135deg, #F87171, #DC2626); border-color: #DC2626; color: #fff; box-shadow: 0 4px 12px rgba(239, 68, 68, .3); }
.step.invalid .step-label { color: #B91C1C; }
.type-card { border: 2px solid #E2E8F0; border-radius: 14px; padding: 18px; cursor: pointer; transition: all .2s; }
.type-card:hover:not(.nav-disabled) { border-color: #7DD3FC; background: #F0F9FF; }
.type-card.selected { border-color: #0EA5E9; background: #F0F9FF; box-shadow: 0 4px 12px rgba(14,165,233,.15); }

/* ── خط سير المعاملة (Timeline) — C06، آمن للاتجاهين ── */
.timeline { position: relative; padding-inline-start: 34px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 13px; top: 6px; bottom: 6px; width: 2px; background: #E2E8F0; }
.tl-item { position: relative; padding-bottom: 22px; }
.tl-dot { position: absolute; inset-inline-start: -34px; top: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; z-index: 2; border: 3px solid #fff; }

/* ── ورقة المستند الرسمي (C06) ── */
.doc-wrap { background: #EEF2F7; padding: 28px; border-radius: 14px; display: flex; justify-content: center; }
/* الورقة بنسبة A4 ثابتة (210×297): aspect-ratio يَفرض ارتفاع صفحة A4 كاملةٍ مهما قَلّ المحتوى — مع أيّ عرض —
   ويسمح بالنموّ إذا زاد المحتوى. لا نضع min-height ثابتاً بالبكسل لئلّا يكسر النسبة على العروض الضيّقة (الجوال/عمودٌ
   جانبي). الفوتر مُعلَّقٌ مطلقاً أسفل الورقة (.paper-foot) فيلتصق بقاعها دائماً. مشتركٌ لكل صفحات المستند (وارد/صادر/داخلي/اعتمادات). */
.paper { background: #fff; width: 100%; max-width: 794px; aspect-ratio: 210 / 297; height: auto; box-shadow: 0 12px 45px rgba(15,23,42,.14); border: 1px solid #E2E8F0; border-radius: 2px; padding: 46px 54px; position: relative; overflow: hidden; font-size: 15px; line-height: 2; color: #1E293B; }
.paper-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: .035; font-size: 160px; font-weight: 900; color: #0369A1; transform: rotate(-22deg); }
.paper-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 3px double #0369A1; padding-bottom: 18px; }
.paper-field { color: #0EA5E9; font-weight: 700; }
.paper-seal { width: 96px; height: 96px; border-radius: 50%; border: 2px dashed #94A3B8; color: #64748B; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; font-weight: 700; transform: rotate(-12deg); opacity: .85; }
/* العلامة المائية الديناميكية (§9.4 الشريحة 4): لونها يُشتقّ من حالة المعاملة عبر PaperStamp — تبقى مخفيّةً عند الطباعة. */
.paper-watermark--draft { color: #B45309; }    /* مسودة (amber-700) */
.paper-watermark--positive { color: #047857; } /* معتمد/موقّع/مكتمل (emerald-700) */
.paper-watermark--negative { color: #B91C1C; } /* ملغى/مُعاد/متجاوَز (red-700) */
/* الختم المعمَّم: غلافٌ مطلقٌ يضع .paper-seal القائم أسفل-بداية الورقة (RTL منطقيّ) بلا تداخلٍ مع التوقيع/الفوتر. */
.paper-seal-wrap { position: absolute; inset-inline-start: 54px; bottom: 74px; pointer-events: none; }
/* صورة ختمٍ مرفوعة (بديلُ التصميم) — بنفس حجم/ميل .paper-seal القائم. */
.paper-seal-img { width: 96px; height: 96px; object-fit: contain; transform: rotate(-12deg); opacity: .9; }

@media print {
    /* اطبع ورقة المستند (.paper) وحدها. نستخدم display:none (لا visibility:hidden) لكل ما ليس
       الورقةَ ولا من محتواها ولا من آبائها — حتى لا يتبقّى ارتفاعٌ مخفيٌّ يُولّد صفحاتٍ فارغة بعد الخطاب
       (كان هذا سبب طباعة «شيءٍ أكبر»). صفحات بلا .paper (التقارير/التدقيق) لا تتأثّر إطلاقاً. */
    body:has(.paper) *:not(.paper):not(.paper *):not(:has(.paper)) { display: none !important; }

    /* سلسلة آباء الورقة تتحوّل إلى كتلٍ كاملة العرض بلا حشو/بطاقة كي لا تُقيّد الشبكةُ عرضَ الورقة */
    body:has(.paper) :has(.paper) {
        display: block !important; width: auto !important; max-width: none !important;
        min-height: 0 !important; height: auto !important;
        margin: 0 !important; padding: 0 !important; background: #fff !important;
        border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    }
    body:has(.paper) .doc-wrap { background: #fff !important; padding: 0 !important; }
    /* الورقة عمودٌ مرنٌ بارتفاع صفحةٍ تقريباً (245mm آمنة تحت A4 وLetter بهامش 12mm) كي يُدفع الفوتر للأسفل */
    body:has(.paper) .paper {
        display: flex !important; flex-direction: column !important;
        width: 100% !important; max-width: none !important; min-height: 245mm !important;
        box-shadow: none !important; border: 0 !important; border-radius: 0 !important; overflow: visible !important;
    }
    body:has(.paper) .paper-watermark { display: none !important; }
    /* الفوتر: من معلّقٍ مطلق (يلتصق بالمحتوى عند انكماش الورقة) إلى عنصرٍ في التدفّق يُدفع لأسفل الصفحة بلا تداخل */
    body:has(.paper) .paper-foot { position: static !important; margin-top: auto !important; }
    @page { margin: 12mm; }
}

/* ── لوحة المهام (كانبان) + بطاقة المهمة + شريط الإنجاز (C09) — أنماط مشتركة آمنة للاتجاهين ── */
.kanban-col { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 14px; }
.task-card { background: #fff; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px; cursor: pointer; transition: all .2s; }
.task-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.08); border-color: #7DD3FC; transform: translateY(-1px); }
.progress-bar { height: 6px; background: #E2E8F0; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; background: #0EA5E9; }
@keyframes pulse-red { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); } }
.pulse-red { animation: pulse-red 1.5s infinite; }

/* ── القوالب الرسمية (C14): عنصر قائمة + شارات المتغيّرات + معاينة الخطاب + أزرار المحرّر — مشتركة آمنة للاتجاهين ── */
.tpl-item { transition: all .2s ease; cursor: pointer; border: 1.5px solid #E2E8F0; border-radius: 14px; }
.tpl-item:hover { border-color: #7DD3FC; background: #F0F9FF; }
.tpl-item.selected { border-color: #0EA5E9; background: #F0F9FF; box-shadow: 0 4px 14px rgba(14,165,233,.18); }
.tpl-item.selected .tpl-ic { background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; }
.toolbar-btn { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #475569; background: #fff; border: 1px solid #E2E8F0; cursor: pointer; transition: all .15s; }
.toolbar-btn:hover { background: #F0F9FF; color: #0369A1; border-color: #7DD3FC; }
.tpl-var { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; border-radius: 5px; padding: 0 5px; font-weight: 700; font-family: monospace; font-size: .92em; direction: ltr; display: inline-block; }
.var-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; background: #FEF9EC; border: 1px solid #FDE68A; color: #92400E; font-family: monospace; direction: ltr; cursor: pointer; transition: all .15s; }
.var-badge:hover { background: #FEF3C7; border-color: #FBBF24; }
.letter-preview { background: #fff; border: 1px solid #E2E8F0; border-radius: 12px; padding: 34px 40px; line-height: 2.1; color: #1E293B; font-size: 14px; box-shadow: inset 0 0 0 1px #F8FAFC; }

/* تمييز صفّ المعاملة المتأخرة بلون خفيف (إثراء واجهة الوارد) — محايد للاتجاه */
.overdue-row { background: #FEF2F2; }
.overdue-row:hover { background: #FEE2E2; }
/* مصغّر مرفق صورة */
.att-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid #E2E8F0; background: #F8FAFC; }

/* ════════════════════════════════════════════════════════════════
   عمود المرفقات في قوائم المعاملات (<x-lists.attachments-cell>)
   رقاقةُ عددٍ في الخليّة + لوحةٌ عائمةٌ بأسماء الملفات. كل الأنماط آمنة
   للاتجاهين (خصائص منطقية). اللوحة تُثبَّت على <body> بـposition:fixed
   لأن غلاف الجدول overflow-x:auto يقصّ أيّ عنصرٍ مطلقٍ داخله.
   ════════════════════════════════════════════════════════════════ */
.att-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; border: 1.5px solid #BAE6FD; background: #F0F9FF; color: #0369A1; font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer; transition: all .18s ease; }
.att-chip:hover { background: #E0F2FE; border-color: #38BDF8; box-shadow: 0 4px 12px rgba(14,165,233,.18); transform: translateY(-1px); }
.att-chip[aria-expanded="true"] { background: #0EA5E9; border-color: #0EA5E9; color: #fff; box-shadow: 0 4px 14px rgba(14,165,233,.32); }
.att-chip-count { font-family: inherit; font-variant-numeric: tabular-nums; font-size: 12px; }
.att-chip-lock { font-size: 9px; opacity: .75; }
/* بلا مرفقات: علامةٌ باهتةٌ غير تفاعلية (فراغٌ مقصودٌ لا زرٌّ معطَّل) */
.att-chip-empty { border-color: transparent; background: transparent; color: #CBD5E1; cursor: default; padding: 5px 6px; }
.att-chip-empty:hover { background: transparent; border-color: transparent; box-shadow: none; transform: none; }

.att-pop { position: fixed; z-index: 95; width: 330px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; box-shadow: 0 18px 44px rgba(15,23,42,.16); overflow: hidden; display: none; text-align: start; }
.att-pop.show { display: block; animation: att-pop-in .16s ease-out; }
@keyframes att-pop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.att-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: linear-gradient(135deg, #F0F9FF, #E0F2FE); border-bottom: 1px solid #E2E8F0; }
.att-pop-title { font-size: 12px; font-weight: 800; color: #0C4A6E; display: inline-flex; align-items: center; gap: 6px; }
.att-pop-num { font-size: 10px; font-family: ui-monospace, monospace; color: #64748B; }
.att-pop-list { list-style: none; margin: 0; padding: 6px; max-height: 268px; overflow-y: auto; }
.att-pop-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; transition: background .15s ease; }
.att-pop-item:hover { background: #F8FAFC; }
.att-pop-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.att-pop-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-pop-name { font-size: 12.5px; font-weight: 700; color: #1E293B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-pop-sub { font-size: 10.5px; color: #94A3B8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-pop-locked .att-pop-name { color: #94A3B8; font-style: italic; }
.att-pop-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.att-pop-btn { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; transition: all .15s ease; }
.att-pop-view { color: #0284C7; }
.att-pop-view:hover { background: #E0F2FE; }
.att-pop-dl { color: #059669; }
.att-pop-dl:hover { background: #D1FAE5; }
.att-pop-off { color: #CBD5E1; cursor: not-allowed; }
.att-pop-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-top: 1px solid #F1F5F9; background: #FCFDFE; font-size: 11.5px; font-weight: 700; color: #0369A1; transition: background .15s ease; }
.att-pop-foot:hover { background: #F0F9FF; }
[dir="ltr"] .att-pop-go::before { content: "\f061"; }

/* ════════════════════════════════════════════════════════════════
   مساعدة الصفحة (Help) — زر في الشريط العلوي + مودال شرح كامل
   كل الأنماط آمنة للاتجاهين (RTL/LTR) عبر الخصائص المنطقية.
   ════════════════════════════════════════════════════════════════ */
.help-trigger { color: #0369A1; }
.help-trigger:hover { background: #E0F2FE; color: #075985; }

/* صندوق المودال: عمود مرن برأس/جسم/ذيل ثابتين والجسم يتمرّر */
.help-overlay { z-index: 110; }
.help-box { display: flex; flex-direction: column; max-height: 90vh; padding: 0; overflow: hidden; }

.help-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 24px; background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff; }
.help-head-title { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.help-head-ic { width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.help-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .04em; opacity: .85; margin: 0; }
.help-title { font-size: 19px; font-weight: 900; line-height: 1.3; margin: 1px 0 0; }
.help-tagline { font-size: 12.5px; opacity: .9; margin: 4px 0 0; line-height: 1.5; }
.help-close { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.15); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .2s; cursor: pointer; border: 0; }
.help-close:hover { background: rgba(255,255,255,.3); }

/* شريط التنقّل السريع */
.help-nav { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 24px; border-bottom: 1px solid #E2E8F0; background: #F8FAFC; flex-shrink: 0; }
.help-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: #fff; border: 1.5px solid #E2E8F0; border-radius: 20px; font-size: 11.5px; font-weight: 700; color: #334155; cursor: pointer; transition: all .2s; }
.help-chip:hover { border-color: #7DD3FC; background: #F0F9FF; color: #0369A1; }
.help-chip i { font-size: 11px; color: #0EA5E9; }

/* جسم المساعدة (المنطقة القابلة للتمرير) */
.help-body { flex: 1; overflow-y: auto; padding: 20px 24px 26px; scroll-behavior: smooth; }
.help-sec { padding: 18px 0; border-bottom: 1px dashed #E2E8F0; }
.help-sec:first-child { padding-top: 2px; }
.help-sec:last-child { border-bottom: 0; padding-bottom: 4px; }
.help-h { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 800; color: #0F172A; margin: 0 0 13px; }
.help-h i { width: 28px; height: 28px; border-radius: 9px; background: #E0F2FE; color: #0369A1; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }

.help-prose p { font-size: 13.7px; line-height: 1.95; color: #334155; margin: 0 0 10px; }
.help-prose p:last-child { margin-bottom: 0; }

/* بطاقات «ماذا تعمل» */
.help-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.help-card { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 13px; padding: 14px 15px; }
.help-card-h { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; color: #0F172A; margin-bottom: 7px; }
.help-card-h i { color: #0EA5E9; width: 18px; text-align: center; }
.help-card-body { font-size: 13px; line-height: 1.85; color: #475569; margin: 0; }
.help-ul { list-style: none; margin: 8px 0 0; padding: 0; }
.help-ul li { position: relative; padding-inline-start: 20px; font-size: 13px; line-height: 1.8; color: #475569; margin-bottom: 5px; }
.help-ul li::before { content: '\f105'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; inset-inline-start: 2px; color: #0EA5E9; }
[dir="ltr"] .help-ul li::before { content: '\f105'; }

/* خطوات طريقة الاستخدام */
.help-steps { list-style: none; counter-reset: hs; margin: 0; padding: 0; }
.help-steps > li { display: flex; gap: 13px; padding-bottom: 14px; position: relative; }
.help-steps > li:not(:last-child)::after { content: ''; position: absolute; inset-inline-start: 14px; top: 30px; bottom: 4px; width: 2px; background: #E0F2FE; }
.help-step-no { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; z-index: 1; box-shadow: 0 3px 8px rgba(14,165,233,.3); }
.help-step-txt { padding-top: 3px; }
.help-step-txt strong { display: block; font-size: 13.7px; color: #0F172A; margin-bottom: 2px; }
.help-step-txt p { font-size: 13px; line-height: 1.85; color: #475569; margin: 0; }

/* الأزرار والإجراءات */
.help-actions { display: flex; flex-direction: column; gap: 10px; }
.help-act { display: flex; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid #E2E8F0; border-radius: 13px; transition: all .2s; }
.help-act:hover { border-color: #7DD3FC; background: #F0F9FF; }
.help-act-ic { flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; background: #E0F2FE; color: #0369A1; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.help-act-label { font-size: 13.7px; font-weight: 800; color: #0F172A; margin: 2px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.help-act-desc { font-size: 12.8px; line-height: 1.8; color: #475569; margin: 4px 0 0; }
.help-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: #FEF3C7; color: #92400E; }

/* الحقول */
.help-fields { display: flex; flex-direction: column; gap: 0; border: 1px solid #E2E8F0; border-radius: 13px; overflow: hidden; }
.help-field { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: 14px; padding: 11px 15px; border-bottom: 1px solid #F1F5F9; }
.help-field:nth-child(odd) { background: #F8FAFC; }
.help-field:last-child { border-bottom: 0; }
.help-field-name { font-size: 12.8px; font-weight: 800; color: #0F172A; }
.help-field-desc { font-size: 12.8px; line-height: 1.75; color: #475569; }

/* الحالات */
.help-states { display: flex; flex-direction: column; gap: 8px; }
.help-state { display: flex; align-items: flex-start; gap: 11px; }
.help-state .badge { flex-shrink: 0; margin-top: 1px; min-width: 84px; justify-content: center; }
.help-state-desc { font-size: 12.8px; line-height: 1.75; color: #475569; }

/* صفحات ذات علاقة */
.help-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 11px; }
.help-rel { display: flex; gap: 11px; padding: 12px 14px; background: #fff; border: 1px solid #E2E8F0; border-radius: 13px; transition: all .2s; text-decoration: none; }
a.help-rel:hover { border-color: #0EA5E9; background: #F0F9FF; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(14,165,233,.12); }
.help-rel-ic { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; background: #EDE9FE; color: #6D28D9; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.help-rel-label { font-size: 13.3px; font-weight: 800; color: #0F172A; margin: 1px 0 0; display: flex; align-items: center; gap: 6px; }
.help-rel-desc { font-size: 12.3px; line-height: 1.7; color: #64748B; margin: 3px 0 0; }

/* الصلاحيات */
.help-perms li::before { content: '\f3ed'; color: #0EA5E9; }

/* نصائح */
.help-tips { display: flex; flex-direction: column; gap: 9px; }
.help-tip { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; background: #ECFDF5; border: 1px solid #A7F3D0; border-radius: 12px; font-size: 13px; line-height: 1.8; color: #065F46; }
.help-tip i { color: #10B981; margin-top: 3px; flex-shrink: 0; }

/* أسئلة شائعة */
.help-faq { display: flex; flex-direction: column; gap: 8px; }
.help-qa { border: 1px solid #E2E8F0; border-radius: 12px; overflow: hidden; background: #fff; }
.help-qa summary { cursor: pointer; padding: 12px 15px; font-size: 13.3px; font-weight: 700; color: #0F172A; list-style: none; display: flex; align-items: center; gap: 9px; }
.help-qa summary::-webkit-details-marker { display: none; }
.help-qa summary::before { content: '\f054'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 11px; color: #0EA5E9; transition: transform .2s; }
[dir="rtl"] .help-qa summary::before { content: '\f053'; }
.help-qa[open] summary::before { transform: rotate(-90deg); }
[dir="rtl"] .help-qa[open] summary::before { transform: rotate(90deg); }
.help-qa[open] summary { background: #F0F9FF; color: #0369A1; }
.help-qa p { font-size: 12.8px; line-height: 1.9; color: #475569; margin: 0; padding: 4px 15px 14px; }

/* ذيل المودال */
.help-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid #E2E8F0; background: #F8FAFC; flex-shrink: 0; }
.help-foot-note { font-size: 11.5px; color: #94A3B8; display: inline-flex; align-items: center; gap: 6px; }
.help-foot-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 11px; font-size: 13px; font-weight: 700; background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; border: 0; cursor: pointer; transition: all .2s; text-decoration: none; }
.help-foot-btn:hover { box-shadow: 0 5px 16px rgba(14,165,233,.4); transform: translateY(-1px); }

/* الحالة الفارغة */
.help-empty { text-align: center; padding: 38px 20px; }
.help-empty-ic { width: 64px; height: 64px; border-radius: 18px; background: #E0F2FE; color: #0369A1; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 16px; }
.help-empty h4 { font-size: 16px; font-weight: 800; color: #0F172A; margin: 0 0 6px; }
.help-empty p { font-size: 13px; color: #64748B; line-height: 1.8; max-width: 420px; margin: 0 auto; }

/* زر مساعدة عائم (للصفحات المستقلة عن التخطيط الرئيسي: الدخول/التحقق بخطوتين) */
.help-fab { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 100; display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 14px; background: linear-gradient(135deg, #0EA5E9, #0284C7); color: #fff; font-size: 13.5px; font-weight: 700; border: 0; cursor: pointer; box-shadow: 0 8px 22px rgba(14,165,233,.4); transition: all .2s; }
.help-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(14,165,233,.5); }
.help-fab i { font-size: 16px; }

@media (max-width: 640px) {
    .help-field { grid-template-columns: 1fr; gap: 3px; }
    .help-cards, .help-related { grid-template-columns: 1fr; }
    .help-fab span { display: none; }
    .help-fab { padding: 13px; border-radius: 50%; }
}


/* ===== المساعدة السياقية على مستوى العنصر (أيقونة «؟» + منبثق ملاصق) ===== */
.hint-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; padding: 0; margin-inline-start: 5px;
    border-radius: 50%; border: 0; cursor: pointer; vertical-align: middle;
    background: #E0F2FE; color: #0369A1; font-size: 11px; line-height: 1;
    transition: background .15s, color .15s, transform .15s; flex: none;
}
.hint-btn:hover { background: #0EA5E9; color: #fff; transform: scale(1.08); }
.hint-btn:focus-visible { outline: 2px solid #0EA5E9; outline-offset: 2px; }
.hint-btn i { font-size: 11px; }

/* المنبثق: يطفو ملاصقاً للزر، بلا خلفية معتمة */
.hint-pop {
    position: fixed; z-index: 200; width: max-content; max-width: 340px;
    background: #fff; border: 1px solid #E2E8F0; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15,23,42,.18); padding: 0;
    opacity: 0; transform: translateY(-4px); transition: opacity .12s ease, transform .12s ease;
}
.hint-pop.show { opacity: 1; transform: translateY(0); }
.hint-pop[hidden] { display: none; }

.hint-pop-arrow {
    position: absolute; width: 12px; height: 12px; background: #fff;
    border: 1px solid #E2E8F0; transform: rotate(45deg);
}
.hint-pop-arrow.is-top { top: -7px; border-bottom: 0; border-inline-end: 0; }      /* المنبثق أسفل الزر → السهم للأعلى */
.hint-pop-arrow.is-bottom { bottom: -7px; border-top: 0; border-inline-start: 0; }  /* المنبثق أعلى الزر → السهم للأسفل */

.hint-pop-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px 6px; border-bottom: 1px solid #F1F5F9;
}
.hint-pop-ic {
    width: 24px; height: 24px; border-radius: 7px; flex: none; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff;
}
.hint-pop-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 800; color: #0f172a; }
.hint-pop-close {
    width: 24px; height: 24px; border-radius: 6px; border: 0; cursor: pointer; flex: none;
    background: transparent; color: #94a3b8; display: flex; align-items: center; justify-content: center;
    font-size: 12px; transition: background .15s, color .15s;
}
.hint-pop-close:hover { background: #F1F5F9; color: #0f172a; }

.hint-pop-body { padding: 9px 12px 12px; }
.hint-pop-text { font-size: 13px; line-height: 1.75; color: #334155; margin: 0; }
.hint-pop-text[hidden] { display: none; }
.hint-pop-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.hint-pop-list[hidden] { display: none; }
.hint-pop-list li {
    position: relative; font-size: 12.5px; line-height: 1.6; color: #475569; padding-inline-start: 18px;
}
.hint-pop-list li::before {
    content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    position: absolute; inset-inline-start: 0; top: 1px; color: #0EA5E9; font-size: 11px;
}

/* لوحة الإجراءات السفلية الموحّدة (§9.4 الشريحة 3) — شريطٌ سفليٌّ لاصقٌ بهوية Sky، RTL منطقيّ.
   sticky bottom: يبقى ظاهراً أثناء التمرير ويرتدّ لمكانه عند نهاية الصفحة دون حجب المحتوى (يحجز مساحته). */
.tx-action-bar {
    position: sticky;
    bottom: 12px;
    z-index: 20;
    margin-top: 8px;
    pointer-events: none; /* تمرير النقر للمحتوى خارج الحاوية الداخلية */
}
.tx-action-bar-inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 18px;
    border: 1px solid #BAE6FD;
    background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(240,249,255,.96));
    backdrop-filter: blur(6px);
    box-shadow: 0 14px 38px rgba(2,132,199,.16), 0 2px 6px rgba(15,23,42,.06);
}
.tx-action-bar-inner::before {
    content: "\f0c9"; /* أيقونة دلالة الشريط (Font Awesome) */
    font-family: "Font Awesome 6 Free"; font-weight: 900;
    width: 30px; height: 30px; flex: none; border-radius: 9px; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff;
}
@media (max-width: 640px) {
    .tx-action-bar { bottom: 0; }
    .tx-action-bar-inner { border-radius: 14px; padding: 10px 12px; }
    .tx-action-bar-inner::before { display: none; }
}
@media print {
    .tx-action-bar { display: none !important; }
}

/* ═══════════════ §5 الجولة الإرشادية الموجَّهة (guided tour) — بلا تبعيّة، هويّة Sky/Tajawal، RTL منطقيّ ═══════════════ */
.tour-root[aria-hidden="true"] { display: none; }
.tour-root[aria-hidden="false"] { display: block; }
.tour-veil { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); z-index: 96; }
/* التسليط الضوئيّ: إطارٌ سماويٌّ + ظلٌّ ضخمٌ يُعتِم ما حوله دون حجب الهدف (لا SVG، لا plugin). */
.tour-spot { position: fixed; z-index: 96; border-radius: 12px; border: 2px solid #38BDF8;
    box-shadow: 0 0 0 9999px rgba(15,23,42,.55), 0 0 0 4px rgba(14,165,233,.35); pointer-events: none;
    transition: top .2s ease, left .2s ease, width .2s ease, height .2s ease; }
.tour-pop { position: fixed; z-index: 97; width: min(340px, calc(100vw - 24px)); background: #fff;
    border: 1px solid #E2E8F0; border-radius: 16px; box-shadow: 0 25px 60px rgba(15,23,42,.25);
    padding: 16px 18px 14px; }
.tour-pop.is-center { width: min(420px, calc(100vw - 32px)); }
.tour-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tour-badge { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: #0369A1;
    background: #E0F2FE; border-radius: 999px; padding: 3px 10px; }
.tour-x { width: 28px; height: 28px; border-radius: 8px; color: #64748B; font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center; transition: all .2s; }
.tour-x:hover { background: #F1F5F9; color: #0F172A; }
.tour-pop-title { font-size: 15px; font-weight: 800; color: #0F172A; margin-bottom: 4px; }
.tour-pop-desc { font-size: 13px; line-height: 1.7; color: #475569; }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.tour-dot { width: 7px; height: 7px; border-radius: 999px; background: #CBD5E1; transition: all .2s; }
.tour-dot.active { background: #0EA5E9; width: 20px; }
.tour-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-btn { font-size: 13px; font-weight: 700; border-radius: 10px; padding: 8px 18px; transition: all .25s ease; }
.tour-btn-ghost { color: #0369A1; }
.tour-btn-ghost:hover { background: #F0F9FF; }
.tour-btn-primary { background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%); color: #fff;
    box-shadow: 0 4px 14px rgba(14,165,233,.35); }
.tour-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(14,165,233,.45); }
/* زرّ إطلاق الجولة داخل مودال المساعدة */
.help-tour-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
    color: #0369A1; background: #F0F9FF; border: 1px solid #BAE6FD; border-radius: 10px; padding: 8px 16px;
    transition: all .25s ease; }
.help-tour-btn:hover { background: #E0F2FE; border-color: #7DD3FC; transform: translateY(-1px); }
@media print {
    .tour-root { display: none !important; }
}

/* ============================================================================
   الدردشة الداخليّة (إذن المالك 2026-07-15) — نافذة مثبّتة أسفل الشريط الجانبي + بالون
   ============================================================================ */
.chat-widget {
    position: fixed; bottom: 1rem; inset-inline-start: calc(260px + 1rem); z-index: 95;
    width: 370px; max-width: calc(100vw - 260px - 2rem);
    height: 560px; max-height: calc(100vh - 2rem);
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid #E2E8F0; border-radius: 1rem;
    box-shadow: 0 20px 45px -12px rgba(2, 32, 60, .28); overflow: hidden;
    transition: inset-inline-start .2s ease;
}
.chat-hd { flex-shrink: 0; background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff; }
.chat-hd-row { display: flex; align-items: center; gap: .5rem; padding: .65rem .8rem; position: relative; }
.chat-hd-title { font-weight: 800; font-size: .95rem; display: flex; align-items: center; gap: .5rem; flex: 1; }
.chat-hd-actions { display: flex; align-items: center; gap: .15rem; }
.chat-hd-actions button, .chat-hd-back {
    width: 32px; height: 32px; border-radius: .6rem; background: transparent; border: 0; color: #fff;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s;
}
.chat-hd-actions button:hover, .chat-hd-back:hover { background: rgba(255, 255, 255, .18); }
.chat-hd-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .22); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.chat-hd-avatar.is-group { border-radius: .6rem; }
.chat-hd-meta { flex: 1; min-width: 0; line-height: 1.2; }
.chat-hd-name { font-weight: 800; font-size: .9rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-hd-meta small { font-size: .7rem; opacity: .85; }
[dir="ltr"] .chat-rtl-flip { transform: scaleX(-1); }

.chat-convo-menu {
    position: absolute; top: 48px; inset-inline-end: .6rem; background: #fff; color: #0f172a;
    border: 1px solid #E2E8F0; border-radius: .7rem; box-shadow: 0 12px 28px -8px rgba(2, 32, 60, .25);
    padding: .3rem; min-width: 180px; z-index: 5;
}
.chat-menu-item {
    width: 100%; display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem; border: 0; background: transparent;
    border-radius: .5rem; cursor: pointer; font-size: .85rem; color: #334155; text-align: start;
}
.chat-menu-item:hover { background: #F1F5F9; }
.chat-menu-item i { width: 16px; text-align: center; color: #64748B; }

.chat-body { flex: 1; min-height: 0; display: flex; overflow: hidden; background: #F8FAFC; }
.chat-body > div { flex: 1; min-width: 0; overflow-y: auto; }

/* قائمة المحادثات */
.chat-list { padding: .3rem; }
.chat-row {
    width: 100%; display: flex; align-items: center; gap: .6rem; padding: .55rem .5rem; border: 0; background: transparent;
    border-radius: .7rem; cursor: pointer; text-align: start;
}
.chat-row:hover { background: #EEF6FC; }
.chat-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, #38BDF8, #0369A1); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem;
}
.chat-avatar.is-group { border-radius: .7rem; background: linear-gradient(135deg, #818CF8, #4F46E5); }
.chat-row-mid { flex: 1; min-width: 0; }
.chat-row-top { display: flex; align-items: baseline; gap: .5rem; }
.chat-row-title { font-weight: 700; font-size: .88rem; color: #0f172a; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-time { font-size: .68rem; color: #94A3B8; flex-shrink: 0; }
.chat-row-bot { display: flex; align-items: center; gap: .5rem; margin-top: .1rem; }
.chat-row-preview { flex: 1; min-width: 0; font-size: .78rem; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-badge {
    flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #0EA5E9; color: #fff;
    font-size: .68rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}

/* خيوط الرسائل */
.chat-thread { padding: .6rem .7rem; display: flex; flex-direction: column; gap: .25rem; }
.chat-day { align-self: center; margin: .4rem 0; font-size: .68rem; font-weight: 700; color: #64748B; background: #E2E8F0; padding: .15rem .7rem; border-radius: 999px; }
.chat-sys { align-self: center; margin: .2rem 0; }
.chat-sys-pill { font-size: .72rem; color: #475569; background: #E9EEF5; padding: .2rem .7rem; border-radius: 999px; }
.chat-msg { display: flex; }
.chat-msg.mine { justify-content: flex-end; }
.chat-msg.theirs { justify-content: flex-start; }
.chat-bubble {
    max-width: 82%; padding: .45rem .6rem; border-radius: 1rem; font-size: .85rem; line-height: 1.5;
    box-shadow: 0 1px 1px rgba(2, 32, 60, .06); position: relative;
}
.chat-msg.theirs .chat-bubble { background: #fff; border: 1px solid #E7EDF3; border-start-start-radius: .3rem; }
.chat-msg.mine .chat-bubble { background: #DCF3FD; border: 1px solid #C3E9FA; border-start-end-radius: .3rem; }
.chat-bubble-sender { display: block; font-size: .72rem; font-weight: 800; color: #0369A1; margin-bottom: .1rem; }
.chat-text { white-space: pre-wrap; word-break: break-word; color: #0f172a; }
.chat-quote { border-inline-start: 3px solid #0EA5E9; background: rgba(14, 165, 233, .08); padding: .25rem .5rem; border-radius: .4rem; margin-bottom: .3rem; }
.chat-quote-name { display: block; font-size: .72rem; font-weight: 800; color: #0369A1; }
.chat-quote-text { display: block; font-size: .74rem; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; align-items: center; gap: .25rem; justify-content: flex-end; margin-top: .15rem; }
.chat-time { font-size: .64rem; color: #94A3B8; }
.chat-tick { font-size: .64rem; color: #94A3B8; }
.chat-tick.read { color: #0EA5E9; }

.chat-voice { display: flex; align-items: center; gap: .4rem; }
.chat-audio { height: 34px; max-width: 210px; }
.chat-voice-dur { font-size: .68rem; color: #64748B; }
.chat-image { display: block; max-width: 220px; border-radius: .6rem; overflow: hidden; }
.chat-image img { display: block; width: 100%; height: auto; max-height: 240px; object-fit: cover; }
.chat-file { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: inherit; padding: .2rem 0; }
.chat-file-ic { width: 34px; height: 34px; border-radius: .5rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-file-mid { flex: 1; min-width: 0; }
.chat-file-name { display: block; font-size: .8rem; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.chat-file-size { display: block; font-size: .68rem; color: #94A3B8; }
.chat-file > i { color: #94A3B8; }

.chat-loadmore { align-self: center; margin: .3rem 0; font-size: .75rem; color: #0369A1; background: #E0F2FE; border: 0; padding: .3rem .9rem; border-radius: 999px; cursor: pointer; }
.chat-loading { text-align: center; color: #94A3B8; padding: 1rem; letter-spacing: .2em; }
.chat-empty, .chat-empty-thread { text-align: center; color: #94A3B8; padding: 2rem 1rem; }
.chat-empty i { font-size: 2rem; color: #CBD5E1; margin-bottom: .5rem; }
.chat-empty-t { font-weight: 700; color: #64748B; }
.chat-empty-h { font-size: .78rem; margin-top: .2rem; }

/* الملحّن */
.chat-composer { flex-shrink: 0; border-top: 1px solid #E7EDF3; background: #fff; padding: .4rem .5rem; }
.chat-composer-row { display: flex; align-items: flex-end; gap: .3rem; }
.chat-composer-row textarea {
    flex: 1; resize: none; border: 1px solid #E2E8F0; border-radius: 1rem; padding: .5rem .8rem; font: inherit; font-size: .85rem;
    max-height: 120px; line-height: 1.4; background: #F8FAFC;
}
.chat-composer-row textarea:focus { outline: none; border-color: #7DD3FC; background: #fff; }
.chat-composer-row button {
    width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: #64748B; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s, color .15s;
}
.chat-composer-row button:hover { background: #F1F5F9; color: #0369A1; }
#chatSendBtn { background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff; }
#chatSendBtn:hover { color: #fff; filter: brightness(1.05); }
#chatSendBtn:disabled { opacity: .5; cursor: default; filter: none; }

/* لوحة الرموز التعبيرية */
.chat-emoji-panel {
    display: flex; flex-wrap: wrap; gap: .1rem; max-height: 180px; overflow-y: auto;
    padding: .4rem; margin-bottom: .35rem; background: #F8FAFC; border: 1px solid #E7EDF3; border-radius: .7rem;
}
.chat-emoji {
    width: 34px; height: 34px; border: 0; background: transparent; border-radius: .5rem; cursor: pointer;
    font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.chat-emoji:hover { background: #E2E8F0; }

.chat-reply-bar, .chat-attach-preview { display: flex; align-items: center; gap: .4rem; padding: .35rem .4rem; margin-bottom: .3rem; background: #F1F5F9; border-radius: .6rem; }
.chat-reply-box { flex: 1; min-width: 0; border-inline-start: 3px solid #0EA5E9; padding-inline-start: .5rem; }
.chat-reply-name { display: block; font-size: .72rem; font-weight: 800; color: #0369A1; }
.chat-reply-text { display: block; font-size: .74rem; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-x, .chat-chip-x { border: 0; background: transparent; color: #94A3B8; cursor: pointer; }
.chat-attach-preview { flex-wrap: wrap; }
.chat-chip { display: inline-flex; align-items: center; gap: .35rem; background: #fff; border: 1px solid #E2E8F0; border-radius: 999px; padding: .2rem .5rem; font-size: .74rem; color: #334155; }
.chat-chip-name { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-record-bar { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem; }
.chat-record-bar button { width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat-record-bar > button:first-child { background: #F1F5F9; color: #EF4444; }
.chat-rec-send { background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff; }
.chat-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #EF4444; animation: chatRecPulse 1s infinite; }
.chat-rec-time { font-variant-numeric: tabular-nums; font-weight: 700; color: #0f172a; }
.chat-rec-label { flex: 1; font-size: .8rem; color: #64748B; }
@keyframes chatRecPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* اختيار الأشخاص / نموذج المجموعة */
.chat-pane { padding: .4rem; display: flex; flex-direction: column; }
.chat-search { display: flex; align-items: center; gap: .5rem; background: #F1F5F9; border-radius: .7rem; padding: .4rem .7rem; margin-bottom: .4rem; }
.chat-search i { color: #94A3B8; font-size: .8rem; }
.chat-search-inp { flex: 1; border: 0; background: transparent; font: inherit; font-size: .85rem; outline: none; }
.chat-people { display: flex; flex-direction: column; gap: .1rem; }
.chat-person { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border: 0; background: transparent; border-radius: .6rem; cursor: pointer; text-align: start; width: 100%; }
.chat-person:hover { background: #EEF6FC; }
.chat-person-mid { flex: 1; min-width: 0; }
.chat-person-name { display: block; font-size: .85rem; font-weight: 600; color: #0f172a; }
.chat-person-dept { display: block; font-size: .72rem; color: #94A3B8; }
.chat-person-check .chat-avatar { width: 36px; height: 36px; font-size: .85rem; }
.chat-cb { width: 18px; height: 18px; accent-color: #0EA5E9; flex-shrink: 0; }
.chat-group-name { margin-bottom: .4rem; }
.chat-input-line { width: 100%; border: 1px solid #E2E8F0; border-radius: .7rem; padding: .55rem .8rem; font: inherit; font-size: .9rem; outline: none; }
.chat-input-line:focus { border-color: #7DD3FC; }
.chat-group-foot { padding-top: .5rem; position: sticky; bottom: 0; background: #F8FAFC; }
.chat-btn-primary { width: 100%; padding: .6rem; border: 0; border-radius: .7rem; background: linear-gradient(135deg, #0EA5E9, #0369A1); color: #fff; font-weight: 800; cursor: pointer; }
.chat-btn-primary:hover { filter: brightness(1.05); }

/* البالون */
.chat-balloon {
    position: fixed; bottom: 5.2rem; inset-inline-start: 1rem; z-index: 118; max-width: 320px;
    display: flex; align-items: flex-start; gap: .6rem; text-align: start;
    background: #fff; border: 1px solid #E2E8F0; border-radius: .9rem; box-shadow: 0 16px 36px -10px rgba(2, 32, 60, .3);
    padding: .7rem .8rem; cursor: pointer; animation: chatBalloonIn .25s ease-out;
}
.chat-balloon-ic { width: 34px; height: 34px; border-radius: 50%; background: #E0F2FE; color: #0369A1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-balloon-body { flex: 1; min-width: 0; }
.chat-balloon-body strong { display: block; font-size: .82rem; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-balloon-body span { display: block; font-size: .78rem; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-balloon-close { color: #CBD5E1; flex-shrink: 0; }
.chat-balloon-close:hover { color: #64748B; }
@keyframes chatBalloonIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* الوضع المطويّ: النافذة تلتصق بجانب الشريط المطويّ (76px) لا تغطّيه */
.sidebar-collapsed .chat-widget { inset-inline-start: calc(76px + 1rem); max-width: calc(100vw - 76px - 2rem); }
/* البالون بجانب الأيقونة أسفل الشريط */
.chat-balloon { inset-inline-start: calc(260px + 1rem); }
.sidebar-collapsed .chat-balloon { inset-inline-start: calc(76px + 1rem); }

@media (max-width: 640px) {
    /* على الجوال الشريط الجانبي متراكب/مخفيّ — النافذة تملأ العرض */
    .chat-widget, .sidebar-collapsed .chat-widget { inset-inline: .5rem; bottom: .5rem; width: auto; max-width: none; height: calc(100vh - 1rem); max-height: none; }
    .chat-balloon, .sidebar-collapsed .chat-balloon { inset-inline: .5rem; max-width: none; }
}

/* ══════════ مُنتقي المعاملة المرتبطة بمهمة (C09) ══════════ */
/* [hidden] ينهزم أمام أيّ display مُصرَّح بنفس الأولوية (.badge/.trx-picked) فيظهر المخفيّ — يُحسَم هنا
   مرّةً واحدة **داخل المُنتقي وحده**: لا قاعدةَ !important عامّة (فخُّ الودجت الذي أخفى نصفَ الواجهة). */
.trx-picker [hidden] { display: none !important; }
.trx-picked { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1.5px solid #BAE6FD; background: #F0F9FF; border-radius: 12px; }
.trx-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #475569; cursor: pointer; }
.trx-list { margin-top: 10px; border: 1.5px solid #E2E8F0; border-radius: 12px; max-height: 240px; overflow-y: auto; background: #fff; }
.trx-list:empty { display: none; }
.trx-item { display: block; width: 100%; text-align: start; padding: 9px 12px; border-bottom: 1px solid #F1F5F9; cursor: pointer; transition: background .15s; background: transparent; }
.trx-item:last-child { border-bottom: 0; }
.trx-item:hover, .trx-item.active { background: #F0F9FF; }
.trx-item[aria-selected="true"] { background: #E0F2FE; }
.trx-item-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 2px; }
.trx-item-subject { display: block; font-size: 13px; font-weight: 700; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx-item-meta { display: block; font-size: 11px; color: #94A3B8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx-state { padding: 14px; text-align: center; font-size: 12.5px; color: #94A3B8; }

/* ══════════ مُنتقي معاملات كشف التسليم (اختيارٌ متعدّد) ══════════ */
/* يرث قاعدةَ [hidden] وأنماطَ الصفّ من .trx-picker أعلاه (الجذرُ يحمل الصنفين) — هنا فروقُ التعدّد فقط. */
.dpick-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dpick-list { max-height: 320px; }
.dpick-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #F1F5F9; cursor: pointer; transition: background .15s; }
.dpick-row:last-child { border-bottom: 0; }
.dpick-row:hover { background: #F8FAFC; }
.dpick-row.is-picked { background: #F0F9FF; }
.dpick-basket { margin-top: 10px; padding: 10px 12px; border: 1.5px solid #BAE6FD; background: #F0F9FF; border-radius: 12px; }
.dpick-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; border: 1px solid #BAE6FD; background: #fff; font-size: 11px; font-weight: 700; color: #0369A1; font-family: inherit; cursor: pointer; }
.dpick-chip:hover { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
