:root {
  --gold: #d4af37;
  --gold-dark: #a17f12;
  --cream: #fffdf8;
  --panel: #ffffff;
  --line: #ece5d3;
  --ink: #2a2a2a;
  --muted: #7a7368;
  --tierA: #d4af37;
  --tierB: #3b82f6;
  --tierC: #9ca3af;
  --tierD: #c2b7a6;
  --danger: #c0392b;
  --ok: #1f8a4c;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
}

/* ── الشريط العلوي ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 20px; background: var(--panel);
  border-bottom: 2px solid var(--gold); box-shadow: var(--shadow);
  flex-wrap: wrap; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; }
.brand-logo { height: 54px; width: auto; display: block; }
.brand h1 { margin: 0; font-size: 20px; color: var(--gold-dark); }
.sub { margin: 0; font-size: 13px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-area { display: flex; align-items: center; gap: 8px; }

.badge {
  background: #faf7ef; border: 1px solid var(--line); border-radius: 20px;
  padding: 3px 12px; font-size: 12px; color: var(--muted);
}

/* ── الأزرار ── */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 14px;
  font-family: inherit; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn-ghost { background: transparent; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #3a2e00; font-weight: 700; }
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-buy { text-decoration: none; display: inline-block; }
.btn-admin { border-color: #d9c8f0; background: #f7f0ff; }
input[type="password"], input[type="text"], input[type="number"], select {
  font-family: inherit; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; color: var(--ink); background: #fff;
}
/* نصوص التلميح (placeholder) بلون واضح ومقروء بدل الرمادي الباهت الافتراضي */
input::placeholder, textarea::placeholder { color: #6f6653; opacity: 1; }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

/* إخفاء بصري مع إبقاء النص لقارئات الشاشة */
.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;
}

/* ── التنبيه المحلي ── */
/* حدّ منطقي لا فيزيائي: ينتقل تلقائياً لليسار في الوضع الإنجليزي */
.notice {
  background: #fdf6df; border-inline-start: 4px solid var(--gold);
  padding: 10px 18px; font-size: 14px; color: #6b5600;
}

/* ── التبويبات ── */
.tabs {
  display: flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.tab {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 15px; padding: 6px 12px; border-radius: 8px; color: var(--muted);
}
.tab.active { background: #faf7ef; color: var(--gold-dark); font-weight: 700; }
.legend { margin-inline-start: auto; display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* ── خيارات الترتيب ── */
.sort-box {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); margin-inline-start: 10px;
}
.sort-box select { font-size: 13px; padding: 5px 9px; cursor: pointer; }

/* ── مبدّل اللغة ── */
/* يعرض دائماً اسم اللغة التي سينتقل إليها، لا اللغة الحالية */
.lang-btn { font-weight: 700; color: var(--gold-dark); border-color: var(--gold); }
.lang-btn:hover { background: var(--gold); color: #3a2e00; }

/* ── تفضيل العملة ── */
.cur-select { font-size: 13px; padding: 5px 9px; cursor: pointer; }
/* تقدير الدولار ثانويٌّ بصرياً: أصغر وأخفت من الريال، فلا يُقرأ سعراً رسمياً */
.usd {
  font-size: .85em; font-weight: 400; color: var(--muted);
  margin-inline-start: 6px; white-space: nowrap; unicode-bidi: isolate;
}
.cur-note {
  margin: 10px 0 0; font-size: 12px; color: var(--muted);
  background: #faf7ef; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}

/* ── شريط المسؤول ── */
.admin-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #f7f0ff; border: 1px solid #e3d5f7; margin: 12px 20px;
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
}
.admin-msg { color: var(--muted); font-size: 13px; }
.inline { display: inline-flex; align-items: center; gap: 6px; }

/* ── قائمة العروض ── */
.deals { padding: 16px 20px; display: grid; gap: 16px; max-width: 1000px; margin: 0 auto; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.card.tier-A { border-inline-start: 5px solid var(--tierA); }
.card.tier-B { border-inline-start: 5px solid var(--tierB); }
.card.tier-C { border-inline-start: 5px solid var(--tierC); }
.card.tier-D { border-inline-start: 5px solid #d8cfbe; }
.card.oos { opacity: .72; }

.card-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: #fcfbf7; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.rank { font-weight: 800; color: var(--muted); font-size: 14px; }
.tier-chip { font-size: 13px; padding: 2px 10px; border-radius: 16px; background: #faf7ef; border: 1px solid var(--line); }
.score-chip { margin-inline-start: auto; font-size: 13px; color: var(--gold-dark); font-weight: 700; }
.sel { font-size: 13px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }

.card-body { display: flex; gap: 16px; padding: 16px; flex-wrap: wrap; }
.thumb { width: 120px; height: 120px; object-fit: contain; border-radius: 10px; background: #fafafa; border: 1px solid var(--line); }
.card-main { flex: 1; min-width: 260px; }
.title { margin: 0 0 8px; font-size: 16px; }
.eng-flag { font-size: 12px; color: var(--gold-dark); background: #fdf3d6; border-radius: 6px; padding: 1px 6px; margin-inline-start: 6px; }

.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font-size: 12px; background: #fdf3d6; border-radius: 6px; padding: 2px 9px; color: #6b5600; }
.chip.danger { background: #fbe6e3; color: var(--danger); }
.chip.stale { background: #eef2fb; color: #3a4a7a; }

.metrics { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; font-size: 14px; }
.metric b { color: var(--gold-dark); }
.metric.price b { font-size: 18px; }
.metric .strike { text-decoration: line-through; color: var(--muted); }
/* دعوة الاطّلاع على السعر حين يكون السعر بايتاً (امتثال: لا رقم قديم) */
.metric.price-stale { font-weight: 700; color: #3a4a7a; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── قائمة المشاركة ── */
.shareMenu {
  margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px;
  background: #faf7ef; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.share-opt {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.share-opt:hover { border-color: var(--gold); background: #fffdf8; }

/* ── جدول كل البيانات ── */
.allData { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.allData table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.allData th, .allData td { padding: 6px 10px; border-bottom: 1px solid #f2ecdf; text-align: start; vertical-align: top; }
.allData th { background: #faf7ef; white-space: nowrap; width: 40%; font-weight: 600; }
.allData td.em { font-weight: 700; }
.allData .fnote { color: var(--gold-dark); font-size: 12px; }
.breakdown { margin-top: 10px; font-size: 13px; color: var(--muted); }
.breakdown li { margin: 2px 0; }
.breakdown .neg { color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 40px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; border-top: 1px solid var(--line); margin-top: 20px; }

/* ── التنبيه المنبثق ── */
/* التوسيط بالإزاحة الفيزيائية مقصود: يبقى في المنتصف في الاتجاهين معاً،
   بخلاف inset-inline-start الذي كان ينزلق للحافة في الوضع الإنجليزي. */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2a2a2a; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; z-index: 50; box-shadow: var(--shadow);
}

/* ── محرّك البحث ── */
.search {
  position: relative; padding: 22px 20px 14px;
  background:
    linear-gradient(rgba(255,253,248,.88), rgba(255,253,248,.94)),
    url('/img/hero.png') center/cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.search > * { max-width: 1000px; margin-inline: auto; }
.search-modes { max-width: 1000px; margin-inline: auto; }
.search-modes { display: flex; gap: 8px; margin-bottom: 10px; }
.mode {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 16px; cursor: pointer; font-family: inherit; font-size: 14px; color: var(--muted);
}
.mode.active { background: var(--gold); border-color: var(--gold); color: #3a2e00; font-weight: 700; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-row #searchInput { flex: 1; min-width: 240px; font-size: 15px; padding: 10px 14px; }
.search-meta {
  margin-top: 10px; font-size: 14px; color: var(--muted);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.search-meta b { color: var(--gold-dark); }

/* ── المنتج المطلوب (بحث برابط) ── */
.original-wrap { max-width: 1000px; margin: 8px auto 0; padding: 0 20px; }
.original-head { font-weight: 800; color: var(--gold-dark); margin: 8px 0; }
.original-wrap .card { border-inline-start-width: 5px; box-shadow: 0 0 0 2px #f6e6b8, var(--shadow); }

/* ── شبكة المقارنة (نتائج البحث) ── */
.deals.compare {
  max-width: 1200px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  align-items: start;
}
.deals.compare .card-body { flex-direction: column; }
.deals.compare .card-main { min-width: 0; }

/* ── معرض الصور ── */
.gallery { display: flex; flex-direction: column; gap: 8px; }
.thumb.main { width: 140px; height: 140px; object-fit: contain; border-radius: 10px; background: #fafafa; border: 1px solid var(--line); }
.deals.compare .thumb.main { width: 100%; height: 200px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; max-width: 200px; }
.gthumb {
  width: 42px; height: 42px; object-fit: contain; border-radius: 6px;
  background: #fafafa; border: 1px solid var(--line); cursor: pointer; opacity: .7;
}
.gthumb:hover { opacity: 1; }
.gthumb.active { border-color: var(--gold); opacity: 1; box-shadow: 0 0 0 2px #f6e6b8; }

/* ── أوسمة المقارنة ── */
.chip.best { background: #e5f6ea; color: var(--ok); font-weight: 700; }
.chip.want { background: #eef2ff; color: #3b4fd8; font-weight: 700; }

/* ── صفحة الإعدادات ── */
.panel {
  max-width: 1000px; margin: 18px auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; color: var(--gold-dark); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.form-row input, .form-row select { flex: 1; min-width: 140px; }
.grid { border-collapse: collapse; width: 100%; font-size: 14px; margin-top: 8px; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; }
.grid th { background: #faf7ef; font-weight: 600; white-space: nowrap; }
.grid td a { color: var(--gold-dark); }
.grid-scroll { overflow-x: auto; }
.grid td.cell-time { white-space: nowrap; color: var(--muted); }
.grid td.cell-actions { white-space: nowrap; }
/* القصّ يجب أن يكون على عنصر داخلي بعرض صريح — max-width على td في جدول
   تلقائي التخطيط يتجاهله المتصفح. الاستعلام الكامل يبقى في تلميح td. */
.grid .clip { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* نص كامل يلتفّ على أسطر (للروابط الطويلة في «عمليات بحث فائتة»).
   unicode-bidi: plaintext ⇒ الكلمات العربية تبقى RTL والروابط اللاتينية تُعرض LTR من أوّلها. */
.grid .q-full { display: block; max-width: 460px; word-break: break-all; white-space: normal; unicode-bidi: plaintext; }

/* ── لوحة الإحصائيات ── */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.stat-card { background: #faf7ef; border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-total { font-size: 28px; font-weight: 800; color: var(--gold-dark); margin: 4px 0; }
.stat-today { font-size: 12px; color: var(--muted); }
.spark { margin-top: 18px; }
.spark-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.spark-bars { display: flex; align-items: flex-end; gap: 8px; height: 96px; }
.spark-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.spark-bar > div { width: 100%; max-width: 44px; background: var(--gold); border-radius: 6px 6px 0 0; min-height: 3px; }
.spark-bar > span { font-size: 11px; color: var(--muted); }

/* ── نافذة «كيف يعمل؟» ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,16,6,.55); }
.modal-box {
  position: relative; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 20px;
}
.modal-title { margin: 0 0 14px; font-size: 20px; color: var(--gold-dark); text-align: center; }
.modal-close {
  position: absolute; inset-inline-end: 12px; top: 12px; width: 34px; height: 34px;
  border: 1px solid var(--line); background: #fff; border-radius: 50%; cursor: pointer; font-size: 15px; color: var(--muted);
}
.modal-close:hover { border-color: var(--gold); color: var(--ink); }
.guide { display: flex; flex-direction: column; gap: 16px; }
.guide img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }

/* أزرار نافذة «كل البيانات» */
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
#dataBuy { text-decoration: none; }

/* ── سجل بحث الزائر ── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.history-row .h-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.history-row .h-type { font-size: 12px; color: var(--gold-dark); background: #faf7ef; border: 1px solid var(--line); border-radius: 16px; padding: 2px 10px; white-space: nowrap; }
.history-row .h-q { font-weight: 600; word-break: break-word; }
.history-row .h-at { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── بوابة دخول المشرف ── */
.login-gate { display: flex; justify-content: center; padding: 48px 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 26px; max-width: 380px; width: 100%; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { height: 92px; width: auto; margin: 0 auto 4px; }
.login-card h2 { margin: 0; font-size: 20px; color: var(--gold-dark); }
.login-card .sub { font-size: 13px; }
.login-card input { padding: 10px 12px; font-size: 15px; text-align: center; }
.login-card .btn { padding: 10px 14px; font-size: 15px; }
.login-err { color: var(--danger); font-size: 13px; }
