:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17201c;
  --muted: #5d6b65;
  --line: #e2e8e5;
  --brand: #0f6e4f;
  --brand-soft: #e3f3ec;
  --good: #128a4b;
  --good-soft: #e2f5ea;
  --warn: #b25c00;
  --warn-soft: #fff1dd;
  --bad: #c0332b;
  --bad-soft: #fde8e6;
  --info-soft: #eaf1fb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --card: #182019;
    --text: #e8efeb;
    --muted: #9aa9a2;
    --line: #26322c;
    --brand: #3cc48e;
    --brand-soft: #173428;
    --good: #43d08a;
    --good-soft: #15301f;
    --warn: #f0a13c;
    --warn-soft: #33260f;
    --bad: #ff7468;
    --bad-soft: #3a1714;
    --info-soft: #18243a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
a { color: var(--brand); }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  max-width: 820px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 12px; }
.top h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.bell {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); font-size: 20px; cursor: pointer;
}
.bell.on { background: var(--brand-soft); border-color: var(--brand); }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 6px; padding: 8px 16px;
  max-width: 820px; margin: 0 auto;
  background: var(--bg);
}
.tab {
  flex: 1; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-weight: 600; cursor: pointer; font-size: 15px;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

main { max-width: 820px; margin: 0 auto; padding: 4px 16px 40px; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.lbl { font-weight: 700; font-size: 17px; display: block; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
input[type=url], input[type=text], input[type=password] {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); direction: ltr; text-align: left; font-size: 16px;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.primary {
  background: var(--brand); color: #fff; border: 0; border-radius: 12px; padding: 12px 18px;
  font-weight: 700; cursor: pointer;
}
.primary.big { width: 100%; margin-top: 12px; padding: 15px; font-size: 17px; }
.primary:disabled { opacity: .55; cursor: default; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  cursor: pointer; color: var(--text); white-space: nowrap;
}
.small { font-size: 13px; padding: 7px 11px; }
.err { color: var(--bad); margin: 8px 0 0; min-height: 0; font-size: 14px; }
.err:empty { display: none; }
.muted { color: var(--muted); }

/* شغل جاري */
.job { border-color: var(--brand); }
.job h3 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin 0.9s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.steps li { padding: 4px 0; color: var(--muted); border-top: 1px dashed var(--line); }
.steps li:first-child { border-top: 0; }
.steps li.last { color: var(--text); font-weight: 600; }

/* النتيجة */
.banner { border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; font-weight: 700; font-size: 17px; }
.banner small { display: block; font-weight: 400; font-size: 14px; margin-top: 2px; }
.banner.good { background: var(--good-soft); color: var(--good); }
.banner.info { background: var(--info-soft); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

.section-title { font-size: 15px; color: var(--muted); margin: 22px 4px 6px; font-weight: 700; }

.offer { position: relative; }
.offer.best { border: 2px solid var(--good); }
.offer .head { display: flex; gap: 12px; align-items: flex-start; }
.offer img.thumb { width: 72px; height: 72px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); flex: none; }
.offer .titles { flex: 1; min-width: 0; }
.offer .t { font-size: 14px; margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.price-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.price { font-size: 24px; font-weight: 800; }
.price .cur { font-size: 14px; font-weight: 600; color: var(--muted); }
.was { text-decoration: line-through; color: var(--muted); font-size: 14px; }
.diff { font-size: 14px; font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.diff.cheaper { background: var(--good-soft); color: var(--good); }
.diff.pricier { background: var(--bad-soft); color: var(--bad); }
.diff.same { background: var(--info-soft); }
.note-vat { font-size: 12px; color: var(--muted); width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.chip.site { font-weight: 700; color: #111; border: 0; }
.chip.site.amazon { background: #ffd8a1; }
.chip.site.noon { background: #fff27a; }
.chip.site.aliexpress { background: #ffc9bd; }
.chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.best { background: var(--good); color: #fff; border: 0; font-weight: 700; }

.match { margin-top: 12px; }
.match .bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.match .bar i { display: block; height: 100%; background: var(--good); }
.match .bar i.mid { background: var(--warn); }
.match .bar i.low { background: var(--bad); }
.match .lab { font-size: 13px; margin-bottom: 4px; display: flex; justify-content: space-between; }

.block { margin-top: 12px; font-size: 14px; }
.block b { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.block ul { margin: 0; padding-inline-start: 18px; }
.flags { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 8px 12px; }
.flags b { color: var(--bad); }
.verdict { background: var(--brand-soft); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.actions a, .actions button { flex: 1; text-align: center; text-decoration: none; }
.linkbtn {
  display: inline-block; background: var(--text); color: var(--card); border-radius: 12px; padding: 11px 14px; font-weight: 700;
}
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }
.kv { font-size: 14px; margin: 6px 0 0; }
.kv div { padding: 3px 0; border-bottom: 1px dashed var(--line); }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.mini td, table.mini th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }

/* المراقبة */
.w-head { display: flex; gap: 12px; align-items: center; }
.w-head img { width: 60px; height: 60px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.w-head h3 { margin: 0; font-size: 15px; }
.w-best { margin-top: 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.listing { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.listing .lp { font-weight: 800; font-size: 16px; }
.listing .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.listing a { font-size: 13px; }
.spark { width: 100%; height: 34px; grid-column: 1 / -1; }
.alerts { font-size: 13px; margin-top: 8px; }
.alerts div { padding: 4px 0; border-top: 1px dashed var(--line); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.h-item { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.h-item img { width: 54px; height: 54px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); flex: none; }
.h-item .x { flex: 1; min-width: 0; }
.h-item .x div:first-child { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* نافذة الإشعارات */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet.hidden { display: none; }
.sheet-body { background: var(--card); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet-body h3 { margin: 0 0 8px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* صفحة الدخول */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login h1 { text-align: center; margin: 10px 0 0; }
.login .logo { display: block; margin: 0 auto; width: 72px; height: 72px; border-radius: 18px; }
.login label { display: block; margin: 12px 0 4px; font-weight: 600; }
.login .primary { width: 100%; margin-top: 16px; padding: 14px; }

/* ابحث */
.modes { display: grid; gap: 8px; margin-top: 12px; }
.mode { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; cursor: pointer; background: var(--bg); }
.mode input { margin-top: 5px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.mode span { display: flex; flex-direction: column; }
.mode small { color: var(--muted); font-size: 13px; }
.mode:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
table.specs { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.specs th, table.specs td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
table.specs th { color: var(--muted); font-weight: 600; }
.vs { font-size: 12px; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.vs.up { background: var(--good-soft); color: var(--good); }
.vs.eq { background: var(--info-soft); }
.vs.down { background: var(--bad-soft); color: var(--bad); }
.vs.unk { background: var(--bg); color: var(--muted); }
.tag-type { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--info-soft); margin-inline-start: 6px; font-weight: 600; }
