:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #15201d;
  --muted: #55625e;
  --line: #d9e0de;
  --brand: #0b6b5a;
  --brand-ink: #ffffff;
  --brand-soft: #e1f1ec;
  --money: #8a5a00;
  --up: #0b7a3e;
  --down: #b42318;
  --green-bg: #e3f4ea; --green-fg: #0b6b34;
  --yellow-bg: #fff4d6; --yellow-fg: #7a5200;
  --red-bg: #fde7e5; --red-fg: #a3150b;
  --sample-bg: #ece6ff; --sample-fg: #4b2fa8;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 2px 8px rgba(16, 24, 22, .05);
  --radius: 14px;
  --font: "Segoe UI", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #16201d; --surface-2: #1d2925; --text: #e7efec; --muted: #9db0aa; --line: #2b3a35;
    --brand: #3cc3a3; --brand-ink: #062a22; --brand-soft: #173a32; --money: #f2c14e; --up: #5fd38e; --down: #ff8a80;
    --green-bg: #12352a; --green-fg: #7fe0a8; --yellow-bg: #3a2f10; --yellow-fg: #f5cf6b; --red-bg: #43191a; --red-fg: #ff9d94;
    --sample-bg: #2b2350; --sample-fg: #c7b8ff; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #16201d; --surface-2: #1d2925; --text: #e7efec; --muted: #9db0aa; --line: #2b3a35;
  --brand: #3cc3a3; --brand-ink: #062a22; --brand-soft: #173a32; --money: #f2c14e; --up: #5fd38e; --down: #ff8a80;
  --green-bg: #12352a; --green-fg: #7fe0a8; --yellow-bg: #3a2f10; --yellow-fg: #f5cf6b; --red-bg: #43191a; --red-fg: #ff9d94;
  --sample-bg: #2b2350; --sample-fg: #c7b8ff; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, .chip { touch-action: manipulation; }
.btn:active, .chip:active { opacity: .8; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: -999px; }
.skip:focus { inset-inline-start: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 99; }
bdi.ltr, .ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }

/* البار العلوي */
.topbar { position: sticky; top: 0; z-index: var(--ds-z-topbar, 30); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: var(--ds-page-2xl, 42rem); margin: 0 auto; display: flex; align-items: center; gap: 2px; padding: var(--ds-bar-pad-y, 6px) var(--ds-page-pad-x, 14px); min-height: 48px; }
.brand { flex: 1 1 auto; min-width: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 16px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .short { display: none; }
@media (max-width: 420px) { .topbar.inner .brand .full { display: none; } .topbar.inner .brand .short { display: inline; } }
.add-row.solo { margin-bottom: 12px; }
.brand img { flex: none; }
@media (max-width: 420px) { .brand img { display: none; } }
.slot-nav, .slot-acct, #slotEye { display: flex; gap: 2px; flex: none; }
.local-tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.bar-actions { display: flex; gap: 2px; flex: none; }
/* بلا إطار ولا خلفية إلا عند التحويم (عقد الغلاف) */
.bar-btn { width: 40px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; background: transparent; border-radius: 10px; cursor: pointer; color: var(--text); text-decoration: none; flex: none; }
.bar-btn:hover { background: var(--surface-2); border-color: var(--line); }
.bar-btn.on { color: var(--brand); }
svg.flip { transform: scaleX(-1); }
.bar-btn svg { width: 18px; height: 18px; }
.bar-btn.spin svg, .btn.run.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bar-btn.spin svg, .btn.run.spin svg { animation: none; } }
.runbar { background: var(--brand-soft); color: var(--text); font-size: 13px; padding: 6px var(--ds-page-pad-x, 14px); text-align: center; }

/* الصفحة */
.page { max-width: var(--ds-page-2xl, 42rem); margin: 0 auto; padding: 14px var(--ds-page-pad-x, 14px) 24px; outline: none; }
h1 { font-size: 20px; margin: 4px 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 8px; }
.lead { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* الشريط السفلي */
.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: var(--ds-z-topbar, 30); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tabbar[hidden] { display: none; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; min-height: 56px; text-decoration: none; color: var(--muted); font-size: 12px; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: 700; }

/* عناصر عامة */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; min-height: 36px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border-radius: 99px; padding: 1px 9px; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green-fg); }
.b-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.b-red { background: var(--red-bg); color: var(--red-fg); }
.b-sample { background: var(--sample-bg); color: var(--sample-fg); }
.b-neutral { background: var(--surface-2); color: var(--muted); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--down); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 0; }

/* كارت المرشّح */
.cand-head { display: flex; align-items: flex-start; gap: 8px; justify-content: space-between; }
.dom { font-family: var(--mono); font-size: 19px; font-weight: 700; direction: ltr; unicode-bidi: isolate; word-break: break-all; text-decoration: none; color: var(--text); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.money-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.money { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.money .lbl { font-size: 12px; color: var(--muted); display: block; }
.money .val { font-size: 17px; font-weight: 700; }
.money .val.gold { color: var(--money); }
.money .src { font-size: 12px; color: var(--muted); display: block; }
.range { display: flex; align-items: baseline; gap: 6px; direction: ltr; justify-content: flex-end; }
.range .lo, .range .hi { font-size: 13px; color: var(--muted); font-weight: 600; }
.range-line { display: block; font-size: 13px; color: var(--muted); }
.offer-actions { flex-basis: 100%; }
.why { font-size: 13px; color: var(--muted); margin: 8px 0 10px; }
.why .u { color: var(--up); }
.why .d { color: var(--down); }
.decided { font-size: 13px; padding: 8px 10px; border-radius: 10px; margin-top: 8px; }
.decided.ok { background: var(--green-bg); color: var(--green-fg); }
.decided.no { background: var(--surface-2); color: var(--muted); }

/* التفاصيل */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.factors { list-style: none; margin: 0; padding: 0; }
.factors li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.factors li:last-child { border-bottom: 0; }
.factors .fx { direction: ltr; font-family: var(--mono); font-weight: 700; font-size: 13px; }
.factors .up .fx { color: var(--up); }
.factors .down .fx { color: var(--down); }
.factors .note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.formula { font-family: var(--mono); font-size: 12px; direction: ltr; text-align: left; background: var(--surface-2); padding: 8px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }
.formula.rtl { direction: rtl; text-align: right; font-family: var(--font); white-space: normal; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 48px; direction: ltr; margin: 6px 0 2px; }
.bars span { flex: 1; background: var(--brand); opacity: .75; border-radius: 2px 2px 0 0; min-height: 2px; }
.bars-x { display: flex; justify-content: space-between; direction: ltr; font-size: 12px; color: var(--muted); }
.tm { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.tm.green { background: var(--green-bg); color: var(--green-fg); }
.tm.yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.tm.red { background: var(--red-bg); color: var(--red-fg); }
.warn { background: var(--yellow-bg); color: var(--yellow-fg); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.note-box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: start; }
table.t td.n { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
.comps-list { list-style: none; margin: 0; padding: 0; }
.comps-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.comps-list li:last-child { border-bottom: 0; }
.comps-list .cl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.comps-list .cd { font-family: var(--mono); font-weight: 700; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.comps-list .cp { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.comps-list .cm { font-size: 12px; color: var(--muted); margin-top: 2px; }
.comps-list a { color: var(--brand); }
ul.bands { margin: 4px 0 6px; padding-inline-start: 18px; }

/* «اتباع شبهه» على الكارت: سطر لكل صفقة — الاسم والسعر في سطر، والتاريخ والمصدر تحتهم */
.comps-mini { border-top: 1px dashed var(--line); padding-top: 8px; margin: 0 0 10px; }
.comps-mini .lbl { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 2px; }
.comps-mini ul { list-style: none; margin: 0; padding: 0; }
.comps-mini li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 3px 0; font-size: 13px; }
.comps-mini .cd { font-family: var(--mono); min-width: 0; overflow-wrap: anywhere; }
.comps-mini .cp { font-weight: 700; font-variant-numeric: tabular-nums; }
.comps-mini .cm { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.src-row { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.src-row:last-child { border-bottom: 0; }
ol.steps { margin: 6px 0 0; padding-inline-start: 20px; }
ol.steps li { margin-bottom: 3px; overflow-wrap: anywhere; }
ol.steps code { display: inline-block; max-width: 100%; font-family: var(--mono); font-size: 12px; unicode-bidi: isolate; direction: ltr; background: var(--surface); color: var(--text); padding: 0 4px; border-radius: 4px; overflow-wrap: anywhere; vertical-align: bottom; }

/* نماذج */
form.f { display: grid; gap: 10px; }
.f label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.f input, .f select, .f textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 16px; color: var(--text); }
.f .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 16px; direction: ltr; text-align: left; }
details.more > summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .lbl { font-size: 12px; color: var(--muted); display: block; }
.stat .val { font-size: 18px; font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.pos { color: var(--up); }
.neg { color: var(--down); }
.offer { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.offer .amt { font-weight: 700; direction: ltr; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.toast { position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); inset-inline: 14px; max-width: 30rem; margin: 0 auto; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: var(--ds-z-modal, 60); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; text-decoration: none; font-size: 14px; }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }

@media (min-width: 720px) {
  .money-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* حجم الخط (Aa) */
:root[data-fs="1"] body { zoom: 1.1; }
:root[data-fs="2"] body { zoom: 1.22; }

/* البارات الثلاثة + المعاينة: متتابعة جوّه الهيدر اللاصق */
.sysbar { display: flex; align-items: center; gap: 6px; padding: 4px var(--ds-page-pad-x, 14px); font-size: 13px; line-height: 1.4; border-bottom: 1px solid var(--line); }
.sysbar > span:first-child { flex: 1; min-width: 0; }
.sysbar .btn, .sysbar .linkish { flex: none; }
.sysbar[hidden] { display: none; }
.sysbar.install { background: var(--brand); color: var(--brand-ink); }
.sysbar.install .btn.primary { background: var(--brand-ink); color: var(--brand); border-color: var(--brand-ink); }
.sysbar.install .linkish { color: var(--brand-ink); }
.sysbar.update { background: var(--yellow-bg); color: var(--yellow-fg); }
.sysbar.notif { background: var(--brand-soft); color: var(--text); }
.sysbar.preview { background: var(--sample-bg); color: var(--sample-fg); font-weight: 600; }
.sysbar .btn.sm { min-height: 32px; }
.linkish { background: none; border: 0; padding: 6px 8px; min-height: 32px; text-decoration: underline; cursor: pointer; color: inherit; font-size: 13px; }

/* سطر العنوان: العنوان + التحديث + الجرس */
.title-line { display: flex; align-items: center; gap: 8px; }
.title-line .grow { flex: 1; }
.btn.run svg { width: 16px; height: 16px; }
.bell { position: relative; width: 44px; height: 44px; display: grid; place-items: center; color: var(--text); border-radius: 10px; flex: none; }
.bell:hover { background: var(--surface-2); }
.bell svg { width: 22px; height: 22px; }
.bell .count { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--down); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.notif-item { display: block; text-decoration: none; color: var(--text); }
.notif-item.unread { border-inline-start: 4px solid var(--brand); }
.readonly-note { margin: 8px 0 0; }

/* الدخول والحساب */
.login { max-width: 24rem; margin: 6vh auto 0; text-align: center; }
.login .section { text-align: start; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }

/* الجولة */
.tour { position: fixed; inset: 0; z-index: var(--ds-z-modal, 60); background: rgba(8, 14, 12, .45); display: flex; align-items: flex-end; justify-content: center; padding: 14px 14px calc(78px + env(safe-area-inset-bottom)); }
.tour[hidden] { display: none; }
.tour-card { background: var(--surface); color: var(--text); border-radius: 16px; padding: 16px; max-width: 26rem; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.tour-card h2 { font-size: 17px; }
.tour-card p { font-size: 14px; }
body.touring .tabbar { z-index: calc(var(--ds-z-modal, 60) + 1); }
.tour-hl { position: relative; z-index: calc(var(--ds-z-modal, 60) + 1); outline: 3px solid var(--money); outline-offset: 3px; border-radius: 12px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }