/* صفحة مهام المشروع — تحديثات التنظيم (scripts/patch-project-tasks-page-v2.mjs).
   تعتمد على أنماط «مهماتي» (home-my-tasks.css) لشريط الأدوات ومربع الأرقام. */

/* التبويبات: شبكة أعمدتها متساوية، وكل صف بعدد ثابت من التبويبات. */
#root [data-feature="elegant-project-tabs-v1"] > div {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 6px !important;
}
#root [data-feature="elegant-project-tabs-v1"] button {
  width: 100%;
  min-width: 0;
  justify-content: flex-start !important;
  text-align: right;
  white-space: normal !important;
  line-height: 1.3;
}
@media (max-width: 640px) {
  #root [data-feature="elegant-project-tabs-v1"] > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* شريط الأدوات الموحد. */
#root .bpt-toolbar .bpt-help { color: #047857; border-color: #a7f3d0 !important; }
#root .bpt-toolbar .bpt-help:hover { background: #ecfdf5 !important; }
#root .bpt-toolbar .bpt-greg.is-active { background: #0f766e !important; border-color: #0f766e !important; color: #fff; }
#root .bpt-subjects { position: relative; flex: 1 1 100px; min-width: 0; }
#root .bpt-subjects-summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 30px;
}
#root .bpt-subjects-summary::-webkit-details-marker { display: none; }
#root .bpt-subjects > div { font-size: 12px; }

/* الأرقام: تسع خانات في مربع واحد، و«معلقة» بالأحمر. */
#root .bpt-stats { grid-template-columns: repeat(9, minmax(0, 1fr)); }
#root .bmt-stat.is-delayed { --c: #e11d48; --t: #fff1f2; }
#root .bmt-stat.is-suspended { --c: #dc2626; --t: #fee2e2; background: linear-gradient(180deg, #fee2e2, #fef2f2 85%); }
#root .bmt-stat.is-suspended .bmt-stat-label { color: #b91c1c; font-weight: 800; }
#root .bmt-stat .bpt-stat-icon { color: #dc2626; flex-shrink: 0; }
@media (max-width: 1100px) {
  #root .bpt-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #root .bpt-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* مراحل المشروع: تاريخا البداية والنهاية في سطر واضح. */
#root .bpt-stage-count { white-space: nowrap; }
#root .bpt-stage-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: #334155;
}
#root .bpt-stage-dates > span { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
#root .bpt-stage-dates b { font-weight: 700; color: #64748b; }

/* التاريخ المختصر (سطر واحد) والميلادي تحته عند التفعيل. */
#root .bpt-date-inline { display: inline-flex; flex-direction: column; line-height: 1.35; font-weight: 600; }
#root .bpt-date-inline small { font-size: 10px; font-weight: 400; color: #94a3b8; }

/* المهام اليومية: قائمة مضغوطة من عمود إلى ثلاثة أعمدة. */
#root [data-task-section="daily"] > div:first-child p { display: none; }
#root [data-task-section="daily"] .bpt-daily-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px !important;
}
#root .bpt-daily-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 6px 5px 8px;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
}
#root .bpt-daily-today {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 10px;
  font-weight: 700;
}
#root .bpt-daily-title { flex: 1 1 auto; min-width: 0; font-weight: 700; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#root .bpt-daily-owner,
#root .bpt-daily-scope { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; font-size: 11px; color: #6b7280; white-space: nowrap; }
#root .bpt-daily-owner svg { color: #a78bfa; }
#root .bpt-daily-done {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  height: 26px;
  padding: 0 9px;
  border-radius: 8px;
  background: #059669;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
#root .bpt-daily-done:hover { background: #047857; }
@media (max-width: 1280px) {
  #root [data-task-section="daily"] .bpt-daily-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  #root [data-task-section="daily"] .bpt-daily-list { grid-template-columns: minmax(0, 1fr); }
}

/* عمود المادة. */
#root .bpt-subject { font-weight: 700; color: #334155; }

/* تلوين صف المهمة كاملاً حسب حالتها (نفس لون شريط الحالة). */
#root tr.bpt-row > td:not(.bg-indigo-50\/60) { transition: background-color .15s; }
#root tr.bpt-row.is-done > td:not(.bg-indigo-50\/60) { background-color: #dcfce7 !important; }
#root tr.bpt-row.is-late > td:not(.bg-indigo-50\/60) { background-color: #fee2e2 !important; }
#root tr.bpt-row.is-active > td:not(.bg-indigo-50\/60) { background-color: #dbeafe !important; }
#root tr.bpt-row.is-missed > td:not(.bg-indigo-50\/60) { background-color: #e5e7eb !important; }
#root tr.bpt-row.is-suspended > td:not(.bg-indigo-50\/60) { background-color: #fecaca !important; }

/* نسبة إنجاز الخطة ونسبة التعثر: بطاقتان بارزتان بجانب «نشر خطة المهام». */
#root .bpt-rates { display: inline-flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
#root .bpt-rate {
  --c: #059669;
  --t: #ecfdf5;
  --b: #a7f3d0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--b);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--t), #fff);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
#root .bpt-rate.is-delay { --c: #e11d48; --t: #fff1f2; --b: #fecdd3; }
#root .bpt-rate-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--c);
  color: #fff;
  flex-shrink: 0;
}
#root .bpt-rate-icon svg { width: 16px; height: 16px; }
#root .bpt-rate-body { display: flex; flex-direction: column; gap: 4px; min-width: 92px; }
#root .bpt-rate-label { font-size: 12px; font-weight: 700; color: #334155; white-space: nowrap; }
#root .bpt-rate-bar { display: block; height: 4px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
#root .bpt-rate-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
#root .bpt-rate-value { font-size: 20px; line-height: 1; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; }

/* زر «قفل المهام» في ترويسة المشروع: واضح غير باهت. */
#root .bpt-lock-btn {
  background: #fff !important;
  color: #1e293b !important;
  border: 1px solid #fff !important;
  font-weight: 700 !important;
  opacity: 1 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .25) !important;
}
#root .bpt-lock-btn svg { color: #d97706 !important; opacity: 1 !important; }
#root .bpt-lock-btn:hover { background: #fffbeb !important; }

/* مربع التبويبات: خلفية خفيفة تميّزه عن بقية الصفحة. */
#root [data-feature="elegant-project-tabs-v1"] {
  background: linear-gradient(180deg, #eef2ff, #f5f3ff) !important;
  border-color: #c7d2fe !important;
  box-shadow: 0 1px 3px rgba(79, 70, 229, .08) !important;
}

/* تبويب «المستفيدون»: سطر صغير بالعدد وأيقونتَي الطباعة والتواصل بدل الشريط الكبير. */
#root .bpb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #eef2ff;
  background: #f8faff;
}
#root .bpb-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
#root .bpb-label { font-size: 14px; font-weight: 800; color: #312e81; }
#root .bpb-count { font-size: 12px; color: #64748b; }
#root .bpb-actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
#root .bpb-icon-btn,
#root .bpb-print > button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  border: 1px solid #c7d2fe !important;
  background: #fff !important;
  color: #4338ca !important;
  box-shadow: none !important;
}
#root .bpb-icon-btn:hover,
#root .bpb-print > button:hover { background: #eef2ff !important; }
#root .bpb-icon-btn:disabled { opacity: .45; cursor: not-allowed; }
#root .bpb-print { display: inline-flex; }
/* زر الطباعة يأتي بنص فقط؛ يُخفى النص وتظهر أيقونة طابعة. */
#root .bpb-print > button { font-size: 0 !important; color: transparent !important; }
#root .bpb-print > button::before {
  content: "";
  width: 16px;
  height: 16px;
  background: #0f766e;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9V2h12v7'/%3E%3Cpath d='M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2'/%3E%3Cpath d='M6 14h12v8H6z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9V2h12v7'/%3E%3Cpath d='M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2'/%3E%3Cpath d='M6 14h12v8H6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* اسم اليوم فوق التاريخ الهجري (صفحة المهام و«مهماتي»). */
#root .bmt-date-d { display: block; font-size: 11px; font-weight: 700; color: #6366f1; line-height: 1.3; }

/* لوحة الأرقام: أربع مجموعات متلاصقة في إطار واحد، وكل رقم يفتح قائمة مهامه. */
#root .bpt-board {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr 1fr 0.8fr;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
}
#root .bpt-board-group { --c: #4f46e5; --t: #eef2ff; display: flex; flex-direction: column; min-width: 0; border-inline-start: 1px solid #e2e8f0; }
#root .bpt-board-group:first-child { border-inline-start: 0; }
#root .bpt-board-group.is-done { --c: #059669; --t: #ecfdf5; }
#root .bpt-board-group.is-delay { --c: #e11d48; --t: #fff1f2; }
#root .bpt-board-group.is-remain { --c: #2563eb; --t: #eff6ff; }
#root .bpt-board-group.is-total { --c: #475569; --t: #f8fafc; }
#root .bpt-board-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 8px;
  background: var(--t);
  text-align: right;
  cursor: pointer;
  transition: filter .15s;
}
#root .bpt-board-head:hover { filter: brightness(.97); }
#root .bpt-board-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
#root .bpt-board-label { font-size: 13px; font-weight: 800; color: #1e293b; white-space: nowrap; }
#root .bpt-board-value { font-size: 24px; line-height: 1; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; }
#root .bpt-board-bar { display: block; height: 5px; border-radius: 999px; background: rgb(15 23 42 / 8%); overflow: hidden; }
#root .bpt-board-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
#root .bpt-board-sub { font-size: 11px; color: #64748b; }
#root .bpt-board-items { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); flex: 1; border-top: 1px solid #e2e8f0; }
#root .bpt-board-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 8px 4px;
  border-inline-start: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background .15s;
}
#root .bpt-board-item:first-child { border-inline-start: 0; }
#root .bpt-board-item:hover:not(:disabled) { background: var(--t); }
#root .bpt-board-item:disabled { cursor: default; opacity: .55; }
#root .bpt-board-item-value { font-size: 18px; line-height: 1.1; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; }
#root .bpt-board-item-label { font-size: 11px; font-weight: 600; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#root .bpt-board-item.is-suspended .bpt-board-item-value,
#root .bpt-board-item.is-suspended .bpt-board-item-label { color: #dc2626; }
@media (max-width: 1100px) {
  #root .bpt-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #root .bpt-board-group:nth-child(3) { border-inline-start: 0; }
  #root .bpt-board-group:nth-child(n+3) { border-top: 1px solid #e2e8f0; }
}
@media (max-width: 640px) {
  #root .bpt-board { grid-template-columns: minmax(0, 1fr); }
  #root .bpt-board-group { border-inline-start: 0; }
  #root .bpt-board-group + .bpt-board-group { border-top: 1px solid #e2e8f0; }
}

/* نافذة قائمة المهام لكل رقم. */
.bpt-statlist-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(15 23 42 / 45%);
}
.bpt-statlist {
  display: flex;
  flex-direction: column;
  width: min(820px, 100%);
  max-height: min(80vh, 720px);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgb(15 23 42 / 25%);
  overflow: hidden;
}
.bpt-statlist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #e2e8f0; }
.bpt-statlist-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; color: #0f172a; }
.bpt-statlist-count { padding: 1px 9px; border-radius: 999px; background: #eef2ff; color: #4338ca; font-size: 12px; font-weight: 800; }
.bpt-statlist-close { width: 30px; height: 30px; border-radius: 8px; font-size: 20px; line-height: 1; color: #64748b; }
.bpt-statlist-close:hover { background: #f1f5f9; color: #0f172a; }
.bpt-statlist-body { overflow: auto; }
.bpt-statlist table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bpt-statlist th { position: sticky; top: 0; padding: 8px 10px; background: #f8fafc; color: #475569; font-weight: 700; text-align: right; white-space: nowrap; border-bottom: 1px solid #e2e8f0; }
.bpt-statlist td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; color: #334155; }
.bpt-statlist-n { width: 32px; color: #94a3b8 !important; font-variant-numeric: tabular-nums; }
.bpt-statlist-title { font-weight: 700; color: #0f172a !important; }
.bpt-statlist-owner { white-space: nowrap; }
.bpt-statlist-tag { display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 999px; background: #f1f5f9; color: #475569; font-size: 10.5px; font-weight: 700; vertical-align: 1px; }
.bpt-statlist-tag.is-early, .bpt-statlist-tag.is-ontime, .bpt-statlist-tag.is-late { background: #dcfce7; color: #047857; }
.bpt-statlist-tag.is-overdue, .bpt-statlist-tag.is-missed, .bpt-statlist-tag.is-suspended { background: #fee2e2; color: #b91c1c; }
.bpt-statlist-tag.is-pending, .bpt-statlist-tag.is-active { background: #dbeafe; color: #1d4ed8; }
.bpt-statlist .bpt-date-inline { display: inline-flex; flex-direction: column; line-height: 1.35; font-weight: 600; }
.bpt-statlist .bpt-date-inline .bmt-date-d { font-size: 10.5px; font-weight: 700; color: #6366f1; }
.bpt-statlist .bpt-date-inline small { font-size: 10px; font-weight: 400; color: #94a3b8; }
.bpt-statlist-empty { padding: 32px; text-align: center; color: #94a3b8; }

/* «الخطة الحالية» و«أرشفة وبدء دورة» في ترويسة الصفحة بجانب «قفل المهام». */
#root .bpt-head-tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#root .bpt-head-tools select {
  min-width: 0 !important;
  height: 38px;
  padding-block: 0 !important;
  background: #fff !important;
  color: #1e293b !important;
  border-color: #fff !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
}
#root .bpt-head-tools svg { color: #fbbf24 !important; }
#root .bpt-head-tools > button {
  height: 38px;
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #92400e !important;
  font-weight: 700;
  font-size: 13px !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
}
#root .bpt-head-tools > button svg { color: #d97706 !important; }

/* المهام اليومية: بطاقة مختصرة — الاسم، الوصف، المرفقات، فترة التنفيذ، تعديل وإنجاز. */
#root .bpt-daily-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  background: #fff;
}
#root .bpt-daily-head { display: flex; align-items: flex-start; gap: 7px; min-width: 0; }
#root .bpt-daily-name { flex: 1; min-width: 0; margin: 0; font-size: 13px; font-weight: 800; line-height: 1.5; color: #111827; overflow-wrap: anywhere; }
#root .bpt-daily-desc {
  margin: 0;
  padding: 5px 8px;
  border-radius: 8px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#root .bpt-daily-files { display: flex; flex-wrap: wrap; gap: 5px; }
#root .bpt-daily-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#root .bpt-daily-file:hover { background: #e0e7ff; }
#root .bpt-daily-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: auto; padding-top: 6px; border-top: 1px solid #f1f5f9; }
#root .bpt-daily-range { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: #334155; }
#root .bpt-daily-range > span { display: inline-flex; align-items: center; gap: 4px; }
#root .bpt-daily-range b { font-weight: 700; color: #64748b; }
#root .bpt-daily-range .bpt-date-inline { flex-direction: row; gap: 4px; align-items: baseline; }
#root .bpt-daily-actions { display: inline-flex; align-items: center; gap: 5px; margin-inline-start: auto; }
#root .bpt-daily-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #fff;
  color: #6d28d9;
  font-size: 11px;
  font-weight: 700;
}
#root .bpt-daily-edit:hover { background: #f5f3ff; }
#root [data-task-section="daily"] .bpt-daily-list { align-items: start; }

/* ===== «خريطة المواد» (scripts/frontend/task-subject-map.js) ===== */
#root .bsm-root { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
#root .bsm-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
#root .bsm-stats, #root .bsm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#root .bsm-stat { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid #e2e8f0; border-radius: 999px; background: #f8fafc; font-size: 12px; color: #475569; }
#root .bsm-stat b { color: #0f172a; font-weight: 800; }
#root .bsm-stat.is-live { cursor: pointer; }
#root .bsm-stat.is-live:disabled { cursor: default; opacity: .6; }
#root .bsm-stat.is-warn { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
#root .bsm-stat.is-warn b { color: #b91c1c; }
#root .bsm-pan { display: inline-flex; gap: 4px; }
#root .bsm-threshold { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #64748b; }
#root .bsm-threshold select { width: auto; }

#root .bsm-panel { border: 1px solid #fecaca; border-radius: 12px; background: #fff7f7; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
#root .bsm-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: #7f1d1d; }
#root .bsm-close { width: 26px; height: 26px; border-radius: 8px; border: 1px solid #fecaca; background: #fff; color: #b91c1c; font-size: 16px; line-height: 1; }
#root .bsm-person { border-top: 1px dashed #fecaca; padding-top: 6px; }
#root .bsm-person-name { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 800; color: #1e293b; }
#root .bsm-person-name small { font-size: 11px; font-weight: 600; color: #b91c1c; }
#root .bsm-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; }
#root .bsm-pair button { padding: 2px 8px; border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; color: #1e293b; font-weight: 600; }
#root .bsm-pair button:hover { border-color: #a78bfa; background: #f5f3ff; }
#root .bsm-pair small { color: #94a3b8; }

#root .bsm-map { position: relative; overflow-x: auto; }
#root .bsm-grid { display: grid; grid-template-columns: minmax(180px, 230px) minmax(560px, 1fr); }
#root .bsm-corner { display: flex; align-items: flex-end; padding: 0 8px 6px; font-size: 12px; font-weight: 800; color: #64748b; border-bottom: 1px solid #e2e8f0; }
#root .bsm-corner.is-load { align-items: center; padding-bottom: 0; font-weight: 700; border-bottom: 1px solid #f1f5f9; }
#root .bsm-axis { position: relative; height: 46px; border-bottom: 1px solid #e2e8f0; }
#root .bsm-tick { position: absolute; bottom: 4px; display: flex; flex-direction: column; padding-inline-start: 4px; border-inline-start: 1px solid #e2e8f0; line-height: 1.25; white-space: nowrap; }
#root .bsm-tick b { font-size: 11px; font-weight: 800; color: #334155; }
#root .bsm-tick small { font-size: 10px; color: #94a3b8; }
#root .bsm-tick .bsm-greg { color: #0f766e; }
#root .bsm-today-label { position: absolute; top: 2px; transform: translateX(50%); padding: 0 6px; border-radius: 999px; background: #7c3aed; color: #fff; font-size: 10px; font-weight: 800; }
#root .bsm-load { position: relative; height: 22px; border-bottom: 1px solid #f1f5f9; background: #fafafa; }
#root .bsm-week { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; border: 0; font-size: 10px; font-weight: 800; color: #fff; background: transparent; }
#root .bsm-week.is-light { background: #fef3c7; }
#root .bsm-week.is-warm { background: #fdba74; }
#root .bsm-week.is-heavy { background: #ef4444; cursor: pointer; }
#root .bsm-week.is-heavy:hover { background: #b91c1c; }
#root .bsm-week:disabled { cursor: default; }

#root .bsm-label { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 8px; border: 0; border-bottom: 1px solid #f1f5f9; background: #fff; text-align: right; min-width: 0; }
#root .bsm-label:hover, #root .bsm-label.is-open { background: #f5f3ff; }
#root .bsm-label.is-general .bsm-name { color: #64748b; }
#root .bsm-name { font-size: 13px; font-weight: 800; color: #1e293b; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#root .bsm-meta { font-size: 11px; color: #64748b; }
#root .bsm-badge { padding: 0 7px; border-radius: 999px; font-size: 10px; font-weight: 800; }
#root .bsm-badge.is-ahead { background: #dcfce7; color: #166534; }
#root .bsm-badge.is-plan { background: #e0f2fe; color: #075985; }
#root .bsm-badge.is-behind { background: #fee2e2; color: #b91c1c; }
#root .bsm-badge.is-future { background: #f1f5f9; color: #64748b; }
#root .bsm-lane { position: relative; min-height: 54px; border-bottom: 1px solid #f1f5f9; background: repeating-linear-gradient(to left, transparent 0 calc(100% / 12 - 1px), #f8fafc calc(100% / 12 - 1px) calc(100% / 12)); }
#root .bsm-bar { position: absolute; top: 16px; height: 18px; display: flex; overflow: hidden; border: 0; padding: 0; border-radius: 999px; background: #e2e8f0; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08); cursor: pointer; transition: transform .15s, box-shadow .15s; }
#root .bsm-bar:hover { transform: scaleY(1.15); box-shadow: 0 2px 8px rgba(79, 70, 229, .25); }
#root .bsm-seg { display: block; height: 100%; min-width: 2px; }
#root .bsm-expected { position: absolute; top: 12px; height: 26px; width: 3px; margin-inline-start: -1px; background: #7c3aed; border-radius: 2px; box-shadow: 0 0 0 1.5px #fff; z-index: 1; }
#root .bsm-dot { position: absolute; top: 38px; width: 9px; height: 9px; margin-inline-start: -4px; border-radius: 999px; border: 1.5px solid #fff; padding: 0; box-shadow: 0 0 0 1px rgba(15, 23, 42, .2); cursor: pointer; }
#root .bsm-dot:hover { transform: scale(1.5); z-index: 2; }
#root .bsm-dot.is-done { background: #16a34a; }
#root .bsm-dot.is-active { background: #2563eb; }
#root .bsm-dot.is-pending { background: #94a3b8; }
#root .bsm-dot.is-overdue { background: #dc2626; }
#root .bsm-dot.is-missed { background: #6b7280; }
#root .bsm-dot.is-suspended { background: #be123c; }
#root .bsm-dot.has-conflict { box-shadow: 0 0 0 2px #f59e0b; }
#root .bsm-today { position: absolute; top: 0; bottom: 0; width: 0; border-inline-start: 2px dashed #7c3aed; opacity: .55; pointer-events: none; z-index: 1; }

#root .bsm-detail { grid-column: 1 / -1; padding: 8px 10px 12px; background: #faf5ff; border-bottom: 1px solid #ede9fe; }
#root .bsm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
#root .bsm-chip { --c: #7c3aed; display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; border: 1px solid #e2e8f0; background: #fff; font-size: 12px; color: #334155; }
#root .bsm-chip b { color: var(--c); }
#root .bsm-chip.is-active { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 20%, transparent); }
#root .bsm-chip.is-conflict { --c: #d97706; }
#root .bsm-range { margin-inline-start: auto; font-size: 11px; color: #64748b; }
#root .bsm-table-wrap { overflow-x: auto; border: 1px solid #ede9fe; border-radius: 10px; background: #fff; }
#root .bsm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
#root .bsm-table th { padding: 6px 8px; background: #f8fafc; color: #64748b; font-weight: 700; text-align: right; white-space: nowrap; }
#root .bsm-table td { padding: 6px 8px; border-top: 1px solid #f1f5f9; vertical-align: top; }
#root .bsm-row { cursor: pointer; }
#root .bsm-row:hover td { background: #f5f3ff; }
#root .bsm-row.is-done td { background: #f0fdf4; }
#root .bsm-row.is-overdue td, #root .bsm-row.is-suspended td { background: #fef2f2; }
#root .bsm-title { font-weight: 700; color: #1e293b; }
#root .bsm-title > span:first-child { margin-inline-end: 6px; }
#root .bsm-conflict { display: inline-block; padding: 0 6px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: 10px; font-weight: 800; }
#root .bsm-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: #64748b; }
#root .bsm-legend span { display: inline-flex; align-items: center; gap: 4px; }
#root .bsm-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
#root .bsm-legend i.is-expected { width: 2px; height: 12px; background: #7c3aed; }
#root .bsm-legend i.is-conflict { border-radius: 999px; background: #fff; box-shadow: 0 0 0 2px #f59e0b; }
#root .bsm-empty { margin: 0; padding: 14px; text-align: center; color: #94a3b8; font-size: 13px; }
#root .bsm-undated summary { cursor: pointer; font-size: 12px; font-weight: 700; color: #64748b; }

/* الطباعة: الخريطة وحدها بعرض الصفحة. */
@media print {
  body.bsm-printing * { visibility: hidden !important; }
  body.bsm-printing .bsm-root, body.bsm-printing .bsm-root * { visibility: visible !important; }
  body.bsm-printing .bsm-root { position: absolute; inset: 0 0 auto 0; border: 0; box-shadow: none; }
  body.bsm-printing .bsm-tools, body.bsm-printing .bsm-close { display: none !important; }
  body.bsm-printing .bsm-map { overflow: visible; }
  body.bsm-printing .bsm-grid { grid-template-columns: 170px 1fr; }
  @page { size: A4 landscape; margin: 10mm; }
}
