/* تمكين v8 — تصحيحات التنسيق على كل الصفحات (يتحمّل بعد delight-50.css)
   القاعدة: ما فيه سحب أفقي لأشياء أساسية، ولا زر عايم يغطي المحتوى، ولا تحكم مقصوص على الحافة.
   الجداول الكبيرة بس تتحرك أفقيًا داخل إطارها (.pl-scroll) مع أعمدة ثابتة. */

/* ===== عام: نصوص طويلة (إيميلات/عناوين/روابط) ما تكسر التنسيق ===== */
.st-u-email, .st-email, [dir="ltr"].st-u-email, .rq-item, .meet-card h3, .task-title, .auth-card, .toast { overflow-wrap: anywhere; }
dialog.modal, dialog.sec-pick, dialog.pz-dlg, dialog.plg-dlg { max-width: calc(100vw - 16px); }
dialog.modal form, dialog.plg-dlg { overscroll-behavior: contain; }

/* ===== الإعدادات: الحسابات (تصفية + مراجعة) ===== */
.st-ufilter { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 10px; }
.st-ufilter button { white-space: nowrap; }
.st-review { background: var(--surface, var(--card)); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
.st-review ul, .st-review-list, .st-review-tasks { margin: 6px 0; padding-inline-start: 20px; line-height: 1.9; }
.st-review-tasks { color: var(--muted); font-size: 13px; }
.st-u-prepared { opacity: .85; }
.st-u-disabled { opacity: .6; }

@media (max-width: 760px) {
  /* ---- الزر العايم «+»: انشال — بداله «+ إضافة مهمة» في شريط الأدوات (ما يغطي أي مهمة) ---- */
  .fab { display: none !important; }
  .toolbar #newTaskBtn, .has-hero .toolbar #newTaskBtn { display: inline-flex !important; align-items: center; justify-content: center; min-height: 40px; order: 30 !important; flex: 1 1 100% !important; width: 100%; }
  .toolbar, .toolbar .month-nav, .has-hero .toolbar, .has-hero .toolbar .month-nav { flex-wrap: wrap !important; min-width: 0; max-width: 100%; }
  .toolbar > *, .toolbar .month-nav > * { min-width: 0; max-width: 100%; }
  .toolbar #titleBtn, .has-hero .toolbar #titleBtn { min-width: 0; flex: 1 1 100%; }
  .hero, .has-hero .hero { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .hero > * { min-width: 0; max-width: 100%; }
  .board-wrap { padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important; }
  .board-wrap.hours-wrap { margin-bottom: calc(24px + env(safe-area-inset-bottom)) !important; }

  /* ---- كروت الأرقام فوق: شبكة تلف (بدون سحب أفقي ولا كروت نصها برا الشاشة) ---- */
  .hero-kpis, .has-hero .hero-kpis { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)) !important; overflow: visible !important; flex-wrap: wrap; width: 100%; gap: 6px !important; }
  .hero-kpis .kpi { min-width: 0 !important; width: auto !important; justify-content: flex-start; }
  .hero-kpis .kpi .kpi-lbl { white-space: normal !important; overflow: visible !important; line-height: 1.25; }
  .hero-kpis .kpi .kpi-tx { flex-wrap: wrap; row-gap: 0; }

  /* ---- الدليل: يلف لسطرين بدل ما ينقص زر «+» ---- */
  .legend-inline { flex-wrap: wrap !important; overflow: visible !important; }
  .legend-inline .legend-list, .legend-list { flex-wrap: wrap !important; overflow: visible !important; min-width: 0; }
  .legend-add, .legend-item .edit { min-width: 32px; min-height: 32px; }
  .stats-row, .has-hero .stats-row { flex-wrap: wrap !important; min-width: 0; max-width: 100%; }
  .stats-row > *, .legend-inline { min-width: 0; max-width: 100%; }
  .legend-inline { width: 100%; }
  .legend-item { max-width: 100%; min-width: 0; }
  .legend-item .chip { min-width: 0; max-width: calc(100% - 34px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* أي عنصر في الصفحة ما يطلع برا عرض الشاشة (RTL: الزيادة تروح يسار وتعمل سحب للصفحة كلها) */
  main, .board-wrap, .stats-row, .toolbar, .hero, .filters, .quick-links { max-width: 100vw; }

  /* ---- أزرار التحكم: حجم لمس مريح ---- */
  .prio-flag { min-width: 28px; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .view-opts { flex-wrap: wrap; row-gap: 6px; }

  /* ---- الروابط السريعة: تلف (والزيادة في «المزيد») ---- */
  .quick-links { flex-wrap: wrap !important; overflow: visible !important; }
  .quick-link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---- صفحة الخطة: شريط الأدوات يلف بترتيب واضح ---- */
  .pl-toolbar { flex-wrap: wrap; row-gap: 8px; }
  .pl-controls { flex-wrap: wrap; row-gap: 6px; width: 100%; }
  .pl-controls > * { flex: 0 1 auto; }
  .pl-director { flex: 1 1 100%; }
  .pl-director select { width: 100%; }
  .pl-type-strip { gap: 4px; }

  /* ---- النوافذ: داخل الشاشة، والأزرار ظاهرة فوق الكيبورد ---- */
  dialog.modal, dialog.plg-dlg, dialog.pz-dlg { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; margin: 8px auto; }
  dialog .modal-actions { position: sticky; bottom: 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .st-iv-link { flex-wrap: wrap; }
  .st-iv-link input { min-width: 0; flex: 1 1 200px; }
}

/* ===== الطلبات على الشاشات الضيقة ===== */
@media (max-width: 760px) {
  .rq-layout { grid-template-columns: minmax(0, 1fr) !important; min-width: 0; }
  .rq-list-pane, .rq-detail-pane, .rq-list-head, .rq-tools { min-width: 0 !important; max-width: 100%; }
  .rq-tabs { flex-wrap: wrap; max-width: 100%; }
  .rq-tabs button { flex: 1 1 auto; }
  .rq-tools { flex-wrap: wrap; }
  .rq-tools input[type=search], #rqSearch { min-width: 0; flex: 1 1 140px; }
  .rq-card { min-width: 0; }
}

@media (max-width: 360px) {
  .hero-kpis, .has-hero .hero-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* موبايل بالعرض (ارتفاع قليل): النوافذ تتمرّر وما تنقص */
@media (max-height: 480px) and (orientation: landscape) {
  dialog.modal, dialog.plg-dlg, dialog.pz-dlg { max-height: calc(100dvh - 8px) !important; margin: 4px auto; }
  .topbar { position: static; }
}

/* الإعدادات: خيارات النوع + فحص البيانات */
.st-style-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.st-style-row input[type="text"] { flex: 1 1 160px; min-width: 0; }
.st-flag { font-size: 12.5px; white-space: nowrap; }
.st-hl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.st-hl-row label { display: flex; gap: 6px; align-items: center; font-size: 13px; min-width: 0; }
.st-hl-row select { max-width: 100%; min-width: 0; }
.st-hl-list { display: grid; gap: 4px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 13px; }

/* ===== الترتيب بالسحب (⠿) — كل المنصة ===== */
.dk-h { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 28px; margin-inline-end: 4px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: grab; touch-action: none; user-select: none; vertical-align: middle; }
.dk-h:hover { background: var(--hover, rgba(26,68,181,.07)); color: var(--brand, #1A44B5); }
.dk-h:focus-visible { outline: 2px solid var(--focus, #2563EB); outline-offset: 1px; }
.dk-h:active { cursor: grabbing; }
.dk-dragging { opacity: .45; }
.dk-over-before { box-shadow: inset 0 3px 0 var(--brand, #1A44B5) !important; }
.dk-over-after { box-shadow: inset 0 -3px 0 var(--brand, #1A44B5) !important; }
th.dk-over-before { box-shadow: inset -3px 0 0 var(--brand, #1A44B5) !important; }
th.dk-over-after { box-shadow: inset 3px 0 0 var(--brand, #1A44B5) !important; }
@media (pointer: coarse) { .dk-h { width: 34px; height: 34px; } }

/* ===== v25: اختيار الفترة (هجري/ميلادي، شهور مع بعض، تاريخ بالضبط) — مشترك بين الخطة والإعدادات ===== */
.tpp { display: grid; gap: 8px; min-width: 0; }
.tpp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpp-cal { flex: none; }
.tpp-year { display: flex; align-items: center; gap: 6px; }
.tpp-year b { min-width: 74px; text-align: center; font-size: 14px; }
.tpp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tpp-m { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 7px 3px; border-radius: 10px; border: 1px solid var(--line); background: var(--card, #fff); color: var(--text); cursor: pointer; font: inherit; line-height: 1.25; }
.tpp-m b { font-size: 13px; }
.tpp-m small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tpp-m:hover { border-color: var(--brand, #1A44B5); }
.tpp-m.on { background: rgba(26, 68, 181, .10); border-color: rgba(26, 68, 181, .45); }
.tpp-m.edge { background: var(--brand, #1A44B5); color: #fff; border-color: var(--brand, #1A44B5); }
.tpp-m.edge small { color: rgba(255, 255, 255, .85); }
.tpp-m.anchor { outline: 2px dashed var(--orange, #F39200); outline-offset: 1px; }
.tpp-tip { margin: 0; font-size: 11.5px; color: var(--muted); }
.tpp-dates summary { cursor: pointer; font-size: 12.5px; font-weight: 700; }
.tpp-dates-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.tpp-dates-row label { display: grid; gap: 3px; font-size: 12.5px; min-width: 0; }
.tpp-date { display: grid; gap: 2px; min-width: 0; }
.tpp-date input, .tpp-hsel select { height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 0 6px; font: inherit; font-size: 13px; background: var(--input, var(--card)); color: var(--text); min-width: 0; max-width: 100%; }
.tpp-hsel { display: grid; grid-template-columns: 52px 1fr 76px; gap: 4px; min-width: 0; }
.tpp-hint { font-size: 11px; color: var(--muted); }
.tpp-sum { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--brand, #1A44B5); }
.tpp-sum.bad { color: #d92d20; }
@media (max-width: 520px) { .tpp-dates-row { grid-template-columns: 1fr; } .tpp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ===== v25: الإضافة السريعة داخل نوافذ التجهيز (جهة / مدير / مشروع) ===== */
.field-label .pl-plus, .pl-plus { margin-inline-start: 8px; padding: 1px 9px; border-radius: 999px; border: 1px dashed var(--brand, #1A44B5); background: transparent; color: var(--brand, #1A44B5); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.pl-quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; }
.pl-quick[hidden] { display: none; }
.pl-quick input, .pl-quick select { flex: 1 1 140px; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.pl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pl-chip { padding: 2px 10px; border-radius: 999px; background: rgba(26, 68, 181, .08); font-size: 12px; }
.check.is-new { font-weight: 700; }
.tpp-sum.none { color: var(--muted); font-weight: 600; }

/* أزرار صغيرة للمس: أقلها 32px */
@media (max-width: 767px) { .l-del { min-width: 34px; min-height: 34px; } .pl-hide-btn { min-width: 32px; min-height: 32px; } .pl-plus-sm { width: 28px; height: 28px; } }
/* ===== V9: المهمة المحوّلة لطلب (نفس شكل الطلب في اللوحة) ===== */
.task.as-request { display: flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; line-height: 20px; font-size: 12.5px; font-weight: 700; background: var(--card); color: #0E7490; border: 1.5px dashed #0891B2; box-shadow: none; }
.task.as-request .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; cursor: pointer; }
.task.as-request > i { font-style: normal; }
.task.as-request input[type="checkbox"] { flex: none; margin: 0; }
.task.as-request .rq-st { font-size: 10.5px; font-weight: 600; background: #E0F2FE; color: #0E7490; border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.task.as-request.s-delivered { background: #F5F3FF; color: #6D28D9; border-color: #7C3AED; border-style: solid; }
.task.as-request.s-delivered .rq-st { background: #7C3AED; color: #fff; }
.task.as-request.s-progress .rq-st { background: #FEF3C7; color: #92400E; }
.task.as-request.s-changes { border-color: #DC2626; color: #B91C1C; }
.task.as-request.s-changes .rq-st { background: #FEE2E2; color: #B91C1C; }
.task.as-request.s-approved { border-style: solid; border-color: #16A34A; color: #15803D; }
.task.as-request.s-approved .rq-st { background: #DCFCE7; color: #15803D; }
.task.as-request.done .title { text-decoration: line-through; opacity: .75; }
.task.as-request .req-open { flex: none; text-decoration: none; color: inherit; font-weight: 800; padding: 0 2px; border-radius: 4px; }
.task.as-request .req-open:hover, .task.as-request .req-open:focus-visible { background: rgba(8, 145, 178, .12); }
.is-dark .task.as-request { background: rgba(8, 145, 178, .1); color: #A5F3FC; }
.is-dark .task.as-request.s-delivered { background: rgba(124, 58, 237, .14); color: #DDD6FE; }
#tReqBox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; border: 1.5px dashed #0891B2; background: rgba(8, 145, 178, .05); font-size: 13px; }
#tReqBox[hidden] { display: none; }
#tReqBox.req-linked { border-style: solid; }
#tReqBox.req-linked .btn-outline { margin-inline-start: auto; }
#tReqBox .req-st { padding: 1px 8px; border-radius: 999px; background: #E0F2FE; color: #0E7490; font-weight: 700; font-size: 12px; }
#tReqBox.open { display: grid; grid-template-columns: 1fr; }
#tReqBox select, #tReqBox textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
#tReqBox select { height: 40px; }
.req-convert-act { display: flex; gap: 8px; }
/* V9: اختيار المسؤولين (بحث + ✓) */
.who-label select { display: none; }
.who-more { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: -2px 0 10px; }
.who-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.who-none { color: var(--muted); font-size: 13px; }
.who-open { align-self: flex-start; min-height: 34px; }
.who-panel { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--card); box-shadow: 0 6px 20px rgba(16, 30, 70, .12); display: grid; gap: 6px; }
.who-panel[hidden] { display: none; }
.who-search { height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.who-list { max-height: 220px; overflow: auto; display: grid; gap: 2px; }
.who-opt { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.who-opt:hover { background: var(--hover, rgba(26, 68, 181, .06)); }
.who-opt.on { background: rgba(26, 68, 181, .08); font-weight: 700; }
.who-opt input { width: 18px; height: 18px; accent-color: var(--blue, #1A44B5); }
.who-empty { margin: 6px; color: var(--muted); font-size: 13px; }
.who-foot { display: flex; justify-content: space-between; gap: 8px; }

/* V9: «+ مدير جديد» داخل قائمة اختيار المدير */
.st-newdir-wrap { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; display: grid; gap: 6px; }
.st-newdir { display: grid; gap: 6px; }
.st-newdir[hidden] { display: none; }
.st-newdir input { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.st-newdir-btn { justify-self: start; color: var(--blue, #1A44B5); font-weight: 700; }

/* V9: إعدادات التوزيع والاعتماد والإجازات */
.pr-rules, .pr-hol { display: grid; gap: 8px; }
.pr-rules .check, .pr-hol .check { align-items: flex-start; line-height: 1.6; }
.pr-req { display: grid; gap: 6px; padding: 10px 12px; border: 1.5px solid #FCA5A5; background: #FEF2F2; border-radius: 12px; margin-bottom: 8px; }
.pr-req-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pr-req-row .btn-primary { margin-inline-start: auto; }
.pr-wd, .pr-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.pr-wd-day { min-height: 34px; }
.pr-dates input[type="date"] { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.is-dark .pr-req { background: rgba(220, 38, 38, .1); }
.modal .who-opt, .who-panel .who-opt { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 500; margin: 0; }
.modal .who-opt.on { font-weight: 700; }
.modal .who-opt input[type="checkbox"] { width: 18px; height: 18px; flex: none; margin: 0; }
.modal .who-opt span { flex: 1; text-align: start; }

/* V9: اختيار المطلوب منه = أزرار */
.req-to-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.req-to-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.req-to-btn i { font-style: normal; font-size: 12px; }
.req-to-btn:hover { border-color: #0891B2; }
.req-to-btn.on { background: #0891B2; border-color: #0891B2; color: #fff; }
.req-to-btn:focus-visible { outline: 2px solid #0891B2; outline-offset: 2px; }

/* V9: ترتيب الإعدادات */
.st-group-desc { grid-column: 2; margin: -6px 0 4px; color: var(--muted); font-size: 13px; }
.st-save-inline { display: flex; justify-content: flex-end; }
@media (max-width: 760px) { .st-group-desc { grid-column: auto; } }

/* V9 (المتطلب 9): حالة المهمة بس — بدون تغيير تصميم اللوحة. المتأخرة: إطار أحمر خفيف */
.task.overdue:not(.done) { box-shadow: inset 0 0 0 1.5px rgba(220, 38, 38, .55); }
.task.as-request.overdue:not(.done) { border-color: #DC2626; }
.task-plan-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--hover, #F8FAFC); font-size: 13px; }
.task-plan-box[hidden] { display: none; }
.task-plan-box .btn-outline { margin-inline-start: auto; }
.task-plan-box small { flex-basis: 100%; }
/* V9: طلبات الخطة في صفحة الطلبات */
.rq-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0; padding: 10px 14px; border-radius: 12px; border: 1.5px dashed #0891B2; background: rgba(8, 145, 178, .05); }
.rq-plan.s-approved { border-style: solid; border-color: #16A34A; background: #F0FDF4; }
.rq-plan.s-rejected { border-style: solid; border-color: #DC2626; background: #FEF2F2; }
.rq-plan small { flex-basis: 100%; color: var(--muted); }
.rq-plan-act { display: flex; gap: 8px; margin-inline-start: auto; }
.rq-status.s-rejected { background: #FEE2E2; color: #B91C1C; }
.is-dark .rq-plan.s-approved, .is-dark .rq-plan.s-rejected { background: var(--card); }
/* ===== V9 (المتطلب 6): الإعدادات — 4 أقسام رئيسية وقسم فرعي واحد ظاهر ===== */
body.st-tabs .st-wrap { max-width: 1480px; grid-template-columns: 270px minmax(0, 1fr); gap: 24px; padding-inline: 24px; }
body.st-tabs .st-nav { padding: 12px; gap: 10px; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(16, 30, 70, .06); max-height: calc(100vh - 100px); overflow: auto; }
body.st-tabs .st-pagehead { grid-column: 2; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: -6px; }
body.st-tabs .st-pagehead b { color: var(--text); font-size: 18px; }
.st-crumb-sep { opacity: .5; }
.st-tabs-main { display: grid; gap: 4px; }
.st-tab { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-weight: 700; font-size: 14.5px; padding: 10px 12px; cursor: pointer; text-align: start; }
.st-tab:hover { background: var(--hover, #F1F5F9); }
.st-tab.on { background: var(--blue, #1A44B5); color: #fff; box-shadow: 0 4px 14px rgba(26, 68, 181, .25); }
.st-tab-ic { width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; background: rgba(26, 68, 181, .08); font-size: 14px; }
.st-tab.on .st-tab-ic { background: rgba(255, 255, 255, .18); }
.st-tabs-sub { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.st-sub-link { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-2, var(--text)); text-decoration: none; font-size: 13.5px; font-weight: 600; border-inline-start: 3px solid transparent; }
.st-sub-link:hover { background: var(--hover, #F1F5F9); color: var(--blue, #1A44B5); }
.st-sub-link.on { background: rgba(26, 68, 181, .07); color: var(--blue, #1A44B5); border-inline-start-color: var(--accent, #F39200); }
body.st-tabs .st-card { padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 12px rgba(16, 30, 70, .05); }
body.st-tabs .st-card[hidden] { display: none !important; }
body.st-tabs .st-group[hidden], body.st-tabs .st-group-desc[hidden], body.st-tabs .st-save[hidden] { display: none !important; }
body.st-tabs .st-card .st-head h2 { font-size: 18px; }
body.st-tabs .st-card .field-hint { max-width: 900px; }
body.st-tabs #stForm { display: grid; gap: 20px; }
.st-utools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.st-search { height: 38px; min-width: 240px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.st-perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.st-perm-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; display: grid; gap: 4px; align-content: start; }
.st-perm-group legend { font-weight: 800; font-size: 13px; padding: 0 6px; color: var(--blue, #1A44B5); }
.po-form { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--hover, #F8FAFC); margin-bottom: 12px; }
.po-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.po-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.po-row input[type="date"], .po-row input[type="month"], .po-row input[type="text"], .po-row select { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; background: var(--input, var(--card)); color: var(--text); }
.po-row input[type="text"] { flex: 1; min-width: 200px; }
.po-picks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.st-po-table tr.past td { opacity: .55; }
.pr-req-main { display: grid; gap: 2px; flex: 1; min-width: 220px; }
.pr-req-main small { color: var(--muted); }
.pr-reason { color: var(--text) !important; }
.pv-global { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.pv-table select { height: 32px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 12.5px; background: var(--card); color: var(--text); }
.pv-users { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.pv-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 13px; }
.pv-user select { height: 34px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 12.5px; background: var(--card); color: var(--text); max-width: 60%; }
@media (max-width: 760px) {
  body.st-tabs .st-wrap { grid-template-columns: 1fr; padding-inline: 12px; gap: 12px; }
  body.st-tabs .st-nav { position: static; max-height: none; padding: 8px; }
  body.st-tabs .st-pagehead { grid-column: auto; }
  .st-tabs-main { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .st-tab { width: auto; white-space: nowrap; padding: 8px 12px; min-height: 40px; }
  .st-tabs-sub { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: thin; }
  .st-sub-link { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
  .st-sub-link.on { border-color: var(--blue, #1A44B5); }
  body.st-tabs .st-card { padding: 16px 14px; }
  .st-search { min-width: 0; width: 100%; }
}
/* V9 (المتطلب 4): قائمة منبثقة بموضع ثابت فوق الكل */
.st-pop-fixed { position: fixed !important; z-index: 1000; overflow: auto; overscroll-behavior: contain; box-shadow: 0 12px 32px rgba(16, 30, 70, .18); }
/* V9 (المتطلب 4) — السبب: حركة الظهور (animation … both) تخلّي كل كارت سياق تكديس دايم، فالقائمة المنبثقة داخل كارت تنرسم تحت الكارت اللي بعده.
   الحل: الحركة ما تحتفظ بحالتها بعد ما تخلص (الشكل النهائي نفسه)، فما يبقى سياق تكديس بعد الظهور. */
.st-card, .pf-card, .pl-card, .pl-ov-card, .pl-goals, .rq-card, .mt-card, .pl-mcard, .auth-card { animation-fill-mode: backwards !important; }
/* V9: العمود ما يتمدد بسبب سطر طويل (أمر الـ Cron / جداول السجل) — يلف أو يتمرّر داخله */
body.st-tabs #stForm { grid-template-columns: minmax(0, 1fr); min-width: 0; }
body.st-tabs .st-card, body.st-tabs .st-wrap > * { min-width: 0; }
body.st-tabs #alCron { display: block; max-width: 100%; overflow-wrap: anywhere; word-break: break-all; white-space: normal; }
body.st-tabs .st-mail-log, body.st-tabs .st-smtp { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 1100px) and (min-width: 761px) { body.st-tabs .st-wrap { grid-template-columns: 220px minmax(0, 1fr); gap: 16px; padding-inline: 16px; } }
@media (max-width: 760px) { body.st-tabs .st-card { overflow-x: auto; } body.st-tabs .st-card input, body.st-tabs .st-card select { max-width: 100%; } }
/* ===== V9 (التصحيح 4): الجوال — النوافذ داخل الشاشة، أزرار مريحة، المناطق الآمنة ===== */
@media (max-width: 760px) {
  dialog.modal { width: calc(100vw - 16px) !important; max-width: none !important; max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; margin: auto; overflow: auto; overscroll-behavior: contain; }
  dialog.modal .modal-actions { position: sticky; bottom: -1px; z-index: 2; background: var(--card); padding: 10px 0 calc(4px + env(safe-area-inset-bottom)); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
  dialog.modal .modal-actions > button { flex: 1 1 auto; min-height: 44px; }
  dialog.modal input[type="text"], dialog.modal input[type="email"], dialog.modal input[type="date"], dialog.modal input[type="time"], dialog.modal input[type="search"], dialog.modal select { min-height: 44px; font-size: 16px; }
  dialog.modal textarea { font-size: 16px; }
  body.st-tabs .st-card .btn-primary, body.st-tabs .st-card .btn-outline { min-height: 42px; }
  body.st-tabs .st-card input[type="text"], body.st-tabs .st-card input[type="email"], body.st-tabs .st-card input[type="date"], body.st-tabs .st-card select { min-height: 42px; font-size: 16px; }
  .topbar { padding-top: env(safe-area-inset-top); }
  body { padding-bottom: env(safe-area-inset-bottom); }
  .notif-pop { max-height: calc(100dvh - 90px); overflow: auto; }
  .who-panel .who-opt { min-height: 44px; }
  .req-to-btn { min-height: 44px; }
}
.task .title .carry-from { font-size: 11.5px; color: #7C3AED; font-weight: 600; }

/* V9 (R15): شريط «معاينة كمستخدم» — ثابت فوق الصفحة */
.tk-pv-bar { position: sticky; top: 0; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 16px; background: #1A44B5; color: #fff; font-size: 13.5px; box-shadow: 0 2px 10px rgba(16, 30, 70, .25); }
.tk-pv-bar.trial { background: #7C3AED; }
.tk-pv-bar span { opacity: .92; }
.tk-pv-bar button { margin-inline-start: auto; border: 1px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .12); color: #fff; border-radius: 9px; padding: 5px 12px; font: inherit; font-weight: 700; cursor: pointer; }
.tk-pv-bar button + button { margin-inline-start: 0; }
.tk-pv-bar button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 640px) { .tk-pv-bar { font-size: 12.5px; } .tk-pv-bar button { margin-inline-start: 0; } }

/* V9 (مراجعة المالك 15): تنبيه على مهمة في لوحة صاحبها */
.task.has-alert { box-shadow: inset 3px 0 0 #F39200; }
.task-alert { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: rgba(243, 146, 0, .14); color: #92400E; font-size: 11.5px; text-decoration: none; }
.task-alert small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.task-alert.replied { background: rgba(26, 68, 181, .1); color: #1A44B5; }
.task-alert:focus-visible { outline: 2px solid #F39200; outline-offset: 2px; }
.is-dark .task-alert, :root[data-theme="dark"] .task-alert { color: #FDE68A; }
.is-dark .task-alert.replied, :root[data-theme="dark"] .task-alert.replied { color: #93C5FD; }
.pr-watch { display: flex; flex-wrap: wrap; gap: 6px 14px; }
/* عرض الشهر: التنبيه أيقونة بس (النص في التلميح) — عشان اسم المهمة يبان */
.view-month .task-alert { flex: 0 0 auto; margin: 0; padding: 0 4px; }
.view-month .task-alert small { display: none; }
/* ===== V9 (مراجعة المالك 16): مهام تخطيط المديرين في كاليندر المتابع ===== */
.request-item.watch-item { border-color: #7C3AED; color: #5B21B6; background: #F5F3FF; border-style: solid; cursor: pointer; }
.request-item.watch-item .rq-st { background: #EDE9FE; color: #5B21B6; white-space: nowrap; }
.request-item.watch-item.late { border-color: #DC2626; color: #B91C1C; background: #FEF2F2; }
.request-item.watch-item.late .rq-st { background: #FEE2E2; color: #B91C1C; }
.request-item.watch-item.s-approved { border-color: #16A34A; color: #15803D; background: #F0FDF4; }
.request-item.watch-item.s-approved .title { text-decoration: line-through; }
.request-item.watch-item.s-approved .rq-st { background: #DCFCE7; color: #15803D; }
.request-item.watch-item.has-alert { box-shadow: inset -3px 0 0 #F39200; }
.request-item.watch-item.has-alert .rq-st { background: rgba(243, 146, 0, .18); color: #92400E; }
.request-item.watch-item:focus-visible { outline: 2px solid #7C3AED; outline-offset: 2px; }
.watch-btn.on { background: #7C3AED; color: #fff; border-color: #7C3AED; }
.is-dark .request-item.watch-item, :root[data-theme="dark"] .request-item.watch-item { background: rgba(124, 58, 237, .16); color: #DDD6FE; }
.is-dark .request-item.watch-item .rq-st, :root[data-theme="dark"] .request-item.watch-item .rq-st { background: rgba(124, 58, 237, .3); color: #EDE9FE; }
.is-dark .request-item.watch-item.late, :root[data-theme="dark"] .request-item.watch-item.late { background: rgba(220, 38, 38, .16); color: #FECACA; }
.is-dark .request-item.watch-item.s-approved, :root[data-theme="dark"] .request-item.watch-item.s-approved { background: rgba(22, 163, 74, .16); color: #BBF7D0; }
/* ===== V9 (مراجعة المالك 18): المهمة اللي عليها تنبيه — برتقالي واضح يغلب أي لون ===== */
li.task.has-alert { --ev-bg: #FFEDD5 !important; --task-accent: #F39200 !important; background: #FFEDD5 !important; border: 2px solid #F39200 !important; box-shadow: 0 0 0 2px rgba(243, 146, 0, .22); color: #7C2D12 !important; }
li.task.has-alert .title, li.task.has-alert .t-title { color: #7C2D12 !important; font-weight: 800; }
li.task.has-alert .task-alert { background: #F39200; color: #fff; font-weight: 800; }
li.task.has-alert .task-alert b { display: inline-block; animation: tkAlertPulse 1.6s ease-in-out infinite; }
@keyframes tkAlertPulse { 50% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { li.task.has-alert .task-alert b { animation: none; } }
.is-dark li.task.has-alert, :root[data-theme="dark"] li.task.has-alert { --ev-bg: rgba(243, 146, 0, .22) !important; background: rgba(243, 146, 0, .22) !important; color: #FED7AA !important; }
.is-dark li.task.has-alert .title, :root[data-theme="dark"] li.task.has-alert .title { color: #FED7AA !important; }
/* إحصائيات مهام المديرين (زرار «مهام المديرين» شغال) */
#heroKpis.is-watch { border-radius: 14px; box-shadow: inset 0 0 0 2px #7C3AED; background: rgba(124, 58, 237, .06); }
#heroKpis.is-watch #heroTotalLbl { color: #7C3AED; font-weight: 800; }
/* V9 (مراجعة المالك 21): زرار «رجّعه للافتراضي» */
#uDialog .modal-actions .u-reset { margin-inline-start: auto; }
/* V9 (مراجعة المالك 25): إعداد شريط الخطط الإضافية */
#pvXStrip { margin-top: 14px; }
#pvXStrip .xs-grp { display: grid; gap: 6px; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
#pvXStrip .xs-grp > b { font-size: 13.5px; }
/* V9 (مراجعة المالك 31): خطط التسويق — التفاصيل كاملة (تنزل سطر) */
#pmBox .pz-row { flex-wrap: wrap; row-gap: 4px; }
#pmBox .pz-row small { white-space: normal; overflow: visible; text-overflow: clip; flex: 1 1 100%; order: 3; line-height: 1.6; }
#pmBox .pz-row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px 10px; }
#pmBox .pz-row > b { grid-column: 1; grid-row: 1; }
#pmBox .pz-row > a { grid-column: 2; grid-row: 1; }
#pmBox .pz-row > button { grid-column: 3; grid-row: 1; }
#pmBox .pz-row > small { grid-column: 1 / -1; grid-row: 2; max-width: none; width: auto; }
#pmBox .pz-row > .pm-conv { grid-column: 3; grid-row: 2; justify-self: end; }
#pmBox .pz-row:has(.pm-conv) > small { grid-column: 1 / 3; }
/* V9 (مراجعة المالك 60): خطط مديرين فنيين آخرين */
fieldset.st-peers label.st-peer-row { display: flex; flex-direction: row; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
fieldset.st-peers label.st-peer-row select { min-width: 140px; width: auto; flex: 0 0 auto; }
fieldset.st-peers { grid-column: 1 / -1; }
/* V9 (مراجعة المالك 72): زر إخفاء/إظهار الخطة */
.pz-row .pm-vis.off { background: rgba(243, 146, 0, .12); border-color: #F39200; color: #92400E; font-weight: 700; }
/* V9 (مراجعة المالك 74): نافذة الحذف النهائي */
.st-del-dlg { width: min(560px, calc(100vw - 24px)); padding: 18px 20px; box-sizing: border-box; }
.st-del-dlg h2 { margin: 0 0 10px; font-size: 17px; color: #B42318; }
.st-del-body { display: grid; gap: 6px; font-size: 13.5px; }
.st-del-body ul { margin: 0 0 4px; padding-inline-start: 18px; }
.st-del-warn { margin: 0 0 6px; padding: 8px 10px; border-radius: 10px; background: #FEF3F2; color: #B42318; font-weight: 700; }
.st-del-block { margin: 0; padding: 10px; border-radius: 10px; background: #FEF3F2; color: #B42318; font-weight: 800; }
.st-del-dlg label.st-del-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.st-del-dlg .st-del-row > span { min-width: 130px; font-weight: 700; }
.st-del-dlg .st-del-row select, .st-del-dlg .st-del-row input { flex: 1 1 220px; width: auto !important; height: 38px !important; min-height: 0 !important; max-height: 40px; padding: 4px 10px; }
.st-del-dlg .modal-actions { display: flex; gap: 8px; margin-top: 14px; }
/* V9 (مراجعة المالك 75): أزرار الخطة في «خطط التسويق» جنب بعض */
#pmBox .pz-row > .pm-acts { grid-column: 3; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-self: center; max-width: 360px; }
#pmBox .pz-row > small { grid-column: 1 / 3 !important; }
#pmBox .pz-row .pm-acts .pm-conv { grid-column: auto; grid-row: auto; }
@media (max-width: 640px) { #pmBox .pz-row { grid-template-columns: minmax(0, 1fr) auto; } #pmBox .pz-row > .pm-acts { grid-column: 1 / -1; grid-row: 3; justify-content: flex-start; max-width: none; } #pmBox .pz-row > small { grid-column: 1 / -1 !important; } }
/* V9 (مراجعة المالك 77): حالة الشهر في «خطة الشهر» */
.gl-mm { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: 12px; flex-wrap: wrap; }
.gl-mm-l { font-weight: 700; }
.gl-mm select { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: inherit; font: inherit; }
.gl-mm-note { margin: 8px 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.7; }
.gl-mm-note.season { background: rgba(26, 68, 181, .07); border: 1px solid rgba(26, 68, 181, .25); }
.gl-mm-note.off { background: #FEF3F2; border: 1px solid #FECDCA; color: #B42318; }
.gl-mm-note.month { background: rgba(243, 146, 0, .08); border: 1px solid rgba(243, 146, 0, .35); }
#stGoals.gl-locked { opacity: .55; }
