/*
 * لوحة تحكّم نمليه.
 *
 * لا تُعرّف هنا أي ألوان — كلها من متغيرات :root في style.css، فترث اللوحة
 * الوضع الليلي وأي تغيير في هوية المطعم مجانًا وبلا تكرار.
 *
 * الموقع العام مقيّد بعرض ٤٦٠ بكسل (إطار جوّال)، أما اللوحة فتُدار غالبًا من
 * شاشة أكبر — لذلك لها حاوية عريضة خاصة بها.
 */

/* إعادة ضبط صندوق القياس. كانت تصل اللوحة تاريخيًا عبر style.css الكامل،
   وانقطعت يوم فصلنا الرموز في tokens.css — فعاد content-box الافتراضي:
   width:100% + padding = فيض أفقي 32px على الجوال وقصّ أطراف الصفوف. */
*, *::before, *::after { box-sizing: border-box; }
/* هامش body الافتراضي (8px) كان يفصل الشريط الجانبي عن حافة الشاشة —
   إعادة الضبط تعيش في style.css الخاص بصفحة الزبون ولا تصل هنا. */
html, body { margin: 0; padding: 0; }

/* بطاقة وحقل بأسلوب المخطّط (بطاقات فاتحة على أرضية أغمق قليلًا).
   القيم دافئة لتبقى من عائلة ثيم نملية لا بياض المرجع المحايد. */
.admin-body {
  --card: #FFFDF8;
  --card-tint: #FBF7EC;
  --field: #F4EFE1;
  --line: #E7DFCC;
  --red: #E2445C;
  /* دلاليات بنسختين: نص «نجح/فشل» بأخضر داكن على بطاقة فاتحة يصير
     غير مقروء إذا انعكس الثيم — النسخة الليلية أسفل. */
  --ok: #3E6B3A;
  --danger-text: #C13A4B;
  /* ظلال بصبغة زيتونية لا رمادية — ظل محايد فوق أرضية دافئة يبان غريبًا */
  --shadow-1: 0 1px 4px rgba(44, 49, 34, 0.05);
  --shadow-2: 0 6px 22px rgba(44, 49, 34, 0.07);
  --shadow-3: 0 14px 40px rgba(24, 27, 18, 0.2);

  min-height: 100vh;
  display: block;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════════════════
   رموز «يلا بلس» — طبقة تصميم شاشات الإعدادات، منقولة حرفيًا من
   المواصفة. تعيش هنا لا في `settings.css` لأنّها رموز اللوحة كلها:
   الشريط الجانبي والتبويبات تستعملها أيضًا.
   ══════════════════════════════════════════════════════════════════ */

.admin-body {
  --y-brand: #1f7a4d;          /* الأخضر الأساسي — الأزرار والحالة النشطة */
  --y-brand-soft: #eaf5ef;     /* خلفية العنصر النشط والمفاتيح المقسومة */
  --y-brand-ink: #ffffff;
  --y-success: #16a34a;        /* المفاتيح ومربّعات الاختيار المفعّلة */
  --y-danger: #e11d48;         /* تجاهل · حذف · إزالة */
  --y-ink: #111827;
  --y-ink-2: #374151;
  --y-muted: #6b7280;
  --y-faint: #9ca3af;          /* نص التلميحات و«هذا الحقل اختياري» */
  --y-line: #e8e6e1;
  --y-line-soft: #f1f0ec;      /* فواصل صفوف الجداول */
  --y-page: #fbfaf8;
  --y-card: #ffffff;
  --y-field: #f3f4f2;
  --y-prefix: #e7e9e4;         /* بادئة الرابط داخل الحقل */
  --y-head: #efece5;           /* رأس الجدول — بيج */
  --y-chip: #e5e7eb;
  --y-rad: 14px;               /* بطاقة داخلية */
  --y-rad-lg: 20px;            /* بطاقة خارجية */
  --y-rad-pill: 999px;
  --y-rad-soft: 12px;          /* منطقة النص متعدّد الأسطر */
  --y-field-h: 40px;
  --y-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --y-font: "IBM Plex Sans Arabic", "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* المقابل الليلي. الأخضر يُرفع قليلًا لا لجمالية بل لأنّ ‎#1f7a4d‎ على
   أرضية داكنة ينزل تحت 4.5:1 ويصير نص الأزرار غير مقروء. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .admin-body {
    --y-brand: #34a06a; --y-brand-soft: #16301f; --y-brand-ink: #06120b;
    --y-success: #35b364; --y-danger: #f2557a;
    --y-ink: #E9E4DA; --y-ink-2: #CFC9BD; --y-muted: #A19A8C; --y-faint: #8A8377;
    --y-line: #3A3F33; --y-line-soft: #2F342A;
    --y-page: #1B1D15; --y-card: #23271C; --y-field: #2C3123;
    --y-prefix: #343A2A; --y-head: #30352A; --y-chip: #383E2E;
    --y-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  }
}
[data-theme="dark"] .admin-body {
  --y-brand: #34a06a; --y-brand-soft: #16301f; --y-brand-ink: #06120b;
  --y-success: #35b364; --y-danger: #f2557a;
  --y-ink: #E9E4DA; --y-ink-2: #CFC9BD; --y-muted: #A19A8C; --y-faint: #8A8377;
  --y-line: #3A3F33; --y-line-soft: #2F342A;
  --y-page: #1B1D15; --y-card: #23271C; --y-field: #2C3123;
  --y-prefix: #343A2A; --y-head: #30352A; --y-chip: #383E2E;
  --y-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

/* المقابل الليلي لرموز البطاقة/الحقل — بدونه تبقى البطاقات فاتحة على
   خلفية داكنة ويصير النص الفاتح غير مقروء فوقها. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .admin-body {
    --card: #23271C; --card-tint: #272B20; --field: #2C3123; --line: #3A4030;
    --ok: #9CC18F; --danger-text: #F0798B;
    --shadow-1: 0 1px 4px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 6px 22px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 14px 40px rgba(0, 0, 0, 0.5);
  }
}
[data-theme="dark"] .admin-body {
  --card: #23271C; --card-tint: #272B20; --field: #2C3123; --line: #3A4030;
  --ok: #9CC18F; --danger-text: #F0798B;
  --shadow-1: 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 6px 22px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.is-hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; line-height: 1.7; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ───────── بوابة الدخول ───────── */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gate-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  text-align: center;
}
.gate-sub { margin: 0 0 6px; text-align: center; color: var(--text-muted); font-size: 14px; }
.gate-note { margin: 4px 0 0; text-align: center; color: var(--text-muted); font-size: 11.5px; line-height: 1.6; }
.gate-error {
  margin: 0;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--danger-text) 14%, transparent);
  color: var(--danger-text);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.gate-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg);
  border-radius: 12px;
  margin: 4px 0 10px;
}
.gate-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.gate-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#gateForm, #staffGateForm, #inviteForm { display: flex; flex-direction: column; gap: 14px; }

/* ───────── الهيكل ───────── */

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

/* الشريط الجانبي — على حافة البداية (اليمين في RTL) كما في المرجع:
   شعار أعلى، بنود بأيقونات، وأسفله «حفظ» ومؤشر التغييرات. */
.side {
  width: 216px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px 16px;
  background: var(--card, var(--bg));
  border-inline-end: 1px solid var(--line, var(--ring));
  overflow-y: auto;
}
.side-logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  padding: 0 10px;
  line-height: 1.15;
}
.side-logo small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 3px;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  position: relative;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-btn svg { width: 17px; height: 17px; flex: none; }
.nav-btn:hover { background: var(--card-tint, var(--surface)); }
.nav-btn.is-active { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 700; }
/* مؤشر الموضع: شريط قصير على حافة البداية — الحالة تُقرأ شكلًا لا لونًا فقط */
.nav-btn.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3.5px;
  height: 60%;
  border-radius: 99px;
  background: var(--accent);
}
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line, var(--ring));
}
.side-foot .dirty-flag { text-align: center; }

/* على الشاشات الضيقة يعود شريطًا أفقيًا أعلى الصفحة */
@media (max-width: 860px) {
  .app { display: block; }
  .side {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 10px 14px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line, var(--ring));
  }
  /* سطران: الشعار و«حفظ» أولًا، ثم التنقّل صفًّا أفقيًّا قابلًا للتمرير —
     تركهما في سطر واحد على ٣٩٠ بكسل كدّس البنود عموديًّا. */
  .side-logo { font-size: 20px; padding: 0; order: 0; }
  .side-foot { order: 1; margin-top: 0; margin-inline-start: auto; flex-direction: row; align-items: center; padding-top: 0; border-top: 0; }
  .nav-btn.is-active::before { display: none; }
  .side-logo small { display: none; }
  .side-foot .btn-block { width: auto; }
  .side-foot .dirty-flag { display: none; }
  .side-nav {
    order: 2; flex: 1 1 100%;
    flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; scrollbar-width: none;
  }
  .nav-btn { width: auto; padding: 7px 11px; white-space: nowrap; }
  .nav-btn svg { width: 15px; height: 15px; }
}

.dirty-flag {
  font-size: 12px;
  font-weight: 700;
  color: #b8860b;
  background: color-mix(in srgb, #b8860b 16%, transparent);
  padding: 6px 12px;
  border-radius: 999px;
}

.app-main { flex: 1; min-width: 0; padding: 26px 26px 64px; max-width: 1100px; }
.view { display: flex; flex-direction: column; gap: 20px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ───────── الأزرار ───────── */

.btn {
  appearance: none;
  border: 1px solid var(--ring);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 17px;
  border-radius: 99px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--red, #E2445C); border-color: color-mix(in srgb, #E2445C 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, #E2445C 12%, transparent); }
/* «تجاهل» — نص أحمر بلا إطار، كما في هيدر نماذج المخطّط */
.btn-cancel { background: transparent; color: var(--red, #E2445C); border-color: transparent; }
.btn-cancel:hover { background: color-mix(in srgb, #E2445C 10%, transparent); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 13px; font-size: 12.5px; }

.icon-btn {
  appearance: none;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { background: var(--ring); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ───────── الحقول ───────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.input {
  font-family: inherit;
  /* ١٦ بكسل حدًّا أدنى — أقل منها يُكبّر سفاري على iOS الصفحة تلقائيًا عند التركيز */
  font-size: 16px;
  padding: 9px 12px;
  min-height: 38px;
  border: 1px solid var(--line, var(--ring));
  border-radius: 11px;
  background: var(--field, var(--bg));
  color: var(--text);
  width: 100%;
}
/* حلقة ناعمة بدل outline الحاد: الحدّ يتلوّن والهالة تتدرّج حوله */
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
textarea.input { resize: vertical; line-height: 1.6; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.form-msg { margin: 0; font-size: 13px; font-weight: 600; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--danger-text); }

/* ───────── اللوحات ───────── */

.panel {
  background: var(--card, var(--surface));
  border: 1px solid var(--line, var(--ring));
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-2);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-title { margin: 0 0 12px; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.panel-head .panel-title { margin: 0; }
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .panel-row { grid-template-columns: 1fr; } }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ───────── بطاقات الأرقام ───────── */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--card, var(--surface));
  border: 1px solid var(--line, var(--ring));
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: start;
  color: var(--text);
}
.stat:hover { background: var(--card-tint, var(--surface-2)); }
.stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat-value { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }

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

.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--bg);
  border-inline-start: 4px solid var(--ring);
}
.alert.error { border-inline-start-color: var(--danger-text); }
.alert.warning { border-inline-start-color: #b8860b; }
.alert.info { border-inline-start-color: var(--accent); }
.alert-count {
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: center;
}
.alert.error .alert-count { color: var(--danger-text); }
.alert.warning .alert-count { color: #b8860b; }
.alert.info .alert-count { color: var(--accent); }
.alert-body strong { display: block; font-size: 14.5px; margin-bottom: 3px; }
.alert-body small { display: block; font-size: 12.5px; color: var(--text-muted); line-height: 1.65; }
.alert-items { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.alert-chip {
  font-size: 11.5px;
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.alert-chip:hover { background: var(--ring); }
.alert-ok {
  padding: 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
  font-weight: 700;
  font-size: 14.5px;
}

/* ───────── التقارير ───────── */

.segment { display: flex; gap: 3px; background: var(--bg); padding: 3px; border-radius: 999px; }
.segment button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
}
.segment button.is-active { background: var(--accent); color: var(--accent-ink); }
.segment button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.reports-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
@media (max-width: 860px) { .reports-grid { grid-template-columns: 1fr; } }
.report-card { background: var(--bg); border-radius: 14px; padding: 16px; }
.report-card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--text-muted); }
.bignum { font-size: 34px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; margin: 0 0 10px; line-height: 1.1; }

.chart { margin: 0; color: var(--accent); }
.chart svg { width: 100%; height: 90px; display: block; }
.chart-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
/* البديل النصّي للرسم — يقرأه قارئ الشاشة ولا يظهر بصريًا. الرسم وحده لا
   يُقرأ صوتيًا مهما أضفنا من aria، وهذا هو البديل الموصى به رسميًا. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.top-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.top-list li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.top-rank { font-weight: 800; color: var(--text-muted); min-width: 18px; font-variant-numeric: tabular-nums; }
.top-name { flex: 1; font-weight: 600; }
.top-name.deleted { color: var(--text-muted); font-style: italic; }
.top-count { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ───────── QR ───────── */

.qr-wrap { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-canvas { border-radius: 10px; background: #fff; padding: 8px; }
.qr-side { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: 9px; }
.qr-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
  direction: ltr;
  text-align: left;
}

/* ───────── الأقسام والأصناف ───────── */

.cat-block { background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.cat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; flex: 1; }
.cat-meta { font-size: 12px; color: var(--text-muted); }
.reorder { display: flex; gap: 3px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px;
  border-radius: 11px;
  background: var(--bg);
  margin-bottom: 7px;
}
.item-thumb {
  width: 46px; height: 46px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--plate);
  flex-shrink: 0;
}
.item-thumb-empty {
  width: 46px; height: 46px;
  border-radius: 9px;
  background: var(--plate);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--on-card-muted);
}
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 700; font-size: 14px; }
.item-sub { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.item-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-sold { background: color-mix(in srgb, var(--danger-text) 16%, transparent); color: var(--danger-text); }
.badge-hidden { background: var(--surface-2); color: var(--text-muted); }
.item-actions { display: flex; gap: 4px; align-items: center; }
.empty-note {
  margin: 7px 0;
  padding: 18px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.7;
  border: 1px dashed var(--line, var(--ring));
  border-radius: 14px;
  background: color-mix(in srgb, var(--card, var(--bg)) 55%, transparent);
}

/* ───────── الصور ───────── */

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 13px; }
.img-cell { display: flex; flex-direction: column; gap: 6px; }
.img-cell img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 11px;
  background: var(--plate);
  cursor: pointer;
  border: 2px solid transparent;
}
.img-cell img:hover { border-color: var(--accent); }
.img-cell-foot { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.img-usage { font-size: 11px; color: var(--text-muted); }
.img-usage.orphan { color: #b8860b; font-weight: 600; }

/* ───────── الأدراج ───────── */

/* ══════════════════════════════════════════════════════════════
   اللوحة الجانبية — سلوك الشاشة العاشرة في المخطّط:

     • تنزلق من حافة البداية خلال 220ms
     • عرض ~٥٥–٦٠٪ على الحاسب · ١٠٠٪ على الجوّال
     • هيدر ثابت لا يتمرّر
     • **لا تحجب الشجرة خلفها** — المستخدم يشوف موقعه في القائمة وهو
       يحرّر. الحجاب خفيف جدًّا ولا يغطّي الجانب المتبقّي.
   ══════════════════════════════════════════════════════════════ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 30, 20, 0.10);
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
  opacity: 1;
}
.drawer-overlay.is-hidden { display: none; }

.drawer {
  width: 58%;
  min-width: 380px;
  max-width: 780px;
  /* ارتفاع كامل لا `max-height`: اللوحة الجانبية تلتصق بالحافّتين، وإلا
     قصرت عند نهاية محتواها وظهرت الشجرة من تحتها في منتصف الشاشة. */
  height: 100%;
  background: var(--card, var(--bg));
  border-radius: 0;
  border-inline-end: 1px solid var(--line, var(--ring));
  display: flex;
  flex-direction: column;
  box-shadow: 14px 0 40px rgba(0,0,0,0.18);
  overflow: hidden;
  animation: drawerIn 0.22s cubic-bezier(.22,.9,.3,1) both;
}
[dir="rtl"] .drawer { box-shadow: -14px 0 40px rgba(0,0,0,0.18); }

@keyframes drawerIn {
  from { transform: translateX(var(--drawer-from, -100%)); }
  to   { transform: translateX(0); }
}
[dir="rtl"] .drawer { --drawer-from: 100%; }

/* الدرج المتداخل (نموذج فوق نموذج) يُفتح بنفس النمط فوق سابقه */
.drawer-overlay.is-nested { z-index: 70; background: rgba(20, 30, 20, 0.14); }

@media (max-width: 860px) {
  .drawer { width: 100%; min-width: 0; max-width: none; border-inline-end: 0; }
}

/* الخروج أسرع من الدخول (~٧٥٪ من مدته) وبمنحنى ease-in — العنصر الخارج
   لم يعد محطّ الانتباه فلا يستحق وقتًا. */
.drawer-overlay { transition: background-color 0.16s ease; }
.drawer-overlay.is-closing { background-color: transparent; }
.drawer-overlay.is-closing .drawer {
  animation: drawerOut 0.16s cubic-bezier(.4, 0, 1, 1) both;
}
@keyframes drawerOut {
  to { transform: translateX(var(--drawer-from, -100%)); }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-overlay.is-closing .drawer { animation: none; }
  .drawer-overlay { transition: none; }
}

.drawer-sm { width: 46%; min-width: 340px; max-width: 520px; }
.drawer-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line, var(--ring));
  background: var(--card, var(--bg));
}
.icon-danger { color: var(--red, #E2445C); font-size: 15px; }
.drawer-head h2 { margin: 0; flex: 1; font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.drawer-body { padding: 15px 16px 22px; overflow-y: auto; display: block; }
.drawer-foot {
  display: flex; gap: 9px; flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--ring);
  background: var(--surface);
}
.drawer-foot .btn-danger { margin-inline-start: auto; }

.img-picker { display: flex; gap: 13px; align-items: flex-start; flex-wrap: wrap; }
.img-preview {
  width: 96px; height: 96px;
  border-radius: 12px;
  background: var(--plate);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-picker-actions { display: flex; flex-direction: column; gap: 7px; }

.toggles { display: flex; gap: 13px; flex-wrap: wrap; }
.toggle {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 13px;
  background: var(--surface);
  border-radius: 11px;
  cursor: pointer;
  flex: 1;
  min-width: 190px;
}
.toggle input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); }
.toggle strong { display: block; font-size: 13.5px; }
.toggle small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* ───────── التنبيه المنبثق ───────── */

.toast::before {
  content: "✓";
  font-weight: 800;
  margin-inline-end: 8px;
  opacity: 0.85;
}
.toast.err::before { content: "!"; }
.toast {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 90;
  max-width: 88vw;
  text-align: center;
}
.toast.err { background: #B23A47; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .btn, .nav-btn { transition: none; }
}

/* ═══════════ شعار المطعم ═══════════ */

.logo-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* رقعة شطرنجية تكشف الشفافية: شعار بخلفية بيضاء صلبة يبان فورًا
   هنا بدل أن يُكتشف بعد نشره على خلفية الموقع الكريمية. */
.logo-preview {
  min-width: 190px;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%),
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

.logo-preview img { max-height: 68px; max-width: 240px; object-fit: contain; }

.logo-empty {
  font-size: 12px;
  color: #8a8a8a;
  text-align: center;
  line-height: 1.7;
}

.logo-actions { display: flex; flex-direction: column; gap: 8px; }

/* ══════════════════════════════════════════════════════════════
   شجرة إدارة القائمة — مبنيّة على مخطّط الواجهة المرفق

   الألوان من متغيّرات هوية نمليه (الزيتوني)، لا من أخضر المرجع
   (#17A35A): اللوحة امتداد لموقع المطعم لا لموقع المنافس. البنية
   والتفاعلات منقولة كما هي.
   ══════════════════════════════════════════════════════════════ */

.tree-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}

.tree-search {
  position: relative; display: flex; align-items: center;
  flex: 1 1 260px; max-width: 380px;
}
.tree-search svg {
  position: absolute; inset-inline-start: 12px;
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.tree-search input {
  width: 100%;
  font: inherit; font-size: 14px;
  padding: 9px 38px 9px 14px;
  border: 1px solid var(--line, var(--ring));
  border-radius: 11px;
  background: var(--field, var(--surface));
  color: var(--text);
}
.tree-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.tree-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.tree-count { font-size: 12.5px; color: var(--text-muted); }

/* ── شريط الإجراءات الجماعية ── */
.bulkbar {
  position: sticky; top: 8px; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 13px; margin-bottom: 12px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-card);
  box-shadow: var(--shadow);
}
.bulkbar strong { font-size: 13.5px; }
.bulkbar .grow { flex: 1; }
.bulkbar .btn { background: rgba(255,255,255,0.14); color: inherit; border-color: transparent; }
.bulkbar .btn:hover { background: rgba(255,255,255,0.24); }
.bulkbar .btn-danger { background: rgba(226,68,92,0.9); color: #fff; }
.bulkbar .icon-btn { color: inherit; }

/* ── العقد والصفوف ── */
.tnest {
  margin-inline-start: 16px;
  border-inline-start: 2px dashed var(--line, var(--ring));
  padding-inline-start: 12px;
}
.tnest.is-collapsed { display: none; }

.trow {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; margin: 8px 0;
  border: 1px solid var(--line, var(--ring));
  border-radius: 14px;
  background: var(--card, var(--bg));
  box-shadow: var(--shadow-1);
  transition: transform 0.15s var(--ease-out-quint), box-shadow 0.15s var(--ease-out-quint);
}
@media (hover: hover) {
  .trow:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(44, 49, 34, 0.09); }
}
.trow-menu { background: var(--card, var(--bg)); }
.trow-cat  { background: var(--card-tint, var(--surface)); }
.trow.is-picked { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 26%, transparent); }
/* المخطّط يعرض صف «غير متوفر» باهتًا كاملًا (opacity .55) — نستثني
   أدوات التحكم حتى تبقى واضحة قابلة للنقر. */
.trow.is-off .tthumb, .trow.is-off .tinfo, .trow.is-off .tstate { opacity: 0.55; }
.trow .grow { flex: 1; }

.tcaret {
  width: 22px; height: 22px; flex: none;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s var(--spring, ease);
}
.tcaret.is-closed { transform: rotate(-90deg); }
[dir="rtl"] .tcaret.is-closed { transform: rotate(90deg); }

.tcheck { display: flex; flex: none; }
.tcheck input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.tttl { font-weight: 700; font-size: 14px; }
.trow-item .tttl { font-size: 13.5px; }
.tmeta { font-size: 11.5px; color: var(--text-muted); }

.tthumb {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  object-fit: cover; background: var(--field, var(--surface-2));
}
.tthumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--text-muted); text-align: center;
  border: 1px dashed var(--ring);
}
.tinfo { min-width: 0; }
.tinfo .tsub { display: flex; align-items: center; gap: 7px; margin-top: 3px; flex-wrap: wrap; }

.tprice {
  font-variant-numeric: tabular-nums;
  background: var(--field, var(--surface-2)); border-radius: 7px;
  padding: 1px 8px; font-size: 11.5px; font-weight: 600;
}
.tkcal { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.tghost {
  border: 0; background: transparent; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; padding: 4px 6px; border-radius: 8px;
}
.tghost:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.tstate { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* مفتاح التوفّر — «أكثر إجراء يتكرر يوميًا، وفتح نموذج لأجله خطأ تصميمي».
   لذلك هو زرّ واحد داخل الصف يحفظ فورًا بلا فتح أي نموذج. */
.tg {
  width: 34px; height: 19px; flex: none;
  border: 0; border-radius: 99px; padding: 0; cursor: pointer;
  background: var(--accent); position: relative;
  transition: background 0.16s ease;
}
.tg::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  /* transform لا inset: الإزاحة تعمل على المركّب بلا إعادة تخطيط،
     والنابض الخفيف يعطي القرص «وزنًا». الصفحة RTL دائمًا فالسالب = نحو
     نهاية السطر. */
  transition: transform 0.22s var(--spring, ease);
}
.tg[aria-checked="false"] { background: var(--line, var(--ring)); }
.tg[aria-checked="false"]::after { transform: translateX(-15px); }
.tg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tmove { display: flex; gap: 2px; flex: none; }
.tmove button {
  width: 24px; height: 24px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-muted);
  font-size: 10px; cursor: pointer; line-height: 1;
}
.tmove button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.tmove button:disabled { opacity: 0.3; cursor: default; }

.tkebab {
  width: 28px; height: 28px; flex: none;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.tkebab:hover, .tkebab[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }

.tadd {
  display: flex; justify-content: center;
  padding: 9px; margin: 7px 0;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

/* تركيز مرئي موحّد لكل أدوات الصف الصغيرة — كانت بلا حالة تركيز أصلًا،
   فمستخدم لوحة المفاتيح يضيع بين ٢٣ صفًّا. */
.tghost:focus-visible, .tkebab:focus-visible, .tcaret:focus-visible,
.tmove button:focus-visible, .tcheck input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ── قائمة السياق ── */
.pop {
  position: fixed; z-index: 80;
  width: 130px; padding: 6px;
  border: 1px solid var(--line, var(--ring)); border-radius: 12px;
  background: var(--card, var(--bg));
  box-shadow: var(--shadow-3);
}
.pop button {
  display: block; width: 100%; text-align: start;
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 13px;
  padding: 7px 11px; border-radius: 8px; color: var(--text);
}
.pop button:hover { background: var(--card-tint, var(--surface-2)); }
.pop button.is-danger { color: #E2445C; }

/* ── شريط التراجع ──
   «تراجع لعشر ثوانٍ بعد كل حذف» — الحذف هنا يبقى في الذاكرة ولا يُحفظ
   إلا بضغط «حفظ»، لكن الشريط يمنع الحذف الخاطئ من المرور دون انتباه. */
.undo {
  position: fixed; inset-inline: 0; bottom: 20px;
  z-index: 90; width: max-content; max-width: calc(100% - 32px);
  margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-radius: 14px;
  background: var(--plate); color: #F3EADA;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  font-size: 13.5px;
}
.undo-btn {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 700; color: #C7DDB2;
  padding: 2px 4px; border-radius: 6px;
}
.undo-tick {
  font-size: 11px; opacity: 0.6;
  min-width: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .trow { gap: 7px; padding: 9px 10px; }
  .tghost { font-size: 12px; }
  .tstate { display: none; }
  .tmeta { display: none; }
  .tnest { margin-inline-start: 8px; padding-inline-start: 8px; }
  /* حقل البحث يأخذ سطره كاملًا فيجتمع زرّا التوسيع/الطيّ في سطر واحد */
  .tree-search { flex: 1 1 100%; max-width: none; }
}

/* ══════════════════════════════════════════════════════════════
   مفردات المخطّط: رأس الشاشة، الأقسام، الحقول المركّبة، صناديق الصور
   ══════════════════════════════════════════════════════════════ */

.screen-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.h-title { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 700; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px;
  font-size: 12px; color: var(--text-muted);
}

/* فاصل قسم داخل النموذج — كما في نموذج الصنف بالمخطّط */
.sec {
  font-size: 14.5px; font-weight: 700;
  margin: 20px 0 10px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.drawer-body > .sec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.fl { margin: 0 0 13px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .g2 { grid-template-columns: 1fr; } }

/* حقل رقم بوحدة ملتصقة (السعر + ر.س، السعرات + سعرة…) */
.numrow { display: flex; }
.numrow .input {
  flex: 1; min-width: 0;
  font-variant-numeric: tabular-nums;
  border-start-end-radius: 0; border-end-end-radius: 0;
  border-inline-end: 0;
}
.numrow .u {
  display: flex; align-items: center; white-space: nowrap;
  padding: 0 12px; font-size: 12px; color: var(--text-muted);
  background: color-mix(in srgb, var(--field) 55%, var(--line));
  border: 1px solid var(--line);
  border-start-end-radius: 11px; border-end-end-radius: 11px;
}

/* صفّ خيار بمربّع — «إظهار الأصناف بعد نفاد الكمية» وأخواتها */
.cbrow {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13.5px; margin: 9px 0; cursor: pointer;
}
.cbrow input {
  width: 19px; height: 19px; margin-top: 1px; flex: none;
  accent-color: var(--accent); cursor: pointer;
}
.hint { font-size: 11px; color: var(--text-muted); margin: 4px 0 0; }
.hint-inline { font-size: 11.5px; color: var(--text-muted); font-weight: 400; }

/* صندوق صورة النموذج — تدرّج فاتح من لون الهوية حين لا صورة */
.imgbox {
  position: relative; height: 128px;
  border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 14%, var(--field)),
    color-mix(in srgb, var(--accent) 30%, var(--field)));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
}
.imgbox img { width: 100%; height: 100%; object-fit: cover; }
.imgbox-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ══════════════════════════════════════════════════════════════
   طبقة الحركة — القواعد:
   · دخول ease-out خلال 200–300ms، خروج ease-in بـ~٧٥٪ من مدة الدخول
   · transform وopacity حصرًا (مسرَّعان على المركّب — لا تخطيط ولا طلاء)
   · تتابع staggered: العناصر الشقيقة تصل تباعًا لا دفعة واحدة
   · prefers-reduced-motion يطفئ كل شيء
   ══════════════════════════════════════════════════════════════ */

.admin-body {
  --ease-out-quint: cubic-bezier(.23, 1, .32, 1);
  --ease-in-cubic: cubic-bezier(.32, 0, .67, 0);
  --spring: cubic-bezier(.34, 1.35, .64, 1);
}

@keyframes aFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes aPopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes aPopOut {
  to { opacity: 0; transform: translateY(-3px) scale(0.97); }
}
@keyframes aRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes aSink {
  to { opacity: 0; transform: translateY(8px); }
}
@keyframes aDrop {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ── تبديل الشاشات: أبناء الشاشة يصلون تباعًا (رأس ← أدوات ← محتوى).
   display:none→flex يعيد تشغيل الحركات تلقائيًّا عند كل تبديل.
   الشجرة مستثناة — صفوفها لها تتابع أدقّ أدناه. ── */
.view > *:not(.bulkbar):not(#tree) {
  animation: aFadeUp 0.3s var(--ease-out-quint) both;
}
/* :not(#tree) هنا لمساواة التخصيص مع قاعدة الأساس — بدونها يفوز
   اختصار animation الأعلى تخصيصًا (فيه id) ويصفّر التأخير ضمنيًّا. */
.view > *:nth-child(2):not(.bulkbar):not(#tree) { animation-delay: 45ms; }
.view > *:nth-child(3):not(.bulkbar):not(#tree) { animation-delay: 90ms; }
.view > *:nth-child(4):not(.bulkbar):not(#tree) { animation-delay: 135ms; }
.view > *:nth-child(n+5):not(.bulkbar):not(#tree) { animation-delay: 170ms; }

/* ── صفوف الشجرة: تتابع 22ms لكل صف عند دخول الشاشة فقط.
   الصنف tree-stagger يُضاف من setView ويُزال بعد انتهاء الموجة، فإعادة
   الرسم أثناء العمل (بحث، قلب توفّر) لا تعيد الحركة — كانت ستزعج. ── */
.tree-stagger .trow, .tree-stagger .tadd {
  animation: aFadeUp 0.3s var(--ease-out-quint) both;
  animation-delay: calc(60ms + var(--i, 0) * 22ms);
}

/* ── قائمة ⋮ تنمو من مرساها وتذوب عند الإغلاق ── */
.pop { animation: aPopIn 0.16s var(--ease-out-quint) both; transform-origin: top center; }
.pop.is-closing { animation: aPopOut 0.12s var(--ease-in-cubic) both; }

/* ── ما يصعد من الأسفل يغرق عند الخروج ── */
.undo  { animation: aRise 0.24s var(--ease-out-quint) both; }
.toast { animation: aRise 0.24s var(--ease-out-quint) both; }
.undo.is-closing, .toast.is-closing { animation: aSink 0.15s var(--ease-in-cubic) both; }

.bulkbar { animation: aDrop 0.2s var(--ease-out-quint) both; }
.dirty-flag { animation: aDrop 0.25s var(--ease-out-quint) both; }

.stat { transition: transform 0.2s var(--ease-out-quint), background 0.2s ease; }
@media (hover: hover) {
  .stat:hover { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  /* نفس محدد قاعدة الأساس حرفيًّا — محدد أضعف يخسر أمام (1,2,0) رغم الميديا */
  .view > *:not(.bulkbar):not(#tree),
  .tree-stagger .trow, .tree-stagger .tadd,
  .pop, .pop.is-closing,
  .undo, .toast, .undo.is-closing, .toast.is-closing,
  .bulkbar, .dirty-flag { animation: none; }
  .trow, .stat, .tg::after, .tcaret { transition: none; }
  .trow:hover, .stat:hover { transform: none; }
}

/* ══════════ لمسات ختامية ══════════ */

/* أشرطة تمرير رفيعة بلون الهوية — الافتراضية الرمادية تكسر الدفء */
.admin-body * { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.admin-body ::-webkit-scrollbar { width: 8px; height: 8px; }
.admin-body ::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
}
.admin-body ::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--line) 60%, var(--text-muted));
}
.admin-body ::-webkit-scrollbar-track { background: transparent; }

.admin-body ::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

/* الهامش التعريفي أسفل الأرقام الكبيرة يلتقط الشبكة نفسها */
.stat-label { line-height: 1.5; }
.hint, .hint-inline, .tmeta, .tstate { line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════════
   مجموعة «الإعدادات» القابلة للطيّ.

   كانت في `admin.html` بلا أي قاعدة: `.nav-group` غير معرّف، فأيقونة
   الترس تُرسم بحجمها الطبيعي (١٧١ بكسل) وتبتلع الشريط، و`.nav-sub`
   بلا `display:none` فالمجموعة لا تنطوي رغم أنّ الـJS يبدّل الصنف.
   ══════════════════════════════════════════════════════════════════ */

.nav-group {
  appearance: none;
  border: none;
  background: transparent;
  position: relative;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-group svg { width: 17px; height: 17px; flex: none; }
.nav-group:hover { background: var(--card-tint, var(--surface)); }
.nav-group:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-group.is-active { color: var(--accent); font-weight: 700; }

/* السهم في نهاية السطر، ويستدير عند الفتح — الحالة تُقرأ شكلًا لا لونًا */
.nav-group .nav-caret {
  width: 14px; height: 14px;
  margin-inline-start: auto;
  transition: transform 0.2s ease;
}
.nav-group[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

.nav-sub { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-sub.is-collapsed { display: none; }
/* إزاحة الأبناء بمقدار الأيقونة + الفجوة، فتصطفّ أسماؤها تحت الأمّ */
.nav-sub-btn { padding-inline-start: 39px; font-size: 13px; font-weight: 500; }
.nav-sub-btn.is-active { font-weight: 700; }
.nav-sub-btn.is-active::before { inset-inline-start: -14px; }

@media (max-width: 900px) {
  .nav-group { width: auto; padding: 7px 11px; white-space: nowrap; }
  .nav-group svg { width: 15px; height: 15px; }
  .nav-group .nav-caret { margin-inline-start: 4px; }
  .nav-sub { flex-direction: row; }
  .nav-sub-btn { padding-inline-start: 11px; }
}

/* ══════════════════════════════════════════════════════════════════
   شاشة «القوائم والأوقات»

   جدول واحد بستّة أعمدة ينقلب بطاقات تحت 720px — نفس قاعدة بقية
   اللوحة: لا تمرير أفقي على الجوال.
   ══════════════════════════════════════════════════════════════════ */

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.mtag {
  background: var(--field); color: var(--text-muted);
  border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 600;
}
.mtag-on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.mtag-warn { background: color-mix(in srgb, #E2445C 14%, transparent); color: var(--danger-text, #C13A4B); }
/* سطر العلاج تحت اللوحة — تحذير لا خطأ: الحالة قابلة للإصلاح بضغطتين،
   فلا يُصرَخ بها بالأحمر الكامل. */
.hint-warn {
  margin: 8px 0 0; width: 100%;
  color: var(--danger-text, #C13A4B);
  background: color-mix(in srgb, #E2445C 8%, transparent);
  border-inline-start: 3px solid color-mix(in srgb, #E2445C 55%, transparent);
  border-radius: 8px; padding: 8px 11px; line-height: 1.9;
}

.mord { display: inline-flex; gap: 4px; }
.mord-btn {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: var(--field); border: 1px solid var(--line);
  color: var(--text); font-size: 11px; line-height: 1;
}
.mord-btn:disabled { opacity: .35; cursor: not-allowed; }

/* مفتاح صغير — لا نعيد استعمال أصناف وحدة الإعدادات كي لا ترتبط هذه
   الشاشة بورقة قد تتغيّر تحتها. */
.mswitch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.mswitch input { position: absolute; opacity: 0; width: 0; height: 0; }
.mswitch-track {
  width: 40px; height: 22px; padding: 3px; display: flex; align-items: center;
  background: var(--line); border-radius: 999px; transition: background .18s ease;
}
.mswitch-track::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  /* الزرّ فاتحٌ في الحالتين لا `--card`: في الوضع الليلي كان `--card`
     داكنًا، فيظهر الزرّ ثقبًا أسود على المسار المضيء — يقرؤه المستخدم
     «مطفأ» وهو مشتغل، فيضغطه ليُشغّله فيُطفئه. */
  background: #F7F5EF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  margin-inline-start: 0; transition: margin-inline-start .18s ease;
}
.mswitch input:checked + .mswitch-track { background: var(--accent); }
/* المسار المطفأ أوضح من `--line` وحده: فرقٌ لونيّ واحد بين الحالتين لا
   يكفي حين تكون النغمتان زيتونيّتين متقاربتين. */
.mswitch input:not(:checked) + .mswitch-track {
  background: color-mix(in srgb, var(--text-muted) 38%, transparent);
}
.mswitch input:checked + .mswitch-track::after { margin-inline-start: calc(100% - 16px); }
.mswitch input:focus-visible + .mswitch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.mdays { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.mday { display: flex; align-items: center; gap: 8px; min-height: 38px; font-size: 13px; cursor: pointer; }
.mquick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.mtimes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mfb-pick { max-width: 320px; margin: 4px 0 12px 30px; }
.mfb-msg { margin-inline-start: 30px; }
.mfb-actions { margin-top: 14px; }

@media (max-width: 720px) {
  .mtimes { grid-template-columns: 1fr; }
  .mfb-pick, .mfb-msg { margin-inline-start: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   لوحة القوائم — بطاقات مكدّسة لا جدولًا.

   الجدول كان يفرد خمسة أعمدة لقائمتين، ويترك أصناف القائمة في شجرة
   منفصلة أسفل الشاشة بينهما شريط بحث. البطاقة تجمع القائمة وأصنافها:
   تضغط قائمة فتنفتح تحتها مباشرة.
   ══════════════════════════════════════════════════════════════════ */

/* شريط الفرع الذي تُدار قائمته الآن */
.mscope {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px;
}
.mscope-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.mscope-sel { width: auto; min-width: 190px; max-width: 100%; }
.mscope .hint { margin: 0; flex: 1 1 240px; font-size: 12px; }

.mcards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mcards-add { margin-top: 10px; }

/* زرّ الفتح/الطيّ قبل الاسم */
.mcard-sign {
  appearance: none; border: 0; background: transparent;
  font-family: inherit; font-size: 16px; font-weight: 700; line-height: 1;
  color: var(--text-muted); width: 24px; height: 24px; flex: none;
  border-radius: 7px; cursor: pointer; padding: 0;
}
.mcard-sign:hover { background: var(--field); color: var(--text); }
.mcard-sign:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mcard.is-editing .mcard-sign { color: var(--accent); }

/* المطويّة: جسمها يبقى في DOM (الشجرة تُرسم داخله) ويُخفى بالعرض */
.mcard.is-folded .mcard-body { display: none; }

.mcard {
  background: var(--card-tint, var(--field));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color .18s ease, background .18s ease;
}
.mcard.is-editing {
  background: var(--card);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.mcard.is-dragging { opacity: .45; }
.mcard.is-drop-target { border-color: var(--accent); border-style: dashed; }

.mcard-row { display: flex; align-items: center; gap: 8px; }

.mcard-name {
  appearance: none; border: 0; background: transparent; padding: 0;
  font: inherit; color: var(--text); cursor: pointer; text-align: start;
  display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap;
  min-width: 0;
}
.mcard-name b { font-size: 14.5px; font-weight: 700; }
.mcard-name:hover b { color: var(--accent); }
.mcard-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.mcard.is-editing .mcard-name b { color: var(--accent); }

.mcard-sub { margin: 5px 0 0; font-size: 12px; color: var(--text-muted); }

.mdrag {
  appearance: none; border: 0; background: transparent;
  color: var(--text-muted); font-size: 15px; line-height: 1;
  width: 30px; height: 30px; border-radius: 8px;
  cursor: grab; flex: none;
}
.mdrag:hover { background: var(--field); color: var(--text); }
.mdrag:active { cursor: grabbing; }
.mdrag:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* جسم البطاقة: شريط البحث والشجرة وزرّ التصنيف — يفصلها خطّ عن رأسها */
.mcard-body {
  margin-top: 12px; padding-top: 12px;
  border-block-start: 1px solid var(--line);
}
/* صفّ «القائمة» في أعلى الشجرة يتكرّر مع رأس البطاقة، فيُخفى داخلها */
.mcard-body .trow-menu { display: none; }
.mcard-body .tree-bar { margin-top: 0; }
.mcard-body #tree { margin-bottom: 12px; }
/* «أضف تصنيفًا» في ذيل البطاقة يكفي — صفّه في ذيل الشجرة تكرارٌ له */
.mcard-body > #menuEditor > #tree > .tnest > .tadd { display: none; }

/* لوحة القوائم داخل شاشة «القائمة» */
.menus-panel { margin-bottom: 14px; }
.menus-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.menus-head .panel-title { margin: 0; }
.menus-head .muted { font-size: 12px; }
.menus-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-block-start: 1px solid var(--line);
  font-size: 12.5px;
}
.menus-foot .hint { margin: 0; flex: 1 1 100%; }

/* مفتاح ثنائي «دائمًا / وقت محدد» */
.mseg {
  display: inline-flex; background: var(--field); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px; margin-bottom: 6px;
}
.mseg button {
  background: none; border: 0; cursor: pointer; border-radius: 999px;
  padding: 7px 18px; min-height: 36px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
}
.mseg button.is-on { background: var(--accent); color: var(--accent-ink); }
.mseg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ══════════════════════════════════════════════════════════════════
   درج «تعديل القائمة» — بلغة تصميم المرجع لا بلغة اللوحة القديمة.

   الرموز ‎--y-*‎ معرّفة أعلى هذا الملف. النطاق محصور بـ`.mform` داخل
   الدرج المشترك، فلا يتسرّب إلى أدراج الأصناف والتصنيفات.
   ══════════════════════════════════════════════════════════════════ */

#setDrawer .mform { font-family: var(--y-font); color: var(--y-ink); }
#setDrawer .mform .fl { margin-bottom: 16px; }
#setDrawer .mform .field-label {
  display: block; margin-bottom: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--y-ink-2);
}
#setDrawer .mform .input,
#setDrawer .mform select.input {
  width: 100%; background: var(--y-field); color: var(--y-ink);
  border: 1px solid transparent; border-radius: var(--y-rad-pill);
  padding: 11px 18px; min-height: 44px;
  font: inherit; font-size: 13.5px; font-weight: 600;
}
#setDrawer .mform .input:focus {
  outline: none; border-color: var(--y-brand);
  box-shadow: 0 0 0 3px var(--y-brand-soft);
}
#setDrawer .mform .hint { font-size: 11.5px; color: var(--y-faint); margin-top: 6px; }

/* «متوفر»: دائمًا | وقت محدد */
#setDrawer .mform .mseg {
  display: inline-flex; background: var(--y-field);
  border: 0; border-radius: var(--y-rad-pill); padding: 3px;
}
#setDrawer .mform .mseg button {
  background: none; border: 0; cursor: pointer;
  border-radius: var(--y-rad-pill); padding: 9px 22px; min-height: 40px;
  font-family: var(--y-font); font-size: 13px; font-weight: 700;
  color: var(--y-ink-2);
}
#setDrawer .mform .mseg button.is-on {
  background: var(--y-brand); color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
#setDrawer .mform .mseg button:focus-visible { outline: 2px solid var(--y-brand); outline-offset: 2px; }

#setDrawer .mform .mtimes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#setDrawer .mform .mdays { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; }
#setDrawer .mform .mday {
  display: flex; align-items: center; gap: 9px;
  min-height: 40px; font-size: 13px; cursor: pointer;
}
#setDrawer .mform .mquick { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
#setDrawer .mform .mquick .btn {
  border-radius: var(--y-rad-pill); background: var(--y-card);
  border: 1px solid var(--y-line); color: var(--y-ink-2);
  font-family: var(--y-font); font-size: 12px; font-weight: 600;
}
#setDrawer .mform .sec {
  margin: 22px 0 10px; font-size: 12.5px; font-weight: 500; color: var(--y-ink-2);
}

/* رأس الدرج بنفس لغة المرجع: حفظ أخضر ممتلئ وتجاهل نصّ أحمر */
#setDrawer .drawer-head .btn-primary,
#setDrawer2 .drawer-head .btn-primary {
  background: var(--y-brand); color: #fff; border-color: transparent;
  border-radius: var(--y-rad-pill); font-family: var(--y-font); font-weight: 700;
}
#setDrawer .drawer-head .btn-primary:hover,
#setDrawer2 .drawer-head .btn-primary:hover {
  background: color-mix(in srgb, var(--y-brand) 88%, black);
}
#setDrawer .drawer-head .btn-cancel,
#setDrawer2 .drawer-head .btn-cancel {
  color: var(--y-danger); font-family: var(--y-font); font-weight: 600;
}

@media (max-width: 560px) {
  #setDrawer .mform .mtimes { grid-template-columns: 1fr; }
  #setDrawer .mform .mdays { grid-template-columns: 1fr; }
}

/* اسم القائمة في أعلى الشجرة زرّ — يفتح إعدادات القائمة */
.tttl-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: start;
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 4px; text-decoration-color: var(--line);
}
.tttl-btn:hover { color: var(--accent); text-decoration-color: var(--accent); }
.tttl-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ── التحقّق بخطوتين ── */
.otp-steps { margin: 0 0 14px; padding-inline-start: 20px; font-size: 13px; line-height: 2.1; color: var(--text-muted); }
.otp-enroll { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.otp-side { flex: 1 1 260px; display: flex; flex-direction: column; gap: 8px; }
.otp-codes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; margin: 12px 0;
}
.otp-codes code {
  background: var(--field); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; text-align: center; font-size: 13.5px; letter-spacing: .5px;
}
.otp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
