/* ============================================================
   أداتك — نظام التصميم v3 (إعادة هيكلة حقيقية)
   ثيمان كاملان بمفتاح تبديل:
   · ليلي (الافتراضي) — على مرجعية لوحة البنك العربية: أسود دافي
     شبه مطفي + لون تمييز واحد دافي + أرقام ضخمة.
   · نهاري — على مرجعية محفظة الأعمال: أبيض مائل للافندر هادئ +
     لون بنفسجي واحد + جداول واضحة.
   إعادة الهيكلة: عناصر أقل في الشاشة، هرمية واضحة، مساحات بيضاء
   أكبر، إخفاء تدريجي بـ<details>، إجراء أساسي واحد لكل شاشة.
   كل السيلكتورز القديمة محفوظة — لا تغيير في الوظائف.
   ============================================================ */

:root {
  /* ===== الثيم الليلي (الافتراضي) — مرجعية البانكينج الداكن ===== */
  --bg: #12100c;           /* أسود دافي مطفي */
  --surface: #1c1913;
  --surface-2: #25211a;
  --ink: #f4f0e6;
  --ink-2: #bdb4a2;
  --ink-3: #8d8472;
  --line: #322c21;
  --line-strong: #463e2e;

  /* لون تمييز واحد دافي (كهرماني) */
  --accent: #e8933d;
  --accent-strong: #f2a95c;
  --accent-soft: #3a2a12;
  --on-accent: #211503;
  --amber: #e0a04a;
  --amber-soft: #3a2a10;
  --red: #e5675a;
  --red-soft: #3c1b17;
  --green: #58bd84;
  --green-soft: #142e20;

  /* الريل الجانبي — أغمق من الخلفية */
  --rail: #0d0b08;
  --rail-2: #191510;
  --rail-ink: #f4f0e6;
  --rail-muted: #9d9481;
  --rail-line: #272219;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 10px 28px rgba(0, 0, 0, .5);

  --sidebar-w: 268px;
  --font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-display: var(--font);
}

/* ===== الثيم النهاري — مرجعية المحفظة الافندرية ===== */
[data-theme="light"] {
  --bg: #f3f2f8;
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --ink: #1e1930;
  --ink-2: #57506e;
  --ink-3: #8b85a0;
  --line: #e4e1ee;
  --line-strong: #cfcadb;

  --accent: #6a4fd0;
  --accent-strong: #573dbf;
  --accent-soft: #eae5fa;
  --on-accent: #ffffff;
  --amber: #8a4b08;
  --amber-soft: #faf0dc;
  --red: #b42318;
  --red-soft: #fcebe8;
  --green: #1a6b3c;
  --green-soft: #e5f3ea;

  --rail: #fbfaff;
  --rail-2: #efecf9;
  --rail-ink: #1e1930;
  --rail-muted: #6b6484;
  --rail-line: #e4e1ee;

  --shadow-1: 0 1px 2px rgba(30, 25, 48, .05);
  --shadow-2: 0 10px 28px rgba(30, 25, 48, .14);
}

/* توافق قديم */
:root {
  --card: var(--surface);
  --hairline: var(--line);
  --teal: var(--accent);
  --teal-soft: var(--accent-soft);
  --ink2: var(--ink-2);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0;          /* التباعد بين الحروف بيكسر اتصال الحروف العربية — بند 134 */
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

b, strong { font-weight: 700; }
a { color: var(--accent); }

/* تركيز الكيبورد ظاهر دايمًا — بند 317 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* رابط تخطَّ إلى المحتوى (إتاحة) */
.skip-link {
  position: absolute; top: -48px; inset-inline-start: 12px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  text-decoration: none; font-weight: 600; transition: top .15s ease;
}
.skip-link:focus { top: 10px; color: var(--bg); }

#shell { display: flex; min-height: 100vh; }
#content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ============ الشريط الجانبي ============ */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--rail);
  color: var(--rail-ink);
  border-inline-end: 1px solid var(--rail-line);
  padding: 26px 14px 18px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding-inline: 8px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 800; font-size: 17px; line-height: 1.35; color: var(--rail-ink); }
.brand-sub { color: var(--rail-muted); font-size: 11.5px; line-height: 1.5; }

#nav { display: flex; flex-direction: column; gap: 3px; }
#nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 46px; padding: 10px 12px;
  border-radius: var(--radius-s);
  color: var(--rail-muted); text-decoration: none;
  font-weight: 500; font-size: 14.5px;
  transition: background .12s ease, color .12s ease;
}
#nav a:hover { background: var(--rail-2); color: var(--rail-ink); }
#nav a.active {
  background: var(--rail-2); color: var(--rail-ink); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);   /* مؤشر الجانب (بداية السطر في RTL) */
}
#nav a .soon {
  font-size: 11px; background: transparent; color: var(--rail-muted);
  border: 1px solid var(--rail-line); border-radius: 999px; padding: 1px 8px; font-weight: 400;
}
.sidebar-foot {
  margin-top: auto; color: var(--rail-muted); font-size: 11.5px; padding-inline: 8px;
  border-top: 1px solid var(--rail-line); padding-top: 12px;
}

/* ستارة الموبايل خلف القائمة */
#scrim {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
#scrim.show { opacity: 1; pointer-events: auto; }

/* شريط علوي للموبايل */
#topbar { display: none; }

/* ============ المحتوى — مساحة أكبر، تنفّس ============ */
#main {
  flex: 1; width: 100%;
  max-width: 880px; margin: 0 auto;   /* أضيق من قبل — تركيز عمود واحد */
  padding: 40px 28px 80px;
}
.page-title {
  font-size: 26px; font-weight: 800; line-height: 1.4;
  margin: 0 0 8px; text-wrap: balance;
}
.page-sub { color: var(--ink-2); margin: 0 0 28px; font-size: 14.5px; max-width: 70ch; }

/* ============ الكروت — مسطحة، حدود شعرية، مساحة داخلية كريمة ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 26px;
  margin-bottom: 22px;
}
.card > :last-child { margin-bottom: 0; }
.card h2 {
  font-size: 17px; font-weight: 800; line-height: 1.5;
  margin: 0 0 16px; text-wrap: balance;
}
/* ماركر مربع صغير من لون التمييز */
.card h2::before {
  content: ""; display: inline-block;
  width: 7px; height: 7px; border-radius: 2px;
  background: var(--accent);
  margin-inline-end: 9px; vertical-align: 0.08em;
}
.card h2.h2-toggle { display: flex; align-items: center; gap: 10px; }
.card h2.h2-toggle .btn { flex-shrink: 1; min-width: 0; font-size: 12px; padding: 4px 10px; min-height: 0; margin-inline-start: auto; white-space: normal; text-align: start; line-height: 1.5; }
.card h3 { font-size: 15px; font-weight: 700; margin: 20px 0 10px; }
.muted { color: var(--ink-2); font-size: 13px; }

/* ============ طيّ تدريجي (إخفاء المعلومات الثانوية) ============ */
details.fold {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  margin-bottom: 22px;
  overflow: hidden;
}
details.fold > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 22px;
  font-weight: 700; font-size: 15px; color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after {
  content: ""; width: 9px; height: 9px; flex-shrink: 0;
  border-inline-end: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg); margin-inline-start: 4px;
  transition: transform .15s ease;
}
details.fold[open] > summary::after { transform: rotate(225deg); }
details.fold > summary:hover { background: var(--surface-2); }
details.fold > summary .fold-hint { color: var(--ink-3); font-size: 12.5px; font-weight: 400; }
details.fold .fold-body { padding: 0 22px 22px; }
details.fold .fold-body > :first-child { margin-top: 0; }
/* طيّ جوه كارت (بدون إطار خاص) */
details.fold-inner { margin: 14px 0; }
details.fold-inner > summary {
  list-style: none; cursor: pointer; color: var(--accent); font-weight: 700; font-size: 14px;
  padding: 6px 0; -webkit-tap-highlight-color: transparent;
}
details.fold-inner > summary::-webkit-details-marker { display: none; }
details.fold-inner > summary::before { content: "＋ "; font-weight: 800; }
details.fold-inner[open] > summary::before { content: "－ "; }

/* ============ الإحصائيات ============ */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.stat .n { font-size: 30px; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat .l, .stat .lbl { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; line-height: 1.55; }

/* ============ الأزرار ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease, transform .05s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 800; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger:hover, .danger-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
/* حالة تحميل على الزر — بند 145 */
.btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading::after {
  content: ""; width: 15px; height: 15px; flex-shrink: 0;
  border: 2px solid currentColor; border-inline-start-color: transparent;
  border-radius: 50%; animation: adk-spin .7s linear infinite;
}
@keyframes adk-spin { to { transform: rotate(360deg); } }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
/* مفاتيح الاختيار بين وضعين (طريقة الربح): زرارين متساويين جنب بعض على كل المقاسات */
.btn-row:has(> .btn[data-mode]) { flex-wrap: nowrap; gap: 8px; margin-top: 2px; align-items: stretch; }
.btn-row:has(> .btn[data-mode]) .btn[data-mode] {
  flex: 1 1 0; min-width: 0; justify-content: center; text-align: center;
  white-space: normal; line-height: 1.45; padding: 9px 8px;
}
@media (max-width: 620px) {
  .btn-row { margin-top: 22px; margin-bottom: 6px; }
  .btn-row .btn.primary { width: 100%; }
}

/* ============ الفورمات ============ */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.grid2 .field { margin-bottom: 0; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field input[type=text], .field input[type=number], .field input[type=url],
.field input[type=password], .field select, .field textarea {
  width: 100%; min-height: 48px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 11px 14px;
  font-family: inherit; font-size: 16px;   /* أقل من 16px بيعمل zoom في iOS */
  background: var(--surface-2); color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
/* خطأ تحت كل خانة مع طريقة الحل — بند 313 */
.field .hint { color: var(--ink-3); font-size: 12.5px; }
.field .err { display: none; color: var(--red); font-size: 13px; font-weight: 500; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.field.invalid .err { display: block; }

.slider-row { margin: 16px 0; }
.slider-row .slider-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.slider-row label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.slider-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }

/* ============ بلوك النتيجة الرئيسي ============ */
.hero {
  border-radius: var(--radius-l); border: 1px solid var(--line);
  padding: 24px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  background: var(--surface);
}
.hero .lbl { color: var(--ink-2); font-size: 13.5px; }
.hero .num {
  font-size: 48px; font-weight: 800; line-height: 1.15;
  direction: ltr; font-variant-numeric: tabular-nums;
}
.hero.win { background: var(--green-soft); border-color: transparent; }
.hero.weak { background: var(--amber-soft); border-color: transparent; }
.hero.loss { background: var(--red-soft); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
}
.chip.win { background: var(--green-soft); color: var(--green); }
.chip.weak { background: var(--amber-soft); color: var(--amber); }
.chip.loss { background: var(--red-soft); color: var(--red); }

/* ============ الحقائق (مفتاح/قيمة) ============ */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 620px) { .facts { grid-template-columns: 1fr; } }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fact .fl { color: var(--ink-2); font-size: 13.5px; }
.fact .fv { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ============ التنبيهات ============ */
.callout { border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; font-size: 14px; border: 1px solid transparent; }
.callout .t { font-weight: 700; margin-bottom: 4px; }
.callout.warn { background: var(--amber-soft); border-color: transparent; }
.callout.danger { background: var(--red-soft); border-color: transparent; }
.callout.note { background: var(--accent-soft); border-color: transparent; }

/* ============ خطة مرقمة ============ */
ol.plan { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; }
ol.plan li { padding-inline-start: 4px; }
ol.plan li::marker { font-weight: 700; color: var(--accent); }

/* ============ الحالة الفاضية ============ */
.placeholder {
  text-align: center; padding: 48px 20px;
  color: var(--ink-2); font-size: 14.5px; max-width: 60ch; margin: 0 auto;
}
.placeholder .big {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 14px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

/* ============ سكيلتون التحميل — بند 112 ============ */
.skel { position: relative; overflow: hidden; background: var(--line); border-radius: 8px; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .12), transparent);
  transform: translateX(-100%);
  animation: adk-skel 1.2s infinite;
}
@keyframes adk-skel { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 10px 0; }
.skel-line.w60 { width: 60%; }
.skel-line.w80 { width: 80%; }

/* ============ الموبايل ============ */
#menuBtn {
  display: none;
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--rail-line); background: transparent;
  font-size: 19px; cursor: pointer; color: var(--rail-ink);
  align-items: center; justify-content: center;
}
@media (max-width: 860px) {
  #topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 40;
    height: 56px; padding: 0 14px;
    background: color-mix(in srgb, var(--rail) 94%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rail-line);
    color: var(--rail-ink);
  }
  #topbar .topbar-brand { font-weight: 800; font-size: 16px; color: var(--rail-ink); }
  #menuBtn { display: inline-flex; flex-shrink: 0; }
  html, body { overflow-x: clip; }
  #sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 50; height: 100vh;
    transform: translateX(105%); transition: transform .2s ease;
    box-shadow: var(--shadow-2);
  }
  #sidebar.open { transform: translateX(0) !important; }
  #main { padding: 24px 16px 60px; }
  .page-title { font-size: 22px; }
  .page-sub { font-size: 14px; margin-bottom: 22px; }
  .card { padding: 18px; border-radius: var(--radius); }
  .hero .num { font-size: 38px; }
  details.fold > summary { padding: 16px 18px; }
  details.fold .fold-body { padding: 0 18px 18px; }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr 1fr; }
}
/* موبايل: لو عدد البلاطات فردي، الأخيرة تاخد العرض كله بدل خانة فاضية جنبها */
@media (max-width: 620px) {
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ============ منتجاتي ============ */
.product-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.product-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.product-thumb.empty, .product-head-img.empty {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 22px;
}
.product-info { flex: 1; min-width: 180px; }
.product-name { font-weight: 700; }
.product-head { display: flex; gap: 16px; align-items: center; }
.product-head-img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab {
  min-height: 40px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px;
  padding: 7px 16px; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--ink-2);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.file-btn { width: fit-content; cursor: pointer; }

/* ============ التحليل ============ */
.check-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.check-row:last-of-type { border-bottom: none; }
.check-mark {
  width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.check-mark.ok { background: var(--green-soft); color: var(--green); }
.check-mark.no { background: var(--red-soft); color: var(--red); }
.check-mark.ask { background: var(--amber-soft); color: var(--amber); }
.check-src {
  margin-inline-start: auto; font-size: 11px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.idea-row { padding: 12px 0; border-bottom: 1px solid var(--line); }

/* ============ المولدات ============ */
.version-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; background: var(--surface-2); }
.version-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.version-text { white-space: normal; line-height: 1.9; }

/* ============ المصمّم ============ */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.design-item img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.design-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; font-size: 13px; font-weight: 600; }
.swatch { width: 34px; height: 34px; border-radius: 999px; border: 2px solid transparent; cursor: pointer; }
.swatch.selected { border-color: var(--accent); }

/* ============ مزودو الـAI في الإعدادات ============ */
.provider-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.provider-block.provider-off { opacity: .75; background: var(--surface-2); }
.provider-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

/* ============ الجداول ============ */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 12px; background: var(--surface);
}
.t-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
.t-table th, .t-table td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); }
.t-table th {
  font-weight: 600; font-size: 12.5px; color: var(--ink-2);
  background: var(--surface-2); white-space: nowrap;
}
.t-table td { font-variant-numeric: tabular-nums; }
.t-table tbody tr:last-child td { border-bottom: none; }
.t-table tbody tr:hover { background: var(--surface-2); }
/* الجداول الصغيرة (قمع الشغل) من غير سكرول */
.table-wrap.plain { border: none; margin-top: 0; background: transparent; }
.table-wrap.plain .t-table { min-width: 0; }

/* ============ المنهجية والتقييم ============ */
.score-btn { white-space: normal; font-size: 13px; line-height: 1.5; }
/* كرت القرار: بيتحرك مع الصفحة عادي — ممنوع sticky/fixed على أي مقاس (طلب المستخدم) */
#sc-resultCard { scroll-margin-bottom: 12px; }
datalist { display: none; }

/* ===== شبكات البطاقات + فلاتر حديثة ===== */
/* شبكة بطاقات متجاوبة — عمودين على الموبايل وأكثر على الشاشات الكبيرة */
.cards-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.cards-grid > .card { margin: 0 !important; padding: 14px; }
/* الصفوف جوه الشبكة بتبقى بطاقة رأسية */
.cards-grid .product-row { flex-direction: column; align-items: stretch; border: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); gap: 8px; }
.cards-grid .product-thumb { width: 100%; height: 110px; }
.cards-grid .product-info { flex: none; min-width: 0; }
@media (min-width: 900px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
}

/* زرار مقسّم (segmented) — للفلاتر القصيرة */
.seg { display: flex; flex-wrap: nowrap; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-btn { flex: 1 1 0; min-width: 0; border: 0; background: transparent; border-radius: 8px; padding: 7px 8px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; text-align: center; }
.seg-btn.active { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.seg-btn:not(.active):hover { background: rgba(127, 117, 96, .18); }

/* سهم مخصص لكل قوائم الاختيار بدل شكل المتصفح */
.field select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238d8472' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-inline-end: 34px;
  padding-inline-start: 12px;
}

/* صف الترجمة: الزرار ميتداسش على الموبايل */
.tr-row { display: flex; gap: 8px; }
.tr-row input { flex: 1; min-width: 0; }
.tr-row .btn { flex-shrink: 0; white-space: nowrap; }

/* شريط «تحديث جديد» — يظهر لما ينزل بناء جديد والتاب على القديم */
#updateBar {
  position: fixed; bottom: 14px; inset-inline: 14px; z-index: 998;
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px;
  padding: 13px 16px; font: inherit; font-weight: 700; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35); cursor: pointer;
}

/* شبكة أزرار متساوية العرض والارتفاع (صفحة ابحث عن منتج) */
.btn-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.btn-grid .btn { width: 100%; height: 100%; justify-content: center; text-align: center; white-space: normal; line-height: 1.45; }

/* وسم «من الصفحة» تحت الخانات اللي اتملت تلقائي من اللينك */
.src-tag{font-size:11px;color:var(--muted,#777);margin-top:3px;min-height:0}

/* موبايل: كل الجداول بتتحول لبطاقات مكدّسة — ممنوع سكرول أفقي في أي صفحة */
@media (max-width: 640px) {
  .t-table { min-width: 0; }
  .t-table, .t-table tbody, .t-table tr, .t-table td, .t-table th { display: block; width: 100%; box-sizing: border-box; }
  .t-table thead { display: none; }
  .t-table tbody tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; background: var(--surface, #fff); }
  .t-table tbody tr:hover { background: var(--surface, #fff); }
  .t-table td { border-bottom: none !important; padding: 3px 0 !important; white-space: normal !important; overflow-wrap: anywhere; font-variant-numeric: normal; }
}

/* مفتاح النهاري/ليلي في القائمة الجانبية */
#themeToggle {
  width: calc(100% - 12px); margin: 0 6px;
  background: transparent; color: var(--rail-ink);
  border-color: var(--rail-line);
}
#themeToggle:hover { background: var(--rail-2); border-color: var(--accent); color: var(--accent); }
