/* =====================================================================
   نظام التصميم — منصة معارج لإدارة المهام
   ---------------------------------------------------------------------
   الطبقة الأولى: رموز أولية (Primitives) — قيم خام، لا تُستخدم مباشرة.
   الطبقة الثانية: رموز دلالية (Semantic) — هي فقط ما تستخدمه المكوّنات.
   فائدة الفصل: الوضع الليلي أو أي هوية جديدة = تبديل الطبقة الثانية فقط،
   دون لمس سطر واحد من كود المكوّنات.
   ===================================================================== */

:root {
  /* ============ 1. رموز أولية: سُلّم ألوان الهوية ============ */
  --c-brand-900: #1A2A39;   /* نيفي الشعار */
  --c-brand-800: #1F4E5E;   /* الطرف الغامق من تدرّج المعيّن */
  --c-brand-700: #256578;
  --c-brand-600: #2C7286;
  --c-brand-500: #3B919F;   /* منتصف التدرّج — اللون الأساسي */
  --c-brand-400: #58A6B2;   /* الطرف الفاتح من التدرّج */
  --c-brand-300: #93A4A5;
  --c-brand-200: #BFDDE2;
  --c-brand-100: #D3E6EA;
  --c-brand-050: #E4F0F2;

  /* محايدات باردة مشتقّة من نيفي الهوية */
  --c-n-900: #1A2A39;
  --c-n-800: #24384A;
  --c-n-700: #3A4B5C;
  --c-n-600: #4C5E68;
  --c-n-500: #5E7078;
  --c-n-400: #93A4A5;
  --c-n-300: #DCE5EA;
  --c-n-200: #E3EAEF;
  --c-n-100: #EEF3F6;
  --c-n-050: #F7FAFC;
  --c-white: #FFFFFF;

  /* ألوان دلالية خام */
  --c-ok-600: #1E6B4A;  --c-ok-050: #E3F3EC;
  --c-warn-600: #7A4F00; --c-warn-050: #FBF0DA;
  --c-dang-600: #B42318; --c-dang-050: #FDECEA;
  --c-info-600: #2A5E8C; --c-info-050: #E6EFF7;

  /* ============ 2. سُلّم المسافات (أساس 4px) ============ */
  --sp-0: 0;      --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;
  --sp-4: 16px;   --sp-5: 20px;  --sp-6: 24px;  --sp-7: 32px;
  --sp-8: 40px;   --sp-9: 48px;  --sp-10: 64px;

  /* ============ 3. سُلّم الحواف ============ */
  --r-xs: 7px;  --r-sm: 10px; --r-md: 12px;
  --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* ============ 4. سُلّم الارتفاع (الظلال) ============ */
  --e-0: none;
  --e-1: 0 1px 3px rgba(22, 41, 58, .05);
  --e-2: 0 4px 14px rgba(22, 41, 58, .07);
  --e-3: 0 8px 28px rgba(22, 41, 58, .09);
  --e-4: 0 16px 44px rgba(22, 41, 58, .13);
  --ring: 0 0 0 3px rgba(45, 119, 135, .18);   /* حلقة التركيز */

  /* ============ 5. سُلّم الخطوط ============ */
  /* دليل الهوية يحدّد Noor وهو غير متاح مجاناً للويب.
     Almarai أقرب بديل متاح بنيةً هندسية ونهايات مستقيمة.
     عند امتلاك ترخيص Noor: ارفع ملفاته وبدّل الاسم هنا فقط. */
  --font: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  --fs-xs: .72rem;  --fs-sm: .8rem;   --fs-md: .88rem;
  --fs-lg: 1rem;    --fs-xl: 1.18rem; --fs-2xl: 1.5rem;
  --fs-3xl: 2.1rem;
  --fw-regular: 400; --fw-medium: 500; --fw-bold: 700; --fw-black: 800;
  --lh-tight: 1.2;  --lh-normal: 1.65;

  /* ============ 6. الحركة ============ */
  --dur-fast: .12s; --dur-base: .18s; --dur-slow: .35s;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* ============ 7. أبعاد الهيكل ============ */
  --sidebar-w: 268px;
  --header-h: 78px;
  --content-max: 1500px;

  /* =====================================================================
     الطبقة الدلالية — المكوّنات تقرأ من هنا فقط
     ===================================================================== */

  /* الأسطح */
  --canvas:    #F3F7FA;
  --surface:   var(--c-white);
  --surface-2: var(--c-n-050);
  --surface-3: var(--c-n-100);
  --overlay:   rgba(22, 41, 58, .45);

  /* الحدود */
  --line:      var(--c-n-200);
  --line-soft: var(--c-n-100);
  --line-strong: var(--c-n-300);

  /* النص */
  --text:     var(--c-n-900);
  --text-2:   var(--c-n-600);
  --text-3:   var(--c-n-500);
  --text-dis: var(--c-n-400);
  --on-brand: var(--c-white);

  /* اللون الأساسي */
  --brand-900: var(--c-brand-900);
  --brand-800: var(--c-brand-800);
  --brand-700: var(--c-brand-700);
  --brand-600: var(--c-brand-600);
  --brand-500: var(--c-brand-500);
  --brand-400: var(--c-brand-400);
  --brand-300: var(--c-brand-300);
  --brand-200: var(--c-brand-200);
  --brand-050: var(--c-brand-050);
  /* التدرّج مأخوذ من معيّن الشعار نفسه */
  --brand-grad: linear-gradient(135deg, var(--c-brand-500) 0%, var(--c-brand-700) 100%);
  --brand-grad-soft: linear-gradient(135deg, var(--c-brand-050) 0%, var(--c-brand-100) 100%);

  /* الحالات الدلالية */
  --ok: var(--c-ok-600);       --ok-bg: var(--c-ok-050);
  --warn: var(--c-warn-600);   --warn-bg: var(--c-warn-050);
  --danger: var(--c-dang-600); --danger-bg: var(--c-dang-050);
  --info: var(--c-info-600);   --info-bg: var(--c-info-050);

  /* الظلال الدلالية */
  --shadow-1: var(--e-1);
  --shadow-2: var(--e-3);

  /* الشريط الجانبي */
  --nav-bg:        var(--c-brand-900);
  --nav-text:      #C8D8E0;
  --nav-text-on:   var(--c-white);
  --nav-hover:     rgba(255, 255, 255, .06);
  --nav-active:    rgba(255, 255, 255, .1);
  --nav-accent:    var(--c-brand-300);
  --nav-divider:   rgba(255, 255, 255, .07);
  --nav-muted:     #7D95A4;
}

/* =====================================================================
   الوضع الليلي — جاهز للتفعيل بإضافة data-theme="dark" على <html>.
   لا يحتاج أي تعديل في كود المكوّنات لأنه يبدّل الطبقة الدلالية فقط.
   ===================================================================== */
[data-theme="dark"] {
  --canvas:    #0E1A24;
  --surface:   #16242F;
  --surface-2: #1C2E3A;
  --surface-3: #24384A;
  --overlay:   rgba(0, 0, 0, .6);

  --line:      #2A3D4C;
  --line-soft: #223442;
  --line-strong: #3A4B5C;

  --text:     #E8EFF3;
  --text-2:   #A7B6C1;
  --text-3:   #7D8F9C;
  --text-dis: #5C6B78;

  --brand-050: #16323B;
  --brand-200: #24697C;

  --ok-bg:     #143324;
  --warn-bg:   #33270E;
  --danger-bg: #331A16;
  --info-bg:   #14273A;

  --e-1: 0 1px 3px rgba(0, 0, 0, .35);
  --e-3: 0 8px 28px rgba(0, 0, 0, .45);

  --nav-bg:      #0B1620;
  --nav-divider: rgba(255, 255, 255, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================ التخطيط ============================ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand-900);
  color: #C8D8E0;
  display: flex; flex-direction: column;
  position: fixed; inset-block: 0; inset-inline-start: 0;
  z-index: 40;
}

.sidebar__brand {
  min-height: var(--header-h);
  display: flex; align-items: center;
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: 6px;
}
.sidebar__brand a { display: inline-flex; width: 100%; }

/* الشعار الكامل: الارتفاع ثابت والعرض يتبع النسبة الأصلية */
.sidebar__logo {
  width: auto; height: 52px; max-width: 100%;
  object-fit: contain; object-position: right center;
}

.sidebar__mark {
  width: 38px; height: 38px; object-fit: contain;
  flex: 0 0 auto;   /* الشعار أبيض أصلاً فلا خلفية له */
}

.sidebar__nav { padding: 14px 12px; overflow-y: auto; flex: 1; }

.sidebar__group {
  font-size: .72rem; color: #7D95A4; margin: 16px 10px 6px;
  letter-spacing: .02em;
}

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-md);
  color: #C6DCD8; font-size: .92rem; margin-bottom: 2px;
  transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.is-active {
  background: var(--brand-700); color: #fff; font-weight: 500;
  box-shadow: inset 3px 0 0 var(--brand-400);
}
.nav-link__icon {
  width: 19px; height: 19px; flex: 0 0 19px;
  display: grid; place-items: center; opacity: .82;
}
.nav-link.is-active .nav-link__icon { opacity: 1; }
.nav-link__badge {
  margin-inline-start: auto; background: var(--danger); color: #fff;
  font-size: .68rem; padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}

.sidebar__foot {
  padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: .74rem; color: #7D95A4;
}

.main {
  flex: 1; min-width: 0;
  margin-inline-start: var(--sidebar-w);
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding-inline: 20px;
  position: sticky; top: 0; z-index: 30;
}

.topbar__toggle {
  display: none; background: none; border: 0; font-size: 1.3rem;
  color: var(--text-2); cursor: pointer; padding: 4px 6px;
}

.topbar__title { font-weight: 600; font-size: 1.02rem; margin: 0; }

.topbar__spacer { flex: 1; }

.content { padding: 22px; max-width: 1400px; width: 100%; }

/* ============================ البحث ============================ */

.search { position: relative; width: 300px; max-width: 34vw; }
.search input {
  width: 100%; padding: 8px 34px 8px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); font-family: inherit; font-size: .88rem;
}
.search input:focus { background: var(--surface); border-color: var(--brand-300); }
.search__icon {
  position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none; font-size: .85rem;
}
.search__results {
  position: absolute; inset-inline: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  max-height: 380px; overflow-y: auto; display: none; z-index: 50;
}
.search__results.is-open { display: block; }
.search__section { padding: 6px 12px 3px; font-size: .72rem; color: var(--text-3); }
.search__item { display: block; padding: 8px 12px; font-size: .88rem; color: var(--text); }
.search__item:hover { background: var(--brand-050); text-decoration: none; }
.search__item small { color: var(--text-3); display: block; font-size: .74rem; }

/* ============================ الإشعارات والحساب ============================ */

.icon-btn {
  position: relative; background: none; border: 1px solid transparent;
  width: 36px; height: 36px; border-radius: var(--r-md);
  cursor: pointer; font-size: 1.05rem; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn__dot {
  position: absolute; top: 4px; inset-inline-end: 4px;
  background: var(--danger); color: #fff; font-size: .62rem;
  min-width: 16px; height: 16px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px;
}

.dropdown { position: relative; }
.dropdown__panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
  min-width: 260px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); display: none; z-index: 50; overflow: hidden;
}
.dropdown__panel.is-open { display: block; }
.dropdown__item {
  display: flex; gap: 9px; padding: 10px 13px;
  font-size: .88rem; color: var(--text); border-bottom: 1px solid var(--line-soft);
}
.dropdown__item:last-child { border-bottom: 0; }
.dropdown__item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown__item small { color: var(--text-3); display: block; font-size: .74rem; }
.dropdown__head {
  padding: 10px 13px; font-size: .8rem; font-weight: 600;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  display: flex; justify-content: space-between; align-items: center;
}

.userchip {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 1px solid transparent; border-radius: var(--r-md);
  padding: 4px 8px; cursor: pointer; font-family: inherit; color: var(--text);
}
.userchip:hover { background: var(--surface-2); border-color: var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-700); color: #fff;
  display: grid; place-items: center; font-size: .82rem; font-weight: 600; flex: 0 0 32px;
}
.avatar--lg { width: 56px; height: 56px; flex-basis: 56px; font-size: 1.2rem; }
.userchip__name { font-size: .87rem; line-height: 1.2; text-align: start; }
.userchip__role { font-size: .72rem; color: var(--text-3); }

/* ============================ البطاقات ============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card__head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card__title { font-size: .96rem; font-weight: 600; margin: 0; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* بطاقة إحصائية: الرقم هو البطل، التسمية هادئة تحته */
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 17px 18px 15px;
  display: flex; flex-direction: column;
  transition: box-shadow .14s ease, border-color .14s ease;
}
.stat:hover { box-shadow: 0 3px 14px rgba(22,41,58,.07); border-color: var(--brand-200); }

/* العنوان أولاً مع أيقونته — كما في المرجع */
.stat__label {
  order: -1; display: flex; align-items: center; gap: 7px;
  font-size: .82rem; font-weight: 500; color: var(--brand-500);
  margin-bottom: 12px;
}
.stat__label .ico { flex: 0 0 auto; opacity: .95; }

.stat__value {
  font-size: 2.05rem; font-weight: 700; line-height: 1.1;
  font-feature-settings: "tnum"; letter-spacing: -.015em; color: var(--text);
}
.stat__sub { font-size: .75rem; color: var(--text-3); margin-top: 7px; }

.stat--ok     .stat__label { color: var(--ok); }
.stat--warn   .stat__label { color: var(--warn); }
.stat--danger .stat__label { color: var(--danger); }
.stat--muted  .stat__label { color: var(--text-2); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-family: inherit; font-size: .88rem; font-weight: 500;
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--brand-700); border-color: var(--brand-700); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-900); border-color: var(--brand-900); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { filter: brightness(.93); }
.btn--danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { padding: 5px 11px; font-size: .8rem; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================ الشارات ============================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 500; white-space: nowrap;
}
.badge--new     { background: var(--info-bg);   color: var(--info); }
.badge--progress{ background: var(--brand-050); color: var(--brand-700); }
.badge--done    { background: var(--ok-bg);     color: var(--ok); }
.badge--late    { background: var(--danger-bg); color: var(--danger); }
.badge--hold    { background: var(--warn-bg);   color: var(--warn); }
.badge--archived{ background: #EDF1F4;          color: var(--text-2); }

.pri {
  display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--text-2);
}
.pri::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pri--low    { color: #6B7A78; }
.pri--medium { color: var(--info); }
.pri--high   { color: var(--warn); }
.pri--urgent { color: var(--danger); font-weight: 600; }

.dot-color { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ============================ الجداول ============================ */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .88rem;
}
table.data th {
  text-align: start; padding: 11px 14px;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 600; font-size: .8rem;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { font-feature-settings: "tnum"; }

.t-title { font-weight: 500; color: var(--text); }
.t-title:hover { color: var(--brand-700); }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

/* ============================ النماذج ============================ */

.form-grid { display: grid; gap: 15px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: .84rem; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: .74rem; color: var(--text-3); }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=datetime-local], input[type=number], input[type=tel], input[type=search],
select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: inherit; font-size: .9rem; background: var(--surface); color: var(--text);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500); outline: none;
  box-shadow: 0 0 0 3px rgba(31,132,118,.14);
}
input[type=color] { padding: 3px; height: 40px; cursor: pointer; }
select { appearance: none; background-image: none; padding-inline-start: 12px; }

.filters {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.switch { display: flex; align-items: center; gap: 9px; font-size: .88rem; cursor: pointer; }

/* ============================ التنبيهات ============================ */

.alert {
  padding: 11px 15px; border-radius: var(--r-md);
  font-size: .89rem; margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--success { background: var(--ok-bg);    color: var(--ok);     border-color: #BFE3CE; }
.alert--error   { background: var(--danger-bg);color: var(--danger); border-color: #EFC9C2; }
.alert--info    { background: var(--info-bg);  color: var(--info);   border-color: #C6DBEC; }

/* ============================ الشريط التقدمي ============================ */

.bar { background: var(--line-soft); border-radius: 999px; height: 7px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--brand-500); border-radius: 999px; }
.bar__fill--ok { background: var(--ok); }
.bar__fill--warn { background: var(--warn); }
.bar__fill--danger { background: var(--danger); }

/* قائمة أداء الأقسام: الاسم، ثم الشريط، ثم النسبة */
.rank { display: flex; flex-direction: column; gap: 13px; }
.rank__row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.rank__name { font-size: .88rem; display: flex; align-items: center; gap: 7px; }
.rank__pct { font-size: .88rem; font-weight: 600; font-feature-settings: "tnum"; }
.rank__bar { grid-column: 1 / -1; }
.rank__meta { font-size: .74rem; color: var(--text-3); grid-column: 1 / -1; margin-top: -2px; }

/* ============================ الشجرة الزمنية (الأرشيف) ============================ */

.tiles { display: grid; gap: 13px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.tile {
  display: block; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); color: var(--text);
}
.tile:hover { border-color: var(--brand-300); text-decoration: none; box-shadow: var(--shadow-1); }
.tile__title { font-weight: 600; font-size: 1rem; }
.tile__range { font-size: .76rem; color: var(--text-3); margin-top: 3px; font-feature-settings: "tnum"; }
.tile__stats { display: flex; gap: 14px; margin-top: 11px; font-size: .8rem; color: var(--text-2); }
.tile__stats b { font-feature-settings: "tnum"; }
.tile--closed { background: var(--surface-2); }

.crumbs { display: flex; gap: 7px; align-items: center; font-size: .84rem; margin-bottom: 16px; flex-wrap: wrap; }
.crumbs span { color: var(--text-3); }

/* ============================ الجدول الزمني للسجل ============================ */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding-inline-start: 22px; padding-bottom: 16px;
  border-inline-start: 2px solid var(--line-soft); margin-inline-start: 5px;
}
.timeline li:last-child { border-inline-start-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: -6px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand-500);
}
.timeline__when { font-size: .74rem; color: var(--text-3); font-feature-settings: "tnum"; }
.timeline__what { font-size: .87rem; }

/* ============================ الترقيم ============================ */

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: .85rem; color: var(--text-2); background: var(--surface);
}
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager .is-current { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

/* ============================ الحالات الفارغة ============================ */

.empty { padding: 44px 20px; text-align: center; color: var(--text-2); }
.empty__title { font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty__hint { font-size: .87rem; }

/* ============================ صفحة الدخول ============================ */

.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 18%, rgba(31,132,118,.13), transparent 42%),
    var(--canvas);
}
.login__box { width: 100%; max-width: 400px; }
.login__card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px; box-shadow: var(--shadow-2);
}
.login__brand { text-align: center; margin-bottom: 22px; }
.login__mark {
  width: auto; height: 62px; max-width: 78%;
  object-fit: contain; display: block; margin: 0 auto var(--sp-5);
}
.login__title { font-size: 1.12rem; font-weight: 600; margin: 0; }
.login__sub { font-size: .85rem; color: var(--text-2); margin-top: 3px; }
.login__foot { text-align: center; margin-top: 18px; font-size: .78rem; color: var(--text-3); }

/* ============================ متفرقات ============================ */

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 1.28rem; margin: 0; font-weight: 600; }
.page-head p { margin: 2px 0 0; font-size: .85rem; color: var(--text-2); }

.chart-box { position: relative; height: 260px; }
.chart-box--sm { height: 200px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: .89rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

.sep { height: 1px; background: var(--line-soft); margin: 16px 0; }

.scrim {
  position: fixed; inset: 0; background: rgba(11,59,53,.4);
  z-index: 35; display: none;
}
.scrim.is-open { display: block; }

/* ============================ الاستجابة ============================ */

@media (max-width: 1024px) {
  .search { width: 210px; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-2);
  }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-inline-start: 0; }
  .topbar__toggle { display: block; }
  .content { padding: 16px; }
  .userchip__name, .userchip__role { display: none; }
  .search { width: auto; flex: 1; max-width: none; }
  .topbar__title { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .stat__value { font-size: 1.55rem; }
  .card__body { padding: 14px; }
  .page-head h1 { font-size: 1.12rem; }
  table.data th, table.data td { padding: 9px 10px; }
  .hide-sm { display: none; }
}

@media print {
  .sidebar, .topbar, .btn, .filters, .pager { display: none !important; }
  .main { margin: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}

/* ============================ صفوف المهام القابلة للنقر ============================ */

.data tr[data-href] { transition: background .12s ease; }
.data tr[data-href]:hover { background: var(--brand-050); }
.data tr[data-href]:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}
.data tr.is-done .t-title { text-decoration: line-through; opacity: .65; }

/* نص مخفي بصرياً ومتاح لقارئات الشاشة */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* صندوق الملاحظة أقصر من الافتراضي */
.card__body textarea[rows="2"] { min-height: 62px; }
.card__body textarea[rows="3"] { min-height: 86px; }

/* ============================ لوحة المهام (سحب وإفلات) ============================ */

.board {
  display: flex; gap: 14px; align-items: flex-start;
  overflow-x: auto; padding-bottom: 10px;
  scroll-behavior: smooth;
}
.board::-webkit-scrollbar { height: 9px; }
.board::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; }

.col {
  flex: 1 0 264px; max-width: 340px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
}
.col__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  font-weight: 600; font-size: .88rem;
}
/* رأس محايد + نقطة ملوّنة: أهدأ بصرياً ويبقى التمييز واضحاً */
.col__head { background: var(--surface); color: var(--text); }
.col__dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-inline-end: 8px; flex: 0 0 8px;
}
.col__title { display: inline-flex; align-items: center; }
.col__head--new      .col__dot { background: var(--brand-300); }
.col__head--progress .col__dot { background: var(--brand-500); }
.col__head--hold     .col__dot { background: var(--warn); }
.col__head--done     .col__dot { background: var(--ok); }
.col__head--late     .col__dot { background: var(--danger); }
.col__head--new      { box-shadow: inset 0 3px 0 var(--brand-300); }
.col__head--progress { box-shadow: inset 0 3px 0 var(--brand-500); }
.col__head--hold     { box-shadow: inset 0 3px 0 var(--warn); }
.col__head--done     { box-shadow: inset 0 3px 0 var(--ok); }
.col__head--late     { box-shadow: inset 0 3px 0 var(--danger); }
.col__count {
  background: var(--line-soft); color: var(--text-2);
  border-radius: 999px; padding: 1px 9px; font-size: .78rem; font-weight: 700;
}
.col__body {
  padding: 10px; display: flex; flex-direction: column; gap: 9px;
  min-height: 130px; max-height: 68vh; overflow-y: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  transition: background .12s ease, box-shadow .12s ease;
}
.col__body.is-over {
  background: var(--brand-050);
  box-shadow: inset 0 0 0 2px var(--brand-300);
}
.col__empty {
  color: var(--text-3); font-size: .82rem; text-align: center;
  padding: 18px 8px; border: 1px dashed var(--line); border-radius: var(--r-md);
}

/* --- بطاقة المهمة --- */
.tcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 12px;
  cursor: pointer;
  transition: box-shadow .12s ease, transform .08s ease, border-color .12s ease;
}
.tcard:hover { box-shadow: 0 2px 8px rgba(16,32,29,.09); border-color: var(--brand-300); }
.tcard:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.tcard--late { border-inline-start: 3px solid var(--danger); }

.tcard__top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.tcard__dept { font-size: .74rem; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.tcard__title { font-size: .89rem; font-weight: 500; line-height: 1.55; margin-bottom: 7px; }
.tcard__meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: .75rem; color: var(--text-2);
}
.tcard__meta .is-late { color: var(--danger); font-weight: 600; }
.tcard__move { margin-top: 9px; }

/* على الأجهزة ذات الماوس يكفي السحب، فنُخفي القائمة حتى المرور
   لتبقى البطاقة نظيفة؛ وعلى اللمس تبقى ظاهرة دائماً لأنها البديل الأسهل. */
@media (hover: hover) and (pointer: fine) {
  .tcard__move {
    max-height: 0; opacity: 0; margin-top: 0; overflow: hidden;
    transition: max-height .15s ease, opacity .15s ease, margin-top .15s ease;
  }
  .tcard:hover .tcard__move,
  .tcard:focus-within .tcard__move { max-height: 46px; opacity: 1; margin-top: 9px; }
}
.tcard__select {
  width: 100%; font-size: .76rem; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); font-family: inherit; color: var(--text-2);
}

/* --- حالات السحب --- */
.tcard.is-dragging { opacity: .32; }
.tcard--ghost {
  position: fixed; z-index: 999; pointer-events: none;
  margin: 0; transform: rotate(1.5deg) scale(1.02);
  box-shadow: 0 10px 26px rgba(16,32,29,.22);
  border-color: var(--brand-500);
}
.tcard.is-saving { opacity: .6; }
.tcard.is-ok { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-bg); }
.board.is-dragging-active .tcard:hover { box-shadow: none; }
body.no-select { user-select: none; -webkit-user-select: none; }

/* --- الجوال: أعمدة متتابعة رأسياً --- */
@media (max-width: 860px) {
  .board { flex-direction: column; overflow-x: visible; }
  .col { flex: 1 1 auto; max-width: none; width: 100%; }
  .col__body { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .board { scroll-behavior: auto; }
  .tcard, .col__body { transition: none; }
  .tcard--ghost { transform: none; }
}

/* ============================ مبدّل عرض المهام ============================ */

.viewbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.viewbar__group {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.viewbar__btn {
  padding: 7px 15px; font-size: .84rem; font-weight: 500;
  color: var(--text-2); text-decoration: none; white-space: nowrap;
  border-inline-start: 1px solid var(--line);
}
.viewbar__btn:first-child { border-inline-start: 0; }
.viewbar__btn:hover { background: var(--line-soft); color: var(--text); }
.viewbar__btn.is-on { background: var(--brand-700); color: var(--on-brand); }

/* ============================ الأيقونات ============================ */

.ico { display: inline-block; vertical-align: -.16em; flex: 0 0 auto; }

/* أيقونات الإشعارات داخل القائمة المنسدلة والصفحة */
.notif__icon, .notif-item__icon {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand-050); color: var(--brand-500); flex: 0 0 auto;
}

.tcard__notes { display: inline-flex; align-items: center; gap: 4px; }
.viewbar__btn { display: inline-flex; align-items: center; gap: 6px; }
.topbar__toggle, .search__icon { display: inline-flex; align-items: center; justify-content: center; }

/* ============================ اللوحة الرئيسية ============================ */

/* --- بطاقات المؤشرات --- */
.kpi-row {
  display: grid; gap: 14px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px 14px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.kpi:hover { box-shadow: 0 4px 16px rgba(22,41,58,.07); border-color: var(--brand-200); }
.kpi__top { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.kpi__ic {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 9px; background: var(--brand-050); color: var(--brand-500); flex: 0 0 30px;
}
.kpi__label { font-size: .84rem; font-weight: 500; color: var(--text-2); }
.kpi__value {
  font-size: 2.15rem; font-weight: 800; line-height: 1.05;
  letter-spacing: -.02em; color: var(--text); font-feature-settings: "tnum";
}
.kpi__foot { display: flex; align-items: center; gap: 7px; margin-top: 9px; min-height: 20px; }
.kpi__note { font-size: .73rem; color: var(--text-3); }

.kpi--ok     .kpi__ic { background: var(--ok-bg);     color: var(--ok); }
.kpi--warn   .kpi__ic { background: var(--warn-bg);   color: var(--warn); }
.kpi--danger .kpi__ic { background: var(--danger-bg); color: var(--danger); }

/* شارة نسبة التغيّر */
.chip {
  font-size: .71rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; font-feature-settings: "tnum"; white-space: nowrap;
}
.chip--up   { background: var(--ok-bg);     color: var(--ok); }
.chip--down { background: var(--danger-bg); color: var(--danger); }

/* --- الشبكة --- */
.dash-grid {
  display: grid; gap: 14px;
  grid-template-columns: 300px 1fr;
  grid-template-areas: "gauge trend" "org rank";
  align-items: start;
}
.panel--gauge { grid-area: gauge; }
.panel--trend { grid-area: trend; }
.panel--org   { grid-area: org; }
.panel--rank  { grid-area: rank; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 15px 18px 17px;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.panel__title {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: .9rem; font-weight: 600; color: var(--text);
}
.panel__title .kpi__ic { width: 27px; height: 27px; flex: 0 0 27px; }
.panel__note { font-size: .76rem; color: var(--text-3); text-decoration: none; }
a.panel__note:hover { color: var(--brand-500); }

/* --- مؤشر الأداء نصف الدائري --- */
.gauge { position: relative; padding: 4px 0 2px; }
.gauge__svg { width: 100%; display: block; }
.gauge__track, .gauge__fill { fill: none; stroke-width: 15; stroke-linecap: round; }
.gauge__track { stroke: var(--line-soft); }
.gauge__fill  { stroke: var(--brand-500); transition: stroke-dashoffset .6s ease; }
.gauge__center {
  position: absolute; inset-inline: 0; bottom: 6px; text-align: center;
}
.gauge__value {
  font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--text); font-feature-settings: "tnum"; line-height: 1;
}
.gauge__cap { font-size: .73rem; color: var(--text-3); margin-top: 3px; }

.metrics { list-style: none; margin: 16px 0 0; padding: 0; }
.metrics li {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-top: 1px solid var(--line-soft); font-size: .82rem;
}
.metrics__k { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.metrics__k .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.metrics__v { margin-inline-start: auto; font-weight: 700; color: var(--text); }

/* --- صفوف المنظمة --- */
.orgrow {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0; border-top: 1px solid var(--line-soft);
  text-decoration: none; color: inherit;
}
.orgrow:first-of-type { border-top: 0; }
.orgrow:hover .orgrow__k { color: var(--brand-500); }
.orgrow__ic {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 9px; background: var(--brand-050); color: var(--brand-500); flex: 0 0 32px;
}
.orgrow__k { font-size: .84rem; color: var(--text-2); }
.orgrow__v { margin-inline-start: auto; font-size: 1.25rem; font-weight: 800; font-feature-settings: "tnum"; }

/* --- الشخص داخل الجدول --- */
.who { display: inline-flex; align-items: center; gap: 8px; }
.who__av {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px;
  display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand-700);
  font-size: .76rem; font-weight: 700;
}

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; grid-template-areas: "gauge" "trend" "org" "rank"; }
}

/* ============================ الهيكل الحديث ============================ */
/* لوحة عائمة بزوايا كبيرة على خلفية فاتحة، بنمط المرجع */

body { background: var(--canvas); }

.sidebar {
  background: var(--brand-900);
  padding-bottom: 8px;
}

/* روابط التنقّل: كبسولة بزوايا كبيرة */
.nav-link {
  border-radius: 14px;
  padding: 10px 13px;
  margin-bottom: 3px;
  gap: 12px;
}
.nav-link:hover { background: rgba(255,255,255,.06); }
.nav-link.is-active {
  background: rgba(255,255,255,.1);
  box-shadow: none;
  color: #fff;
}
.nav-link.is-active .nav-link__icon { color: var(--brand-300); }
.sidebar__nav { padding: 10px 14px; }

/* الشريط العلوي: شفاف فوق الخلفية بدل شريط أبيض بحد */
.topbar {
  background: transparent;
  border-bottom: 0;
  padding-inline: 26px 22px;
  gap: 16px;
}

/* حقل البحث ككبسولة */
.search input {
  border-radius: 999px;
  padding: 10px 40px 10px 16px;
  background: var(--surface);
  border-color: transparent;
  box-shadow: var(--shadow-1);
}
.search input:focus { border-color: var(--brand-300); background: var(--surface); }
.search__icon { inset-inline-start: auto; inset-inline-end: 14px; }

/* أزرار الأيقونات دائرية */
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border-color: transparent;
  box-shadow: var(--shadow-1);
}
.icon-btn:hover { background: var(--brand-050); color: var(--brand-700); }

/* منطقة المحتوى: بطاقة عائمة كبيرة */
.content {
  padding: 4px 22px 26px;
  max-width: 1500px;
}

/* البطاقات: بلا حدود قاسية، ظل ناعم بدلها */
.card, .panel, .kpi, .col {
  border-color: transparent;
  box-shadow: var(--shadow-1);
}
.card:hover, .panel:hover { box-shadow: var(--shadow-1); }
.kpi:hover { box-shadow: var(--shadow-2); border-color: transparent; }

/* رؤوس أعمدة اللوحة وبطاقاتها */
.col { background: var(--surface); }
.col__head { border-bottom: 1px solid var(--line-soft); }
.col__body { background: transparent; }
.tcard {
  border-radius: 15px;
  border-color: var(--line-soft);
  box-shadow: none;
}
.tcard:hover { box-shadow: var(--shadow-1); border-color: var(--brand-200); }

/* الأزرار أكثر استدارة */
.btn { border-radius: 12px; padding: 9px 17px; }
.btn--primary { box-shadow: 0 2px 10px rgba(45,119,135,.25); }
.viewbar__group { border-radius: 14px; box-shadow: var(--shadow-1); border-color: transparent; }
.viewbar__btn { padding: 9px 17px; }

/* الحقول */
input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], input[type=search], select, textarea {
  border-radius: 12px;
}

/* الجداول: صفوف أهدأ */
.data thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600; color: var(--text-2);
}
.data td { border-bottom: 1px solid var(--line-soft); }
.data tbody tr:last-child td { border-bottom: 0; }

/* الشارات ككبسولات */
.badge { border-radius: 999px; padding: 3px 11px; font-weight: 600; }
.pri { border-radius: 999px; }

@media (max-width: 860px) {
  .content { padding: 4px 14px 22px; }
  .topbar { padding-inline: 14px; }
}

/* =====================================================================
   حالات المكوّنات — Hover / Active / Focus / Disabled / Loading
   موحّدة لكل العناصر التفاعلية، ومبنية على الرموز الدلالية.
   ===================================================================== */

/* --- التركيز بلوحة المفاتيح: حلقة واحدة موحّدة في كل النظام --- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --- الأزرار --- */
.btn {
  transition: background var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease),
              transform var(--dur-fast) var(--ease);
  position: relative;
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn--primary:hover:not(:disabled) { background: var(--brand-800); }
.btn--primary:active:not(:disabled) { background: var(--brand-900); }

.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none; box-shadow: none;
}

/* زر في حالة تحميل: يُخفى نصه وتظهر دوّامة مكانه */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-inline-start-color: transparent;
  color: var(--on-brand);
  animation: spin .6s linear infinite;
}
.btn:not(.btn--primary).is-loading::after { color: var(--brand-500); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- الحقول --- */
input, select, textarea { transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: var(--line-strong);
}
input:focus, select:focus, textarea:focus { box-shadow: var(--ring); outline: none; }
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-3); color: var(--text-dis); cursor: not-allowed;
}
input[aria-invalid="true"], .field--error input, .field--error select, .field--error textarea {
  border-color: var(--danger);
}
.field__error { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--sp-1); display: block; }

/* --- البطاقات القابلة للنقر --- */
.is-clickable { cursor: pointer; transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease); }
.is-clickable:hover { box-shadow: var(--e-2); }
.is-clickable:active { transform: translateY(1px); }

/* --- هياكل التحميل (Skeleton) --- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--line-soft) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm); color: transparent !important;
}
.skeleton--text { height: 12px; margin: 5px 0; }
.skeleton--title { height: 20px; width: 45%; }
.skeleton--block { height: 84px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* لوحة كاملة أثناء التحميل */
.is-busy { position: relative; pointer-events: none; }
.is-busy::after {
  content: ""; position: absolute; inset: 0;
  background: var(--surface); opacity: .6; border-radius: inherit;
}

/* --- روابط التنقّل --- */
.nav-link { transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease); }
.nav-link:hover { background: var(--nav-hover); color: var(--nav-text-on); }
.nav-link.is-active { background: var(--nav-active); color: var(--nav-text-on); }
.nav-link.is-active .nav-link__icon { color: var(--nav-accent); }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .btn.is-loading::after { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* --- مجموعة هياكل التحميل --- */
.skeleton-group { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2) 0; }
.who__av--lg { width: 34px; height: 34px; flex: 0 0 34px; font-size: var(--fs-md); }
a.kpi { text-decoration: none; color: inherit; display: block; }

/* =====================================================================
   تطبيق التصميم المعتمد — يعيد تعريف المكوّنات القائمة بلغته البصرية
   ===================================================================== */

/* ---------- الشريط الجانبي ---------- */
.sidebar{
  width:268px; flex:0 0 268px;
  background:var(--c-brand-900);
  padding:28px 18px; gap:28px;
  display:flex; flex-direction:column;
}
.sidebar__brand{
  padding:10px 10px 20px; margin:0;
  border-bottom:1px solid rgba(147,164,165,.22);
  min-height:auto;
  display:flex; justify-content:center;      /* توسيط الشعار */
}
.sidebar__brand a{ display:inline-flex; width:auto; }
.sidebar__logo{ width:160px; height:auto; max-width:100%; display:block; }
.sidebar__nav{ padding:0; display:flex; flex-direction:column; gap:4px; flex:1; }
.sidebar__sec{
  font-size:12px; color:var(--c-brand-300);
  padding:0 12px 8px; margin:18px 0 0;
}
.sidebar__nav > .sidebar__sec:first-child{ margin-top:0; }
.nav-link{
  gap:12px; padding:12px 14px; border-radius:10px;
  color:#C3CFD7; font-size:15px; margin-bottom:0;
}
.nav-link:hover{ background:rgba(255,255,255,.07); color:#fff; }
.nav-link.is-active{
  background:var(--c-brand-700); color:#fff; font-weight:500; box-shadow:none;
}
.nav-link.is-active .nav-link__icon{ color:#fff; }
.nav-link__icon{ width:20px; height:20px; flex:0 0 20px; opacity:1; }
.nav-link__badge{
  min-width:22px; height:22px; padding:0 6px; border-radius:11px;
  background:var(--c-brand-500); color:#fff; font-size:12px;
}
.sidebar__foot{
  margin-top:auto; padding:18px 12px 0;
  border-top:1px solid rgba(147,164,165,.22);
  font-size:12px; color:var(--c-brand-300);
}

/* ---------- الشريط العلوي ---------- */
.topbar{
  height:78px; background:var(--surface);
  border-bottom:1px solid var(--line);
  padding:0 32px; gap:24px;
}
.topbar__toggle{ border:0; background:transparent; }
.search input{
  height:46px; border-radius:12px; padding:0 44px 0 16px;
  border:1px solid var(--c-n-300); background:var(--surface);
  font-size:15px; box-shadow:none;
}
.search input:focus{ border-color:var(--c-brand-700); box-shadow:0 0 0 3px rgba(37,101,120,.14); }
.search__icon{ inset-inline-end:16px; }
.icon-btn{
  width:44px; height:44px; border-radius:12px;
  background:transparent; border:0; box-shadow:none; color:var(--text);
}
.icon-btn:hover{ background:#EAF1F4; color:var(--text); }
.icon-btn__dot{ inset-block-start:10px; inset-inline-start:11px; border:2px solid #fff; }
.avatar, .topbar .usr__av{
  width:44px; height:44px; border-radius:50%;
  background:var(--c-brand-700); color:#fff;
  font-size:17px; font-weight:600;
}

/* ---------- شريط التبويبات (مبدّل العرض) ---------- */
.viewbar{
  background:var(--surface); border-bottom:1px solid var(--line);
  margin:0 -32px 20px; padding:10px 32px;
  gap:16px; align-items:center;
}
.viewbar__group{ border:0; background:transparent; box-shadow:none; gap:6px; }
.viewbar__btn{
  padding:10px 20px; border-radius:22px; border:0;
  color:var(--text-2); font-size:15px; font-weight:400;
}
.viewbar__btn:hover{ color:var(--c-brand-900); background:#EAF1F4; }
.viewbar__btn.is-on{
  background:var(--c-brand-050); color:var(--c-brand-900); font-weight:500;
}

/* ---------- البطاقات ---------- */
.card, .panel, .kpi, .col{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--r-lg);
  box-shadow:none;
}
.panel, .kpi{ padding:20px 22px; }
.kpi:hover, .card:hover, .panel:hover{ box-shadow:none; transform:none; }
.panel__head, .card__head{ margin-bottom:14px; }
.panel__title, .card__title{ font-size:16px; font-weight:600; }

/* ---------- بطاقة المؤشر ---------- */
.kpi__top{ margin-bottom:14px; }
.kpi__ic{
  width:32px; height:32px; border-radius:9px;
  background:var(--c-brand-050); color:var(--c-brand-700);
}
.kpi__label{ font-size:15px; font-weight:500; color:var(--text); }
.kpi__value{ font-size:34px; font-weight:600; letter-spacing:0; }
.kpi__foot{ gap:8px; font-size:12px; color:var(--text-3); margin-top:14px; }
.kpi__note{ font-size:12px; }
.chip{ border-radius:6px; padding:3px 8px; font-size:12px; font-weight:500; direction:ltr; }
.chip--up{ background:var(--ok-bg); color:var(--ok); }
.chip--down{ background:var(--danger-bg); color:var(--danger); }
.kpi--ok .kpi__ic, .kpi--warn .kpi__ic, .kpi--danger .kpi__ic{
  background:var(--c-brand-050); color:var(--c-brand-700);
}

/* ---------- المؤشر نصف الدائري ---------- */
.gauge__track{ stroke:var(--c-brand-050); stroke-width:20; }
.gauge__fill{ stroke:var(--c-brand-700); stroke-width:20; }
.gauge__value{ font-size:36px; font-weight:600; }
.gauge__cap{ font-size:12px; }
.metrics li{ font-size:14px; border-top:0; padding:7px 0; }
.metrics__v{ font-weight:600; }

/* ---------- الجداول ---------- */
.data thead th{
  text-align:start; font-weight:400; font-size:12px; color:var(--text-3);
  padding:10px 12px; background:transparent;
  border-top:1px solid var(--line); border-bottom:1px solid var(--line);
  white-space:nowrap; border-radius:0;
}
.data td{ padding:13px 12px; border-bottom:1px solid var(--line-soft); color:var(--text-2); }
.data tbody tr:hover{ background:#F7FAFC; }
.data td:first-child{ color:var(--text); }
.who__av{
  width:28px; height:28px; border-radius:50%;
  background:var(--c-brand-050); color:var(--c-brand-700);
  font-size:12px; font-weight:600;
}
.badge{ padding:4px 12px; border-radius:12px; font-size:12px; font-weight:500; }
.badge--done{ background:var(--ok-bg); color:var(--ok); }
.badge--progress, .badge--hold{ background:var(--warn-bg); color:var(--warn); }
.badge--late{ background:var(--danger-bg); color:var(--danger); }
.badge--new{ background:var(--c-brand-050); color:var(--c-brand-700); }

/* ---------- الأزرار ---------- */
.btn{
  height:42px; padding:0 18px; border-radius:21px;
  border:1px solid var(--c-n-300); background:var(--surface);
  font-size:14px; font-weight:500; box-shadow:none;
}
.btn:hover{ background:#EAF1F4; }
.btn--primary{
  background:var(--c-brand-700); border-color:var(--c-brand-700); color:#fff; box-shadow:none;
}
.btn--primary:hover{ background:var(--c-brand-900); }

/* ---------- المحتوى ---------- */
.content{ padding:26px 32px 32px; }
.page-head h1{ font-size:22px; font-weight:600; letter-spacing:0; }
.bar__fill{ border-radius:5px; }
.bar{ height:10px; border-radius:5px; background:var(--line-soft); }

@media (max-width:900px){
  .sidebar{ width:100%; flex:1 1 auto; }
  .topbar{ height:auto; padding:14px 16px; flex-wrap:wrap; }
  .content{ padding:20px 16px 24px; }
  .viewbar{ margin-inline:-16px; padding-inline:16px; }
}
.nav-link .grow{ flex-grow:1; }
.kpi__value{ display:flex; align-items:baseline; gap:8px; }
.kpi__value strong{ font-size:34px; font-weight:600; line-height:1; }
.kpi__value span{ font-size:14px; font-weight:400; color:var(--text-3); }

/* --- تصحيح: متغيّرات الأزرار يجب أن تأتي بعد القاعدة الجديدة --- */
.btn--sm{
  height:32px; padding:0 14px; font-size:13px; border-radius:16px;
}
.btn--ok{
  background:var(--ok-bg); border-color:transparent; color:var(--ok); font-weight:600;
}
.btn--ok:hover{ background:var(--ok); color:#fff; }
.btn--block{ width:100%; }
.btn--danger{ background:var(--danger-bg); border-color:transparent; color:var(--danger); }
.btn--danger:hover{ background:var(--danger); color:#fff; }

/* وسم المهام التي لم يحن موعد بدئها */
.soon{
  display:inline-block; font-size:11px; font-weight:500;
  padding:2px 8px; border-radius:10px;
  background:var(--c-brand-050); color:var(--c-brand-700);
}

/* ===================== المهام الإدارية والحملات ===================== */

/* شارة المهمة الإدارية — لون مختلف صراحةً عن شارات الحالة */
.adminbadge{
  display:inline-flex; align-items:center; gap:5px;
  font-size:11px; font-weight:600; padding:3px 9px; border-radius:12px;
  background:#EFE6D6; color:#7A4F00; border:1px solid #E0CFAE;
  white-space:nowrap;
}
.adminbadge--lg{ font-size:12px; padding:4px 12px; }
.adminbadge svg{ width:12px; height:12px; }

/* البطاقة الإدارية على اللوحة: شريط جانبي مميّز */
.tcard[data-type="admin"]{ border-inline-start:3px solid #C89A3C; }
.data tr:has(.adminbadge) td:first-child{ box-shadow:inset 3px 0 0 #C89A3C; }

/* اختيار نوع المهمة */
.ttype{ display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:10px; }
.ttype__opt input{ position:absolute; opacity:0; pointer-events:none; }
.ttype__box{
  display:block; padding:12px 14px; border:1px solid var(--line);
  border-radius:var(--r-md); cursor:pointer; transition:.15s;
}
.ttype__box strong{ display:flex; align-items:center; gap:6px; font-size:.88rem; }
.ttype__box small{ display:block; color:var(--text-3); font-size:.75rem; margin-top:3px; }
.ttype__opt:hover .ttype__box{ border-color:var(--c-brand-300); }
.ttype__opt input:checked + .ttype__box{
  border-color:var(--c-brand-700); background:var(--c-brand-050);
}
.ttype__opt--admin input:checked + .ttype__box{
  border-color:#C89A3C; background:#FBF4E7;
}

/* وسم المنصة */
.ptag{
  display:inline-block; font-size:11px; font-weight:600;
  padding:3px 9px; border-radius:12px; margin-inline-end:4px;
  background:color-mix(in srgb, var(--pc) 14%, transparent);
  color:var(--pc); border:1px solid color-mix(in srgb, var(--pc) 30%, transparent);
}

/* شبكة اختيار المنصات */
.pgrid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px; }
.pcheck input{ position:absolute; opacity:0; pointer-events:none; }
.pcheck__box{
  display:flex; align-items:center; gap:8px; padding:10px 12px;
  border:1px solid var(--line); border-radius:var(--r-md);
  cursor:pointer; font-size:.84rem; transition:.15s;
}
.pcheck__dot{ width:10px; height:10px; border-radius:50%; background:var(--pc); flex:0 0 10px; }
.pcheck:hover .pcheck__box{ border-color:var(--c-brand-300); }
.pcheck input:checked + .pcheck__box{
  border-color:var(--pc); background:color-mix(in srgb, var(--pc) 8%, transparent); font-weight:600;
}

/* قوائم الملفات */
.filelist{ display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.fitem{
  display:inline-flex; align-items:center; gap:5px; font-size:.76rem;
  padding:4px 10px; border-radius:12px; background:var(--surface-2); color:var(--text-2);
}
.fitem--bad{ background:var(--danger-bg); color:var(--danger); }
.flist{ display:flex; flex-direction:column; gap:8px; }
.frow{
  display:flex; align-items:center; gap:10px; padding:9px 11px;
  border:1px solid var(--line-soft); border-radius:var(--r-md);
}
.frow__ic{ color:var(--c-brand-700); display:flex; }
.frow__n{ flex:1; min-width:0; font-size:.84rem; overflow:hidden; text-overflow:ellipsis; }
.frow__n small{ display:block; font-size:.72rem; }

.req{ color:var(--danger); }

/* ===================== النوافذ المنبثقة ===================== */
.modal{ position:fixed; inset:0; z-index:200; display:grid; place-items:center; padding:16px; }
.modal[hidden]{ display:none; }
.modal__backdrop{ position:absolute; inset:0; background:rgba(26,42,57,.5); }
.modal__box{
  position:relative; background:var(--surface); border-radius:var(--r-lg);
  width:min(620px,100%); max-height:90vh; overflow-y:auto; box-shadow:0 24px 60px rgba(26,42,57,.3);
}
.modal__head{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 22px; border-bottom:1px solid var(--line);
}
.modal__head h2{ font-size:16px; font-weight:600; margin:0; }
.modal__x{ border:0; background:transparent; font-size:26px; line-height:1; color:var(--text-3); cursor:pointer; }
.modal__x:hover{ color:var(--text); }
.modal__body{ padding:18px 22px; }
.modal__foot{
  display:flex; gap:10px; padding:16px 22px; border-top:1px solid var(--line);
  background:var(--surface-2); border-radius:0 0 var(--r-lg) var(--r-lg);
}
.alert--warn{ background:var(--warn-bg); color:var(--warn); border:1px solid #EAD6A6; }
.alert--info{ background:var(--info-bg); color:var(--info); border:1px solid #C9DCEC; }

.pcheck__box > span{ line-height:1.4; }

/* ===================== شرح منبثق بعلامة استفهام ===================== */

.hintbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:17px; height:17px; padding:0; margin-inline-start:5px;
  border:0; background:transparent; color:var(--text-3);
  cursor:help; vertical-align:-3px; position:relative;
}
.hintbtn:hover, .hintbtn:focus-visible{ color:var(--c-brand-700); outline:none; }
.hintbtn svg{ width:15px; height:15px; }

/* الفقاعة */
.hintbtn::after{
  content:attr(data-hint);
  position:absolute; inset-block-end:calc(100% + 8px); inset-inline-start:50%;
  transform:translateX(50%) translateY(3px);
  min-width:180px; max-width:280px; width:max-content;
  background:var(--c-brand-900); color:#fff;
  font-size:.75rem; font-weight:400; line-height:1.6;
  padding:8px 11px; border-radius:10px; text-align:start;
  box-shadow:0 8px 24px rgba(26,42,57,.22);
  opacity:0; visibility:hidden; pointer-events:none;
  transition:opacity .15s ease, transform .15s ease, visibility .15s;
  z-index:120; white-space:normal;
}
/* السهم */
.hintbtn::before{
  content:""; position:absolute; inset-block-end:calc(100% + 3px); inset-inline-start:50%;
  transform:translateX(50%) translateY(3px);
  border:5px solid transparent; border-block-start-color:var(--c-brand-900);
  opacity:0; visibility:hidden; transition:inherit; z-index:121;
}
.hintbtn:hover::after, .hintbtn:hover::before,
.hintbtn:focus-visible::after, .hintbtn:focus-visible::before{
  opacity:1; visibility:visible; transform:translateX(50%) translateY(0);
}

/* قرب حافة الشاشة: تُزاح الفقاعة للداخل */
.hintbtn[data-side="start"]::after{ inset-inline-start:auto; inset-inline-end:-6px; transform:translateY(3px); }
.hintbtn[data-side="start"]:hover::after,
.hintbtn[data-side="start"]:focus-visible::after{ transform:translateY(0); }

@media (max-width:560px){
  .hintbtn::after{ min-width:150px; max-width:210px; }
}
@media (prefers-reduced-motion: reduce){
  .hintbtn::after, .hintbtn::before{ transition:none; }
}

/* لافتة: المهمة صادرة من شخص آخر (الإدارة عادةً) */
.frommgmt{
  display:inline-flex; align-items:center; gap:7px; margin-top:10px;
  font-size:.8rem; color:var(--c-brand-700);
  background:var(--c-brand-050); padding:7px 12px; border-radius:12px;
}
.frommgmt strong{ font-weight:600; }

/* حقل للقراءة فقط داخل النماذج */
.readonly{
  display:flex; align-items:center; gap:8px;
  min-height:44px; padding:0 14px;
  border:1px solid var(--line-soft); border-radius:12px;
  background:var(--surface-2); font-size:.88rem; color:var(--text);
}
.readonly .is-warn{ color:var(--danger); font-weight:500; }

/* ===================== مسار الموافقة ===================== */

.ttype__opt--flow input:checked + .ttype__box{
  border-color:var(--c-brand-700); background:var(--c-brand-050);
}
.flowbox[hidden]{ display:none; }
.flowpick{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.flowpick select{ flex:1; min-width:180px; }

.flowlist{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:7px; }
.flowitem{
  display:flex; align-items:center; gap:10px;
  padding:9px 12px; border:1px solid var(--line); border-radius:12px;
  background:var(--surface);
}
.flowitem__n{
  width:24px; height:24px; border-radius:50%; flex:0 0 24px;
  display:grid; place-items:center; font-size:.75rem; font-weight:700;
  background:var(--c-brand-700); color:#fff;
}
.flowitem__name{ flex:1; font-size:.86rem; }
.flowitem__acts{ display:flex; gap:4px; }
.flowbtn{
  width:26px; height:26px; border:1px solid var(--line); border-radius:7px;
  background:var(--surface); color:var(--text-2); font-size:.7rem; cursor:pointer;
  display:grid; place-items:center;
}
.flowbtn:hover:not(:disabled){ border-color:var(--c-brand-500); color:var(--c-brand-700); }
.flowbtn:disabled{ opacity:.35; cursor:not-allowed; }
.flowbtn--del:hover{ border-color:var(--danger); color:var(--danger); }
.flowempty{
  font-size:.8rem; color:var(--text-3); text-align:center;
  padding:14px; border:1px dashed var(--line); border-radius:12px;
}
.flowempty[hidden]{ display:none; }

/* ===================== خطوات المسار ===================== */

.fsteps{ list-style:none; margin:0 0 4px; padding:0; }
.fstep{ display:flex; gap:12px; padding-bottom:16px; position:relative; }
.fstep:not(:last-child)::before{
  content:""; position:absolute; inset-inline-start:13px; inset-block-start:28px;
  width:2px; height:calc(100% - 28px); background:var(--line);
}
.fstep__dot{
  width:28px; height:28px; border-radius:50%; flex:0 0 28px; z-index:1;
  display:grid; place-items:center; font-size:.75rem; font-weight:700;
  background:var(--surface-3); color:var(--text-3); border:2px solid var(--line);
}
.fstep__body{ display:flex; flex-direction:column; gap:2px; padding-top:3px; }
.fstep__body strong{ font-size:.87rem; }
.fstep__body small{ font-size:.75rem; color:var(--text-3); }
.fstep__note{
  margin-top:5px; font-size:.78rem; padding:6px 10px; border-radius:9px;
  background:var(--surface-2); color:var(--text-2);
}
.fstep--done .fstep__dot{ background:var(--ok-bg); color:var(--ok); border-color:var(--ok); }
.fstep--now  .fstep__dot{ background:var(--c-brand-700); color:#fff; border-color:var(--c-brand-700);
                          box-shadow:0 0 0 4px var(--c-brand-050); }
.fstep--now  .fstep__body strong{ color:var(--c-brand-700); }
.fstep--bad  .fstep__dot{ background:var(--danger-bg); color:var(--danger); border-color:var(--danger); }
.fstep--warn .fstep__dot{ background:var(--warn-bg); color:var(--warn); border-color:var(--warn); }

/* صندوق الإجراءات */
.facts{
  margin-top:14px; padding:14px 16px; border-radius:var(--r-md);
  background:var(--c-brand-050); border:1px solid var(--c-brand-200);
}
.facts__head{
  display:flex; align-items:flex-start; gap:8px; margin-bottom:12px;
  font-size:.85rem; color:var(--c-brand-800);
}
.facts .field{ margin-bottom:10px; }
.facts textarea{ background:var(--surface); }
.alert--danger{ background:var(--danger-bg); color:var(--danger); border:1px solid #EFC9C2; }

/* سجل الإجراءات */
.timeline__note{
  font-size:.78rem; color:var(--text-2); background:var(--surface-2);
  padding:6px 10px; border-radius:8px; margin-top:4px;
}

/* شارة مدير المنصة — تمييزه عن الموظفين */
.pbadge{
  display:inline-block; font-size:10.5px; font-weight:700;
  padding:2px 8px; border-radius:10px;
  background:var(--c-brand-700); color:#fff; letter-spacing:.2px;
}

/* ===================== مصفوفة الموارد والإجراءات ===================== */
.matrix th.matrix__h{ font-size:11px; text-align:center; white-space:nowrap; padding:8px 4px; }
.matrix td.matrix__c{ text-align:center; padding:6px 4px; }
.mcheck input{ position:absolute; opacity:0; width:0; height:0; }
.mcheck span{
  display:inline-block; width:20px; height:20px; border-radius:6px;
  border:1px solid var(--c-n-300); background:var(--surface); cursor:pointer;
  position:relative; transition:.12s;
}
.mcheck:hover span{ border-color:var(--c-brand-500); }
.mcheck input:checked + span{ background:var(--c-brand-700); border-color:var(--c-brand-700); }
.mcheck input:checked + span::after{
  content:""; position:absolute; inset-inline-start:6px; inset-block-start:2px;
  width:5px; height:10px; border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg);
}
.mcheck input:disabled + span{ opacity:.3; cursor:not-allowed; }

/* نافذة أعرض للنماذج، وعدّاد الفلاتر النشطة */
.modal__box--wide{ width:min(880px,100%); }
.fcount{
  display:inline-grid; place-items:center; min-width:18px; height:18px;
  padding:0 5px; margin-inline-start:6px; border-radius:9px;
  background:var(--c-brand-700); color:#fff; font-size:11px; font-weight:700;
}

/* ===================== صور الحسابات ===================== */

/* المقاس مضبوط بالـ CSS دائماً، فأي صورة مهما كان حجمها تُعرض مربّعة */
.who__av--img, .avatar--img {
  object-fit: cover; object-position: center; display: block; padding: 0;
}
.who__av--xl { width: 96px; height: 96px; flex: 0 0 96px; font-size: 2rem; }

.avatarbox { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.avatarbox__side { flex: 1; min-width: 240px; }
.avatarbox .field { margin-bottom: 10px; }

@media (max-width: 560px) {
  .avatarbox { justify-content: center; text-align: center; }
}

/* بطاقة الهوية داخل صفحة الحساب */
.idcard { display:flex; gap:16px; align-items:center; margin-bottom:18px; flex-wrap:wrap; }
.idcard__info { flex:1; min-width:180px; }
.idcard__name { font-weight:600; font-size:1.02rem; }
.idcard__acts { display:flex; gap:8px; align-items:center; margin:8px 0 4px; flex-wrap:wrap; }

/* الصورة نفسها زر: إطار عند المرور وأيقونة قلم في الزاوية */
.avatarpick { position:relative; display:inline-block; cursor:pointer; line-height:0; }
.avatarpick .avatar--lg { transition:filter .15s ease; }
.avatarpick:hover .avatar--lg { filter:brightness(.82); }
.avatarpick__edit {
  position:absolute; inset-block-end:-2px; inset-inline-start:-2px;
  width:26px; height:26px; border-radius:50%;
  display:grid; place-items:center;
  background:var(--c-brand-700); color:#fff; border:2px solid var(--surface);
}
.avatarpick__edit svg { width:13px; height:13px; }
.avatar--lg { width:72px; height:72px; font-size:1.6rem; }

/* ===================== بناء مسار الموافقة ===================== */

.wfbox[hidden]{ display:none; }
.flowitem[draggable]{ cursor:grab; }
.flowitem.is-dragging{ opacity:.45; }
.flowitem.is-over{ border-color:var(--c-brand-500); box-shadow:0 0 0 3px var(--c-brand-050); }
.soon{
  font-size:11px; padding:2px 7px; border-radius:8px;
  background:var(--danger-bg); color:var(--danger);
}

/* معاينة المسار الفعلي بعد إدراج نائب المدير */
.wfpreview{
  margin-top:14px; padding:12px 14px; border-radius:var(--r-md);
  background:var(--c-brand-050); border:1px solid var(--c-brand-200);
}
.wfpreview[hidden]{ display:none; }
.wfpreview__t{ font-size:.78rem; color:var(--c-brand-800); margin-bottom:8px; }
.wfchain{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.wfchain__item{
  font-size:.8rem; padding:5px 11px; border-radius:10px;
  background:var(--surface); border:1px solid var(--line); white-space:nowrap;
}
.wfchain__item--deputy{
  background:var(--c-brand-700); color:#fff; border-color:var(--c-brand-700); font-weight:600;
}
.wfchain__arrow{ color:var(--text-3); font-size:.9rem; }


/* ===================== توحيد تباعد اللوحة ===================== */
/* كانت البطاقات تأخذ 14px و16px وهوامش سطرية متفرقة، فبدت المسافات
   غير متساوية. مسافة واحدة تحكم الشبكات كلها والفواصل بينها. */
:root{ --gap-block: 16px; }

.kpi-row   { gap: var(--gap-block); margin-bottom: var(--gap-block); }
.dash-grid { gap: var(--gap-block); }
.grid      { gap: var(--gap-block); }

/* أي قسم يلي شبكة يأخذ المسافة نفسها، فلا حاجة لهوامش سطرية */
.dash-grid + .panel,
.dash-grid + .card,
.kpi-row  + .panel,
.kpi-row  + .card,
.grid     + .panel,
.grid     + .card,
.panel    + .panel,
.panel    + .card,
.card     + .card { margin-top: var(--gap-block); }

/* البطاقات داخل الشبكة بارتفاع موحّد فلا تتفاوت حوافها السفلية */
.dash-grid > .panel { height: 100%; }

/* ===================== زر الإشعارات ===================== */
.icon-btn{
  position: relative;
  border: 1px solid var(--line);
  color: var(--text-2);
}
.icon-btn:hover{
  background: var(--brand-050); color: var(--brand-700);
  border-color: var(--brand-300);
}
.icon-btn[aria-expanded="true"]{
  background: var(--brand-050); color: var(--brand-700); border-color: var(--brand-300);
}

/* العدّاد: رقم مقروء لا نقطة صامتة */
.icon-btn__dot{
  position: absolute; inset-block-start: -3px; inset-inline-end: -3px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 10px; border: 2px solid var(--surface);
  background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 1;
}

/* ===================== بطاقة طلب إشعارات المتصفح ===================== */
.notifask{
  position: fixed; inset-block-end: 20px; inset-inline-start: 20px; z-index: 900;
  width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: 16px 18px;
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.notifask.is-in{ opacity: 1; transform: translateY(0); }
.notifask__body strong{ display: block; font-size: .92rem; margin-bottom: 5px; }
.notifask__body span{ font-size: .82rem; color: var(--text-2); line-height: 1.6; }
.notifask__acts{ display: flex; gap: 8px; margin-top: 14px; }

/* رأس الصفحة يتبع المسافة الموحّدة أيضاً — كان 18px وحده */
.page-head{ margin-bottom: var(--gap-block); }

/* خطوات مرقّمة في صفحات الإرشاد */
.steps{ list-style:none; counter-reset:st; margin:0; padding:0; }
.steps li{
  counter-increment:st; position:relative;
  padding-inline-start:38px; padding-bottom:18px;
}
.steps li:last-child{ padding-bottom:0; }
.steps li::before{
  content:counter(st); position:absolute; inset-inline-start:0; inset-block-start:0;
  width:26px; height:26px; border-radius:50%;
  display:grid; place-items:center; font-size:.78rem; font-weight:700;
  background:var(--c-brand-700); color:#fff;
}
.steps li strong{ display:block; font-size:.9rem; margin-bottom:3px; }
.steps li span{ font-size:.82rem; color:var(--text-2); line-height:1.6; display:block; }

/* ===================== ضبط شكل اللوحة ===================== */

/* البطاقات تأخذ ارتفاع محتواها، فلا يبقى فراغ أسفل القليلة المحتوى */
.dash-grid{ align-items: stretch; }
.dash-grid > .panel{ display: flex; flex-direction: column; }
.dash-grid > .panel > .rank,
.dash-grid > .panel > .orglist{ flex: 1; }

/* صفوف الترتيب: مسافات متساوية ولا تتباعد عند قلة العناصر */
.rank{ display: flex; flex-direction: column; gap: 14px; }
.rank__row{ display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.rank__name{ display: flex; align-items: center; gap: 8px; font-size: .86rem; min-width: 0; }
.rank__name > span:last-child{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__pct{ font-size: .82rem; color: var(--text-2); font-weight: 600; }
.rank__bar{ grid-column: 1 / -1; }
.rank__meta{ grid-column: 1 / -1; font-size: .74rem; color: var(--text-3); }

/* مؤشر الأداء: تقليل الفراغ حوله */
.panel--gauge .gauge{ margin: 2px auto 10px; }
.panel--gauge .orgrow{ padding: 9px 0; }

/* صفوف المنظمة: ارتفاع موحّد */
.orgrow{ display: flex; align-items: center; gap: 10px; padding: 11px 0; }
.orgrow + .orgrow{ border-top: 1px solid var(--line-soft); }
.orgrow__k{ flex: 1; font-size: .85rem; color: var(--text-2); }


/* ===================== محاذاة موحّدة للوحة ===================== */
/*
 * كانت بطاقات المؤشرات تُقسم على 4 أعمدة متساوية، والشبكة تحتها على
 * عمودين (300px + الباقي). فلا تتحاذى الحواف رأسياً ويبدو التصميم مائلاً.
 * الآن الاثنتان على شبكة 4 أعمدة واحدة وفجوة واحدة، فكل حافة تقابل حافة.
 */
.kpi-row{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap-block);
  margin-bottom: var(--gap-block);
}

.dash-grid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas:
    "gauge trend trend trend"
    "org   rank  rank  rank";
  gap: var(--gap-block);
  align-items: stretch;
}

/* البطاقات تملأ خليتها كاملة فتتساوى أطوال الصف الواحد */
.dash-grid > .panel{ height: 100%; margin: 0; }

/* شاشات متوسطة: عمودان */
@media (max-width: 1100px){
  .kpi-row{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "gauge trend" "org rank";
  }
}

/* الجوال: عمود واحد */
@media (max-width: 760px){
  .kpi-row{ grid-template-columns: 1fr; }
  .dash-grid{
    grid-template-columns: 1fr;
    grid-template-areas: "gauge" "trend" "org" "rank";
  }
}

/* ===================== المشاريع ===================== */

/* شريط خطوات المعالج */
.wsteps{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:var(--gap-block); }
.wstep{
  display:flex; align-items:center; gap:7px; padding:8px 12px;
  border:1px solid var(--line); border-radius:11px; background:var(--surface);
  font-size:.8rem; color:var(--text-2); text-decoration:none; white-space:nowrap;
}
a.wstep:hover{ border-color:var(--c-brand-500); color:var(--c-brand-700); }
.wstep__n{
  width:21px; height:21px; border-radius:50%; flex:0 0 21px;
  display:grid; place-items:center; font-size:.72rem; font-weight:700;
  background:var(--surface-3); color:var(--text-3);
}
.wstep.is-done .wstep__n{ background:var(--ok-bg); color:var(--ok); }
.wstep.is-now{ border-color:var(--c-brand-700); background:var(--c-brand-050); color:var(--c-brand-800); }
.wstep.is-now .wstep__n{ background:var(--c-brand-700); color:#fff; }
@media (max-width:760px){ .wstep__l{ display:none; } }

/* بطاقات المشاريع */
.pgrid-cards{
  display:grid; gap:var(--gap-block);
  grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
}
.pcard{
  display:block; text-decoration:none; color:inherit; overflow:hidden;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg);
  transition:border-color .15s, transform .15s;
}
.pcard:hover{ border-color:var(--c-brand-500); transform:translateY(-2px); }
.pcard__media{
  position:relative; height:132px; background:var(--surface-2);
  display:grid; place-items:center; color:var(--text-3);
}
.pcard__tag{
  position:absolute; inset-block-start:8px; inset-inline-start:8px;
  font-size:11px; padding:3px 8px; border-radius:8px;
  background:var(--surface); border:1px solid var(--line); color:var(--text-2);
}
.pcard__body{ padding:13px 15px 15px; }
.pcard__title{ font-weight:600; font-size:.95rem; margin-bottom:3px; }
.pcard__meta{ font-size:.8rem; color:var(--text-3); margin-bottom:9px; }
.pcard__row{ display:flex; gap:8px; align-items:center; margin-bottom:9px; font-size:.8rem; }
.pcard__stats{
  display:flex; gap:14px; font-size:.78rem; color:var(--text-3);
  border-top:1px solid var(--line-soft); padding-top:9px;
}

/* المستثمرون */
.invlist{ display:flex; flex-direction:column; gap:8px; }
.invrow{ display:grid; grid-template-columns:1.4fr 1fr 1fr auto; gap:8px; align-items:center; }
@media (max-width:640px){ .invrow{ grid-template-columns:1fr 1fr; } }

/* الطوابق والوحدات */
.floorbox{ border:1px solid var(--line); border-radius:var(--r-md); margin-bottom:10px; overflow:hidden; }
.floorbox__head{
  padding:9px 13px; background:var(--surface-2); font-size:.84rem; font-weight:600;
  display:flex; gap:9px; align-items:center;
}
.floorbox__head .muted{ font-weight:400; font-size:.78rem; margin-inline-start:auto; }
.unitgrid{
  display:grid; gap:8px; padding:12px 13px;
  grid-template-columns:repeat(auto-fill, minmax(150px, 1fr));
}
.unitcell{ display:flex; flex-direction:column; gap:5px; }
.unitcell__no{ font-size:.8rem; font-weight:600; }
.unitcell--view{
  border:1px solid var(--line-soft); border-radius:10px; padding:9px 11px;
  background:var(--surface-2);
}

/* شبكة الصور */
.imggrid{ display:grid; gap:10px; grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); }
.imggrid__item{ position:relative; aspect-ratio:4/3; border-radius:11px; overflow:hidden;
                border:1px solid var(--line); }
.imggrid__item img{ width:100%; height:100%; object-fit:cover; display:block; }
.imggrid__x{
  position:absolute; inset-block-start:5px; inset-inline-start:5px;
  width:24px; height:24px; border-radius:50%; border:none; cursor:pointer;
  background:rgba(0,0,0,.55); color:#fff; font-size:.72rem;
}

/* ===================== طلبات الشراء ===================== */

/* الشريط الزمني للحالة */
.prtrack{
  display:flex; list-style:none; margin:0; padding:0; gap:0;
  overflow-x:auto; padding-bottom:6px;
}
.prtrack__i{
  flex:1; min-width:96px; position:relative;
  display:flex; flex-direction:column; align-items:center; gap:7px;
  font-size:.72rem; color:var(--text-3); text-align:center;
}
.prtrack__i::before{
  content:''; position:absolute; inset-block-start:7px;
  inset-inline-start:50%; width:100%; height:2px; background:var(--line);
}
.prtrack__i:last-child::before{ display:none; }
.prtrack__d{
  width:16px; height:16px; border-radius:50%; position:relative; z-index:1;
  background:var(--surface); border:2px solid var(--line);
}
.prtrack__i.is-done .prtrack__d{ background:var(--ok); border-color:var(--ok); }
.prtrack__i.is-done::before{ background:var(--ok); }
.prtrack__i.is-done{ color:var(--text-2); }
.prtrack__i.is-now .prtrack__d{
  background:var(--c-brand-700); border-color:var(--c-brand-700);
  box-shadow:0 0 0 4px var(--c-brand-050);
}
.prtrack__i.is-now{ color:var(--c-brand-800); font-weight:600; }

/* صف العرض المعتمد */
tr.is-selected{ background:var(--ok-bg); }

/* قائمة قابلة للطي داخل البطاقات */
details > summary{ cursor:pointer; list-style:none; display:inline-flex; }
details > summary::-webkit-details-marker{ display:none; }

/* شريط خيارات ثلاثي — يتبع / منح / منع */
.segbar{ display:inline-flex; border:1px solid var(--line); border-radius:9px; overflow:hidden; }
.seg{ cursor:pointer; }
.seg input{ position:absolute; opacity:0; pointer-events:none; }
.seg span{
  display:block; padding:5px 11px; font-size:.78rem; color:var(--text-2);
  border-inline-start:1px solid var(--line); white-space:nowrap;
}
.seg:first-child span{ border-inline-start:none; }
.seg input:checked + span{ background:var(--c-brand-700); color:#fff; font-weight:600; }
.seg input[value="deny"]:checked + span{ background:var(--danger); }
