/* ═══════════════════════════════════════════════════════════════════════════
   تحليل الأسهم
   ───────────────────────────────────────────────────────────────────────────
   لغة التصميم من منصة ثانوية طيبة: بطاقات بزوايا 2rem وظل ناعم، مفاتيح اختيار
   بأقراص، شارات بخلفية مُلوَّنة، خط ثمانية. الألوان هوية مالية (كحلي ونيلي)
   وبنفسجي الإشارة هو لون شمعة المؤشر. غيّر الألوان من :root و .dark فقط.
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face { font-family: "Thmanyah Sans"; src: url("../fonts/thmanyahsans-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Thmanyah Sans"; src: url("../fonts/thmanyahsans-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Thmanyah Sans"; src: url("../fonts/thmanyahsans-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Thmanyah Sans"; src: url("../fonts/thmanyahsans-Black.otf") format("opentype"); font-weight: 900; font-display: swap; }

:root {
  --brand-primary: #1d2457;
  --brand-secondary: #3b45c4;
  --brand-accent: #8b7cf6;

  --background: #f5f6fb;
  --foreground: #11142b;
  --card: #ffffff;
  --muted: #eceef8;
  --muted-foreground: #5a6180;
  --accent: #e8eafb;
  --border: #e0e3f2;
  --input: #d3d7ec;
  --primary: var(--brand-primary);
  --primary-foreground: #ffffff;
  --ring: var(--brand-secondary);

  --up: #0f8f7a;
  --down: #d6335a;
  --warning: #c8901e;
  --info: #2f6fd0;

  /* إشارات المؤشر: البنفسجي هو لون شمعة الإشارة */
  --tn-contraction: #7c3aed;
  --tn-squeeze: #c026a3;
  --tn-expansion: #b45309;

  /* السكربت الثاني: منطقة الدخول والأهداف، وبورصة نيويورك */
  --entry: #0f766e;
  --target: #a16207;
  --nyse: #0f766e;

  /* لون النص فوق أي تعبئة لونية صلبة */
  --on-fill: #ffffff;

  --shadow-soft: 0 2px 16px -4px rgb(29 36 87 / 0.1);
  --shadow-lift: 0 16px 40px -8px rgb(29 36 87 / 0.2);
}

.dark {
  --background: #0a0c1c;
  --foreground: #eceefc;
  --card: #121530;
  --muted: #1a1e3d;
  --muted-foreground: #9aa1c9;
  --accent: #1e2347;
  --border: #262b52;
  --input: #30366a;
  --primary: #a5b0ff;
  --primary-foreground: #0c1030;
  --ring: #7c88f2;
  --brand-secondary: #7c88f2;

  --up: #2dd4b0;
  --down: #fb7185;
  --warning: #e2ad45;
  --info: #7aa7ff;

  --tn-contraction: #b79cf2;
  --tn-squeeze: #f09ae0;
  --tn-expansion: #f5b04a;

  --entry: #2dd4bf;
  --target: #facc15;
  --nyse: #2dd4bf;

  --on-fill: #0a0c1c;

  --shadow-soft: 0 2px 16px -4px rgb(0 0 0 / 0.5);
  --shadow-lift: 0 16px 40px -8px rgb(0 0 0 / 0.6);
}

*, *::before, *::after { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; color-scheme: light; }
html.dark { color-scheme: dark; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Thmanyah Sans", ui-sans-serif, system-ui, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  padding-inline: env(safe-area-inset-right) env(safe-area-inset-left);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--brand-secondary); color: #fff; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
a { color: inherit; }
.num, .ltr { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted-foreground); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--ring) 50%, transparent); outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: 1rem; top: -4rem; background: var(--primary); color: var(--primary-foreground); padding: .6rem 1rem; border-radius: .75rem; z-index: 20; }
.skip-link:focus { top: 1rem; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--brand-secondary) 50%, transparent); border-radius: 8px; border: 2px solid var(--background); }

/* ───────── الترويسة ───────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--background) 84%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .8rem; }
.topbar h1 { font-size: 1.3rem; font-weight: 900; letter-spacing: -.01em; line-height: 1.3; }
.theme-btn {
  height: 2.5rem; padding-inline: 1rem; border-radius: .85rem; border: 1px solid var(--input); background: var(--card);
  font-size: .8rem; font-weight: 700; white-space: nowrap; transition: background .15s, transform .15s;
}
.theme-btn:hover { background: var(--accent); }
.theme-btn:active { transform: scale(.97); }

main { padding-block: 1.5rem 3rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.lead { max-width: 62ch; color: var(--muted-foreground); font-size: .95rem; font-weight: 500; }

/* تنبيه بحواف فقط، بدون تعبئة */
.alert {
  border-radius: 1.25rem; padding: .85rem 1.1rem; font-weight: 700; font-size: .9rem;
  background: var(--card); color: var(--foreground); border: 2px solid var(--warning);
}
.alert.error { border-color: var(--down); }

/* ───────── البطاقات ───────── */
.card {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 2rem; box-shadow: var(--shadow-soft);
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat {
  position: relative; overflow: hidden; padding: 1.4rem;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 2rem; box-shadow: var(--shadow-soft); transition: box-shadow .25s, transform .25s;
}
.stat:hover { box-shadow: var(--shadow-lift); transform: translateY(-4px); }
.stat-icon {
  position: relative; display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: 1rem; border-radius: 1rem;
  background: var(--tone); color: var(--on-fill);
}
.stat-icon svg { width: 1.5rem; height: 1.5rem; }
.stat-label { position: relative; font-size: .78rem; font-weight: 700; color: var(--muted-foreground); }
.stat-value { position: relative; margin-top: .15rem; font-size: 2rem; font-weight: 900; line-height: 1.2; letter-spacing: -.02em; }
.stat-value-sm { font-size: 1.1rem; line-height: 1.6; letter-spacing: 0; margin-top: .35rem; }
.stat-hint { position: relative; margin-top: .3rem; font-size: .72rem; font-weight: 500; color: var(--muted-foreground); }

.sk {
  display: inline-block; width: 5rem; height: 1.6rem; vertical-align: middle; border-radius: .6rem;
  background: linear-gradient(90deg, var(--muted) 25%, var(--accent) 50%, var(--muted) 75%); background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ───────── الفلاتر ───────── */
.filters { padding: 1.4rem; display: grid; gap: 1.1rem; }
.filter-grid { display: grid; grid-template-columns: .8fr 1fr 1.2fr; gap: 1rem; }
.filter-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.field { display: grid; gap: .45rem; min-width: 0; align-content: start; }
.field.grow { flex: 1 1 22rem; }
.field.search { flex: 1 1 15rem; max-width: 26rem; }
.field-label { font-size: .74rem; font-weight: 700; color: var(--muted-foreground); }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .25rem; padding: .375rem;
  background: var(--muted); border-radius: 1rem;
}
.seg button {
  min-height: 2.5rem; padding-inline: .5rem; border: 0; border-radius: .75rem; background: transparent;
  color: var(--muted-foreground); font-weight: 700; font-size: .85rem; white-space: nowrap; transition: all .15s;
}
.seg button:hover { color: var(--foreground); }
.seg button[aria-checked="true"] { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

/* خيار طريقة حساب التمدد: زرّان بسطرين */
.calc-row {
  display: grid; grid-template-columns: minmax(0, 28rem) minmax(0, 1fr); gap: 1rem 1.5rem; align-items: end;
  padding-top: 1.1rem; border-top: 1px solid var(--border);
}
.seg-2l button { display: grid; gap: .1rem; justify-items: center; align-content: center; min-height: 3.4rem; padding-block: .5rem; white-space: normal; line-height: 1.35; }
.seg-2l button b { font-size: .85rem; font-weight: 900; }
.seg-2l button small { font-size: .7rem; font-weight: 500; color: var(--muted-foreground); }
.seg-2l button[aria-checked="true"] small { color: var(--foreground); }
.calc-note { font-size: .78rem; font-weight: 500; color: var(--muted-foreground); max-width: 62ch; }
@media (max-width: 860px) { .calc-row { grid-template-columns: minmax(0, 1fr); } }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  --c: var(--muted-foreground);
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.5rem; padding-inline: 1rem;
  border: 1px solid var(--input); border-radius: .85rem; background: var(--card); font-weight: 700; font-size: .85rem;
  transition: all .15s;
}
.chip i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--c); }
.chip:hover { background: var(--accent); }
/* المحدد: تعبئة لونية كاملة. غير المحدد: حواف فقط */
.chip[aria-checked="true"] { background: var(--c); border-color: var(--c); color: var(--on-fill); }
.chip[aria-checked="true"] i { background: var(--on-fill); }
.chip[data-value="all"][aria-checked="true"] { --c: var(--primary); }
.t-contraction { --c: var(--tn-contraction); }
.t-squeeze { --c: var(--tn-squeeze); }
.t-expansion { --c: var(--tn-expansion); }
.t-direct { --c: var(--entry); }
.t-cross { --c: var(--tn-expansion); }

.search-box { position: relative; }
.search-box svg { position: absolute; inset-inline-start: .9rem; top: 50%; width: 1.05rem; height: 1.05rem; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.search-box input {
  width: 100%; height: 2.75rem; padding-inline: 2.7rem .9rem; border: 1px solid var(--input); border-radius: .85rem;
  background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / .04); outline: none; font-size: .9rem;
}
.search-box input::placeholder { color: color-mix(in srgb, var(--muted-foreground) 75%, transparent); }
.search-box input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
.search-box input::-webkit-search-cancel-button { display: none; }

/* ───────── نظرة سريعة (أعمدة) ───────── */
.overview { padding: 1.4rem; }
.ov-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.ov h2 { font-size: .9rem; font-weight: 900; margin-bottom: .8rem; }
.bars { display: grid; gap: .45rem; }
.bar-row {
  --c: var(--brand-secondary);
  display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) 2.2rem; align-items: center; gap: .6rem;
  min-height: 2.25rem; padding: .15rem .35rem; border: 0; border-radius: .75rem; background: transparent; text-align: start;
  transition: background .15s;
}
button.bar-row:hover { background: var(--accent); }
.bar-row[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--c); }
.bar-label { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.bar-track { height: .7rem; border-radius: 99px; background: var(--muted); overflow: hidden; direction: rtl; }
.bar-fill { display: block; height: 100%; min-width: 0; border-radius: 99px; background: var(--c); transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.bar-count { font-size: .85rem; font-weight: 900; text-align: end; }
.bar-row.t-contraction { --c: var(--tn-contraction); }
.bar-row.t-squeeze { --c: var(--tn-squeeze); }
.bar-row.t-expansion { --c: var(--tn-expansion); }
.bar-row.market-sa { --c: var(--brand-secondary); }
.bar-row.market-us { --c: var(--info); }
.bar-row.market-nyse { --c: var(--nyse); }
.bar-row.kind-direct { --c: var(--entry); }
.bar-row.kind-cross { --c: var(--tn-expansion); }
.bar-row.age { --c: var(--tn-contraction); }

/* ───────── النتائج ───────── */
.results { padding: 1.4rem 1.4rem .6rem; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.results-head h2 { font-size: 1.1rem; font-weight: 900; letter-spacing: -.01em; }
.results-head p { font-size: .78rem; font-weight: 500; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
thead th {
  height: 2.75rem; padding-inline: .6rem; text-align: start; white-space: nowrap; font-size: .74rem; font-weight: 900;
  background: var(--muted); color: var(--muted-foreground);
}
thead th:first-child { border-start-start-radius: .85rem; border-end-start-radius: .85rem; }
thead th:last-child { border-start-end-radius: .85rem; border-end-end-radius: .85rem; }
tbody td { padding: .75rem .6rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
tbody tr.sig-row { transition: background .15s; }
tbody tr.sig-row:hover { background: var(--accent); }
tbody tr:last-child td { border-bottom: 0; }
.num-col, td.num-col { text-align: end; }
tr.detail-row td { padding: 0 .4rem 1rem; background: var(--background); }

.stock { display: grid; justify-items: start; gap: .1rem; min-width: 6.5rem; }
.stock-symbol { font-weight: 900; font-size: .95rem; letter-spacing: .01em; }
.stock-name { font-size: .76rem; font-weight: 500; color: var(--muted-foreground); max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* السوق: تعبئة لونية كاملة. الفريم: حواف فقط. بدون خلفيات مخففة */
.pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border: 1px solid transparent; border-radius: .6rem;
  font-size: .72rem; font-weight: 900; line-height: 1.2; white-space: nowrap; background: var(--muted); color: var(--foreground);
}
.pill.tf { background: transparent; border-color: var(--input); color: var(--foreground); }
.pill.market-sa { background: var(--brand-secondary); color: var(--on-fill); }
.pill.market-us { background: var(--info); color: var(--on-fill); }
.pill.market-nyse { background: var(--nyse); color: var(--on-fill); }

.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.tn {
  --c: var(--tn-contraction);
  display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border-radius: .6rem;
  font-size: .74rem; font-weight: 900; line-height: 1.2; white-space: nowrap;
  background: var(--c); color: var(--on-fill);
}
.tn.t-contraction { --c: var(--tn-contraction); }
.tn.t-squeeze { --c: var(--tn-squeeze); }
.tn.t-expansion { --c: var(--tn-expansion); }

.when { display: grid; gap: .1rem; }
.when-main { font-weight: 700; white-space: nowrap; }
.when-sub { font-size: .72rem; font-weight: 500; color: var(--muted-foreground); white-space: nowrap; }
.when-sub.fresh { color: color-mix(in srgb, var(--tn-contraction) 85%, var(--foreground)); font-weight: 700; }

.price { font-weight: 900; font-size: .95rem; }
.range { display: grid; gap: .15rem; justify-items: end; font-size: .8rem; font-weight: 700; }
.range span { display: inline-flex; gap: .4rem; align-items: baseline; }
.range small { font-weight: 500; color: var(--muted-foreground); font-size: .68rem; }
.range .hi { color: color-mix(in srgb, var(--up) 85%, var(--foreground)); }
.range .lo { color: color-mix(in srgb, var(--down) 85%, var(--foreground)); }
.pos { font-size: .68rem; font-weight: 700; color: var(--muted-foreground); text-align: end; }

.spark-btn {
  display: inline-grid; place-items: center; gap: .1rem; padding: .35rem .5rem; border: 1px solid transparent; border-radius: .85rem;
  background: transparent; transition: background .15s, border-color .15s;
}
.spark-btn:hover { background: var(--accent); }
.spark-btn[aria-expanded="true"] { border-color: var(--tn-contraction); }
.spark { width: 5.2rem; height: 1.8rem; display: block; }
.spark path { fill: none; stroke: var(--muted-foreground); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--tn-contraction); }
.spark-cap { font-size: .66rem; font-weight: 700; color: var(--muted-foreground); }

.tv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.25rem; padding-inline: .8rem;
  border-radius: .85rem; text-decoration: none; white-space: nowrap; font-weight: 700; font-size: .78rem;
  background: var(--primary); color: var(--primary-foreground);
  transition: filter .15s, transform .15s;
}
.tv-btn:hover { filter: brightness(1.15); }
.tv-btn:active { transform: scale(.98); }
.tv-btn svg { width: .95rem; height: .95rem; }

/* بطاقات الجوال والتابلت */
.cards { display: none; gap: .75rem; padding-bottom: .8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.sig-card {
  display: grid; gap: .8rem; padding: 1rem; border-radius: 1.5rem; align-content: start;
  border: 1px solid var(--border); background: var(--background);
}
.sig-card.open { grid-column: 1 / -1; }
.sig-card .detail-head { display: none; }
.sig-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.sig-card-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.sig-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: start; }
.sig-card-grid .lbl { font-size: .68rem; font-weight: 700; color: var(--muted-foreground); margin-bottom: .15rem; }
.sig-card-actions { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: stretch; }
.sig-card-actions .tv-btn { min-height: 2.75rem; }
.chart-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding-inline: .9rem;
  border: 1px solid var(--input); border-radius: .85rem; background: transparent;
  font-weight: 700; font-size: .8rem; white-space: nowrap; color: var(--foreground);
}
.chart-toggle[aria-expanded="true"] { background: var(--tn-contraction); border-color: var(--tn-contraction); color: var(--on-fill); }
.chart-toggle[aria-expanded="true"] .spark path { stroke: var(--on-fill); }
.chart-toggle[aria-expanded="true"] .spark circle { fill: var(--on-fill); }
.chart-toggle .spark { width: 3.4rem; height: 1.4rem; }

/* ───────── الشارت التفصيلي ───────── */
.detail { display: grid; gap: .7rem; padding: .6rem .2rem .2rem; }
.detail-head { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .78rem; font-weight: 700; color: var(--muted-foreground); }
.detail-head b { color: var(--foreground); font-weight: 900; }
.chart-box { position: relative; direction: ltr; touch-action: pan-y; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.cc-grid { stroke: var(--border); stroke-width: 1; }
.cc-text { fill: var(--muted-foreground); font-size: 11px; font-weight: 500; font-family: inherit; }
.cc-mark { fill: var(--tn-contraction); }
.cc-band { fill: var(--muted); }
.cc-up { fill: var(--up); stroke: var(--up); }
.cc-down { fill: var(--down); stroke: var(--down); }
.cc-sig { fill: var(--tn-contraction); stroke: var(--tn-contraction); }
.cc-line { stroke: var(--tn-contraction); stroke-width: 1.6; }
.cc-tag { fill: var(--tn-contraction); }
.cc-tag-text { fill: var(--on-fill); font-size: 10.5px; font-weight: 700; font-family: inherit; }
.cc-bbw { fill: none; stroke: var(--brand-secondary); stroke-width: 1.6; stroke-linejoin: round; }
.cc-xh { stroke: var(--muted-foreground); stroke-width: 1; stroke-dasharray: 3 3; }
.cc-dot-1 { fill: var(--tn-squeeze); }
.cc-dot-2 { fill: var(--tn-expansion); }
.cc-dot-4 { fill: var(--tn-contraction); }
.tip {
  position: absolute; top: 4px; inset-inline-start: 6px; z-index: 2; pointer-events: none; direction: rtl;
  padding: .45rem .65rem; border-radius: .75rem; font-size: .72rem; font-weight: 700; line-height: 1.5;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-soft);
}
.tip .t-date { color: var(--muted-foreground); font-weight: 500; }
.tip .t-grid { display: flex; flex-wrap: wrap; gap: 0 .8rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .72rem; font-weight: 700; color: var(--muted-foreground); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: .6rem; height: .6rem; border-radius: 3px; background: var(--c, var(--muted-foreground)); }
.legend i.line { height: 2px; width: 1rem; border-radius: 2px; }

.empty { display: grid; justify-items: center; gap: .35rem; padding: 2.5rem 1rem 3rem; text-align: center; }
.empty-title { font-size: 1.05rem; font-weight: 900; }
.empty .muted { font-size: .85rem; max-width: 34ch; }
[hidden] { display: none !important; }

.notes { display: grid; gap: .45rem; padding-inline: .5rem; font-size: .76rem; font-weight: 500; color: var(--muted-foreground); }

/* ───────── ظهور تدريجي ───────── */
.stat, .card { animation: rise .5s cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .stat, .card, .sk { animation: none; }
  .stat:hover { transform: none; }
  .bar-fill { transition: none; }
}

/* ───────── الاستجابة ───────── */
@media (max-width: 1100px) {
  .table-wrap { display: none; }
  .cards { display: grid; }
}
@media (max-width: 1020px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid .field:last-child { grid-column: 1 / -1; }
  .ov-grid { grid-template-columns: 1fr 1fr; }
  .ov-grid .ov:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .wrap { width: calc(100% - 1.5rem); }
  main { padding-block: 1.1rem 2.5rem; gap: 1rem; }
  .topbar h1 { font-size: 1.15rem; }
  .stats { gap: .7rem; }
  .stat { padding: 1.05rem; border-radius: 1.5rem; }
  .stat-icon { width: 2.6rem; height: 2.6rem; margin-bottom: .7rem; }
  .stat-value { font-size: 1.7rem; }
  .stat-value-sm { font-size: .95rem; }
  .card { border-radius: 1.5rem; }
  .filters, .overview { padding: 1.1rem; }
  /* مساحة أوسع للبطاقات والشارت داخل النتائج */
  .results { padding: .9rem .6rem .4rem; }
  .results-head { padding-inline: .4rem; }
  .sig-card { padding: .85rem; }
  .detail { padding-inline: 0; }
  .filter-grid { grid-template-columns: 1fr; }
  .ov-grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .seg button, .chip { min-height: 2.75rem; }
  .field.search { max-width: none; flex-basis: 100%; }
  .search-box input { height: 3rem; font-size: 16px; } /* يمنع تكبير الصفحة تلقائياً في آيفون */
  .bar-row { grid-template-columns: 4.6rem minmax(0, 1fr) 2rem; min-height: 2.6rem; }
  .sig-card-grid { grid-template-columns: 1fr 1fr; }
  .tip { font-size: .7rem; }
}
@media (max-width: 400px) {
  .chart-toggle .spark { display: none; }
  .stat-hint { font-size: .68rem; }
  .seg button { font-size: .8rem; padding-inline: .3rem; }
}

/* ───────── رأس الصفحة: الأزرار ───────── */
.topbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ───────── اختيار السكربت ───────── */
.script-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.script-tabs button {
  display: grid; gap: .1rem; justify-items: start; text-align: start; min-height: 3.6rem; padding: .6rem 1.1rem;
  border: 1px solid var(--input); border-radius: 1.25rem; background: var(--card); color: var(--foreground);
  transition: background .15s, color .15s, border-color .15s;
}
.script-tabs button b { font-size: .98rem; font-weight: 900; }
.script-tabs button small { font-size: .72rem; font-weight: 500; color: var(--muted-foreground); }
.script-tabs button:hover { background: var(--accent); }
.script-tabs button[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.script-tabs button[aria-selected="true"] small { color: var(--primary-foreground); opacity: .85; }

/* ───────── فلتر السوق بخمسة خيارات ───────── */
.seg-market button { font-size: .85rem; padding-inline: .3rem; }

/* ───────── شاشة القفل ───────── */
.gate { display: grid; place-items: center; min-height: calc(100vh - 5rem); min-height: calc(100dvh - 5rem); padding: 1.5rem 1rem; }
.gate-card {
  width: min(26rem, 100%); display: grid; gap: .8rem; padding: 1.75rem;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 2rem; box-shadow: var(--shadow-lift);
}
.gate-card h2 { font-size: 1.35rem; font-weight: 900; letter-spacing: -.01em; }
.gate-lead { color: var(--muted-foreground); font-size: .9rem; font-weight: 500; margin-bottom: .3rem; }
.gate-input { position: relative; }
/* النص يبدأ من اليسار (الرمز لاتيني)، فالزر على اليمين الفعلي علشان ما يغطّي اللي تكتبه */
.gate-input input {
  width: 100%; height: 3.5rem; padding: 0 5.4rem 0 1rem; border: 2px solid var(--input); border-radius: 1rem;
  background: var(--background); color: var(--foreground); outline: none;
  font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; direction: ltr; text-align: left;
}
.gate-input input::placeholder { color: var(--muted-foreground); font-weight: 500; letter-spacing: 0; opacity: 1; }
.gate-input input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
.gate-eye {
  position: absolute; right: .5rem; left: auto; top: 50%; transform: translateY(-50%); min-height: 2.5rem; padding-inline: .9rem;
  border: 0; border-radius: .75rem; background: var(--muted); color: var(--foreground); font-size: .8rem; font-weight: 700;
}
.gate-error { padding: .65rem .9rem; border: 2px solid var(--down); border-radius: .95rem; font-size: .85rem; font-weight: 700; }
.gate-submit {
  min-height: 3.1rem; border: 0; border-radius: .95rem; background: var(--primary); color: var(--primary-foreground);
  font-size: 1rem; font-weight: 900; transition: filter .15s, transform .15s;
}
.gate-submit:hover { filter: brightness(1.12); }
.gate-submit:active { transform: scale(.98); }
.gate-submit:disabled { opacity: .6; cursor: progress; }

/* ───────── السكربت الثاني: منطقة الدخول ───────── */
.lvl { display: grid; gap: .1rem; justify-items: end; font-size: .8rem; font-weight: 700; }
.lvl span { display: inline-flex; gap: .4rem; align-items: baseline; }
.lvl small { font-weight: 500; color: var(--muted-foreground); font-size: .66rem; }
.lvl .stop { color: color-mix(in srgb, var(--down) 85%, var(--foreground)); }
.lvl .tgt { color: color-mix(in srgb, var(--target) 90%, var(--foreground)); }
.lvl .zone { color: color-mix(in srgb, var(--entry) 85%, var(--foreground)); }
.status {
  display: inline-flex; padding: .2rem .5rem; border-radius: .5rem; font-size: .66rem; font-weight: 900; line-height: 1.2;
  background: var(--entry); color: var(--on-fill);
}
.status.hit { background: var(--up); }
.status.stopped { background: var(--down); }
.tn.kind-direct { --c: var(--entry); }
.tn.kind-cross { --c: var(--tn-expansion); }

.cc-zone { fill: none; stroke: var(--entry); stroke-width: 1.6; }
.cc-stop { stroke: var(--down); stroke-width: 1.5; }
.cc-target { stroke: var(--target); stroke-width: 1.5; }
.cc-ma { fill: none; stroke: var(--brand-secondary); stroke-width: 1.6; stroke-linejoin: round; }
.cc-tag-entry { fill: var(--entry); }
.cc-tag-stop { fill: var(--down); }
.cc-tag-target { fill: var(--target); }
.cc-hist-up { fill: var(--up); }
.cc-hist-down { fill: var(--down); }
.cc-macd { fill: none; stroke: var(--brand-secondary); stroke-width: 1.5; }
.cc-msig { fill: none; stroke: var(--tn-expansion); stroke-width: 1.5; }

@media (max-width: 640px) {
  .script-tabs { grid-template-columns: 1fr; }
  .seg-market button { font-size: .78rem; }
  .gate-card { padding: 1.4rem; border-radius: 1.5rem; }
  .gate-input input { font-size: 17px; } /* 16 فأكثر يمنع تكبير الصفحة تلقائياً في آيفون */
}
@media (max-width: 380px) {
  .seg-market button { font-size: .72rem; }
}
