/* عناصر الواجهة: القائمة الليلية، والشريط العائم، وبطاقات الأرقام، والتبويبات، والجداول، والتنبيهات. */

* { box-sizing: border-box; border-color: var(--border); }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary) 32%, transparent) transparent;
}
html::-webkit-scrollbar { width: 10px; height: 10px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary) 32%, transparent);
  border: 3px solid var(--background);
  border-radius: var(--radius-full);
}
html::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--primary) 65%, transparent); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.6;
  background: var(--background);
  color: var(--foreground);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; line-height: 1.4; letter-spacing: -0.01em; }
p { margin: 0 0 0.5rem; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--primary-tint); color: var(--primary-text); }

.num, .mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.muted { color: var(--muted-foreground); }
.small { font-size: var(--text-micro); }
.nowrap { white-space: nowrap; }
.spacer { margin-inline-start: auto; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }

.custom-scrollbar { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--primary) 28%, transparent) transparent; }
.custom-scrollbar::-webkit-scrollbar { width: 5px; height: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted-foreground) 25%, transparent); border-radius: var(--radius-full); }
.no-scrollbar::-webkit-scrollbar { display: none; width: 0; height: 0; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ==========================================================================
   الهيكل: قائمة ليلية ثابتة، وشريط علوي عائم، والمحتوى في عمود محدود العرض
   ========================================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  flex: none;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-inline-start: 1px solid var(--sidebar-border);
  user-select: none;
  animation: sidebar-open 560ms var(--enter-ease) backwards;
}
/* وهجان خافتان يعطيان السطح الداكن عمقاً */
.sidebar::before, .sidebar::after {
  content: "";
  position: absolute;
  width: 256px; height: 256px;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.sidebar::before { top: -96px; inset-inline-start: -80px; background: rgba(99, 102, 241, 0.2); }
.sidebar::after { bottom: -112px; inset-inline-end: -96px; background: rgba(251, 191, 36, 0.1); }

.brand {
  position: relative;
  height: var(--header-height);
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.brand .mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e1b4b 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(79, 70, 229, 0.9);
}
.brand .mark svg { width: 20px; height: 20px; }
.brand .name { display: block; font-size: 13.5px; font-weight: 800; color: #fff; }
.brand .sub { display: block; font-size: var(--text-micro); color: var(--sidebar-muted); }

.nav {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--sidebar-muted);
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--sidebar-foreground);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--fast), color var(--fast);
  animation: nav-item-in 420ms var(--enter-ease) both;
  animation-delay: calc(200ms + var(--i, 0) * 35ms);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex: none; position: relative; transform: translateY(1.5px); }
.nav-item .tail {
  position: relative;
  margin-inline-start: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}
.nav-item .tail:empty { display: none; }
.nav-item[aria-selected="true"] { color: #fff; font-weight: 600; }
.nav-item[aria-selected="true"] svg { color: var(--sidebar-primary); }
/* العلامة النشطة: حقل متدرج وشريط ذهبي على الحافة */
.nav-item[aria-selected="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(to left, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.nav-item[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline-start: -12px;
  top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--sidebar-primary);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.7);
}
.nav-item > * { position: relative; }

.main { display: flex; min-width: 0; flex: 1; flex-direction: column; }

.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 16px 24px 0;
  animation: header-drop 620ms var(--enter-ease) 120ms both;
}
.topbar {
  margin: 0 auto;
  max-width: 1280px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 24px -20px rgba(20, 22, 58, 0.35);
  transition: box-shadow var(--base), background-color var(--base), border-color var(--base);
}
.topbar.scrolled {
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--card) 85%, transparent);
  box-shadow: var(--shadow-md);
}
.crumbs { display: flex; min-width: 0; align-items: center; gap: 6px; font-size: var(--text-body); }
.crumbs .where { color: var(--muted-foreground); }
.crumbs .sep-ico { width: 14px; height: 14px; color: var(--muted-foreground); flex: none; }
.crumbs h1 { font-size: var(--text-body); font-weight: 600; }

.page { padding: 16px 24px 32px; margin: 0 auto; width: 100%; max-width: 1280px; }
.page[hidden] { display: none; }

/* موجة الدخول: كل كتلة ترتفع وتصفو بعد التي قبلها */
.cascade > * {
  opacity: 0;
  animation: wave-in 460ms var(--enter-ease) both;
  animation-delay: calc(var(--shell-offset) + var(--wave, 0ms));
}
.cascade > :nth-child(1) { --wave: calc(var(--wave-step) * 1); }
.cascade > :nth-child(2) { --wave: calc(var(--wave-step) * 2); }
.cascade > :nth-child(3) { --wave: calc(var(--wave-step) * 3); }
.cascade > :nth-child(4) { --wave: calc(var(--wave-step) * 4); }
.cascade > :nth-child(5) { --wave: calc(var(--wave-step) * 5); }
.cascade > :nth-child(6) { --wave: calc(var(--wave-step) * 6); }
.cascade > :nth-child(7) { --wave: calc(var(--wave-step) * 7); }
.cascade > :nth-child(n + 8) { --wave: calc(var(--wave-step) * 8); }

/* ==========================================================================
   رأس الصفحة والعناوين
   ========================================================================== */
/* عنوان الصفحة: اسمه وحده، بلا أيقونة ولا خط، وبحجم أكبر */
.section-title.lead { margin-bottom: 18px; }
.section-title.lead h3 { font-size: var(--text-title); font-weight: 800; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title .side { display: flex; min-width: 0; flex: 1; align-items: center; gap: 10px; }
.section-title .ico-box {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}
.section-title .ico-box svg { width: 16px; height: 16px; }
/* الحرف العربي يجلس أخفض من منتصف سطره، فتُنزَّل الأيقونة والخط ليستويا معه في العين لا في الحساب */
.section-title .ico-box, .section-title .title-line { transform: translateY(0.5px); }
.section-title.lead h3 { transform: none; }
.section-title h3 { display: flex; min-width: 0; align-items: center; gap: 8px; font-size: var(--text-lead); font-weight: 700; }
.section-title h3 .count { font-size: var(--text-micro); font-weight: 600; color: var(--muted-foreground); }

/* الخط الفاصل ثنائي اللون */
.title-line {
  --line-color: var(--primary);
  --line-accent: #a5b4fc;
  position: relative;
  flex: 1;
  min-width: 48px;
  height: 12px;
  margin-inline-start: 14px;
  margin-inline-end: 8px;
  background: linear-gradient(to left, var(--line-color) 0%, var(--line-accent) 25%,
      color-mix(in srgb, var(--line-accent) 85%, var(--line-color)) 65%, var(--line-accent) 80%, transparent 100%)
      center / 100% 2px no-repeat;
}
.title-line::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  width: 22px; height: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(to left, var(--line-color), var(--line-accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--line-color) 20%, transparent),
              0 0 10px color-mix(in srgb, var(--line-accent) 40%, transparent);
  transform: translateY(-50%);
}
.title-line::after {
  content: "";
  position: absolute;
  inset-inline-start: 28px;
  top: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--line-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--line-accent) 25%, transparent),
              0 0 8px color-mix(in srgb, var(--line-accent) 50%, transparent);
  transform: translateY(-50%);
}
.title-line.tone-amber { --line-color: #d97706; --line-accent: #fbbf24; }

/* ==========================================================================
   البطاقات
   ========================================================================== */
.card {
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: var(--text-lead); font-weight: 700; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* صف داخل قائمة بطاقة: يرتفع ويتلون عند المرور */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--background) 50%, transparent);
  transition: all var(--base);
}
.list-row:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  background: var(--card);
  box-shadow: 0 8px 20px -14px rgba(79, 70, 229, 0.5);
}
.list-row + .list-row { margin-top: 10px; }

/* ==========================================================================
   بطاقة الرقم: حزّ علوي، ووهج زاوية، وأيقونة تميل، وخط ينزلق في الأسفل
   ========================================================================== */
.stat-card {
  --tone: var(--primary);
  --tone-soft: color-mix(in srgb, var(--tone) 12%, transparent);
  position: relative;
  z-index: 0;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  padding: 16px 18px 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: inherit;
  box-shadow: var(--shadow-sm);
  transform-origin: center;
  transition: transform 0.28s cubic-bezier(0.34, 1.45, 0.64, 1), border-color 0.24s ease,
              box-shadow 0.28s ease, background-color 0.24s ease;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 18px;
  top: 0;
  width: 44px; height: 3.5px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--tone), color-mix(in srgb, var(--tone) 50%, var(--primary)));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--tone) 35%, transparent);
  z-index: 2;
}
.stat-card::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset-inline-end: -44px;
  top: -44px;
  width: 148px; height: 148px;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 45%, color-mix(in srgb, var(--tone) 24%, transparent) 0%,
      color-mix(in srgb, var(--tone) 12%, transparent) 46%, transparent 72%);
  opacity: 0.35;
  transform: scale(0.85) rotate(-10deg);
  transition: transform 0.38s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.28s ease;
  pointer-events: none;
}
.stat-card:hover {
  z-index: 20;
  transform: translateY(-6px) scale(1.032);
  border-color: color-mix(in srgb, var(--tone) 45%, var(--border));
  background: color-mix(in srgb, var(--tone) 4.5%, var(--card));
  box-shadow: 0 22px 42px -16px color-mix(in srgb, var(--tone) 55%, rgba(15, 23, 42, 0.38)),
              0 0 0 1px color-mix(in srgb, var(--tone) 25%, transparent);
}
.stat-card:hover::after { opacity: 0.95; transform: scale(1.15) rotate(0deg); }

.stat-card-main {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}
.stat-copy { min-width: 0; flex: 1; }
.stat-label { margin: 0; color: var(--muted-foreground); font-size: 0.73rem; font-weight: 750; letter-spacing: -0.01em; }
.stat-value {
  display: block;
  margin-top: 5px;
  font-size: 1.62rem;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.025em;
  transition: transform 0.26s cubic-bezier(0.2, 0.85, 0.25, 1), color 0.22s;
}
.stat-card:hover .stat-value { transform: translateY(-1px); color: color-mix(in srgb, var(--foreground) 88%, var(--tone)); }
.stat-icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--tone-soft);
  color: var(--tone);
  border: 1px solid color-mix(in srgb, var(--tone) 16%, transparent);
  transition: transform 0.3s cubic-bezier(0.2, 0.85, 0.25, 1), background-color 0.24s, box-shadow 0.28s, color 0.24s;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-card:hover .stat-icon {
  transform: translate3d(-4px, -4px, 0) rotate(-6deg) scale(1.09);
  color: color-mix(in srgb, var(--tone) 88%, white);
  background: color-mix(in srgb, var(--tone) 16%, var(--card));
  box-shadow: 0 10px 20px -14px var(--tone);
}
.stat-card-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin-top: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--muted) 70%, var(--card));
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 650;
  transition: border-color 0.22s, background-color 0.22s, transform 0.22s;
}
.stat-card-footer > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card:hover .stat-card-footer {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--tone) 22%, var(--border));
  background: color-mix(in srgb, var(--tone) 5%, var(--card));
}
.sub-dot {
  width: 6px; height: 6px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--tone) 18%, transparent);
}
.sub-dot.live { animation: soft-pulse 1.8s ease-in-out infinite; }
.stat-accent {
  position: absolute;
  z-index: 4;
  inset-inline-start: 0;
  bottom: 0;
  width: 0; height: 3px;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: linear-gradient(90deg, var(--tone), color-mix(in srgb, var(--tone) 45%, var(--primary)));
  box-shadow: 0 -2px 10px color-mix(in srgb, var(--tone) 35%, transparent);
  transition: width 0.38s cubic-bezier(0.2, 0.85, 0.25, 1);
}
.stat-card:hover .stat-accent { width: 100%; }

.stat-card.tone-primary { --tone: var(--primary); }
.stat-card.tone-accent { --tone: #f5a524; --tone-soft: color-mix(in srgb, var(--tone) 14%, transparent); }
.stat-card.tone-success { --tone: color-mix(in srgb, #10b981 82%, var(--primary)); --tone-soft: color-mix(in srgb, var(--tone) 13%, transparent); }
.stat-card.tone-warning { --tone: color-mix(in srgb, #f59e0b 86%, var(--primary)); --tone-soft: color-mix(in srgb, var(--tone) 13%, transparent); }
.stat-card.tone-info { --tone: color-mix(in srgb, #0ea5e9 82%, var(--primary)); --tone-soft: color-mix(in srgb, var(--tone) 13%, transparent); }
.stat-card.tone-purple { --tone: color-mix(in srgb, #8b5cf6 80%, var(--primary)); --tone-soft: color-mix(in srgb, var(--tone) 13%, transparent); }

/* ==========================================================================
   الأزرار والحقول
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  white-space: nowrap;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font-family: inherit;
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--fast), color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 30%, transparent); }
.btn[disabled] { pointer-events: none; opacity: 0.5; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 8px 20px -12px rgba(79, 70, 229, 0.8); }
.btn.outline { border: 1px solid var(--border-strong); background: var(--card); color: var(--foreground); }
.btn.outline:hover { background: var(--muted); }
.btn.secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn.secondary:hover { background: color-mix(in srgb, var(--primary-tint) 70%, var(--card)); }
.btn.ghost { background: transparent; color: var(--muted-foreground); }
.btn.ghost:hover { background: var(--muted); color: var(--foreground); }
.btn.danger { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.accent { background: var(--accent); color: var(--accent-foreground); }
.btn.accent:hover { background: var(--accent-hover); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--fast), color var(--fast), border-color var(--fast);
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--muted-foreground); }
.field .note { font-size: var(--text-micro); color: var(--muted-foreground); }

input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: var(--text-body);
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--fast), box-shadow var(--fast);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 96px; line-height: 1.9; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.tight { gap: 6px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-body); cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--muted); border-radius: var(--radius-md); }
.segmented button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 6px 13px;
  border-radius: var(--radius);
  transition: all var(--fast);
}
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--primary-text); box-shadow: var(--shadow-xs); }

/* شريط تبويبات داخلي بخط سفلي منزلق */
.tabbar { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabbar button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--fast);
}
.tabbar button:hover { color: var(--foreground); }
.tabbar button[aria-selected="true"] { color: var(--primary); }
.tabbar button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline: 8px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  animation: fade 180ms both;
}

/* ==========================================================================
   الشارات والتنبيهات
   ========================================================================== */
.badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--text-micro);
  font-weight: 700;
}
.badge .dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }
.badge.live .dot { animation: soft-pulse 1.6s ease-in-out infinite; }
.badge.ok { border-color: color-mix(in srgb, var(--success) 25%, transparent); background: var(--success-soft); color: var(--success); }
.badge.warn { border-color: color-mix(in srgb, var(--warning) 25%, transparent); background: var(--warning-soft); color: var(--warning); }
.badge.bad { border-color: color-mix(in srgb, var(--danger) 25%, transparent); background: var(--danger-soft); color: var(--danger); }
.badge.info { border-color: color-mix(in srgb, var(--info) 25%, transparent); background: var(--info-soft); color: var(--info); }
.badge.primary { border-color: color-mix(in srgb, var(--primary) 25%, transparent); background: var(--primary-tint); color: var(--primary-text); }

.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  font-size: 13.5px;
  color: var(--muted-foreground);
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.notice.ok { border-color: color-mix(in srgb, var(--success) 25%, transparent); background: var(--success-soft); color: var(--success); }
.notice.warn { border-color: color-mix(in srgb, var(--warning) 25%, transparent); background: var(--warning-soft); color: var(--warning); }
.notice.bad { border-color: color-mix(in srgb, var(--danger) 25%, transparent); background: var(--danger-soft); color: var(--danger); }
.notice.info { border-color: color-mix(in srgb, var(--info) 25%, transparent); background: var(--info-soft); color: var(--info); }
.notice + .notice { margin-top: 8px; }

/* التنبيه المنبثق بشريط وقت متناقص */
/* تظهر في الجهة المقابلة للقائمة الجانبية، فلا تغطّيها */
.toasts {
  position: fixed;
  top: 24px;
  inset-inline-end: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: calc(100% - 48px);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  animation: toast-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast.leaving { animation: fade 180ms reverse both; }
.toast.ok { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.toast.warn { border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.toast-body { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.toast-icon {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
}
.toast-icon svg { width: 18px; height: 18px; }
.toast.ok .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.bad .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast.warn .toast-icon { background: var(--warning-soft); color: var(--warning); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--foreground); }
.toast-message { margin: 2px 0 0; font-size: 12.5px; font-weight: 500; line-height: 1.55; color: var(--muted-foreground); word-break: break-word; }
.toast-timer { height: 3px; width: 100%; }
.toast.ok .toast-timer { background: linear-gradient(90deg, var(--success), #a5b4fc); animation: toast-timer-drain 5s linear forwards; }
.toast.bad .toast-timer { background: linear-gradient(90deg, var(--danger), #f87171); animation: toast-timer-drain 7s linear forwards; }
.toast.warn .toast-timer { background: linear-gradient(90deg, var(--accent), #fbbf24); animation: toast-timer-drain 5s linear forwards; }

/* ==========================================================================
   أشرطة التقدم والحلقة
   ========================================================================== */
.bar { height: 8px; border-radius: var(--radius-full); background: var(--muted); overflow: hidden; }
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #a5b4fc);
  transition: width var(--slow);
}
.bar.live > i {
  background-image: linear-gradient(90deg, var(--primary), #a5b4fc),
    repeating-linear-gradient(60deg, rgba(255, 255, 255, 0.22) 0 10px, transparent 10px 22px);
  background-size: 100% 100%, 44px 100%;
  animation: bar-stripes 1s linear infinite;
}
.bar.thin { height: 6px; }

.ring { --p: 0; width: 132px; height: 132px; flex: none; display: grid; place-items: center; position: relative; }
.ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--muted) 0);
  transition: --p var(--slow);
}
.ring::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--card); }
.ring .inside { position: relative; text-align: center; line-height: 1.3; }
.ring .inside b { display: block; font-size: 25px; font-weight: 900; letter-spacing: -0.02em; }
.ring .inside span { font-size: 11.5px; color: var(--muted-foreground); }

/* ==========================================================================
   الجداول
   ========================================================================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-body); }
thead th {
  position: sticky;
  top: 0;
  padding: 11px 14px;
  background: color-mix(in srgb, var(--muted) 70%, var(--card));
  border-bottom: 1px solid var(--border);
  text-align: start;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted-foreground);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color 0.18s cubic-bezier(0.2, 0.85, 0.25, 1), box-shadow 0.18s; }
tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5.5%, var(--card));
  box-shadow: inset -3.5px 0 0 var(--primary), inset -8px 0 16px color-mix(in srgb, var(--primary) 12%, transparent);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   الحالات الفارغة والانتظار
   ========================================================================== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  text-align: center;
}
.empty .ico {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--primary-tint) 40%, transparent);
  color: var(--primary);
}
.empty .ico svg { width: 24px; height: 24px; }
.empty b { font-size: var(--text-lead); font-weight: 700; color: var(--foreground); }
.empty .hint { margin-top: 8px; max-width: 48ch; font-size: var(--text-body); color: var(--muted-foreground); }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.skeleton { display: block; height: 16px; border-radius: var(--radius); background: var(--muted); animation: soft-pulse 1.6s ease-in-out infinite; }
.skeleton + .skeleton { margin-top: 10px; }
.skeleton.tall { height: 72px; }
.skeleton.w70 { width: 70%; }
.skeleton.w45 { width: 45%; }

/* اللوح الجانبي */
.drawer-back { position: fixed; inset: 0; z-index: 70; background: rgba(13, 15, 31, 0.45); backdrop-filter: blur(2px); animation: fade var(--fast) both; }
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 71;
  width: min(560px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-inline-end: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: nav-item-in 280ms var(--enter-ease) both;
}
.drawer header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer header h3 { font-size: var(--text-lead); }
.drawer .body { padding: 18px 20px; overflow-y: auto; }

details.disclose { border: 1px solid var(--border); border-radius: var(--radius-md); background: color-mix(in srgb, var(--muted) 50%, var(--card)); }
details.disclose + details.disclose { margin-top: 8px; }
details.disclose > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  font-size: var(--text-body); font-weight: 600;
  cursor: pointer; list-style: none;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before { content: "‹"; font-size: 18px; color: var(--muted-foreground); transition: transform var(--fast); }
details.disclose[open] > summary::before { transform: rotate(-90deg); }
details.disclose > .inner { padding: 0 14px 14px; animation: fade var(--base) both; }

.scroll-y { overflow-y: auto; }

/* ==========================================================================
   الشاشات الصغيرة
   ========================================================================== */
@media (hover: none) {
  .stat-card:hover { transform: none; }
  .stat-card:active { transform: scale(0.98); }
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    transform: translateX(100%);
    transition: transform var(--base);
    animation: none;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar-wrap { padding: 12px 16px 0; }
  .page { padding: 14px 16px 28px; }
}

@media (max-width: 639px) {
  .stat-card { min-height: 0; gap: 8px; padding: 14px; border-radius: var(--radius-lg); }
  .stat-card::before { inset-inline-start: 14px; width: 32px; }
  .stat-card-main { flex-direction: column-reverse; align-items: flex-start; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 12px; }
  .stat-value { font-size: 1.375rem; margin-top: 2px; }
  .stat-card-footer { display: none; }
  .toasts { top: 16px; inset-inline: 16px; width: auto; max-width: none; }
}

@media (min-width: 1024px) { .only-small { display: none !important; } }

/* القسم: عنوانه فوق الحاوية لا داخلها */
.block { display: flex; flex-direction: column; min-width: 0; }
.block > .section-title { margin-bottom: 12px; }
.block > .card { flex: 1; }
.block + .block, .card + .block, .block + .card { margin-top: 20px; }
/* كل قسم في الصفحة على بعد واحد من الذي قبله، أياً كان نوعه */
.page > * + * { margin-top: 20px; }
/* داخل شبكة، المسافة من الشبكة نفسها، فلا يُزاح عنصر عن صفّه فتختلّ موازاة الصف */
.grid > .block + .block, .grid > .block + .card, .grid > .card + .block, .grid > .card + .card { margin-top: 0; }

/* ==========================================================================
   شريط الفلترة والبحث: صندوق مستقل فوق البيانات — تبويبات سريعة، ثم بحث
   ومنتقيات وترتيب، ثم الفلاتر النشطة وعدد النتائج. منقول أسلوباً من منصة السوق.
   ========================================================================== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}
.fb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fb-row.split { padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }

/* تبويبات سريعة */
.fb-tabs { display: flex; align-items: center; gap: 6px; overflow-x: auto; min-width: 0; }
.fb-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  color: var(--muted-foreground);
  font-family: inherit;
  font-size: var(--text-micro);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all var(--fast);
}
.fb-tab:hover { background: var(--muted); color: var(--foreground); }
.fb-tab svg { width: 14px; height: 14px; flex: none; }
.fb-tab[aria-selected="true"] {
  background: var(--primary);
  border-color: transparent;
  color: var(--primary-foreground);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}
.fb-tab .n {
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--muted-foreground) 15%, transparent);
  font-size: 10.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.fb-tab[aria-selected="true"] .n { background: rgba(255, 255, 255, 0.22); color: var(--primary-foreground); }

/* البحث */
.fb-search { position: relative; flex: 1; min-width: 240px; }
.fb-search input {
  height: 40px;
  padding-inline-start: 40px;
  padding-inline-end: 38px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card) 60%, transparent);
  font-size: var(--text-micro);
}
.fb-search input:hover { background: var(--card); }
.fb-search > svg {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.fb-clear {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.fb-clear:hover { background: var(--muted); color: var(--foreground); }
.fb-clear[hidden] { display: none; }

/* المنتقيات والترتيب */
.fb-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-select { position: relative; min-width: 150px; }
.fb-select select {
  width: 100%;
  height: 40px;
  padding-inline-start: 36px;
  padding-inline-end: 30px;
  appearance: none;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--card) 60%, transparent);
  font-size: var(--text-micro);
  font-weight: 600;
  cursor: pointer;
}
.fb-select select:hover { background: var(--card); }
.fb-select > svg { position: absolute; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted-foreground); }
.fb-select > svg.lead { inset-inline-start: 12px; width: 16px; height: 16px; }
.fb-select > svg.tail { inset-inline-end: 12px; width: 14px; height: 14px; opacity: 0.8; }

.fb-reset {
  height: 40px;
  padding: 0 12px;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--danger);
  font-family: inherit;
  font-size: var(--text-micro);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.fb-reset:hover { background: var(--danger-soft); }
.fb-reset svg { width: 14px; height: 14px; }

/* الفلاتر النشطة وعدد النتائج */
.fb-active { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--text-micro); }
.fb-active .label { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--muted-foreground); }
.fb-active .label svg { width: 13px; height: 13px; color: var(--primary); }
.fb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 700;
  animation: fade var(--fast) both;
}
.fb-chip .of { color: var(--muted-foreground); font-weight: 500; }
.fb-chip button {
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.fb-chip button:hover { background: color-mix(in srgb, var(--primary) 20%, transparent); }
.fb-chip svg { width: 12px; height: 12px; }
.fb-count { margin-inline-start: auto; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted-foreground); }
.fb-count b { color: var(--foreground); }

/* عدد السطور والتنقل */
.fb-pager { display: flex; align-items: center; gap: 10px; flex: none; }
.fb-size, .fb-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
}
.fb-size select {
  height: 24px;
  width: auto;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fb-nav button {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.fb-nav button:hover:not([disabled]) { background: var(--card); color: var(--foreground); }
.fb-nav button[disabled] { opacity: 0.3; cursor: not-allowed; }
.fb-nav svg { width: 15px; height: 15px; }
.fb-nav .at { padding: 0 4px; font-size: var(--text-micro); font-weight: 700; color: var(--foreground); white-space: nowrap; }
.fb-nav .at b { color: var(--primary); font-weight: 900; font-variant-numeric: tabular-nums; }
.fb-nav .at span { font-weight: 400; color: var(--muted-foreground); }

/* ==========================================================================
   وضع الجوال: شريط التطبيق أعلى، وتنقّل سفلي، كما في منصة الأكاديمية
   ========================================================================== */
.app-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 35;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(20px);
  transition: border-color var(--base), box-shadow var(--base);
}
.app-bar.scrolled { border-bottom-color: var(--border); box-shadow: 0 8px 20px -16px rgba(20, 22, 58, 0.35); }
.app-bar-row { display: flex; height: 56px; align-items: center; gap: 12px; padding: 0 16px; }
.app-bar-text { min-width: 0; flex: 1; line-height: 1.25; }
.app-bar-text h1 { margin: 0; font-size: 1.0625rem; font-weight: 800; }
/* بلا هامشٍ أسفل السطر الثاني: لولا ذلك لعلا الاسمان عن مركز العلامة بأربعة بكسلات */
.app-bar-text p { margin: 0; font-size: var(--text-micro); font-weight: 500; color: var(--muted-foreground); }
.app-bar-text h1, .app-bar-text p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* زر دائري بقياس الإصبع: 40 بكسلاً، وينكمش عند اللمس فيُحَسّ به */
.round-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--muted-foreground);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
  cursor: pointer;
  transition: transform var(--fast);
  -webkit-tap-highlight-color: transparent;
}
.round-btn:active { transform: scale(0.9); }
.round-btn.install { background: var(--primary-tint); color: var(--primary-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent); }
.round-btn.brand {
  background: linear-gradient(135deg, #6366f1, #3730a3);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(79, 70, 229, 0.8), inset 0 0 0 2px var(--card);
}

/* شريط التنقّل السفلي: أربع وجهات و«المزيد» يفتح القائمة كاملة */
.tabbar {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: 0 -8px 24px -18px rgba(20, 22, 58, 0.35);
}
/* القائمة تبدأ من الحافة: للمتصفح حشوٌ افتراضي 40 بكسلاً في أولها، ولو تُرك
   لانزاحت الوجهات الخمس عن اليمين وبقي فراغ في طرف الشريط. */
.tabbar ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: 64px; margin: 0 auto; padding: 0; max-width: 32rem; list-style: none; }
.tabbar button {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: none;
  cursor: pointer;
  user-select: none;
  transition: transform var(--fast);
  -webkit-tap-highlight-color: transparent;
}
.tabbar button:active { transform: scale(0.9); }
.tabbar .slot { position: relative; display: grid; place-items: center; width: min(56px, 100%); height: 32px; }
/* الحبّة خلف أيقونة المفتوح تنزلق من وجهة إلى وجهة بدل أن تقفز */
.tabbar .slot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--primary-tint);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--base), transform var(--base);
}
.tabbar [aria-current="page"] .slot::before { opacity: 1; transform: none; }
.tabbar .slot svg { position: relative; color: var(--muted-foreground); transition: color var(--base), transform var(--base); }
.tabbar [aria-current="page"] .slot svg { color: var(--primary); transform: translateY(-1px); stroke-width: 2.2; }
/* وزن الخط واحد في الحالين، فلا يتسع الاسم عند فتحه فيُقصّ بثلاث نقاط */
.tabbar .tab-label { white-space: nowrap; font-size: 0.6875rem; line-height: 1; font-weight: 600; color: var(--muted-foreground); transition: color var(--base); }
.tabbar [aria-current="page"] .tab-label { color: var(--primary); }

/* ستارة تحت القائمة المنسدلة على الجوال، فيُغلق بلمسة خارجها.
   وهي فوق شريط التنقّل أيضاً، فلا يبقى جزء من الواجهة مضيئاً خلف القائمة. */
.sidebar-back {
  position: fixed;
  inset: 0;
  z-index: 41;
  background: rgba(13, 15, 31, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--base);
}
body.nav-open .sidebar-back { opacity: 1; pointer-events: auto; }

/* بطاقة التثبيت: تظهر متى عرض المتصفح التثبيت، وتُخفى إن رُفضت */
.install-card { display: flex; align-items: center; gap: 12px; }
.install-card .ico-box { flex: none; }
.install-card .grow { min-width: 0; flex: 1; }

@media (max-width: 1023px) {
  .app-bar { display: block; }
  .tabbar { display: block; }
  .topbar-wrap { display: none; }
  .sidebar { z-index: 42; }
  .page { padding-bottom: calc(64px + env(safe-area-inset-bottom) + 24px); }
}
@media (min-width: 1024px) { .only-wide-none { display: none !important; } }

/* داخل التطبيق المثبَّت لا شريط عنوان للمتصفح، فيُفسح للشريط العلوي قدر شريط الحالة */
@media (display-mode: standalone) {
  .app-bar { background: color-mix(in srgb, var(--background) 96%, transparent); }
}

/* بطاقات الأرقام اثنتين في السطر على الجوال واللوح، فتُقرأ الأربع بنظرة، ولا يبقى
   في السطر الأخير بطاقة وحيدة كما يحدث لو وُزّعت بحسب عرضٍ أدنى. */
@media (max-width: 1023px) {
  .grid.cols-4:has(> .stat-card), .grid.cols-3:has(> .stat-card), .grid.cols-2:has(> .stat-card) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  /* وإن كُنّ وتراً فالأخيرة تملأ سطرها، فلا تبقى بطاقة في نصف سطر وجنبها فراغ */
  .grid:has(> .stat-card) > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 639px) {
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: var(--text-micro); }
  .tabbar .tab-label { font-size: 0.625rem; }

  /* عنوان القسم على الجوال: الشاشة ضيقة فقد ينزل العنوان سطرين، فتُحاذى الأيقونة
     والخط بالسطر الأول لا بوسط الكتلة، وإلا بدت الأيقونة هابطة عن اسمها. */
  .section-title { align-items: flex-start; }
  .section-title .side { align-items: flex-start; }
  .section-title .ico-box {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    transform: translateY(-1.5px);           /* وسط السطر الأول: (22.4 − 26) ÷ 2 */
  }
  .section-title .ico-box svg { width: 15px; height: 15px; }
  /* ويضيق موضع الخط، فيبقى للاسم عرضٌ يكفيه في سطر واحد */
  .section-title .title-line {
    min-width: 24px;
    margin-inline-start: 10px;
    margin-inline-end: 0;
    transform: translateY(5.2px);             /* وسط السطر الأول: (22.4 − 12) ÷ 2 */
  }
  .section-title .side > h3 { flex: 0 1 auto; }

  /* شريط الفلترة على الجوال: البحث سطراً كاملاً، والمنتقيات شبكة من عمودين
     بلا فراغ في نصف السطر، فيستوي الشريط ولا تتناثر أدواته. */
  .filter-bar { gap: 12px; padding: 14px; }
  .fb-search { flex: 1 0 100%; min-width: 0; }
  .fb-controls { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fb-select { min-width: 0; }
  .fb-select select { padding-inline: 34px 30px; }
  .fb-reset { justify-content: center; }
  .fb-pager { width: 100%; justify-content: space-between; }
  .fb-active { width: 100%; }
}
