/* ============================================================
   مزرعة النايفة — نظام فعاليات الأسرة
   طابع: عصري نظيف وبسيط · RTL
   ============================================================ */

/* الألوان مأخوذة من الشعار نفسه لا مخمّنة: تحليل بكسلات assets/logo.png
   أعطى الأخضر الغالب #1B422F والبرونزي #997958. الخلفية الصحراوية مشتقة
   من درجة البرونزي نفسها بإضاءة عالية، فتنسجم مع الشعار بدل رمادي محايد. */
:root {
  --bg:          #F4EADF;   /* رمل صحراوي من درجة برونزي الشعار */
  --surface:     #FFFFFF;
  --surface-2:   #FAF5EF;
  --ink:         #1E1A15;
  --ink-2:       #4A4239;
  --muted:       #7A7065;
  --line:        #E7DCCE;
  --line-strong: #D3C4B1;

  --brand:       #1F5740;   /* من عائلة أخضر الشعار */
  --brand-dark:  #143A2A;
  --brand-soft:  #E7EDE8;
  --brand-ring:  rgba(31, 87, 64, .24);
  --heading:     #1B422F;   /* أخضر الشعار الغالب — لعناوين الأقسام */

  --gold:        #8A6A49;   /* برونزي الشعار */
  --gold-soft:   #F2E7D9;
  --danger:      #B3382C;
  --danger-soft: #F8E7E4;
  --warn:        #98661A;
  --warn-soft:   #F7EBD8;
  --info:        #2A5A9E;
  --info-soft:   #E9EFF7;

  --sec-men:     #2A5A9E;
  --sec-men-soft:#E9EFF7;
  --sec-girls:   #7B4A96;
  --sec-girls-soft:#F1E9F5;
  --sec-shared:  #1F5740;
  --sec-shared-soft:#E7EDE8;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(20,32,28,.06), 0 1px 3px rgba(20,32,28,.04);
  --sh-2: 0 2px 6px rgba(20,32,28,.06), 0 8px 24px rgba(20,32,28,.06);
  --sh-3: 0 12px 40px rgba(20,32,28,.16);

  --nav-w: 232px;
  --top-h: 62px;

  --font: "Segoe UI", "Noto Sans Arabic", "Dubai", "Tahoma", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* عناوين الأقسام بأخضر الشعار. البطاقة الخضراء (hero) مستثناة لأن
   نصها أبيض على أخضر، وأخضر على أخضر لا يُقرأ. */
h1, h2, h3, h4 {
  margin: 0; font-weight: 700; line-height: 1.35; letter-spacing: -.01em;
  color: var(--heading);
}
.hero h1, .hero h2, .hero h3 { color: inherit; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.muted   { color: var(--muted); }
.small   { font-size: .82rem; }
.tiny    { font-size: .74rem; }
.strong  { font-weight: 700; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.num     { font-variant-numeric: tabular-nums; }
.error   { color: var(--danger); font-size: .85rem; margin-top: 6px; }
.hint    { color: var(--muted); font-size: .8rem; margin-top: 6px; }

/* ---------- أزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--r);
  padding: 10px 16px; font-size: .92rem; font-weight: 600;
  cursor: pointer; background: transparent; color: var(--ink);
  transition: background .14s, border-color .14s, color .14s, transform .06s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 1px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--brand-dark); }
.btn-outline { border-color: var(--line-strong); background: var(--surface); }
.btn-outline:hover:not([disabled]) { border-color: var(--brand); color: var(--brand); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-2); }
.btn-danger  { background: var(--danger-soft); color: var(--danger); border-color: #F3D2CF; }
.btn-danger:hover:not([disabled]) { background: var(--danger); color: #fff; }
.btn-gold    { background: var(--gold-soft); color: var(--gold); border-color: #EFDCB6; }
.btn-sm      { padding: 6px 11px; font-size: .82rem; border-radius: var(--r-sm); }
.btn-block   { width: 100%; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible { outline: 3px solid var(--brand-ring); }
.icon-btn .dot {
  position: absolute; inset-block-start: 6px; inset-inline-end: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}

/* ---------- حقول ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
.textarea { min-height: 86px; resize: vertical; line-height: 1.6; }
.input-code { text-align: center; letter-spacing: .12em; font-weight: 700; text-transform: uppercase; }
.input-pin  { text-align: center; letter-spacing: .55em; font-size: 1.4rem; font-weight: 700; padding-inline-start: .55em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; font-size: .9rem; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; cursor: pointer; }

/* ============================================================
   شاشة الدخول
   ============================================================ */
.auth-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px 18px;
  background:
    radial-gradient(1100px 520px at 78% -8%, #DCEFE8 0%, transparent 62%),
    radial-gradient(900px 480px at 12% 108%, #E8F0DC 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 430px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-2);
  padding: 30px 26px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo { margin: 0 auto 10px; display: flex; justify-content: center; }
.auth-logo svg { max-width: 100%; height: auto; }

/* شعار المزرعة أعلى الصفحة الرئيسية */
.home-brand { display: flex; justify-content: center; padding: 4px 0 2px; }
.home-brand .brand-full { max-height: 96px; }
/* ملاحظة: الشعار أُزيل من الصفحة الرئيسية بطلب المستخدم — القواعد باقية
   لأن logoEl لا يزال مستخدماً في شاشة الدخول. */

/* نص الإعلان مقصوص — الإعلان الطويل ما ياخذ الشاشة كلها.
   المحدِّد مركّب عمداً: القاعدة العامة `.list-item-main > span`
   أقوى تحديداً وتفرض display:block، وهي تُلغي -webkit-box فيبطل القص. */
.ann-row .ann-body {
  white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* صورة الإعلان: مقاس ثابت و object-fit حتى تبقى الصفوف متساوية
   مهما كانت أبعاد الصورة المرفوعة (طولية أو عرضية) */
.ann-thumb {
  width: 56px; height: 56px; flex: none;
  object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  display: block;
}
.ann-full {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface-2); display: block;
}

/* ترويسة قسم قابل للطي: زر بعرض البطاقة يحمل نفس شكل card-head */
.fold-head {
  width: 100%; border: 0; cursor: pointer; text-align: inherit;
  font: inherit; color: inherit;
}
.fold-head:hover { filter: brightness(1.06); }
.fold-head:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: -3px; }
.fold-caret { font-size: .8rem; opacity: .85; flex: none; }
.fold-title { gap: 8px; min-width: 0; }
.fold-title h2 { margin: 0; }

/* شارة نوع الإعلان: تأخذ خانة الأيقونة في كل صف إعلان */
.ann-badge { display: inline-flex; flex: none; align-self: flex-start; }
.ann-badge > img { width: 100%; height: 100%; object-fit: contain; display: block; }

.ann-row { cursor: pointer; transition: background .14s; }
.ann-row:hover { background: var(--surface-2); }
.ann-row:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: -3px; }

/* الشعار الأصلي (يحوي الاسم أصلاً) يُعرض وحده */
.brand-full { max-width: 100%; height: auto; display: block; object-fit: contain; }
.auth-logo .brand-full { max-height: 120px; }

/* شعار المزرعة: الورقة + الاسم */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-words { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.brand-ar {
  font-size: 1.6rem; font-weight: 800; color: var(--brand-dark);
  letter-spacing: -.01em; white-space: nowrap;
}
.brand-en {
  font-size: .66rem; font-weight: 600; color: #2F7A57;
  letter-spacing: .22em; margin-top: 5px; white-space: nowrap;
  direction: ltr;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.auth-back-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pin-lead { font-size: .88rem; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 13px; margin-bottom: 14px; }
.auth-foot { text-align: center; }

.member-picker { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding-inline-end: 4px; }
.member-opt {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: start;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); cursor: pointer; transition: border-color .14s, background .14s;
}
.member-opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.member-opt:focus-visible { outline: 3px solid var(--brand-ring); }
.member-opt-main { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.member-opt-main b { font-size: .93rem; }
.member-opt .lock { margin-inline-start: auto; font-size: .78rem; color: var(--muted); flex: none; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  font-weight: 700; font-size: .82rem;
}
.avatar.sm { width: 27px; height: 27px; font-size: .7rem; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.05rem; }
.avatar.f  { background: var(--sec-girls-soft); color: var(--sec-girls); }
.avatar.m  { background: var(--sec-men-soft);   color: var(--sec-men); }

/* ============================================================
   الهيكل العام
   ============================================================ */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { display: flex; flex: none; }
.topbar-logo svg { display: block; }
.topbar-titles { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar-titles strong { font-size: .97rem; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 11px 4px 4px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer;
}
.user-chip:hover { border-color: var(--brand); }
.user-chip-name { font-size: .85rem; font-weight: 600; max-width: 108px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

.shell { flex: 1; display: flex; align-items: flex-start; }

/* القائمة الجانبية: خلفية أخضر الشعار، وقابلة للطي لتوسيع مساحة الصفحة */
.nav {
  position: sticky; top: var(--top-h); flex: none; width: var(--nav-w);
  height: calc(100vh - var(--top-h)); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--heading);
  transition: width .2s ease, padding .2s ease, opacity .15s ease;
  overflow: hidden;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: start;
  padding: 10px 12px; border: 0; border-radius: var(--r); background: transparent;
  cursor: pointer; font-size: .92rem; font-weight: 600;
  color: rgba(255, 255, 255, .82);
  transition: background .14s, color .14s;
  white-space: nowrap;
}
/* التسمية القصيرة للشريط السفلي على الجوال فقط */
.nav-txt-short { display: none; }
.nav-item:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-item[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-item:focus-visible { outline: 2px solid rgba(255,255,255,.7); outline-offset: -2px; }

/* مطويّة: شريط ضيق يبقى فيه زر الطي وحده — لو اختفى كلياً ما بقي
   طريق لإرجاع القائمة. */
.app.nav-collapsed .nav { width: 56px; padding-inline: 8px; }
.app.nav-collapsed .nav-item,
.app.nav-collapsed .nav-sep,
.app.nav-collapsed .nav-label { display: none; }

/* زر الطي — علامة وحدها بلا نص، داخل القائمة فوق أول عنصر */
.nav-toggle {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,.22); border-radius: var(--r);
  background: rgba(255,255,255,.08); color: #fff;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}
.nav-toggle:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.38); }
.nav-toggle:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: -2px; }
.nav-toggle .nav-toggle-ico { font-size: 1.1rem; line-height: 1; }
.nav-item .nav-ico { font-size: 1.05rem; width: 22px; text-align: center; flex: none; }
.nav-item .nav-badge {
  margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.nav-sep { height: 1px; background: rgba(255,255,255,.16); margin: 9px 4px; }
.nav-label {
  font-size: .7rem; font-weight: 700; color: rgba(255,255,255,.55);
  padding: 4px 12px; letter-spacing: .04em; white-space: nowrap;
}

.view-root { flex: 1; min-width: 0; padding: 22px; max-width: 1180px; margin-inline: auto; width: 100%; }
.view-root:focus { outline: none; }

/* ============================================================
   عناصر عامة
   ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-pad { padding: 18px; }
/* ترويسة البطاقة: خلفية بأخضر الشعار ونص أبيض */
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  background: var(--heading);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-head h2, .card-head h3 { font-size: 1rem; color: #fff; }
.card-head .muted, .card-head .tiny, .card-head .small { color: rgba(255,255,255,.75); }

/* الشرائح داخل الترويسة الخضراء تحتاج تباينها الخاص */
.card-head .chip {
  background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.24);
}
.card-head .btn-outline {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff;
}
.card-head .btn-outline:hover { background: rgba(255,255,255,.22); border-color: #fff; color: #fff; }
.card-head .btn-primary { background: #fff; color: var(--heading); }
.card-head .btn-primary:hover { background: #EFEAE2; }
.card-head .btn-ghost { color: rgba(255,255,255,.85); }
.card-head .btn-ghost:hover { background: rgba(255,255,255,.14); color: #fff; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
/* شبكة الإحصائيات: أربعة أعمدة ثابتة حتى تنتظم ٨ بطاقات في صفّين متساويين */
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack  { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip-men    { background: var(--sec-men-soft);   color: var(--sec-men);   border-color: #D3E2FA; }
.chip-girls  { background: var(--sec-girls-soft); color: var(--sec-girls); border-color: #E6D2F4; }
.chip-shared { background: var(--sec-shared-soft);color: var(--sec-shared);border-color: #CFE6DE; }
.chip-gold   { background: var(--gold-soft);      color: var(--gold);      border-color: #EFDCB6; }
.chip-danger { background: var(--danger-soft);    color: var(--danger);    border-color: #F3D2CF; }
.chip-warn   { background: var(--warn-soft);      color: var(--warn);      border-color: #F2DFBC; }
.chip-ok     { background: var(--brand-soft);     color: var(--brand-dark);border-color: #CFE6DE; }
.chip-info   { background: var(--info-soft);      color: var(--info);      border-color: #D3E2FA; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); font-size: .84rem; font-weight: 600; cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
}
.pill:hover { border-color: var(--brand); }
.pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
  overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 15px; border: 0; background: transparent; cursor: pointer;
  font-size: .9rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-dark); border-bottom-color: var(--brand); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .empty-ico { font-size: 34px; display: block; margin-bottom: 8px; opacity: .55; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item-main { min-width: 0; flex: 1; }
.list-item-main b { display: block; font-size: .92rem; }
/* الأسطر الفرعية (الوصف، الكاتب، التاريخ) كل واحد على سطره */
.list-item-main > span { display: block; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- إحصائيات ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 16px; box-shadow: var(--sh-1);
}
.stat-val { font-size: 1.65rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.stat-ico { font-size: 1.05rem; margin-bottom: 4px; display: block; }

/* ---------- بطاقة الجلسة القادمة ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); padding: 24px;
  background: linear-gradient(135deg, #0F7B5F 0%, #12674F 52%, #0A4A39 100%);
  color: #fff; box-shadow: var(--sh-2);
}
.hero::after {
  content: ""; position: absolute; inset-block-start: -60px; inset-inline-start: -40px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.hero > * { position: relative; z-index: 1; }
.hero-eyebrow { font-size: .78rem; font-weight: 700; opacity: .82; letter-spacing: .04em; }
.hero h2 { font-size: 1.5rem; margin: 4px 0 2px; }
.hero-dates { font-size: .88rem; opacity: .88; }
/* العدّاد على خلفية بيضاء داخل بوكس الجمعة القادمة */
.next-date { font-size: 1.35rem; font-weight: 800; color: var(--heading); line-height: 1.3; }
.countdown { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.cd-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px 12px; min-width: 62px; text-align: center;
}
.cd-num {
  font-size: 1.3rem; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--heading);
}
.cd-lbl { font-size: .68rem; color: var(--muted); }

/* البطاقة الخضراء القديمة ما عادت تُستخدم في الرئيسية، لكن
   قواعدها باقية لأن .hero مستعملة في أماكن أخرى محتملة */
.hero-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.hero .btn-outline { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.hero .btn-outline:hover { background: rgba(255,255,255,.24); border-color: #fff; color: #fff; }
.hero .btn-primary { background: #fff; color: var(--brand-dark); }
.hero .btn-primary:hover { background: #EAF6F2; }

/* ---------- بطاقات الأنشطة ---------- */
.act-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  transition: box-shadow .16s, transform .16s, border-color .16s;
}
.act-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); border-color: var(--line-strong); }
.act-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.act-media > svg, .act-media > img { width: 100%; height: 100%; display: block; object-fit: cover; }
.act-points {
  position: absolute; inset-block-start: 9px; inset-inline-end: 9px;
  background: rgba(20,32,28,.78); color: #fff; border-radius: 999px;
  padding: 3px 10px; font-size: .74rem; font-weight: 700; backdrop-filter: blur(4px);
}
.act-body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.act-body h3 { font-size: .96rem; }
.act-desc {
  font-size: .83rem; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.act-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.act-card.is-picked { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-ring); }

/* ---------- المتصدرون ---------- */
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.lb-row:last-child { border-bottom: 0; }
.lb-row.is-me { background: var(--brand-soft); }
.lb-rank {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: .82rem;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.lb-rank.r1 { background: #F7E7BE; color: #7A5710; border-color: #E9D096; }
.lb-rank.r2 { background: #E7EAEC; color: #4E585D; border-color: #D3D9DC; }
.lb-rank.r3 { background: #F3E0D0; color: #7C4E24; border-color: #E4CBB3; }
.lb-main { flex: 1; min-width: 0; }
.lb-main b { display: block; font-size: .92rem; }
.lb-pts { font-weight: 800; font-size: 1rem; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.lb-pts small { font-weight: 600; color: var(--muted); font-size: .72rem; }

/* ---------- الحضور ---------- */
/* أزرار الحضور: صف أفقي نحيف بدل صناديق ضخمة. الأيقونة جنب النص لا
   فوقه، فالارتفاع ينزل للنصف تقريباً مع بقاء الهدف اللمسي مريحاً. */
.rsvp-group { display: flex; gap: 6px; }
.rsvp-btn {
  flex: 1 1 0; min-width: 0; padding: 8px 6px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; font-weight: 600; font-size: .76rem; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  line-height: 1.3; text-align: center;
  transition: border-color .14s, background .14s, color .14s, box-shadow .14s;
}
.rsvp-btn:hover { border-color: var(--line-strong); background: var(--surface); }
.rsvp-btn .rsvp-ico { font-size: .9rem; flex: none; }
.rsvp-btn[aria-pressed="true"] { font-weight: 700; box-shadow: 0 1px 3px rgba(30,26,21,.08); }
.rsvp-btn[aria-pressed="true"][data-v="yes"]   { border-color: var(--brand);  background: var(--brand-soft);  color: var(--brand-dark); }
.rsvp-btn[aria-pressed="true"][data-v="maybe"] { border-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }
.rsvp-btn[aria-pressed="true"][data-v="no"]    { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* خيارات تقرير المهمة — نفس لغة أزرار الحضور لكن صف كامل لكل خيار */
.choice-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; font-size: .86rem; font-weight: 600; color: var(--ink-2);
  text-align: start;
  transition: border-color .14s, background .14s, color .14s;
}
.choice-btn:hover { border-color: var(--line-strong); background: var(--surface); }
.choice-btn .rsvp-ico { font-size: 1rem; flex: none; }
.choice-btn[aria-pressed="true"] { font-weight: 700; }
.choice-btn[aria-pressed="true"][data-rep="done"]  { border-color: var(--brand);  background: var(--brand-soft);  color: var(--brand-dark); }
.choice-btn[aria-pressed="true"][data-rep="cant"]  { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.choice-btn[aria-pressed="true"][data-rep="other"] { border-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }

/* بوكس عدد الضيوف: صغير ومتناسق. أخفينا أسهم الزيادة لأنها
   تسرق نصف عرض الخانة، والرقم يُكتب مباشرة على أي حال. */
.count-input {
  width: 58px; max-width: 58px; padding-inline: 6px;
  text-align: center; font-weight: 700;
}
.count-input::-webkit-outer-spin-button,
.count-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count-input { -moz-appearance: textfield; appearance: textfield; }

/* أسماء الضيوف: تظهر فقط حين يكون العدد أكبر من صفر */
.guest-names { display: flex; flex-direction: column; gap: 8px; }
.guest-names .field-label { margin-bottom: 4px; }

/* عدّادات الحضور: سطر لكل حالة، والإجمالي بارز */
.rsvp-counts {
  display: flex; flex-direction: column; gap: 5px;
  font-size: .84rem; color: var(--muted);
}
.rsvp-counts .rsvp-total {
  font-weight: 800; color: var(--heading); font-size: .92rem;
  padding-top: 7px; margin-top: 2px; border-top: 1px solid var(--line);
}

.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px;
  transition: width .3s; }

/* ---------- الإثبات ---------- */
.proof-thumb {
  width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface-2); display: block;
}
.proof-mini { width: 54px; height: 54px; object-fit: cover; border-radius: var(--r-sm);
  border: 1px solid var(--line); flex: none; cursor: zoom-in; }
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r);
  padding: 20px; text-align: center; color: var(--muted); cursor: pointer;
  background: var(--surface-2); transition: border-color .14s, background .14s;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- جداول ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line);
  vertical-align: middle; }
table.tbl th { font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--surface-2);
  white-space: nowrap; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- التنبيهات ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 15px;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2);
  font-size: .87rem;
}
.alert .alert-ico { font-size: 1.05rem; flex: none; line-height: 1.4; }
.alert-warn   { background: var(--warn-soft);   border-color: #F2DFBC; color: #6B4103; }
.alert-info   { background: var(--info-soft);   border-color: #D3E2FA; color: #16408A; }
.alert-ok     { background: var(--brand-soft);  border-color: #CFE6DE; color: var(--brand-dark); }
.alert-danger { background: var(--danger-soft); border-color: #F3D2CF; color: #8C2019; }

/* ---------- نافذة منبثقة ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,32,28,.5); backdrop-filter: blur(2px); }
.modal {
  position: relative; width: 100%; max-width: 540px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.modal-foot:empty { display: none; }

/* ---------- توست ---------- */
.toast-root { position: fixed; inset-block-end: 20px; inset-inline: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .87rem; font-weight: 600; box-shadow: var(--sh-3);
  animation: rise .2s ease-out; max-width: 90vw; text-align: center;
}
.toast.ok  { background: var(--brand-dark); }
.toast.err { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- نص الواتساب ---------- */
.wa-preview {
  white-space: pre-wrap; font-family: var(--font); font-size: .86rem; line-height: 1.75;
  background: #F0F5F2; border: 1px solid #D8E6DF; border-radius: var(--r);
  padding: 14px 16px; max-height: 340px; overflow-y: auto;
}

/* ============================================================
   الجوال
   ============================================================ */
/* ============================================================
   إحساس التطبيق
   ------------------------------------------------------------
   هذه القواعد تفصل بين "موقع مفتوح في متصفح" و"تطبيق":
   بلا وميض أزرق عند اللمس، بلا تحديد نص عرضي على الأزرار،
   وبلا سحب الصفحة كلها عند الوصول لطرف قائمة داخلية.
   ============================================================ */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: contain; }

button, .nav-item, .pill, .tab, .rsvp-btn, .member-opt, .act-card {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* النصوص والحقول تبقى قابلة للتحديد والنسخ */
input, textarea, .wa-preview, .ann-body, p { -webkit-user-select: text; user-select: text; }

/* مناطق الأمان: النوتش أعلى الشاشة والشريط السفلي في آيفون */
.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--top-h) + env(safe-area-inset-top));
}

/* أهداف اللمس على الأجهزة اللمسية فقط — الفأرة أدق ولا تحتاج التكبير */
@media (pointer: coarse) {
  .btn-sm { min-height: 44px; padding-inline: 14px; }
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; }
  .nav-item { min-height: 52px; }
  .list-item { padding-top: 14px; padding-bottom: 14px; }
  .pill, .tab { min-height: 40px; }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  /* على الجوال شريط سفلي — الطي لا ينطبق لأنه لا يأخذ عرضاً من الصفحة */
  .nav, .app.nav-collapsed .nav {
    position: fixed; inset-block-end: 0; inset-inline: 0; top: auto;
    width: 100%; height: auto; padding: 6px 4px;
    flex-direction: row; justify-content: space-around; gap: 0;
    border-inline-end: 0; border-top: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 -2px 12px rgba(30,26,21,.12); z-index: 50;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    opacity: 1; pointer-events: auto; overflow-x: auto;
  }
  .nav-toggle { display: none; }
  .nav-item {
    flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .66rem;
    border-radius: var(--r-sm); flex: 1; text-align: center; min-width: 0;
  }
  .nav-item .nav-ico { font-size: 1.15rem; width: auto; }
  .nav-item .nav-txt { display: none; }
  .nav-item .nav-txt-short {
    display: block; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; max-width: 100%;
  }
  .nav-item .nav-badge { position: absolute; margin: 0; transform: translate(-14px, -4px); }
  .nav-item { position: relative; }
  .nav-sep, .nav-label { display: none; }
  .view-root { padding: 16px 14px 96px; }
  .field-row { grid-template-columns: 1fr; }

  /* الشعار شريط هوية لا بانر: بطاقة الجمعة والعدّاد أهم منه في أول شاشة */
  .home-brand { padding: 0; }
  .home-brand .brand-full { max-height: 58px; }

  /* الإعلان: عنوان وسطر واحد. التفاصيل بضغطة، لا بإفراد الشاشة لها */
  .ann-row .ann-body { -webkit-line-clamp: 1; }
  .ann-row .ann-meta { display: none; }
  .ann-row .ann-kind { display: none; }
  .ann-row { padding-top: 10px; padding-bottom: 10px; gap: 9px; }
  .hero { padding: 20px 18px; }
  .hero h2 { font-size: 1.28rem; }
  .modal { max-height: 92vh; }
  h1 { font-size: 1.3rem; }
}

@media (max-width: 700px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .user-chip-name { display: none; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* نقطة لون التصنيف في قائمة التصنيفات بالإعدادات */
.cat-dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1px solid rgba(0, 0, 0, .12);
}

/* صورة الفرد داخل دائرة الأفاتار */
.avatar.has-photo { padding: 0; overflow: hidden; }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* رأس عمود قابل للترتيب */
.th-sort {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; font-weight: 700;
}
.th-sort:hover { color: var(--brand); }
.th-sort:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.th-arrow { font-size: .7rem; opacity: .55; }
.th-sort[aria-sort]:not([aria-sort="none"]) .th-arrow { opacity: 1; color: var(--brand); }

/* أيقونة القائمة الجانبية حين تكون صورة لا إيموجي */
.nav-ico img { width: 1.25em; height: 1.25em; object-fit: contain; display: block; }

/* صفوف بأعمدة معنونة — للإعدادات حيث الحقل بلا عنوان يصير لغزاً */
.grid-head, .grid-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
}
.grid-head {
  background: var(--surface-2); border-block-end: 1px solid var(--line);
  font-size: .78rem; font-weight: 700; color: var(--ink-2);
}
.grid-row + .grid-row { border-block-start: 1px solid var(--line); }
.gr-cell { flex: 1; min-width: 0; }
.gr-cell.narrow { flex: 0 0 200px; }
.gr-cell.tight  { flex: 0 0 auto; }
.gr-cell.row    { display: flex; align-items: center; gap: 8px; }
.gr-cell .input.num { max-width: 72px; text-align: center; }

@media (max-width: 720px) {
  .grid-head { display: none; }              /* العنوان يضيع في عمود واحد */
  .grid-row { flex-wrap: wrap; }
  .gr-cell.narrow { flex: 1 1 auto; }
}

/* سطر شرائح أسماء الأعمدة في أدوات الجدول */
.chip-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }

/* خانات التحديد في جدول الأفراد */
.tbl input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer;
}
.tbl input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .4; }

/* ---------- إبداعات الأعضاء ---------- */
.cr-card { cursor: pointer; overflow: hidden; transition: box-shadow .15s, transform .15s; }
.cr-card:hover { box-shadow: var(--sh-2); transform: translateY(-2px); border-color: var(--line-strong); }
.cr-media { display: block; width: 100%; background: var(--surface-2); }
.cr-media-none {
  display: grid; place-items: center; font-size: 2.2rem;
  background: var(--surface-2); color: var(--muted);
}
/* المعاينة داخل نموذج الرفع */
.cr-preview {
  margin-top: 8px; padding: 8px; border: 1px dashed var(--line);
  border-radius: var(--r); background: var(--surface-2);
}
.cr-preview img, .cr-preview video { display: block; margin-inline: auto; border-radius: var(--r-sm); }

/* ---------- الشريط السفلي على أضيق الشاشات ----------
   ثمانية بنود على ٣٢٠ بكسل = ٣٩ بكسل للخانة، وأسماءٌ مثل «الفعاليات»
   و«لوحة التحكم» تُقصّ. تصغيرٌ طفيف للخط وتضييق الحشو يكفي لظهورها
   كاملة، وهو أفضل من شريطٍ يُخفي بنوده وراء تمرير أفقي. */
@media (max-width: 380px) {
  .nav-item { font-size: .62rem; padding: 6px 2px; letter-spacing: -.2px; }
  .nav-item .nav-ico { font-size: 1.05rem; }
}

/* ---------- شريط نتيجة التصويت ---------- */
.poll-bar {
  display: inline-block; width: 90px; height: 8px; flex: none;
  background: var(--surface-2); border-radius: 999px; overflow: hidden;
}
.poll-bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- مقبض السحب في ترتيب الفعاليات ---------- */
.drag-handle {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: var(--r-sm);
  color: var(--muted); font-size: 1.25rem; line-height: 1;
  cursor: grab; user-select: none;
  /* على المقبض وحده: لو منعنا اللمس على الصف كله لما استطاع أحد
     تمرير الصفحة بإصبعه فوق القائمة */
  touch-action: none;
}
.drag-handle:hover { background: var(--surface-2); color: var(--ink-2); }
.drag-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.list-item.dragging {
  opacity: .75; background: var(--surface-2);
  box-shadow: var(--sh-2); border-radius: var(--r-sm);
}
.list-item.dragging .drag-handle { cursor: grabbing; }

/* الصف كله يُسحب: مؤشّر يدلّ، وبلا تحديد نصٍّ يفسد السحب.
   ولا touch-action هنا عمداً — منعُ اللمس على الصف يمنع تمرير الصفحة
   فوق القائمة، والتفريق بين السحب والتمرير يتكفّل به مؤقّت الضغط. */
.list-item[data-id] { cursor: grab; user-select: none; }
.list-item[data-id]:active { cursor: grabbing; }

/* النسبة المئوية في نتيجة التصويت: رقمٌ بارز بجانب كل فعالية */
.poll-pct {
  flex: none; min-width: 46px; text-align: end;
  font-weight: 700; color: var(--brand);
}
/* الشريط تحت الاسم داخل بطاقة الفئة يأخذ عرض السطر */
.list-item-main .poll-bar { width: 100%; margin-top: 6px; }
