/* ============================================================================
   منصة قيادة مشاريع الولاية — باتنة (05)
   نظام التصميم v3.0 — «هوية حكومية عصرية»
   أسس: بطاقات ملونة، شارات واضحة، أزرق حكومي عميق + ذهبي رسمي، RTL كامل
   ========================================================================== */

/* ---------- الخطوط ---------- */
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-800.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}

/* ---------- المتغيرات ---------- */
:root {
  /* الأزرق الحكومي */
  --navy-950: #061F35;
  --navy-900: #0A2E4E;
  --navy-800: #0D3A61;
  --navy-700: #12507E;
  --navy-600: #17619B;
  --navy-500: #1B7EC2;
  --blue-50:  #EAF3FB;
  --blue-100: #D5E7F6;
  --blue-200: #A9CFEC;

  /* الذهبي الرسمي */
  --gold:      #C9A227;
  --gold-dark: #A8861B;
  --gold-soft: #F5EBCE;

  /* الأسطح والنصوص */
  --bg:        #F2F5F9;
  --surface:   #FFFFFF;
  --surface-2: #F8FAFC;
  --border:    #E3E9F0;
  --border-2:  #CFD9E4;
  --ink:       #16283B;
  --muted:     #5B7085;
  --muted-2:   #8CA0B3;

  /* ألوان الحالة */
  --green-600: #16A34A; --green-100: #E3F6EC; --green-700: #15803D;
  --amber-600: #D97706; --amber-100: #FCEFDD; --amber-700: #B45309;
  --red-600:   #DC2626; --red-100:   #FDE9E9; --red-700:   #B91C1C;
  --violet-600:#7C3AED; --violet-100:#EFE8FD; --violet-700:#6D28D9;
  --teal-600:  #0D9488; --teal-100:  #E0F5F2; --teal-700:  #0F766E;
  --sky-600:   #0284C7; --sky-100:   #E0F2FE; --sky-700:   #0369A1;
  --slate-600: #64748B; --slate-100: #EDF1F5; --slate-700: #475569;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(10, 46, 78, .05), 0 1px 3px rgba(10, 46, 78, .07);
  --shadow-2: 0 4px 14px rgba(10, 46, 78, .09);
  --shadow-3: 0 12px 34px rgba(10, 46, 78, .16);
  --sidebar-w: 264px;
  --font: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---------- إعادة الضبط ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* إخفاء حقيقي: أي عنصر يحمل [hidden] يُخفى مهما كان عرضه (flex/grid) */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .35rem; line-height: 1.3; font-weight: 800; }
p { margin: 0 0 .6rem; }
a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--navy-500); }
svg { display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
.ltr-input { direction: ltr; text-align: left; }
.num { font-feature-settings: 'tnum'; letter-spacing: .2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C3CFDB; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #A9B9C9; }

/* ============================================================================
   الهيكل العام: الشريط الجانبي + المنطقة الرئيسية
   ========================================================================== */
.app-body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 34%, var(--navy-800) 100%);
  color: #EAF2F9;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 60;
}
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), #E3C766 55%, var(--navy-800));
  position: sticky;
  top: 0;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-emblem { width: 46px; height: 46px; flex: 0 0 auto; }
.brand-text strong { display: block; font-size: 1.02rem; font-weight: 800; letter-spacing: .2px; }
.brand-text small { color: #AFC6D8; font-size: .8rem; }
.brand-text small em {
  font-style: normal;
  background: rgba(201,162,39,.16);
  color: #E8CE79;
  border: 1px solid rgba(201,162,39,.45);
  border-radius: 6px;
  padding: 0 6px;
  margin-inline-start: 4px;
  font-size: .72rem;
}

.side-nav { flex: 1; padding: 10px 12px 16px; }
.nav-group { margin-bottom: 10px; }
.nav-group-title {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #7D99B2;
  padding: 12px 10px 6px;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 10px;
  color: #D5E3EF;
  font-weight: 500;
  font-size: .93rem;
  position: relative;
  transition: background .18s, color .18s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
}
.nav-link svg { width: 21px; height: 21px; fill: currentColor; opacity: .85; flex: 0 0 auto; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active {
  background: linear-gradient(90deg, rgba(27,126,194,.28), rgba(27,126,194,.12));
  color: #fff;
  font-weight: 700;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -12px;
  top: 15%;
  height: 70%;
  width: 4px;
  border-radius: 4px;
  background: var(--gold);
}
.nav-count {
  font-style: normal;
  margin-inline-start: auto;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.14);
  color: #CFE1F0;
  border-radius: 999px;
  font-size: .7rem;
  min-width: 26px;
  text-align: center;
  padding: 1px 7px;
}
.nav-link.active .nav-count { background: rgba(201,162,39,.2); border-color: rgba(201,162,39,.5); color: #F0DDA4; }

.side-foot { padding: 10px 12px 18px; border-top: 1px solid rgba(255,255,255,.09); }
.logout-btn { color: #F1B9B9; }
.logout-btn:hover { background: rgba(220,38,38,.18); color: #FFD9D9; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 31, 53, .55);
  z-index: 55;
  backdrop-filter: blur(2px);
}

/* ---------- المنطقة الرئيسية ---------- */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 60px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.menu-toggle { display: none; }

.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .86rem; color: var(--muted); min-width: 0; }
.breadcrumb .crumb { color: var(--muted); }
.breadcrumb .crumb-sep { color: var(--muted-2); font-size: .75rem; }
.breadcrumb .crumb.current { color: var(--ink); font-weight: 700; }
.breadcrumb a.crumb:hover { text-decoration: underline; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: background .15s, color .15s, border-color .15s;
  flex: 0 0 auto;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-btn:hover { background: var(--surface-2); color: var(--navy-700); border-color: var(--border-2); }

.bell-btn .bell-badge {
  position: absolute;
  top: -6px;
  inset-inline-start: -6px;
  background: var(--red-600);
  color: #fff;
  border-radius: 999px;
  min-width: 19px;
  height: 19px;
  font-size: .68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--surface);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
  user-select: none;
}
.user-chip:hover { border-color: var(--navy-400, var(--primary)); }
.chip-caret { width: 15px; height: 15px; color: var(--muted); flex: none; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy-700), var(--navy-500));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .95rem;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* قائمة حساب المستخدم المنسدلة (v3.5) */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(7, 26, 48, .18);
  padding: 6px;
  z-index: 900;
}
.user-menu a,
.user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: start;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}
.user-menu a:hover,
.user-menu button:hover { background: var(--surface-2); }
.user-menu button { color: var(--red-600); }
.user-meta strong { display: block; font-size: .84rem; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: .72rem; }

.content { padding: 24px 26px 46px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* ============================================================================
   الأزرار
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: filter .15s, background .15s, box-shadow .15s, transform .06s;
  user-select: none;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-500));
  color: #fff;
  box-shadow: 0 3px 10px rgba(18, 80, 126, .28);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #241C05;
  box-shadow: 0 3px 10px rgba(201, 162, 39, .3);
}

.btn-light { background: var(--surface); color: var(--navy-800); border-color: var(--border-2); }
.btn-light:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }

.btn-success { background: var(--green-600); color: #fff; }

.btn-sm { padding: 6px 13px; font-size: .82rem; border-radius: 9px; }
.btn-xs { padding: 3px 10px; font-size: .74rem; border-radius: 8px; }
.btn-lg { padding: 12px 24px; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }

.btn .spinner,
.spinner {
  width: 17px; height: 17px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 42px; height: 42px; border-width: 4px; border-color: #CBDCF0; border-top-color: var(--navy-600); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   الشارات (Badges) والنقاط
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.b-green  { background: var(--green-100);  color: var(--green-700);  border-color: #BEE6CF; }
.b-amber  { background: var(--amber-100);  color: var(--amber-700);  border-color: #F3DBB2; }
.b-red    { background: var(--red-100);    color: var(--red-700);    border-color: #F5C2C2; }
.b-blue   { background: var(--blue-50);    color: var(--navy-700);   border-color: var(--blue-200); }
.b-violet { background: var(--violet-100); color: var(--violet-700); border-color: #DCCDF9; }
.b-teal   { background: var(--teal-100);   color: var(--teal-700);   border-color: #B4E4DE; }
.b-sky    { background: var(--sky-100);    color: var(--sky-700);    border-color: #B9E0F7; }
.b-slate  { background: var(--slate-100);  color: var(--slate-700);  border-color: #D5DDE6; }
.b-gold   { background: var(--gold-soft);  color: #7A6210;           border-color: #E4D39A; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 2px 9px;
  font-size: .74rem;
  font-weight: 600;
}
.chip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ============================================================================
   البطاقات العامة
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title h3 { font-size: 1.02rem; margin: 0; }
.card-title .sub { color: var(--muted); font-size: .8rem; font-weight: 500; }

/* ---------- بطاقات المؤشرات KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--kpi-color, var(--navy-500));
}
.kpi-icon {
  width: 50px; height: 50px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--kpi-bg, var(--blue-50));
  color: var(--kpi-color, var(--navy-500));
}
.kpi-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; }
.kpi-body { min-width: 0; }
.kpi-value { font-size: 1.5rem; font-weight: 800; line-height: 1.15; color: var(--ink); }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi-extra { font-size: .73rem; color: var(--muted-2); margin-top: 2px; }

/* ---------- بطاقات الجهات (المديريات/الدوائر/البلديات) ---------- */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 15px;
}
.unit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  position: relative;
  overflow: hidden;
}
.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: var(--uc-color, var(--navy-500));
}
.unit-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--uc-color, var(--navy-500)), var(--uc-soft, var(--blue-200)));
}
.unit-head { display: flex; align-items: center; gap: 12px; }
.unit-tile {
  width: 48px; height: 48px;
  border-radius: 13px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(135deg, var(--uc-dark, var(--navy-600)), var(--uc-color, var(--navy-500)));
  box-shadow: 0 3px 9px rgba(10, 46, 78, .22);
}
.unit-name { font-weight: 800; font-size: .97rem; line-height: 1.35; margin: 0; }
.unit-code { font-size: .7rem; color: var(--muted-2); font-weight: 600; letter-spacing: .4px; }

.unit-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 9px;
  font-size: .74rem;
  color: var(--muted);
  font-weight: 600;
}
.stat-pill strong { color: var(--ink); font-size: .88rem; }
.stat-pill.sp-green strong { color: var(--green-700); }
.stat-pill.sp-red strong { color: var(--red-700); }
.stat-pill.sp-amber strong { color: var(--amber-700); }
.stat-pill.sp-teal strong { color: #0D9488; } /* منجزة/مستلمة */

.unit-progress { display: flex; flex-direction: column; gap: 3px; }
.unit-progress .row { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); font-weight: 600; }

/* ---------- أشرطة التقدم ---------- */
.progress {
  height: 9px;
  background: #E7EDF3;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy-600), var(--navy-500));
  transition: width .5s ease;
}
.progress.p-green > i { background: linear-gradient(90deg, var(--green-700), var(--green-600)); }
.progress.p-amber > i { background: linear-gradient(90deg, var(--amber-700), var(--amber-600)); }
.progress.p-red > i   { background: linear-gradient(90deg, var(--red-700), var(--red-600)); }
.progress.thin { height: 5px; }

/* ---------- بطاقات المشاريع ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--pc-health, var(--navy-500));
  border-radius: var(--radius);
  padding: 17px 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  cursor: pointer;
  transition: transform .16s, box-shadow .16s;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.pc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pc-code {
  font-size: .68rem;
  font-weight: 700;
  color: var(--navy-700);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  padding: 2px 9px;
  border-radius: 7px;
  letter-spacing: .5px;
  direction: ltr;
}
.pc-title { font-size: .99rem; font-weight: 800; margin: 6px 0 2px; line-height: 1.45; }
.pc-owners { display: flex; gap: 6px; flex-wrap: wrap; }
.pc-progress-row { display: flex; align-items: center; gap: 10px; }
.pc-progress-row .pct { font-size: .84rem; font-weight: 800; min-width: 42px; text-align: left; direction: ltr; }
.pc-progress-row .bar { flex: 1; }
.pc-finance { display: flex; gap: 7px; flex-wrap: wrap; font-size: .73rem; color: var(--muted); }
.pc-finance span { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 9px; border-radius: 8px; }
.pc-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted-2); font-size: .73rem; border-top: 1px dashed var(--border); padding-top: 10px; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 640px; }
table.data th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #F6F9FC; }
table.data td.num, table.data th.num { direction: ltr; text-align: left; font-feature-settings: 'tnum'; }

/* ============================================================================
   النماذج والحقول
   ========================================================================== */
.field { margin-bottom: 15px; min-width: 0; }
.field > label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.field .hint { color: var(--muted-2); font-size: .73rem; margin-top: 4px; display: block; }
.field .req { color: var(--red-600); font-weight: 800; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-500);
  box-shadow: 0 0 0 3.5px rgba(27, 126, 194, .13);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 84px; resize: vertical; }
select { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.input-affix { position: relative; }
.input-affix .affix {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  font-size: .76rem;
  font-weight: 700;
  pointer-events: none;
}

.alert { border-radius: 11px; padding: 11px 15px; font-size: .86rem; font-weight: 600; margin-bottom: 14px; border: 1px solid; }
.alert-danger { background: var(--red-100); color: var(--red-700); border-color: #F3C4C4; }
.alert-success { background: var(--green-100); color: var(--green-700); border-color: #BEE6CF; }
.alert-info { background: var(--blue-50); color: var(--navy-700); border-color: var(--blue-200); }
.alert-warn { background: var(--amber-100); color: var(--amber-700); border-color: #F3DBB2; }

/* ============================================================================
   معالج إدراج المشروع (Wizard)
   ========================================================================== */
.wizard-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

.wizard-steps { display: flex; align-items: flex-start; margin-bottom: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 10px 8px; box-shadow: var(--shadow-1); overflow-x: auto; }
.wstep { flex: 1; min-width: 96px; text-align: center; position: relative; }
.wstep .wstep-dot {
  width: 42px; height: 42px;
  margin: 0 auto 7px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .95rem;
  background: var(--surface-2);
  border: 2px solid var(--border-2);
  color: var(--muted-2);
  position: relative;
  z-index: 2;
  transition: all .2s;
}
.wstep .wstep-label { font-size: .74rem; font-weight: 700; color: var(--muted-2); padding: 0 4px 8px; line-height: 1.35; }
.wstep::before {
  content: '';
  position: absolute;
  top: 21px;
  inset-inline-start: calc(-50% + 24px);
  inset-inline-end: calc(50% + 24px);
  height: 3px;
  background: var(--border);
  border-radius: 3px;
}
.wstep:first-child::before { display: none; }
.wstep.done .wstep-dot { background: var(--green-100); border-color: var(--green-600); color: var(--green-700); }
.wstep.done::before { background: var(--green-600); }
.wstep.current .wstep-dot {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-500));
  border-color: var(--navy-500);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(27,126,194,.16);
}
.wstep.current .wstep-label { color: var(--navy-800); }
.wstep.done .wstep-label { color: var(--green-700); }

.wizard-step-title { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.wizard-step-title .wz-ico {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--navy-700), var(--navy-500));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.wizard-step-title .wz-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.wizard-step-title h2 { font-size: 1.15rem; margin: 0; }
.wizard-step-title p { color: var(--muted); font-size: .8rem; margin: 0; }

.wizard-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

/* شريط الملخص الجانبي */
.wizard-summary { position: sticky; top: 84px; }
.ws-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .8rem; }
.ws-item span { color: var(--muted); }
.ws-item strong { text-align: left; max-width: 60%; }

.completion-ring { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.completion-ring svg { width: 54px; height: 54px; }
.completion-ring .pct-txt { font-size: .9rem; font-weight: 800; }

/* اختيار البطاقات (نمط الاختيار) */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pick-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 11px 13px;
  cursor: pointer;
  text-align: right;
  transition: all .15s;
  font-weight: 700;
  font-size: .84rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
}
.pick-card:hover { border-color: var(--navy-500); background: var(--blue-50); }
.pick-card.picked {
  border-color: var(--navy-500);
  background: var(--blue-50);
  box-shadow: 0 0 0 3px rgba(27,126,194,.14);
}
.pick-card.picked::after { content: '✓'; margin-inline-start: auto; color: var(--navy-600); font-weight: 800; }
.pick-tile {
  width: 34px; height: 34px;
  border-radius: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 800;
  flex: 0 0 auto;
}

/* قائمة مراجعة الحصص */
.lot-row { display: grid; grid-template-columns: 1fr 110px 110px 42px; gap: 9px; margin-bottom: 9px; align-items: center; }
.lot-row .lot-weight-total { font-size: .74rem; color: var(--muted); text-align: center; font-weight: 700; }

/* ============================================================================
   صفحة تفاصيل المشروع
   ========================================================================== */
.detail-hero {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800) 55%, var(--navy-700));
  border-radius: var(--radius);
  color: #EAF2F9;
  padding: 24px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.detail-hero::after {
  content: '';
  position: absolute;
  inset-inline-end: -70px;
  top: -70px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,39,.18), transparent 70%);
}
.detail-hero h2 { color: #fff; font-size: 1.3rem; margin: 8px 0 4px; }
.detail-hero .sub-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.detail-hero .badge { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }

.dual-progress { margin-top: 16px; display: grid; gap: 10px; }
.dual-progress .row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; font-size: .8rem; }
.dual-progress .row .lbl { color: #B9CEDF; font-weight: 700; }
.dual-progress .row .val { font-weight: 800; color: #fff; text-align: left; direction: ltr; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 11px; }
.info-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 14px;
}
.info-item .k { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; margin-bottom: 3px; }
.info-item .v { font-weight: 700; font-size: .9rem; }
.info-item .v.ltr { direction: ltr; text-align: left; }

.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border-2); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before {
  content: '';
  position: absolute;
  inset-inline-start: -21px;
  top: 5px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--navy-500);
}
.tl-item.tl-green::before { border-color: var(--green-600); }
.tl-item.tl-red::before { border-color: var(--red-600); }
.tl-item.tl-amber::before { border-color: var(--amber-600); }

/* v3.8: المراحل القانونية — دائرة رقمية لكل مرحلة جزئية في دورة الحياة */
.tl-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 25px; height: 25px; border-radius: 50%;
  font-size: .7rem; font-weight: 800; color: #fff; flex: none;
  box-shadow: 0 1px 3px rgba(22, 40, 59, .18);
}
.tl-item:has(.tl-num)::before { display: none; }
.tl-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.tl-date { color: var(--muted-2); font-size: .73rem; }

/* ============================================================================
   عناصر مساعدة عامة
   ========================================================================== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; }
.page-head .desc { color: var(--muted); font-size: .88rem; max-width: 640px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 14px;
  font-size: 1.05rem;
  font-weight: 800;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.section-title .st-ico {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--blue-50);
  color: var(--navy-700);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.section-title .st-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 9px 18px;
  font-weight: 700;
  font-size: .88rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--navy-700); border-bottom-color: var(--navy-500); }

.empty-state {
  text-align: center;
  padding: 54px 20px;
  color: var(--muted);
}
.empty-state .es-ico {
  width: 74px; height: 74px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px dashed var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
}
.empty-state .es-ico svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.empty-state h4 { margin-bottom: 6px; color: var(--ink); }

.skeleton { background: linear-gradient(90deg, #EDF2F7 25%, #F7FAFC 50%, #EDF2F7 75%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 9px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; }

.page-loader { text-align: center; padding: 90px 20px; color: var(--muted); }
.page-loader .spinner-lg { margin: 0 auto 16px; }

/* ============================================================================
   النوافذ والدرج والتنبيهات العائمة
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 31, 53, .52);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  width: min(640px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-3);
  animation: popIn .18s ease;
}
.modal.wide { width: min(860px, 96vw); }
@keyframes popIn { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 20px 22px; overflow-y: auto; }

.notif-drawer {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  bottom: 0;
  width: min(400px, 94vw);
  background: var(--surface);
  z-index: 95;
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
[dir="rtl"] .notif-drawer { animation-name: slideInRtl; }
@keyframes slideInRtl { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(6,31,53,.4); z-index: 94; }
.notif-drawer header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.notif-drawer header strong { flex: 1; }
.notif-list { flex: 1; overflow-y: auto; padding: 12px; }
.notif-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 9px;
  background: var(--surface);
}
.notif-item.unread { background: var(--blue-50); border-color: var(--blue-200); }
.notif-item .n-title { font-weight: 700; font-size: .87rem; margin-bottom: 3px; }
.notif-item .n-body { color: var(--muted); font-size: .79rem; }
.notif-item .n-time { color: var(--muted-2); font-size: .7rem; margin-top: 6px; }

.toast-stack {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(400px, 90vw);
}
.toast {
  background: var(--navy-900);
  color: #fff;
  border-radius: 13px;
  padding: 12px 18px;
  font-size: .87rem;
  font-weight: 600;
  box-shadow: var(--shadow-3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .25s ease;
  border-inline-start: 4px solid var(--navy-500);
}
.toast.t-success { border-inline-start-color: var(--green-600); }
.toast.t-error { border-inline-start-color: var(--red-600); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================================
   صفحة الدخول
   ========================================================================== */
.login-body { background: var(--bg); }
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-hero {
  background:
    radial-gradient(1100px 500px at -10% -10%, rgba(27,126,194,.35), transparent 55%),
    radial-gradient(800px 500px at 110% 110%, rgba(201,162,39,.16), transparent 55%),
    linear-gradient(160deg, var(--navy-950), var(--navy-900) 45%, var(--navy-800));
  color: #EAF2F9;
  position: relative;
  overflow: hidden;
  display: flex;
}
.login-hero-inner { position: relative; z-index: 2; margin: auto; padding: 52px 56px; max-width: 620px; }
.hero-emblem { width: 66px; height: 66px; margin-bottom: 20px; }
.login-hero h1 { font-size: 1.05rem; font-weight: 700; color: #C8DAE9; margin-bottom: 6px; }
.login-hero h2 { font-size: 2.1rem; color: #fff; font-weight: 800; }
.hero-code {
  display: inline-block;
  background: rgba(201,162,39,.16);
  border: 1px solid rgba(201,162,39,.5);
  color: #EFD98F;
  border-radius: 9px;
  padding: 0 10px;
  font-size: 1.3rem;
  vertical-align: middle;
  margin-inline-start: 8px;
}
.hero-app { font-size: 1.15rem; color: var(--gold-soft); font-weight: 700; margin-top: 4px; }
.hero-divider { width: 64px; height: 3px; background: var(--gold); border-radius: 3px; margin: 20px 0; }
.hero-points { list-style: none; padding: 0; margin: 0 0 26px; }
.hero-points li { padding: 7px 0 7px 26px; position: relative; color: #C9DAE8; font-size: .93rem; }
.hero-points li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 13px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: rgba(201,162,39,.15);
  border: 1.5px solid var(--gold);
}
.hero-foot { color: #86A2B8; font-size: .78rem; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; }
.hero-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 70% 30%, black, transparent 75%);
}

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 26px; }
.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
  padding: 34px 34px 28px;
}
.login-card-head { margin-bottom: 22px; }
.login-card-head h3 { font-size: 1.35rem; }
.login-card-head p { color: var(--muted); font-size: .85rem; margin: 0; }
.step-badge {
  display: inline-block;
  background: var(--gold-soft);
  color: #7A6210;
  border: 1px solid #E4D39A;
  font-size: .7rem;
  font-weight: 800;
  padding: 2px 11px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.login-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted-2);
  font-size: .74rem;
  margin-top: 18px;
}
.lock-ico { width: 14px; height: 14px; fill: var(--muted-2); }
.login-copy { color: var(--muted-2); font-size: .75rem; margin-top: 18px; }

.input-icon { position: relative; }
.input-icon > svg {
  position: absolute;
  inset-inline-end: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px; height: 19px;
  fill: #B7C6D4;
  pointer-events: none;
}
.input-icon input { padding-inline-end: 42px; }
.pass-toggle {
  position: absolute;
  inset-inline-start: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted-2);
  padding: 5px;
  border-radius: 7px;
}
.pass-toggle svg { width: 19px; height: 19px; fill: currentColor; }
.pass-toggle:hover { background: var(--surface-2); color: var(--muted); }
.otp-input {
  font-size: 1.6rem !important;
  letter-spacing: 14px;
  text-align: center;
  font-weight: 800;
  padding: 12px !important;
}

/* ============================================================================
   الاستجابة (Responsive)
   ========================================================================== */
@media (max-width: 1100px) {
  .wizard-layout { grid-template-columns: 1fr; }
  .wizard-summary { position: static; }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    transform: translateX(100%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-3);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 14px 40px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .user-chip .user-meta { display: none; }
  .page-head h1 { font-size: 1.2rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px; gap: 10px; }
  .kpi-icon { width: 40px; height: 40px; border-radius: 11px; }
  .kpi-value { font-size: 1.15rem; }
  .units-grid, .projects-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .lot-row { grid-template-columns: 1fr 90px 42px; }
  .lot-row .lot-pct { display: none; }
  .wizard-actions { flex-direction: column-reverse; }
  .wizard-actions .btn { width: 100%; }
  .detail-hero { padding: 18px; }
  .dual-progress .row { grid-template-columns: 105px 1fr 48px; gap: 8px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .grow { min-width: 0; }
}

/* الطباعة */
@media print {
  .sidebar, .topbar, .wizard-summary, .wizard-actions, .toolbar { display: none !important; }
  .content { padding: 0; }
  .card, .detail-hero { box-shadow: none; }
}

/* ================= v3.1: الجدولة التعاقدية وأوامر ODS والجهات المتدخلة ================= */
.btn-teal { background: #0D9488; color: #fff; border: 1px solid #0F766E; }
.btn-teal:hover { background: #0F766E; }
.btn-violet { background: #7C3AED; color: #fff; border: 1px solid #6D28D9; }
.btn-violet:hover { background: #6D28D9; }
.text-danger { color: var(--red-600, #DC2626) !important; font-weight: 700; }
.text-success { color: var(--green-600, #16A34A) !important; font-weight: 700; }

/* شريط الجدولة أعلى بطاقة المشروع */
.sch-chip {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px; padding: 7px 13px; min-width: 96px;
}
.sch-chip-k { font-size: .66rem; color: #9FB8CE; font-weight: 700; }
.sch-chip-v { font-size: .84rem; color: #fff; direction: ltr; text-align: right; }
.sch-chip.sch-start { border-color: #16A34A88; }
.sch-chip.sch-stop { border-color: #DC262688; background: #DC262622; }
.sch-chip.sch-ext { border-color: #D9770688; background: #D9770622; }
.sch-chip.sch-original { border-style: dashed; opacity: .85; }
.sch-chip.sch-original .sch-chip-v { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.sch-chip.sch-ok { border-color: #C9A227; background: #C9A22722; }
.sch-chip.sch-late { border-color: #DC2626; background: #DC262633; }
.info-item.sch-original-cell .v { text-decoration: line-through dotted; opacity: .8; }

/* ============================================================================
   لوحة مؤشرات الوالي (wb-*) — بطاقات مؤشرات + صحة + خط زمني + وضع تلفاز
   ========================================================================== */
.wb-filters { margin-bottom: 14px; }
.wb-filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.wb-filter-row .field { flex: 1 1 170px; min-width: 150px; margin: 0; }
.wb-scope-note { margin-top: 10px; font-size: .8rem; color: var(--muted); background: var(--bg-2, #F6F8FA); border-radius: 8px; padding: 7px 12px; }

/* بطاقات المؤشرات */
.wb-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.wb-kpi { position: relative; background: var(--card, #fff); border: 1px solid var(--border); border-radius: 12px; padding: 14px 12px 12px; text-align: center; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.wb-kpi-ico { font-size: 1.25rem; margin-bottom: 4px; }
.wb-kpi-val { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; line-height: 1.1; color: var(--navy-900, #16233A); }
.wb-kpi-label { font-size: .78rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.wb-kpi-sub { font-size: .7rem; color: var(--muted-2, #98A2B3); margin-top: 5px; }
.wb-kpi-danger { border-color: #F3B6B6; background: #FFF7F7; }
.wb-kpi-danger .wb-kpi-val { color: #C0392B; }
.wb-kpi-click { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.wb-kpi-click:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(16,24,40,.12); }
.wb-kpi-active { outline: 3px solid var(--gold-500, #C9A227); outline-offset: -1px; }

/* شريط الصحة */
.wb-health { margin-bottom: 14px; }
.wb-health-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.wb-health-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; font-weight: 700; }
.wb-dot { display: inline-flex; align-items: center; gap: 5px; }
.wb-dot::before { content: ''; width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.wb-dot-green::before { background: #16A34A; }
.wb-dot-yellow::before { background: #D97706; }
.wb-dot-red::before { background: #DC2626; }
.wb-hbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--bg-2, #EDF1F5); }
.wb-hseg { height: 100%; }
.wb-hseg-green { background: #16A34A; }
.wb-hseg-yellow { background: #D97706; }
.wb-hseg-red { background: #DC2626; }
.wb-health-foot { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 9px; font-size: .78rem; color: var(--muted); font-weight: 600; }

/* الجهات الأكثر معاناة */
.wb-suffer { margin-bottom: 14px; }
.wb-suffer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.wb-suffer-chip { border: 1px solid #F1D2D2; background: #FDF6F6; color: inherit; border-radius: 10px; padding: 8px 12px; font-size: .78rem; cursor: pointer; transition: all .12s ease; text-align: right; }
.wb-suffer-chip:hover { background: #FBEAEA; border-color: #DC2626; }
.wb-suffer-chip .wb-suffer-nums { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.txt-red { color: #C0392B; font-weight: 800; }

/* شبكة بطاقات المشاريع */
.wb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.wb-project { border-inline-start: 5px solid #16A34A; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; display: flex; flex-direction: column; gap: 7px; }
.wb-project:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(16,24,40,.13); }
.wb-p-green { border-inline-start-color: #16A34A; }
.wb-p-yellow { border-inline-start-color: #D97706; }
.wb-p-red { border-inline-start-color: #DC2626; }
.wb-p-title { font-weight: 800; font-size: .95rem; line-height: 1.35; }
.wb-p-meta { font-size: .74rem; color: var(--muted-2, #98A2B3); }
.wb-p-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.wb-p-plabel { font-size: .72rem; color: var(--muted); min-width: 42px; font-weight: 700; }
.wb-p-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .72rem; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 7px; margin-top: auto; }

/* الخط الزمني الكتابي */
.wb-timeline { max-height: 65vh; overflow-y: auto; padding-inline-end: 4px; }
.wb-tl-head { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 14px; }
.wb-tl-head h3 { margin: 0 0 4px; }
.wb-tl-kpis { display: flex; gap: 10px 18px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.wb-tl-line { position: relative; padding-inline-start: 26px; }
.wb-tl-line::before { content: ''; position: absolute; inset-inline-start: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.wb-tl-ev { position: relative; padding: 0 0 16px; }
.wb-tl-dot { position: absolute; inset-inline-start: -26px; top: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .85rem; background: var(--card, #fff); border: 2px solid var(--border); z-index: 1; }
.wb-tl-date { font-size: .7rem; color: var(--muted-2, #98A2B3); font-weight: 700; }
.wb-tl-title { font-weight: 700; font-size: .88rem; margin-top: 2px; }
.wb-tl-detail { font-size: .78rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.tl-green .wb-tl-dot { border-color: #16A34A; }
.tl-red .wb-tl-dot { border-color: #DC2626; }
.tl-amber .wb-tl-dot { border-color: #D97706; }
.tl-blue .wb-tl-dot { border-color: #1B7EC2; }
.tl-teal .wb-tl-dot { border-color: #0D9488; }
.tl-violet .wb-tl-dot { border-color: #7C3AED; }
.wb-curated-sub { font-weight: 800; font-size: .85rem; margin: 14px 0 8px; color: var(--navy-700, #2C4A73); }

/* هاتف */
@media (max-width: 640px) {
  .wb-filter-row .field { flex-basis: 100%; }
  .wb-kpis { grid-template-columns: repeat(2, 1fr); }
  .wb-grid { grid-template-columns: 1fr; }
  .wb-health-foot { flex-direction: column; gap: 4px; }
}

/* وضع التلفاز: عرض كبير على شاشة الحائط أو الهاتف الملقّم */
body.wali-tv { background: #0F1B2D; }
body.wali-tv #sidebar { display: none; }
body.wali-tv .app-main { max-width: none; padding: 18px 26px; }
body.wali-tv .page-head h1 { color: #fff; font-size: clamp(1.4rem, 2.6vw, 2rem); }
body.wali-tv .page-head .desc { color: #B9C6DA; }
body.wali-tv .card, body.wali-tv .wb-kpi { background: #16233A; border-color: #2A3B57; }
body.wali-tv .wb-kpi-val { color: #fff; }
body.wali-tv .wb-kpi-label, body.wali-tv .wb-scope-note, body.wali-tv .wb-p-meta,
body.wali-tv .wb-health-foot, body.wali-tv .wb-kpi-sub { color: #B9C6DA; }
body.wali-tv .wb-kpi { padding: 20px 14px; }
body.wali-tv .wb-kpi-val { font-size: clamp(2rem, 4.5vw, 3.4rem); }
body.wali-tv .wb-kpi-label { font-size: clamp(.85rem, 1.4vw, 1.1rem); }
body.wali-tv .wb-kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; }
body.wali-tv .wb-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
body.wali-tv .wb-p-title { color: #fff; font-size: 1.02rem; }
body.wali-tv .wb-health-head strong, body.wali-tv .wb-suffer-chip strong { color: #fff; }
body.wali-tv .wb-suffer-chip { background: #1B2A44; border-color: #34486B; }
body.wali-tv .wb-scope-note { background: #1B2A44; }
body.wali-tv .wb-p-foot, body.wali-tv .wb-tl-date { color: #93A3BC; }
body.wali-tv .bar { background: #2A3B57; }
body.wali-tv select, body.wali-tv .btn-light { background: #1B2A44; border-color: #34486B; color: #E7EDF6; }
body.wali-tv .section-title { color: #fff; }

/* صفحة الملف الشخصي (v3.5) */
.profile-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: 1fr; }
}

/* بطاقات المتدخلين في الدليل (v3.6) */
.stake-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.stake-card {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px;
}
