/* ═══════════════════════════════════════════════════════════
   Jrss — نظام التصميم
   العلامة #C85151 مستخرجة من الشعار · كل الألوان مشتقة منها
   داكن · Inter · كثافة عالية · RTL · موبايل أولاً
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── العلامة — من الشعار ── */
  --brand:      #C85151;
  --brand-lt:   #D97B7B;
  --brand-dk:   #9E3C3C;
  --brand-a08:  rgba(200,81,81,.08);
  --brand-a14:  rgba(200,81,81,.14);
  --brand-a24:  rgba(200,81,81,.24);
  --grad:       linear-gradient(135deg, #D97B7B 0%, #C85151 55%, #9E3C3C 100%);

  /* ── الأسطح — رمادي دافئ مائل للعلامة، لا رمادي بارد ── */
  --bg:        #0C0909;
  --surface:   #151011;
  --surface-2: #1C1618;
  --surface-3: #251D1F;
  --border:    #2A2124;
  --border-2:  #382C2F;

  /* ── النص ── */
  --text:   #F2EDED;
  --text-2: #B3A5A6;
  --muted:  #7C6C6E;

  /* ── الدلالة — مضبوطة لتنسجم مع الطوبي ── */
  --up:       #3FB984;
  --up-dim:   rgba(63,185,132,.13);
  --down:     #E05563;
  --down-dim: rgba(224,85,99,.13);
  --warn:     #E0A44F;
  --warn-dim: rgba(224,164,79,.13);

  /* ── المقاييس ── */
  --r-sm: 10px; --r: 14px; --r-lg: 18px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --fast: 180ms; --mid: 280ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ⚠️ منع تحديد النص على واجهة التطبيق.
   على الويب والجوال أي سحبة بالإصبع تحدّد النص فيظهر مستطيل أزرق
   خلف الكلمات ويبقى بعد الرجوع — هذي هي «الطبقة» التي كانت تظهر
   في كل القوائم. التطبيق يُلمس ويُمرّر، لا يُنسخ منه.
   نستثني ما يحتاج المستخدم نسخه فعلاً (المعرّف، الأوامر، المدخلات). */
body, .view, .topbar, .tabbar, .sheet, .locked {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
input, textarea, .locked-cmd, .selectable, .metric b, code {
  -webkit-user-select: text;
  user-select: text;
}
/* لو حصل تحديد رغم ذلك، يكون بلون العلامة لا أزرق النظام */
::selection { background: var(--brand-a24); color: var(--text); }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* حشوة علوية بقدر الترويسة المثبّتة، وسفلية بقدر الشريط */
  padding-top: calc(60px + env(safe-area-inset-top));
  /* الشريط صار فقاعة عائمة: يحتاج مساحة أكبر تحته حتى لا يغطي آخر بطاقة */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  overscroll-behavior-y: none;   /* يمنع سحب الصفحة خلف الترويسة */
  min-height: 100dvh;
}

.hidden { display: none !important; }
b, .num, .stat b, .metric b, .lvl b, .pnl, .bucket b { font-variant-numeric: tabular-nums; }

/* ═══ خلفية الـ blobs المتدرّجة ═══ */
/* ملاحظة: الخلفية مثبّتة خلف كل شي. بدون contain/isolation كانت الفلاتر
   تُعاد رسمها مع كل تمرير فتظهر طبقات ترتجف على الجوال. */
.ambient {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  contain: strict; isolation: isolate;
  transform: translateZ(0);
}
.ambient i {
  position: absolute; border-radius: 50%;
  filter: blur(80px);
  will-change: transform;
  backface-visibility: hidden;
}
.ambient i:nth-child(1) {
  width: 68vw; height: 68vw; max-width: 460px; max-height: 460px;
  background: radial-gradient(circle at 35% 35%, #E86B6B, #C85151 45%, transparent 72%);
  opacity: .30; top: -16%; inset-inline-start: -22%;
  animation: b1 26s var(--ease) infinite;
}
.ambient i:nth-child(2) {
  width: 56vw; height: 56vw; max-width: 380px; max-height: 380px;
  background: radial-gradient(circle at 60% 40%, #9E3C3C, #6E2A2A 50%, transparent 74%);
  opacity: .34; bottom: 6%; inset-inline-end: -20%;
  animation: b2 32s var(--ease) infinite;
}
.ambient i:nth-child(3) {
  width: 44vw; height: 44vw; max-width: 300px; max-height: 300px;
  background: radial-gradient(circle, #D97B7B, transparent 68%);
  opacity: .16; top: 42%; inset-inline-start: 28%;
  animation: b3 38s var(--ease) infinite;
}
@keyframes b1 { 0%,100%{transform:translate(0,0) scale(1)}   50%{transform:translate(8%,10%) scale(1.16)} }
@keyframes b2 { 0%,100%{transform:translate(0,0) scale(1)}   50%{transform:translate(-10%,-8%) scale(1.12)} }
@keyframes b3 { 0%,100%{transform:translate(0,0) scale(1)}   50%{transform:translate(-14%,12%) scale(1.2)} }

/* ═══ الأيقونات ═══ */
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 16px; height: 16px; stroke-width: 2; }

/* ═══ الشريط العلوي ═══ */
/* الترويسة ثابتة لا لاصقة.
   السبب: تلقرام يمرّر ترويسته الخاصة مع الصفحة. مع sticky كانت
   ترويسة التطبيق تتراكب مع ترويسة تلقرام أثناء التمرير فتظهر
   طبقتان مزدوجتان. التثبيت يفصل الطبقتين نهائياً. */
.topbar {
  position: fixed; top: 0; inset-inline: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4);
  padding-top: max(var(--s3), env(safe-area-inset-top));
  background: rgba(12,9,9,.78);
  backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--s3); }

/* الشعار — أعلى اليمين (بداية السطر في RTL) */
/* الشعار — أعلى اليمين. نستخدم قناعاً بدل مرشّح لوني تقريبي:
   القناع يأخذ لونه من --brand مباشرة، فأي تغيير للعلامة ينعكس فوراً
   ولا نحتاج نعيد توليد الصورة. */
.logo {
  height: 30px; width: 88px; display: block;
  background: var(--grad);
  -webkit-mask: url("/static/assets/wordmark.png") no-repeat center / contain;
          mask: url("/static/assets/wordmark.png") no-repeat center / contain;
}
.brand-txt { display: flex; flex-direction: column; gap: 1px; }
.brand-txt b { font-size: 13px; font-weight: 700; letter-spacing: .4px; color: var(--text-2); }
.badge {
  align-self: flex-start;
  font-size: 10px; font-weight: 500; padding: 1px 7px;
  border-radius: 99px; background: var(--surface-2); color: var(--muted);
}
.badge.live { background: var(--up-dim); color: var(--up); }
.clock { text-align: start; line-height: 1.3; }
.clock b { display: block; font-size: 14px; font-weight: 600; }
.clock span { font-size: 10.5px; color: var(--muted); }

/* ═══ التنبيه ═══ */
.notice {
  position: relative; z-index: 1;
  margin: var(--s2) var(--s4) 0; padding: var(--s3) var(--s4);
  display: flex; align-items: flex-start; gap: var(--s2);
  border-radius: var(--r); font-size: 12.5px; line-height: 1.5;
  background: var(--warn-dim); border: 1px solid rgba(224,164,79,.26); color: var(--warn);
}

/* ═══ العروض ═══ */
/* ارتفاع أدنى يمنع قفزة التخطيط عند تبديل القوائم */
.view {
  display: none; position: relative; z-index: 1;
  padding: var(--s4);
  min-height: calc(100dvh - 210px);
  /* ممنوع content-visibility هنا. في مقاطع المرجع ظهرت بطاقات فاضية
     تماماً أثناء الانتقال — المتصفح يتخطى الرسم ثم ما يعيده مع الحركة.
     هذي هي «مشكلة الطبقات» الي شفناها. */
}
.view.active { display: block; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.sec {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 14.5px; font-weight: 600; color: var(--text-2);
  margin: var(--s5) 0 var(--s3);
}
.sec:first-child { margin-top: var(--s1); }
.sec .ic { width: 15px; height: 15px; color: var(--brand); }
.sec.dim .ic { color: var(--muted); }

.empty {
  padding: var(--s5) var(--s4); text-align: center;
  color: var(--muted); font-size: 14px;
  background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--r);
}

/* ═══ إحصاءات ═══ */
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--s2); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s3) var(--s2); text-align: center;
}
.stat span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.stat b { font-size: 23px; font-weight: 700; letter-spacing: -.4px; }

/* ═══ الصدارة ═══ */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); padding: var(--s4);
  transition: transform var(--fast) var(--ease);
}
.hero::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--grad); }
.hero::after {
  content: ""; position: absolute; top: -70px; inset-inline-end: -70px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-a24), transparent 68%);
  pointer-events: none;
}
.hero:active { transform: scale(.972); }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.hero-sym { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.hero-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.hero-pnl { font-size: 26px; font-weight: 800; letter-spacing: -.8px; white-space: nowrap; }
.hero-r { font-size: 11px; color: var(--muted); text-align: start; margin-top: 1px; }

.lvls { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--s1); margin-top: var(--s4); }
.lvl { background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s2) var(--s1); text-align: center; }
.lvl span { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 1px; }
.lvl b { font-size: 14px; font-weight: 600; }

.prog { margin-top: var(--s3); }
.prog-track { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
/* الشريط يمتلئ أخضر كلما اقترب من الهدف، ويصير أحمر وينكمش لو نزل
   تحت الدخول. اللون يقول الاتجاه فوراً بلا قراءة رقم. */
.prog-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #2E9E6E, var(--up));
  transition: width 700ms var(--ease), background 400ms var(--ease);
}
.prog-fill.down { background: linear-gradient(90deg, #B8404C, var(--down)); }
.prog-track.neg { background: var(--down-dim); }
.prog-meta { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 5px; }

/* ═══ الكروت ═══ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s3) var(--s4); margin-bottom: var(--s2);
  cursor: pointer; animation: rise var(--mid) var(--ease) backwards;
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.card:active { transform: scale(.965); border-color: var(--brand); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.card-sym { display: flex; align-items: center; gap: var(--s2); font-size: 17.5px; font-weight: 700; letter-spacing: -.3px; }
.rank {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
}
.rank.r1 { background: var(--grad); color: #fff; }
.card-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card-bot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-top: var(--s2); }
.card-line { font-size: 12.5px; color: var(--text-2); }
.pnl { font-size: 18.5px; font-weight: 700; letter-spacing: -.4px; }

.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

/* ═══ الأوسمة ═══ */
.tags { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 500; padding: 3px 7px;
  border-radius: 6px; border: 1px solid transparent;
}
.tag .ic { width: 11px; height: 11px; stroke-width: 2.2; }
.tag.hot { color: var(--brand-lt); background: var(--brand-a14); border-color: var(--brand-a24); }
.tag.warn { color: var(--warn); background: var(--warn-dim); border-color: rgba(224,164,79,.22); }
.tag.info { color: var(--text-2); background: var(--surface-2); border-color: var(--border-2); }

/* ═══ الشرائح ═══ */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 15px; border-radius: 99px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); font: 500 13px Inter, sans-serif;
  transition: all var(--fast) var(--ease);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:active { transform: scale(.9); }

/* ═══ توزيع الأداء ═══ */
.buckets { display: grid; grid-template-columns: repeat(5,1fr); gap: var(--s1); }
.bucket {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--s3) 2px; text-align: center;
}
.bucket b { display: block; font-size: 19px; font-weight: 700; }
.bucket span { font-size: 10px; color: var(--muted); }
.bucket.hit b { color: var(--up); }
.bucket.hit { border-color: rgba(63,185,132,.28); }

/* ═══ المقاييس ═══ */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s3); }
.metric-h { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.metric-h .ic { width: 13px; height: 13px; color: var(--muted); }
.metric-h span { font-size: 11.5px; color: var(--muted); }
.metric b { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.metric .note { font-size: 10px; margin-top: 2px; color: var(--muted); }
.metric .note.up { color: var(--up); }
.metric .note.warn { color: var(--warn); }
.metric .note.down { color: var(--down); }

/* ═══ الأدلة ═══ */
.evidence { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s4); margin-top: var(--s2); }
.conf { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); }
.ring {
  width: 60px; height: 60px; flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--brand) calc(var(--p,0) * 1%), var(--surface-3) 0);
}
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 18px; font-weight: 700; }
.conf-txt b { font-size: 13px; display: block; }
.conf-txt span { font-size: 11.5px; color: var(--muted); }

.cat { display: flex; align-items: center; gap: var(--s2); margin: 6px 0; font-size: 12px; }
.cat-n { width: 58px; flex: none; color: var(--muted); }
.cat-b { flex: 1; height: 5px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.cat-f { height: 100%; background: var(--brand); border-radius: 99px; transition: width 500ms var(--ease); }
.cat-f.full { background: var(--up); }
.cat-v { width: 32px; text-align: start; color: var(--muted); font-variant-numeric: tabular-nums; }

.reasons { list-style: none; margin-top: var(--s3); }
.reasons li { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; padding: 3px 0; line-height: 1.45; }
.reasons .ic { width: 13px; height: 13px; margin-top: 3px; color: var(--up); }
.reasons.no li, .reasons.no .ic { color: var(--muted); }

.veto {
  display: flex; align-items: flex-start; gap: 6px;
  background: var(--down-dim); border: 1px solid rgba(224,85,99,.28);
  border-radius: var(--r-sm); padding: var(--s3); margin-top: var(--s3);
  font-size: 12px; color: var(--down);
}

/* ═══ التنقل ═══ */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5,1fr);
  background: rgba(21,16,17,.94);
  backdrop-filter: blur(22px) saturate(150%);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  position: relative; min-height: 52px; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font: 500 10px Inter, sans-serif;
  transition: color var(--fast) var(--ease);
}
.tab .ic { transition: transform var(--fast) var(--ease); }
.tab.on { color: var(--brand-lt); }
.tab.on .ic { transform: translateY(-1px); }
.tab.on::before {
  content: ""; position: absolute; top: 0; inset-inline: 26%;
  height: 2.5px; border-radius: 0 0 3px 3px; background: var(--grad);
  animation: tabIn 320ms var(--ease);
  box-shadow: 0 2px 12px var(--brand-a24);
}
@keyframes tabIn { from { transform: scaleX(0); opacity: 0; } }
.tab:active .ic { transform: scale(.82); }

/* ═══ متفرقات ═══ */
.back {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 0 var(--s3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-2);
  font: 500 13px Inter, sans-serif; cursor: pointer; margin-bottom: var(--s3);
}
.back:active { transform: scale(.96); }

.disclaimer { font-size: 10.5px; color: var(--muted); line-height: 1.65; text-align: center; margin-top: var(--s5); padding: 0 var(--s3); }

.toast {
  position: fixed; bottom: calc(76px + env(safe-area-inset-bottom));
  inset-inline: var(--s4); z-index: 60;
  display: flex; align-items: center; gap: var(--s2);
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: var(--r); padding: var(--s3) var(--s4);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.55);
  opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity var(--mid) var(--ease), transform var(--mid) var(--ease);
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast .ic { color: var(--brand-lt); }

.skel {
  height: 84px; border-radius: var(--r); margin-bottom: var(--s2);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%; animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

@media (min-width: 600px) {
  main { max-width: 640px; margin-inline: auto; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ambient i { animation: none; }
}


/* ═══ متوقع وصول الهدف — صف مستقل تحت كل توصية ═══ */
.eta {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s2); padding: 9px var(--s3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px; color: var(--text-2);
}
.eta .ic { width: 15px; height: 15px; color: var(--warn); flex: none; }
.eta b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.eta .eta-win { margin-inline-start: auto; color: var(--muted); font-size: 11px; }
.eta .eta-win b { color: var(--up); }

/* وسم السعر المباشر */
.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--up); margin-inline-end: 5px; vertical-align: middle;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:.25} }

/* ═══ ملاحظة الدخول تحت كل توصية ═══ */
.note-row {
  display: flex; align-items: flex-start; gap: var(--s2);
  margin-top: var(--s2); padding: 10px var(--s3);
  border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
}
.note-row .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.note-row.ok    { background: var(--up-dim);   border-color: rgba(63,185,132,.30);  color: var(--up); }
.note-row.below { background: var(--warn-dim); border-color: rgba(224,164,79,.30);  color: var(--warn); }
.note-row.above { background: var(--warn-dim); border-color: rgba(224,164,79,.30);  color: var(--warn); }
.note-row.void  { background: var(--down-dim); border-color: rgba(224,85,99,.34);   color: var(--down); }
.note-row.late  { background: var(--surface-3); color: var(--muted); }

/* ═══ الوقف المتحرّك ═══ */
.trail-row {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s2); padding: 9px var(--s3);
  border-radius: var(--r-sm); font-size: 12.5px;
  background: var(--up-dim); border: 1px solid rgba(63,185,132,.30);
  color: var(--up);
}
.trail-row .ic { width: 15px; height: 15px; flex: none; }
.trail-row b { font-weight: 700; font-variant-numeric: tabular-nums; }
.trail-lock { margin-inline-start: auto; font-size: 11.5px; opacity: .9; }
