/* ===========================================================
   مدار المال — ورقة الأنماط
   هوية: أخضر عميق + ذهبي. عربية (RTL)، متجاوبة بالكامل.
   مكتوبة يدوياً بلا أي إطار خارجي.
   =========================================================== */

/* ───────────────────────────── الرموز ───────────────────────────── */

:root {
  /* الأسطح */
  --bg:         #fbfaf7;
  --bg-soft:    #f3f1ec;
  --bg-elev:    #ffffff;
  --bg-ink:     #0b1512;   /* أقسام داكنة داخل الوضع الفاتح */

  /* النص */
  --text:       #111917;
  --text-soft:  #5d6b66;
  --text-faint: #8b9792;

  /* الحدود */
  --border:      #e5e2da;
  --border-soft: #efece5;

  /* العلامة */
  --brand:      #0c6b5f;
  --brand-deep: #084a42;
  --brand-ink:  #0a5c52;
  --brand-soft: #e7f2ef;

  /* الذهبي */
  --gold:       #a67c15;
  --gold-soft:  #f7efd9;
  --gold-line:  #d9bd6b;

  /* الشكل */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(11, 21, 18, .05);
  --shadow:    0 2px 4px rgba(11, 21, 18, .04), 0 12px 28px -14px rgba(11, 21, 18, .18);
  --shadow-lg: 0 4px 8px rgba(11, 21, 18, .05), 0 28px 60px -24px rgba(11, 21, 18, .28);

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 68px;

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-display: "Tajawal", var(--font);

  --ease: cubic-bezier(.4, .14, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #080c0b;
    --bg-soft:    #0e1514;
    --bg-elev:    #111a18;
    --bg-ink:     #060a09;

    --text:       #eef2f0;
    --text-soft:  #9aaaa4;
    --text-faint: #6c7d77;

    --border:      #1e2a27;
    --border-soft: #182220;

    --brand:      #3fd5c0;
    --brand-deep: #1b9c8b;
    --brand-ink:  #6fe4d3;
    --brand-soft: #0d2420;

    --gold:       #e8c069;
    --gold-soft:  #241d0d;
    --gold-line:  #8a6e2a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow:    0 2px 4px rgba(0, 0, 0, .4), 0 14px 32px -16px rgba(0, 0, 0, .8);
    --shadow-lg: 0 4px 10px rgba(0, 0, 0, .5), 0 32px 64px -28px rgba(0, 0, 0, .9);
  }
}

:root[data-theme="dark"] {
  --bg:         #080c0b;
  --bg-soft:    #0e1514;
  --bg-elev:    #111a18;
  --bg-ink:     #060a09;

  --text:       #eef2f0;
  --text-soft:  #9aaaa4;
  --text-faint: #6c7d77;

  --border:      #1e2a27;
  --border-soft: #182220;

  --brand:      #3fd5c0;
  --brand-deep: #1b9c8b;
  --brand-ink:  #6fe4d3;
  --brand-soft: #0d2420;

  --gold:       #e8c069;
  --gold-soft:  #241d0d;
  --gold-line:  #8a6e2a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow:    0 2px 4px rgba(0, 0, 0, .4), 0 14px 32px -16px rgba(0, 0, 0, .8);
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, .5), 0 32px 64px -28px rgba(0, 0, 0, .9);
}

/* ───────────────────────────── الأساس ───────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
  /* clip (لا hidden) يمنع التمرير الأفقي الذي يسببه الدرج المنزلق
     دون أن يُنشئ حاوية تمرير تكسر position: sticky */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(16px, 0.35vw + 15.2px, 17.5px);
  line-height: 1.9;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

body.is-locked { overflow: hidden; }

img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--brand-ink);
  text-decoration: none;
  transition: color .16s var(--ease);
}
a:hover { color: var(--brand); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.32;
  margin: 0 0 .55em;
  font-weight: 800;
  letter-spacing: -.015em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.85rem, 1.1rem + 3.4vw, 3.2rem); }
h2 { font-size: clamp(1.38rem, 1rem + 1.7vw, 2rem); }
h3 { font-size: clamp(1.12rem, .95rem + .8vw, 1.35rem); }
h4 { font-size: 1.05rem; font-weight: 700; }

p { margin: 0 0 1.15em; text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--brand); color: #fff; }

/* أدوات */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.muted { color: var(--text-soft); font-size: .92rem; }
.center { text-align: center; }
.lead { font-size: clamp(1.02rem, .95rem + .35vw, 1.18rem); color: var(--text-soft); line-height: 1.85; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--gold); font-weight: 700; font-size: .83rem;
  letter-spacing: .06em; margin-bottom: .9em;
}
.eyebrow::before {
  content: ""; width: 26px; height: 1.5px; background: var(--gold-line); flex: none;
}

/* يُخفى بالقصّ لا بالإزاحة — الإزاحة خارج الشاشة تُنشئ تمريراً أفقياً في RTL */
.skip {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; z-index: 200;
  inset-block-start: 12px; inset-inline-start: 12px;
  width: auto; height: auto; margin: 0; padding: 12px 22px;
  overflow: visible; clip-path: none;
  background: var(--brand); color: #fff; border-radius: var(--r-sm);
  box-shadow: var(--shadow);
}

/* شريط تقدّم القراءة */
.progress {
  position: fixed; inset-block-start: 0; inset-inline: 0; height: 2.5px; z-index: 90;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  transform-origin: right center; transform: scaleX(0);
  transition: transform .08s linear; pointer-events: none;
}

/* ───────────────────────────── الأزرار ───────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 26px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff; font-family: var(--font); font-weight: 700; font-size: .98rem;
  cursor: pointer; text-align: center;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--brand) 70%, transparent);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), filter .16s var(--ease);
}
.btn:hover {
  color: #fff; transform: translateY(-2px);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--brand) 75%, transparent);
  filter: brightness(1.06);
}
.btn:active { transform: translateY(0); }

.btn--ghost {
  background: transparent; color: var(--text);
  border-color: var(--border); box-shadow: none;
}
.btn--ghost:hover {
  color: var(--brand); border-color: var(--brand);
  background: var(--brand-soft); box-shadow: none;
}

.btn--gold {
  background: linear-gradient(135deg, var(--gold), #8a6512);
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--gold) 70%, transparent);
}

.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text-soft);
  transition: all .16s var(--ease);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

/* ───────────────────────────── الترويسة ───────────────────────────── */

.site-header {
  position: sticky; top: 0; z-index: 85;
  border-bottom: 1px solid var(--border-soft);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
/* الزجاج على عنصر زائف لا على الترويسة نفسها:
   backdrop-filter على العنصر الأب يجعله المرجع لتموضع الأبناء الـfixed،
   وهو ما كان يحبس درج الجوال داخل شريط الترويسة. */
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.site-header.is-stuck { box-shadow: var(--shadow-sm); border-color: var(--border); }

.site-header__inner {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--header-h);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); flex: none; }
.brand:hover { color: var(--text); }
.brand__mark {
  position: relative; width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-deep) 70%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 40%, transparent);
}
.brand__mark::after {
  content: ""; position: absolute; inset-inline-end: 7px; inset-block-start: 7px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand__text strong { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; letter-spacing: -.02em; }
.brand__text small { color: var(--text-faint); font-size: .7rem; letter-spacing: .01em; }

.nav { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.nav a {
  position: relative; padding: 9px 13px; border-radius: 10px;
  color: var(--text-soft); font-size: .93rem; font-weight: 600; white-space: nowrap;
}
.nav a:hover { color: var(--brand); background: var(--brand-soft); }

.header-tools { display: flex; gap: 8px; flex: none; }

.nav-toggle { display: none; }

.nav-scrim {
  position: fixed; inset: 0; z-index: 78;
  background: rgba(6, 12, 10, .55);
  backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s var(--ease), visibility .25s var(--ease);
}
.nav-scrim.is-open { opacity: 1; visibility: visible; }

/* ─── الترويسة على الجوال: درج منزلق ─── */
@media (max-width: 940px) {
  :root { --header-h: 62px; }

  .nav-toggle {
    display: grid; place-items: center;
    width: 42px; height: 42px; flex: none; margin-inline-start: auto;
    border-radius: 12px; cursor: pointer;
    background: transparent; border: 1px solid var(--border); color: var(--text);
  }
  /* أيقونتان متبادلتان: الخطوط عند الإغلاق و X عند الفتح */
  .nav-toggle svg { grid-area: 1 / 1; transition: opacity .18s var(--ease), transform .22s var(--ease); }
  .nav-toggle__close { opacity: 0; transform: rotate(-90deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle__open { opacity: 0; transform: rotate(90deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle__close { opacity: 1; transform: rotate(0); }

  .nav {
    position: fixed; z-index: 80;
    inset-block: 0; inset-inline-end: 0;
    width: min(330px, 86vw);
    margin: 0; padding: calc(var(--header-h) + 20px) 20px calc(28px + env(safe-area-inset-bottom));
    flex-direction: column; align-items: stretch; gap: 4px;
    background: var(--bg-elev);
    border-inline-start: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    /* visibility تمنع الدرج المغلق من إنشاء تمرير أفقي ومن استقبال التركيز */
    visibility: hidden;
    transition: transform .3s var(--ease), visibility .3s var(--ease);
    overflow-y: auto; overscroll-behavior: contain;
  }
  [dir="rtl"] .nav { transform: translateX(-100%); }
  .nav.is-open { transform: translateX(0) !important; visibility: visible; }

  .nav a {
    padding: 14px 16px; border-radius: 12px;
    font-size: 1rem; color: var(--text);
    border: 1px solid transparent;
  }
  .nav a:hover, .nav a:active { border-color: var(--border); }

  /* أدوات الترويسة فوق الدرج ليبقى زر الإغلاق (X) ظاهراً وقابلاً للنقر */
  .header-tools { margin-inline-start: auto; position: relative; z-index: 82; }
  .brand { position: relative; z-index: 82; }
  .brand__text small { display: none; }
  .brand__text strong { font-size: 1rem; }
}

@media (max-width: 420px) {
  .brand__mark { width: 34px; height: 34px; }
  .icon-btn, .nav-toggle { width: 40px; height: 40px; }
  .header-tools { gap: 6px; }
}

/* ───────────────────────────── البطل ───────────────────────────── */

.hero {
  position: relative; overflow: hidden;
  padding: clamp(40px, 7vw, 86px) 0;
  background:
    radial-gradient(1100px 520px at 88% -12%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 62%),
    radial-gradient(760px 420px at 4% 108%, color-mix(in srgb, var(--gold) 11%, transparent), transparent 60%),
    var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
}

.hero__inner {
  display: grid; grid-template-columns: 1.05fr .95fr;
  gap: clamp(28px, 5vw, 56px); align-items: center;
}

.hero__text h1 { margin-bottom: .4em; }
.hero__text h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--brand), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

.hero__stats {
  display: flex; gap: clamp(18px, 4vw, 34px); flex-wrap: wrap;
  margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--border);
}
.hero__stat strong {
  display: block; font-family: var(--font-display); font-size: 1.5rem;
  font-weight: 800; color: var(--brand); line-height: 1.2;
}
.hero__stat span { font-size: .84rem; color: var(--text-soft); }

.hero__card {
  display: block; position: relative;
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); color: var(--text);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.hero__card:hover { transform: translateY(-4px); color: var(--text); }
.hero__card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.hero__card-body { padding: clamp(16px, 2.5vw, 22px); display: flex; flex-direction: column; gap: 9px; }
.hero__card-body strong { font-family: var(--font-display); font-size: clamp(1.02rem, .95rem + .5vw, 1.25rem); line-height: 1.5; font-weight: 700; }

@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__card { order: -1; }
  .hero__stats { margin-top: 26px; }
}
@media (max-width: 420px) {
  .hero__stats { gap: 16px; }
  .hero__stat strong { font-size: 1.28rem; }
  .hero__actions .btn { flex: 1 1 100%; }
}

/* ───────────────────────────── الأقسام ───────────────────────────── */

.section { padding: clamp(40px, 6vw, 72px) 0; }

.section__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: clamp(22px, 3vw, 34px); flex-wrap: wrap;
}
.section__head h1, .section__head h2 { margin: 0; }
.section__head h2::after {
  content: ""; display: block; width: 44px; height: 3px; border-radius: 3px;
  margin-top: 12px; background: linear-gradient(90deg, var(--brand), var(--gold));
}

.grid {
  display: grid; gap: clamp(16px, 2.4vw, 26px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.card__media { display: block; aspect-ratio: 16 / 9; background: var(--bg-soft); overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.card:hover .card__media img { transform: scale(1.04); }
.card__body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: clamp(15px, 2vw, 20px); }
.card__title { margin: 0; font-size: clamp(1.02rem, .96rem + .3vw, 1.15rem); line-height: 1.55; font-weight: 700; }
.card__title a { color: var(--text); }
.card__title a:hover { color: var(--brand); }
.card__desc {
  margin: 0; color: var(--text-soft); font-size: .93rem; line-height: 1.75;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta {
  margin: auto 0 0; padding-top: 10px; border-top: 1px solid var(--border-soft);
  color: var(--text-faint); font-size: .82rem;
}

.tag {
  align-self: flex-start;
  padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: .76rem; font-weight: 700; letter-spacing: .01em;
}
.tag--plain { background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border-soft); }

.cat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 215px), 1fr)); }
.cat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 5px;
  padding: 22px; min-height: 104px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-elev); color: var(--text);
  transition: all .2s var(--ease);
}
.cat::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px;
  background: linear-gradient(var(--brand), var(--gold));
  transform: scaleY(0); transform-origin: bottom; transition: transform .25s var(--ease);
}
.cat:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); transform: translateY(-3px); }
.cat:hover::before { transform: scaleY(1); }
.cat strong { font-family: var(--font-display); font-size: 1.06rem; font-weight: 700; }

/* ───────────────────────────── المقال ───────────────────────────── */

.article-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 312px;
  gap: clamp(28px, 4vw, 52px);
  padding-block: clamp(24px, 4vw, 44px);
  align-items: start;
}
.article-layout .related { grid-column: 1 / -1; }

@media (max-width: 1040px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { order: 2; }
  .article-layout .related { order: 3; }
}

.page-layout { padding-block: clamp(24px, 4vw, 44px); max-width: 860px; }

.breadcrumb {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: .85rem; color: var(--text-faint); margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--brand); }

.article { min-width: 0; }
.article__lead {
  font-size: clamp(1.03rem, .96rem + .4vw, 1.2rem);
  color: var(--text-soft); line-height: 1.85; margin-bottom: 1em;
}
.article__meta {
  display: flex; gap: 7px; flex-wrap: wrap; align-items: center;
  color: var(--text-faint); font-size: .86rem;
  padding-bottom: 20px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
}
.article__cover {
  width: 100%; aspect-ratio: 1200 / 630; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--border);
  margin-bottom: clamp(22px, 3vw, 32px);
}
.article__tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 28px 0; }

.toc {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r); padding: clamp(16px, 2.2vw, 22px);
  margin-bottom: clamp(26px, 3vw, 36px);
}
.toc__title {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 800; margin: 0 0 10px;
}
.toc__title::before { content: ""; width: 18px; height: 2px; background: var(--gold); flex: none; }
.toc ol { margin: 0; padding-inline-start: 22px; }
.toc li { margin-bottom: 6px; }
.toc a { color: var(--text-soft); font-size: .94rem; }
.toc a:hover { color: var(--brand); }

/* نص المقال */
.prose { font-size: clamp(1rem, .96rem + .22vw, 1.08rem); }
.prose > h2 {
  margin-top: 2.1em; padding-top: .45em;
  border-top: 1px solid var(--border-soft);
}
.prose > h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.prose h3 { margin-top: 1.8em; color: var(--brand-ink); }
.prose ul, .prose ol { padding-inline-start: 24px; margin-bottom: 1.3em; }
.prose li { margin-bottom: .55em; }
.prose li::marker { color: var(--brand); font-weight: 700; }
.prose strong { font-weight: 700; color: var(--text); }

.prose blockquote {
  position: relative; margin: 1.8em 0; padding: 6px 22px;
  border-inline-start: 3px solid var(--gold);
  color: var(--text-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
  border: 0; height: 1px; margin: 2.6em 0;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.prose code {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: .88em;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  direction: ltr; display: inline-block; vertical-align: baseline;
  word-break: break-word;
}
.prose .code {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 16px 18px; overflow-x: auto;
  direction: ltr; text-align: left; font-size: .88rem; line-height: 1.7;
  -webkit-overflow-scrolling: touch;
}
.prose .code code { background: none; border: 0; padding: 0; }

/* الجداول — مع تمرير أفقي سلس على الجوال */
.table-wrap {
  margin: 1.8em 0;
  border: 1px solid var(--border); border-radius: var(--r);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: .94rem; }
th, td { padding: 13px 16px; text-align: start; border-bottom: 1px solid var(--border-soft); }
th {
  background: var(--bg-soft); font-weight: 700; white-space: nowrap;
  font-size: .88rem; color: var(--text);
  position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }

@media (max-width: 560px) {
  th, td { padding: 11px 13px; }
  table { font-size: .88rem; min-width: 400px; }
  .table-wrap::after {
    content: "← مرّر أفقياً"; display: block;
    padding: 7px 13px; font-size: .74rem; color: var(--text-faint);
    background: var(--bg-soft); border-top: 1px solid var(--border-soft);
    position: sticky; inset-inline-start: 0;
  }
}

/* صناديق الملاحظات */
.callout {
  position: relative; margin: 1.9em 0;
  padding: clamp(16px, 2.2vw, 20px) clamp(18px, 2.4vw, 24px);
  border-radius: var(--r); background: var(--bg-soft);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
}
.callout p:last-child { margin-bottom: 0; }
.callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout__title {
  font-family: var(--font-display); font-weight: 800;
  margin-bottom: .45em; color: var(--brand-ink); font-size: 1.02rem;
}
.callout--warn { border-inline-start-color: #d4860b; background: color-mix(in srgb, #d4860b 6%, var(--bg-soft)); }
.callout--warn .callout__title { color: #b06f08; }
.callout--money {
  border-inline-start-color: var(--gold);
  background: var(--gold-soft);
}
.callout--money .callout__title { color: var(--gold); }

:root[data-theme="dark"] .callout--warn .callout__title { color: #e8a53c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout--warn .callout__title { color: #e8a53c; }
}

/* الأسئلة الشائعة */
.faq { margin: clamp(32px, 4vw, 46px) 0; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 2px 18px; margin-bottom: 10px; background: var(--bg-elev);
  transition: border-color .2s var(--ease);
}
.faq details[open] { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.faq summary {
  cursor: pointer; font-weight: 700; padding: 15px 0;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: none;
  font-size: 1.35rem; font-weight: 400; line-height: 1; color: var(--brand);
  transition: transform .22s var(--ease);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > p { margin: 0 0 16px; color: var(--text-soft); }

.disclaimer-note {
  margin-top: 34px; padding: 16px 20px; border-radius: var(--r-sm);
  background: var(--bg-soft); border: 1px dashed var(--border);
}
.disclaimer-note p { margin: 0; font-size: .87rem; color: var(--text-faint); line-height: 1.75; }

/* ─────────────────────────── الشريط الجانبي ─────────────────────────── */

.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: calc(var(--header-h) + 18px);
}
@media (max-width: 1040px) { .sidebar { position: static; } }

.sidebar__box {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px;
}
.sidebar__box h3 {
  margin: 0 0 14px; font-size: 1rem;
  display: flex; align-items: center; gap: 9px;
}
.sidebar__box h3::before { content: ""; width: 16px; height: 2px; background: var(--gold); flex: none; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li + li { border-top: 1px solid var(--border-soft); }
.mini-list a { display: block; padding: 11px 0; color: var(--text); font-size: .93rem; line-height: 1.6; }
.mini-list a:hover { color: var(--brand); }

/* ───────────────────────────── الإعلانات ───────────────────────────── */

.ad { margin: clamp(28px, 4vw, 38px) 0; text-align: center; }
.ad--placeholder {
  display: grid; place-items: center; min-height: 120px;
  border: 1px dashed var(--border); border-radius: var(--r);
  background: var(--bg-soft); color: var(--text-faint);
  font-size: .82rem; letter-spacing: .02em;
}

/* ───────────────────────────── البحث ───────────────────────────── */

.search {
  width: min(640px, calc(100vw - 32px));
  margin: clamp(60px, 11vh, 120px) auto auto;
  padding: 18px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg);
}
.search::backdrop { background: rgba(5, 10, 9, .6); backdrop-filter: blur(4px); }
.search__form { display: flex; gap: 10px; }
.search__form input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 1rem;
}
.search__form input::placeholder { color: var(--text-faint); }
.search__results {
  list-style: none; margin: 16px 0 0; padding: 0;
  max-height: min(52vh, 420px); overflow-y: auto; overscroll-behavior: contain;
}
.search__results li + li { border-top: 1px solid var(--border-soft); }
.search__results a { display: block; padding: 13px 10px; border-radius: 10px; color: var(--text); font-weight: 600; }
.search__results a:hover { background: var(--bg-soft); }
.search__results small { display: block; color: var(--text-faint); font-size: .83rem; font-weight: 400; margin-top: 3px; }

@media (max-width: 480px) {
  .search { margin-top: 40px; padding: 14px; }
  .search__form .btn { padding: 0 16px; }
}

/* ───────────────────────────── زر العودة للأعلى ───────────────────────────── */

.to-top {
  position: fixed; z-index: 60;
  inset-block-end: calc(20px + env(safe-area-inset-bottom));
  inset-inline-start: 20px;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--bg-elev); color: var(--brand);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: all .25s var(--ease);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ───────────────────────────── التذييل ───────────────────────────── */

.site-footer {
  margin-top: clamp(48px, 7vw, 80px);
  padding-top: clamp(38px, 5vw, 58px);
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}
.site-footer__grid {
  display: grid; grid-template-columns: 1.8fr 1fr 1fr;
  gap: clamp(26px, 4vw, 44px); padding-bottom: clamp(28px, 4vw, 40px);
}
@media (max-width: 780px) { .site-footer__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .site-footer__grid { grid-template-columns: 1fr; gap: 26px; } }

.site-footer__brand {
  display: block; font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 800; margin-bottom: 10px;
}
.site-footer h3 { font-size: .95rem; margin-bottom: 14px; }
.site-footer p { color: var(--text-soft); font-size: .93rem; line-height: 1.8; max-width: 42ch; }

.site-footer__links, .site-footer__social { display: flex; flex-direction: column; gap: 11px; }
.site-footer__social { flex-direction: row; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.site-footer__links a, .site-footer__social a { color: var(--text-soft); font-size: .93rem; }
.site-footer__links a:hover, .site-footer__social a:hover { color: var(--brand); }

.site-footer__bar {
  border-top: 1px solid var(--border);
  padding-block: 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.site-footer__bar p { margin: 0; font-size: .85rem; }

/* ───────────────────────────── تفضيلات وطباعة ───────────────────────────── */

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

@media print {
  .site-header, .site-footer, .sidebar, .ad, .toc, .search,
  .skip, .to-top, .progress, .nav-scrim, .related { display: none !important; }
  .article-layout { grid-template-columns: 1fr; display: block; }
  body { font-size: 11pt; background: #fff; color: #000; }
  a { text-decoration: underline; }
}
