/* =====================================================================
   مدار ERP — نظام الواجهة (Swiss / SaaS)
   المرجع الكامل: DESIGN.md بجذر المشروع. هذا الملف هو المصدر الوحيد للتوكنز
   والمكوّنات؛ الشاشات تستعمل المتغيّرات أدناه ولا تكتب ألواناً خاماً.

   المبدأ: محايد، دقيق، كثيف. سطح أبيض بحد شعري، لون واحد للإجراء،
   والحالة نقطة ملوّنة + كلمة. لا تدرّجات، لا زجاج، لا مربعات أيقونات ملوّنة.
   ===================================================================== */

:root {
    /* ---- الخط ---- */
    --font-sans: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;   /* Cairo للعربي واللاتيني (طلب صاحب الشغل، 2026-10-07) */
    /* المبالغ والمعرّفات: نفس Cairo بخانات متساوية (tabular-nums في قواعدها)، عشان النظام كله بخط واحد */
    --font-mono: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

    /* ---- الأسطح ---- */
    --bg: #F6F7F9;            /* الصفحة */
    --surface: #FFFFFF;        /* اللوحات */
    --surface-subtle: #F9FAFB; /* رؤوس الجداول والمناطق الهادئة */
    --surface-hover: #F3F4F6;
    --sidebar: #FBFBFC;

    /* ---- النص (على الأبيض) ---- */
    --text: #101828;           /* 17.8:1 */
    --text-secondary: #475467; /* 7.6:1 */
    --text-tertiary: #667085;  /* 4.8:1 — أصغر نص مسموح */
    --text-placeholder: #98A2B3;

    /* ---- الحدود ---- */
    --border: #E4E7EC;
    --border-strong: #D0D5DD;
    --border-input: #CDD3DD;

    /* ---- العلامة: لون واحد للإجراء والموضع النشط والتركيز ---- */
    --primary: #0066FF;        /* أبيض عليه 4.83:1 */
    --primary-hover: #0057D9;
    --primary-active: #004BBD;
    --primary-text: #0052CC;   /* نص أزرق على أبيض 6.8:1 */
    --primary-subtle: #EEF4FF;
    --ring: rgba(0, 102, 255, .18);
    --navy: #0B1E3D;
    --header-bg: #0B1E3D;     /* رأس التطبيق: كحلي الهوية */

    /* ---- الحالات: نص داكن + خلفية خافتة + نقطة ---- */
    --success: #067647;  --success-subtle: #ECFDF3;  --success-dot: #17B26A;
    --danger:  #B42318;  --danger-subtle:  #FEF3F2;  --danger-dot:  #F04438;
    --warning: #B54708;  --warning-subtle: #FFFAEB;  --warning-dot: #F79009;
    --info:    #175CD3;  --info-subtle:    #EFF8FF;  --info-dot:    #2E90FA;
    --neutral-dot: #98A2B3;

    /* ---- الشكل ---- */
    --radius-sm: 4px;
    --radius: 6px;          /* حقول وأزرار */
    --radius-lg: 10px;      /* لوحات */
    --radius-xl: 12px;      /* مودال */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-pop: 0 12px 24px -6px rgba(16, 24, 40, .14), 0 4px 8px -4px rgba(16, 24, 40, .06);

    --control-h: 36px;
    --control-h-sm: 30px;
    --row-h: 44px;
    /* القايمة الجانبية (2026-11-07، طلب محمد: «صغر القايمه دي شويه»): كانت ٢٤٨، والـ٤٠ بكسل راحوا لـ«تفاصيل العميل» في الشات (wa-chat.css --wdx-info-w) */
    --sidebar-w: 208px;
    --topbar-h: 56px;
    --page-pad: 28px;

    --t-fast: 120ms;
    --t-base: 180ms;

    /* ---- Bootstrap ---- */
    --bs-body-font-family: var(--font-sans);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
    --bs-primary: #0066FF; --bs-primary-rgb: 0, 102, 255;
    --bs-success-rgb: 6, 118, 71; --bs-danger-rgb: 180, 35, 24;
    --bs-warning-rgb: 181, 71, 8; --bs-info-rgb: 23, 92, 211;
    --bs-secondary-rgb: 102, 112, 133;
    --bs-link-color: #0052CC; --bs-link-hover-color: #004BBD;
    --bs-link-color-rgb: 0, 82, 204; --bs-link-hover-color-rgb: 0, 75, 189;

    /* ---- أسماء قديمة تستعملها الشاشات — تُقرأ من التوكنز الجديدة ---- */
    --surface-0: var(--bg); --surface-1: var(--surface); --surface-2: var(--surface-subtle); --surface-3: var(--surface-hover);
    --text-1: var(--text); --text-2: var(--text-secondary); --text-3: var(--text-tertiary);
    --line: var(--border); --line-strong: var(--border-strong); --line-input: var(--border-input); --line-2: #F2F4F7;
    --brand: var(--primary); --brand-ink: var(--primary-text); --brand-dark: var(--primary-active);
    --brand-tint: var(--primary-subtle); --brand-tint-2: #D1E0FF; --dark: #0A0F17;
    --ok: var(--success); --ok-bg: var(--success-subtle);
    --bad: var(--danger); --bad-bg: var(--danger-subtle);
    --warn: var(--warning); --warn-bg: var(--warning-subtle);
    --info-bg: var(--info-subtle);
    --r-control: var(--radius); --r-panel: var(--radius-lg); --r-badge: var(--radius-sm);
    --blue: var(--primary); --blue-700: var(--primary-text); --blue-800: var(--primary-active);
    --blue-50: var(--primary-subtle); --blue-100: #D1E0FF; --blue-300: #528BFF;
    --bg-2: var(--surface-subtle); --card: var(--surface);
    --ink: var(--text); --ink-2: var(--text-secondary); --muted: var(--text-tertiary);
    --radius-md: var(--radius); --radius-sm-legacy: var(--radius-sm);
    --success-bg: var(--success-subtle); --danger-bg: var(--danger-subtle); --warning-bg: var(--warning-subtle);
    --shadow: var(--shadow-sm); --shadow-lg: var(--shadow-pop);
    --beige: var(--bg); --beige-dark: var(--surface-subtle);
}

/* =====================================================================
   الأساس
   ===================================================================== */
* { font-family: var(--font-sans); }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
/* لا letter-spacing على العربي — يفكّك الحروف المتصلة */
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 600; letter-spacing: 0; line-height: 1.4; }
h4, .h4 { font-size: 18px; } h5, .h5 { font-size: 16px; } h6, .h6 { font-size: 15px; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { color: var(--primary-active); }
::selection { background: #D1E0FF; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
hr { border-color: var(--border); opacity: 1; }
.small, small { font-size: 13px; }
.fw-bold, b, strong { font-weight: 600 !important; }
.fw-semibold { font-weight: 600 !important; }
.fs-4 { font-size: 20px !important; } .fs-5 { font-size: 17px !important; } .fs-6 { font-size: 15px !important; }

/* المعرّفات والمبالغ: خط مثبّت العرض يتحاذى في الأعمدة */
.doc-id, .num, .money {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums;
    direction: ltr; unicode-bidi: isolate; display: inline-block;
}
td.doc-id, td.num, td.money, th.doc-id, th.num, th.money { display: table-cell; }
/* `* { font-family }` يقطع الوراثة؛ أبناء الرقم يرثون خطّه المثبّت */
.num *, .money *, .doc-id * { font-family: inherit; }
a.doc-id { color: var(--text); }
a.doc-id:hover { color: var(--primary-text); }
/* وحدة العملة بجانب مبلغ: معزولة اتجاهياً فلا تقلب ترتيب الرقم */
.unit { font-family: var(--font-sans); unicode-bidi: isolate; font-size: 12.5px; font-weight: 400; color: var(--text-tertiary); }
.brand-ink { color: var(--primary-text) !important; }
.brand-soft { background: var(--primary-subtle); border-color: #D1E0FF; color: var(--primary-text); }
.doc-id { font-size: 13.5px; font-weight: 500; color: var(--text-secondary); }
.money { font-weight: 500; }

.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }
.text-primary { color: var(--primary-text) !important; }
.text-secondary, .text-muted { color: var(--text-tertiary) !important; }
.text-dark, .text-body { color: var(--text) !important; }
.bg-light { background: var(--surface-subtle) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }

/* =====================================================================
   الشل: رأس كحلي بعرض الصفحة + سايدبار تحته + رأس الصفحة
   ===================================================================== */
.app-header {
    position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px; padding-inline: 12px 16px;
    background: var(--header-bg); color: #fff;
}
/* منطقة البداية بعرض السايدبار: الشعار يقف فوق القائمة تماماً */
.ah-start { display: flex; align-items: center; gap: 10px; flex: 0 0 calc(var(--sidebar-w) - 12px); min-width: 0; }
.ah-logo { display: inline-flex; align-items: center; border-radius: var(--radius-sm); }
.ah-logo img { height: 22px; width: auto; display: block; }
.ah-btn { width: 36px; height: 36px; flex: 0 0 36px; display: inline-flex; align-items: center; justify-content: center;
    position: relative; border: 0; border-radius: var(--radius); background: transparent;
    color: rgba(255, 255, 255, .78); font-size: 18px;
    transition: background var(--t-fast), color var(--t-fast); }
.ah-btn:hover, .ah-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .10); color: #fff; }
.app-header :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.ah-search { position: relative; flex: 1 1 auto; display: flex; align-items: center; max-width: 520px; margin-inline: auto; }
.ah-search > i { position: absolute; inset-inline-start: 12px; font-size: 16px; color: rgba(255, 255, 255, .55); pointer-events: none; }
.ah-search input { width: 100%; height: 36px; padding-inline: 38px 58px; font-size: 14px; color: #fff;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--radius);
    transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast); }
.ah-search input::placeholder { color: rgba(255, 255, 255, .55); }
.ah-search input:hover { background: rgba(255, 255, 255, .11); }
.ah-search input:focus { outline: 0; background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .45);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .12); }
.ah-search input::-webkit-search-cancel-button { filter: invert(1); opacity: .6; }
/* جوانب فعلية: kbd اتجاهه ltr فتنقلب عنده inset-inline */
html[dir="rtl"] .ah-search kbd { left: 8px; }
html:not([dir="rtl"]) .ah-search kbd { right: 8px; }
.ah-search kbd { position: absolute; font-family: var(--font-mono); font-size: 11px;
    color: rgba(255, 255, 255, .6); background: transparent; border: 1px solid rgba(255, 255, 255, .2);
    border-radius: var(--radius-sm); padding: 1px 6px; box-shadow: none; pointer-events: none; direction: ltr; }
.ah-search input:focus ~ kbd { display: none; }

.ah-end { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; margin-inline-start: auto; }
.notif-dot { position: absolute; top: 2px; inset-inline-end: 2px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--danger-dot); color: #fff; font-size: 10.5px; font-weight: 600;
    font-family: var(--font-mono); display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--header-bg); line-height: 1; }
/* «محتاج تصرّف» من غير جديد: نقطة صغيرة، مش رقم */
.notif-dot.is-quiet { min-width: 0; width: 10px; height: 10px; padding: 0; top: 7px; inset-inline-end: 7px; }
/* أيقونة «طالبين مكالمة» من غير حد مستني (partials/call-requests) */
.notif-dot[hidden] { display: none; }

/* ---- الإشعارات (2026-10-17، «غير شكل الاشعارات بطريقه احترافيه ومنظمه») ----
   لوحة من الجرس: «محتاج تصرّف» كروت بأعدادها، وتحتها اللي جه مقسوم بالأيام. السطر: صورة العميل بأول حرف وعلامة
   نوعه (أو أيقونة النوع)، الاسم ووقته، وتحته الكلام — رسايل العميل الواحد سطر واحد بعددها. الجديد اسمه أتقل ووقته
   أزرق بنقطة. نفس السطور في صفحة «كل الإشعارات» وفي الكارت اللي بيطلع في الركن. */
.nt-panel { width: 400px; max-width: calc(100vw - 16px); padding: 0; border-radius: 12px; overflow: hidden; background: var(--surface); }
.nt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; }
.nt-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.nt-new { font-size: 12.5px; font-weight: 600; color: var(--primary-text); background: var(--primary-subtle); padding: 2px 8px; border-radius: 10px; }
.nt-label { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--text-tertiary); }
.nt-ops { padding: 0 16px 14px; }
.nt-ops-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nt-op { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); text-decoration: none; transition: background var(--t-fast), border-color var(--t-fast); }
.nt-op:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.nt-op-n { font-size: 20px; font-weight: 700; line-height: 1.25; }
.nt-op-l { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
.nt-op-l::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-dot); }
.nt-op.is-danger .nt-op-l::before { background: var(--danger-dot); }
.nt-op.is-warning .nt-op-l::before { background: var(--warning-dot); }
.nt-op.is-info .nt-op-l::before { background: var(--info-dot); }
.nt-feed { max-height: min(54vh, 460px); overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--border); }
.nt-day { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 16px 6px; background: var(--surface);
    font-size: 12px; font-weight: 700; color: var(--text-tertiary); }
.nt-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 16px; color: var(--text); text-decoration: none;
    transition: background var(--t-fast); }
.nt-item:hover, .nt-item:focus-visible { background: var(--surface-hover); color: var(--text); }
.nt-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nt-av { position: relative; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: #EEF1F5; color: var(--text-secondary); font-size: 15px; font-weight: 700; }
.nt-av.is-icon i { font-size: 17px; }
.nt-kind { position: absolute; bottom: -3px; inset-inline-end: -3px; width: 19px; height: 19px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; background: var(--surface); box-shadow: 0 0 0 2px var(--surface); font-size: 12px; }
.k-message { color: #1DA851; }
.k-assigned { color: var(--primary); }
.k-meeting, .k-followup, .k-quote, .k-silent { color: var(--warning); }
.k-waiting, .k-hot { color: var(--danger); }
.k-renewal { color: var(--info); }
.k-deal, .k-ring { color: var(--success); }
.nt-body { flex: 1 1 auto; min-width: 0; }
/* «اتصل» من السنترال (partials/pbx-dial، وراس المحادثة في «الشات»)، والرد عليه في ركن الإشعارات (js/pbx-dial.js) */
.pbx-dial { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 24px; margin-inline-start: 8px; padding: 0 10px;
    border: 0; border-radius: 999px; background: var(--success-subtle); color: var(--success-text, var(--success)); font: inherit; font-size: 12.5px;
    font-weight: 600; line-height: 1; vertical-align: middle; cursor: pointer; white-space: nowrap; }
.pbx-dial:hover { filter: brightness(.96); }
.pbx-dial:disabled { opacity: .55; cursor: default; }
.pbx-dial.is-icon { width: 24px; padding: 0; margin-inline-start: 0; font-size: 11px; }
.wdx-head-num { display: inline-flex; align-items: center; gap: 6px; }
/* زرار شباك «التليفون» فوق: النقطة خضرا وهو مفتوح */
.pbx-phone-btn { position: relative; }
.pbx-phone-dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--neutral-dot, #98A2B3);
    box-shadow: 0 0 0 2px var(--header-bg, #0B1736); }
.pbx-phone-dot.is-on { background: var(--success-dot, #12B76A); }
.pbx-toast { align-items: center; cursor: default; }
.pbx-toast > i { flex: none; font-size: 18px; color: var(--success); }
.pbx-toast.is-bad > i { color: var(--danger); }
.nt-line { display: flex; align-items: baseline; gap: 10px; }
.nt-name { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt-time { flex: none; font-size: 12px; color: var(--text-tertiary); }
.nt-item.is-new .nt-name { font-weight: 700; }
.nt-item.is-new .nt-time { color: var(--primary-text); font-weight: 600; }
.nt-item.is-new .nt-time::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-inline-end: 6px; border-radius: 50%;
    background: var(--primary); vertical-align: 1px; }
.nt-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px;
    font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.nt-count { display: inline-block; margin-inline-end: 6px; padding: 0 7px; border-radius: 9px; background: #EEF1F5;
    font-size: 11.5px; font-weight: 700; color: var(--text-secondary); }
.nt-empty { margin: 0; padding: 28px 16px; text-align: center; font-size: 13.5px; color: var(--text-tertiary); }
.nt-foot { display: block; padding: 11px 16px; border-top: 1px solid var(--border); background: var(--surface-subtle);
    text-align: center; font-size: 13.5px; font-weight: 600; color: var(--primary-text); text-decoration: none; }
.nt-foot:hover { background: var(--surface-hover); color: var(--primary-text); }
/* لافتة الوقعة (OutageWatch): فوق كل صفحة للمديرين طول ما الرقم أو الجهاز أو البوت واقع */
.outage-bar { display: flex; align-items: flex-start; gap: 10px; margin: 14px var(--page-pad) 0; padding: 10px 14px;
    border: 1px solid #FECDCA; border-radius: 10px; background: var(--danger-subtle); color: var(--danger); font-size: 14px; line-height: 1.6; }
.outage-bar > i { margin-top: 3px; font-size: 16px; }
.outage-bar b { font-weight: 700; margin-inline-end: 6px; }
.outage-bar span { color: #7A271A; }
@media (max-width: 575.98px) { .outage-bar { margin-inline: 12px; } }
/* تنبيه للكل (wa_send_down): كهرماني، وزرار «افتح واتساب الجهاز» على جنب */
.outage-bar.is-notice { align-items: center; border-color: #FEDF89; background: var(--warning-subtle); color: var(--warning); }
.outage-bar.is-notice span { color: #93370D; }
.outage-bar .btn { flex: none; margin-inline-start: auto; }
.k-outage, .k-call { color: var(--danger); }
/* الموبايل: اللوحة تحت الرأس بعرض الشاشة */
@media (max-width: 575.98px) {
    .nt-panel { position: fixed !important; inset: calc(var(--topbar-h) + 6px) 8px auto 8px !important; transform: none !important;
        width: auto; max-width: none; }
    .nt-feed { max-height: calc(100dvh - var(--topbar-h) - 260px); }
}

.user-chip { display: flex; align-items: center; gap: 8px; height: 40px; padding-inline: 6px 8px; border: 0;
    border-radius: var(--radius); background: transparent; color: #fff; cursor: pointer; transition: background var(--t-fast); }
.user-chip:hover, .user-chip[aria-expanded="true"] { background: rgba(255, 255, 255, .10); }
.user-chip .avatar { width: 28px; height: 28px; min-width: 28px; border-radius: 50%; overflow: hidden;
    background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; font-size: 12.5px;
    display: inline-flex; align-items: center; justify-content: center; }
.user-chip .avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-chip .uinfo { flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-chip .uname { font-weight: 600; font-size: 13.5px; color: #fff; }
.user-chip .urole { font-size: 12px; color: rgba(255, 255, 255, .62); }
.user-chip .chev { font-size: 14px; color: rgba(255, 255, 255, .55); }

/* زر أيقوني محايد داخل المحتوى */
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    position: relative; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-secondary);
    font-size: 16px; transition: background var(--t-fast), color var(--t-fast); }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ---- السايدبار (2026-10-17، «غير التصميم بتاع القايمه كلها بتصميم احترافي») ----
   كحلي الهوية زي الرأس (اختيار محمد بين الكحلي والفاتح): الاتنين إطار واحد حوالين المحتوى، والمحتوى لوحة فاتحة
   ركنها اللي جوّه الإطار مدوّر. عنصر 36px بأيقونة خطّية واسم؛ النشط خلفيته أفتح ومعاه شَرطة زرقا على حافة القايمة
   اللي جنب الشاشة؛ الأقسام بتتطوي بحركة قصيرة؛ والمجموعات جوّه القسم بتسمية وخط رفيع. الألوان متغيّرات --sb-*. */
.sidebar {
    --sb-bg: var(--navy);
    --sb-text: rgba(255, 255, 255, .78);
    --sb-text-hover: #FFFFFF;
    --sb-icon: rgba(255, 255, 255, .56);
    --sb-hover: rgba(255, 255, 255, .07);
    --sb-active-bg: rgba(255, 255, 255, .11);
    --sb-active-text: #FFFFFF;
    --sb-active-icon: #FFFFFF;
    --sb-bar: #5B9BFF;
    --sb-head: rgba(255, 255, 255, .52);
    --sb-sub: rgba(255, 255, 255, .40);
    --sb-line: rgba(255, 255, 255, .09);
    --sb-thumb: rgba(255, 255, 255, .20);
    --sb-focus: #FFFFFF;
    position: fixed; top: var(--topbar-h); bottom: 0; inset-inline-start: 0; z-index: 1025;
    width: var(--sidebar-w);
    background: var(--sb-bg);
    display: flex; flex-direction: column;
    transition: transform var(--t-base) ease-out;
}
.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; padding: 10px 12px 28px;
    scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidebar-scroll:hover { scrollbar-color: var(--sb-thumb) transparent; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar-scroll:hover::-webkit-scrollbar-thumb { background: var(--sb-thumb); }
.sidebar-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(16, 24, 40, .4); z-index: 1024; display: none; }

.sidebar .nav-link {
    position: relative;
    display: flex; align-items: center; gap: 11px; width: 100%;
    min-height: 36px; padding: 6px 10px; margin: 1px 0;
    border: 0; border-radius: 8px; background: none;
    color: var(--sb-text); font-size: 14px; font-weight: 500; line-height: 1.35; text-align: start;
    transition: background var(--t-fast), color var(--t-fast);
}
.sidebar .nav-link i { width: 18px; flex: 0 0 18px; text-align: center; font-size: 16px;
    color: var(--sb-icon); transition: color var(--t-fast); }
.sidebar .nav-link:hover { background: var(--sb-hover); color: var(--sb-text-hover); }
.sidebar .nav-link:hover i { color: var(--sb-text-hover); }
.sidebar .nav-link:active { background: var(--sb-active-bg); }
/* الموضع النشط: خلفية خافتة + شَرطة على الحافة اللي جنب الشاشة — لا كتلة ملوّنة */
.sidebar .nav-link.active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 600; }
.sidebar .nav-link.active i { color: var(--sb-active-icon); }
.sidebar .nav-link.active::before { content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px;
    border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--sb-bar); }
.sidebar .nav-link:focus-visible, .sidebar .nav-sec-head:focus-visible { outline: 2px solid var(--sb-focus); outline-offset: -2px; }

/* ركن المحتوى اللي جوّه الإطار مدوّر: ربع دايرة كحلي ثابتة فوق الركن (من غير ما المحتوى يتقص) */
@media (min-width: 992px) {
    html:not(.sb-collapsed) .main::before {
        content: ""; position: fixed; top: var(--topbar-h); inset-inline-start: var(--sidebar-w); z-index: 1020;
        width: 14px; height: 14px; pointer-events: none;
        background: radial-gradient(circle at 0 100%, transparent 13.5px, var(--navy) 14px);
    }
    html[dir="ltr"]:not(.sb-collapsed) .main::before { background: radial-gradient(circle at 100% 100%, transparent 13.5px, var(--navy) 14px); }
}

/* القسم: عنوان صغير يطوي ويفتح */
.nav-sec { margin-top: 18px; }
.nav-sec-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
    min-height: 28px; padding: 4px 10px; margin: 0 0 3px;
    border: 0; border-radius: 6px; background: none; cursor: pointer;
    color: var(--sb-head); font-size: 12px; font-weight: 700; text-align: start;
    transition: color var(--t-fast);
}
.nav-sec-head .lbl { display: flex; align-items: center; min-width: 0; }
.nav-sec-head .lbl > i { display: none; }
.nav-sec-head .chev { font-size: 12px; color: var(--sb-sub); opacity: 0; transition: transform var(--t-base) ease, opacity var(--t-fast); }
.nav-sec-head:hover { color: var(--sb-text-hover); }
.nav-sec-head:hover .chev, .nav-sec-head:focus-visible .chev, .nav-sec:not(.open) > .nav-sec-head .chev { opacity: 1; }
.nav-sec.open > .nav-sec-head .chev { transform: rotate(180deg); }
/* الطيّ بحركة قصيرة (الارتفاع من 0fr لـ1fr)، بعد ما الصفحة تفتح بس (.sb-ready) — مش مع كل تحميل */
.nav-sec-body { display: grid; grid-template-rows: 0fr; }
.nav-sec.open > .nav-sec-body { grid-template-rows: 1fr; }
.nav-sec-inner { overflow: hidden; min-height: 0; visibility: hidden; }
.nav-sec.open > .nav-sec-body > .nav-sec-inner { visibility: visible; }
.sidebar.sb-ready .nav-sec-body { transition: grid-template-rows var(--t-base) ease-out; }
.sidebar.sb-ready .nav-sec:not(.open) .nav-sec-inner { transition: visibility 0s var(--t-base); }
@media (prefers-reduced-motion: reduce) {
    .sidebar.sb-ready .nav-sec-body, .sidebar.sb-ready .nav-sec:not(.open) .nav-sec-inner, .nav-sec-head .chev { transition: none; }
}
/* مجموعة جوّه القسم (المبيعات: الشغل اليومي، البيع، التقارير، الإعدادات): تسمية أهدى وبعدها خط رفيع */
.nav-sub { display: flex; align-items: center; gap: 8px; padding: 12px 10px 4px; color: var(--sb-sub); font-size: 11.5px; font-weight: 600; }
.nav-sub::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--sb-line); }
.nav-sec-inner > .nav-sub:first-child { padding-top: 2px; }

/* ---- المحتوى ---- */
.main { margin-inline-start: var(--sidebar-w); min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column;
    transition: margin var(--t-base) ease-out; }
/* الموبايل: iPhone بيكبّر الصفحة لوحده لما تدوس على خانة كتابة خطها أقل من 16px، والشاشة بتتقص من الجنب — فكل الخانات 16px */
@media (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), textarea, select { font-size: 16px !important; }
}
.page { flex: 1 1 auto; width: 100%; max-width: 1600px; padding: 20px var(--page-pad) 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 20px; }
.page-head .ph-text { min-width: 0; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 4px;
    font-size: 13px; color: var(--text-tertiary); }
.crumbs a { color: var(--text-tertiary); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-placeholder); font-size: 12px; }
.page-title { font-size: 22px; font-weight: 600; line-height: 1.35; margin: 0; color: var(--text); }
.page-sub { font-size: 13.5px; color: var(--text-tertiary); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* طيّ السايدبار على سطح المكتب (زر القائمة في الرأس) */
@media (min-width: 992px) {
    html.sb-collapsed .sidebar { transform: translateX(100%); visibility: hidden; transition: transform var(--t-base) ease-out, visibility 0s var(--t-base); }
    html[dir="ltr"].sb-collapsed .sidebar { transform: translateX(-100%); }
    html.sb-collapsed .main { margin-inline-start: 0; }
}

/* ---- قائمة إجراءات الصف (⋯) — يبنيها public/js/madar-ui.js من أزرار الصف الأيقونية ---- */
.row-menu { display: inline-block; }
.row-menu-btn { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: var(--radius); background: transparent; color: var(--text-tertiary); font-size: 17px;
    transition: background var(--t-fast), color var(--t-fast); }
.row-menu-btn:hover, .row-menu-btn[aria-expanded="true"] { background: var(--surface-hover); color: var(--text); }
.row-menu .dropdown-menu { min-width: 168px; }
.row-menu .dropdown-menu form { display: block; margin: 0; }
.row-menu .dropdown-item { width: 100%; border: 0; background: none; text-align: start; font-size: 14px; font-weight: 400; }
.row-menu .dropdown-item i { font-size: 15px; }
.row-menu .dropdown-item.disabled, .row-menu .dropdown-item:disabled { color: var(--text-placeholder); pointer-events: none; }
/* الصف كلّه يفتح «عرض» */
tr.row-link { cursor: pointer; }

/* =====================================================================
   اللوحات
   ===================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs); --bs-card-spacer-x: 20px; --bs-card-spacer-y: 18px; }
.card > .card-body { padding: 18px 20px; }
.card h5, .card h6, .card .card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 20px;
    font-weight: 600; font-size: 15px; color: var(--text); }
.card-header:first-child { border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0; }
.card-footer { background: var(--surface-subtle); border-top: 1px solid var(--border); padding: 12px 20px; }

/* رأس لوحة: عنوان + إجراءات + فاصل */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px; border-bottom: 1px solid var(--border); min-height: 52px; }
.card-head h2, .card-head h3, .card-head h5, .card-head h6, .card-head .card-title { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .card-sub { font-size: 13px; color: var(--text-tertiary); }
.card-head a:not(.btn) { font-size: 13.5px; font-weight: 500; }

/* الجدول داخل اللوحة يمتد لحافتيها، والعمود الأول والأخير يحاذيان النص */
.card-body > .table-responsive, .card > .table-responsive { margin-inline: -20px; }
.card > .table-responsive { margin-inline: 0; }
.card-body > .table-responsive:last-child { margin-bottom: -18px; }
.card-body > .table-responsive:first-child { margin-top: -18px; }
.card-body > .table-responsive:first-child .table > thead > tr:first-child > th:first-child { border-start-start-radius: calc(var(--radius-lg) - 1px); }
.card-body > .table-responsive:first-child .table > thead > tr:first-child > th:last-child { border-start-end-radius: calc(var(--radius-lg) - 1px); }
/* جوانب فعلية لا منطقية: خلية .num اتجاهها ltr فيقع padding-inline على الجانب الخطأ */
html[dir="rtl"] .card .table > :not(caption) > * > *:first-child { padding-right: 20px; }
html[dir="rtl"] .card .table > :not(caption) > * > *:last-child { padding-left: 20px; }
html:not([dir="rtl"]) .card .table > :not(caption) > * > *:first-child { padding-left: 20px; }
html:not([dir="rtl"]) .card .table > :not(caption) > * > *:last-child { padding-right: 20px; }
.card-body > .table-responsive:not(:first-child) { border-top: 1px solid var(--border); }
.card-body > .table-responsive + .pagination, .card-body > .table-responsive + nav { margin-top: 18px; }

/* المؤشر: تسمية فوق رقم، بلا أيقونة ملوّنة ولا شريط — اللون للحالة فقط */
.statcard, .metric { display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs); padding: 16px 18px; height: 100%; min-width: 0; position: relative; }
.statcard::before { display: none; }
.statcard .sc-ic { display: none; }
.statcard > :last-child { display: flex; flex-direction: column-reverse; gap: 6px; min-width: 0; }
.statcard .sc-l, .m-label { display: flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 500; color: var(--text-tertiary); line-height: 1.4; }
.statcard .sc-v, .m-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
    font-size: 22px; font-weight: 600; line-height: 1.2; color: var(--text); direction: ltr; text-align: end;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-foot { font-size: 12.5px; color: var(--text-tertiary); }
.metric-strip .m-value { margin-top: auto; }
/* النقطة تحمل دلالة البطاقة بدل مربع الأيقونة */
.statcard .sc-l::before { content: ''; display: inline-block; vertical-align: middle; margin-inline-end: 7px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--neutral-dot); flex: 0 0 6px; }
.sc-primary .sc-l::before { background: var(--primary); }
.sc-info .sc-l::before { background: var(--info-dot); }
.sc-success .sc-l::before { background: var(--success-dot); }
.sc-danger .sc-l::before { background: var(--danger-dot); }
.sc-warning .sc-l::before { background: var(--warning-dot); }
.sc-danger .sc-v { color: var(--danger); }
.statcard .sc-v + .sc-l, .statcard .sc-l + .sc-v { margin: 0; }

/* شريط مؤشرات متصل: خلايا مفصولة بخط داخل لوحة واحدة */
.metric-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs); overflow: hidden; }
/* كل خلية تحمل حدّها العلوي وحدّ بدايتها، وتُزاح بكسل للخارج فتُقصّ حدود الحافة —
   فواصل صحيحة مهما التفّت الشبكة، بلا فجوات رمادية في آخر صف */
.metric-strip > * { padding: 16px 18px; border-inline-start: 1px solid var(--border); margin-inline-start: -1px;
    border-top: 1px solid var(--border); margin-top: -1px;
    display: flex; flex-direction: column; gap: 6px; color: var(--text); min-width: 0; }
.metric-strip > a { transition: background var(--t-fast); }
.metric-strip > a:hover { background: var(--surface-subtle); color: var(--text); }

.stat-box { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; height: 100%; background: var(--surface); }
.stat-box .sl { font-size: 13px; color: var(--text-tertiary); }
.stat-box .sv { font-size: 20px; font-weight: 600; line-height: 1.3; color: var(--text);
    font-family: var(--font-mono); font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
.stat-box.accent { background: var(--primary-subtle); border-color: #D1E0FF; }

.entity-avatar { width: 44px; height: 44px; min-width: 44px; border-radius: var(--radius-lg);
    background: var(--surface-subtle); border: 1px solid var(--border); color: var(--text-secondary);
    display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }

/* مفتاح–قيمة */
.info-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
@media (max-width: 700px) { .info-list { grid-template-columns: 1fr; } }
.info-list .il { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-list .il .k { color: var(--text-tertiary); font-size: 14px; }
.info-list .il .v { font-weight: 500; text-align: end; color: var(--text); font-size: 14px; }
.info-list .il:last-child { border-bottom: 0; }
.info-list.one-col { grid-template-columns: 1fr; }
.info-list .il.wide { grid-column: 1 / -1; flex-direction: column; gap: 4px; }
.info-list .il.wide .v { text-align: start; font-weight: 400; white-space: pre-line; }
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--text-tertiary); font-weight: 400; }
.kv dd { margin: 0; color: var(--text); font-weight: 500; }

/* =====================================================================
   شريط الفلاتر
   ===================================================================== */
.filter-bar { background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; }
.filter-bar .form-label { font-size: 12.5px; color: var(--text-tertiary); font-weight: 500; margin-bottom: 4px; }
.filter-bar .form-control, .filter-bar .form-select { font-size: 14px; }
.filter-bar .filter-actions { display: flex; gap: 8px; }

/* =====================================================================
   الأزرار
   ===================================================================== */
.btn { --bs-btn-font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--control-h); padding: 6px 14px; font-size: 14px; font-weight: 500; line-height: 1.3;
    border-radius: var(--radius); border: 1px solid transparent; box-shadow: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.btn i { font-size: 16px; }
.btn-sm i { font-size: 15px; }
.btn > i.ms-1, .btn > i.ms-2, .btn > i.me-1, .btn > i.me-2 { margin: 0 !important; }
.btn-sm { min-height: var(--control-h-sm); padding: 4px 10px; font-size: 13.5px; }
.btn-lg { min-height: 42px; padding: 8px 18px; font-size: 15px; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: none; }

.btn-primary, .btn-brand { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover, .btn-brand:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:active, .btn-brand:active, .btn-primary.active { background: var(--primary-active) !important; border-color: var(--primary-active) !important; color: #fff !important; }
.btn-light, .btn-secondary, .btn-outline-secondary, .btn-outline-primary, .btn-outline-dark, .btn-outline-info, .btn-outline-success, .btn-outline-warning {
    background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-light:hover, .btn-secondary:hover, .btn-outline-secondary:hover, .btn-outline-primary:hover,
.btn-outline-dark:hover, .btn-outline-info:hover, .btn-outline-success:hover, .btn-outline-warning:hover {
    background: var(--surface-subtle); border-color: var(--border-strong); color: var(--text); }
.btn-light:active, .btn-secondary:active, .btn-outline-secondary:active, .btn-outline-primary:active {
    background: var(--surface-hover) !important; border-color: var(--border-strong) !important; color: var(--text) !important; }
.btn-outline-primary { color: var(--primary-text); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #05603A; border-color: #05603A; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; border-color: #912018; color: #fff; }
.btn-outline-danger { background: var(--surface); border-color: var(--border-strong); color: var(--danger); box-shadow: var(--shadow-xs); }
.btn-outline-danger:hover { background: var(--danger-subtle); border-color: #FECDCA; color: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-link { color: var(--primary-text); text-decoration: none; padding-inline: 4px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-check:checked + .btn, .btn.active { background: #EDEFF3; border-color: var(--border-strong); color: var(--text); }
.btn-close { width: .7em; height: .7em; opacity: .5; }

/* إجراءات الصف: أيقونات شبحية لا أزرار محدّدة — الصف يبقى هادئاً */
.table td:not([colspan]) .btn.btn-sm:is(.btn-outline-secondary, .btn-outline-primary, .btn-outline-danger, .btn-light):is([aria-label], [title]),
.row-list .btn.btn-sm:is(.btn-outline-secondary, .btn-outline-primary, .btn-outline-danger, .btn-light):is([aria-label], [title]) {
    min-height: 28px; min-width: 28px; padding: 4px 7px; border-color: transparent; background: transparent;
    box-shadow: none; color: var(--text-tertiary); line-height: 1; }
.table td:not([colspan]) .btn.btn-sm:is(.btn-outline-secondary, .btn-outline-primary, .btn-light):is([aria-label], [title]):hover,
.row-list .btn.btn-sm:is(.btn-outline-secondary, .btn-outline-primary, .btn-light):is([aria-label], [title]):hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }
.table td:not([colspan]) .btn.btn-sm.btn-outline-danger:is([aria-label], [title]):hover,
.row-list .btn.btn-sm.btn-outline-danger:is([aria-label], [title]):hover { background: var(--danger-subtle); color: var(--danger); border-color: transparent; }
.table td .btn.btn-sm:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.table td .d-inline + .btn, .table td .btn + .btn, .table td .btn + .d-inline, .table td .d-inline + .d-inline { margin-inline-start: 2px; }

/* =====================================================================
   الجداول
   ===================================================================== */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--surface-subtle); --bs-table-striped-bg: var(--surface-subtle);
    color: var(--text); margin-bottom: 0; font-size: 14px; }
.table > thead th, .table-light > tr > th, thead.table-light th, .table > thead.table-light > tr > th {
    background: var(--surface-subtle); color: var(--text-tertiary); font-weight: 500; font-size: 12.5px;
    border-bottom: 1px solid var(--border); padding: 9px 12px; white-space: nowrap; vertical-align: middle;
    position: sticky; top: 0; z-index: 2; }
.table > tbody > tr > td { padding: 10px 12px; height: var(--row-h); vertical-align: middle;
    border-bottom: 1px solid var(--border); }
.table-sm > tbody > tr > td { padding: 7px 12px; height: 38px; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-subtle); }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table td.num, .table th.num, .table td .money { text-align: end; }
/* رأس عمود رقمي نصٌّ عربي: خط النص واتجاهه، ويحاذي حافة الأرقام تحته */
.table th.num { font-family: var(--font-sans); direction: rtl; unicode-bidi: plaintext; text-align: right; }
html:not([dir="rtl"]) .table th.num { direction: ltr; }
.table td.num, .table td .num, .table td.doc-id, .table td .doc-id, .table td .money { white-space: nowrap; }
.table tfoot td, .table tfoot th { background: var(--surface-subtle); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; padding: 10px 12px; }
.table-bordered > :not(caption) > * > * { border-color: var(--border); }
.table-warning { --bs-table-bg: var(--warning-subtle); --bs-table-color: var(--text); }
.table-danger  { --bs-table-bg: var(--danger-subtle);  --bs-table-color: var(--text); }
.table-success { --bs-table-bg: var(--success-subtle); --bs-table-color: var(--text); }
.table-info    { --bs-table-bg: var(--info-subtle);    --bs-table-color: var(--text); }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* الصف الفارغ */
.table td[colspan].text-center { height: auto; padding: 32px 16px; color: var(--text-tertiary); }
.table td > i:is(.fa-solid, .fa-regular, .fa) { vertical-align: middle; }

/* =====================================================================
   الشارات — نقطة + كلمة على سطح محايد
   ===================================================================== */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
    line-height: 1.4; padding: 2px 8px; border-radius: var(--radius); white-space: nowrap;
    background: var(--surface) !important; color: var(--text-secondary) !important;
    border: 1px solid var(--border); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--neutral-dot); flex: 0 0 6px; }
.badge.text-bg-success::before, .badge.bg-success::before { background: var(--success-dot); }
.badge.text-bg-danger::before,  .badge.bg-danger::before  { background: var(--danger-dot); }
.badge.text-bg-warning::before, .badge.bg-warning::before { background: var(--warning-dot); }
.badge.text-bg-info::before,    .badge.bg-info::before    { background: var(--info-dot); }
.badge.text-bg-primary::before, .badge.bg-primary::before { background: var(--primary); }
.badge.text-bg-dark::before,    .badge.bg-dark::before    { background: var(--text); }
.badge.rounded-pill { border-radius: 999px; }
/* عدّاد رقمي داخل زر/قائمة: بلا نقطة */
.badge.cpill, .badge.count, .nav-link .badge, .dropdown-item .badge { gap: 0; font-family: var(--font-mono); padding: 1px 7px; }
.badge.cpill::before, .badge.count::before, .nav-link .badge::before, .dropdown-item .badge::before { display: none; }
.cpill { color: var(--text) !important; background: var(--surface-hover) !important; border-color: transparent !important; font-weight: 600; }
.cpill.danger { color: var(--danger) !important; background: var(--danger-subtle) !important; }
.cpill.warning { color: var(--warning) !important; background: var(--warning-subtle) !important; }
.cpill.info { color: var(--info) !important; background: var(--info-subtle) !important; }
.cpill.success { color: var(--success) !important; background: var(--success-subtle) !important; }
.cpill.primary { color: var(--primary-text) !important; background: var(--primary-subtle) !important; }

/* =====================================================================
   النماذج
   ===================================================================== */
.form-label { font-size: 13.5px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-control, .form-select {
    min-height: var(--control-h); padding: 6px 12px; font-size: 14px; color: var(--text);
    background-color: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius);
    box-shadow: var(--shadow-xs); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
html[dir="rtl"] .form-select { padding-left: 34px; padding-right: 12px; background-position: left 10px center; }
html:not([dir="rtl"]) .form-select { padding-right: 34px; padding-left: 12px; background-position: right 10px center; }
.form-control::placeholder { color: var(--text-placeholder); }
.form-control:hover, .form-select:hover { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); outline: 0; }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--surface-subtle); color: var(--text-secondary); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger-dot); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(240, 68, 56, .16); }
.invalid-feedback { font-size: 13px; color: var(--danger); }
.form-control-sm, .form-select-sm { min-height: var(--control-h-sm); font-size: 13.5px; padding-block: 3px; }
textarea.form-control { min-height: 84px; line-height: 1.6; }
.form-control[type="file"] { padding: 4px 6px; }
.form-control[type="file"]::file-selector-button { font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 3px 10px; margin-inline-end: 10px; box-shadow: var(--shadow-xs); cursor: pointer; }
.form-control[type="file"]::file-selector-button:hover { background: var(--surface-subtle); }
.form-text { font-size: 12.5px; color: var(--text-tertiary); margin-top: 4px; }
.form-check-input { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.form-check-label { font-size: 14px; color: var(--text); }
.input-group-text { background: var(--surface-subtle); border-color: var(--border-input); color: var(--text-secondary); font-size: 14px; border-radius: var(--radius); }
input[type=number] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: end; }
/* قسم داخل نموذج طويل */
.form-section { padding: 20px 0; border-top: 1px solid var(--border); }
.form-section:first-child, .form-section:not(.form-section ~ .form-section) { border-top: 0; padding-top: 0; }
/* أزرار آخر النموذج: الأساسي ثم «إلغاء» */
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.form-section-sub { font-size: 13px; color: var(--text-tertiary); margin-bottom: 14px; }

/* =====================================================================
   التبويب، الترقيم، التنبيهات، القوائم، المودال، شريط التقدّم
   ===================================================================== */
.nav-tabs { border-bottom: 1px solid var(--border); gap: 20px; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 2px;
    margin-bottom: -1px; color: var(--text-tertiary); font-size: 14px; font-weight: 500; background: none; }
.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.nav-tabs .nav-link.active { color: var(--text); border-bottom-color: var(--primary); background: none; }
.nav-pills .nav-link { color: var(--text-secondary); border-radius: var(--radius); font-size: 14px; font-weight: 500; padding: 6px 12px; }
.nav-pills .nav-link.active { background: #EDEFF3; color: var(--text); }

/* شريط مقاطع (segmented): روابط نطاق متجاورة */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-hover); border-radius: var(--radius); }
.segmented > a, .segmented > button { padding: 4px 12px; font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
    border: 0; background: none; border-radius: 4px; white-space: nowrap; }
.segmented > .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

.pagination { --bs-pagination-color: var(--text-secondary); --bs-pagination-hover-color: var(--text);
    --bs-pagination-hover-bg: var(--surface-hover); --bs-pagination-active-bg: var(--surface);
    --bs-pagination-active-color: var(--text); --bs-pagination-active-border-color: var(--border-strong);
    --bs-pagination-border-color: var(--border); --bs-pagination-disabled-color: var(--text-placeholder);
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--ring); gap: 4px; margin: 0; }
.page-link { min-width: 32px; height: 32px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius) !important; font-size: 13.5px; font-family: var(--font-mono); }
.page-item.active .page-link { font-weight: 600; box-shadow: var(--shadow-xs); }
nav .small.text-muted, .pagination + .small { font-size: 13px; }

.alert { display: block; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); font-size: 14px; padding: 12px 14px; }
.alert > i:first-child { margin-inline-end: 8px; }
/* تنبيه بأيقونة وكتلة نص: الأيقونة عمود والنص عمود */
.alert:has(> i:first-child + div) { display: flex; gap: 10px; align-items: flex-start; }
.alert:has(> i:first-child + div) > i:first-child { margin: 3px 0 0; }
.alert-success { border-color: #ABEFC6; background: var(--success-subtle); } .alert-success > i:first-child { color: var(--success-dot); }
.alert-danger  { border-color: #FECDCA; background: var(--danger-subtle); }  .alert-danger > i:first-child { color: var(--danger-dot); }
.alert-warning { border-color: #FEDF89; background: var(--warning-subtle); } .alert-warning > i:first-child { color: var(--warning-dot); }
.alert-info    { border-color: #B2DDFF; background: var(--info-subtle); }    .alert-info > i:first-child { color: var(--info-dot); }
.alert-light, .alert-secondary { background: var(--surface-subtle); }
.alert-dismissible { padding-inline-end: 44px; }
.alert-dismissible .btn-close { padding: 14px; }
.alert ul { padding-inline-start: 18px; }

.dropdown-menu { --bs-dropdown-link-active-bg: var(--surface-hover); --bs-dropdown-link-active-color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
    padding: 4px; font-size: 14px; min-width: 200px; }
.dropdown-item { border-radius: var(--radius-sm); padding: 7px 10px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.dropdown-item i { color: var(--text-tertiary); width: 16px; text-align: center; font-size: 16px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-hover); color: var(--text); }
.dropdown-item.text-danger:hover { background: var(--danger-subtle); }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-header { font-size: 12.5px; font-weight: 600; color: var(--text-tertiary); padding: 6px 10px; }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

.modal-content { border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); }
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-header .modal-title { font-size: 16px; font-weight: 600; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; background: var(--surface-subtle);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.modal-backdrop { --bs-backdrop-bg: #101828; --bs-backdrop-opacity: .45; }

.progress { height: 6px; background: var(--surface-hover); border-radius: 3px; }
.progress-bar { background: var(--primary); }
.list-group-item { border-color: var(--border); font-size: 14px; }

/* حالة فارغة */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-tertiary); font-size: 14px; }
.empty-state .es-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* قائمة صفوف داخل لوحة (مواعيد، متأخرات) */
.row-list > * { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 20px; border-top: 1px solid var(--border); color: var(--text); min-height: 52px; }
.row-list > *:first-child { border-top: 0; }
.row-list > a:hover { background: var(--surface-subtle); color: var(--text); }
.row-list .rl-title { font-size: 14px; font-weight: 500; color: var(--text); }
.row-list .rl-sub { font-size: 12.5px; color: var(--text-tertiary); }
.row-list .rl-end { text-align: end; flex: 0 0 auto; }
.row-list > .empty-state { display: block; padding: 24px 20px; }

/* نقطة حالة وسطر حالة (نقطة + كلمة) خارج الشارات */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-dot); flex: 0 0 7px; vertical-align: middle; }
.dot.success, .state-line.success::before { background: var(--success-dot); }
.dot.danger, .state-line.danger::before { background: var(--danger-dot); }
.dot.warning, .state-line.warning::before { background: var(--warning-dot); }
.dot.info, .state-line.info::before { background: var(--info-dot); }
.dot.primary, .state-line.primary::before { background: var(--primary); }
.state-line { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text-secondary); }
.state-line::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-dot); flex: 0 0 7px; }
/* عمود واحد لا يتّسع بمحتواه (جدول عريض داخل شبكة) */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
/* سطر ملخّص يظهر تحت العمود اللاصق على الشاشات الضيقة فقط */
.m-sum { display: none; }

/* =====================================================================
   مودال التأكيد
   ===================================================================== */
.ac-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--danger-subtle); color: var(--danger);
    display: flex; align-items: center; justify-content: center; font-size: 18px; margin: 0 auto 14px; }

/* =====================================================================
   الشاشات الضيقة
   ===================================================================== */
@media (max-width: 991.98px) {
    :root { --page-pad: 16px; }
    /* السايدبار درج تحت الرأس */
    .sidebar { width: min(300px, 86vw); transform: translateX(calc(100% + 1px)); visibility: hidden; box-shadow: none;
        transition: transform var(--t-base) ease-out, visibility 0s var(--t-base); }
    html[dir="ltr"] .sidebar { transform: translateX(calc(-100% - 1px)); }
    .sidebar.show { transform: none; visibility: visible; box-shadow: var(--shadow-pop); transition: transform var(--t-base) ease-out; }
    .sidebar.show ~ .sidebar-backdrop { display: block; }
    .main { margin-inline-start: 0; }
    .app-header { padding-inline: 8px 10px; gap: 6px; }
    .ah-start { flex: 0 1 auto; gap: 6px; }
    .ah-logo img { height: 20px; }
    .ah-btn { width: 40px; height: 40px; flex-basis: 40px; }
    .page { padding-top: 16px; }
    .page-head { align-items: flex-start; }
    .btn, .form-control, .form-select { min-height: 42px; }
    .btn-sm { min-height: 38px; }
    .icon-btn { width: 40px; height: 40px; }
    .sidebar .nav-link { min-height: 42px; }
    .nav-sec-head { min-height: 34px; }
    .nav-sec-head .chev { opacity: 1; }
    .row-menu-btn { width: 40px; height: 40px; }
    .table td .btn.btn-sm.btn-outline-secondary,
    .table td .btn.btn-sm.btn-outline-primary,
    .table td .btn.btn-sm.btn-outline-danger,
    .table td .btn.btn-sm { min-width: 40px; min-height: 40px; }
    .row-menu .dropdown-item { min-height: 42px; }
    .table td:not([colspan]) .btn.btn-sm:is(.btn-outline-secondary, .btn-outline-primary, .btn-outline-danger, .btn-light):is([aria-label], [title]) { min-width: 40px; min-height: 40px; }
    .card-head a:not(.btn) { min-height: 40px; display: inline-flex; align-items: center; }
    .crumbs a { padding-block: 6px; }
    /* العمود اللاصق يُظلّل حافته بعد التمرير فيُقرأ المقطوع على أنه قابل للتمرير */
    .table-responsive.is-scrolled th:first-child, .table-responsive.is-scrolled td:first-child {
        box-shadow: -8px 0 8px -8px rgba(16, 24, 40, .2); clip-path: inset(0 -12px 0 0); }
    html[dir="ltr"] .table-responsive.is-scrolled th:first-child, html[dir="ltr"] .table-responsive.is-scrolled td:first-child {
        box-shadow: 8px 0 8px -8px rgba(16, 24, 40, .2); clip-path: inset(0 0 0 -12px); }
    /* الجدول يتمرّر أفقياً ويثبت عمود الهوية */
    .table-responsive table { min-width: 760px; }
    .table-responsive th:first-child, .table-responsive td:first-child {
        position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); }
    .table-responsive thead th:first-child { background: var(--surface-subtle); z-index: 3; }
    .table-hover > tbody > tr:hover > td:first-child { background: var(--surface-subtle); }
    .table td .money, .table td .doc-id, .table td .badge { white-space: nowrap; }
    .table-responsive tfoot td:first-child, .table-responsive tfoot th:first-child { background: var(--surface-subtle); }
    /* صف «لا بيانات» أو صف إجمالي ممتد: لا يلتصق ولا يتوسّط جدولاً أعرض من الشاشة */
    .table-responsive td[colspan] { position: static !important; text-align: start !important; }
    .table-responsive td[colspan].text-center > *, .table-responsive td[colspan] .empty-state { max-width: calc(100vw - 2 * var(--page-pad) - 24px); }
    .table-responsive th.col-name, .table-responsive td.col-name { min-width: 170px; }
    /* جدول قصير (3–4 أعمدة) يتّسع للشاشة بلا تمرير */
    .table-responsive table.table-fit { min-width: 0; }
    .table-responsive .table-fit th:first-child, .table-responsive .table-fit td:first-child { position: static; }
    .m-sum { display: block; font-size: 12.5px; font-weight: 400; color: var(--text-tertiary); margin-top: 2px; white-space: nowrap; }
}
@media (max-width: 575.98px) {
    .page-title { font-size: 20px; }
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > form > .btn { flex: 1 1 auto; }
    .row > [class*="col-"]:has(> .statcard), .row > [class*="col-"]:has(> a > .statcard) { flex: 0 0 100%; max-width: 100%; }
    .statcard .sc-v { font-size: 20px; }
    .metric-strip { grid-template-columns: 1fr 1fr; }
    .metric-strip .m-value { font-size: 18px; }
    .metric-strip .m-value.lg { font-size: 22px; }
    .metric-strip > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .table-responsive .table-fit th.col-name, .table-responsive .table-fit td.col-name { min-width: 0; }
    /* رابط «مسح الفلاتر» يأخذ سطره فلا يُقصّ ما بجانبه */
    .filter-bar .filter-actions:has(.btn-ghost) { flex: 1 1 100%; }
    .page-actions > form { display: flex !important; flex: 1 1 auto; }
    .page-actions > form > .btn { flex: 1 1 auto; }
}

@media (prefers-contrast: more) {
    :root { --border: #B9C0CB; --border-input: #8695AC; --text-tertiary: #475467; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
    .sidebar, .app-header, .sidebar-backdrop, .no-print, .d-print-none, .page-actions, .crumbs, .row-menu { display: none !important; }
    .main { margin-inline-start: 0 !important; }
    body { background: #fff; font-size: 12.5px; }
    .card { box-shadow: none; border: 1px solid #ccc !important; }
    .page { padding: 0; max-width: none; }
    .page > .row { margin-inline: 0; }
    .table-responsive { overflow: visible !important; margin-inline: 0 !important; }
    .table-responsive table { min-width: 0 !important; }
    /* يلغي اللصق فقط؛ relative تُبقي شرائط ::before داخل الخلية في مكانها */
    .table-responsive th:first-child, .table-responsive td:first-child { position: relative !important; box-shadow: none; clip-path: none; }
    .m-sum { display: none !important; }
}

.min-w-0 { min-width: 0; }

/* ترقيم الصفحات (resources/views/vendor/pagination/bootstrap-5.blade.php) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.pager-info { font-size: 13px; color: var(--text-tertiary); }
.pager .page-link i { font-size: 14px; }
@media (max-width: 575.98px) {
    .pager .pager-num:not(.active) { display: none; }
}
