/* =====================================================================
   إدارة الأعمال الخاصة
   الهوية: أبيض عملي، أخضر النخيل للإجراءات، رملي وبرتقالي التمر من صورة الموقع
   ===================================================================== */

:root {
  /* ألوان مأخوذة من صورة النخيل والتمر */
  --bg: #f6f2ea;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --line: #e9e1d1;
  --line-2: #d8ccb4;

  --ink: #2a2418;
  --text: #3d3529;
  --muted: #74695a;
  --dim: #a09583;

  --primary: #3e6b24;
  --primary-hi: #4a7d2c;
  --primary-soft: #eef4e5;
  --primary-line: #cddcb9;

  --sand: #b9a276;
  --leaf: #5e8f3a;
  --date: #d9662b;
  --date-soft: #fcece2;
  --date-line: #f1cbb3;

  --brass: #c45e27;
  --success: #2f7a3e;
  --success-soft: #e7f3e8;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #8a5a00;
  --warn-soft: #fff5db;

  --f-title: "Aref Ruqaa", "Amiri", "Traditional Arabic", serif;
  --f-body: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(42, 36, 24, .06);
  --shadow-md: 0 6px 20px -8px rgba(42, 36, 24, .16);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
a { color: var(--primary-hi); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--primary-hi); outline-offset: 2px; border-radius: 6px; }
.backdrop { display: none; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px clamp(14px, 3vw, 28px);
  min-height: 62px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.seal {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  color: #fff; background: var(--primary);
}
.seal svg { width: 22px; height: 22px; stroke-width: 1.6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--f-title); font-size: 19px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: 11.5px; font-weight: 600; }

.nav { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
.nav > a, .icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 6px 12px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  background: none; cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s;
}
.nav > a svg, .icon-btn svg { width: 19px; height: 19px; }
.nav > a:hover, .icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.nav > a.is-active { color: var(--primary); background: var(--primary-soft); }
.icon-btn { padding: 0; width: 38px; justify-content: center; }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-soft); }
.inline-form { display: inline; margin: 0; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft);
}
.avatar--lg { width: 60px; height: 60px; font-size: 22px; }
.avatar--xs { width: 22px; height: 22px; font-size: 10px; }

/* ---------- قائمة المستخدم ---------- */
.user-menu { position: relative; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 4px 10px 4px 8px; padding-inline-start: 4px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.user-chip:hover, .user-menu.is-open .user-chip { border-color: var(--primary-line); background: var(--primary-soft); }
.user-chip.is-active { border-color: var(--primary-line); }
.user-chip .chev { width: 16px; height: 16px; color: var(--dim); transition: transform .2s var(--ease); }
.user-menu.is-open .chev { transform: rotate(180deg); }

.menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: 280px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 18px 40px -12px rgba(42, 36, 24, .25);
  animation: menu-in .16s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-head strong { display: block; color: var(--ink); font-size: 14.5px; line-height: 1.4; }
.menu-head small { display: block; color: var(--dim); font-size: 12.5px; text-align: right; }
.avatar--md { width: 40px; height: 40px; font-size: 15px; }
.menu-form { margin: 0; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); text-decoration: none; text-align: right; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-ico { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); }
.menu-ico svg { width: 18px; height: 18px; }
.menu-text { display: flex; flex-direction: column; line-height: 1.4; }
.menu-text b { font-size: 14px; font-weight: 700; }
.menu-text small { font-size: 12px; color: var(--muted); }
.menu-item--install { background: var(--primary-soft); margin-bottom: 4px; }
.menu-item--install:hover { background: #e3eed6; }
.menu-item--install .menu-ico { background: var(--primary); color: #fff; }
.menu-item--install b { color: var(--primary); }
.menu-item--install.is-installed { background: var(--success-soft); cursor: default; }
.menu-item--install.is-installed .menu-ico { background: var(--success); }
.menu-item--install.is-installed b { color: var(--success); }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .menu-ico { color: var(--danger); background: var(--danger-soft); }
.menu-item--danger:hover { background: var(--danger-soft); }

/* نافذة شرح التثبيت */
.sheet {
  width: min(440px, calc(100% - 28px)); padding: 20px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: 0 30px 60px -20px rgba(42, 36, 24, .35);
}
.sheet::backdrop { background: rgba(42, 36, 24, .45); }
.sheet[open] { animation: menu-in .2s var(--ease); }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head img { border-radius: 12px; flex-shrink: 0; }
.sheet-head > div { flex: 1; }
.sheet-head h2 { margin: 0; font-size: 18px; color: var(--ink); }
.sheet-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.steps { list-style: none; counter-reset: s; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.steps li {
  counter-increment: s; position: relative;
  padding: 10px 46px 10px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.8;
}
.steps li::before {
  content: counter(s, arabic-indic); position: absolute; right: 10px; top: 10px;
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}
.step-ico {
  display: inline-block; width: 22px; height: 22px; padding: 2px; vertical-align: -6px;
  border-radius: 6px; background: var(--surface); border: 1px solid var(--line); color: var(--primary-hi);
}

/* ---------- الحاوية ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(14px, 3.5vw, 28px) 56px; flex: 1; }
.container.narrow { max-width: 720px; padding-top: 28px; }

/* ---------- ترويسة الاسم ---------- */
.hero {
  position: relative; overflow: hidden;
  text-align: center;
  margin-top: clamp(16px, 3vw, 28px);
  min-height: clamp(190px, 24vw, 280px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px clamp(90px, 22vw, 260px);
  background:
    url("img/palm-left.webp") left top / auto 100% no-repeat,
    url("img/palm-right.webp") right top / auto 100% no-repeat,
    var(--sand);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.hero > * { position: relative; }
.ornament { width: 120px; height: 16px; color: #8a3f14; opacity: .7; margin: 0 auto 4px; display: block; }
.hero-title { margin: 0; font-family: var(--f-title); font-weight: 400; line-height: 1.2; display: flex; flex-direction: column; align-items: center; }
.hero-title .t2 {
  display: inline-block;
  font-size: clamp(42px, 7.2vw, 78px); font-weight: 700; line-height: 1.2;
  color: #24451a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.hero-title .t1 {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: clamp(24px, 3.4vw, 36px); color: #5a3a17; margin-top: 2px;
}
.hero-title .t1::before, .hero-title .t1::after { content: ""; width: clamp(26px, 5vw, 56px); height: 1.5px; background: var(--date); opacity: .8; }

/* ---------- الترحيب والبحث ---------- */
.welcome {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 22px;
}
.welcome p { margin: 0; }
.hello { font-size: 19px; font-weight: 800; color: var(--ink); }
.welcome .muted { font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); display: inline-block; }

.search { position: relative; display: flex; align-items: center; flex: 0 1 320px; }
.search svg { position: absolute; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--dim); pointer-events: none; }
.search input {
  width: 100%; height: 42px; padding: 0 40px 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--primary-hi); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input::placeholder { color: var(--dim); }

/* ---------- المجموعات وبطاقات الأقسام ---------- */
.group-title {
  display: flex; align-items: center; gap: 10px;
  margin: 30px 0 12px;
  font-size: 15px; font-weight: 800; color: var(--ink);
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group-title .count {
  min-width: 24px; height: 22px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700;
}

.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
}

.tile {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, box-shadow .2s, transform .2s var(--ease);
}
.tile-icon {
  position: relative; overflow: hidden;
  width: 52px; height: 52px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--primary-soft); color: var(--primary);
}
.tile-icon svg { width: 26px; height: 26px; stroke-width: 1.7; }
.tile-icon .tile-icon-svg { display: grid; place-items: center; }
.tile-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tile-title { font-size: 16px; font-weight: 800; color: var(--ink); line-height: 1.45; }
.tile-sub { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.tile-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.tile-tag {
  display: inline-block; direction: ltr;
  padding: 0 7px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em;
}
.tile-tag:empty { display: none; }
.tile-host { font-size: 12px; color: var(--dim); direction: ltr; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tile-host.is-missing { direction: rtl; color: var(--warn); }
.tile-go {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--dim);
  transition: background-color .15s, color .15s, transform .2s var(--ease);
}
.tile-go svg { width: 17px; height: 17px; }

@media (hover: hover) {
  .tile:hover { border-color: var(--primary-line); box-shadow: var(--shadow-md); transform: translateY(-2px); }
  .tile:hover .tile-go { background: var(--primary); color: #fff; transform: translate(-2px, -2px); }
}
.tile:active { transform: scale(.99); }
.tile:focus-visible { outline: 2px solid var(--primary-hi); outline-offset: 2px; }

.no-results { text-align: center; color: var(--muted); padding: 36px 0; }

/* ---------- حالات فارغة ---------- */
.empty-state { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); margin-top: 20px; }
.empty-state h2 { margin: 12px 0 4px; font-size: 18px; color: var(--ink); }
.empty-state p { color: var(--muted); margin: 0 0 18px; }
.empty-icon {
  width: 60px; height: 60px; margin: 0 auto;
  display: grid; place-items: center; color: var(--primary);
  border-radius: var(--r-md); background: var(--primary-soft);
}
.empty-icon svg { width: 28px; height: 28px; }

/* ---------- التنبيهات ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; margin: 14px 0;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; font-weight: 600;
}
.alert svg { width: 18px; height: 18px; margin-top: 3px; }
.alert--success { background: var(--success-soft); border-color: #bfe1cd; color: #145536; }
.alert--success svg { color: var(--success); }
.alert--error { background: var(--danger-soft); border-color: #f5c2bd; color: #8a1c12; }
.alert--error svg { color: var(--danger); }
.alert--warn { background: var(--warn-soft); border-color: #f0d998; color: var(--warn); }
.alert--info { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  font-weight: 700; font-size: 14.5px; text-decoration: none; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn--gold, .btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(42, 36, 24, .15); }
.btn--gold:hover, .btn--primary:hover { background: var(--primary-hi); border-color: var(--primary-hi); }
.btn--ghost { color: var(--muted); }
.btn--ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn--block { width: 100%; }
.link-btn { background: none; border: 0; padding: 2px 4px; color: var(--primary-hi); font-size: 13px; font-weight: 700; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- الحقول ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.field-label small { font-weight: 500; }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=url] {
  width: 100%; height: 44px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary-hi); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input::placeholder { color: var(--dim); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input-icon { position: absolute; right: 12px; width: 18px; height: 18px; color: var(--dim); pointer-events: none; z-index: 1; }
.input-wrap .input-icon ~ input { padding-right: 40px; padding-left: 12px; }
.input-wrap input[dir=ltr] { text-align: right; }
.input-wrap input[dir=ltr]:not(:placeholder-shown), .input-wrap input[dir=ltr]:focus { text-align: left; }
.input-wrap:has(.reveal) {
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:has(.reveal):focus-within { border-color: var(--primary-hi); box-shadow: 0 0 0 3px var(--primary-soft); }
.field .input-wrap:has(.reveal) input { border: 0; background: none; box-shadow: none; height: 42px; }
.reveal {
  flex-shrink: 0; width: 40px; height: 42px;
  display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; color: var(--dim);
}
.reveal svg { width: 18px; height: 18px; }
.reveal:hover { color: var(--primary); }

/* مفاتيح التبديل */
.switches { display: flex; flex-wrap: wrap; gap: 10px 22px; align-content: center; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span {
  position: relative; width: 38px; height: 22px; flex-shrink: 0;
  border-radius: 999px; background: #d5dbe3;
  transition: background-color .2s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .2s var(--ease);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(-16px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary-hi); outline-offset: 2px; }
.switch input:disabled + span { opacity: .55; }

/* اختيار نوع الحساب */
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); width: fit-content; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 6px 20px; border-radius: 6px; font-size: 14px; font-weight: 700; color: var(--muted); transition: all .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary-hi); }
.segmented input:disabled:not(:checked) + span { opacity: .4; cursor: not-allowed; }

/* ---------- صفحة الدخول ---------- */
.auth { flex: 1; display: grid; place-items: center; padding: clamp(16px, 4vw, 40px) 14px; }
.auth-shell {
  width: 100%; max-width: 920px;
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 30px 60px -30px rgba(42, 36, 24, .25);
  overflow: hidden;
}
.auth-brand {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; gap: 24px;
  padding: 40px 36px;
  background:
    url("img/palm-left.webp") left top / auto 62% no-repeat,
    url("img/palm-right.webp") right top / auto 62% no-repeat,
    var(--sand);
  color: var(--ink);
}
.auth-brand > * { position: relative; }
.auth-brand .hero { margin: 0; padding: 60px 0; min-height: 0; background: none; border: 0; box-shadow: none; overflow: visible; }
.auth-brand .hero-title .t2 { font-size: clamp(44px, 6vw, 64px); }
.auth-points { list-style: none; margin: 0; padding: 18px 0 0; border-top: 1px solid rgba(42, 36, 24, .15); display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; color: #3a2e1c; }
.auth-points svg { width: 20px; height: 20px; padding: 7px; box-sizing: content-box; border-radius: 8px; background: rgba(255, 255, 255, .45); color: var(--primary); }

.auth-card {
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: 40px clamp(22px, 4vw, 40px);
}
.auth-card h2 { margin: 0; font-size: 24px; color: var(--ink); }
.auth-card > .muted { margin: -12px 0 4px; font-size: 14px; }
.auth-card .alert { margin: 0; }
.auth-card .btn { margin-top: 6px; height: 48px; font-size: 16px; }
.auth-help { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); }
.auth-help svg { width: 16px; height: 16px; color: var(--dim); }

/* ---------- لوحة الإدارة ---------- */
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 28px 0 18px; }
.page-title { margin: 0; font-size: clamp(24px, 3.5vw, 30px); font-weight: 800; color: var(--ink); line-height: 1.35; }
.admin-head .muted { margin: 2px 0 0; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.page-head .muted { margin: 0; display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

.stats { display: flex; margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.stats div { padding: 10px 20px; text-align: center; min-width: 84px; }
.stats div + div { border-inline-start: 1px solid var(--line); }
.stats dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.stats dd { margin: 0; font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.35; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 11px 16px; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14.5px;
  border-bottom: 2px solid transparent;
}
.tabs a svg { width: 18px; height: 18px; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .muted { margin: 0; font-size: 14px; flex: 1 1 260px; }

.panel {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-sm);
  padding: clamp(16px, 3vw, 28px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 19px; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-start; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.sub-head { display: flex; align-items: center; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 700; color: var(--ink); }
.sub-head svg { width: 18px; height: 18px; color: var(--primary); }
.sub-head small { font-weight: 500; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.perms legend, fieldset > legend { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 700; font-size: 14px; color: var(--ink); }
.perms-tools { display: inline-flex; gap: 4px; }
.admin-note { display: none; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary); font-size: 14px; font-weight: 600; }
.admin-note svg { width: 18px; height: 18px; }
.perms[data-admin] .admin-note { display: flex; }
.perms[data-admin] .chips, .perms[data-admin] .perms-tools { opacity: .4; pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; }
.chip > span {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--muted);
  transition: all .15s;
}
.chip > span > svg { width: 17px; height: 17px; }
.chip small { font-weight: 500; color: var(--dim); }
.chip input:checked + span { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.chip input:checked + span::before {
  content: ""; width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0;
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/11px no-repeat;
}
.chip input:focus-visible + span { outline: 2px solid var(--primary-hi); outline-offset: 2px; }

/* نموذج القسم مع المعاينة */
.section-form { display: flex; flex-direction: column; gap: 18px; }
.section-form-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; }
.preview-col { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); align-self: start; }
.tile--preview { pointer-events: none; }
.upload {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px dashed var(--line-2); background: var(--surface);
  cursor: pointer; font-size: 14px; font-weight: 700;
  transition: border-color .15s;
}
.upload:hover { border-color: var(--primary-hi); }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload svg { width: 20px; height: 20px; color: var(--primary); margin-top: 3px; }
.upload small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.icon-picker label { cursor: pointer; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px 6px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  transition: all .15s;
}
.icon-picker svg { width: 23px; height: 23px; }
.icon-picker small { font-size: 11.5px; }
.icon-picker span:hover { border-color: var(--line-2); }
.icon-picker input:checked + span { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.icon-picker input:focus-visible + span { outline: 2px solid var(--primary-hi); }

/* جدول المستخدمين */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: right; padding: 11px 16px; font-size: 12.5px; color: var(--muted); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.who { display: flex; align-items: center; gap: 10px; }
.who .avatar { width: 38px; height: 38px; }
.who strong { display: block; font-size: 14.5px; color: var(--ink); }
.who small { display: block; color: var(--dim); font-size: 12.5px; text-align: right; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge--gold { color: var(--primary); border-color: var(--primary-line); background: var(--primary-soft); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.status.is-on { color: var(--success); } .status.is-on::before { background: var(--success); }
.status.is-off { color: var(--dim); } .status.is-off::before { background: var(--dim); }

/* قائمة الأقسام في الإدارة */
.section-list { display: grid; gap: 10px; }
.section-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.section-row.is-off { opacity: .6; }
.mini-arch {
  width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden; color: var(--primary);
  border-radius: var(--r-sm); background: var(--primary-soft);
}
.mini-arch svg { width: 23px; height: 23px; }
.mini-arch img { width: 100%; height: 100%; object-fit: cover; }
.section-row-main { flex: 1; min-width: 0; }
.section-row-main h3 { margin: 0; font-size: 15.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: 12.5px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta svg { width: 14px; height: 14px; color: var(--dim); }
.url { margin: 0; font-size: 12.5px; color: var(--primary-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.url.is-missing { color: var(--warn); direction: rtl; }
.status-btn { cursor: pointer; padding: 3px 11px; border-radius: 6px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--line); background: var(--surface); }
.status-btn.is-on { color: var(--success); border-color: #bfe1cd; background: var(--success-soft); }
.status-btn.is-off { color: var(--muted); }

/* ترتيب الأقسام */
.inline-icon { width: 16px; height: 16px; vertical-align: -3px; stroke-width: 3.2; color: var(--primary); }
.sort-group + .sort-group { margin-top: 24px; }
.sort-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sort-group-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 800; color: var(--ink); }
.sort-group-head h3 svg { width: 17px; height: 17px; color: var(--primary); }
.sort-group-head small { min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; font-size: 11.5px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.group-move { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.sort-items { display: grid; gap: 8px; }
.order-ctrl { display: flex; flex-direction: column; align-items: center; margin-inline-end: -4px; }
.move-btn, .drag-handle {
  width: 32px; height: 24px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 6px; color: var(--dim); cursor: pointer;
}
.move-btn svg { width: 18px; height: 18px; }
.drag-handle { height: 28px; cursor: grab; touch-action: none; }
.drag-handle svg { width: 22px; height: 22px; stroke-width: 3.4; }
.move-btn:hover:not(:disabled), .drag-handle:hover { color: var(--primary); background: var(--primary-soft); }
.move-btn:disabled { opacity: .25; cursor: default; }
.section-row.is-dragging { position: relative; z-index: 2; border-color: var(--primary); box-shadow: 0 14px 30px -14px rgba(62, 107, 36, .4); }
.section-row.is-dragging .drag-handle { color: var(--primary); }
body.is-sorting, body.is-sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.just-moved { animation: moved .7s var(--ease); }
@keyframes moved { from { background-color: var(--primary-soft); } }
.save-status { font-weight: 700; white-space: nowrap; }
.save-status.is-saving { color: var(--muted); }
.save-status.is-saved { color: var(--success); }
.save-status.is-error { color: var(--danger); }

/* ---------- التذييل ---------- */
.site-foot {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 18px 16px; border-top: 1px solid var(--line); background: var(--surface);
  color: var(--dim); font-size: 13px;
}
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-2); }

/* ---------- الهاتف والأجهزة اللوحية ---------- */
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); max-width: 460px; }
  .auth-brand { padding: 22px 18px; gap: 16px; background-size: auto 100%, auto 100%, auto; }
  .auth-brand .hero { padding: 6px 70px; }
  .auth-brand .hero-title .t2 { font-size: clamp(34px, 10vw, 48px); }
  .auth-points { display: none; }
  .auth-card { padding: 26px 22px 28px; }
}

@media (max-width: 760px) {
  .nav-label { display: none; }
  .brand-text strong { font-size: 17px; }
  .nav > a { padding: 6px 9px; }
  .user-chip { padding: 3px; padding-inline-end: 6px; gap: 4px; }
  .menu { width: min(290px, calc(100vw - 20px)); left: -4px; }

  .welcome { flex-direction: column; align-items: stretch; }
  .search { flex-basis: auto; }
  .grid { gap: 10px; }
  .tile { padding: 13px; gap: 12px; }
  .tile-icon { width: 46px; height: 46px; }

  .stats { width: 100%; }
  .stats div { flex: 1; padding: 8px 4px; min-width: 0; }
  .tabs a { flex: 1 0 auto; justify-content: center; padding: 11px 6px; gap: 5px; font-size: 13.5px; }
  .tabs a svg { width: 16px; height: 16px; }
  .tab-extra { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .section-form-body { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { flex: 1; }

  .table-wrap { border: 0; background: none; box-shadow: none; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 10px; padding: 6px 0; position: relative; box-shadow: var(--shadow-sm); }
  .table td { border: 0; padding: 5px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .table td[data-label]::before { content: attr(data-label); color: var(--dim); font-size: 12.5px; font-weight: 600; }
  .table td[data-label="الحساب"]::before { display: none; }
  .table td.row-actions { position: absolute; top: 8px; left: 6px; width: auto; padding: 0; }

  .section-row { flex-wrap: wrap; }
  .section-row .row-actions { width: 100%; justify-content: flex-start; border-top: 1px solid var(--line); padding-top: 8px; }
}

/* ---------- الإعلانات في الصفحة الرئيسية ---------- */
.notices { display: grid; gap: 10px; margin-top: 16px; }
.notice {
  --c: var(--primary); --soft: var(--primary-soft); --edge: var(--primary-line);
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--edge); border-inline-start: 4px solid var(--c);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: opacity .25s, transform .25s var(--ease);
}
.notice--important { --c: #b7791f; --soft: #fff6e0; --edge: #f2dcaa; }
.notice--urgent { --c: var(--danger); --soft: var(--danger-soft); --edge: #f3c4bf; }
.notice.is-leaving { opacity: 0; transform: translateY(-6px); }
.notice-ico { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--soft); color: var(--c); }
.notice-ico svg { width: 21px; height: 21px; }
.notice-body { flex: 1; min-width: 0; }
.notice-meta { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 12.5px; color: var(--dim); }
.notice h2 { margin: 2px 0 0; font-size: 16.5px; font-weight: 800; color: var(--ink); line-height: 1.5; }
.notice-text { margin-top: 4px; font-size: 14.5px; color: var(--text); line-height: 1.8; overflow-wrap: anywhere; }
.notice-text a { color: var(--primary-hi); font-weight: 600; }
.notice-form { margin: 0; align-self: center; }
.btn--small { min-height: 34px; padding: 0 12px; font-size: 13px; gap: 6px; white-space: nowrap; }
.btn--small svg { width: 16px; height: 16px; }
.notice .btn--small:hover { border-color: var(--c); color: var(--c); }

.lvl { display: inline-block; padding: 0 8px; border-radius: 5px; font-size: 11.5px; font-weight: 800; line-height: 1.8; background: var(--primary-soft); color: var(--primary); }
.lvl--important { background: #fff1d1; color: #8a5a00; }
.lvl--urgent { background: var(--danger-soft); color: var(--danger); }

/* ---------- البحث داخل الأقسام ---------- */
.deep-search {
  margin-top: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--primary-line); border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.deep-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.deep-title svg { width: 17px; height: 17px; color: var(--primary); }
.deep-title b { color: var(--ink); }
.deep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 8px; }
.deep-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px;
  transition: border-color .15s, background-color .15s;
}
.deep-item:hover, .deep-item:focus-visible { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.deep-ico { width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center; border-radius: 7px; background: var(--surface); color: var(--primary); border: 1px solid var(--line); }
.deep-ico svg { width: 18px; height: 18px; }
.deep-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deep-go { width: 16px; height: 16px; color: var(--dim); }

/* ---------- حقول إضافية ---------- */
.field textarea, .field input[type=date] {
  width: 100%; padding: 10px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); outline: none; resize: vertical; line-height: 1.7;
  transition: border-color .15s, box-shadow .15s;
}
.field input[type=date] { height: 44px; padding: 0 12px; }
.field textarea:focus, .field input[type=date]:focus { border-color: var(--primary-hi); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-help { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.meta-ok { color: var(--success); font-weight: 700; }
.meta-ok svg { color: var(--success) !important; }
.tab-count { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 800; }

.level-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level { cursor: pointer; }
.level input { position: absolute; opacity: 0; }
.level span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
  transition: all .15s;
}
.level span svg { width: 18px; height: 18px; }
.level--info input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.level--important input:checked + span { border-color: #b7791f; background: #fff6e0; color: #8a5a00; box-shadow: inset 0 0 0 1px #b7791f; }
.level--urgent input:checked + span { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.level input:focus-visible + span { outline: 2px solid var(--primary-hi); outline-offset: 2px; }

/* ---------- قائمة الإعلانات في الإدارة ---------- */
.news-list { display: grid; gap: 10px; }
.news-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.news-row.is-dim { opacity: .65; }
.news-ico { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary); }
.news-ico svg { width: 21px; height: 21px; }
.news-row--important .news-ico { background: #fff6e0; color: #8a5a00; }
.news-row--urgent .news-ico { background: var(--danger-soft); color: var(--danger); }
.news-main { flex: 1; min-width: 0; }
.news-main h3 { margin: 0; font-size: 15.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-excerpt { margin: 2px 0 4px; font-size: 13.5px; color: var(--muted); }
.state { font-weight: 800; }
.state--on { color: var(--success); }
.state--soon { color: var(--primary-hi); }
.state--ended, .state--off { color: var(--dim); }
.readers { margin-top: 6px; font-size: 13px; }
.readers summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--primary-hi); font-weight: 700; list-style: none; }
.readers summary::-webkit-details-marker { display: none; }
.readers summary svg { width: 15px; height: 15px; }
.readers ul { margin: 8px 0 0; padding: 8px 12px; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; background: var(--surface-2); border-radius: var(--r-sm); border: 1px solid var(--line); }
.readers li small { color: var(--dim); margin-inline-start: 4px; }
.readers .muted { margin: 6px 0 0; }

/* ---------- الهاتف: ترويسة صغيرة حتى تظهر الأقسام فوراً ---------- */
@media (max-width: 760px) {
  .page-home .hero { margin-top: 12px; min-height: 118px; padding: 10px 84px; }
  .page-home .ornament { display: none; }
  .page-home .hero-title .t2 { font-size: 34px; }
  .page-home .hero-title .t1 { font-size: 20px; gap: 8px; }
  .page-home .hero-title .t1::before, .page-home .hero-title .t1::after { width: 18px; }
  .page-home .welcome { margin-top: 14px; }
  .page-home .hello { font-size: 17px; }

  .notice { padding: 14px; gap: 10px; flex-wrap: wrap; }
  .notice-ico { width: 34px; height: 34px; }
  .notice-form { width: 100%; }
  .notice-form .btn { width: 100%; }
  .level-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .news-row { flex-wrap: wrap; }
  .news-row .row-actions { width: 100%; justify-content: flex-start; border-top: 1px solid var(--line); padding-top: 8px; }
}

/* ---------- سجل النشاط ---------- */
.field select {
  width: 100%; height: 44px; padding: 0 12px 0 32px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6a7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") left 10px center / 16px no-repeat;
  -webkit-appearance: none; appearance: none; outline: none;
}
.field select:focus { border-color: var(--primary-hi); box-shadow: 0 0 0 3px var(--primary-soft); }

.log-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.stat-card:hover { border-color: var(--primary-line); box-shadow: var(--shadow-md); }
.stat-card b { display: block; font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.stat-card small { display: block; font-size: 12.5px; color: var(--muted); }
.stat-ico { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary); }
.stat-ico svg { width: 20px; height: 20px; }
.stat-card--alert { border-color: #f3c4bf; background: #fffafa; }
.stat-card--alert .stat-ico { background: var(--danger-soft); color: var(--danger); }
.stat-card--alert b { color: var(--danger); }

.log-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.log-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; padding: 16px; }
.log-filters .log-q { grid-column: 1 / 3; }
.log-actions { grid-column: 3 / -1; display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.log-actions .btn { min-height: 44px; }
.log-count { margin: 14px 2px 6px; font-size: 13px; }

.log-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.log-list > :first-child { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }
.log-day {
  margin: 0; padding: 8px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 800; color: var(--muted);
}
.log-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-time { width: 44px; flex-shrink: 0; padding-top: 7px; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.log-ico { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.log-ico svg { width: 17px; height: 17px; }
.log-row--auth .log-ico { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.log-row--alert .log-ico { background: var(--danger-soft); color: var(--danger); }
.log-row--alert .log-line b { color: var(--danger); }
.log-row--admin .log-ico { background: #fff4dc; color: #8a5a00; }
.log-body { flex: 1; min-width: 0; }
.log-line { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.log-line b { font-weight: 800; }
.log-detail { color: var(--text); }
.log-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin: 0; font-size: 12.5px; color: var(--dim); }
.log-sub a { color: var(--primary-hi); font-weight: 700; text-decoration: none; }
.log-sub a:hover { text-decoration: underline; }
.log-sub span { display: inline-flex; align-items: center; gap: 4px; }
.log-sub svg { width: 13px; height: 13px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pg-prev { transform: rotate(-90deg); }
.pg-next { transform: rotate(90deg); }

.log-side { position: sticky; top: 80px; padding: 16px; }
.log-side h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; color: var(--ink); }
.log-side h3 svg { width: 18px; height: 18px; color: var(--primary); }
.log-side > .muted { margin: 0 0 12px; font-size: 12.5px; }
.log-side-empty { font-size: 13.5px; }
.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.top-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.top-name { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-name svg { width: 15px; height: 15px; color: var(--primary); }
.top-num { font-size: 13px; font-weight: 800; color: var(--primary); }
.top-bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.top-bar span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.log-note { display: flex; align-items: flex-start; gap: 6px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.log-note svg { width: 14px; height: 14px; margin-top: 3px; flex-shrink: 0; }

@media (max-width: 1000px) {
  .log-layout { grid-template-columns: minmax(0, 1fr); }
  .log-side { position: static; }
  .log-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .log-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log-filters .log-q, .log-actions { grid-column: 1 / -1; }
  .log-actions .btn { flex: 1; }
  .log-row { padding: 10px 12px; gap: 10px; }
  .log-time { width: 38px; font-size: 12.5px; }
  .stat-card { padding: 10px; gap: 8px; }
  .stat-card b { font-size: 19px; }
  .stat-ico { width: 34px; height: 34px; }
}

/* ---------- صفحات عامة ---------- */
.tile-tag--brass { background: var(--date-soft); border-color: var(--date-line); color: #a24a17; }
.tile--general { border-color: var(--date-line); }
.folder-path { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--line-2); font-size: 13.5px; font-weight: 700; color: var(--muted); }
.folder-path svg { width: 17px; height: 17px; color: var(--brass); }
.info-strip { margin-top: 30px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.info-strip-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.info-strip-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 800; color: var(--ink); }
.info-strip-head h2 svg { width: 18px; height: 18px; color: var(--brass); }
.info-strip-head h2 small { min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--date-soft); color: #a24a17; font-size: 11.5px; }
.info-strip-head a { font-size: 13px; font-weight: 700; color: var(--primary-hi); text-decoration: none; }
.info-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.info-chip.tile {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); box-shadow: none;
  font-size: 13.5px; font-weight: 700; color: var(--text);
}
.info-chip.tile:hover { transform: none; box-shadow: none; border-color: var(--brass); background: #fdf6f1; }
.info-chip svg { width: 16px; height: 16px; color: var(--brass); }
.info-chip small { font-weight: 500; color: var(--dim); font-size: 11.5px; }

.page-results { margin-top: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.page-results h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13.5px; font-weight: 800; color: var(--muted); }
.page-results h3 svg { width: 16px; height: 16px; color: var(--brass); }
.page-hit { display: flex; gap: 12px; padding: 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); text-decoration: none; color: var(--text); transition: border-color .15s, background-color .15s; }
.page-hit + .page-hit { margin-top: 8px; }
.page-hit:hover, .page-hit:focus-visible { border-color: var(--primary-line); background: #f6faf1; }
.hit-ico { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--date-soft); color: #a24a17; }
.hit-ico svg { width: 20px; height: 20px; }
.hit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hit-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; color: var(--ink); font-size: 15px; }
.hit-cat { font-size: 11.5px; font-weight: 700; padding: 0 7px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.hit-count { font-size: 12px; font-weight: 700; color: var(--primary-hi); }
.hit-snip { margin: 4px 0 2px; font-size: 13.5px; color: var(--text); line-height: 1.8; overflow-wrap: anywhere; }
.hit-snip mark { background: #fde9a8; color: var(--ink); padding: 0 2px; border-radius: 3px; font-weight: 700; }
.hit-meta { font-size: 12px; color: var(--dim); }

.tile-icon--page { background: var(--date-soft); color: #a24a17; }
.tile.is-off { opacity: .55; }
.news-ico--page { background: var(--date-soft); color: #a24a17; }
.news-main h3 a { color: inherit; text-decoration: none; }
.news-main h3 a:hover { color: var(--primary-hi); }
.head-actions { display: inline-flex; gap: 8px; }

/* عارض الصفحة */
.page-viewer { min-height: 100vh; }
.viewer { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.viewer-bar { position: sticky; top: 62px; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.viewer-bar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px clamp(14px, 3vw, 28px); }
.v-back { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.v-back:hover { color: var(--ink); background: var(--surface-2); }
.v-back svg { width: 16px; height: 16px; }
.v-title { flex: 1; min-width: 0; }
.v-title strong { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title strong svg { width: 18px; height: 18px; color: var(--brass); flex-shrink: 0; }
.v-title small { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.ro { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 5px; background: var(--success-soft); color: var(--success); font-weight: 800; font-size: 11.5px; }
.ro svg { width: 12px; height: 12px; }
.ro--edit { background: var(--primary-soft); color: var(--primary); }
.ro--off { background: var(--warn-soft); color: var(--warn); }
.v-actions { display: flex; gap: 6px; }
.v-actions .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }
.v-menu { position: relative; }
.v-menu summary { list-style: none; cursor: pointer; }
.v-menu summary::-webkit-details-marker { display: none; }
.v-ver { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.v-ver svg { width: 15px; height: 15px; color: var(--dim); }
.v-menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  width: 330px; max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 18px 40px -12px rgba(42, 36, 24, .25);
}
.v-menu-head { margin: 4px 8px 8px; font-size: 12px; color: var(--muted); }
.v-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.v-item:hover { background: var(--surface-2); }
.v-item b { display: block; font-size: 13px; color: var(--ink); text-align: right; }
.v-item small { display: block; font-size: 12px; color: var(--dim); }
.v-item-actions { display: inline-flex; align-items: center; gap: 6px; }
.v-item-actions form { margin: 0; }
.v-item-actions a, .v-item-actions button { font: inherit; font-size: 12.5px; font-weight: 700; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--primary-hi); text-decoration: none; cursor: pointer; }
.v-item-actions button:hover, .v-item-actions a:hover { border-color: var(--primary); }
.v-old { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 700; border-bottom: 1px solid #f0d998; }
.v-old svg { width: 16px; height: 16px; }
.v-old a { color: inherit; }
.viewer > .alert { max-width: 1180px; margin: 10px auto 0; width: calc(100% - 28px); }
.viewer-frame { flex: 1; width: 100%; border: 0; min-height: calc(100vh - 130px); background: #fff; display: block; }
.viewer-frame.is-image { background: var(--bg); }

@media (max-width: 760px) {
  .viewer-bar { top: 62px; }
  .viewer-bar-inner { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .v-title { order: -1; flex-basis: 100%; }
  .v-back .lbl, .v-actions .lbl, .v-ver .lbl { display: none; }
  .v-actions { margin-inline-start: auto; }
  .v-menu-panel { position: fixed; top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 70vh; }
  .viewer-frame { min-height: calc(100vh - 150px); }
  .info-strip { padding: 14px; }
}

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

@media print {
  .topbar, .site-foot, .search, .tile-go { display: none !important; }
  body { background: #fff; }
}
.page-pages .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.chip--edit input:checked + span { border-color: var(--date); color: #a24a17; background: var(--date-soft); }
.chip--edit input:checked + span::before { background-color: var(--date); }

/* صلاحيات الصفحات العامة في نموذج الحساب */
.page-perms { display: grid; gap: 8px; }
.page-perm { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.pp-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.pp-name svg { width: 18px; height: 18px; color: var(--brass); }
.pp-name small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; line-height: 1.3; }
.segmented--sm span { padding: 4px 12px; font-size: 13px; }
.perms[data-admin] .page-perms { opacity: .4; pointer-events: none; }
.perms legend svg { width: 18px; height: 18px; color: var(--brass); }

/* زر الرجوع في كل الصفحات */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 12px; margin-inline-end: 4px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px;
}
.back-btn:hover { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary); }
.back-btn svg { width: 18px; height: 18px; }
@media (max-width: 760px) { .back-btn { padding: 0; width: 38px; justify-content: center; margin-inline-end: 0; } .topbar-inner { gap: 8px; } }

/* زر التعديل في شريط الصفحة العامة */
.v-actions .btn--edit { background: var(--primary); border-color: var(--primary); color: #fff; }
.v-actions .btn--edit:hover { background: var(--primary-hi); }
.v-actions .btn--edit.is-on { background: #fff4e5; border-color: #e7a95a; color: #a24a17; }
@media (max-width: 760px) { .v-actions .btn--edit .lbl-e { display: inline; } }
