/*
   DashCast — أنماط الواجهة. بلا خطوة بناء: ورقة واحدة تُقرأ.

   نظام التصميم منتزَعٌ من صفحة الهبوط (`landing.blade.php`) لا مخترَعٌ هنا:
   ليلُ البطل ونيليُّه، والتدرّج نيليّ ← سماويّ ← نعناعيّ، وبطاقاتٌ بيضاء
   بحدٍّ رماديّ يكاد لا يُرى. فاللوحة التي يُريها الهبوطُ للزائر هي اللوحة
   التي يجدها حين يدخل — لا شقيقةٌ لها تشبهها من بعيد.

   والألوان كلّها متغيّرات على `:root`: لونٌ يُكتب بالرقم في قاعدتين يفترق
   عن نفسه عند أول تعديل.
*/

:root {
  /* الليل — السايدبار وصفحة الدخول ورأس اللوحة */
  --night: #050816;
  --night-2: #0a1026;
  --side: #0e1330;
  --side-ink: #eef2ff;
  --side-muted: #aab4d6;

  /* النهار — المحتوى */
  --bg: #f6f7fc;
  --card: #ffffff;
  --ink: #0b1020;
  --ink-2: #283048;
  --muted: #5d6680;          /* ٥٫٩:١ على الأبيض — نصٌّ يُقرأ لا زخرفة */
  --faint: #8a92ab;          /* للزخرفة وحدها: لا يحمل معنى يُفقد إن لم يُرَ */
  --line: #e8eaf2;
  --line-2: #f0f1f6;
  --line-strong: #dcdfea;
  --hover: #f8f9fe;

  /* العلامة */
  --indigo: #6366f1;
  --indigo-d: #4f46e5;
  --indigo-dd: #4338ca;
  --indigo-soft: #eef0ff;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --cyan-d: #0891b2;
  --mint: #6ee7b7;
  --grad: linear-gradient(100deg, #818cf8 0%, #22d3ee 50%, #6ee7b7 100%);
  --grad-btn: linear-gradient(135deg, #6366f1 0%, #4f46e5 40%, #0891b2 100%);

  /* الحالات — لكلٍّ لونُ نصٍّ وخلفية، والنصّ يجتاز ٤٫٥:١ على خلفيته */
  --ok: #047857;      --ok-bg: #dcfce7;      --ok-line: #a7f3d0;
  --bad: #b91c1c;     --bad-bg: #fee2e2;     --bad-line: #fecaca;
  --run: #4338ca;     --run-bg: #eef0ff;     --run-line: #c7d2fe;
  --wait: #0e7490;    --wait-bg: #e0f7fa;    --wait-line: #a5f3fc;
  --warn: #92400e;    --warn-bg: #fef3c7;    --warn-line: #fcd34d;
  --idle: #5d6680;    --idle-bg: #f1f2f7;

  /* أسماءٌ قديمة تُبقى لما يشير إليها */
  --brand: var(--indigo);
  --brand-dark: var(--indigo-d);
  --busy: var(--run);

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -18px rgba(15, 23, 42, .18);
  --shadow-lg: 0 30px 60px -30px rgba(15, 23, 42, .3);
  --ring: 0 0 0 4px rgba(99, 102, 241, .16);

  --font: "IBM Plex Sans Arabic", "Inter", system-ui, "Segoe UI", Tahoma, sans-serif;
  --font-latin: "Inter", "IBM Plex Sans Arabic", system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/*
   ⚠️ لا `letter-spacing` سالباً في أي قاعدة تمسّ نصّاً عربياً: التباعد يُدخل
   فراغاً بين الحروف المتّصلة فيقطع وصلها. والسالب منه مسموحٌ على اللاتيني
   وحده (`.nm` و`.v`) حيث يُكتب الرقم أو الاسم بالإنجليزية.
*/
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--indigo-d); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* حلقةُ التركيز واحدةٌ في الشاشة كلّها — تُرى ولا تُخمَّن. */
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 6px; }

::selection { background: rgba(99, 102, 241, .22); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ── الترويسة ─────────────────────────────────────────────── */
header.top {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
header.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .dot { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #818cf8, #22d3ee);
  display: grid; place-items: center; color: #fff; font-size: 16px; }
.spacer { margin-inline-start: auto; }

/* ── البطاقات ─────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad { padding: 22px; }

h1 { font-size: 26px; margin: 26px 0 6px; font-weight: 700; line-height: 1.35; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 700; line-height: 1.45; color: var(--ink); }
.lede { color: var(--muted); margin: 0 0 22px; }

/* رأس بطاقة: عنوانٌ يميناً وما يخصّه يساراً، وحدٌّ يفصله عن جسمها. */
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2);
}
.card-head h2 { margin: 0; }
.card-head .sp { margin-inline-start: auto; }
.count {
  font-family: var(--font-latin); font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--idle-bg); padding: 1px 9px; border-radius: 999px;
}

/* ── الأزرار ──────────────────────────────────────────────── */
/*
 * ارتفاعٌ أدنى لا ارتفاعٌ مقطوع: الزرّ يصطفّ مع الحقول (٤٠ بكسلاً) حين يكون
 * سطراً واحداً — وهو الغالب — ويتمدّد إن لفَّ نصُّه سطرين على شاشةٍ ضيّقة
 * بدل أن يفيض خارج حدّه.
 *
 * ومنقولٌ عن `.ui-btn` في الهبوط: أبيضُ بحدٍّ خفيف، والأساسيُّ وحده يتوهّج.
 * زرٌّ متوهّجٌ واحد في الشاشة يقول «هذا ما جئت له» — وثلاثةٌ لا تقول شيئاً.
 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2);
  padding: 8px 16px; min-height: 40px; line-height: 1.2;
  border-radius: 10px; font: inherit; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: background .15s, border-color .15s, box-shadow .2s, transform .15s, color .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { background: var(--hover); border-color: #c9cddd; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--grad-btn); border-color: transparent; color: #fff;
  box-shadow: 0 10px 26px -12px rgba(99, 102, 241, .95), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn.primary:hover { background: var(--grad-btn); filter: brightness(1.06); box-shadow: 0 14px 32px -12px rgba(99, 102, 241, 1), inset 0 1px 0 rgba(255, 255, 255, .28); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

/* ── الشارات ──────────────────────────────────────────────── */
/*
 * لكل حالةٍ لونٌ لا تشاركها فيه أخرى — والمعنى قبل الجمال:
 *
 *   مسودة       رماديّ            لم يبدأ شيء.
 *   في الطابور  سماويّ، نقطةٌ جوفاء  ينتظر دوره — لا يعمل بعد.
 *   قيد الإنتاج نيليّ، نقطةٌ تنبض    يعمل الآن.
 *   جاهز        أخضر             أُنتج.
 *   أخفق        أحمر             توقّف بخطأ.
 *   ناقص / قديم  كهرمانيّ          بين النجاح والإخفاق — لأنه بينهما.
 *   منشور       أخضرُ مُصمَت بعلامة  أمام العميل — غير «جاهز» الذي لا يراه أحد.
 *
 * والطابورُ والإنتاج يتقاسمان النبرة `busy` في المتحكّم وفي استطلاع صفحة
 * الدرس، فيفترقان هنا بـ`data-status` لا بنبرةٍ جديدة يجهلها الخادم.
 */
.badge {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
  padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.6;
  white-space: nowrap; border: 1px solid transparent;
}
.badge.ok, .badge.bad, .badge.busy, .badge.idle { gap: 7px; }
.badge.ok::before, .badge.bad::before, .badge.busy::before, .badge.idle::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }
.badge.busy { background: var(--run-bg);  color: var(--run); }
.badge.idle { background: var(--idle-bg); color: var(--idle); }
.badge.idle::before { opacity: .55; }
.badge.busy::before { animation: pulse-ring 1.4s ease-out infinite; box-shadow: 0 0 0 0 rgba(67, 56, 202, .5); }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(67, 56, 202, .45); } 80%, 100% { box-shadow: 0 0 0 6px rgba(67, 56, 202, 0); } }

/* في الطابور: ينتظر ولا يعمل — نقطةٌ جوفاء ساكنة. */
.badge.busy[data-status="queued"] { background: var(--wait-bg); color: var(--wait); }
.badge.busy[data-status="queued"]::before {
  background: transparent; box-shadow: inset 0 0 0 1.6px currentColor; animation: none; width: 7px; height: 7px;
}

/* منشور: مُصمَتٌ بعلامة صحّ — يُرى من بعيد أنه أمام العميل. */
.badge.live { background: var(--ok); color: #fff; gap: 5px; }
.badge.live::before {
  content: ''; width: 11px; height: 11px; border-radius: 0; box-shadow: none; animation: none; opacity: 1;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%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='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/contain no-repeat;
}
/* منشورٌ بنسخةٍ قديمة: كهرمانٌ بحدٍّ متقطّع — منشورٌ، لكن لا كما ينبغي. */
.badge.live.stale { background: var(--warn-bg); color: var(--warn); border: 1px dashed #d97706; }
.badge.live.stale::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7'/%3E%3C/svg%3E");
}

/* ── الجدول ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: start; border-bottom: 1px solid var(--line-2); vertical-align: middle; }

/*
 * الجدول يتمرّر داخل حدوده، لا تتمدّد الصفحة كلّها.
 *
 * جدولُ الفيديوهات سبعة أعمدة وآخرها أربعة أزرار — وبلا هذا الغلاف يدفع
 * الصفحة عرضاً على الشاشات الضيّقة، فيصير التمرير الأفقي للنافذة كلّها:
 * تزحف الترويسة والقائمة الجانبية معه ويضيع التخطيط.
 *
 * و`.scroll-x.fit` للجداول الأقصر: تتمرّر على الهاتف ولا تُفرَض عليها
 * ثمانمئة بكسل على الحاسوب.
 */
.scroll-x { overflow-x: auto; }
.scroll-x > table { min-width: 880px; }
.scroll-x.fit > table { min-width: 620px; }
th {
  font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap;
  background: #fafbfe; padding-top: 11px; padding-bottom: 11px;
}
thead tr:first-child th:first-child { border-start-start-radius: inherit; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--hover); }
td .muted { font-size: 12.5px; line-height: 1.55; }
td a { color: var(--ink); }
td a:hover { color: var(--indigo-d); }
td > .badge + .badge { margin-inline-start: 4px; }

/* اسمٌ ورمزُ نظامٍ بجانبه — خليّة الصفّ الأولى في أكثر الجداول. */
.cell-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-id > div { min-width: 0; }
.cell-id b, .cell-id .nm { font-weight: 700; color: var(--ink); }

/* ── شريط إجراءات الصفّ — رموزٌ لا نصوص ─────────────────── */
/*
 * كان العمود أربعةَ أزرارٍ نصّية: عروضُها مختلفة لاختلاف كلماتها، وحدودُها
 * أربعة، وألوانُها — أزرقُ «أنتج» وأحمرُ «احذف» وأحمرُ «إلغاء النشر» — تتناثر
 * في كل صفّ، ثم تلتفّ سطرين إن ضاق العمود. فصار أضجَّ ما في الجدول وأقلَّه
 * قابليةً للمسح بالعين، والجدولُ إنما يُقرأ بالمسح.
 *
 * والعلاج مربّعاتٌ متساوية، في كلٍّ منها رمزٌ واحد. فالعروضُ تتساوى حتماً —
 * إذ لم يبقَ نصٌّ يطول ويقصر — ويقف كلُّ فعلٍ في موضعه من كل صفّ، فتتعلّمه
 * العينُ مرّةً ثم تقصده بلا قراءة. واللونُ يظهر عند الحوم لا قبله، فلا يزاحم
 * ألوانَ الحالات في الأعمدة الأخرى وهي التي تستحقّ أن تُرى.
 *
 * (جهاتٌ منطقية — `dir` على الجذر يتبع اللغة.)
 */
.row-actions { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; }
/* فجوةٌ قبل الحذف: الفعل الذي لا يُتراجَع عنه لا يُلاصِق ما قبله. */
.row-actions .act.del { margin-inline-start: 6px; }

.act {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--muted); cursor: pointer;
  font: inherit; line-height: 1;
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.act:hover { background: var(--hover); border-color: var(--line-strong); color: var(--ink); text-decoration: none; z-index: 3; }
.act:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; z-index: 3; }

/* نبرةُ كل فعل — رماديةٌ ساكنة، تتلوّن عند الحوم وحده. */
.act.go:hover   { background: var(--indigo-soft); border-color: var(--run-line); color: var(--indigo-dd); }
.act.run:hover  { background: #ecfdf5; border-color: var(--mint); color: var(--ok); }
.act.pub:hover  { background: #ecfeff; border-color: var(--wait-line); color: var(--wait); }
.act.warn:hover { background: #fffbeb; border-color: var(--warn-line); color: #b45309; }
.act.bad:hover  { background: #fef2f2; border-color: #fca5a5; color: var(--bad); }

.act[disabled] { color: #c3c8d6; background: #fafbfe; cursor: not-allowed; }
.act[disabled]:hover { background: #fafbfe; border-color: var(--line); color: #c3c8d6; }

/*
 * الاسم يظهر عند التأشير وحده — لافتةٌ ليلية فوق الزرّ.
 *
 * ⚠️ **فوقه** لا تحته: الجدول داخل `.scroll-x`، وهو يقصّ ما خرج عنه رأسياً
 * أيضاً (التمرير في محورٍ يُصيّر الآخر `auto` لا `visible`). واللافتةُ فوق
 * الزرّ تقع في مساحة الصفّ الذي قبله — أو في ترويسة الجدول إن كان الصفُّ
 * أوّلَ الصفوف — وكلاهما داخل الحاوية. أما تحته فتُقَصُّ في الصفّ الأخير.
 *
 * ⚠️ و**تتمدّد نحو بداية السطر** لا من المنتصف: عمود الإجراءات آخرُ الأعمدة، وهو في
 * RTL أقصى اليسار. فلافتةٌ موسَّطةٌ فوق زرٍّ عرضه ٣٤ بكسلاً يفيض نصفُها خارج
 * حدّ الجدول فيُقَصّ. وحين تُثبَّت حافتُها اليسرى عند الزرّ تنمو نحو داخل
 * الجدول — حيث المتّسع دائماً.
 *
 * ولا يُعتمد على `title`: يتأخّر قرابة الثانية ويرسمه النظامُ بخطّه، ونحن
 * نريد الاسم فوريّاً. ومع ذلك يُكتب `aria-label` لقارئ الشاشة.
 */
.act::after, .act::before {
  opacity: 0; pointer-events: none; position: absolute; z-index: 20;
  transform: translateY(4px);
  transition: opacity .13s ease, transform .13s ease;
}
.act::after {
  content: attr(data-tip);
  inset-inline-end: -4px; bottom: calc(100% + 8px);
  background: var(--side); color: #fff; white-space: nowrap;
  font-size: 12px; font-weight: 600; line-height: 1.45;
  padding: 5px 10px; border-radius: 8px;
  box-shadow: 0 10px 24px -8px rgba(5, 8, 22, .55);
}
.act::before {                                   /* سنُّ اللافتة — على منتصف الزرّ */
  content: ''; inset-inline-end: 11px; bottom: calc(100% + 3px);
  border: 5px solid transparent; border-top-color: var(--side);
}
.act:hover::after, .act:hover::before,
.act:focus-visible::after, .act:focus-visible::before {
  opacity: 1; transform: translateY(0);
}

/*
 * الرموز مُعرَّفةٌ مرّةً في `<symbol>` وتُستدعى بـ`<use>`.
 *
 * والتلوين بالوراثة: `stroke: currentColor` تنزل إلى شجرة `use` الظلّية،
 * فيأخذ الرمزُ لونَ زرّه في كل حالاته بلا قاعدةٍ لكل لون.
 */
.i {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.i.solid { fill: currentColor; stroke: none; }

/* ── شريط الترشيح ────────────────────────────────────────── */
/*
 * شبكةٌ لا صفٌّ مرن: الحقول تصطفّ أعمدةً بعروضٍ ثابتة تحت عناوينها، ولا
 * يتمدّد أحدها على حساب جاره حين يطول اسمُ دورة. والبحث أعرضُها لأنه
 * الحقل الذي يُكتب فيه.
 */
.filters { padding: 16px 18px; margin-bottom: 18px; }
.filters .grid {
  display: grid; gap: 12px 14px; align-items: end;
  grid-template-columns: minmax(200px, 1.6fr) minmax(170px, 1.2fr) repeat(3, minmax(125px, .9fr)) auto;
}
.filters .field { margin: 0; }
.filters .go { display: flex; gap: 8px; }
.filters .tally {
  margin: 14px 0 0; padding-top: 13px; border-top: 1px dashed var(--line);
}
.filters .tally b { color: var(--ink); font-family: var(--font-latin); }
@media (max-width: 1080px) {
  .filters .grid { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
  .filters .go { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .filters .grid { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .filters .go .btn { flex: 1; }
}

/* ── الحقول ───────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

/*
 * ⚠️ الأنواعُ كلُّها لا `text` وحده.
 *
 * كان المحدِّد `input[type=text]`، فحقلُ البحث — وهو `type=search` — يسقط إلى
 * شكل المتصفّح الخام: حدٌّ رماديّ رفيع وزوايا قائمة وزرُّ مسحٍ دائريّ، بين
 * قوائمَ مصمَّمةٍ حوله. وأظهرُ ما يكون ذلك في شريط الترشيح حيث يقف الخمسة
 * جنباً إلى جنب. والقاعدة: كلُّ حقلٍ نصّيٍّ يُكتب فيه يُعامَل معاملةً واحدة.
 */
input[type=text], input[type=search], input[type=password], input[type=email],
input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; font-size: 14.5px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input[type=text], input[type=search], input[type=password], input[type=email],
input[type=number], input[type=url], input[type=date], select {
  height: 40px; padding-top: 0; padding-bottom: 0;   /* ارتفاعٌ واحد يصطفّ عليه الشريط */
}
input::placeholder, textarea::placeholder { color: var(--faint); }

input:hover, select:hover, textarea:hover { border-color: #c4c9da; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--indigo); box-shadow: var(--ring);
}
input[type=checkbox], input[type=radio] { accent-color: var(--indigo-d); }

/*
 * سهم القائمة — مرسومٌ لا متروكاً للمتصفّح.
 *
 * السهم الافتراضي يختلف بين المتصفّحات ويقف في **يمين** الحقل على بعض
 * محرّكات RTL فيصطدم بأول النصّ. والمرسومُ يقف يساراً دائماً، والحشوةُ
 * تُفرِغ له موضعه — في نهاية السطر، يساراً في RTL ويميناً في LTR.
 */
select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6680' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 15px;
}
[dir="ltr"] select { background-position: right 12px center; }
select:hover { background-color: var(--hover); }

/* عدسةٌ داخل حقل البحث: تقول ما هو قبل أن يُقرأ عنوانه. */
input[type=search] {
  -webkit-appearance: none; appearance: none;
  padding-inline-start: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.8'/%3E%3Cpath d='M20.2 20.2l-4.4-4.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 16px;
}
[dir="ltr"] input[type=search] { background-position: left 13px center; }
input[type=search]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; cursor: pointer; opacity: .4;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b1020' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center/contain no-repeat;
}
input[type=search]::-webkit-search-cancel-button:hover { opacity: .85; }

/* المحرّر ليليٌّ كشيفرة الهبوط: النصّ هنا شيفرةٌ تُقرأ لا فقرةٌ تُكتب. */
textarea.code {
  font: 13px/1.8 var(--mono);
  direction: ltr; text-align: left; min-height: 460px; resize: vertical;
  background: #0b1020; color: #c7d2fe; border-color: #1b2240;
  padding: 16px 18px; caret-color: #a5b4fc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
textarea.code:hover { border-color: #2a3360; }
textarea.code:focus { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(99, 102, 241, .25); }
textarea.code::placeholder { color: #5a648a; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.field + .field { margin-top: 16px; }

/* بادئةٌ ملتصقة بالحقل — نطاقُ الرابط قبل اسم المجلّد. */
.affix { display: flex; align-items: stretch; direction: ltr; }
.affix > span {
  display: flex; align-items: center; padding: 0 11px; white-space: nowrap;
  border: 1px solid var(--line-strong); border-right: 0; border-radius: 10px 0 0 10px;
  background: #fafbfe; color: var(--muted); font-size: 13px;
}
.affix > input { border-radius: 0 10px 10px 0; min-width: 0; flex: 1; }

/* مربّع اختيارٍ بعنوانه — سطرٌ واحد قابلٌ للنقر كلّه. */
.check-line {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 0;
  font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.check-line input { width: 17px; height: 17px; margin: 0; flex-shrink: 0; }

/* ── التنبيهات ────────────────────────────────────────────── */
.note {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 18px;
  font-size: 14px; font-weight: 500; border: 1px solid; line-height: 1.75;
  position: relative;
}
.note b { font-weight: 700; }
.note.ok  { background: #ecfdf5; border-color: var(--ok-line); color: #065f46; }
.note.err { background: #fef2f2; border-color: var(--bad-line); color: #991b1b; }
.note.info{ background: #f3f4ff; border-color: var(--run-line); color: #3730a3; }
/* الناقص لا الفاشل: كهرمانٌ بين خضرة النجاح وحمرة الإخفاق، لأنه بينهما. */
.note.warn{ background: #fffbeb; border-color: #fde68a; color: #92400e; }
.note a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ── التقدّم والسجلّ ──────────────────────────────────────── */
.bar { height: 8px; background: #eef0f6; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #818cf8, #22d3ee); transition: width .5s ease; }
/* الشريط يملأ من اليمين — بداية السطر في RTL. */
[dir="rtl"] .bar > i { background: linear-gradient(270deg, #818cf8, #22d3ee); margin-right: 0; margin-left: auto; }
td .bar { height: 6px; margin-bottom: 5px; }

pre.log {
  background: #0b1020; color: #c7d2fe; padding: 16px 18px; border-radius: 12px;
  font: 12.5px/1.85 var(--mono);
  max-height: 340px; overflow: auto; margin: 0;
  direction: rtl; white-space: pre-wrap; word-break: break-word;
}
pre.log::-webkit-scrollbar, textarea.code::-webkit-scrollbar { width: 9px; }
pre.log::-webkit-scrollbar-thumb, textarea.code::-webkit-scrollbar-thumb { background: #2a3360; border-radius: 6px; }

video { width: 100%; border-radius: 12px; background: #000; display: block; }

/* ── فحص الجاهزية ─────────────────────────────────────────── */
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); }
.chk.off { background: var(--bad-bg); color: var(--bad); }

/* ── النافذة المنبثقة ─────────────────────────────────────── */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(620px, 92vw); color: var(--ink);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .06), 0 40px 90px -30px rgba(5, 8, 22, .6);
}
dialog[open] { animation: dlg-in .22s var(--ease, ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog::backdrop { background: rgba(5, 8, 22, .6); backdrop-filter: blur(3px); }
dialog .head { padding: 18px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff;
  border-radius: 18px 18px 0 0; }
dialog .head .sp { margin-inline-start: auto; }
dialog .body { padding: 22px; max-height: 65vh; overflow: auto; }
dialog .foot { padding: 14px 22px; border-top: 1px solid var(--line-2);
  display: flex; gap: 10px; justify-content: flex-start; background: #fafbfe;
  border-radius: 0 0 18px 18px; }
/* نموذج الحذف تحت التذييل — منطقة خطرٍ مفصولة لا زرٌّ بين «احفظ» و«إلغاء». */
dialog .danger-zone { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 22px 18px; border-top: 1px dashed var(--line); }
dialog .danger-zone form { margin: 0; }
dialog h3 { margin: 0; font-size: 17px; font-weight: 700; }
dialog .body h4 { margin: 20px 0 6px; font-size: 14.5px; font-weight: 700; color: var(--ink); }
dialog .body h4:first-child { margin-top: 0; }
dialog .body p, dialog .body li { font-size: 14px; color: var(--ink-2); }
dialog .body ol, dialog .body ul { padding-inline-start: 20px; margin: 6px 0; }
dialog .body details { margin: 12px 0; padding: 10px 14px; border-radius: 10px; background: #fafbfe; border: 1px solid var(--line); }
dialog .body summary { cursor: pointer; font-weight: 600; font-size: 14px; }

/* ── جدول الرموز في دليل الشاشة ─────────────────────────── */
/*
 * الرمزُ نفسه لا وصفُه: يُرى في الدليل كما يُرى في الصفّ، فيُربط به فوراً.
 * والمربّعُ حوله بحدّ الزرّ وقياسه ليكون الشبهُ تامّاً.
 */
.legend { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px 13px; margin: 10px 0 0; }
.legend .k {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--muted);
}
.legend > div { font-size: 14px; color: var(--ink-2); align-self: center; }

.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); direction: ltr; display: inline-block; font-size: .92em; }
code { font-family: var(--mono); font-size: .9em; background: var(--idle-bg); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .em-ic {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--indigo-soft); color: var(--indigo-d);
}
.empty .em-ic svg { width: 24px; height: 24px; }
.empty .em-t { font-size: 17px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.empty p { margin: 0 0 16px; }

@media (max-width: 960px) { .row { grid-template-columns: 1fr; } }

/* ── تبويبات التنقّل في الترويسة ─────────────────────────── */
.tabs { display: flex; gap: 4px; margin-inline-start: 10px; }
.tabs a { padding: 7px 13px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--muted); }
.tabs a:hover { background: var(--idle-bg); color: var(--ink); text-decoration: none; }
.tabs a.on { background: var(--indigo-soft); color: var(--indigo-dd); }

/* ── بطاقات المؤشّرات ───────────────────────────────────── */
/*
 * منقولةٌ عن `.kpi` في الهبوط: عنوانٌ صغير ثم رقمٌ كبير. والرقم لاتيني بخطّ
 * Inter ويُحاذى إلى بداية السطر — والمقياس تحته نسبةٌ حقيقية (المعروض من
 * الكلّ) يمرّرها المتحكّم، لا خطٌّ مرسومٌ للزينة.
 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.kpi-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-ic svg { width: 17px; height: 17px; }
.kpi .v { font-family: var(--font-latin); font-size: 30px; font-weight: 800; margin: 0; line-height: 1.15;
  letter-spacing: -.02em; color: var(--ink); }
.kpi .l { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi .sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.meter { height: 5px; border-radius: 999px; background: #eef0f6; overflow: hidden; margin-top: 12px; display: flex; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--indigo)); }

/* ── سطر «ينتظر خطوة» ───────────────────────────────────── */
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line-2); }
.todo:last-child { border-bottom: 0; }
.todo a { font-weight: 700; color: var(--ink); }
.todo a:hover { color: var(--indigo-d); }
.todo .muted { flex: 1 1 200px; }

/* ── رمز النظام في الجدول ───────────────────────────────── */
.ico-sm { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-size: 16px; flex-shrink: 0; }
.t-sky     { background: #e0f2fe; color: #0369a1; }
.t-violet  { background: #ede9fe; color: #6d28d9; }
.t-emerald { background: #d1fae5; color: #047857; }
.t-amber   { background: #fef3c7; color: #b45309; }
.t-rose    { background: #ffe4e6; color: #be123c; }
.t-slate   { background: #f1f2f7; color: #475569; }
.t-indigo  { background: var(--indigo-soft); color: var(--indigo-dd); }
.t-cyan    { background: #e0f7fa; color: #0e7490; }

header.top .wrap form { display: inline-flex; }

/* ── صندوق البرومبت ──────────────────────────────────────── */
.prompt-box {
  margin: 0; padding: 22px; max-height: 62vh; overflow: auto;
  background: #0b1020; color: #c7d2fe;
  font: 12.5px/1.95 var(--mono);
  white-space: pre-wrap; word-break: break-word;
  direction: rtl; text-align: right;
}
.prompt-box::-webkit-scrollbar { width: 9px; }
.prompt-box::-webkit-scrollbar-thumb { background: #2a3360; border-radius: 6px; }

/* ── رأس اللوحة: بطاقة البرومبت ليلاً ─────────────────────── */
/*
 * البطاقة الوحيدة الداكنة في المحتوى، ولها وحدها شفقُ الهبوط وشبكتُه.
 * ليلٌ في كل بطاقة يُطفئ الليل؛ وليلٌ واحد في رأس الصفحة يقول «ابدأ من هنا».
 */
.promo {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 20px; padding: 26px 28px; margin-bottom: 18px;
  border-radius: var(--radius-lg); text-decoration: none; color: #fff;
  background: radial-gradient(120% 160% at 100% 0%, #1e1b4b 0%, #0a1026 52%, #050816 100%);
  box-shadow: 0 30px 60px -36px rgba(79, 70, 229, .75), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  transition: transform .2s, box-shadow .2s;
}
.promo:hover { text-decoration: none; transform: translateY(-2px);
  box-shadow: 0 36px 70px -36px rgba(79, 70, 229, .9), 0 0 0 1px rgba(255, 255, 255, .06) inset; }
.promo:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; border-radius: var(--radius-lg); }
.promo > * { position: relative; z-index: 1; }
.promo > .sky, .promo > .grid-bg { position: absolute; z-index: 0; }
.promo .ico {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #fff; font-size: 22px;
  flex-shrink: 0; box-shadow: 0 10px 28px -8px rgba(99, 102, 241, .9), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.promo .ico svg { width: 24px; height: 24px; }
.promo .tx { flex: 1; min-width: 0; }
.promo .eyebrow { margin-bottom: 8px; }
.promo .tx b { display: block; font-size: 19px; font-weight: 700; color: #fff; margin-bottom: 4px; line-height: 1.4; }
.promo .tx > span:not(.eyebrow) { font-size: 14px; color: #aab4d6; line-height: 1.8; display: block; max-width: 640px; }
.promo .go {
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 12px;
  background: var(--grad-btn); box-shadow: 0 12px 30px -10px rgba(99, 102, 241, .95), inset 0 1px 0 rgba(255, 255, 255, .25);
}
@media (max-width: 700px) {
  .promo { flex-wrap: wrap; padding: 22px 20px; gap: 14px; }
  .promo .ico { width: 44px; height: 44px; border-radius: 13px; }
  .promo .go { width: 100%; justify-content: center; }
}

/* الشفق والشبكة — من البطل، أخفتُ منه، ولا يُرسمان إلا تحت الليل. */
.sky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.sky i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45; animation: drift 22s ease-in-out infinite alternate; }
.sky i:nth-child(1) { width: 380px; height: 380px; background: #4338ca; top: -200px; right: -80px; }
.sky i:nth-child(2) { width: 320px; height: 320px; background: #0891b2; top: -160px; left: 8%; opacity: .32; animation-delay: -8s; }
.sky i:nth-child(3) { width: 340px; height: 260px; background: #9333ea; bottom: -200px; left: 40%; opacity: .22; animation-delay: -14s; }
@keyframes drift { to { transform: translate3d(40px, 30px, 0) scale(1.1); } }
.grid-bg { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 60% 90% at 85% 0%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse 60% 90% at 85% 0%, #000 20%, transparent 75%); }

/* عنوانٌ صغير فوق العنوان — بلا تباعد أحرف، فالنصّ عربي. */
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  padding: 3px 11px; border-radius: 999px;
  color: var(--indigo-d); background: rgba(99, 102, 241, .09); border: 1px solid rgba(99, 102, 241, .16);
}
.promo .eyebrow, .auth .eyebrow { color: #c7d2fe; background: rgba(129, 140, 248, .12); border-color: rgba(129, 140, 248, .25); }
.grad-t { background: linear-gradient(100deg, #a5b4fc 0%, #67e8f9 45%, #6ee7b7 85%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── اللوحة الرئيسية ─────────────────────────────────────── */
.dash { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 18px; margin-top: 18px; align-items: start; }
.dash > * { min-width: 0; }
.stack { display: grid; gap: 18px; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }

/* صفٌّ في «قيد الإنتاج الآن» — اسمٌ وحالة وعدّاد، ثم شريطه أو سببُ انتظاره. */
.job { padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.job:last-child { border-bottom: 0; }
.job-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.job-top a { font-weight: 700; color: var(--ink); }
.job-top .n { margin-inline-start: auto; font-family: var(--font-latin); }
.job .bar { margin-top: 10px; }
.queue-line { margin: 0; padding: 12px 20px; border-bottom: 1px solid var(--line-2); background: #fafbfe; }
.queue-line b { color: var(--ink-2); }

/* حلقة الجاهزية — نسبة الفحوص الناجحة، تُرسم من عددها لا تُزيَّن. */
.ring-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.ring { width: 64px; height: 64px; flex-shrink: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .trk { stroke: #eef0f6; }
.ring .val { stroke: var(--c, var(--indigo)); stroke-linecap: round; }
.ring-row b { font-family: var(--font-latin); font-size: 22px; font-weight: 800; display: block; line-height: 1.2; }
.ring-row span { font-size: 13px; color: var(--muted); }
.lgd { display: grid; gap: 9px; font-size: 13.5px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.lgd div { display: flex; align-items: center; gap: 9px; }
.lgd i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex-shrink: 0; }
.lgd b { margin-inline-start: auto; font-family: var(--font-latin); font-weight: 700; }

/* ── قيمة مشتقّة من الملفّ (لا تُحرَّر هنا) ──────────────── */
.from-file {
  display: inline-block; font-size: 10.5px; font-weight: 600; color: var(--indigo-dd);
  background: var(--indigo-soft); padding: 0 8px; border-radius: 999px; margin-inline-start: 6px; line-height: 1.8;
}
.derived {
  margin: 0; padding: 10px 13px; border-radius: 10px;
  background: #fafbfe; border: 1px dashed var(--line-strong);
  font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.7;
}
.derived.empty { font-weight: 500; color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: start; padding: 10px 13px; }

/* ── تبويبات داخل الصفحة ─────────────────────────────────── */
/* شرائح كـ`.chip` في الهبوط: المختار ليليٌّ مُصمَت، والباقي أبيض بحدّ. */
.tabs-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font: inherit;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  padding: 7px 16px; border-radius: 999px; transition: background .16s, color .16s, border-color .16s;
}
.tab:hover { border-color: #b9bed1; }
.tab.on { color: #fff; background: var(--side); border-color: var(--side); }
.hidden { display: none; }

.prompt-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line-2); background: #fafbfe;
}

/* ── المستخدمون ──────────────────────────────────────────── */
.av-sm {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.creds {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  margin-top: 8px; font-weight: 500;
}
.creds span { font-size: 12.5px; color: #065f46; font-weight: 600; }
.creds code {
  font-family: var(--mono); direction: ltr; text-align: left;
  background: #fff; border: 1px solid var(--ok-line); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; color: var(--ink); user-select: all; word-break: break-all;
}

/* ── صفحة البرومبت: ضبطٌ عريض + معاينة لاصقة ─────────────── */

/*
  ⚠️ **الضبط أخذ العرض والمعاينة أخذت العمود** — وكان العكس.
  تسعةَ عشرَ خياراً في عمودٍ عرضُه ٣٢٠ بكسلاً تصير قائمةَ تمرير: يُضبط أوّلها
  ويُنسى آخرها، ولا يُرى أثرُ اختيارٍ على جيرانه. والمعاينة نصٌّ يُقرأ سطراً
  سطراً في الغالب، فيكفيها عمودٌ لاصق.
*/
.page:has(.prompt-layout) { max-width: 1460px; }

.prompt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 22px; align-items: start; }
.prompt-layout > * { min-width: 0; }

/* ── «ما تريد شرحه»: الحقل الذي لا يعرفه غير كاتبه ───────── */
.scope-card {
  border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
  background: linear-gradient(120deg, #fffbeb 0%, #fffdf7 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 26px -18px rgba(217, 119, 6, .5);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.scope-card.filled {
  border-color: var(--mint); background: linear-gradient(120deg, #f0fdf4 0%, #f7fefb 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 26px -20px rgba(5, 150, 105, .45);
}
/* نبضةٌ عند النسخ وهو فارغ — تنبيهٌ لا منع. */
.scope-card.nudge { animation: scope-nudge .45s ease 2; }
@keyframes scope-nudge {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(6px); }
  70% { transform: translateX(-6px); }
}

.scope-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.scope-ico {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--amber, #f59e0b); color: #fff; font-size: 17px; transition: background .2s;
  box-shadow: 0 8px 18px -8px rgba(217, 119, 6, .8);
}
.scope-card.filled .scope-ico { background: #10b981; box-shadow: 0 8px 18px -8px rgba(5, 150, 105, .8); }
.scope-head b { display: block; font-size: 15.5px; font-weight: 700; line-height: 1.5; }
.req {
  font-size: 10.5px; font-weight: 600; color: var(--warn); background: #fde68a;
  padding: 1px 8px; border-radius: 999px; margin-inline-start: 7px; vertical-align: 2px;
}
.scope-card.filled .req { color: var(--ok); background: var(--ok-line); }
.scope-state { font-size: 13px; font-weight: 500; color: #b45309; }
.scope-card.filled .scope-state { color: var(--ok); }

.scope-card textarea {
  width: 100%; display: block; resize: vertical; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px 14px;
  font: inherit; font-size: 14.5px; line-height: 1.8; color: var(--ink);
}
.scope-card textarea::placeholder { color: var(--faint); }
.scope-card textarea:focus {
  outline: 0; border-color: var(--indigo); box-shadow: var(--ring);
}

/* ── مجموعات الخيارات ───────────────────────────────────── */
.opts-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 14px; }
.opts-toolbar b { font-size: 15px; font-weight: 700; }

/*
  عمودٌ واحد عريض لا عمودان: الخيار صفٌّ كامل — عنوانه يميناً وشرائحه تمتدّ
  يساراً — فتُقرأ الشرائح كلّها في سطرٍ واحد بلا لفٍّ ولا تمرير.
*/
.opt-card { margin: 0 0 16px; padding: 18px 20px; }

.opt-group { font-size: 12px; font-weight: 600; color: var(--indigo-d);
  margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }

.opt { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; align-items: start; }
.opt + .opt { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.opt-label { padding-top: 5px; }
.opt-title { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin: 0; }
.opt-desc { font-size: 12px; line-height: 1.7; font-weight: 400; color: var(--muted); margin: 6px 0 0; }

/*
  خيارٌ مُبرَز — لِما لا يصحّ أن يُمرَّ عليه. وأوّلُه «شاشات خلف تسجيل الدخول»:
  بلا حسابٍ صحيح يقف المتصفّح عند نموذج الدخول ويخرج الفيديو كلُّه تسجيلاً له.
*/
.opt.key {
  grid-template-columns: 230px minmax(0, 1fr); align-items: center;
  padding: 15px 17px; border-radius: 12px; border: 1px solid var(--run-line);
  background: linear-gradient(120deg, #f3f4ff 0%, #f5f3ff 100%);
}
.opt.key .opt-label { padding-top: 0; }
.opt.key .opt-title { font-size: 14px; color: var(--indigo-dd); }
.opt.key .opt-desc { color: var(--ink-2); font-size: 12.5px; }

/* ── المعاينة ───────────────────────────────────────────── */
.preview { position: sticky; top: calc(var(--head-h) + 20px); }
.preview .prompt-box { max-height: calc(100vh - var(--head-h) - 210px); }
.preview-foot { font-size: 12.5px; line-height: 1.75; margin: 12px 2px 0; }
.preview-foot .mono { font-size: 11.5px; }

/* اختيار واحد — شرائح */
.opt-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-opt { cursor: pointer; margin: 0; position: relative; }
.chip-opt input { position: absolute; opacity: 0; pointer-events: none; }
.chip-opt span {
  display: block; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); transition: .14s;
}
.chip-opt span em { display: block; font-style: normal; font-size: 11px; font-weight: 400;
  color: var(--muted); margin-top: 1px; }
.chip-opt:hover span { border-color: #a5b4fc; }
.chip-opt input:focus-visible + span { outline: 2px solid var(--indigo); outline-offset: 2px; }
.chip-opt input:checked + span {
  background: var(--indigo-soft); border-color: var(--indigo); color: var(--indigo-dd);
  box-shadow: inset 0 0 0 1px var(--indigo);
}
.chip-opt input:checked + span em { color: var(--indigo-d); }

/* اختيار متعدّد — مربّعات تتوزّع على العرض لا تتكدّس عموداً */
.opt-checks { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 6px; }
.check-opt { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.check-opt input { width: 16px; height: 16px; accent-color: var(--indigo-d); flex-shrink: 0; margin: 0; }
.check-opt:hover { color: var(--ink); }

@media (max-width: 1400px) {
  .prompt-layout { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* عمودٌ واحد: الضبط أولاً ثم المعاينة — والمعاينة تتوقّف عن اللصوق. */
@media (max-width: 1150px) {
  .prompt-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .preview .prompt-box { max-height: 62vh; }
}

/* عنوان الخيار فوق شرائحه حين يضيق الصفّ عن الاثنين جنباً إلى جنب. */
@media (max-width: 720px) {
  .opt, .opt.key { grid-template-columns: 1fr; gap: 10px; align-items: start; }
  .opt-label { padding-top: 0; }
}

/* ── صفحة الدخول — ليلُ البطل ─────────────────────────────── */
/*
 * الصفحة الوحيدة الداكنة كلّها: هي الباب بين الهبوط واللوحة، فتأخذ ليلَ
 * الأوّل وتسلّم إلى نهار الثانية. والبطاقة زجاجٌ على الشفق، وحقولها داكنة
 * بنصٍّ فاتح — حقلٌ أبيض في ليلٍ يقفز من الصفحة قبل عنوانه.
 */
body.auth {
  min-height: 100vh; margin: 0; display: grid; place-items: center; padding: 32px 16px;
  background: var(--night); color: #eef2ff; position: relative; overflow-x: hidden;
}
.auth > .sky, .auth > .grid-bg { position: fixed; }
.auth > .sky i:nth-child(1) { width: 640px; height: 640px; top: -320px; right: -160px; filter: blur(100px); opacity: .5; }
.auth > .sky i:nth-child(2) { width: 540px; height: 540px; top: -240px; left: -180px; filter: blur(100px); opacity: .45; }
.auth > .sky i:nth-child(3) { width: 600px; height: 400px; top: auto; bottom: -260px; left: 50%; margin-left: -300px; filter: blur(100px); opacity: .3; }
.auth > .grid-bg { background-size: 60px 60px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 25%, transparent 75%);
          mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 25%, transparent 75%); }
.auth-box { position: relative; z-index: 1; width: min(420px, 100%); }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .mark {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #22d3ee); color: #fff;
  box-shadow: 0 14px 40px -10px rgba(99, 102, 241, .95), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.auth-brand .mark svg { width: 100%; height: 100%; }
.auth-brand h1 { margin: 12px 0 6px; font-size: 26px; font-weight: 700; color: #fff; }
.auth-brand p { margin: 0; color: var(--side-muted); font-size: 14.5px; }
.auth-card {
  border-radius: 20px; padding: 26px;
  background: rgba(14, 19, 48, .72); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 40px 100px -30px rgba(79, 70, 229, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.auth-card label { color: #c7d2fe; }
.auth-card input[type=text], .auth-card input[type=password] {
  height: 46px; background: rgba(255, 255, 255, .06); color: #fff; border-color: rgba(255, 255, 255, .16);
}
.auth-card input:hover { border-color: rgba(255, 255, 255, .28); }
.auth-card input:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(129, 140, 248, .25); }
.auth-card input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 40px #1a2050 inset; caret-color: #fff; }
.auth-card .check-line { color: #dfe5ff; font-weight: 500; }
.auth-card .btn.primary { height: 48px; font-size: 15px; width: 100%; margin-top: 20px; }
.auth-card .btn:focus-visible, .auth-card :focus-visible { outline-color: #a5b4fc; }
.auth-card .note.err { background: rgba(239, 68, 68, .14); border-color: rgba(248, 113, 113, .4); color: #fecaca; }
.auth-back { text-align: center; margin: 22px 0 0; font-size: 14px; }
.auth-back a { color: var(--side-muted); }
.auth-back a:hover { color: #fff; }
.auth-back a:focus-visible { outline-color: #a5b4fc; }

/* ── الحركة لمن طلب تقليلها ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* أرقامٌ في الجدول — بخطٍّ لاتيني وعرضٍ ثابت، فتصطفّ الخانات عمودياً. */
td.num { font-family: var(--font-latin); font-variant-numeric: tabular-nums; direction: ltr; text-align: right; white-space: nowrap; }

/* سطر الحالة أعلى صفحة الدرس — شاراته ثم معرّفه. */
.status-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 0; }
.status-line .mono { margin-inline-start: 4px; }

/* ── الهاتف: المؤشّرات اثنين اثنين، والجداول بطاقات ─────────── */
/*
 * جدولٌ يتمرّر أفقياً على الهاتف يُريك عمودين ويُخفي الخمسة الباقية خلف
 * إيماءةٍ لا يدلّ عليها شيء — والحالة والنشر في المخفيّ. فالصفّ هنا يصير
 * بطاقة: الاسم سطرٌ كامل، وما بعده خاناتٌ متجاورة، والإجراءات ذيلُها.
 *
 * `.stack-sm` على الجدول، والترتيب الخاصّ بكل شاشة بـ`order` لا بإعادة
 * ترتيب الأعمدة في القالب — فالحاسوب لا يمسّه شيء.
 */
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-top { gap: 8px; margin-bottom: 6px; }
  .kpi-ic { width: 28px; height: 28px; border-radius: 9px; }
  .kpi-ic svg { width: 15px; height: 15px; }
  .kpi .l { font-size: 13px; }
  .kpi .v { font-size: 26px; }

  .card.pad { padding: 18px; }
  .card-head { padding: 14px 16px; }

  .scroll-x:has(> table.stack-sm) { overflow: visible; }
  .scroll-x > table.stack-sm { min-width: 0; }
  table.stack-sm, table.stack-sm tbody { display: block; }
  table.stack-sm thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  table.stack-sm tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  }
  table.stack-sm tr:last-child { border-bottom: 0; }
  table.stack-sm td { display: block; padding: 0; border: 0; min-width: 0; text-align: start !important; width: auto !important; }
  table.stack-sm td:first-child, table.stack-sm td:last-child { grid-column: 1 / -1; }
  table.stack-sm td:last-child:not(:first-child) { padding-top: 4px; }
  table.stack-sm td:nth-child(even):not(:last-child) { justify-self: end; }
  table.stack-sm td.num { direction: inherit; }
  /* الرقم بلا عمودٍ فوقه لا يُقرأ — فيحمل عنوانه معه. */
  table.stack-sm td[data-label]::before {
    content: attr(data-label) ' '; font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--muted);
  }
  table.stack-sm td[data-label] + td[data-label] { justify-self: end; }

  /* الفيديوهات: الاسم، الدورة، ثم الحالة بجانب النشر، ثم التقدّم بجانب المدّة. */
  table.stack-sm.videos-t td:nth-child(2) { grid-column: 1 / -1; justify-self: start; }
  table.stack-sm.videos-t td:nth-child(3) { order: 3; }
  table.stack-sm.videos-t td:nth-child(5) { order: 4; justify-self: end; }
  table.stack-sm.videos-t td:nth-child(4) { order: 5; justify-self: stretch; max-width: 220px; }
  table.stack-sm.videos-t td:nth-child(6) { order: 6; justify-self: end; }
  table.stack-sm.videos-t td:nth-child(7) { order: 7; }

  /* آخر ما عُمل عليه: الاسم، ثم الدورة بجانب الوقت، ثم الحالة بجانب النشر. */
  table.stack-sm.recent-t td:nth-child(2) { order: 2; justify-self: start; }
  table.stack-sm.recent-t td:nth-child(5) { order: 3; justify-self: end; }
  table.stack-sm.recent-t td:nth-child(3) { order: 4; justify-self: start; }
  table.stack-sm.recent-t td:nth-child(4) { order: 5; justify-self: end; }
  table.stack-sm.recent-t td:last-child { grid-column: auto; }
}

/* ── اللغات ذات الاتجاه LTR ─────────────────────────────────
 * ما لا خاصّية منطقية له يُعكس هنا: الأرقام تُحاذى إلى بداية عمودها، والبريد
 * إلى جهة صورته، وسهمُ «رجوع» المرسوم لـRTL ينقلب.
 * وخطوط اللاتينية وCJK والهندية: `Inter` أوّلاً، ثم خطوط النظام لما لا يغطّيه.
 */
:lang(en), :lang(zh), :lang(es), :lang(fr), :lang(de), :lang(pt), :lang(ru), :lang(ja),
:lang(ko), :lang(hi), :lang(id), :lang(tr), :lang(it), :lang(nl) {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans", "PingFang SC", "Hiragino Sans",
          "Microsoft YaHei", "Malgun Gothic", "Nirmala UI", sans-serif;
}
[dir="ltr"] td.num { text-align: left; }
[dir="ltr"] .side-foot .em { text-align: left; }
[dir="ltr"] .side { background:
    radial-gradient(120% 50% at 0% 0%, rgba(99, 102, 241, .22) 0%, transparent 60%),
    linear-gradient(180deg, var(--side) 0%, #0b1029 100%); }
[dir="ltr"] svg:has(> use[href="#n-back"]) { transform: scaleX(-1); }

/* قائمة اللغات في الهيدر — كرةٌ أرضية ثم الاسم بلغته. */
.langs { position: relative; display: inline-flex; align-items: center; color: var(--muted); flex-shrink: 0; }
.langs svg { position: absolute; inset-inline-start: 10px; width: 16px; height: 16px; pointer-events: none; }
.langs select {
  min-height: 38px; padding-block: 0; padding-inline-start: 32px; font-size: 13px; font-weight: 600;
  max-width: 150px; width: auto; border-radius: 10px;
}
.side-langs { display: none; margin-bottom: 10px; }
.side-langs select { width: 100%; max-width: none; background-color: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; }
.side-langs option { background: #0e1330; color: #e6ebff; }
.side-langs svg { color: #c7d2fe; }
@media (max-width: 600px) {
  body.shell > .head .langs { display: none; }
  .side-langs { display: flex; }
}
/* صفحة الدخول: القائمة في الزاوية العليا، على الليل. */
.auth-langs { position: fixed; top: 16px; inset-inline-end: 16px; z-index: 5; }
.auth-langs select { background-color: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #e6ebff; }
.auth-langs option { background: #0e1330; color: #e6ebff; }
.auth-langs svg { color: #c7d2fe; }
