:root {
  --brand: #4338CA; --brand-d: #312E81; --brand-l: #C7D2FE;
  --accent: #0EA5E9; --gold: #D97706;
  --bg: #f3f4f8; --card: #ffffff; --line: #e3e5ee;
  --text: #1b1b1f; --muted: #6b7280; --danger: #c62828; --ok: #15803d;
  --c-alive: #15803d; --c-dead: #6b7280; --c-noissue: #b91c1c;   /* ألوان الحالات الموحّدة (حي/متوفّى/لم يعقب) */
  --radius: 14px; --shadow: 0 1px 3px rgba(0,0,0,.12);
}
html[data-theme="dark"] {
  --brand: #818CF8; --brand-d: #6366F1; --brand-l: #312E81;
  --accent: #38BDF8; --gold: #FBBF24;
  --bg: #0f1117; --card: #1a1d27; --line: #2a2e3c;
  --text: #e8eaf2; --muted: #9aa1b4; --danger: #f87171; --ok: #4ade80;
  --c-alive: #4ade80; --c-dead: #9ca3af; --c-noissue: #f87171;
  --shadow: 0 1px 3px rgba(0,0,0,.5);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html, body { overflow-x: hidden; }   /* حارس: يمنع تجاوز أي صفحة عرضَ الشاشة (التمرير الأفقي المقصود يبقى داخل حاوياته) */
body {
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
.hidden { display: none !important; }
#app { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand), var(--brand-d)); color: #fff;
  display: flex; align-items: center; gap: 8px;
  padding: 14px; padding-top: calc(14px + env(safe-area-inset-top)); box-shadow: var(--shadow);
}
.appbar h1 { font-size: 1.2rem; margin: 0; font-weight: 700; flex: 1; }
.icon-btn {
  background: rgba(255,255,255,.16); color: #fff; border: 0; width: 38px; height: 38px;
  border-radius: 10px; font-size: 1.3rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: none;
}
main { padding: 14px; max-width: 820px; margin: 0 auto; }
.muted { color: var(--muted); }
.center-empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.loading { text-align:center; color:var(--muted); padding:40px; }

/* Cards */
.card { background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 6%, var(--card)) 0%, var(--card) 60%); border-radius: 18px; box-shadow: 0 16px 36px -24px color-mix(in srgb, var(--brand) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--brand) 16%, transparent), inset 0 1px 0 rgba(255,255,255,.5); padding: 16px; margin-bottom: 12px; border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--line)); }
.card.click { cursor: pointer; } .card.click:active { transform: scale(.99); }
.card h3 { margin: 0 0 10px; color: var(--brand); font-size: 1.15rem; font-weight: 800; letter-spacing: -.2px; }
.row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); } .row .v { font-weight: 600; text-align: left; }
.title-lg { font-size: 1.5rem; font-weight: 800; color: var(--brand); margin: 4px 0 2px; }

/* Stats */
.vstats { padding: 14px 16px; }
.vstats summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--brand); font-size: 1.02rem; }
.vstats summary::-webkit-details-marker { display: none; }
.vstats summary::before { content: '▸'; color: var(--gold); font-size: .9rem; }
.vstats[open] summary::before { content: '▾'; }
.vstats-total { margin-inline-start: auto; background: var(--brand-l); color: var(--brand-d); border-radius: 999px; padding: 1px 11px; font-size: .82rem; font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0; }
.stat {
  border-radius: 16px; padding: 16px 12px; text-align: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 12%, var(--card)), var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--brand) 75%, transparent), 0 2px 0 color-mix(in srgb, var(--brand) 20%, transparent), inset 0 1px 0 rgba(255,255,255,.5);
}
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--brand); } .stat .l { font-size: .82rem; font-weight: 700; color: var(--muted); }
.stat.a { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 14%, var(--card)), var(--card) 70%); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--accent) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--accent) 20%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.stat.g { background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card) 70%); border-color: color-mix(in srgb, var(--gold) 32%, var(--line)); box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--gold) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--gold) 22%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.stat.k { background: linear-gradient(160deg, color-mix(in srgb, var(--ok) 14%, var(--card)), var(--card) 70%); border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--ok) 68%, transparent), 0 2px 0 color-mix(in srgb, var(--ok) 20%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.stat.d { background: linear-gradient(160deg, color-mix(in srgb, var(--danger) 14%, var(--card)), var(--card) 70%); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--danger) 68%, transparent), 0 2px 0 color-mix(in srgb, var(--danger) 20%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.stat.a .n { color: var(--accent); } .stat.g .n { color: var(--gold); } .stat.d .n { color: var(--danger); } .stat.k .n { color: var(--ok); }
@media (max-width:520px){ .stats { grid-template-columns: 1fr 1fr; } }

/* مربّع «المتواجدون الآن» (الرئيسية) — عريض يحتوي المتواجدين حسب الفروع */
.online-home:empty { display: none; }
.online-home { display: block; width: 100%; box-sizing: border-box; margin: 0 0 12px; padding: 13px 15px; border-radius: 16px; background: linear-gradient(160deg, rgba(28,139,77,.12), var(--card) 70%); box-shadow: 0 14px 30px -20px rgba(28,139,77,.6), 0 2px 0 rgba(28,139,77,.18), inset 0 1px 0 rgba(255,255,255,.45); border: 1px solid rgba(28,139,77,.4); }
.online-home .oh-title { font-weight: 800; color: #1c8b4d; font-size: .95rem; margin-bottom: 8px; }
.online-home .oh-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.online-home .oh-chip { background: rgba(28,139,77,.12); color: #1c8b4d; border: 1px solid rgba(28,139,77,.35); border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: .9rem; }
.online-home .oh-empty { color: var(--muted); font-size: .88rem; }
html.dark .online-home { border-color: rgba(40,180,99,.4); }
html.dark .online-home .oh-title { color: #4cd07d; }
html.dark .online-home .oh-chip { background: rgba(40,180,99,.16); color: #4cd07d; border-color: rgba(40,180,99,.4); }
/* عدد المتواجدين أمام كل فرع في قائمة الفروع — خط صغير غامق */
.br-online:empty { display: none; }
.br-online { font-size: .95rem; font-weight: 800; color: #1c8b4d; margin-inline-start: 6px; white-space: nowrap; }
html.dark .br-online { color: #4cd07d; }

/* ===== الصفحة التعريفية (قبيلة المفرجي) ===== */
/* زر «ⓘ» بزاوية عنوان الرئيسية */
.hero-row { display: flex; align-items: center; gap: 8px; }
.about-i { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000)); color: #fff;
  font-size: 1.05rem; font-weight: 800; line-height: 1; box-shadow: 0 3px 8px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.3); }
.about-i:active { transform: translateY(1px); }

/* عرض احترافي ثلاثي الأبعاد للبطاقة */
/* ===== وثيقة تاريخية: بطاقة الرئيسية + صفحة العرض ثلاثية الأبعاد ===== */
.doc-card { display: flex; align-items: center; gap: 12px; }
.doc-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; flex: none; border: 2px solid color-mix(in srgb, var(--gold) 55%, var(--line)); box-shadow: 0 6px 14px -8px rgba(0,0,0,.45); background: #f5ecd8; }
.doc-card-body { flex: 1; min-width: 0; }
.doc-card .li-title { color: var(--brand); }
.doc-card-arrow { color: var(--gold); font-size: 1.6rem; font-weight: 800; flex: none; }
.doc-wrap { perspective: 1300px; padding: 14px 6px 28px; max-width: 860px; margin: 0 auto; }
.doc-3d {
  text-align: center; border-radius: 20px; padding: 20px 16px 22px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 12%, var(--card)), var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--gold) 38%, var(--line));
  box-shadow: 0 28px 54px -28px rgba(0,0,0,.55), 0 2px 0 color-mix(in srgb, var(--gold) 30%, transparent), inset 0 1px 0 rgba(255,255,255,.55);
}
.doc-eyebrow { color: var(--gold); font-weight: 800; letter-spacing: 2px; font-size: .78rem; }
.doc-title { color: var(--brand); font-size: 1.32rem; font-weight: 800; margin: .25em 0 .7em; letter-spacing: -.2px; }
.doc-frame {
  display: inline-block; max-width: 100%; border-radius: 12px; overflow: hidden; background: #fff; border: 7px solid #fff;
  box-shadow: 0 34px 64px -26px rgba(0,0,0,.6), 0 10px 0 -2px color-mix(in srgb, var(--gold) 45%, #5a3e12);
  transform: rotateX(5deg); transition: transform .35s ease;
}
.doc-frame:hover, .doc-frame:active { transform: rotateX(0deg) translateY(-4px); }
.doc-frame img { display: block; max-width: 100%; height: auto; cursor: zoom-in; }
.doc-actions { margin-top: 16px; }
.doc-text { white-space: pre-wrap; text-align: right; line-height: 2; font-size: .95rem; font-weight: 600; color: var(--text); margin-top: 16px; padding-top: 14px; border-top: 1px solid color-mix(in srgb, var(--gold) 32%, var(--line)); }
/* عرض الوثيقة كاملةً (طبقة فوق الصفحة) + سهم رجوع */
.doc-full { position: fixed; inset: 0; z-index: 60; background: rgba(15,17,23,.96); overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: 30px; }
.doc-full-bar { position: sticky; top: 0; display: flex; padding: 10px 14px; background: linear-gradient(180deg, rgba(0,0,0,.6), transparent); }
.doc-full-back { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px; padding: 9px 18px; font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.doc-full-back:active { transform: translateY(1px); }
.doc-full img { display: block; width: 100%; max-width: 920px; height: auto; margin: 8px auto 0; border-radius: 6px; }
.doc-note { margin: 12px auto 0; max-width: 640px; font-size: .85rem; line-height: 1.9; }
@media (prefers-reduced-motion: reduce) { .doc-frame { transform: none; } }
.about-wrap { perspective: 1200px; padding: 14px 6px 28px; }
.about-card {
  position: relative; max-width: 760px; margin: 0 auto; padding: 26px 22px;
  border-radius: 18px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--brand) 8%, var(--card)) 0%, var(--card) 45%);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  box-shadow:
    0 1px 0 rgba(255,255,255,.5) inset,
    0 18px 40px -18px rgba(0,0,0,.55),
    0 10px 22px -16px rgba(0,0,0,.4),
    0 2px 0 color-mix(in srgb, var(--brand) 35%, transparent);
  transform: rotateX(2.2deg);
  transform-style: preserve-3d;
  transition: transform .35s ease, box-shadow .35s ease;
  overflow: hidden;
}
.about-card::before {   /* شريط علوي زخرفي */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--gold, #c9a227), var(--brand));
}
.about-card:hover { transform: rotateX(0) translateY(-2px); box-shadow: 0 26px 54px -20px rgba(0,0,0,.6), 0 12px 26px -18px rgba(0,0,0,.45); }
.about-body { font-size: 1.02rem; line-height: 2; color: var(--text); }
.about-body h1, .about-body h2, .about-body h3 { color: var(--brand); text-align: center; margin: .2em 0 .5em; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.about-body h2 { font-size: 1.5rem; }
.about-body p { margin: 0 0 .8em; }
.about-body img { max-width: 100%; border-radius: 12px; box-shadow: 0 8px 20px -10px rgba(0,0,0,.5); display: block; margin: 10px auto; }
.about-body a { color: var(--brand); font-weight: 700; }
.about-body .about-eyebrow { text-align: center; color: var(--gold, #c9a227); font-weight: 800; letter-spacing: 2px; font-size: .8rem; margin: 0 0 2px; }
.about-body hr { border: 0; height: 2px; width: 70px; margin: 6px auto 16px; background: linear-gradient(90deg, transparent, var(--brand), transparent); }
.about-body p { text-align: justify; }
.about-body .about-sign { text-align: center; color: var(--brand); font-weight: 800; margin-top: 14px; }
html.dark .about-card { box-shadow: 0 18px 44px -18px rgba(0,0,0,.8), 0 2px 0 color-mix(in srgb, var(--brand) 40%, transparent); }

/* دليل الموقع (الكتيّب) — بلا تدوير ثلاثي الأبعاد (يُفرغ المحتوى الطويل على الجوال) */
.guide-card { text-align: right; transform: none !important; overflow: visible; }
.guide-card:hover { transform: translateY(-2px) !important; }
.guide-card h2 { color: var(--brand); text-align: center; font-size: 1.4rem; margin: .2em 0 .4em; }
.guide-card .about-eyebrow { text-align: center; color: var(--gold, #c9a227); font-weight: 800; letter-spacing: 2px; font-size: .8rem; margin: 0 0 2px; }
.guide-card hr { border: 0; height: 2px; width: 70px; margin: 6px auto 16px; background: linear-gradient(90deg, transparent, var(--brand), transparent); }
.guide-toc { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 0 0 18px; }
.guide-new { background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--card)), var(--card) 70%); border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line)); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; box-shadow: 0 10px 22px -16px color-mix(in srgb, var(--brand) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.guide-new-t { font-weight: 800; color: var(--brand); margin-bottom: 6px; }
.guide-new-i { font-weight: 700; padding: 6px 0; border-top: 1px dashed color-mix(in srgb, var(--brand) 18%, var(--line)); line-height: 1.7; }
.guide-new-i:first-of-type { border-top: 0; }
.guide-toc-link { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); border-radius: 999px; padding: 5px 12px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.guide-toc-link:active { background: var(--brand); color: #fff; }
.guide-sec { margin-top: 18px; scroll-margin-top: 70px; }
.guide-sec-h { color: var(--brand); font-size: 1.15rem; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); }
.guide-item { background: color-mix(in srgb, var(--brand) 4%, var(--card)); border: 1px solid var(--line); border-inline-start: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 2px 6px -3px rgba(0,0,0,.3); }
.guide-item-t { font-weight: 800; color: var(--text); font-size: 1.02rem; margin-bottom: 6px; }
.guide-row { display: grid; grid-template-columns: 86px minmax(0,1fr); gap: 8px; padding: 3px 0; align-items: baseline; }
.guide-lbl { font-size: .78rem; font-weight: 800; color: var(--brand); }
.guide-val { font-size: .92rem; line-height: 1.7; word-break: break-word; }

/* الأسئلة الشائعة (تصنيف مستقل) — أكورديون سؤال/جواب */
.faq-item { background: color-mix(in srgb, var(--brand) 4%, var(--card)); border: 1px solid var(--line);
  border-inline-start: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 12px;
  margin-bottom: 10px; box-shadow: 0 2px 6px -3px rgba(0,0,0,.3); overflow: hidden; }
.faq-item > summary { cursor: pointer; font-weight: 800; color: var(--text); font-size: .98rem; line-height: 1.6;
  padding: 13px 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after { content: '+'; margin-inline-start: auto; font-size: 1.3rem; font-weight: 900;
  color: var(--brand); line-height: 1; }
.faq-item[open] > summary::after { content: '\2212'; }
.faq-item[open] > summary { color: var(--brand); }
.faq-a { padding: 0 14px 14px; color: var(--muted); font-size: .92rem; line-height: 1.9;
  border-top: 1px dashed var(--line); margin: 0 12px; padding-top: 11px; }
.faq-adm-tag { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand);
  border-radius: 999px; padding: 2px 8px; font-size: .7rem; font-weight: 800; flex: none; }

/* محرّر النص الغني (أدوات تنسيق الخطوط) */
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.rte-b { min-width: 34px; height: 32px; border: 1px solid var(--line); background: var(--card); border-radius: 7px;
  cursor: pointer; font-size: .95rem; color: var(--text); }
.rte-b:active { background: var(--brand-soft, #eef0ff); }
.rte-sel { height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--text); padding: 0 6px; }
.rte-color { display: inline-flex; align-items: center; gap: 3px; height: 32px; padding: 0 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); cursor: pointer; }
.rte-color input { width: 22px; height: 22px; border: 0; background: none; padding: 0; cursor: pointer; }
.rte-sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.rte-area { min-height: 240px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; padding: 14px;
  background: var(--card); color: var(--text); line-height: 2; outline: none; }
.rte-area:focus { border-color: var(--brand); }

/* Chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--brand-l); background: var(--card); color: var(--brand); padding: 6px 12px; border-radius: 999px; font-size: .85rem; cursor: pointer; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .85rem; color: var(--text); font-weight: 700; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid color-mix(in srgb, var(--brand) 26%, var(--line)); border-radius: 12px; font: inherit; font-weight: 600; background: var(--card); color: var(--text);
  box-shadow: inset 0 2px 5px -3px rgba(0,0,0,.22); transition: box-shadow .18s ease, border-color .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent), inset 0 2px 5px -3px rgba(0,0,0,.18); }
/* حقول نموذج إرسال الملاحظة — خلفية مميّزة لتبرز عن بطاقة بيضاء */
.fb-screen .field input, .fb-screen .field select, .fb-screen .field textarea { background: var(--bg); border-color: var(--brand-l); }
[data-theme="dark"] .fb-screen .field input, [data-theme="dark"] .fb-screen .field select, [data-theme="dark"] .fb-screen .field textarea { background: #11141c; }
.field textarea { resize: vertical; min-height: 64px; }
.field.pw { position: relative; }
.field.pw input { padding-inline-end: 44px; }
.field.pw .eye { position: absolute; inset-inline-end: 4px; bottom: 3px; width: 38px; height: 40px; border: 0; background: transparent; cursor: pointer; font-size: 1.15rem; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width:520px){ .grid2 { grid-template-columns: 1fr; } }
.hint { color: var(--brand); font-size: .85rem; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.check input { width: auto; }

/* Buttons */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; width:100%; padding:13px; border:0; border-radius:13px; font:inherit; font-weight:800; background:linear-gradient(180deg, var(--brand), var(--brand-d)); color:#fff; cursor:pointer; margin-top:6px; box-shadow: 0 10px 20px -10px color-mix(in srgb, var(--brand) 80%, transparent), 0 3px 0 var(--brand-d), inset 0 1px 0 rgba(255,255,255,.25); transform: translateY(0); transition: transform .12s ease, box-shadow .12s ease; }
.btn:active { transform: translateY(3px); box-shadow: 0 4px 10px -10px color-mix(in srgb, var(--brand) 80%, transparent), 0 0 0 var(--brand-d), inset 0 1px 0 rgba(255,255,255,.25); }
.btn:disabled { opacity:.5; cursor: not-allowed; transform:none; }
.btn.outline { background:var(--card); color:var(--brand); border:1.5px solid var(--brand); box-shadow: 0 6px 16px -12px color-mix(in srgb, var(--brand) 60%, transparent); }
.btn.gold { background:linear-gradient(180deg, var(--gold), color-mix(in srgb, var(--gold) 72%, #000)); color:#fff; box-shadow: 0 10px 20px -10px color-mix(in srgb, var(--gold) 80%, transparent), 0 3px 0 color-mix(in srgb, var(--gold) 72%, #000), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.danger { background:var(--card); color:var(--danger); border:1.5px solid var(--danger); box-shadow: 0 6px 16px -12px color-mix(in srgb, var(--danger) 55%, transparent); }
.btn.outline:active, .btn.danger:active { box-shadow: none; }
.btn.sm { width:auto; padding:8px 14px; font-size:.9rem; }
.btn-row { display:flex; gap:8px; flex-wrap: wrap; } .btn-row .btn { margin-top:0; }
.fab { position:fixed; bottom:90px; inset-inline-start:16px; background:var(--brand); color:#fff; border:0; border-radius:999px; padding:14px 20px; font-weight:700; box-shadow:0 3px 12px rgba(0,0,0,.3); cursor:pointer; z-index:15; }

.li-title { font-weight: 800; font-size: 1.05rem; }
.li-sub { color: var(--muted); font-size: .9rem; }
/* بطاقات نتائج البحث/الأشخاص — خط أوضح وأغمق */
.pc .li-title { font-weight: 800; font-size: 1.15rem; }
.pc .li-sub { color: var(--text); font-weight: 600; }
.badge { display:inline-block; font-size:.75rem; padding:2px 8px; border-radius:999px; background:var(--brand-l); color:var(--brand); }
.badge.dead { background:#FFCDD2; color:#8a1c1c; } .badge.alive { background:#C8E6C9; color:#1b5e20; }
.badge.role { background:#E1BEE7; color:#6a1b9a; } .badge.off { background:#e0e0e0; color:#777; }
html[data-theme="dark"] .badge.dead { background:#4a1c1c; color:#fca5a5; }
html[data-theme="dark"] .badge.alive { background:#14361c; color:#86efac; }
html[data-theme="dark"] .badge.off { background:#333; color:#aaa; }

/* Person header */
.person-hd { display:flex; align-items:center; gap:14px; }
.avatar { width:64px; height:64px; border-radius:50%; object-fit:cover; background:var(--brand-l); display:flex; align-items:center; justify-content:center; font-size:1.6rem; color:var(--brand); flex:none; border:2px solid var(--brand-l); }
.avatar.lg { width:96px; height:96px; font-size:2.4rem; }
.lineage { color:var(--muted); font-size:.92rem; line-height:1.9; }
.lineage a { color:var(--brand); text-decoration:none; }
.lineage a:hover { text-decoration:underline; }

/* Bottom nav */
.bottomnav { position:fixed; bottom:0; inset-inline:0; z-index:20; display:grid; background:var(--card); border-top:1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-item { background:none; border:0; padding:8px 0 10px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:2px; font:inherit; font-size:.78rem; color:var(--text); font-weight:700; }
.nav-item span { font-size:1.05rem; line-height:1; }
.nav-ico { position: relative; display: inline-flex; }
.nav-badge { position: absolute; top: -7px; inset-inline-end: -12px; min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box; background: var(--danger); color: #fff; border-radius: 999px; font-size: .66rem; font-weight: 800; line-height: 17px; text-align: center; box-shadow: 0 2px 6px -1px rgba(0,0,0,.4); }
.nav-item.active { color:var(--brand); font-weight:800; }
/* بطاقة تحكّم الشجرة: «ابدأ من» واضحة وغامقة */
.tree-ctl label { color: var(--text); font-weight: 800; font-size: .92rem; }
.tree-ctl select { font-weight: 700; color: var(--text); }

/* Search */
.search { position: relative; margin: 10px 0; }
.search input { width:100%; padding:12px; padding-inline-start:40px; border:1px solid var(--line); border-radius:10px; font:inherit; background:var(--card); color:var(--text); }
.search::before { content:"🔍"; position:absolute; inset-inline-start:12px; top:12px; }

/* Modal */
.modal-bg { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:40; display:flex; align-items:flex-end; justify-content:center; }
.modal { background:var(--card); color:var(--text); width:100%; max-width:560px; border-radius:18px 18px 0 0; padding:18px; max-height:90vh; overflow-y:auto; }
.modal h3 { margin:0 0 12px; color:var(--brand); }

/* Toast */
.toast { position:fixed; bottom:96px; inset-inline:0; margin:auto; width:max-content; max-width:90%; background:#222; color:#fff; padding:10px 18px; border-radius:18px; z-index:60; animation:fade 2.8s forwards; text-align:center; overflow-wrap:anywhere; }
@keyframes fade { 0%,85%{opacity:1} 100%{opacity:0} }

/* Auth */
.auth { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; background:linear-gradient(160deg,var(--brand),var(--brand-d)); }
.auth-box { background:var(--card); color:var(--text); border-radius:20px; box-shadow:0 8px 30px rgba(0,0,0,.3); padding:26px; width:100%; max-width:380px; }
.auth-box .logo { text-align:center; font-size:2.2rem; }
.auth-box h2 { text-align:center; color:var(--brand); margin:6px 0 2px; }
.auth-box .sub { text-align:center; color:var(--muted); margin-bottom:16px; font-size:.9rem; }
.auth-msg { text-align:center; font-size:.9rem; margin-top:10px; min-height:1.2em; }
.auth-guest-link { display:block; width:100%; margin-top:14px; background:none; border:0; color:var(--brand); font:inherit; font-weight:700; font-size:.9rem; cursor:pointer; text-align:center; }
.auth-msg.err { color:var(--danger); } .auth-msg.ok { color:var(--ok); }

/* Members / permissions */
.perm-grid { display:grid; grid-template-columns: 1fr auto auto auto; gap:6px 8px; align-items:center; margin:8px 0; }
.perm-grid .h { font-size:.72rem; color:var(--muted); font-weight:700; text-align:center; }
.perm-grid label { display:flex; align-items:center; justify-content:center; }

/* ===== الشجرة التفاعلية ===== */
.tree { font-size:.95rem; }
.tnode { margin-inline-start: 0; }
.tnode .trow { display:flex; align-items:center; gap:6px; padding:5px 6px; border-radius:8px; cursor:pointer; }
.tnode .trow:hover { background:var(--brand-l); }
.tnode .ttoggle { width:22px; height:22px; flex:none; border:1px solid var(--brand-l); border-radius:6px; background:var(--card); color:var(--brand); font-weight:700; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.tnode .ttoggle.leaf { border-color:transparent; background:transparent; color:var(--muted); cursor:default; }
.tnode .tname { font-weight:600; }
.tnode .tcount { font-size:.78rem; color:var(--muted); }
.tkids { margin-inline-start:18px; border-inline-start:2px solid var(--line); padding-inline-start:8px; }

/* ===== العرض الهرمي النصي ===== */
.ascii { font-family: "Courier New", monospace; white-space: pre; overflow-x:auto; background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; line-height:1.8; direction:ltr; text-align:right; }

@media (min-width:820px){ .bottomnav{ max-width:820px; margin:0 auto; border-radius:14px 14px 0 0; } }

/* ===== الطباعة / تصدير PDF ===== */
@media print {
  .appbar, .bottomnav, .fab, #themeBtn, #signoutBtn, .btn, .no-print { display:none !important; }
  body, #app { background:#fff !important; color:#000 !important; padding:0 !important; }
  main { max-width:100% !important; padding:0 !important; }
  .card { box-shadow:none !important; border:1px solid #ccc !important; break-inside: avoid; }
  .ascii { border:0 !important; }
  a { color:#000 !important; text-decoration:none !important; }
}
.print-only { display:none; }
@media print { .print-only { display:block; } }

/* ===== الفهرس النَّسَبي الاحترافي ===== */
.idx-card .idx-list { margin-top: 4px; }
.idx-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 3px 8px;
  padding: 6px 0; border-bottom: 1px dotted var(--line, #e3e3ef);
  font-size: .95rem;
  border-inline-start: 3px solid transparent;
}
/* صفوف الآباء (لها ذرية) تُبرز بخلفية خفيفة وحدّ ملوّن لتوضيح التسلسل */
.idx-row.idx-parent { background: color-mix(in srgb, var(--brand) 5%, transparent); border-inline-start-color: color-mix(in srgb, var(--brand) 35%, transparent); border-radius: 0 6px 6px 0; }
.idx-row.idx-root { font-weight: 700; font-size: 1.05rem; border-bottom: 2px solid var(--brand); padding-bottom: 7px; background: none; border-inline-start-color: transparent; }
.idx-num {
  flex: 0 0 auto;
  direction: ltr; unicode-bidi: isolate;            /* يمنع تداخل الأرقام مع الاسم في RTL */
  font-family: ui-monospace, monospace; color: var(--brand);
  background: var(--brand-soft, #eef0ff); border-radius: 6px;
  padding: 1px 7px; font-size: .78rem; white-space: nowrap; text-align: center;
}
.idx-name { flex: 0 1 auto; min-width: 0; color: inherit; text-decoration: none; font-weight: 700; word-break: break-word; }
.idx-name:hover { color: var(--brand); text-decoration: underline; }
.idx-tag { color: #888; font-size: .85em; }
.idx-meta { flex: 0 0 auto; margin-inline-start: auto; color: #888; font-size: .76rem; white-space: nowrap; }
[data-theme="dark"] .idx-num { background: #2a2c44; }
[data-theme="dark"] .idx-row { border-color: #333; }

/* ===== نص الرئيسية (البانر) ===== */
.banner {
  position: relative;
  background:
    radial-gradient(130% 150% at 50% -30%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 55%),
    linear-gradient(135deg, var(--brand), var(--brand-d) 88%);
  color: #fff; border-radius: 14px;
  padding: 14px 40px; margin-bottom: 18px;
  font-size: 1.05rem; font-weight: 700; line-height: 1.7; text-align: center;
  border: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
  text-shadow: 0 1px 8px rgba(0,0,0,.25);
  will-change: transform;
  animation: bannerFloat 4.5s ease-in-out infinite;
}
/* رمز شجرة العائلة (هوية الموقع) قبل النص، وقصّ النص الطويل مع زرّ «المزيد» */
.banner-text { display: block; }
.banner-text::before { content: "🌳 "; }
.banner-text.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.banner-more {
  margin-top: 9px; display: inline-block; font: inherit; font-weight: 800; font-size: .9rem; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #000)); border: 0; border-radius: 999px; padding: 5px 18px;
  box-shadow: 0 8px 16px -8px color-mix(in srgb, var(--gold) 85%, transparent), 0 2px 0 color-mix(in srgb, var(--gold) 65%, #000), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .12s ease;
}
.banner-more:active { transform: translateY(2px); }
/* تعويم احترافي: يطفو لأعلى وأسفل بنعومة مع ظلٍّ يكبر عند الارتفاع (إحساس بالطيران فوق الصفحة) */
@keyframes bannerFloat {
  0%, 100% { transform: translateY(0);
    box-shadow: 0 12px 24px -16px color-mix(in srgb, var(--brand) 90%, transparent), 0 2px 0 rgba(0,0,0,.15), inset 0 1px 0 rgba(255,255,255,.28); }
  50% { transform: translateY(-6px);
    box-shadow: 0 24px 40px -18px color-mix(in srgb, var(--brand) 90%, transparent), 0 2px 0 rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.28); }
}
@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; transform: none; box-shadow: 0 16px 30px -18px color-mix(in srgb, var(--brand) 90%, transparent), inset 0 1px 0 rgba(255,255,255,.28); }
}
/* زر «ⓘ» النبذة التعريفية بزاوية المربع الأزرق */
.banner-i { position: absolute; top: 8px; left: 8px;
  width: 28px; height: 28px; font-size: 1rem;
  background: rgba(255,255,255,.22); box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
/* ===== صندوق صلاحيات العضو ===== */
.perm-box { margin: 10px 0; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); }
.perm-title { font-size: .8rem; color: var(--brand); font-weight: 700; margin-bottom: 6px; }
.perm-chk { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.perm-chk input { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; }
.perm-chk span { font-weight: 600; }
.perm-chk small { color: #999; font-size: .75rem; margin-right: auto; }
.perm-note { font-size: .75rem; color: var(--danger, #c0392b); margin-top: 6px; }
.badge.dead { background: #6b7280; color: #fff; }

/* ===== تنبيه تغيير كلمة المرور (أول دخول) ===== */
.notice-pw {
  background: #fff7ed; border: 1px solid #fdba74; color: #9a3412;
  border-radius: var(--radius, 14px); padding: 12px 14px; margin-bottom: 12px;
  font-weight: 600; line-height: 1.7;
}
[data-theme="dark"] .notice-pw { background: #2a1f12; border-color: #7c4a1e; color: #fcd9b6; }
.notice-pw .btn { margin-inline-start: 6px; }

/* شارة الإضافة في سجل التعديلات */
.badge.add { background: #16a34a; color: #fff; }

/* ===== نوافذ التأكيد/الإدخال الأنيقة ===== */
.dlg-bg {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 17, 23, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: dlgFade .18s ease;
}
@keyframes dlgFade { from { opacity: 0 } to { opacity: 1 } }
.dlg {
  background: var(--card); border-radius: 20px; padding: 22px 20px 18px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); border: 1px solid var(--line);
  animation: dlgPop .22s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes dlgPop { from { transform: scale(.9) translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }
.dlg-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  background: var(--brand-l); color: var(--brand-d);
}
.dlg-icon.danger { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .dlg-icon { background: #312E81; }
[data-theme="dark"] .dlg-icon.danger { background: #4c1d1d; color: #fca5a5; }
.dlg-title { font-size: 1.15rem; font-weight: 800; color: var(--text, inherit); margin-bottom: 6px; }
.dlg-msg { color: var(--muted, #666); line-height: 1.9; font-size: .96rem; margin-bottom: 16px; overflow-wrap: anywhere; }
.dlg-input {
  width: 100%; box-sizing: border-box; padding: 11px 12px; margin-bottom: 16px;
  border: 1.5px solid var(--line); border-radius: 12px; font-size: 1rem;
  background: var(--bg); color: inherit; text-align: center;
}
.dlg-input:focus { outline: none; border-color: var(--brand); }
.dlg-actions { display: flex; gap: 10px; }
.dlg-actions .btn { flex: 1; margin: 0; }

/* ===== بحث متقدّم احترافي ===== */
.search-card { padding: 18px 16px; }
.search-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.search-head h3 { margin: 0; }
.search-ico {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--brand-l); color: var(--brand-d);
}
[data-theme="dark"] .search-ico { background: #312E81; }
.search-hint { font-size: .82rem; margin: 0 0 14px; }
.search-card .field { margin-bottom: 14px; }
.search-card .field input::placeholder { color: #9aa0ad; font-size: .9rem; }
[data-theme="dark"] .search-card .field input::placeholder { color: #5a6172; }
.search-card .grid2 { gap: 12px; }
.search-actions { margin-top: 4px; gap: 10px; }
.search-actions .btn { flex: 1; margin: 0; }
.search-count { margin: 14px 2px 8px; font-size: .92rem; color: var(--muted); }
.search-count b { color: var(--brand); font-size: 1.05rem; }

/* ===== آخر الإضافات ===== */
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.row.click { cursor: pointer; border-radius: 8px; transition: background .12s; }
.row.click:hover { background: var(--brand-l); }
[data-theme="dark"] .row.click:hover { background: #262a3a; }
.row.click .k { color: var(--brand); font-weight: 600; }
.mini-info { margin-bottom: 12px; }

/* ===== أسلوب إضافة المواليد ===== */
.add-ctx {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-d)); color: #fff;
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.add-ctx-ico { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.add-ctx-title { font-weight: 800; font-size: 1.1rem; }
.add-ctx-sub { font-size: .85rem; opacity: .95; margin-top: 2px; }
.add-steps { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 12px; }
.add-step { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; }
.add-step-n { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--brand-l); color: var(--brand-d); align-items: center; justify-content: center; font-weight: 700; margin-inline-end: 4px; }
.father-pick { display: flex; flex-direction: column; gap: 10px; }
.father-name { padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1.5px solid var(--line); font-weight: 700; font-size: 1.05rem; text-align: center; }
.father-name.empty { color: var(--muted); font-weight: 400; border-style: dashed; }
.btn.btn-lg { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 700; }

/* ===== تنبيه التراجع ===== */
.toast.undo { display: flex; align-items: center; gap: 14px; animation: none; }
.undo-btn { background: var(--brand-l); color: var(--brand-d); border: 0; border-radius: 999px; padding: 5px 14px; font-weight: 700; cursor: pointer; font-size: .9rem; }

/* ===== العرض الهرمي الاحترافي ===== */
.hier-wrap { padding: 6px 2px 20px; overflow-x: auto; }
ul.hier { list-style: none; margin: 0; padding: 0; }
/* تداخل الأبناء مع خط ربط رأسي أنيق */
ul.hier ul.hier { margin-inline-start: 14px; padding-inline-start: 16px; border-inline-start: 2px solid var(--line); position: relative; }
.hier-li { position: relative; padding: 3px 0; }
/* خط أفقي صغير يربط البطاقة بالخط الرأسي */
ul.hier ul.hier > .hier-li::before {
  content: ""; position: absolute; top: 18px; inset-inline-start: -16px;
  width: 14px; height: 2px; background: var(--line);
}
.hier-row {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 7px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .12s, transform .12s;
}
.hier-row:hover { box-shadow: 0 3px 10px rgba(67,56,202,.15); }
.hier-name { font-weight: 700; cursor: pointer; color: var(--text, inherit); }
.hier-name:hover { color: var(--brand); }
.hier-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.hier-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hier-meta { display: block; font-size: .68rem; color: var(--muted, #999); font-weight: normal; }
.hier-tog {
  width: 22px; height: 22px; flex: none; border: 0; cursor: pointer;
  border-radius: 7px; background: var(--brand); color: #fff;
  font-size: 1rem; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.hier-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-l); flex: none; margin: 0 7px; }
/* تمييز لوني خفيف لحدود الأجيال على البطاقة */
.hier-li.lvl1 > .hier-row { border-inline-start: 4px solid #4338CA; }
.hier-li.lvl2 > .hier-row { border-inline-start: 4px solid #0891B2; }
.hier-li.lvl3 > .hier-row { border-inline-start: 4px solid #059669; }
.hier-li.lvl4 > .hier-row { border-inline-start: 4px solid #CA8A04; }
.hier-li.lvl5 > .hier-row { border-inline-start: 4px solid #DC2626; }
.hier-li.lvl6 > .hier-row { border-inline-start: 4px solid #7C3AED; }
@media print {
  .hier-row { box-shadow: none; border: 1px solid #ccc; }
  .hier-tog { background: #fff; color: #000; border: 1px solid #999; }
}

/* ===== التعديل الجماعي ===== */
.bk-val { margin: -2px 0 8px 26px; padding-inline-start: 8px; }
.bk-val .field { margin-bottom: 6px; }

/* ===== نافذة النسب والأحفاد ===== */
.rel-block { margin-bottom: 14px; }
.rel-h { font-size: .8rem; font-weight: 700; color: var(--brand); margin-bottom: 6px; }
.rel-chain { line-height: 2; font-size: 1.02rem; background: var(--bg); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.rel-sep { color: var(--muted); font-size: .85rem; }
.rel-link { color: var(--brand); text-decoration: none; font-weight: 600; }
.rel-link:hover { text-decoration: underline; }
.rel-kids { display: flex; flex-direction: column; gap: 8px; }
.rel-kid { background: var(--card); border: 1px solid var(--line); border-inline-start: 3px solid var(--brand); border-radius: 10px; padding: 8px 10px; }
.rel-kid-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.rel-count { font-size: .7rem; background: var(--brand-l); color: var(--brand-d); border-radius: 999px; padding: 0 7px; font-weight: 700; }
.rel-grand { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.rel-gchip { font-size: .82rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: inherit; text-decoration: none; }
.rel-gchip:hover { border-color: var(--brand); color: var(--brand); }
.rel-stats { text-align: center; font-size: .9rem; color: var(--muted); margin: 10px 0; }
.rel-stats b { color: var(--brand); }

/* ===== قائمة مراجعة التعديل الجماعي ===== */
.bk-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.bk-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.bk-item:last-child { border-bottom: 0; }
.bk-item input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.bk-item-name { font-weight: 700; }
.bk-item-sub { font-size: .78rem; color: var(--muted); margin-inline-start: auto; }
.bk-item.bk-blocked { opacity: .55; cursor: not-allowed; background: rgba(127,127,127,.06); }
.bk-item.bk-blocked input { cursor: not-allowed; }
.bk-dead-tag { font-size: .68rem; font-weight: 600; color: var(--c-dead); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-inline-start: 6px; }

/* ===== قائمة تعديل/مراجعة البيانات (لكل فرد) ===== */
.grid-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.grid-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.grid-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.grid-head { font-size: 1rem; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.grid-head .muted { font-size: .78rem; }
.grid-f { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.grid-f label { flex: 0 0 92px; font-size: .85rem; color: var(--muted); }
.grid-f input, .grid-f select { flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: var(--card); color: var(--text); }
.grid-f input:focus, .grid-f select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-l); }
.grid-rev { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 2px 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--line); }
.grid-rev:last-child { border-bottom: 0; }
.grid-rev-l { font-size: .82rem; color: var(--muted); }
.grid-rev-v { font-weight: 700; word-break: break-word; min-width: 0; }
.grid-rev-by { grid-column: 2; font-size: .72rem; color: var(--brand); white-space: normal; word-break: break-word; min-width: 0; }

/* مبدّل قطاعي (الأحياء/المتوفّون/الكل) */
.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.seg-b { flex: 1; padding: 8px 4px; border: 0; background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; border-inline-start: 1px solid var(--line); }
.seg-b:first-child { border-inline-start: 0; }
.seg-b.on { background: var(--brand); color: #fff; }
/* تخطيط جدولي للتعديل: الاسم وبجانبه حقوله في صفّ واحد */
.grid-table { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; margin-top: 6px; }
.grid-trow { display: grid; grid-template-columns: minmax(100px, 1.2fr) repeat(var(--cols), minmax(116px, 1fr)); gap: 6px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.grid-trow:last-child { border-bottom: 0; }
.grid-thead { background: var(--bg); font-weight: 700; font-size: .82rem; color: var(--brand); position: sticky; top: 0; }
.grid-tc { min-width: 0; }
.grid-tc-name b { display: block; font-size: .95rem; line-height: 1.25; }
.grid-tc-name .muted { font-size: .7rem; }
.grid-tc input, .grid-tc select { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--text); }
.grid-tc input:focus, .grid-tc select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-l); }

/* ===== زر التعليمات (i) ===== */
.hint-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-l); color: var(--brand-d); font-size: .72rem; font-weight: 800;
  font-family: Georgia, 'Times New Roman', serif; font-style: italic;
  margin-inline-start: 6px; vertical-align: middle; line-height: 1; flex: none;
}
.hint-i:hover { background: var(--brand); color: #fff; }
.more-card { display: flex; align-items: center; justify-content: space-between; }
.more-card .hint-i { width: 22px; height: 22px; font-size: .85rem; }
.hint-body { line-height: 1.9; font-size: .98rem; color: var(--text, inherit); margin-bottom: 4px; }

/* ===== تبويبات فرعية داخل الشاشة ===== */
.subtabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 5px; margin-bottom: 12px; }
.subtab { flex: 1; border: 0; background: transparent; padding: 10px 8px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--muted); transition: background .12s, color .12s; }
.subtab.active { background: var(--brand); color: #fff; }
.subtab:not(.active):hover { background: var(--bg); color: var(--brand); }

/* ===== مجموعات قائمة المزيد ===== */
.more-group { margin-bottom: 12px; }
.more-group-title {
  width: 100%; display: flex; align-items: center; gap: 9px; cursor: pointer; text-align: right;
  font: inherit; font-size: 1rem; font-weight: 800; color: var(--brand);
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--card)), var(--card) 70%);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); border-radius: 14px; padding: 13px 14px; margin: 0;
  box-shadow: 0 10px 22px -16px color-mix(in srgb, var(--brand) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.5);
}
.more-group-title .mg-ico { font-size: .85rem; width: 14px; flex: none; opacity: .8; }
.more-group-title .mg-label { flex: 1; }
.more-group-title .mg-count { font-size: .72rem; font-weight: 700; background: var(--brand-l); color: var(--brand-d); border-radius: 999px; padding: 1px 9px; flex: none; }
.more-group-items { padding-top: 8px; }
.more-group:not(.open) .more-group-items { display: none; }
.more-card { margin-bottom: 8px; }

/* ===== قائمة المستخدمين (أسماء فقط + توسعة) ===== */
.mlist { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.mitem { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.mitem.open { border-color: var(--brand); }
.mitem-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; cursor: pointer; }
.mitem-head:hover { background: var(--brand-l); }
[data-theme="dark"] .mitem-head:hover { background: #262a3a; }
.mitem-name { font-weight: 700; }
.mitem-sub { font-size: .78rem; color: var(--muted); margin-inline-start: auto; }
.mitem-arrow { color: var(--brand); font-size: .9rem; }
.mitem-body { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--card); }

/* ===== نموذج إضافة المولود المبسّط ===== */
.add-card { padding: 18px 16px; }
.add-more { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.add-more summary { cursor: pointer; padding: 10px 0; font-weight: 700; color: var(--brand); list-style: none; }
.add-more summary::-webkit-details-marker { display: none; }
.add-more[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }


/* رأس المفرجي في العرض الهرمي */
.hier-top { font-weight: 800; font-size: 1.1rem; color: var(--brand); background: var(--brand-l); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; text-align: center; }
[data-theme="dark"] .hier-top { background: #312E81; color: #fff; }
@media print { .outline-tbl th.oc, .outline-tbl td[class*="oc"] { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ===== نموذج الأعمدة (تدرّجات خضراء + فواصل الفروع) ===== */
.outline-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
.outline-tbl { border-collapse: collapse; font-size: .95rem; min-width: 100%; }
.outline-tbl th, .outline-tbl td { padding: 8px 12px; white-space: nowrap; border: 1px solid #7bb389; text-align: center; }
.outline-tbl th.oc { color: #fff; font-weight: 800; position: sticky; top: 0; }
/* ترويسات خضراء غامقة → فاتحة حسب الجيل */
.outline-tbl th.oc0 { background: #14532d; } .outline-tbl td.oc0 { background: #cdeccd; }
.outline-tbl th.oc1 { background: #166534; } .outline-tbl td.oc1 { background: #d6f0d6; }
.outline-tbl th.oc2 { background: #15803d; } .outline-tbl td.oc2 { background: #e0f4e0; }
.outline-tbl th.oc3 { background: #16a34a; } .outline-tbl td.oc3 { background: #eaf8ea; }
.outline-tbl th.oc4 { background: #22c55e; } .outline-tbl td.oc4 { background: #f1fbf1; }
.outline-tbl th.oc5 { background: #4ade80; } .outline-tbl td.oc5 { background: #f8fef8; }
.outline-tbl td.filled { font-weight: 800; color: #052e16; }
.outline-tbl td.obranch { font-weight: 800; }
.outline-tbl td.oroot { font-size: 1.05rem; font-weight: 800; color: #14532d; }
/* خط سميك أعلى رأس كل فرع (الجيل الثاني) */
.outline-tbl tr.orow-branch td { border-top: 3px solid #15803d; }
/* خطّان (سميك مزدوج) أعلى كل أصل: فراج/مفرج */
.outline-tbl tr.orow-root td { border-top: 6px double #14532d; }
[data-theme="dark"] .outline-tbl th, [data-theme="dark"] .outline-tbl td { border-color: #3a6b4d; }
[data-theme="dark"] .outline-tbl td.oc0 { background: #0c2a18; }
[data-theme="dark"] .outline-tbl td.oc1 { background: #0e2f1b; }
[data-theme="dark"] .outline-tbl td.oc2 { background: #10341e; }
[data-theme="dark"] .outline-tbl td.oc3 { background: #123922; }
[data-theme="dark"] .outline-tbl td.oc4 { background: #143e25; }
[data-theme="dark"] .outline-tbl td.oc5 { background: #164328; }
[data-theme="dark"] .outline-tbl td.filled { color: #bbf7d0; }
[data-theme="dark"] .outline-tbl td.oroot { color: #86efac; }
[data-theme="dark"] .outline-tbl tr.orow-branch td { border-top-color: #4ade80; }
[data-theme="dark"] .outline-tbl tr.orow-root td { border-top-color: #86efac; }
@media print { .outline-tbl th.oc, .outline-tbl td[class*="oc"] { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ===== معالج إضافة المولود ===== */
.add-step.cur { border-color: var(--brand); color: var(--brand); font-weight: 800; }
.add-step.cur .add-step-n { background: var(--brand); color: #fff; }
.add-step.done .add-step-n { background: var(--ok); color: #fff; }
.abw-tree { max-height: 60vh; }
.abw-chain { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.abw-chain-t { font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.abw-child { color: var(--brand); background: var(--brand-l); padding: 1px 8px; border-radius: 6px; }
.abw-anc { color: var(--text); }
.abw-bn { color: var(--muted); font-size: .82rem; margin: 0; }
#abw_chain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; line-height: 1.9; font-size: 1.02rem; }

/* ===== مؤشّر الحالة (نقطة ملوّنة بدل كلمة) ===== */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-inline-start: 4px; flex: none; }
.status-dot.died { background: var(--c-dead); }                 /* متوفّى: رمادي */
.status-dot.died-noissue { background: var(--c-noissue); }         /* توفي ولم يعقب: أحمر داكن */
/* نص الحالة في صفحة الشخص */
.died-txt { color: var(--c-dead); font-weight: 700; }
.died-noissue-txt { color: var(--c-noissue); font-weight: 800; }
/* مفتاح الألوان */
.status-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 1rem; font-weight: 700; margin: 6px 2px; }
.status-legend span { display: inline-flex; align-items: center; gap: 5px; }
.status-legend-card { padding: 12px 14px; }
.legend-title { font-weight: 700; color: var(--brand); font-size: .92rem; margin-bottom: 8px; }

/* ===== تمييز الحالة بلون اسم الشخص ===== */
.stat-tag { font-size: .72rem; font-weight: 600; margin-inline-start: 4px; white-space: nowrap; }
/* إعادة ترتيب الأبناء (سحب وإفلات بضغط مطوّل) */
.reorder-hint { font-size: .8rem; color: var(--muted); background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 6px 9px; margin-bottom: 8px; }
.reorder-list [data-reorder-id] { touch-action: none; user-select: none; -webkit-user-select: none; align-items: center; gap: 8px; }
.reorder-grip { color: var(--brand); cursor: grab; font-size: 1.3rem; flex: none; padding: 4px 8px; touch-action: none; }
.reorder-grip:active { cursor: grabbing; }
.row.reorder-grab { background: var(--brand-l); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.22); }
.reorder-list.reordering [data-reorder-id]:not(.reorder-grab) { opacity: .85; }
/* أسهم ترتيب الأبناء (دقيقة، ضمن الأب فقط) */
.reorder-arrows { display: inline-flex; flex-direction: column; gap: 3px; flex: none; }
.reorder-up, .reorder-down {
  width: 32px; height: 24px; line-height: 1; padding: 0; cursor: pointer; color: var(--brand); font-size: .78rem;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); border-radius: 7px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 12%, var(--card)), var(--card));
  box-shadow: 0 2px 5px -3px color-mix(in srgb, var(--brand) 70%, transparent); touch-action: manipulation;
}
.reorder-up:active, .reorder-down:active { transform: translateY(1px); }
.reorder-up:disabled, .reorder-down:disabled { opacity: .3; cursor: default; box-shadow: none; }
.nick { color: var(--gold); font-weight: 600; font-size: .9em; }
.n-alive { color: var(--text) !important; font-weight: 700; }  /* موجود: لون عادي */
.n-died { color: var(--c-dead) !important; }                    /* متوفّى: رمادي */
.n-noissue { color: var(--c-noissue) !important; }                 /* لم يعقب: أحمر داكن */
/* بطاقات حالات الإحصائيات: العدد فوق، التفصيل تحته، بروزٌ ثلاثي الأبعاد */
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 2px; }
.s3 { text-align: center; border-radius: 14px; padding: 14px 6px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--s3c) 14%, var(--card)), var(--card) 72%);
  border: 1px solid color-mix(in srgb, var(--s3c) 32%, var(--line));
  box-shadow: 0 13px 26px -18px color-mix(in srgb, var(--s3c) 75%, transparent), 0 2px 0 color-mix(in srgb, var(--s3c) 24%, transparent), inset 0 1px 0 rgba(255,255,255,.5); }
.s3-n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; color: var(--s3c); }
.s3-l { font-size: .74rem; font-weight: 700; color: var(--muted); margin-top: 4px; }
.s3-alive { --s3c: var(--c-alive); }
.s3-dead { --s3c: var(--c-dead); }
.s3-noissue { --s3c: var(--c-noissue); }

/* ===== شريط تبويبات لوحة التحكم ===== */
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.admin-tab { flex: none; background: var(--card); color: var(--brand); border: 1px solid var(--brand-l); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.admin-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== اختيار الجدّ الهرمي ===== */
.anc-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.anc-crumb { font-size: .82rem; color: var(--muted); margin-bottom: 6px; line-height: 1.9; }
.anc-cl { color: var(--brand); cursor: pointer; }
.anc-cl:hover { text-decoration: underline; }
.anc-cur { background: var(--brand-l); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.anc-cur .btn { margin: 0; }
.anc-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.anc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.anc-row:last-child { border-bottom: 0; }
.anc-name { font-weight: 700; cursor: pointer; flex: 1; }
.anc-name:hover { color: var(--brand); }
.anc-row .btn { margin: 0; }

/* ===== شريط تثبيت التطبيق ===== */
.install-bar {
  position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 70;
  background: var(--card); border: 1px solid var(--brand); border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  animation: dlgPop .25s ease;
}
.install-txt { flex: 1; min-width: 160px; font-weight: 600; font-size: .92rem; line-height: 1.6; }
.install-actions { display: flex; gap: 8px; }
.install-actions .btn { margin: 0; }

/* ===== أدوات المشجّرة الجديدة (مسار النسب/خريطة الذرية/الأقرباء/العدسة) ===== */
/* مسار النسب */
.lp-list { display: flex; flex-direction: column; gap: 0; margin: 4px 0 10px; }
.lp-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer; }
.lp-row:active { background: var(--brand-l); }
.lp-self { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.lp-ico { flex: none; width: 22px; text-align: center; }
.lp-name { font-weight: 800; flex: 1; min-width: 0; word-break: break-word; }
.lp-gen { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.lp-arrow { text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.lp-warn { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: 8px; padding: 6px 10px; font-size: .85rem; margin-bottom: 8px; font-weight: 700; }
.lp-full { background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; font-weight: 700; line-height: 1.9; }

/* خريطة الذرية المصغّرة */
.mini-head { margin-bottom: 8px; }
.mini-head b { font-size: 1.05rem; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 6px 0; }
.mini-stat { border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line)); border-radius: 12px; padding: 10px 4px; text-align: center; background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--card)), var(--card) 72%); box-shadow: 0 10px 22px -16px color-mix(in srgb, var(--brand) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--brand) 16%, transparent), inset 0 1px 0 rgba(255,255,255,.45); }
.mini-stat .n { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.mini-stat .l { font-size: .72rem; font-weight: 700; color: var(--muted); }
.mini-stat.ok { background: linear-gradient(160deg, color-mix(in srgb, var(--ok) 12%, var(--card)), var(--card) 72%); border-color: color-mix(in srgb, var(--ok) 28%, var(--line)); box-shadow: 0 10px 22px -16px color-mix(in srgb, var(--ok) 65%, transparent), 0 2px 0 color-mix(in srgb, var(--ok) 18%, transparent), inset 0 1px 0 rgba(255,255,255,.45); }
.mini-stat.ok .n { color: var(--ok); } .mini-stat.mut .n { color: var(--muted); }
.mini-lvl { margin-top: 8px; max-height: 40vh; overflow-y: auto; }
.mini-node { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.mini-sub { margin-top: 4px; padding-inline-start: 14px; display: flex; flex-wrap: wrap; gap: 4px; }

/* رقائق الأسماء (الأقرباء/الذرية) */
.rel-sec { margin: 8px 0; }
.rel-sec-h { font-size: .82rem; font-weight: 800; color: var(--brand); margin-bottom: 4px; }
.rel-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.rel-self .rel-chips .rel-chip { }
.rel-chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-weight: 700; font-size: .9rem; cursor: pointer; }
.rel-chip:active { background: var(--brand-l); }
.rel-chip.strong { border-color: var(--brand); }
.rel-chip.n-died { color: var(--c-dead); } .rel-chip.n-noissue { color: var(--c-noissue); }
.rel-more { display: inline-block; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); border-radius: 999px; padding: 4px 11px; font-weight: 800; font-size: .85rem; cursor: pointer; }

/* العدسة السريعة */
.ql-sub { color: var(--muted); font-size: .9rem; margin: -4px 0 10px; line-height: 1.7; }
.ql-stats { display: flex; gap: 10px; margin-bottom: 12px; }
.ql-stat { flex: 1; border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line)); border-radius: 12px; padding: 10px 8px; text-align: center; background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--card)), var(--card) 72%); box-shadow: 0 10px 22px -16px color-mix(in srgb, var(--brand) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--brand) 16%, transparent), inset 0 1px 0 rgba(255,255,255,.45); }
.ql-stat .n { font-size: 1.6rem; font-weight: 800; color: var(--brand); }
.ql-stat .l { font-size: .75rem; font-weight: 700; color: var(--muted); }
.ql-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ql-tools .btn { margin: 0; }

/* ===== خط الأجيال ===== */
.tl-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.tl-rootbadge { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.tl-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tl-sel { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); padding: 0 8px; font: inherit; }
.tl-filters .search { flex: 1; min-width: 140px; }
.tl-gen { margin-bottom: 14px; }
.tl-gen-h { font-weight: 800; color: var(--brand); font-size: 1.02rem; padding: 6px 4px; border-bottom: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.tl-gen-n { font-size: .75rem; font-weight: 700; color: #fff; background: var(--brand); border-radius: 999px; padding: 2px 9px; }
.tl-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .tl-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) { .tl-grid { grid-template-columns: 1fr 1fr 1fr; } }
.tl-card { border: 1px solid var(--line); border-inline-start: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 10px; padding: 9px 11px; background: var(--card); cursor: pointer; }
.tl-card:active { background: var(--brand-l); }
.tl-name { font-weight: 800; }
.tl-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* ===== الشجرة الدائرية ===== */
.rad-genctl { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.rad-genctl .btn { min-width: 30px; padding: 4px 8px; }
.rad-wrap { width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 8px; }
.rad-svg { display: block; }
.rad-guides .rad-ring { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; opacity: .7; }
.rad-link { fill: none; stroke: color-mix(in srgb, var(--brand) 35%, transparent); stroke-width: 1.6; }
.rad-g { cursor: pointer; }
.rad-c { fill: var(--brand); stroke: #fff; stroke-width: 2.5; }
.rad-c.d0 { fill: var(--brand-d); stroke-width: 3; } .rad-c.d1 { fill: var(--brand); } .rad-c.d2 { fill: var(--accent); } .rad-c.d3 { fill: #6b7fd1; }
.rad-c.n-died { fill: var(--c-dead); } .rad-c.n-noissue { fill: var(--c-noissue); }
/* تسمية المركز داخل الدائرة بيضاء؛ التسميات الشعاعية بلون النص مع هالة بيضاء لوضوحها */
.rad-t { pointer-events: none; font-weight: 800; }
.rad-t0 { fill: #fff; font-size: 13px; }
.rad-lbl { fill: var(--text); font-size: 12px; paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; }
.rad-more circle { fill: color-mix(in srgb, var(--brand) 22%, var(--card)); stroke: var(--brand); stroke-width: 1.5; }
.rad-more text { fill: var(--brand); font-size: 12px; font-weight: 800; pointer-events: none; }

/* ===== وضع تتبّع الفرع ===== */
.track-bar { background: color-mix(in srgb, var(--brand) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.track-bar.suggest { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.track-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; flex-wrap: wrap; }
.track-up { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.track-up-h { font-size: .8rem; font-weight: 800; color: var(--brand); margin-bottom: 4px; }
.track-stats { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.track-recent { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.track-lbl { font-size: .78rem; color: var(--muted); }

/* ===== عرض النسخة المختصرة للطباعة (داخل الموقع) ===== */
.ptv { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ptv-h1 { color: var(--brand); font-size: 1.2rem; font-weight: 800; margin: 0 0 2px; }
.ptv-sub { color: var(--muted); font-size: .85rem; border-bottom: 2px solid var(--brand); padding-bottom: 6px; margin-bottom: 10px; }
.ptv-cols { column-width: auto; }   /* عمود واحد على الشاشة لتفادي التداخل */
.ptv-idx .ptv-r { break-inside: avoid; line-height: 1.5; font-size: .9rem; padding: 2px 0; border-bottom: 1px dotted var(--line); }
.ptv-idx .ptv-num { color: var(--brand); font-family: ui-monospace, monospace; font-size: .72rem; font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.ptv .nm { font-weight: 700; }
.ptv .m { color: var(--muted); font-weight: 400; font-size: .82em; }
.ptv-tree, .ptv-tree ul { list-style: none; margin: 0; padding-inline-start: 14px; border-inline-start: 1px dotted var(--line); }
.ptv-tree { padding-inline-start: 0; border: 0; }
.ptv-tree li { margin: 2px 0; line-height: 1.6; font-size: .9rem; break-inside: avoid; }
.ptv-foot { margin-top: 16px; color: var(--muted); font-size: .72rem; border-top: 1px solid var(--line); padding-top: 6px; }
@media print {
  /* اطبع منطقة النسخة فقط بشكلٍ نظيف */
  .ptv { border: 0 !important; padding: 0 !important; }
  .ptv-h1 { color: #312E81 !important; }
  /* الأعمدة عند الطباعة فقط، وللفهرس المرقّم فقط (المشجّرة المتدرّجة تبقى عموداً واحداً) */
  .ptv-idx { column-width: 250px; column-gap: 20px; }
  .ptv-idx .ptv-r { border-bottom: 1px dotted #e6e6ee; }
  .ptv-num { color: #312E81 !important; }
}

/* ===== حاسبة صلة القرابة ===== */
.kin-slot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 4%, var(--card)); }
.kin-slot-l { font-size: .78rem; font-weight: 800; color: var(--brand); flex: 0 0 auto; }
.kin-slot-body { flex: 1 1 130px; min-width: 0; }
.kin-slot .btn { flex: 0 0 auto; }
.kin-slot-p b { font-weight: 800; overflow-wrap: anywhere; }
.kin-chain, .kin-rel { overflow-wrap: anywhere; }
.kin-vs { text-align: center; color: var(--muted); font-size: 1.1rem; margin: 6px 0; }
.kin-card { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.kin-rel { font-size: 1.15rem; font-weight: 800; color: var(--brand); line-height: 1.5; }
.kin-detail { color: var(--text); font-size: .92rem; margin-top: 4px; }
.kin-lca { text-align: center; margin: 12px 0; padding: 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 8%, transparent); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.kin-lca-l { font-size: .76rem; font-weight: 800; color: var(--muted); }
.kin-lca-name { font-size: 1.15rem; font-weight: 800; color: var(--brand); cursor: pointer; }
.kin-paths { display: flex; flex-direction: column; gap: 10px; }
.kin-path { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kin-path-l { font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.kin-chain { line-height: 2; }
.kin-name { font-weight: 700; cursor: pointer; color: var(--text); }
.kin-name.kin-lca-name { display: inline; font-size: 1rem; background: color-mix(in srgb, var(--brand) 16%, transparent); border-radius: 6px; padding: 1px 6px; }
.kin-bn { color: var(--muted); font-weight: 400; font-size: .85em; margin: 0 4px; }

/* ===== رسالة الترحيب/المبارَكة بعد الدخول (الجزء الأوسط العلوي) ===== */
.greet-bg { position: fixed; inset: 0; z-index: 1100; background: rgba(15,17,23,.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 18px 18px; overflow-y: auto; }
.greet-card { background: var(--card); color: var(--text); width: 100%; max-width: 460px; border-radius: 18px;
  padding: 20px 18px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.55); border: 1px solid var(--line);
  animation: greetIn .28s ease both; }
@keyframes greetIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
.greet-welcome { text-align: center; white-space: pre-wrap; font-size: 1.15rem; line-height: 1.95; font-weight: 700; padding: 4px 2px; }
.greet-congrats { position: relative; margin-top: 14px; padding: 16px 14px 14px; border-radius: 14px; text-align: center;
  background: linear-gradient(150deg, color-mix(in srgb, var(--gold) 14%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  box-shadow: 0 6px 20px -10px color-mix(in srgb, var(--gold) 60%, transparent); }
.greet-congrats-badge { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .5px; color: #fff;
  background: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #b45309)); padding: 3px 12px; border-radius: 999px; margin-bottom: 8px; }
.greet-congrats-text { font-size: 1.15rem; font-weight: 800; line-height: 1.8; white-space: pre-wrap; }
.greet-card .btn-lg { margin-top: 16px; width: 100%; }

/* شريط التهنئة أعلى الرئيسية طوال مدّة العرض */
.congrats-strip { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius, 14px);
  background: linear-gradient(150deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--gold) 55%, transparent); }
.congrats-strip .cs-badge { font-size: .7rem; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #b45309)); padding: 2px 10px; border-radius: 999px; }
.congrats-strip .cs-text { font-size: 1.05rem; font-weight: 800; line-height: 1.7; white-space: pre-wrap; }

/* سطر الترحيب أعلى الرئيسية: غامق ومميّز، وبخطٍّ أصغر درجةً ليتّسع الاسم كاملاً */
.home-greet { font-size: .9rem; margin: 2px 0 10px; line-height: 1.7; font-weight: 700; }
.home-greet .hg-name { font-weight: 800; color: var(--brand); }
.home-greet .hg-role { color: var(--muted); font-weight: 600; }

/* الصفحة الرئيسية: كل الكتابات غامقة */
[data-screen="home"] { font-weight: 700; }
[data-screen="home"] .muted, [data-screen="home"] .hg-role, [data-screen="home"] p,
[data-screen="home"] small, [data-screen="home"] .li-sub, [data-screen="home"] li { font-weight: 700; }

/* ===== شاشة «إرسال ملاحظات» — تصميم عصري ثلاثي الأبعاد بخطوط غامقة مميّزة ===== */
.fb-screen { font-weight: 700; }
.fb-screen .field { margin-bottom: 8px; }
.fb-screen .grid2 { gap: 8px; }
.fb-screen .field input, .fb-screen .field textarea { line-height: 1.4; }
.fb-screen .card {
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: 18px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 7%, var(--card)) 0%, var(--card) 55%);
  box-shadow: 0 18px 40px -22px color-mix(in srgb, var(--brand) 75%, transparent),
              0 2px 0 color-mix(in srgb, var(--brand) 22%, transparent),
              inset 0 1px 0 rgba(255,255,255,.55);
}
.fb-screen h3 { font-weight: 800; font-size: 1.2rem; letter-spacing: -.2px; }
.fb-screen .li-title { font-weight: 800; color: var(--brand); font-size: 1.02rem; }
.fb-screen .field label, .fb-screen label { font-weight: 800; color: var(--text); }
.fb-screen .muted { font-weight: 600; }
.fb-screen .field input, .fb-screen .field select, .fb-screen .field textarea {
  font-weight: 700; border-radius: 12px;
  border: 1.5px solid color-mix(in srgb, var(--brand) 28%, var(--line));
  box-shadow: inset 0 2px 5px -3px rgba(0,0,0,.25);
  transition: box-shadow .18s ease, border-color .18s ease;
}
.fb-screen .field input:focus, .fb-screen .field select:focus, .fb-screen .field textarea:focus {
  border-color: var(--brand); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent), inset 0 2px 5px -3px rgba(0,0,0,.2);
}
/* بطاقة العنوان (الترويسة) — بارزة أكثر */
.fb-screen .card:first-child {
  background: linear-gradient(150deg, color-mix(in srgb, var(--brand) 16%, var(--card)), var(--card) 70%);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
}
.fb-screen .card:first-child > div:first-child { filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--brand) 45%, transparent)); }
/* زر الإرسال — ثلاثي الأبعاد عصري (يضغط للأسفل عند النقر) */
.fb-screen .btn-lg {
  font-weight: 800; font-size: 1.06rem; border: 0; border-radius: 14px; color: #fff;
  background: linear-gradient(180deg, var(--brand), var(--brand-d));
  box-shadow: 0 12px 24px -10px color-mix(in srgb, var(--brand) 85%, transparent),
              0 3px 0 var(--brand-d), inset 0 1px 0 rgba(255,255,255,.28);
  transform: translateY(0); transition: transform .12s ease, box-shadow .12s ease;
}
.fb-screen .btn-lg:active {
  transform: translateY(3px);
  box-shadow: 0 5px 12px -10px color-mix(in srgb, var(--brand) 85%, transparent),
              0 0 0 var(--brand-d), inset 0 1px 0 rgba(255,255,255,.28);
}

/* مجموعات شاشة «النصوص»: قابلة للطيّ/التمدد وبلونٍ مميّز لكل قسم */
.tx-group { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: color-mix(in srgb, var(--txc) 4%, var(--card));
  border-inline-start: 5px solid var(--txc);
  box-shadow: 0 2px 8px -4px rgba(0,0,0,.25); }
.tx-group-title { width: 100%; display: flex; align-items: center; gap: 8px; padding: 13px 14px;
  background: color-mix(in srgb, var(--txc) 10%, var(--card));
  border: 0; font: inherit; font-weight: 800; font-size: 1rem; color: var(--txc);
  cursor: pointer; text-align: start; }
.txg-ico { font-size: .9rem; width: 14px; }
.txg-label { flex: 1; }
.txg-count { background: var(--txc); color: #fff; border-radius: 999px; min-width: 22px; height: 22px;
  padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font-size: .74rem; }
.tx-group-items { display: none; padding: 10px 10px 2px; }
.tx-group.open .tx-group-items { display: block; }
.tx-group .card { box-shadow: none; border: 1px solid var(--line); }
.txg-0 { --txc: #4338CA; }   /* الرئيسية والهوية — بنفسجي */
.txg-1 { --txc: #b8860b; }   /* المناسبات — ذهبي */
.txg-2 { --txc: #0f8a4d; }   /* دخول الزائر — أخضر */
.txg-3 { --txc: #0891B2; }   /* الملاحظات والردود — سماوي */
.txg-4 { --txc: #d9480f; }   /* الإحصاء والحالة — برتقالي */

/* لوحة التحكم: شبكة مربعات الخدمات — متباعدة بلا تداخل، لكلٍّ لونه ومسؤولياته */
.cp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cp-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 16px 10px 14px; border: 1px solid var(--line); border-radius: 16px; cursor: pointer;
  font: inherit; color: var(--text);
  background: linear-gradient(160deg, color-mix(in srgb, var(--tc) 10%, var(--card)), var(--card) 70%);
  border-top: 3px solid var(--tc);
  box-shadow: 0 4px 12px -6px rgba(0,0,0,.35); }
.cp-tile:active { transform: scale(.97); }
.cp-ico { font-size: 1.9rem; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.2)); }
.cp-title { font-weight: 800; font-size: .95rem; color: var(--tc); }
.cp-desc { font-size: .72rem; color: var(--muted); line-height: 1.7; }
.cpt-0 { --tc: #4338CA; } .cpt-1 { --tc: #0f8a4d; } .cpt-2 { --tc: #d9480f; }
.cpt-3 { --tc: #0891B2; } .cpt-4 { --tc: #b8860b; } .cpt-5 { --tc: #9c36b5; }

/* اللوحة: الخدمات الأكثر استخداماً — صفوف بارزة أعلى الشبكة مع عدّاد المعلّق */
.cp-sec { font-weight: 800; font-size: .92rem; color: var(--muted); margin: 2px 2px 8px; }
.cp-feat { width: 100%; display: flex; align-items: center; gap: 12px; text-align: start;
  padding: 13px 14px; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 14px;
  border-inline-start: 5px solid var(--tc); cursor: pointer; font: inherit; color: var(--text);
  background: linear-gradient(120deg, color-mix(in srgb, var(--tc) 10%, var(--card)), var(--card) 75%);
  box-shadow: 0 4px 12px -6px rgba(0,0,0,.35); }
.cp-feat:active { transform: scale(.98); }
.cp-feat .cp-ico { font-size: 1.6rem; }
.cp-feat-tx { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cp-feat .cp-title { font-size: 1rem; }
.cp-feat .cp-desc { font-size: .74rem; }
.cp-badge { background: var(--danger); color: #fff; border-radius: 999px; min-width: 26px; height: 26px;
  padding: 0 7px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .82rem; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.cp-arrow { color: var(--tc); font-weight: 900; font-size: 1.2rem; }

/* شارة صندوق الوارد داخل قوائم «المزيد» — تتسلسل من تبويب المزيد حتى البند */
.inb-badge { display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; border-radius: 999px; min-width: 20px; height: 20px;
  padding: 0 6px; font-size: .7rem; font-weight: 800; vertical-align: middle; margin-inline-start: 4px; }

/* 💬 المناقشات — محاكاة واتساب: قائمة المحادثات */
.wa-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 12px;
  margin: 0 0 8px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  font: inherit; color: var(--text); background: var(--card); text-align: start;
  box-shadow: 0 2px 8px -5px rgba(0,0,0,.3); }
.wa-item:active { background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
.wa-item.unread { border-inline-start: 4px solid #1fa855; }
.wa-av { width: 44px; height: 44px; flex: none; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 1.3rem; background: color-mix(in srgb, #1fa855 14%, var(--card)); }
.wa-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-row1, .wa-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wa-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-time { font-size: .7rem; color: var(--muted); flex: none; }
.wa-prev { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item.unread .wa-prev { color: var(--text); font-weight: 600; }
.wa-dot { width: 10px; height: 10px; border-radius: 50%; background: #1fa855; flex: none; }

/* غرفة المحادثة: خلفية وفقاعات وفواصل أيام */
.wa-chat { min-height: 55vh; max-height: calc(100vh - 235px); overflow-y: auto; padding: 10px 6px;
  border-radius: 14px; border: 1px solid var(--line);
  background: color-mix(in srgb, #7a9e7e 12%, var(--bg)); display: flex; flex-direction: column; gap: 4px; }
.wa-day { text-align: center; margin: 8px 0 4px; }
.wa-day span { background: var(--card); color: var(--muted); font-size: .7rem; font-weight: 700;
  padding: 3px 12px; border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.wa-bub { position: relative; max-width: 82%; align-self: flex-start; background: var(--card);
  border-radius: 12px; border-start-end-radius: 3px; padding: 6px 10px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.wa-bub.me { align-self: flex-end; background: color-mix(in srgb, #1fa855 22%, var(--card));
  border-start-end-radius: 12px; border-start-start-radius: 3px; }
.wa-who { font-size: .72rem; font-weight: 800; color: #d9480f; margin-bottom: 2px; }
.wa-body { white-space: pre-wrap; word-break: break-word; font-size: .95rem; line-height: 1.7; }
.wa-t { position: absolute; bottom: 3px; inset-inline-end: 9px; font-size: .62rem; color: var(--muted); }

/* شريط الإدخال */
.wa-inputbar { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.wa-inputbar textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 22px;
  padding: 11px 14px; font: inherit; background: var(--card); color: var(--text); max-height: 120px; }
.wa-inputbar button { width: 46px; height: 46px; flex: none; border: none; border-radius: 50%;
  background: #1fa855; color: #fff; font-size: 1.15rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transform: scaleX(-1);
  box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.wa-inputbar button:active { transform: scaleX(-1) scale(.92); }

/* الحقول الإجبارية (نموذج التسجيل): خلفية مميزة وكتابة/إطار بالأحمر */
.req-in { background: #fff5f5 !important; border: 1.6px solid #e03131 !important; color: #c92a2a !important; font-weight: 700; }
.req-in::placeholder { color: #e03131; opacity: .95; font-weight: 700; }
:root[data-theme="dark"] .req-in { background: #2a1215 !important; }
@media (prefers-color-scheme: dark) { .req-in { background: #2a1215 !important; } }

/* نافذة التسجيل: ضغطٌ عمودي لتظهر كل الحقول دفعةً واحدة على الجوال */
.signup-compact .field { margin-bottom: 6px; }
.signup-compact .field input { padding: 8px 10px; font-size: .88rem; min-height: 0; }
.signup-compact .grid2 { gap: 6px; }
.signup-compact .perm-chk { padding: 3px 0; font-size: .82rem; }
.signup-compact .btn { padding: 10px 12px; }
.modal { max-height: 94vh; overflow-y: auto; }
